Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: bump reth #111

Merged
merged 1 commit into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,534 changes: 818 additions & 716 deletions Cargo.lock

Large diffs are not rendered by default.

34 changes: 24 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,32 @@ alloy-signer-local = { version = "0.3", features = ["mnemonic"] }
tokio = { version = "1.21", default-features = false }

# reth
reth = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.0.6", features = [
reth = { git = "https://github.com/paradigmxyz/reth.git", rev = "c1b5fbb" }
reth-chainspec = { git = "https://github.com/paradigmxyz/reth.git", rev = "c1b5fbb", features = [
"optimism",
] }
reth-chainspec = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.0.6" }
reth-cli-util = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.0.6" }
reth-node-api = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.0.6" }
reth-node-builder = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.0.6" }
reth-node-core = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.0.6" }
reth-node-optimism = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.0.6" }
reth-optimism-rpc = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.0.6" }
reth-primitives = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.0.6" }
reth-tracing = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.0.6" }
reth-cli-util = { git = "https://github.com/paradigmxyz/reth.git", rev = "c1b5fbb" }
reth-node-api = { git = "https://github.com/paradigmxyz/reth.git", rev = "c1b5fbb" }
reth-node-builder = { git = "https://github.com/paradigmxyz/reth.git", rev = "c1b5fbb" }
reth-node-core = { git = "https://github.com/paradigmxyz/reth.git", rev = "c1b5fbb", features = [
"optimism",
] }
reth-node-optimism = { git = "https://github.com/paradigmxyz/reth.git", rev = "c1b5fbb", features = [
"optimism",
] }
reth-optimism-cli = { git = "https://github.com/paradigmxyz/reth.git", rev = "c1b5fbb", features = [
"optimism",
] }
reth-optimism-rpc = { git = "https://github.com/paradigmxyz/reth.git", rev = "c1b5fbb", features = [
"optimism",
] }
reth-primitives = { git = "https://github.com/paradigmxyz/reth.git", rev = "c1b5fbb", features = [
"optimism",
] }
reth-revm = { git = "https://github.com/paradigmxyz/reth.git", rev = "c1b5fbb", features = [
"optimism",
] }
reth-tracing = { git = "https://github.com/paradigmxyz/reth.git", rev = "c1b5fbb" }

# misc
clap = "4"
Expand Down
6 changes: 3 additions & 3 deletions bin/alphanet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ workspace = true
[dependencies]
alphanet-node.workspace = true
tracing.workspace = true
reth.workspace = true
reth-cli-util.workspace = true
reth-node-optimism.workspace = true
reth-optimism-cli.workspace = true
reth-optimism-rpc.workspace = true
clap = { workspace = true, features = ["derive"] }

[target.'cfg(not(windows))'.dependencies]
tikv-jemallocator = { version = "0.5", optional = true }

[features]
default = ["jemalloc", "reth/optimism", "reth-node-optimism/optimism"]
default = ["jemalloc"]

asm-keccak = ["reth/asm-keccak"]
asm-keccak = ["reth-optimism-cli/asm-keccak"]

jemalloc = ["dep:tikv-jemallocator"]
jemalloc-prof = ["jemalloc", "tikv-jemallocator?/profiling"]
Expand Down
36 changes: 19 additions & 17 deletions bin/alphanet/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@

use alphanet_node::node::AlphaNetNode;
use clap::Parser;
use reth::cli::Cli;
use reth_node_optimism::args::RollupArgs;
use reth_optimism_cli::{chainspec::OpChainSpecParser, Cli};
use reth_optimism_rpc::eth::rpc::SequencerClient;

// We use jemalloc for performance reasons.
Expand All @@ -44,24 +44,26 @@ fn main() {
std::env::set_var("RUST_BACKTRACE", "1");
}

