mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat(builder): ethereum builder config (#13315)
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
use crate::{cli::config::PayloadBuilderConfig, version::default_extradata};
|
||||
use crate::{cli::config::PayloadBuilderConfig, version::default_extra_data};
|
||||
use alloy_consensus::constants::MAXIMUM_EXTRA_DATA_SIZE;
|
||||
use alloy_eips::{eip1559::ETHEREUM_BLOCK_GAS_LIMIT, merge::SLOT_DURATION};
|
||||
use clap::{
|
||||
@ -13,7 +13,7 @@ use std::{borrow::Cow, ffi::OsStr, time::Duration};
|
||||
#[command(next_help_heading = "Builder")]
|
||||
pub struct PayloadBuilderArgs {
|
||||
/// Block extra data set by the payload builder.
|
||||
#[arg(long = "builder.extradata", value_parser = ExtradataValueParser::default(), default_value_t = default_extradata())]
|
||||
#[arg(long = "builder.extradata", value_parser = ExtradataValueParser::default(), default_value_t = default_extra_data())]
|
||||
pub extradata: String,
|
||||
|
||||
/// Target gas ceiling for built blocks.
|
||||
@ -40,7 +40,7 @@ pub struct PayloadBuilderArgs {
|
||||
impl Default for PayloadBuilderArgs {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
extradata: default_extradata(),
|
||||
extradata: default_extra_data(),
|
||||
max_gas_limit: ETHEREUM_BLOCK_GAS_LIMIT,
|
||||
interval: Duration::from_secs(1),
|
||||
deadline: SLOT_DURATION,
|
||||
@ -130,7 +130,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_default_extradata() {
|
||||
let extradata = default_extradata();
|
||||
let extradata = default_extra_data();
|
||||
let args = CommandParser::<PayloadBuilderArgs>::parse_from([
|
||||
"reth",
|
||||
"--builder.extradata",
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
//! Version information for reth.
|
||||
use alloy_primitives::Bytes;
|
||||
use alloy_rpc_types_engine::ClientCode;
|
||||
use reth_db::ClientVersion;
|
||||
|
||||
@ -114,7 +115,7 @@ pub(crate) const P2P_CLIENT_VERSION: &str = const_format::concatcp!(
|
||||
env!("VERGEN_CARGO_TARGET_TRIPLE")
|
||||
);
|
||||
|
||||
/// The default extradata used for payload building.
|
||||
/// The default extra data used for payload building.
|
||||
///
|
||||
/// - The latest version from Cargo.toml
|
||||
/// - The OS identifier
|
||||
@ -124,10 +125,16 @@ pub(crate) const P2P_CLIENT_VERSION: &str = const_format::concatcp!(
|
||||
/// ```text
|
||||
/// reth/v{major}.{minor}.{patch}/{OS}
|
||||
/// ```
|
||||
pub fn default_extradata() -> String {
|
||||
pub fn default_extra_data() -> String {
|
||||
format!("reth/v{}/{}", env!("CARGO_PKG_VERSION"), std::env::consts::OS)
|
||||
}
|
||||
|
||||
/// The default extra data in bytes.
|
||||
/// See [`default_extra_data`].
|
||||
pub fn default_extra_data_bytes() -> Bytes {
|
||||
Bytes::from(default_extra_data().as_bytes().to_vec())
|
||||
}
|
||||
|
||||
/// The default client version accessing the database.
|
||||
pub fn default_client_version() -> ClientVersion {
|
||||
ClientVersion {
|
||||
@ -143,7 +150,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn assert_extradata_less_32bytes() {
|
||||
let extradata = default_extradata();
|
||||
let extradata = default_extra_data();
|
||||
assert!(extradata.len() <= 32, "extradata must be less than 32 bytes: {extradata}")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user