From c43950a194b2aa7c1aa7f7b2a1cb6c5d7bde3a81 Mon Sep 17 00:00:00 2001 From: woxjro Date: Wed, 20 Mar 2024 16:35:43 +0900 Subject: [PATCH 1/7] [feat]: add `ethereum-consensus` --- .gitmodules | 3 +++ Cargo.toml | 4 +++- ethereum-consensus | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 .gitmodules create mode 160000 ethereum-consensus diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..e6b2f03 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "ethereum-consensus"] + path = ethereum-consensus + url = git@github.com:ralexstokes/ethereum-consensus.git diff --git a/Cargo.toml b/Cargo.toml index 7d6332e..0167f59 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,13 +21,15 @@ futures = "0.3.28" ratatui = { version = "0.22.0", features = ["all-widgets"] } serde_json = "1.0.104" tokio = { version = "1.29.1", features = ["full"] } -clap = { version = "4.3.23", features = ["derive"] } +clap = { version = "4.5.3", features = ["derive"] } log = "0.4.20" simplelog = "0.12.1" serde = "1.0.189" url = "2.4.1" tempfile = "3.9.0" anyhow = "1.0.79" +beacon-api-client = { path = "ethereum-consensus/beacon-api-client" } +ethereum-consensus = { path = "ethereum-consensus/ethereum-consensus" } [dependencies.crossterm] version = "0.26.1" diff --git a/ethereum-consensus b/ethereum-consensus new file mode 160000 index 0000000..a52eabf --- /dev/null +++ b/ethereum-consensus @@ -0,0 +1 @@ +Subproject commit a52eabfdd4d408407a4e922b57962447ca6472bf From 7d462c95bc5a5e5dfea2d0c3a3572b40a4eb03fb Mon Sep 17 00:00:00 2001 From: woxjro Date: Wed, 20 Mar 2024 16:43:24 +0900 Subject: [PATCH 2/7] [feat]: add `examples/get_beacon_block.rs`` --- examples/get_beacon_block.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 examples/get_beacon_block.rs diff --git a/examples/get_beacon_block.rs b/examples/get_beacon_block.rs new file mode 100644 index 0000000..a2594b5 --- /dev/null +++ b/examples/get_beacon_block.rs @@ -0,0 +1,18 @@ +use beacon_api_client::{mainnet::Client, BlockId}; +use ethereum_consensus::primitives::Root; +use ethers::utils::hex; +use url::Url; + +#[tokio::main] +async fn main() { + let url = Url::parse("http://localhost:5052").unwrap(); + let client = Client::new(url); + + let root_hex = + hex::decode("421c16805c3416150aa04533fdfe7fc3f0880d0ed86cee33fa58011f10dd95c8").unwrap(); + let _root = Root::try_from(root_hex.as_ref()).unwrap(); + let id = BlockId::Finalized; + + let block = client.get_beacon_block(id).await.unwrap(); + dbg!(block); +} From 9e969e76707eae0e620e1b864eb7037a09a2c535 Mon Sep 17 00:00:00 2001 From: woxjro Date: Wed, 20 Mar 2024 22:43:31 +0900 Subject: [PATCH 3/7] [feat]: Add script for starting and shutting down a node --- utils/SETUP_NODE.sh | 20 ++++++++++++++++++++ utils/SHUTDOWN_NODE.sh | 7 +++++++ 2 files changed, 27 insertions(+) create mode 100755 utils/SETUP_NODE.sh create mode 100755 utils/SHUTDOWN_NODE.sh diff --git a/utils/SETUP_NODE.sh b/utils/SETUP_NODE.sh new file mode 100755 index 0000000..adb91ad --- /dev/null +++ b/utils/SETUP_NODE.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +GETH_LOG_FILE="./logs/geth.log" +LIGHTHOUSE_LOG_FILE="./logs/lighthouse.log" + +echo "Starting Ethereum Execution Node (geth)..." +geth --authrpc.addr localhost \ + --authrpc.port 8551 \ + --authrpc.vhosts localhost \ + --authrpc.jwtsecret ~/.ethereum/geth/jwtsecret >> "$GETH_LOG_FILE" 2>&1 & + +echo "Starting Beacon Node (lighthouse)..." +lighthouse bn \ + --network mainnet \ + --execution-endpoint http://localhost:8551 \ + --execution-jwt ~/.ethereum/geth/jwtsecret \ + --disable-deposit-contract-sync \ + --http >> "$LIGHTHOUSE_LOG_FILE" 2>&1 & +# --http \ +# --checkpoint-sync-url https://beaconstate.info >> "$LIGHTHOUSE_LOG_FILE" 2>&1 & diff --git a/utils/SHUTDOWN_NODE.sh b/utils/SHUTDOWN_NODE.sh new file mode 100755 index 0000000..df92325 --- /dev/null +++ b/utils/SHUTDOWN_NODE.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +echo "Shutting down Ethereum Execution Node (geth)..." +pkill geth + +echo "Shutting down Beacon Node (lighthouse)..." +pkill lighthouse From 7d3f646acb0b4d31434315d2c9d5d11f21103f4a Mon Sep 17 00:00:00 2001 From: woxjro Date: Wed, 20 Mar 2024 22:49:36 +0900 Subject: [PATCH 4/7] [docs]: update README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ca0e34f..c3e5fa4 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ This software has been tested and verified to work correctly on the following op - `macOS Ventura 13.2` ```sh -$ git clone https://github.com/woxjro/lazy-etherscan +$ git clone --recursive https://github.com/woxjro/lazy-etherscan $ cd lazy-etherscan $ cargo run -- ``` From 3174b295ab0ba3a7255ab72781b5a3a2982ce75c Mon Sep 17 00:00:00 2001 From: woxjro Date: Wed, 20 Mar 2024 22:58:57 +0900 Subject: [PATCH 5/7] [fix]: Used https instead of ssh --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index e6b2f03..a91f77f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "ethereum-consensus"] path = ethereum-consensus - url = git@github.com:ralexstokes/ethereum-consensus.git + url = https://github.com/ralexstokes/ethereum-consensus.git From 42d9b1b43e6783ffb6e78e74053d00252f89c8d2 Mon Sep 17 00:00:00 2001 From: haturatu Date: Sat, 19 Apr 2025 19:53:52 +0900 Subject: [PATCH 6/7] [chore]: eth.public-rpc.com -> eth.llamarpc.com --- docs/src/guide/configuration.md | 2 +- src/main.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/src/guide/configuration.md b/docs/src/guide/configuration.md index 761b863..ff37b7e 100644 --- a/docs/src/guide/configuration.md +++ b/docs/src/guide/configuration.md @@ -1,7 +1,7 @@ # Configuration ## Endpoint -The default endpoint is https://eth.public-rpc.com, and you can also set your preferred endpoint. +The default endpoint is https://eth.llamarpc.com, and you can also set your preferred endpoint. You can find free endpoints from [ChainList](https://chainlist.org/chain/1). To set your endpoint, run with a `--endpoint` option. ```sh diff --git a/src/main.rs b/src/main.rs index 52e15b1..939b296 100644 --- a/src/main.rs +++ b/src/main.rs @@ -20,7 +20,7 @@ use tokio::sync::Mutex; #[command(author, version, about, long_about = None)] struct Args { /// Json-RPC URL - #[arg(short, long, default_value = "https://eth.public-rpc.com")] + #[arg(short, long, default_value = "https://eth.llamarpc.com")] endpoint: String, } From 2e71b2f8700f43fb3deaec4610846f795303108b Mon Sep 17 00:00:00 2001 From: woxjro Date: Sun, 20 Apr 2025 20:32:03 +0900 Subject: [PATCH 7/7] [refactor]: display Total Difficulty conditionally --- src/ui/home/block/fee_info.rs | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/ui/home/block/fee_info.rs b/src/ui/home/block/fee_info.rs index e8b37b7..0b925e9 100644 --- a/src/ui/home/block/fee_info.rs +++ b/src/ui/home/block/fee_info.rs @@ -40,7 +40,7 @@ pub fn render( ), ]; - let details = vec![ + let mut details = vec![ Line::from( if app.block_detail_list_state.selected() == Some(SelectableBlockDetailItem::FeeRecipient.into()) @@ -53,21 +53,17 @@ pub fn render( fee_recipient_spans }, ), - //ref: https://docs.alchemy.com/docs/how-to-calculate-ethereum-miner-rewards#calculate-a-miner-reward - //format!("Block Reward: {} ETH", /* TODO */): - Line::from( - Span::raw(format!( - "{:<20}: {}", - "Total Difficulty", - block.total_difficulty.unwrap() - )) - .fg(Color::White), - ), Line::from( Span::raw(format!("{:<20}: {} bytes", "Size", block.size.unwrap())).fg(Color::White), ), ]; + if let Some(total_difficulty) = block.total_difficulty { + details.push(Line::from( + Span::raw(format!("{:<20}: {}", "Total Difficulty", total_difficulty)).fg(Color::White), + )); + } + let paragraph = Paragraph::new(details) .block(detail_block.to_owned()) .alignment(Alignment::Left)