if let Err(err) = Cli::<RollupArgs>::parse().run(|builder, rollup_args| async move {
let node = builder
.node(AlphaNetNode::new(rollup_args.clone()))
.extend_rpc_modules(move |ctx| {
// register sequencer tx forwarder
if let Some(sequencer_http) = rollup_args.sequencer_http.clone() {
ctx.registry
.eth_api()
.set_sequencer_client(SequencerClient::new(sequencer_http));
}
if let Err(err) =
Cli::<OpChainSpecParser, RollupArgs>::parse().run(|builder, rollup_args| async move {
let node = builder
.node(AlphaNetNode::new(rollup_args.clone()))
.extend_rpc_modules(move |ctx| {
// register sequencer tx forwarder
if let Some(sequencer_http) = rollup_args.sequencer_http.clone() {
ctx.registry
.eth_api()
.set_sequencer_client(SequencerClient::new(sequencer_http));
}

Ok(())
})
.launch()
.await?;
Ok(())
})
.launch()
.await?;

node.wait_for_node_exit().await
}) {
node.wait_for_node_exit().await
})
{
eprintln!("Error: {err:?}");
std::process::exit(1);
}
Expand Down
11 changes: 3 additions & 8 deletions crates/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,14 @@ categories.workspace = true

[dependencies]
alphanet-precompile.workspace = true
reth.workspace = true
reth-node-api.workspace = true
reth-node-builder.workspace = true
reth-node-optimism.workspace = true
reth-chainspec.workspace = true
reth-primitives.workspace = true
reth-revm.workspace = true

eyre.workspace = true

[features]
default = [
"alphanet-precompile/optimism",
"reth/optimism",
"reth-node-optimism/optimism",
]

[lints]
workspace = true
106 changes: 55 additions & 51 deletions crates/node/src/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,34 @@
//! precompiles defined by [`alphanet_precompile`].

use alphanet_precompile::secp256r1;
use reth::{
primitives::{
revm_primitives::{CfgEnvWithHandlerCfg, TxEnv},
transaction::FillTxEnv,
Address, Bytes, Header, TransactionSigned, TxKind, U256,
},
revm::{
handler::register::EvmHandler,
inspector_handle_register,
precompile::PrecompileSpecId,
primitives::{AnalysisKind, Env, OptimismFields},
ContextPrecompiles, Database, Evm, EvmBuilder, GetInspector,
},
};
use reth_chainspec::{ChainSpec, EthereumHardfork, Head, OptimismHardfork};
use reth_node_api::{ConfigureEvm, ConfigureEvmEnv};
use reth_primitives::{
revm_primitives::{CfgEnvWithHandlerCfg, TxEnv},
transaction::FillTxEnv,
Address, Bytes, Header, TransactionSigned, TxKind, U256,
};
use reth_revm::{
handler::register::EvmHandler,
inspector_handle_register,
precompile::PrecompileSpecId,
primitives::{AnalysisKind, Env, OptimismFields},
ContextPrecompiles, Database, Evm, EvmBuilder, GetInspector,
};
use std::sync::Arc;

/// Custom EVM configuration
#[derive(Debug, Clone, Copy, Default)]
#[non_exhaustive]
pub struct AlphaNetEvmConfig;
#[derive(Debug, Clone, Default)]
pub struct AlphaNetEvmConfig {
chain_spec: Arc<ChainSpec>,
}

impl AlphaNetEvmConfig {
/// Creates a new AlphaNet EVM configuration with the given chain spec.
pub const fn new(chain_spec: Arc<ChainSpec>) -> Self {
Self { chain_spec }
}

/// Sets the precompiles to the EVM handler
///
/// This will be invoked when the EVM is created via [ConfigureEvm::evm] or
Expand Down Expand Up @@ -113,12 +117,11 @@ impl ConfigureEvmEnv for AlphaNetEvmConfig {
fn fill_cfg_env(
&self,
cfg_env: &mut CfgEnvWithHandlerCfg,
chain_spec: &ChainSpec,
header: &Header,
total_difficulty: U256,
) {
let spec_id = revm_spec(
chain_spec,
&self.chain_spec,
&Head {
number: header.number,
timestamp: header.timestamp,
Expand All @@ -128,11 +131,11 @@ impl ConfigureEvmEnv for AlphaNetEvmConfig {
},
);

cfg_env.chain_id = chain_spec.chain().id();
cfg_env.chain_id = self.chain_spec.chain().id();
cfg_env.perf_analyse_created_bytecodes = AnalysisKind::Analyse;

cfg_env.handler_cfg.spec_id = spec_id;
cfg_env.handler_cfg.is_optimism = chain_spec.is_optimism();
cfg_env.handler_cfg.is_optimism = self.chain_spec.is_optimism();
}
}

Expand Down Expand Up @@ -167,47 +170,47 @@ impl ConfigureEvm for AlphaNetEvmConfig {
}

/// Determine the revm spec ID from the current block and reth chainspec.
fn revm_spec(chain_spec: &ChainSpec, block: &Head) -> reth::revm::primitives::SpecId {
fn revm_spec(chain_spec: &ChainSpec, block: &Head) -> reth_revm::primitives::SpecId {
if chain_spec.fork(EthereumHardfork::Prague).active_at_head(block) {
reth::revm::primitives::PRAGUE_EOF
reth_revm::primitives::PRAGUE_EOF
} else if chain_spec.fork(OptimismHardfork::Granite).active_at_head(block) {
reth::revm::primitives::GRANITE
reth_revm::primitives::GRANITE
} else if chain_spec.fork(OptimismHardfork::Fjord).active_at_head(block) {
reth::revm::primitives::FJORD
reth_revm::primitives::FJORD
} else if chain_spec.fork(OptimismHardfork::Ecotone).active_at_head(block) {
reth::revm::primitives::ECOTONE
reth_revm::primitives::ECOTONE
} else if chain_spec.fork(OptimismHardfork::Canyon).active_at_head(block) {
reth::revm::primitives::CANYON
reth_revm::primitives::CANYON
} else if chain_spec.fork(OptimismHardfork::Regolith).active_at_head(block) {
reth::revm::primitives::REGOLITH
reth_revm::primitives::REGOLITH
} else if chain_spec.fork(OptimismHardfork::Bedrock).active_at_head(block) {
reth::revm::primitives::BEDROCK
reth_revm::primitives::BEDROCK
} else if chain_spec.fork(EthereumHardfork::Prague).active_at_head(block) {
reth::revm::primitives::PRAGUE
reth_revm::primitives::PRAGUE
} else if chain_spec.fork(EthereumHardfork::Cancun).active_at_head(block) {
reth::revm::primitives::CANCUN
reth_revm::primitives::CANCUN
} else if chain_spec.fork(EthereumHardfork::Shanghai).active_at_head(block) {
reth::revm::primitives::SHANGHAI
reth_revm::primitives::SHANGHAI
} else if chain_spec.fork(EthereumHardfork::Paris).active_at_head(block) {
reth::revm::primitives::MERGE
reth_revm::primitives::MERGE
} else if chain_spec.fork(EthereumHardfork::London).active_at_head(block) {
reth::revm::primitives::LONDON
reth_revm::primitives::LONDON
} else if chain_spec.fork(EthereumHardfork::Berlin).active_at_head(block) {
reth::revm::primitives::BERLIN
reth_revm::primitives::BERLIN
} else if chain_spec.fork(EthereumHardfork::Istanbul).active_at_head(block) {
reth::revm::primitives::ISTANBUL
reth_revm::primitives::ISTANBUL
} else if chain_spec.fork(EthereumHardfork::Petersburg).active_at_head(block) {
reth::revm::primitives::PETERSBURG
reth_revm::primitives::PETERSBURG
} else if chain_spec.fork(EthereumHardfork::Byzantium).active_at_head(block) {
reth::revm::primitives::BYZANTIUM
reth_revm::primitives::BYZANTIUM
} else if chain_spec.fork(EthereumHardfork::SpuriousDragon).active_at_head(block) {
reth::revm::primitives::SPURIOUS_DRAGON
reth_revm::primitives::SPURIOUS_DRAGON
} else if chain_spec.fork(EthereumHardfork::Tangerine).active_at_head(block) {
reth::revm::primitives::TANGERINE
reth_revm::primitives::TANGERINE
} else if chain_spec.fork(EthereumHardfork::Homestead).active_at_head(block) {
reth::revm::primitives::HOMESTEAD
reth_revm::primitives::HOMESTEAD
} else if chain_spec.fork(EthereumHardfork::Frontier).active_at_head(block) {
reth::revm::primitives::FRONTIER
reth_revm::primitives::FRONTIER
} else {
panic!(
"invalid hardfork chainspec: expected at least one hardfork, got {:?}",
Expand All @@ -219,28 +222,29 @@ fn revm_spec(chain_spec: &ChainSpec, block: &Head) -> reth::revm::primitives::Sp
#[cfg(test)]
mod tests {
use super::*;
use reth::primitives::{
use reth_chainspec::{Chain, ChainSpecBuilder, EthereumHardfork};
use reth_primitives::{
revm_primitives::{BlockEnv, CfgEnv, SpecId},
ForkCondition, Genesis,
};
use reth_chainspec::{Chain, ChainSpecBuilder, EthereumHardfork};

#[test]
fn test_fill_cfg_and_block_env() {
let mut cfg_env = CfgEnvWithHandlerCfg::new_with_spec_id(CfgEnv::default(), SpecId::LATEST);
let mut block_env = BlockEnv::default();
let header = Header::default();
let chain_spec = ChainSpecBuilder::default()
.chain(Chain::optimism_mainnet())
.genesis(Genesis::default())
.with_fork(EthereumHardfork::Frontier, ForkCondition::Block(0))
.build();
let chain_spec = Arc::new(
ChainSpecBuilder::default()
.chain(Chain::optimism_mainnet())
.genesis(Genesis::default())
.with_fork(EthereumHardfork::Frontier, ForkCondition::Block(0))
.build(),
);
let total_difficulty = U256::ZERO;

AlphaNetEvmConfig::default().fill_cfg_and_block_env(
AlphaNetEvmConfig::new(chain_spec.clone()).fill_cfg_and_block_env(
&mut cfg_env,
&mut block_env,
&chain_spec,
&header,
total_difficulty,
);
Expand Down
4 changes: 2 additions & 2 deletions crates/node/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
//! [AlphaNetEvmConfig](evm::AlphaNetEvmConfig).
//!
//! The [AlphaNetNode](node::AlphaNetNode) type implements the
//! [NodeTypes](reth::builder::NodeTypes) trait, and configures the engine types required for the
//! optimism engine API.
//! [NodeTypes](reth_node_builder::NodeTypes) trait, and configures the engine types required for
//! the optimism engine API.
//!
//! The [AlphaNetEvmConfig](evm::AlphaNetEvmConfig) type implements the
//! [ConfigureEvm](reth_node_api::ConfigureEvm) and
Expand Down
Loading