1- use alloy:: {
2- consensus:: constants:: KECCAK_EMPTY ,
3- primitives:: { Address , map:: HashSet } ,
4- } ;
5- use eyre:: OptionExt ;
6- #[ cfg( doc) ]
7- use reth:: providers:: StateProvider ;
8- use reth:: providers:: { StateProviderBox , StateProviderFactory } ;
1+ use alloy:: primitives:: { Address , map:: HashSet } ;
92use std:: sync:: { Arc , Mutex } ;
103
114/// Simple trait to allow checking if an address should be aliased.
@@ -14,35 +7,6 @@ pub trait AliasOracle {
147 fn should_alias ( & self , address : Address ) -> eyre:: Result < bool > ;
158}
169
17- /// Default implementation of [`AliasOracle`] for any type implementing
18- /// [`StateProvider`]. This implementation checks if the address has bytecode
19- /// associated with it, and if so, whether that bytecode matches the pattern
20- /// for a 7702 delegation contract. If it is a delegation contract, it is not
21- /// aliased; otherwise, it is aliased.
22- impl AliasOracle for StateProviderBox {
23- fn should_alias ( & self , address : Address ) -> eyre:: Result < bool > {
24- // No account at this address.
25- let Some ( acct) = self . basic_account ( & address) ? else { return Ok ( false ) } ;
26- // Get the bytecode hash for this account.
27- let bch = match acct. bytecode_hash {
28- Some ( hash) => hash,
29- // No bytecode hash; not a contract.
30- None => return Ok ( false ) ,
31- } ;
32- // No code at this address.
33- if bch == KECCAK_EMPTY {
34- return Ok ( false ) ;
35- }
36- // Fetch the code associated with this bytecode hash.
37- let code = self
38- . bytecode_by_hash ( & bch) ?
39- . ok_or_eyre ( "code not found. This indicates a corrupted database" ) ?;
40-
41- // If not a 7702 delegation contract, alias it.
42- Ok ( !code. is_eip7702 ( ) )
43- }
44- }
45-
4610impl AliasOracle for HashSet < Address > {
4711 fn should_alias ( & self , address : Address ) -> eyre:: Result < bool > {
4812 Ok ( self . contains ( & address) )
@@ -51,9 +15,8 @@ impl AliasOracle for HashSet<Address> {
5115
5216/// Factory trait to create new [`AliasOracle`] instances.
5317///
54- /// The default implementation on `Box<dyn StateProviderFactory>` creates
55- /// [`AliasOracle`] instances backed by the state provider for a given block
56- /// height. It will error if that state provider cannot be obtained.
18+ /// See `signet-node` for the reth-backed implementation that creates
19+ /// [`AliasOracle`] instances backed by the host chain state provider.
5720///
5821/// This trait is primarily intended to allow injecting test implementations
5922/// of [`AliasOracle`] into the Signet Node for testing purposes. The test
@@ -67,21 +30,6 @@ pub trait AliasOracleFactory: Send + Sync + 'static {
6730 fn create ( & self ) -> eyre:: Result < Self :: Oracle > ;
6831}
6932
70- impl AliasOracleFactory for Box < dyn StateProviderFactory > {
71- type Oracle = StateProviderBox ;
72-
73- fn create ( & self ) -> eyre:: Result < Self :: Oracle > {
74- // NB: This becomes a problem if anyone ever birthday attacks a
75- // contract/EOA pair (c.f. EIP-3607). In practice this is unlikely to
76- // happen for the foreseeable future, and if it does we can revisit
77- // this decision.
78- // We considered taking the host height as an argument to this method,
79- // but this would require all nodes to be archive nodes in order to
80- // sync, which is less than ideal
81- self . state_by_block_number_or_tag ( alloy:: eips:: BlockNumberOrTag :: Latest ) . map_err ( Into :: into)
82- }
83- }
84-
8533/// This implementation is primarily for testing purposes.
8634impl AliasOracleFactory for HashSet < Address > {
8735 type Oracle = HashSet < Address > ;
0 commit comments