1
1
//! Constants for the Ethereum protocol.
2
2
extern crate alloc;
3
3
4
+ use crate :: primitives:: { uint, BlockNumber , ChainId , U256 } ;
5
+ use crate :: proof_type:: ProofType ;
4
6
use alloc:: collections:: BTreeMap ;
5
-
6
7
use alloy_primitives:: Address ;
7
8
use anyhow:: { anyhow, bail, Result } ;
9
+ use once_cell:: sync:: Lazy ;
8
10
use reth_primitives:: revm_primitives:: SpecId ;
9
11
use serde:: { Deserialize , Serialize } ;
10
12
use serde_json:: Value ;
11
-
12
- #[ cfg( not( feature = "std" ) ) ]
13
- use crate :: no_std:: * ;
14
- use crate :: primitives:: { uint, BlockNumber , ChainId , U256 } ;
15
-
16
- use once_cell:: sync:: Lazy ;
17
13
use std:: path:: PathBuf ;
18
14
use std:: { collections:: HashMap , env:: var} ;
19
15
20
- use crate :: proof_type:: ProofType ;
16
+ #[ cfg( not( feature = "std" ) ) ]
17
+ use crate :: no_std:: * ;
21
18
22
19
/// U256 representation of 0.
23
20
pub const ZERO : U256 = U256 :: ZERO ;
@@ -129,26 +126,6 @@ impl Default for Eip1559Constants {
129
126
}
130
127
}
131
128
132
- #[ repr( u8 ) ]
133
- #[ derive( Clone , Copy , Debug , PartialEq , Eq , PartialOrd , Ord , Hash , Serialize , Deserialize ) ]
134
- pub enum VerifierType {
135
- None ,
136
- SGX ,
137
- SP1 ,
138
- RISC0 ,
139
- }
140
-
141
- impl From < ProofType > for VerifierType {
142
- fn from ( val : ProofType ) -> Self {
143
- match val {
144
- ProofType :: Native => VerifierType :: None ,
145
- ProofType :: Sgx => VerifierType :: SGX ,
146
- ProofType :: Sp1 => VerifierType :: SP1 ,
147
- ProofType :: Risc0 => VerifierType :: RISC0 ,
148
- }
149
- }
150
- }
151
-
152
129
/// Specification of a specific chain.
153
130
#[ derive( Debug , Clone , Default , Serialize , Deserialize , PartialEq ) ]
154
131
pub struct ChainSpec {
@@ -161,7 +138,7 @@ pub struct ChainSpec {
161
138
pub l2_contract : Option < Address > ,
162
139
pub rpc : String ,
163
140
pub beacon_rpc : Option < String > ,
164
- pub verifier_address_forks : BTreeMap < SpecId , BTreeMap < VerifierType , Option < Address > > > ,
141
+ pub verifier_address_forks : BTreeMap < SpecId , BTreeMap < ProofType , Option < Address > > > ,
165
142
pub genesis_time : u64 ,
166
143
pub seconds_per_slot : u64 ,
167
144
pub is_taiko : bool ,
@@ -229,14 +206,14 @@ impl ChainSpec {
229
206
pub fn get_fork_verifier_address (
230
207
& self ,
231
208
block_num : u64 ,
232
- verifier_type : VerifierType ,
209
+ proof_type : ProofType ,
233
210
) -> Result < Address > {
234
211
// fall down to the first fork that is active as default
235
212
for ( spec_id, fork) in self . hard_forks . iter ( ) . rev ( ) {
236
213
if fork. active ( block_num, 0u64 ) {
237
214
if let Some ( fork_verifier) = self . verifier_address_forks . get ( spec_id) {
238
215
return fork_verifier
239
- . get ( & verifier_type )
216
+ . get ( & proof_type )
240
217
. ok_or_else ( || anyhow ! ( "Verifier type not found" ) )
241
218
. and_then ( |address| {
242
219
address. ok_or_else ( || anyhow ! ( "Verifier address not found" ) )
@@ -344,7 +321,7 @@ mod tests {
344
321
. get_chain_spec ( & Network :: Ethereum . to_string ( ) )
345
322
. unwrap ( ) ;
346
323
let verifier_address = eth_mainnet_spec
347
- . get_fork_verifier_address ( 15_537_394 , VerifierType :: SGX )
324
+ . get_fork_verifier_address ( 15_537_394 , ProofType :: Sgx )
348
325
. unwrap ( ) ;
349
326
assert_eq ! (
350
327
verifier_address,
@@ -355,14 +332,14 @@ mod tests {
355
332
. get_chain_spec ( & Network :: TaikoA7 . to_string ( ) )
356
333
. unwrap ( ) ;
357
334
let verifier_address = hekla_mainnet_spec
358
- . get_fork_verifier_address ( 12345 , VerifierType :: SGX )
335
+ . get_fork_verifier_address ( 12345 , ProofType :: Sgx )
359
336
. unwrap ( ) ;
360
337
assert_eq ! (
361
338
verifier_address,
362
339
address!( "532efbf6d62720d0b2a2bb9d11066e8588cae6d9" )
363
340
) ;
364
341
let verifier_address = hekla_mainnet_spec
365
- . get_fork_verifier_address ( 15_537_394 , VerifierType :: SGX )
342
+ . get_fork_verifier_address ( 15_537_394 , ProofType :: Sgx )
366
343
. unwrap ( ) ;
367
344
assert_eq ! (
368
345
verifier_address,
@@ -371,12 +348,12 @@ mod tests {
371
348
}
372
349
373
350
#[ test]
374
- fn forked_none_verifier_address ( ) {
351
+ fn forked_native_verifier_address ( ) {
375
352
let eth_mainnet_spec = SupportedChainSpecs :: default ( )
376
353
. get_chain_spec ( & Network :: Ethereum . to_string ( ) )
377
354
. unwrap ( ) ;
378
355
let verifier_address = eth_mainnet_spec
379
- . get_fork_verifier_address ( 15_537_394 , VerifierType :: None )
356
+ . get_fork_verifier_address ( 15_537_394 , ProofType :: Native )
380
357
. unwrap_or_default ( ) ;
381
358
assert_eq ! ( verifier_address, Address :: ZERO ) ;
382
359
}
@@ -407,9 +384,9 @@ mod tests {
407
384
verifier_address_forks : BTreeMap :: from ( [ (
408
385
SpecId :: FRONTIER ,
409
386
BTreeMap :: from ( [
410
- ( VerifierType :: SGX , Some ( Address :: default ( ) ) ) ,
411
- ( VerifierType :: SP1 , None ) ,
412
- ( VerifierType :: RISC0 , Some ( Address :: default ( ) ) ) ,
387
+ ( ProofType :: Sgx , Some ( Address :: default ( ) ) ) ,
388
+ ( ProofType :: Sp1 , None ) ,
389
+ ( ProofType :: Risc0 , Some ( Address :: default ( ) ) ) ,
413
390
] ) ,
414
391
) ] ) ,
415
392
genesis_time : 0u64 ,
0 commit comments