Skip to content

Commit 887bfdd

Browse files
committed
feat: alias addresses
1 parent a6daf31 commit 887bfdd

File tree

8 files changed

+96
-395
lines changed

8 files changed

+96
-395
lines changed

Cargo.toml

Lines changed: 46 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ members = ["crates/*"]
33
resolver = "2"
44

55
[workspace.package]
6-
version = "0.11.4"
6+
version = "0.12.4"
77
edition = "2024"
88
rust-version = "1.88"
99
authors = ["init4"]
@@ -34,34 +34,34 @@ debug = false
3434
incremental = false
3535

3636
[workspace.dependencies]
37-
signet-blobber = { version = "0.11", path = "crates/blobber" }
38-
signet-block-processor = { version = "0.11", path = "crates/block-processor" }
39-
signet-db = { version = "0.11", path = "crates/db" }
40-
signet-genesis = { version = "0.11", path = "crates/genesis" }
41-
signet-node = { version = "0.11", path = "crates/node" }
42-
signet-node-config = { version = "0.11", path = "crates/node-config" }
43-
signet-node-tests = { version = "0.11", path = "crates/node-tests" }
44-
signet-node-types = { version = "0.11", path = "crates/node-types" }
45-
signet-rpc = { version = "0.11", path = "crates/rpc" }
46-
37+
signet-blobber = { version = "0.12", path = "crates/blobber" }
38+
signet-block-processor = { version = "0.12", path = "crates/block-processor" }
39+
signet-db = { version = "0.12", path = "crates/db" }
40+
signet-genesis = { version = "0.12", path = "crates/genesis" }
41+
signet-node = { version = "0.12", path = "crates/node" }
42+
signet-node-config = { version = "0.12", path = "crates/node-config" }
43+
signet-node-tests = { version = "0.12", path = "crates/node-tests" }
44+
signet-node-types = { version = "0.12", path = "crates/node-types" }
45+
signet-rpc = { version = "0.12", path = "crates/rpc" }
4746

4847
init4-bin-base = { version = "0.13.1", features = ["alloy"] }
4948

50-
signet-bundle = "0.11.1"
51-
signet-constants = "0.11.1"
52-
signet-evm = "0.11.1"
53-
signet-extract = "0.11.1"
54-
signet-test-utils = "0.11.1"
55-
signet-tx-cache = "0.11.1"
56-
signet-types = "0.11.1"
57-
signet-zenith = "0.11.1"
58-
signet-journal = "0.11.1"
49+
signet-bundle = "0.12"
50+
signet-constants = "0.12"
51+
signet-evm = "0.12"
52+
signet-extract = "0.12"
53+
signet-test-utils = "0.12"
54+
signet-tx-cache = "0.12"
55+
signet-types = "0.12"
56+
signet-zenith = "0.12"
57+
signet-journal = "0.12"
5958

6059
# ajj
6160
ajj = { version = "0.3.4" }
6261

6362
# trevm
6463
trevm = { version = "0.29.0", features = ["full_env_cfg"] }
64+
revm-inspectors = "0.30.0" # should be 1 more than trevm version, usually
6565

