Skip to content

Commit

Permalink
Factorise the PopVerify() gas-price.
Browse files Browse the repository at this point in the history
  • Loading branch information
shawn-zil committed Aug 28, 2024
1 parent e5b4d08 commit ce75b24
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
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

0 comments on commit ce75b24

Please sign in to comment.