fix(op): Add optimism in node api, few cfg transitions (#6598)

This commit is contained in:
rakita
2024-02-14 03:01:48 +01:00
committed by GitHub
parent eb8a805a94
commit 4c8f31a8c1
14 changed files with 57 additions and 25 deletions

View File

@ -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

View File

@ -68,4 +68,5 @@ optimism = [
"reth-rpc-types/optimism",
"reth-payload-builder/optimism",
"reth-blockchain-tree/optimism",
"reth-node-api/optimism",
]

View File

@ -19,3 +19,6 @@ thiserror.workspace = true
# io
serde.workspace = true
[features]
optimism = []

View File

@ -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)
}
@ -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(())

View File

@ -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
@ -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"]

View File

@ -21,4 +21,4 @@ reth-node-api.workspace = true
serde.workspace = true
[features]
optimism = []
optimism = ["reth-node-api/optimism"]

View File

@ -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",
]

View File

@ -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"]

View File

@ -24,3 +24,4 @@ serde_json.workspace = true
[features]
client = ["jsonrpsee/client", "jsonrpsee/async-client"]
optimism = ["reth-node-api/optimism"]

View File

@ -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",
]

View File

@ -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
@ -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
@ -95,4 +101,5 @@ optimism = [
"reth-network/optimism",
"reth-provider/optimism",
"reth-transaction-pool/optimism",
"reth-node-api/optimism",
]

View File

@ -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(),
@ -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,
@ -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);
}

View File

@ -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"
]