diff --git a/Cargo.lock b/Cargo.lock index 718045b2..34bf566c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4226,7 +4226,6 @@ version = "0.1.0" dependencies = [ "anyhow", "bls", - "builder_api", "bytesize", "database", "derive_more 1.0.0", diff --git a/builder_api/src/lib.rs b/builder_api/src/lib.rs index 81782dc3..11f1beb2 100644 --- a/builder_api/src/lib.rs +++ b/builder_api/src/lib.rs @@ -4,6 +4,7 @@ pub use crate::{ Config as BuilderConfig, DEFAULT_BUILDER_MAX_SKIPPED_SLOTS, DEFAULT_BUILDER_MAX_SKIPPED_SLOTS_PER_EPOCH, }, + consts::PREFERRED_EXECUTION_GAS_LIMIT, }; pub mod combined; diff --git a/grandine/src/grandine_args.rs b/grandine/src/grandine_args.rs index 4d49aae6..fc88c6cd 100644 --- a/grandine/src/grandine_args.rs +++ b/grandine/src/grandine_args.rs @@ -16,6 +16,7 @@ use anyhow::{ensure, Result}; use bls::PublicKeyBytes; use builder_api::{ BuilderConfig, DEFAULT_BUILDER_MAX_SKIPPED_SLOTS, DEFAULT_BUILDER_MAX_SKIPPED_SLOTS_PER_EPOCH, + PREFERRED_EXECUTION_GAS_LIMIT, }; use bytesize::ByteSize; use clap::{error::ErrorKind, Args, CommandFactory as _, Error as ClapError, Parser, ValueEnum}; @@ -54,7 +55,7 @@ use std_ext::ArcExt as _; use thiserror::Error; use tower_http::cors::AllowOrigin; use types::{ - bellatrix::primitives::Difficulty, + bellatrix::primitives::{Difficulty, Gas}, config::Config as ChainConfig, nonstandard::Phase, phase0::primitives::{ @@ -720,6 +721,10 @@ struct ValidatorOptions { #[clap(long, default_value_t = DEFAULT_BUILDER_MAX_SKIPPED_SLOTS_PER_EPOCH)] builder_max_skipped_slots_per_epoch: u64, + /// Default execution gas limit for all validators + #[clap(long, default_value_t = PREFERRED_EXECUTION_GAS_LIMIT)] + default_gas_limit: Gas, + /// List of public keys to use from Web3Signer #[clap(long, num_args = 1.., value_delimiter = ',')] web3signer_public_keys: Vec, @@ -922,6 +927,7 @@ impl GrandineArgs { builder_disable_checks, builder_max_skipped_slots, builder_max_skipped_slots_per_epoch, + default_gas_limit, use_validator_key_cache, web3signer_public_keys, web3signer_refresh_keys_every_epoch, @@ -1238,6 +1244,7 @@ impl GrandineArgs { graffiti, max_empty_slots, suggested_fee_recipient: suggested_fee_recipient.unwrap_or(GRANDINE_DONATION_ADDRESS), + default_gas_limit, network_config: network_config_options.into_config( network, directories.network_dir.clone().unwrap_or_default(), diff --git a/grandine/src/grandine_config.rs b/grandine/src/grandine_config.rs index a748882a..91e40282 100644 --- a/grandine/src/grandine_config.rs +++ b/grandine/src/grandine_config.rs @@ -11,6 +11,7 @@ use p2p::NetworkConfig; use runtime::{MetricsConfig, StorageConfig}; use signer::Web3SignerConfig; use types::{ + bellatrix::primitives::Gas, config::Config as ChainConfig, phase0::primitives::{ExecutionAddress, ExecutionBlockNumber, Slot, H256}, redacting_url::RedactingUrl, @@ -42,6 +43,7 @@ pub struct GrandineConfig { pub graffiti: Vec, pub max_empty_slots: u64, pub suggested_fee_recipient: ExecutionAddress, + pub default_gas_limit: Gas, pub network_config: NetworkConfig, pub storage_config: StorageConfig, pub unfinalized_states_in_memory: u64, diff --git a/grandine/src/main.rs b/grandine/src/main.rs index 77867106..e21c1791 100644 --- a/grandine/src/main.rs +++ b/grandine/src/main.rs @@ -362,6 +362,7 @@ fn try_main() -> Result<()> { graffiti, max_empty_slots, suggested_fee_recipient, + default_gas_limit, network_config, storage_config, request_timeout, @@ -416,6 +417,7 @@ fn try_main() -> Result<()> { graffiti, max_empty_slots, suggested_fee_recipient, + default_gas_limit, keystore_storage_password_file, }); diff --git a/http_api/src/context.rs b/http_api/src/context.rs index 7a4ece0a..c89b47d3 100644 --- a/http_api/src/context.rs +++ b/http_api/src/context.rs @@ -229,6 +229,7 @@ impl Context

{ slashing_protector.clone_arc(), anchor_state.genesis_validators_root(), validator_config.suggested_fee_recipient, + validator_config.default_gas_limit, H256::default(), )); diff --git a/keymanager/Cargo.toml b/keymanager/Cargo.toml index 74537d08..e7e7c02a 100644 --- a/keymanager/Cargo.toml +++ b/keymanager/Cargo.toml @@ -7,7 +7,6 @@ authors = ["Grandine "] [dependencies] anyhow = { workspace = true } bls = { workspace = true } -builder_api = { workspace = true } bytesize = { workspace = true } database = { workspace = true } derive_more = { workspace = true } diff --git a/keymanager/src/lib.rs b/keymanager/src/lib.rs index 2bd49c7a..094397ec 100644 --- a/keymanager/src/lib.rs +++ b/keymanager/src/lib.rs @@ -1,6 +1,7 @@ pub use keystores::{load_key_storage, load_key_storage_password, ValidatingPubkey}; pub use misc::OperationStatus as KeymanagerOperationStatus; pub use remote_keys::{ListedRemoteKey, RemoteKey}; +pub use types::bellatrix::primitives::Gas; pub use crate::proposer_configs::ProposerConfigs; @@ -35,10 +36,12 @@ impl KeyManager { slashing_protector: Arc>, genesis_validators_root: H256, default_fee_recipient: ExecutionAddress, + default_gas_limit: Gas, default_graffiti: H256, ) -> Self { let proposer_configs = Arc::new(ProposerConfigs::new_in_memory( default_fee_recipient, + default_gas_limit, default_graffiti, )); @@ -57,6 +60,7 @@ impl KeyManager { } } + #[expect(clippy::too_many_arguments)] pub fn new_persistent( signer: Arc, slashing_protector: Arc>, @@ -64,11 +68,13 @@ impl KeyManager { validator_directory: PathBuf, keystore_storage_password_path: Option<&Path>, default_fee_recipient: ExecutionAddress, + default_gas_limit: Gas, default_graffiti: H256, ) -> Result { let proposer_configs = Arc::new(ProposerConfigs::new_persistent( &validator_directory, default_fee_recipient, + default_gas_limit, default_graffiti, )?); diff --git a/keymanager/src/proposer_configs.rs b/keymanager/src/proposer_configs.rs index a0b64558..95832238 100644 --- a/keymanager/src/proposer_configs.rs +++ b/keymanager/src/proposer_configs.rs @@ -2,7 +2,6 @@ use std::{path::Path, str}; use anyhow::{ensure, Result}; use bls::PublicKeyBytes; -use builder_api::consts::PREFERRED_EXECUTION_GAS_LIMIT; use bytesize::ByteSize; use database::Database; use derive_more::Display; @@ -19,17 +18,23 @@ const DB_MAX_SIZE: ByteSize = ByteSize::gib(1); pub struct ProposerConfigs { database: Database, default_fee_recipient: ExecutionAddress, + default_gas_limit: Gas, default_graffiti: H256, } impl ProposerConfigs { #[must_use] - pub fn new_in_memory(default_fee_recipient: ExecutionAddress, default_graffiti: H256) -> Self { + pub fn new_in_memory( + default_fee_recipient: ExecutionAddress, + default_gas_limit: Gas, + default_graffiti: H256, + ) -> Self { let database = Database::in_memory(); Self { database, default_fee_recipient, + default_gas_limit, default_graffiti, } } @@ -37,6 +42,7 @@ impl ProposerConfigs { pub fn new_persistent( validator_directory: &Path, default_fee_recipient: ExecutionAddress, + default_gas_limit: Gas, default_graffiti: H256, ) -> Result { let database = @@ -45,6 +51,7 @@ impl ProposerConfigs { Ok(Self { database, default_fee_recipient, + default_gas_limit, default_graffiti, }) } @@ -70,7 +77,7 @@ impl ProposerConfigs { pub fn gas_limit(&self, pubkey: PublicKeyBytes) -> Result { let gas_limit = self.db_get(GasLimitByPubkey(pubkey))?; - Ok(gas_limit.unwrap_or(PREFERRED_EXECUTION_GAS_LIMIT)) + Ok(gas_limit.unwrap_or(self.default_gas_limit)) } pub fn set_gas_limit(&self, pubkey: PublicKeyBytes, gas_limit: Gas) -> Result<()> { @@ -165,6 +172,7 @@ mod tests { const DEFAULT_GRAFFITI: &str = "Grandine"; const DEFAULT_FEE_RECIPIENT: ExecutionAddress = ExecutionAddress::repeat_byte(1); + const DEFAULT_GAS_LIMIT: Gas = 30_000_000; const TEST_FEE_RECIPIENT: ExecutionAddress = ExecutionAddress::repeat_byte(2); const PUBKEY: PublicKeyBytes = PublicKeyBytes::repeat_byte(1); @@ -172,11 +180,15 @@ mod tests { let graffiti_bytes = parse_graffiti(DEFAULT_GRAFFITI)?; match validator_dir { - Some(dir) => { - ProposerConfigs::new_persistent(dir, DEFAULT_FEE_RECIPIENT, graffiti_bytes) - } + Some(dir) => ProposerConfigs::new_persistent( + dir, + DEFAULT_FEE_RECIPIENT, + DEFAULT_GAS_LIMIT, + graffiti_bytes, + ), None => Ok(ProposerConfigs::new_in_memory( DEFAULT_FEE_RECIPIENT, + DEFAULT_GAS_LIMIT, graffiti_bytes, )), } @@ -226,7 +238,7 @@ mod tests { let gas_limit = proposer_configs.gas_limit(PUBKEY)?; - assert_eq!(gas_limit, PREFERRED_EXECUTION_GAS_LIMIT); + assert_eq!(gas_limit, DEFAULT_GAS_LIMIT); Ok(()) } @@ -253,7 +265,7 @@ mod tests { let gas_limit = proposer_configs.gas_limit(PUBKEY)?; - assert_eq!(gas_limit, PREFERRED_EXECUTION_GAS_LIMIT); + assert_eq!(gas_limit, DEFAULT_GAS_LIMIT); Ok(()) } diff --git a/runtime/src/runtime.rs b/runtime/src/runtime.rs index 4f9ba0f0..6c26690f 100644 --- a/runtime/src/runtime.rs +++ b/runtime/src/runtime.rs @@ -447,6 +447,7 @@ pub async fn run_after_genesis( slashing_protector.clone_arc(), anchor_state.genesis_validators_root(), validator_config.suggested_fee_recipient, + validator_config.default_gas_limit, graffiti, )) } else { @@ -457,6 +458,7 @@ pub async fn run_after_genesis( directories.validator_dir.clone().unwrap_or_default(), validator_config.keystore_storage_password_file.as_deref(), validator_config.suggested_fee_recipient, + validator_config.default_gas_limit, graffiti, )?) }; diff --git a/validator/src/validator_config.rs b/validator/src/validator_config.rs index 77e0fe6d..94003ee9 100644 --- a/validator/src/validator_config.rs +++ b/validator/src/validator_config.rs @@ -1,7 +1,10 @@ use std::path::PathBuf; use derivative::Derivative; -use types::phase0::primitives::{ExecutionAddress, H256}; +use types::{ + bellatrix::primitives::Gas, + phase0::primitives::{ExecutionAddress, H256}, +}; #[derive(Clone, Debug, Derivative)] #[derivative(Default)] @@ -10,5 +13,6 @@ pub struct ValidatorConfig { #[derivative(Default(value = "32"))] pub max_empty_slots: u64, pub suggested_fee_recipient: ExecutionAddress, + pub default_gas_limit: Gas, pub keystore_storage_password_file: Option, }