6666
# Alloy periphery crates
6767
alloy = { version = "1.0.35", features = [
@@ -74,22 +74,22 @@ alloy = { version = "1.0.35", features = [
7474
alloy-contract = { version = "1.0.35", features = ["pubsub"] }
7575

7676
# Reth
77-
reth = { git = "https://github.com/paradigmxyz/reth", tag = "v1.8.1" }
78-
reth-ethereum = { git = "https://github.com/paradigmxyz/reth", tag = "v1.8.1" }
79-
reth-chainspec = { git = "https://github.com/paradigmxyz/reth", tag = "v1.8.1" }
80-
reth-db = { git = "https://github.com/paradigmxyz/reth", tag = "v1.8.1" }
81-
reth-db-common = { git = "https://github.com/paradigmxyz/reth", tag = "v1.8.1" }
82-
reth-eth-wire-types = { git = "https://github.com/paradigmxyz/reth", tag = "v1.8.1" }
83-
reth-evm-ethereum = { git = "https://github.com/paradigmxyz/reth", tag = "v1.8.1" }
84-
reth-exex = { git = "https://github.com/paradigmxyz/reth", tag = "v1.8.1" }
85-
reth-exex-test-utils = { git = "https://github.com/paradigmxyz/reth", tag = "v1.8.1" }
86-
reth-network-api = { git = "https://github.com/paradigmxyz/reth", tag = "v1.8.1" }
87-
reth-network-peers = { git = "https://github.com/paradigmxyz/reth", tag = "v1.8.1" }
88-
reth-node-api = { git = "https://github.com/paradigmxyz/reth", tag = "v1.8.1" }
89-
reth-node-ethereum = { git = "https://github.com/paradigmxyz/reth", tag = "v1.8.1" }
90-
reth-prune-types = { git = "https://github.com/paradigmxyz/reth", tag = "v1.8.1" }
91-
reth-rpc-eth-api = { git = "https://github.com/paradigmxyz/reth", tag = "v1.8.1" }
92-
reth-transaction-pool = { git = "https://github.com/paradigmxyz/reth", tag = "v1.8.1" }
77+
reth = { git = "https://github.com/paradigmxyz/reth", tag = "v1.8.3" }
78+
reth-ethereum = { git = "https://github.com/paradigmxyz/reth", tag = "v1.8.3" }
79+
reth-chainspec = { git = "https://github.com/paradigmxyz/reth", tag = "v1.8.3" }
80+
reth-db = { git = "https://github.com/paradigmxyz/reth", tag = "v1.8.3" }
81+
reth-db-common = { git = "https://github.com/paradigmxyz/reth", tag = "v1.8.3" }
82+
reth-eth-wire-types = { git = "https://github.com/paradigmxyz/reth", tag = "v1.8.3" }
83+
reth-evm-ethereum = { git = "https://github.com/paradigmxyz/reth", tag = "v1.8.3" }
84+
reth-exex = { git = "https://github.com/paradigmxyz/reth", tag = "v1.8.3" }
85+
reth-exex-test-utils = { git = "https://github.com/paradigmxyz/reth", tag = "v1.8.3" }
86+
reth-network-api = { git = "https://github.com/paradigmxyz/reth", tag = "v1.8.3" }
87+
reth-network-peers = { git = "https://github.com/paradigmxyz/reth", tag = "v1.8.3" }
88+
reth-node-api = { git = "https://github.com/paradigmxyz/reth", tag = "v1.8.3" }
89+
reth-node-ethereum = { git = "https://github.com/paradigmxyz/reth", tag = "v1.8.3" }
90+
reth-prune-types = { git = "https://github.com/paradigmxyz/reth", tag = "v1.8.3" }
91+
reth-rpc-eth-api = { git = "https://github.com/paradigmxyz/reth", tag = "v1.8.3" }
92+
reth-transaction-pool = { git = "https://github.com/paradigmxyz/reth", tag = "v1.8.3" }
9393

9494
# Foundry periphery
9595
foundry-blob-explorers = "0.17"
@@ -127,14 +127,15 @@ uuid = "1.16.0"
127127
alloy-rlp = "0.3.11"
128128
tempfile = "3.17.0"
129129

130-
# [patch.crates-io]
131-
# signet-bundle = { path = "../sdk/crates/bundle"}
132-
# signet-constants = { path = "../sdk/crates/constants"}
133-
# signet-evm = { path = "../sdk/crates/evm"}
134-
# signet-extract = { path = "../sdk/crates/extract"}
135-
# signet-test-utils = { path = "../sdk/crates/test-utils"}
136-
# signet-tx-cache = { path = "../sdk/crates/tx-cache"}
137-
# signet-types = { path = "../sdk/crates/types"}
138-
# signet-zenith = { path = "../sdk/crates/zenith"}
130+
[patch.crates-io]
131+
signet-bundle = { path = "../sdk/crates/bundle"}
132+
signet-constants = { path = "../sdk/crates/constants"}
133+
signet-evm = { path = "../sdk/crates/evm"}
134+
signet-extract = { path = "../sdk/crates/extract"}
135+
signet-journal = { path = "../sdk/crates/journal"}
136+
signet-test-utils = { path = "../sdk/crates/test-utils"}
137+
signet-tx-cache = { path = "../sdk/crates/tx-cache"}
138+
signet-types = { path = "../sdk/crates/types"}
139+
signet-zenith = { path = "../sdk/crates/zenith"}
139140

140141
# init4-bin-base = { path = "../shared" }

crates/block-processor/src/v1/processor.rs

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
use crate::{Chain, metrics};
2-
use alloy::{consensus::BlockHeader, primitives::B256};
2+
use alloy::{
3+
consensus::BlockHeader,
4+
primitives::{Address, B256, map::HashSet},
5+
};
6+
use core::fmt;
37
use eyre::ContextCompat;
48
use init4_bin_base::utils::calc::SlotCalculator;
59
use reth::{
610
primitives::EthPrimitives,
7-
providers::{BlockNumReader, BlockReader, ExecutionOutcome, HeaderProvider, ProviderFactory},
11+
providers::{
12+
BlockNumReader, BlockReader, ExecutionOutcome, HeaderProvider, ProviderFactory,
13+
StateProviderFactory,
14+
},
815
revm::{database::StateProviderDatabase, db::StateBuilder},
916
};
1017
use reth_chainspec::{ChainSpec, EthereumHardforks};
@@ -16,14 +23,12 @@ use signet_evm::{BlockResult, EvmNeedsCfg, SignetDriver};
1623
use signet_extract::{Extractor, Extracts};
1724
use signet_journal::HostJournal;
1825
use signet_node_types::{NodeTypesDbTrait, SignetNodeTypes};
19-
use std::collections::VecDeque;
20-
use std::sync::Arc;
26+
use std::{collections::VecDeque, sync::Arc};
2127
use tracing::{Instrument, debug, error, info, info_span, instrument};
2228
use trevm::revm::primitives::hardfork::SpecId;
2329

2430
/// A block processor that listens to host chain commits and processes
2531
/// Signet blocks accordingly.
26-
#[derive(Debug)]
2732
pub struct SignetBlockProcessor<Db>
2833
where
2934
Db: NodeTypesDbTrait,
@@ -37,13 +42,25 @@ where
3742
/// A [`ProviderFactory`] instance to allow RU database access.
3843
ru_provider: ProviderFactory<SignetNodeTypes<Db>>,
3944

45+
/// A [`ProviderFactory`] instance to allow Host database access.
46+
host_provider: Box<dyn StateProviderFactory>,
47+
4048
/// The slot calculator.
4149
slot_calculator: SlotCalculator,
4250

4351
/// A handle to the blob cacher.
4452
blob_cacher: CacheHandle,
4553
}
4654

55+
impl<Db> fmt::Debug for SignetBlockProcessor<Db>
56+
where
57+
Db: NodeTypesDbTrait,
58+
{
59+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
60+
f.debug_struct("SignetBlockProcessor").finish()
61+
}
62+
}
63+
4764
impl<Db> SignetBlockProcessor<Db>
4865
where
4966
Db: NodeTypesDbTrait,
@@ -53,10 +70,11 @@ where
5370
constants: SignetSystemConstants,
5471
chain_spec: Arc<ChainSpec>,
5572
ru_provider: ProviderFactory<SignetNodeTypes<Db>>,
73+
host_provider: Box<dyn StateProviderFactory>,
5674
slot_calculator: SlotCalculator,
5775
blob_cacher: CacheHandle,
5876
) -> Self {
59-
Self { constants, chain_spec, ru_provider, slot_calculator, blob_cacher }
77+
Self { constants, chain_spec, ru_provider, host_provider, slot_calculator, blob_cacher }
6078
}
6179

6280
/// Get the active spec id at the given timestamp.
@@ -92,6 +110,12 @@ where
92110
Ok(trevm)
93111
}
94112

