Skip to content

Commit

Permalink
fix(op): Add optimism in node api, few cfg transitions (paradigmxyz#6598
Browse files Browse the repository at this point in the history
)
  • Loading branch information
rakita authored Feb 14, 2024
1 parent eb8a805 commit 4c8f31a
Show file tree
Hide file tree
Showing 14 changed files with 57 additions and 25 deletions.
1 change: 1 addition & 0 deletions bin/reth/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ optimism = [
"reth-node-ethereum/optimism",
"dep:reth-node-optimism",
"reth-node-core/optimism",
"reth-node-api/optimism",
]

# no-op feature flag for switching between the `optimism` and default functionality in CI matrices
Expand Down
1 change: 1 addition & 0 deletions crates/consensus/beacon/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,5 @@ optimism = [
"reth-rpc-types/optimism",
"reth-payload-builder/optimism",
"reth-blockchain-tree/optimism",
"reth-node-api/optimism",
]
5 changes: 4 additions & 1 deletion crates/node-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,7 @@ revm-primitives.workspace = true
thiserror.workspace = true

# io
serde.workspace = true
serde.workspace = true

[features]
optimism = []
14 changes: 10 additions & 4 deletions crates/node-api/src/engine/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,16 +126,22 @@ pub trait PayloadBuilderAttributes: Send + Sync + std::fmt::Debug {
blob_excess_gas_and_price,
};

let cfg_with_handler_cfg;
#[cfg(feature = "optimism")]
{
let cfg_with_handler_cfg = CfgEnvWithHandlerCfg {
cfg_with_handler_cfg = CfgEnvWithHandlerCfg {
cfg_env: cfg,
handler_cfg: HandlerCfg { spec_id, is_optimism: chain_spec.is_optimism() },
handler_cfg: revm_primitives::HandlerCfg {
spec_id,
is_optimism: chain_spec.is_optimism(),
},
};
}

#[cfg(not(feature = "optimism"))]
let cfg_with_handler_cfg = CfgEnvWithHandlerCfg::new(cfg, spec_id);
{
cfg_with_handler_cfg = CfgEnvWithHandlerCfg::new(cfg, spec_id);
}

(cfg_with_handler_cfg, block_env)
}
Expand Down Expand Up @@ -211,7 +217,7 @@ impl PayloadAttributes for OptimismPayloadAttributes {
if self.gas_limit.is_none() && chain_spec.is_optimism() {
return Err(AttributesValidationError::InvalidParams(
"MissingGasLimitInPayloadAttributes".to_string().into(),
))
));
}

Ok(())
Expand Down
7 changes: 6 additions & 1 deletion crates/node-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,11 @@ tracing.workspace = true
# crypto
alloy-rlp.workspace = true
alloy-chains.workspace = true
secp256k1 = { workspace = true, features = ["global-context", "rand-std", "recovery"] }
secp256k1 = { workspace = true, features = [
"global-context",
"rand-std",
"recovery",
] }

# async
futures.workspace = true
Expand Down Expand Up @@ -118,6 +122,7 @@ optimism = [
"reth-blockchain-tree/optimism",
"reth-beacon-consensus/optimism",
"reth-optimism-payload-builder/optimism",
"reth-node-api/optimism",
]

jemalloc = ["dep:jemalloc-ctl"]
Expand Down
2 changes: 1 addition & 1 deletion crates/node-optimism/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ reth-node-api.workspace = true
serde.workspace = true

[features]
optimism = []
optimism = ["reth-node-api/optimism"]
3 changes: 2 additions & 1 deletion crates/payload/builder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,6 @@ optimism = [
"reth-rpc-types/optimism",
"reth-rpc-types-compat/optimism",
"reth-interfaces/optimism",
"reth-transaction-pool/optimism"
"reth-transaction-pool/optimism",
"reth-node-api/optimism",
]
1 change: 1 addition & 0 deletions crates/revm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,6 @@ optimism = [
"reth-primitives/optimism",
"reth-consensus-common/optimism",
"reth-interfaces/optimism",
"reth-node-api/optimism",
]
js-tracer = ["revm-inspectors/js-tracer"]
1 change: 1 addition & 0 deletions crates/rpc/rpc-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ serde_json.workspace = true

