Skip to content

Commit 04883db

Browse files
committed
Merge remote-tracking branch 'origin/main' into joshie/bump-reth
2 parents db85133 + b35e5a9 commit 04883db

File tree

11 files changed

+258
-2
lines changed

11 files changed

+258
-2
lines changed

Cargo.lock

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[workspace]
22
members = [
33
"bin/odyssey/",
4+
"crates/common",
45
"crates/node",
56
"crates/e2e-tests",
67
"crates/wallet",
@@ -134,6 +135,7 @@ strip = false
134135

135136
[workspace.dependencies]
136137
# odyssey
138+
odyssey-common = { path = "crates/common" }
137139
odyssey-node = { path = "crates/node" }
138140
odyssey-wallet = { path = "crates/wallet" }
139141
odyssey-walltime = { path = "crates/walltime" }
@@ -149,6 +151,7 @@ alloy-eips = "0.6.4"
149151
alloy-network = "0.6.4"
150152
alloy-primitives = "0.8.11"
151153
alloy-rpc-types = "0.6.4"
154+
alloy-rpc-types-eth = "0.6.4"
152155
alloy-signer-local = { version = "0.6.4", features = ["mnemonic"] }
153156

154157
# tokio
@@ -158,6 +161,7 @@ tokio = { version = "1.21", default-features = false }
158161
reth-chainspec = { git = "https://github.com/paradigmxyz/reth.git", rev = "38cf6c9" }
159162
reth-cli = { git = "https://github.com/paradigmxyz/reth.git", rev = "38cf6c9" }
160163
reth-cli-util = { git = "https://github.com/paradigmxyz/reth.git", rev = "38cf6c9" }
164+
reth-errors = { git = "https://github.com/paradigmxyz/reth.git", rev = "38cf6c9" }
161165
reth-evm = { git = "https://github.com/paradigmxyz/reth.git", rev = "38cf6c9" }
162166
reth-rpc-eth-api = { git = "https://github.com/paradigmxyz/reth.git", rev = "38cf6c9" }
163167
reth-node-api = { git = "https://github.com/paradigmxyz/reth.git", rev = "38cf6c9" }
@@ -185,9 +189,12 @@ reth-provider = { git = "https://github.com/paradigmxyz/reth.git", rev = "38cf6c
185189
"optimism",
186190
] }
187191
reth-revm = { git = "https://github.com/paradigmxyz/reth.git", rev = "38cf6c9" }
192+
reth-rpc-types-compat = { git = "https://github.com/paradigmxyz/reth.git", rev = "38cf6c9" }
193+
reth-rpc-eth-types = { git = "https://github.com/paradigmxyz/reth.git", rev = "38cf6c9" }
188194
reth-storage-api = { git = "https://github.com/paradigmxyz/reth.git", rev = "38cf6c9" }
189195
reth-tracing = { git = "https://github.com/paradigmxyz/reth.git", rev = "38cf6c9" }
190196
reth-transaction-pool = { git = "https://github.com/paradigmxyz/reth.git", rev = "38cf6c9" }
197+
reth-trie-common = { git = "https://github.com/paradigmxyz/reth.git", rev = "38cf6c9" }
191198
reth-trie-db = { git = "https://github.com/paradigmxyz/reth.git", rev = "38cf6c9" }
192199
reth-network = { git = "https://github.com/paradigmxyz/reth.git", rev = "38cf6c9" }
193200
reth-network-types = { git = "https://github.com/paradigmxyz/reth.git", rev = "38cf6c9" }

