Skip to content

Commit 541a4c1

Browse files
committed
comments
1 parent 4b19e48 commit 541a4c1

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

crates/ev-revm/src/deploy.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ pub struct DeployAllowlistSettings {
1313
impl 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
}

crates/node/src/config.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use alloy_primitives::Address;
22
use reth_chainspec::ChainSpec;
33
use serde::{Deserialize, Serialize};
4+
use std::collections::HashSet;
45

56
/// Default contract size limit in bytes (24KB per EIP-170).
67
pub 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

0 commit comments

Comments
 (0)