Skip to content

feat(l1): properly format client version #2564

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

Merged
merged 44 commits into from
Apr 30, 2025
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
0a51c91
Add more information to client version
Mechanix97 Apr 23, 2025
dad8631
Use const variables
Mechanix97 Apr 24, 2025
6bd21d5
Use vergen to get more envs vars
Mechanix97 Apr 24, 2025
e732be8
remove unnecesary dependencies
Mechanix97 Apr 24, 2025
00221ea
Add develop tag hardcoded
Mechanix97 Apr 24, 2025
e4ea587
Merge branch 'main' into feat/properly-format-client-version
Mechanix97 Apr 24, 2025
72719f4
Refactor to ethrex_constart, added to hello_message
Mechanix97 Apr 24, 2025
8bfbac9
Merge branch 'main' into feat/properly-format-client-version
Mechanix97 Apr 24, 2025
76c4be9
Merge remote-tracking branch 'Origin/main' into feat/properly-format-…
Mechanix97 Apr 24, 2025
3d7fbc2
Merge branch 'main' into feat/properly-format-client-version
Mechanix97 Apr 24, 2025
8d2a846
Added function to abstract the client information
Mechanix97 Apr 24, 2025
7ff8460
Add rpc admin
Mechanix97 Apr 24, 2025
61fe0f0
Merge branch 'main' into feat/properly-format-client-version
Mechanix97 Apr 24, 2025
b5c83ad
Merge branch 'main' into feat/properly-format-client-version
Mechanix97 Apr 25, 2025
82d5b27
Merge branch 'main' into feat/properly-format-client-version
Mechanix97 Apr 25, 2025
37a244f
Merge branch 'main' into feat/properly-format-client-version
Mechanix97 Apr 28, 2025
5d40b89
Merge branch 'main' into feat/properly-format-client-version
Mechanix97 Apr 28, 2025
307a37e
feat use client_info as argument
Mechanix97 Apr 28, 2025
7870d5d
Merge branch 'main' into feat/properly-format-client-version
Mechanix97 Apr 28, 2025
36362a3
Merge branch 'feat/properly-format-client-version' of github.com:lamb…
Mechanix97 Apr 28, 2025
4209edb
Fix tests
Mechanix97 Apr 28, 2025
043809b
Fix client version RPC
Mechanix97 Apr 28, 2025
f3beab3
Fix tests
Mechanix97 Apr 28, 2025
545abc8
Fix RPC test
Mechanix97 Apr 28, 2025
fd3c16d
add admin client_info
Mechanix97 Apr 28, 2025
2a9a2e5
Merge branch 'main' into feat/properly-format-client-version
Mechanix97 Apr 28, 2025
2fce0fa
Fix clippy
Mechanix97 Apr 28, 2025
ac77a8b
Merge branch 'feat/properly-format-client-version' of github.com:lamb…
Mechanix97 Apr 28, 2025
6998ffd
add version command
Mechanix97 Apr 28, 2025
545283b
nit get_client_version
Mechanix97 Apr 28, 2025
0d40ea1
replace client_version
Mechanix97 Apr 28, 2025
9127a09
Merge branch 'main' into feat/properly-format-client-version
Mechanix97 Apr 29, 2025
e4cc096
Merge branch 'main' into feat/properly-format-client-version
Mechanix97 Apr 29, 2025
4d6cb67
fix merge
Mechanix97 Apr 29, 2025
3c0ed5f
Merge branch 'feat/properly-format-client-version' of github.com:lamb…
Mechanix97 Apr 29, 2025
ba76106
Fix merge2
Mechanix97 Apr 29, 2025
9bf2727
Fix merge2
Mechanix97 Apr 29, 2025
01b0076
Merge branch 'feat/properly-format-client-version' of github.com:lamb…
Mechanix97 Apr 29, 2025
48c1e09
cargo fmt
Mechanix97 Apr 29, 2025
e534575
chenge vergen import
Mechanix97 Apr 30, 2025
51a7dbd
nit new line
Mechanix97 Apr 30, 2025
76d7ab5
Remove Web3 mod
Mechanix97 Apr 30, 2025
26edb2c
Add comment to build
Mechanix97 Apr 30, 2025
c2b1ca2
Merge branch 'main' into feat/properly-format-client-version
Mechanix97 Apr 30, 2025
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
4 changes: 4 additions & 0 deletions crates/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name = "ethrex-common"
version = "0.1.0"
edition = "2021"
build = "build.rs"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand Down Expand Up @@ -37,3 +38,6 @@ c-kzg = ["dep:c-kzg"]

