Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Factorise the PopVerify() gas-price. #1335

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions zilliqa/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ pub const EVM_MAX_INIT_CODE_SIZE: usize = 2 * EVM_MAX_CODE_SIZE;
// Minimum gas required for EVM transaction (without input data)
pub const EVM_MIN_GAS_UNITS: EvmGas = EvmGas(21000);

// Gas used for verifying proof of posession
pub const EVM_POP_VERIFY_GAS_PRICE: EvmGas = EvmGas(1_000_000);

// Maximum code size allowed for zil transactions (imported from ZQ1)
pub const ZIL_MAX_CODE_SIZE: usize = 76800;

Expand Down
8 changes: 3 additions & 5 deletions zilliqa/src/precompiles/pop_verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,18 @@ use revm::{
ContextStatefulPrecompile, InnerEvmContext,
};

use crate::state::State;
use crate::{constants::EVM_POP_VERIFY_GAS_PRICE, state::State};

pub struct PopVerify;

// keep in-sync with zilliqa/src/contracts/deposit.sol
impl PopVerify {
const POP_VERIFY_GAS_PRICE: u64 = 1_000_000u64; // FIXME: Gas Price?
fn pop_verify(
input: &[u8],
gas_limit: u64,
_context: &mut InnerEvmContext<&State>,
) -> PrecompileResult {
if gas_limit < Self::POP_VERIFY_GAS_PRICE {
if gas_limit < EVM_POP_VERIFY_GAS_PRICE.0 {
return Err(PrecompileErrors::Error(PrecompileError::OutOfGas));
}

Expand All @@ -47,10 +46,9 @@ impl PopVerify {

let result = pop.verify(pk).is_ok();

// FIXME: Gas?
let output = encode(&[Token::Bool(result)]);
Ok(PrecompileOutput::new(
Self::POP_VERIFY_GAS_PRICE,
EVM_POP_VERIFY_GAS_PRICE.0,
output.into(),
))
}
Expand Down
Loading