Skip to content
This repository was archived by the owner on Feb 6, 2025. It is now read-only.

feat: add bsc node bin #6

Merged
merged 5 commits into from
May 15, 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
29 changes: 29 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,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 @@ -276,6 +277,7 @@ reth-trie-parallel = { path = "crates/trie-parallel" }
reth-optimism-consensus = { path = "crates/optimism/consensus" }
reth-node-events = { path = "crates/node/events" }
reth-testing-utils = { path = "testing/testing-utils" }
reth-node-bsc = { path = "crates/bsc/node" }

# revm
revm = { version = "8.0.0", features = ["std", "secp256k1"], default-features = false }
Expand Down
15 changes: 14 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,12 @@ optimism = [
"reth-node-core/optimism",
]

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 +161,7 @@ path = "src/main.rs"
name = "op-reth"
path = "src/optimism.rs"
required-features = ["optimism"]

[[bin]]
name = "bsc-reth"
path = "src/bsc.rs"
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);
}
}
46 changes: 46 additions & 0 deletions crates/bsc/node/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
[package]
name = "reth-node-bsc"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
license.workspace = true
homepage.workspace = true
repository.workspace = true

[lints]
workspace = true

[dependencies]
# 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

[features]
bsc = [
"reth-primitives/bsc",
"reth-network/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
Loading