[lib]
path = "./common.rs"

[build-dependencies]
vergen = { version = "9.0.0", features = ["rustc"] }
9 changes: 9 additions & 0 deletions crates/common/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
use std::error::Error;
use vergen::*;

fn main() -> Result<(), Box<dyn Error>> {
let rustc = RustcBuilder::all_rustc()?;

Emitter::default().add_instructions(&rustc)?.emit()?;
Ok(())
}
6 changes: 6 additions & 0 deletions crates/common/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,9 @@ pub const GAS_PER_BLOB: u64 = 1 << 17;

// Minimum base fee per blob
pub const MIN_BASE_FEE_PER_BLOB_GAS: u64 = 1;

pub const ETHREX_PKG_NAME: &str = env!("CARGO_PKG_NAME");
pub const ETHREX_PKG_VERSION: &str = env!("CARGO_PKG_VERSION");
pub const ETHREX_COMMIT_HASH: &str = env!("VERGEN_RUSTC_COMMIT_HASH");
pub const ETHREX_BUILD_OS: &str = env!("VERGEN_RUSTC_HOST_TRIPLE");
pub const ETHREX_RUSTC_VERSION: &str = env!("VERGEN_RUSTC_SEMVER");
12 changes: 11 additions & 1 deletion crates/networking/p2p/rlpx/p2p.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
use bytes::BufMut;
use ethrex_common::constants;
use ethrex_common::H512;
use ethrex_rlp::{
decode::RLPDecode,
encode::RLPEncode,
error::{RLPDecodeError, RLPEncodeError},
structs::{Decoder, Encoder},
};

use k256::PublicKey;

use crate::rlpx::utils::{id2pubkey, snappy_decompress};
Expand Down Expand Up @@ -63,9 +65,17 @@ impl HelloMessage {

impl RLPxMessage for HelloMessage {
fn encode(&self, mut buf: &mut dyn BufMut) -> Result<(), RLPEncodeError> {
let client_id = format!(
"{}/v{}-develop-{}/{}/rustc-v{}",
constants::ETHREX_PKG_NAME,
constants::ETHREX_PKG_VERSION,
&constants::ETHREX_COMMIT_HASH[0..6],
constants::ETHREX_BUILD_OS,
constants::ETHREX_RUSTC_VERSION
);
Encoder::new(&mut buf)
.encode_field(&5_u8) // protocolVersion
.encode_field(&"Ethrex/0.1.0") // clientId
.encode_field(&client_id) // clientId
.encode_field(&self.capabilities) // capabilities
.encode_field(&0u8) // listenPort (ignored)
.encode_field(&pubkey2id(&self.node_id)) // nodeKey
Expand Down
10 changes: 9 additions & 1 deletion crates/networking/rpc/web3/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@ use ethrex_storage::Store;
use serde_json::Value;

use crate::utils::{RpcErr, RpcRequest};
use ethrex_common::constants;

pub fn client_version(_req: &RpcRequest, _store: Store) -> Result<Value, RpcErr> {
Ok(Value::String("[email protected]".to_owned()))
Ok(Value::String(format!(
"{}/v{}-develop-{}/{}/rustc-v{}",
constants::ETHREX_PKG_NAME,
constants::ETHREX_PKG_VERSION,
&constants::ETHREX_COMMIT_HASH[0..6],
constants::ETHREX_BUILD_OS,
constants::ETHREX_RUSTC_VERSION
)))
}
Loading