Skip to content

Commit

Permalink
feat: impl wallet_ namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
onbjerg committed Oct 8, 2024
1 parent fa3f2e7 commit 95220dc
Show file tree
Hide file tree
Showing 7 changed files with 338 additions and 7 deletions.
12 changes: 12 additions & 0 deletions Cargo.lock

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

5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ reth-chainspec = { git = "https://github.com/paradigmxyz/reth.git", rev = "78426
] }
reth-cli = { git = "https://github.com/paradigmxyz/reth.git", rev = "7842673" }
reth-cli-util = { git = "https://github.com/paradigmxyz/reth.git", rev = "7842673" }
reth-rpc-eth-api = { git = "https://github.com/paradigmxyz/reth.git", rev = "7842673", features = [
"optimism",
] }
reth-node-api = { git = "https://github.com/paradigmxyz/reth.git", rev = "7842673" }
reth-node-builder = { git = "https://github.com/paradigmxyz/reth.git", rev = "7842673" }
reth-node-core = { git = "https://github.com/paradigmxyz/reth.git", rev = "7842673", features = [
Expand All @@ -106,6 +109,7 @@ reth-provider = { git = "https://github.com/paradigmxyz/reth.git", rev = "784267
reth-revm = { git = "https://github.com/paradigmxyz/reth.git", rev = "7842673", features = [
"optimism",
] }
reth-storage-api = { git = "https://github.com/paradigmxyz/reth.git", rev = "7842673" }
reth-tracing = { git = "https://github.com/paradigmxyz/reth.git", rev = "7842673" }
reth-transaction-pool = { git = "https://github.com/paradigmxyz/reth.git", rev = "7842673" }

Expand All @@ -119,6 +123,7 @@ tracing = "0.1.0"
serde = "1"
serde_json = "1"
once_cell = "1.19"
thiserror = "1"

# misc-testing
rstest = "0.18.2"
5 changes: 5 additions & 0 deletions bin/alphanet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ default-run = "alphanet"
workspace = true

[dependencies]
alloy-signer-local.workspace = true
alloy-network.workspace = true
alloy-primitives.workspace = true
alphanet-node.workspace = true
alphanet-wallet.workspace = true
eyre.workspace = true
tracing.workspace = true
reth-cli-util.workspace = true
reth-node-builder.workspace = true
Expand Down
36 changes: 36 additions & 0 deletions bin/alphanet/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,19 @@
//! - `min-debug-logs`: Disables all logs below `debug` level.
//! - `min-trace-logs`: Disables all logs below `trace` level.

use alloy_network::EthereumWallet;
use alloy_primitives::Address;
use alloy_signer_local::PrivateKeySigner;
use alphanet_node::{chainspec::AlphanetChainSpecParser, node::AlphaNetNode};
use alphanet_wallet::{AlphaNetWallet, AlphaNetWalletApiServer};
use clap::Parser;
use eyre::Context;
use reth_node_builder::{engine_tree_config::TreeConfig, EngineNodeLauncher};
use reth_optimism_cli::Cli;
use reth_optimism_node::{args::RollupArgs, node::OptimismAddOns};
use reth_optimism_rpc::sequencer::SequencerClient;
use reth_provider::providers::BlockchainProvider2;
use tracing::{info, warn};

// We use jemalloc for performance reasons.
#[cfg(all(feature = "jemalloc", unix))]
Expand Down Expand Up @@ -60,6 +66,36 @@ fn main() {
.set_sequencer_client(SequencerClient::new(sequencer_http))?;
}

// register alphanet wallet namespace
if let Ok(sk) = std::env::var("EXP1_SK") {
let signer: PrivateKeySigner =
sk.parse().wrap_err("Invalid EXP0001 secret key.")?;
let wallet = EthereumWallet::from(signer);

let raw_delegations = std::env::var("EXP1_WHITELIST")
.wrap_err("No EXP0001 delegations specified")?;
let valid_delegations: Vec<Address> = raw_delegations
.split(',')
.map(|addr| Address::parse_checksummed(addr, None))
.collect::<Result<_, _>>()
.wrap_err("No valid EXP0001 delegations specified")?;

ctx.modules.merge_configured(
AlphaNetWallet::new(
ctx.provider().clone(),
wallet,
ctx.registry.eth_api().clone(),
ctx.config().chain.chain().id(),
valid_delegations,
)
.into_rpc(),
)?;

info!(target: "reth::cli", "EXP0001 wallet configured");
} else {
warn!(target: "reth::cli", "EXP0001 wallet not configured");
}

Ok(())
})
.launch_with_fn(|builder| {
Expand Down
2 changes: 1 addition & 1 deletion clippy.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
msrv = "1.80"
msrv = "1.81"
allow-dbg-in-tests = true
10 changes: 10 additions & 0 deletions crates/wallet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,20 @@ keywords.workspace = true
categories.workspace = true

[dependencies]
alloy-network.workspace = true
alloy-primitives.workspace = true
alloy-rpc-types.workspace = true
jsonrpsee = { workspace = true, features = ["server", "macros"] }
reth-primitives.workspace = true
reth-storage-api.workspace = true
reth-rpc-eth-api.workspace = true
serde = { workspace = true, features = ["derive"] }
thiserror.workspace = true
tracing.workspace = true

[dev-dependencies]
serde_json.workspace = true
jsonrpsee = { workspace = true, features = ["server", "client", "macros"] }

[lints]
workspace = true
Loading

0 comments on commit 95220dc

Please sign in to comment.