Skip to content

Commit de157f6

Browse files
committed
fix(precompiles): gate PQ verifier on Zero6
1 parent 3f1efe9 commit de157f6

1 file changed

Lines changed: 21 additions & 7 deletions

File tree

‎crates/precompiles/src/precompile_provider.rs‎

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use crate::pq::{run_pq, PQ_ADDRESS};
2222
use crate::system_accounting::{run_system_accounting, SYSTEM_ACCOUNTING_ADDRESS};
2323
use alloy_evm::precompiles::PrecompilesMap;
2424
use alloy_primitives::Address;
25-
use arc_execution_config::hardforks::ArcHardforkFlags;
25+
use arc_execution_config::hardforks::{ArcHardfork, ArcHardforkFlags};
2626
use reth_ethereum::evm::revm::precompile::PrecompileSpecId;
2727
use reth_ethereum::evm::revm::precompile::Precompiles;
2828
use reth_evm::precompiles::DynPrecompile;
@@ -60,10 +60,11 @@ impl ArcPrecompileProvider {
6060
PrecompileId::Custom("SYSTEM_ACCOUNTING".into()),
6161
move |input| run_system_accounting(input, hardfork_flags),
6262
)),
63-
PQ_ADDRESS => Some(DynPrecompile::new_stateful(
64-
PrecompileId::Custom("PQ".into()),
65-
move |input| run_pq(input, hardfork_flags),
66-
)),
63+
PQ_ADDRESS if hardfork_flags.is_active(ArcHardfork::Zero6) => Some(
64+
DynPrecompile::new_stateful(PrecompileId::Custom("PQ".into()), move |input| {
65+
run_pq(input, hardfork_flags)
66+
}),
67+
),
6768
_ => handle_unknown_precompile(address),
6869
});
6970
precompile_map
@@ -117,15 +118,28 @@ mod tests {
117118
}
118119

119120
#[test]
120-
fn test_pq_precompile_available() {
121+
fn test_pq_precompile_not_available_before_zero6() {
121122
let precompiles = ArcPrecompileProvider::create_precompiles_map(
122123
SpecId::PRAGUE,
123124
ArcHardforkFlags::default(),
124125
);
125126

127+
assert!(
128+
precompiles.get(&PQ_ADDRESS).is_none(),
129+
"PQ precompile should not be available before Zero6"
130+
);
131+
}
132+
133+
#[test]
134+
fn test_pq_precompile_available_with_zero6() {
135+
let precompiles = ArcPrecompileProvider::create_precompiles_map(
136+
SpecId::PRAGUE,
137+
ArcHardforkFlags::with(&[ArcHardfork::Zero6]),
138+
);
139+
126140
assert!(
127141
precompiles.get(&PQ_ADDRESS).is_some(),
128-
"PQ precompile should be available"
142+
"PQ precompile should be available with Zero6"
129143
);
130144
}
131145

0 commit comments

Comments
 (0)