Skip to content

Commit

Permalink
feat: add genesis, system contracts and bin for bsc (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
forcodedancing authored May 15, 2024
1 parent fede7b9 commit e771b4f
Show file tree
Hide file tree
Showing 128 changed files with 2,462 additions and 233 deletions.
1,227 changes: 1,080 additions & 147 deletions Cargo.lock

Large diffs are not rendered by default.

9 changes: 6 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ members = [
"crates/transaction-pool/",
"crates/trie/",
"crates/trie-parallel/",
"crates/bsc/node/",
"examples/node-custom-rpc/",
"examples/beacon-api-sse/",
"examples/node-event-hooks/",
Expand Down Expand Up @@ -407,7 +408,9 @@ serial_test = "3"
similar-asserts = "1.5.0"
test-fuzz = "5"


[patch.crates-io]
# TODO: update to official version
revm = { git = "https://github.com/bnb-chain/revm", rev = "baf5e15d053b9cc183d69867934f40ffece898e1" }
revm-primitives = { git = "https://github.com/bnb-chain/revm", rev = "baf5e15d053b9cc183d69867934f40ffece898e1" }
revm = { git = "https://github.com/bnb-chain/revm.git", rev = "d99a54e461d6e6506fc6707ed1d2547915bbf943", features = ["std", "secp256k1"], default-features = false }
revm-primitives = { git = "https://github.com/bnb-chain/revm.git", rev = "d99a54e461d6e6506fc6707ed1d2547915bbf943", features = ["std"], default-features = false }
alloy-chains = { git = "https://github.com/bnb-chain/alloy-chains-rs.git", branch = "feat/v0.1.15-opbnb", feature = ["serde", "rlp", "arbitrary"] }
alloy-genesis = { git = "https://github.com/forcodedancing/alloy", branch = "feat/parlia-config" }
17 changes: 16 additions & 1 deletion bin/reth/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ license.workspace = true
homepage.workspace = true
repository.workspace = true
description = "Reth node implementation"
default-run = "reth"
default-run = "bsc-reth"

[lints]
workspace = true
Expand Down Expand Up @@ -55,6 +55,9 @@ reth-node-core.workspace = true
reth-node-builder.workspace = true
reth-node-events.workspace = true
reth-consensus.workspace = true
reth-node-bsc = { workspace = true, optional = true, features = [
"bsc",
] }

# crypto
alloy-rlp.workspace = true
Expand Down Expand Up @@ -141,6 +144,13 @@ optimism = [
"reth-node-core/optimism",
]

bsc = [
"reth-rpc/bsc",
"reth-primitives/bsc",
"dep:reth-node-bsc",
"reth-node-core/bsc"
]

# no-op feature flag for switching between the `optimism` and default functionality in CI matrices
ethereum = []

Expand All @@ -152,3 +162,8 @@ path = "src/main.rs"
name = "op-reth"
path = "src/optimism.rs"
required-features = ["optimism"]

[[bin]]
name = "bsc-reth"
path = "src/bsc.rs"
required-features = ["bsc"]
30 changes: 30 additions & 0 deletions bin/reth/src/bsc.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#![allow(missing_docs)]

// We use jemalloc for performance reasons.
#[cfg(all(feature = "jemalloc", unix))]
#[global_allocator]
static ALLOC: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;

#[cfg(all(feature = "optimism", not(test)))]
compile_error!("Cannot build the `reth` binary with the `optimism` feature flag enabled. Did you mean to build `op-reth`?");

#[cfg(feature = "bsc")]
fn main() {
use reth::cli::Cli;
use reth_node_bsc::BscNode;

reth::sigsegv_handler::install();

// Enable backtraces unless a RUST_BACKTRACE value has already been explicitly provided.
if std::env::var_os("RUST_BACKTRACE").is_none() {
std::env::set_var("RUST_BACKTRACE", "1");
}

if let Err(err) = Cli::parse_args().run(|builder, _| async {
let handle = builder.launch_node(BscNode::default()).await?;
handle.node_exit_future.await
}) {
eprintln!("Error: {err:?}");
std::process::exit(1);
}
}
2 changes: 1 addition & 1 deletion bin/reth/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ static ALLOC: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;
#[cfg(all(feature = "optimism", not(test)))]
compile_error!("Cannot build the `reth` binary with the `optimism` feature flag enabled. Did you mean to build `op-reth`?");

#[cfg(not(feature = "optimism"))]
#[cfg(all(not(feature = "optimism"), not(feature = "bsc")))]
fn main() {
use reth::cli::Cli;
use reth_node_ethereum::EthereumNode;
Expand Down
30 changes: 29 additions & 1 deletion crates/bsc/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,38 @@ repository.workspace = true
workspace = true

[dependencies]
# Reth
# reth
reth-payload-builder.workspace = true
reth-ethereum-engine-primitives.workspace = true
reth-basic-payload-builder.workspace = true
reth-ethereum-payload-builder.workspace = true
reth-node-builder.workspace = true
reth-tracing.workspace = true
reth-provider.workspace = true
reth-transaction-pool.workspace = true
reth-network.workspace = true
reth-evm-ethereum.workspace = true

# misc
eyre.workspace = true

[dev-dependencies]
reth.workspace = true
reth-db.workspace = true
reth-exex.workspace = true
reth-node-api.workspace = true
reth-node-core.workspace = true
reth-primitives.workspace = true
reth-e2e-test-utils.workspace = true
futures.workspace = true
tokio.workspace = true
futures-util.workspace = true
serde_json.workspace = true
reth-evm-bsc.workspace = true

[features]
bsc = [
"reth-primitives/bsc",
"reth-network/bsc",
"reth-evm-bsc/bsc",
]
6 changes: 6 additions & 0 deletions crates/bsc/node/src/evm.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//! BSC EVM support

#[doc(inline)]
pub use reth_evm_ethereum::execute::EthExecutorProvider; // TODO: bsc executor provider
#[doc(inline)]
pub use reth_evm_ethereum::EthEvmConfig; // TODO: bsc evm config
17 changes: 17 additions & 0 deletions crates/bsc/node/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//! Standalone crate for ethereum-specific Reth configuration and builder types.

#![doc(
html_logo_url = "https://raw.githubusercontent.com/paradigmxyz/reth/main/assets/reth-docs.png",
html_favicon_url = "https://avatars0.githubusercontent.com/u/97369466?s=256",
issue_tracker_base_url = "https://github.com/paradigmxyz/reth/issues/"
)]
#![cfg_attr(not(test), warn(unused_crate_dependencies))]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]

pub use reth_ethereum_engine_primitives::EthEngineTypes;

pub mod evm;
pub use evm::{EthEvmConfig, EthExecutorProvider};

pub mod node;
pub use node::BscNode;
Loading

0 comments on commit e771b4f

Please sign in to comment.