113+
/// Check if the given address should be aliased.
114+
fn should_alias(&self, host_height: u64, address: Address) -> eyre::Result<bool> {
115+
let state = self.host_provider.history_by_block_number(host_height)?;
116+
state.account_code(&address).map(|code| code.is_some()).map_err(Into::into)
117+
}
118+
95119
/// Called when the host chain has committed a block or set of blocks.
96120
#[instrument(skip_all, fields(count = chain.len(), first = chain.first().number(), tip = chain.tip().number()))]
97121
pub async fn on_host_commit<Host>(&self, chain: &Chain<Host>) -> eyre::Result<Option<RuChain>>
@@ -239,8 +263,17 @@ where
239263
None => VecDeque::new(),
240264
};
241265

266+
let mut to_alias: HashSet<Address> = Default::default();
267+
for transact in block_extracts.transacts() {
268+
let addr = transact.host_sender();
269+
if self.should_alias(host_height, addr)? {
270+
to_alias.insert(addr);
271+
}
272+
}
273+
242274
let mut driver = SignetDriver::new(
243275
block_extracts,
276+
to_alias,
244277
txns,
245278
parent_header.convert(),
246279
self.constants.clone(),

crates/node/src/node.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ where
177177
constants.clone(),
178178
config.chain_spec().clone(),
179179
factory.clone(),
180+
Box::new(ctx.provider().clone()),
180181
config.slot_calculator(),
181182
blob_cacher,
182183
);

crates/rpc/Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ repository.workspace = true
1010

1111
[dependencies]
1212
signet-node-types.workspace = true
13+
signet-db.workspace = true
1314

1415
signet-bundle.workspace = true
1516
signet-evm.workspace = true
@@ -20,6 +21,8 @@ ajj.workspace = true
2021
trevm.workspace = true
2122

2223
alloy.workspace = true
24+
revm-inspectors.workspace = true
25+
2326
reth.workspace = true
2427
reth-chainspec.workspace = true
2528
reth-db.workspace = true
@@ -42,8 +45,6 @@ tracing.workspace = true
4245
serde_json.workspace = true
4346
futures-util = "0.3.31"
4447
itertools.workspace = true
45-
revm-inspectors = "0.30.0"
46-
signet-db.workspace = true
4748

4849
[dev-dependencies]
4950
signet-zenith.workspace = true

0 commit comments

Comments
 (0)