File tree Expand file tree Collapse file tree 2 files changed +10
-9
lines changed
Expand file tree Collapse file tree 2 files changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,9 @@ pub struct DeployAllowlistSettings {
1313impl DeployAllowlistSettings {
1414 /// Creates a new deploy allowlist configuration.
1515 pub fn new ( allowlist : Vec < Address > , activation_height : u64 ) -> Self {
16+ let mut allowlist = allowlist;
1617 debug_assert ! ( !allowlist. is_empty( ) , "deploy allowlist must not be empty" ) ;
18+ allowlist. sort_unstable ( ) ;
1719 Self {
1820 allowlist : Arc :: from ( allowlist) ,
1921 activation_height,
@@ -37,6 +39,6 @@ impl DeployAllowlistSettings {
3739
3840 /// Returns true if the caller is in the allowlist.
3941 pub fn is_allowed ( & self , caller : Address ) -> bool {
40- self . allowlist . contains ( & caller)
42+ self . allowlist . binary_search ( & caller) . is_ok ( )
4143 }
4244}
Original file line number Diff line number Diff line change 11use alloy_primitives:: Address ;
22use reth_chainspec:: ChainSpec ;
33use serde:: { Deserialize , Serialize } ;
4+ use std:: collections:: HashSet ;
45
56/// Default contract size limit in bytes (24KB per EIP-170).
67pub const DEFAULT_CONTRACT_SIZE_LIMIT : usize = 24 * 1024 ;
@@ -167,19 +168,17 @@ impl EvolvePayloadBuilderConfig {
167168 ) ) ) ;
168169 }
169170
170- for i in 0 ..allowlist_len {
171- let addr = self . deploy_allowlist [ i ] ;
171+ let mut seen = HashSet :: with_capacity ( allowlist_len ) ;
172+ for addr in & self . deploy_allowlist {
172173 if addr. is_zero ( ) {
173174 return Err ( ConfigError :: InvalidDeployAllowlist (
174175 "deployAllowlist contains zero address" . to_string ( ) ,
175176 ) ) ;
176177 }
177- for j in ( i + 1 ) ..allowlist_len {
178- if addr == self . deploy_allowlist [ j] {
179- return Err ( ConfigError :: InvalidDeployAllowlist (
180- "deployAllowlist contains duplicate entries" . to_string ( ) ,
181- ) ) ;
182- }
178+ if !seen. insert ( * addr) {
179+ return Err ( ConfigError :: InvalidDeployAllowlist (
180+ "deployAllowlist contains duplicate entries" . to_string ( ) ,
181+ ) ) ;
183182 }
184183 }
185184
You can’t perform that action at this time.
0 commit comments