bin/odyssey/src/main.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ use alloy_primitives::Address;
2828
use alloy_signer_local::PrivateKeySigner;
2929
use clap::Parser;
3030
use eyre::Context;
31-
use odyssey_node::{chainspec::OdysseyChainSpecParser, node::OdysseyNode};
31+
use odyssey_node::{
32+
chainspec::OdysseyChainSpecParser,
33+
node::OdysseyNode,
34+
rpc::{EthApiExt, EthApiOverrideServer},
35+
};
3236
use odyssey_wallet::{OdysseyWallet, OdysseyWalletApiServer};
3337
use odyssey_walltime::{OdysseyWallTime, OdysseyWallTimeRpcApiServer};
3438
use reth_node_builder::{engine_tree_config::TreeConfig, EngineNodeLauncher};
@@ -56,6 +60,11 @@ fn main() {
5660
.with_components(OdysseyNode::components(&rollup_args))
5761
.with_add_ons(OpAddOns::new(rollup_args.sequencer_http))
5862
.extend_rpc_modules(move |ctx| {
63+
// override eth namespace
64+
ctx.modules.replace_configured(
65+
EthApiExt::new(ctx.registry.eth_api().clone()).into_rpc(),
66+
)?;
67+
5968
// register odyssey wallet namespace
6069
if let Ok(sk) = std::env::var("EXP1_SK") {
6170
let signer: PrivateKeySigner =

crates/common/Cargo.toml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[package]
2+
name = "odyssey-common"
3+
version.workspace = true
4+
edition.workspace = true
5+
rust-version.workspace = true
6+
authors.workspace = true
7+
license.workspace = true
8+
repository.workspace = true
9+
keywords.workspace = true
10+
categories.workspace = true
11+
12+
[dependencies]
13+
alloy-primitives.workspace = true
14+
15+
[lints]
16+
workspace = true

crates/common/src/constants.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//! Odyssey constants.
2+
3+
use alloy_primitives::{address, Address};
4+
5+
/// Withdrawal predeployed contract address.
6+
///
7+
/// [The L2ToL1MessagePasser](https://specs.optimism.io/protocol/withdrawals.html#the-l2tol1messagepasser-contract)
8+
pub const WITHDRAWAL_CONTRACT: Address = address!("4200000000000000000000000000000000000016");

crates/common/src/lib.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
//! Odyssey common types and constants
2+
3+
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
4+
#![warn(unused_crate_dependencies)]
5+
6+
mod constants;
7+
pub use constants::WITHDRAWAL_CONTRACT;

crates/e2e-tests/Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ keywords.workspace = true
1010
categories.workspace = true
1111

1212
[dev-dependencies]
13+
odyssey-common.workspace = true
14+
15+
reth-primitives-traits.workspace = true
16+
reth-trie-common.workspace = true
17+
1318
alloy.workspace = true
1419
alloy-network.workspace = true
1520
alloy-rpc-types.workspace = true

crates/e2e-tests/src/tests.rs

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ use alloy::{
77
signers::SignerSync,
88
};
99
use alloy_network::{TransactionBuilder, TransactionBuilder7702};
10-
use alloy_rpc_types::TransactionRequest;
10+
use alloy_rpc_types::{Block, BlockNumberOrTag, EIP1186AccountProofResponse, TransactionRequest};
1111
use alloy_signer_local::PrivateKeySigner;
12+
use reth_primitives_traits::Account;
13+
use reth_trie_common::{AccountProof, StorageProof};
1214
use url::Url;
1315

1416
static REPLICA_RPC: LazyLock<Url> = LazyLock::new(|| {
@@ -127,3 +129,61 @@ async fn test_new_wallet_api() -> Result<(), Box<dyn std::error::Error>> {
127129

128130
Ok(())
129131
}
132+
133+
#[tokio::test]
134+
async fn test_withdrawal_proof_with_fallback() -> Result<(), Box<dyn std::error::Error>> {
135+
if !ci_info::is_ci() {
136+
return Ok(());
137+
}
138+
139+
let provider = ProviderBuilder::new().on_http(REPLICA_RPC.clone());
140+
let block: Block = provider
141+
.client()
142+
.request("eth_getBlockByNumber", (BlockNumberOrTag::Latest, false))
143+
.await?;
144+
let block_number = BlockNumberOrTag::Number(block.header.number);
145+
146+
// Withdrawal contract will return an empty account proof, since it only handles storage proofs
147+
let withdrawal_contract_response: EIP1186AccountProofResponse = provider
148+
.client()
149+
.request(
150+
"eth_getProof",
151+
(odyssey_common::WITHDRAWAL_CONTRACT, vec![B256::ZERO], block_number),
152+
)
153+
.await?;
154+
155+
assert!(withdrawal_contract_response.account_proof.is_empty());
156+
assert!(!withdrawal_contract_response.storage_proof.is_empty());
157+
158+
let storage_root = withdrawal_contract_response.storage_hash;
159+
for proof in withdrawal_contract_response.storage_proof {
160+
StorageProof::new(proof.key.as_b256()).with_proof(proof.proof).verify(storage_root)?
161+
}
162+
163+
// If not targeting the withdrawal contract, it defaults back to the standard getProof
164+
// implementation
165+
let signer = PrivateKeySigner::from_bytes(&b256!(
166+
"59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d"
167+
))?;
168+
169+
let eoa_response: EIP1186AccountProofResponse = provider
170+
.client()
171+
.request("eth_getProof", (signer.address(), [0; 0], block_number))
172+
.await
173+
.unwrap();
174+
175+
assert!(!eoa_response.account_proof.is_empty());
176+
AccountProof {
177+
address: signer.address(),
178+
info: Some(Account {
179+
nonce: eoa_response.nonce,
180+
balance: eoa_response.balance,
181+
bytecode_hash: Some(eoa_response.code_hash),
182+
}),
183+
proof: eoa_response.account_proof,
184+
..Default::default()
185+
}
186+
.verify(block.header.state_root)?;
187+
188+
Ok(())
189+
}

crates/node/Cargo.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@ keywords.workspace = true
1010
categories.workspace = true
1111

1212
[dependencies]
13+
odyssey-common.workspace = true
14+
1315
revm-precompile.workspace = true
1416
revm-primitives.workspace = true
1517

1618
reth-cli.workspace = true
19+
reth-errors.workspace = true
1720
reth-node-api.workspace = true
1821
reth-node-builder.workspace = true
1922
reth-optimism-node.workspace = true
@@ -25,18 +28,26 @@ reth-payload-builder.workspace = true
2528
reth-primitives.workspace = true
2629
reth-evm.workspace = true
2730
reth-revm.workspace = true
31+
reth-rpc-eth-api.workspace = true
32+
reth-rpc-eth-types.workspace = true
33+
reth-rpc-types-compat.workspace = true
2834
reth-transaction-pool.workspace = true
35+
reth-trie-common.workspace = true
2936
reth-trie-db.workspace = true
3037
reth-network.workspace = true
3138
reth-network-types.workspace = true
3239

3340
alloy-consensus.workspace = true
3441
alloy-eips.workspace = true
3542
alloy-primitives.workspace = true
43+
alloy-rpc-types.workspace = true
44+
alloy-rpc-types-eth.workspace = true
45+
3646

3747
serde_json.workspace = true
3848
tracing.workspace = true
3949
eyre.workspace = true
50+
jsonrpsee.workspace = true
4051

4152
[lints]
4253
workspace = true

crates/node/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@
1818
pub mod chainspec;
1919
pub mod evm;
2020
pub mod node;
21+
pub mod rpc;

0 commit comments

Comments
 (0)