From 8c93b11172431fc0dd03aaddb97ef0e1fc2d9053 Mon Sep 17 00:00:00 2001 From: Pawan Dhananjay Date: Fri, 3 Jan 2025 14:16:06 -0800 Subject: [PATCH] Take builder secret key as an argument --- .../src/test_utils/mock_builder.rs | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/beacon_node/execution_layer/src/test_utils/mock_builder.rs b/beacon_node/execution_layer/src/test_utils/mock_builder.rs index 12245d2b93..efaf3642a4 100644 --- a/beacon_node/execution_layer/src/test_utils/mock_builder.rs +++ b/beacon_node/execution_layer/src/test_utils/mock_builder.rs @@ -35,6 +35,8 @@ use warp::{Filter, Rejection}; pub const DEFAULT_FEE_RECIPIENT: Address = Address::repeat_byte(42); pub const DEFAULT_GAS_LIMIT: u64 = 30_000_000; +pub const DEFAULT_BUILDER_PRIVATE_KEY: &str = + "607a11b45a7219cc61a3d9c5fd08c7eebd602a6a19a977f8d3771d5711a550f2"; #[derive(Clone)] pub enum Operation { @@ -308,6 +310,7 @@ impl MockBuilder { true, false, spec, + None, executor.log().clone(), ); let host: Ipv4Addr = Ipv4Addr::LOCALHOST; @@ -316,6 +319,7 @@ impl MockBuilder { (builder, server) } + #[allow(clippy::too_many_arguments)] pub fn new( el: ExecutionLayer, beacon_client: BeaconNodeHttpClient, @@ -323,16 +327,30 @@ impl MockBuilder { apply_operations: bool, max_bid: bool, spec: Arc, + sk: Option<&[u8]>, log: Logger, ) -> Self { - let sk = SecretKey::random(); + let builder_sk = if let Some(sk_bytes) = sk { + match SecretKey::deserialize(sk_bytes) { + Ok(sk) => sk, + Err(_) => { + error!( + log, + "Invalid sk_bytes provided, generating random secret key" + ); + SecretKey::random() + } + } + } else { + SecretKey::deserialize(&hex::decode(DEFAULT_BUILDER_PRIVATE_KEY).unwrap()).unwrap() + }; Self { el, beacon_client, // Should keep spec and context consistent somehow spec, val_registration_cache: Arc::new(RwLock::new(HashMap::new())), - builder_sk: sk, + builder_sk, validate_pubkey, operations: Arc::new(RwLock::new(vec![])), invalidate_signatures: Arc::new(RwLock::new(false)),