From baaa36d9bbb52e58086b9874e664895470ee239b Mon Sep 17 00:00:00 2001 From: Shawn Date: Thu, 22 Aug 2024 10:33:25 +0800 Subject: [PATCH] Factorise the PopVerify() gas-price. --- zilliqa/src/constants.rs | 3 +++ zilliqa/src/precompiles/pop_verify.rs | 8 +++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/zilliqa/src/constants.rs b/zilliqa/src/constants.rs index 55fc7216e..ad11511e4 100644 --- a/zilliqa/src/constants.rs +++ b/zilliqa/src/constants.rs @@ -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; diff --git a/zilliqa/src/precompiles/pop_verify.rs b/zilliqa/src/precompiles/pop_verify.rs index 3d31b5cb4..d6ec532d5 100644 --- a/zilliqa/src/precompiles/pop_verify.rs +++ b/zilliqa/src/precompiles/pop_verify.rs @@ -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)); } @@ -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(), )) }