Skip to content

Commit 365c584

Browse files
SDartayetLeandro Serra
authored andcommitted
fix(l1): fix P256 precompile name in eth_config response (#5418)
**Motivation** Complicance with the RPC spec **Description** When we added the eth_config endpoint, there were no Osaka test cases, so we used a (plausible) placeholder name for the precompile introduced by [EIP-7951](https://eips.ethereum.org/EIPS/eip-7951). Now there [are test cases](https://github.com/ethereum/execution-specs/blob/1e99293904cf3efc4c82834cc30159cfeb66f299/packages/testing/src/execution_testing/cli/pytest_commands/plugins/execute/eth_config/tests/test_execute_eth_config.py#L228) indicating the expected name for this precompile, which is different than the one we used. This PR fixed the naming for the precompile. Additionally, a bug with the `get_fork` function was fixed where the BPO forks weren't being considered.
1 parent 51df32c commit 365c584

3 files changed

Lines changed: 19 additions & 10 deletions

File tree

crates/common/types/genesis.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,17 @@ impl ChainConfig {
421421
}
422422

423423
pub fn get_fork(&self, block_timestamp: u64) -> Fork {
424-
if self.is_osaka_activated(block_timestamp) {
424+
if self.is_bpo5_activated(block_timestamp) {
425+
Fork::BPO5
426+
} else if self.is_bpo4_activated(block_timestamp) {
427+
Fork::BPO4
428+
} else if self.is_bpo3_activated(block_timestamp) {
429+
Fork::BPO3
430+
} else if self.is_bpo2_activated(block_timestamp) {
431+
Fork::BPO2
432+
} else if self.is_bpo1_activated(block_timestamp) {
433+
Fork::BPO1
434+
} else if self.is_osaka_activated(block_timestamp) {
425435
Fork::Osaka
426436
} else if self.is_prague_activated(block_timestamp) {
427437
Fork::Prague

crates/networking/rpc/rpc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -948,7 +948,7 @@ mod tests {
948948
"ID": "0x0000000000000000000000000000000000000004",
949949
"KZG_POINT_EVALUATION": "0x000000000000000000000000000000000000000a",
950950
"MODEXP": "0x0000000000000000000000000000000000000005",
951-
"P256_VERIFICATION":"0x0000000000000000000000000000000000000100",
951+
"P256VERIFY":"0x0000000000000000000000000000000000000100",
952952
"RIPEMD160": "0x0000000000000000000000000000000000000003",
953953
"SHA256": "0x0000000000000000000000000000000000000002"
954954
},

crates/vm/levm/src/precompiles.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -255,12 +255,12 @@ pub const BLS12_MAP_FP2_TO_G2: Precompile = Precompile {
255255
active_since_fork: Prague,
256256
};
257257

258-
pub const P256_VERIFICATION: Precompile = Precompile {
258+
pub const P256VERIFY: Precompile = Precompile {
259259
address: H160([
260260
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
261261
0x00, 0x00, 0x00, 0x01, 0x00,
262262
]),
263-
name: "P256_VERIFICATION",
263+
name: "P256VERIFY",
264264
active_since_fork: Osaka,
265265
};
266266

@@ -283,7 +283,7 @@ pub const PRECOMPILES: [Precompile; 19] = [
283283
BLS12_MAP_FP2_TO_G2,
284284
BLS12_MAP_FP_TO_G1,
285285
BLS12_PAIRING_CHECK,
286-
P256_VERIFICATION,
286+
P256VERIFY,
287287
];
288288

289289
pub fn precompiles_for_fork(fork: Fork) -> impl Iterator<Item = Precompile> {
@@ -293,7 +293,7 @@ pub fn precompiles_for_fork(fork: Fork) -> impl Iterator<Item = Precompile> {
293293
}
294294

295295
pub fn is_precompile(address: &Address, fork: Fork, vm_type: VMType) -> bool {
296-
(matches!(vm_type, VMType::L2(_)) && *address == P256_VERIFICATION.address)
296+
(matches!(vm_type, VMType::L2(_)) && *address == P256VERIFY.address)
297297
|| precompiles_for_fork(fork).any(|precompile| precompile.address == *address)
298298
}
299299

@@ -329,10 +329,9 @@ pub fn execute_precompile(
329329
Some(bls12_map_fp_to_g1 as PrecompileFn);
330330
precompiles[BLS12_MAP_FP2_TO_G2.address.0[19] as usize] =
331331
Some(bls12_map_fp2_tp_g2 as PrecompileFn);
332-
precompiles[u16::from_be_bytes([
333-
P256_VERIFICATION.address.0[18],
334-
P256_VERIFICATION.address.0[19],
335-
]) as usize] = Some(p_256_verify as PrecompileFn);
332+
precompiles
333+
[u16::from_be_bytes([P256VERIFY.address.0[18], P256VERIFY.address.0[19]]) as usize] =
334+
Some(p_256_verify as PrecompileFn);
336335
precompiles
337336
};
338337

0 commit comments

Comments
 (0)