[features]
client = ["jsonrpsee/client", "jsonrpsee/async-client"]
optimism = ["reth-node-api/optimism"]
2 changes: 1 addition & 1 deletion crates/rpc/rpc-builder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ reth-tracing.workspace = true
reth-transaction-pool = { workspace = true, features = ["test-utils"] }

tokio = { workspace = true, features = ["rt", "rt-multi-thread"] }
serde_json.workspace = true
serde_json.workspace = true
6 changes: 5 additions & 1 deletion crates/rpc/rpc-engine-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,8 @@ reth-payload-builder = { workspace = true, features = ["test-utils"] }
assert_matches.workspace = true

[features]
optimism = ["reth-primitives/optimism", "reth-rpc-types/optimism"]
optimism = [
"reth-primitives/optimism",
"reth-rpc-types/optimism",
"reth-node-api/optimism",
]
11 changes: 9 additions & 2 deletions crates/rpc/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ hyper = "0.14.24"
jsonwebtoken = "8"

## required for optimism sequencer delegation
reqwest = { version = "0.11", default-features = false, features = ["rustls-tls"], optional = true }
reqwest = { version = "0.11", default-features = false, features = [
"rustls-tls",
], optional = true }

# async
async-trait.workspace = true
Expand All @@ -66,7 +68,11 @@ metrics.workspace = true

# misc
bytes.workspace = true
secp256k1 = { workspace = true, features = ["global-context", "rand-std", "recovery"] }
secp256k1 = { workspace = true, features = [
"global-context",
"rand-std",
"recovery",
] }
serde = { workspace = true, features = ["derive"] }
serde_json.workspace = true
thiserror.workspace = true
Expand Down Expand Up @@ -95,4 +101,5 @@ optimism = [
"reth-network/optimism",
"reth-provider/optimism",
"reth-transaction-pool/optimism",
"reth-node-api/optimism",
]
25 changes: 13 additions & 12 deletions crates/rpc/rpc/src/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ where
while let Some((index, tx)) = transactions.next() {
let tx_hash = tx.hash;
let tx = tx_env_with_recovered(&tx);
let env = EnvWithHandlerCfg::new(
Env::boxed(cfg.cfg_env.clone(), block_env.clone(), tx),
cfg.handler_cfg.spec_id,
);
let env = EnvWithHandlerCfg {
env: Env::boxed(cfg.cfg_env.clone(), block_env.clone(), tx),
handler_cfg: cfg.handler_cfg,
};
let (result, state_changes) = this
.trace_transaction(
opts.clone(),
Expand Down Expand Up @@ -237,10 +237,11 @@ where
tx.hash,
)?;

let env = EnvWithHandlerCfg::new(
Env::boxed(cfg.cfg_env.clone(), block_env, tx_env_with_recovered(&tx)),
cfg.handler_cfg.spec_id,
);
let env = EnvWithHandlerCfg {
env: Env::boxed(cfg.cfg_env.clone(), block_env, tx_env_with_recovered(&tx)),
handler_cfg: cfg.handler_cfg,
};

this.trace_transaction(
opts,
env,
Expand Down Expand Up @@ -436,10 +437,10 @@ where
// Execute all transactions until index
for tx in transactions {
let tx = tx_env_with_recovered(&tx);
let env = EnvWithHandlerCfg::new(
Env::boxed(cfg.cfg_env.clone(), block_env.clone(), tx),
cfg.handler_cfg.spec_id,
);
let env = EnvWithHandlerCfg {
env: Env::boxed(cfg.cfg_env.clone(), block_env.clone(), tx),
handler_cfg: cfg.handler_cfg,
};
let (res, _) = transact(&mut db, env)?;
db.commit(res.state);
}
Expand Down
3 changes: 2 additions & 1 deletion crates/storage/provider/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,6 @@ rand.workspace = true
test-utils = ["alloy-rlp", "reth-db/test-utils"]
optimism = [
"reth-primitives/optimism",
"reth-interfaces/optimism"
"reth-interfaces/optimism",
"reth-node-api/optimism"
]

0 comments on commit 4c8f31a

Please sign in to comment.