Skip to content

Commit

Permalink
fix: count SECP256 precompile to account validation gas limit as well (
Browse files Browse the repository at this point in the history
…#2859)

Account validation counts all the precompile's extra gas costs. This PR
adds a missing precompile.
  • Loading branch information
joonazan committed Sep 12, 2024
1 parent ccf1b63 commit fee0c2a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions core/lib/constants/src/contracts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ pub const SHA256_PRECOMPILE_ADDRESS: Address = H160([
0x00, 0x00, 0x00, 0x02,
]);

pub const SECP256R1_VERIFY_PRECOMPILE_ADDRESS: Address = H160([
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x01, 0x00,
]);

pub const EC_ADD_PRECOMPILE_ADDRESS: Address = H160([
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x06,
Expand Down
4 changes: 3 additions & 1 deletion core/lib/multivm/src/versions/vm_latest/tracers/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ use zk_evm_1_5_0::{
},
};
use zksync_system_constants::{
ECRECOVER_PRECOMPILE_ADDRESS, KECCAK256_PRECOMPILE_ADDRESS, SHA256_PRECOMPILE_ADDRESS,
ECRECOVER_PRECOMPILE_ADDRESS, KECCAK256_PRECOMPILE_ADDRESS,
SECP256R1_VERIFY_PRECOMPILE_ADDRESS, SHA256_PRECOMPILE_ADDRESS,
};
use zksync_types::U256;
use zksync_utils::u256_to_h256;
Expand Down Expand Up @@ -187,6 +188,7 @@ pub(crate) fn computational_gas_price(
if address == KECCAK256_PRECOMPILE_ADDRESS
|| address == SHA256_PRECOMPILE_ADDRESS
|| address == ECRECOVER_PRECOMPILE_ADDRESS
|| address == SECP256R1_VERIFY_PRECOMPILE_ADDRESS
{
data.src1_value.value.low_u32()
} else {
Expand Down

0 comments on commit fee0c2a

Please sign in to comment.