From 69f2c25800ed6c33864364fd10673f7f568ae7a0 Mon Sep 17 00:00:00 2001 From: Ryan Schneider Date: Mon, 30 Sep 2024 16:37:03 -0700 Subject: [PATCH 01/10] WIP feat(Dockerfile): Add reth to container image so we can run both in same container for kurtosis. --- Dockerfile | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index a908c3e2..6299564b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -57,18 +57,15 @@ RUN --mount=type=cache,target=/usr/local/cargo/registry \ --mount=type=cache,target=$SCCACHE_DIR,sharing=locked \ cargo build --release --features="$FEATURES" +FROM ethpandaops/reth:main-d6113e1 as reth # -# Runtime container -# -FROM gcr.io/distroless/cc-debian12 +## Runtime container with both rbuilder and reth + entrypoint script +## +FROM ubuntu:latest AS runtime WORKDIR /app -# RUN apk add libssl3 ca-certificates -# RUN apt-get update \ -# && apt-get install -y libssl3 ca-certificates \ -# && rm -rf /var/lib/apt/lists/* - COPY --from=builder /app/target/release/rbuilder /app/rbuilder +COPY --from=reth /usr/local/bin/reth /app/reth -ENTRYPOINT ["/app/rbuilder"] +EXPOSE 30303 30303/udp 9001 8545 8546 From 9c6e248585fc312eb269cf3907b057c4411c87cb Mon Sep 17 00:00:00 2001 From: parithosh Date: Tue, 1 Oct 2024 15:37:30 +0200 Subject: [PATCH 02/10] adding entrypoint.sh --- entrypoint.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 entrypoint.sh diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 00000000..267ba9c6 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,14 @@ +#!/bin/bash +set -e + +if [ -n "$RETH_CMD" ]; then + echo "Running reth with arguments: $RETH_CMD" + /app/reth $RETH_CMD + sleep 5 +fi + +if [ -n "$RBUILDER_CONFIG_PATH" ]; then + echo "Running rbuilder with config file: $RBUILDER_CONFIG_PATH" + /app/rbuilder run $RBUILDER_CONFIG_PATH +fi + From a74e3dbba45371c955bbb12d6826a7acb950d72c Mon Sep 17 00:00:00 2001 From: parithosh Date: Tue, 1 Oct 2024 16:28:42 +0200 Subject: [PATCH 03/10] updating local --- Dockerfile | 8 ++++++++ entrypoint.sh | 33 ++++++++++++++++++++++++++------- 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6299564b..4c5cfbc9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -65,7 +65,15 @@ FROM ubuntu:latest AS runtime WORKDIR /app +RUN apt-get update \ + && apt-get install -y curl + COPY --from=builder /app/target/release/rbuilder /app/rbuilder COPY --from=reth /usr/local/bin/reth /app/reth +COPY ./entrypoint.sh /app/entrypoint.sh + +# Make the entrypoint script executable +RUN chmod +x /app/entrypoint.sh EXPOSE 30303 30303/udp 9001 8545 8546 +ENTRYPOINT ["/app/entrypoint.sh"] diff --git a/entrypoint.sh b/entrypoint.sh index 267ba9c6..b457bfd8 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,14 +1,33 @@ #!/bin/bash set -e -if [ -n "$RETH_CMD" ]; then - echo "Running reth with arguments: $RETH_CMD" - /app/reth $RETH_CMD - sleep 5 +if [ -n "$RETH_ENV" ]; then + echo "Running /app/reth with arguments: $RETH_ENV" + /app/reth $RETH_ENV fi -if [ -n "$RBUILDER_CONFIG_PATH" ]; then - echo "Running rbuilder with config file: $RBUILDER_CONFIG_PATH" - /app/rbuilder run $RBUILDER_CONFIG_PATH +# Check if CL_ENDPOINT is set +if [ -n "$CL_ENDPOINT" ]; then + # Function to check the endpoint + check_endpoint() { + echo "Waiting for $CL_ENDPOINT/eth/v1/config/spec to become available..." + until curl -s -f "$CL_ENDPOINT/eth/v1/config/spec" > /dev/null; do + echo "Endpoint not available yet. Retrying in 5 seconds..." + sleep 5 + done + echo "Endpoint is available." + } + + # Call the function to check the endpoint + check_endpoint +else + echo "CL_ENDPOINT is not set. Skipping endpoint check." +fi + +# Proceed with running the binaries if the environment variables are set +if [ -n "$RBUILDER_ENV" ]; then + echo "Running /app/rbuilder with arguments: $RBUILDER_ENV" + /app/rbuilder $RBUILDER_ENV fi + From 5ee17f7744d87c2f5229bfe7697985025615f07c Mon Sep 17 00:00:00 2001 From: Ferran Borreguero Date: Wed, 2 Oct 2024 08:58:05 +0100 Subject: [PATCH 04/10] Add option to supply genesis fork version from flags --- config-live-example.toml | 2 + crates/rbuilder/src/live_builder/config.rs | 72 ++++++++++++++++------ 2 files changed, 56 insertions(+), 18 deletions(-) diff --git a/config-live-example.toml b/config-live-example.toml index b3c4f03e..020db91a 100644 --- a/config-live-example.toml +++ b/config-live-example.toml @@ -29,6 +29,8 @@ ignore_cancellable_orders = true max_concurrent_seals = 4 +# genesis_fork_version = "0x00112233" + sbundle_mergeabe_signers = [] # slot_delta_to_start_submits_ms is usually negative since we start bidding BEFORE the slot start # slot_delta_to_start_submits_ms = -5000 diff --git a/crates/rbuilder/src/live_builder/config.rs b/crates/rbuilder/src/live_builder/config.rs index b0112c5d..36eac698 100644 --- a/crates/rbuilder/src/live_builder/config.rs +++ b/crates/rbuilder/src/live_builder/config.rs @@ -127,6 +127,9 @@ pub struct L1Config { ///Name kept singular for backwards compatibility #[serde_as(deserialize_as = "OneOrMany>")] pub cl_node_url: Vec>, + + /// Genesis fork version for the chain. If not provided it will be fetched from the beacon client. + pub genesis_fork_version: Option, } impl Default for L1Config { @@ -143,6 +146,7 @@ impl Default for L1Config { slot_delta_to_start_submits_ms: None, cl_node_url: vec![EnvOrValue::from("http://127.0.0.1:3500")], max_concurrent_seals: DEFAULT_MAX_CONCURRENT_SEALS, + genesis_fork_version: None, } } } @@ -171,7 +175,11 @@ impl L1Config { } fn bls_signer(&self, chain_spec: &ChainSpec) -> eyre::Result { - let signing_domain = get_signing_domain(chain_spec.chain, self.beacon_clients()?)?; + let signing_domain = get_signing_domain( + chain_spec.chain, + self.beacon_clients()?, + self.genesis_fork_version.clone(), + )?; let secret_key = self.relay_secret_key.value()?; let secret_key = SecretKey::try_from(secret_key) .map_err(|e| eyre::eyre!("Failed to parse relay key: {:?}", e.to_string()))?; @@ -180,7 +188,11 @@ impl L1Config { } fn bls_optimistic_signer(&self, chain_spec: &ChainSpec) -> eyre::Result { - let signing_domain = get_signing_domain(chain_spec.chain, self.beacon_clients()?)?; + let signing_domain = get_signing_domain( + chain_spec.chain, + self.beacon_clients()?, + self.genesis_fork_version.clone(), + )?; let secret_key = self.optimistic_relay_secret_key.value()?; let secret_key = SecretKey::try_from(secret_key).map_err(|e| { eyre::eyre!("Failed to parse optimistic relay key: {:?}", e.to_string()) @@ -492,26 +504,34 @@ fn create_builder( } } -fn get_signing_domain(chain: Chain, beacon_clients: Vec) -> eyre::Result { +fn get_signing_domain( + chain: Chain, + beacon_clients: Vec, + genesis_fork_version: Option, +) -> eyre::Result { let cl_context = match chain.kind() { ChainKind::Named(NamedChain::Mainnet) => ContextEth::for_mainnet(), ChainKind::Named(NamedChain::Sepolia) => ContextEth::for_sepolia(), ChainKind::Named(NamedChain::Goerli) => ContextEth::for_goerli(), ChainKind::Named(NamedChain::Holesky) => ContextEth::for_holesky(), _ => { - let client = beacon_clients - .first() - .ok_or_else(|| eyre::eyre!("No beacon clients provided"))?; - - let spec = tokio::task::block_in_place(|| { - tokio::runtime::Handle::current().block_on(client.get_spec()) - })?; - - let genesis_fork_version = spec - .get("GENESIS_FORK_VERSION") - .ok_or_else(|| eyre::eyre!("GENESIS_FORK_VERSION not found in spec"))?; - - let version: FixedBytes<4> = FixedBytes::from_str(genesis_fork_version) + let genesis_fork_version = if let Some(genesis_fork_version) = genesis_fork_version { + genesis_fork_version + } else { + let client = beacon_clients + .first() + .ok_or_else(|| eyre::eyre!("No beacon clients provided"))?; + + let spec = tokio::task::block_in_place(|| { + tokio::runtime::Handle::current().block_on(client.get_spec()) + })?; + + spec.get("GENESIS_FORK_VERSION") + .ok_or_else(|| eyre::eyre!("GENESIS_FORK_VERSION not found in spec"))? + .clone() + }; + + let version: FixedBytes<4> = FixedBytes::from_str(&genesis_fork_version) .map_err(|e| eyre::eyre!("Failed to parse genesis fork version: {:?}", e))?; let version = Version::from(version); @@ -616,16 +636,32 @@ mod test { ]; for (chain, domain) in cases.iter() { - let found = get_signing_domain(Chain::from_named(*chain), vec![]).unwrap(); + let found = get_signing_domain(Chain::from_named(*chain), vec![], None).unwrap(); assert_eq!(found, *domain); } } + #[test] + fn test_signing_domain_with_genesis_fork() { + let client = Client::new(Url::parse("http://localhost:8000").unwrap()); + let found = get_signing_domain( + Chain::from_id(12345), + vec![client], + Some("0x00112233".to_string()), + ) + .unwrap(); + + assert_eq!( + found, + fixed_bytes!("0000000157eb3d0fd9a819dee70b5403ce939a22b4f25ec3fc841a16cc4eab3e") + ); + } + #[ignore] #[test] fn test_signing_domain_custom_chain() { let client = Client::new(Url::parse("http://localhost:8000").unwrap()); - let found = get_signing_domain(Chain::from_id(12345), vec![client]).unwrap(); + let found = get_signing_domain(Chain::from_id(12345), vec![client], None).unwrap(); assert_eq!( found, From 1b427ad7ead4833b258ecddcb1269f4aa037dc8b Mon Sep 17 00:00:00 2001 From: parithosh Date: Wed, 2 Oct 2024 17:36:48 +0200 Subject: [PATCH 05/10] push local --- entrypoint.sh | 33 +++++++++------------------------ 1 file changed, 9 insertions(+), 24 deletions(-) mode change 100644 => 100755 entrypoint.sh diff --git a/entrypoint.sh b/entrypoint.sh old mode 100644 new mode 100755 index b457bfd8..af5c0d30 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,33 +1,18 @@ #!/bin/bash set -e +# Run reth in the background if RETH_ENV is set if [ -n "$RETH_ENV" ]; then - echo "Running /app/reth with arguments: $RETH_ENV" - /app/reth $RETH_ENV + echo "Running /app/reth with arguments: $RETH_ENV in the background" + /app/reth $RETH_ENV & fi -# Check if CL_ENDPOINT is set -if [ -n "$CL_ENDPOINT" ]; then - # Function to check the endpoint - check_endpoint() { - echo "Waiting for $CL_ENDPOINT/eth/v1/config/spec to become available..." - until curl -s -f "$CL_ENDPOINT/eth/v1/config/spec" > /dev/null; do - echo "Endpoint not available yet. Retrying in 5 seconds..." - sleep 5 - done - echo "Endpoint is available." - } - - # Call the function to check the endpoint - check_endpoint +# Run rbuilder as the main process +if [ -n "$RBUILDER_CONFIG" ]; then + echo "Running /app/rbuilder with arguments: $RBUILDER_CONFIG" + exec /app/rbuilder else - echo "CL_ENDPOINT is not set. Skipping endpoint check." -fi - -# Proceed with running the binaries if the environment variables are set -if [ -n "$RBUILDER_ENV" ]; then - echo "Running /app/rbuilder with arguments: $RBUILDER_ENV" - /app/rbuilder $RBUILDER_ENV + echo "RBUILDER_CONFIG is not set. Exiting." + exit 1 fi - From df15ac3f5f6a99210ea50cf29f08e210710ef465 Mon Sep 17 00:00:00 2001 From: parithosh Date: Thu, 3 Oct 2024 10:07:28 +0200 Subject: [PATCH 06/10] update entrypoint --- entrypoint.sh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index af5c0d30..42ab6707 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,18 +1,19 @@ #!/bin/bash set -e -# Run reth in the background if RETH_ENV is set -if [ -n "$RETH_ENV" ]; then - echo "Running /app/reth with arguments: $RETH_ENV in the background" - /app/reth $RETH_ENV & +# Run reth in the background if RETH_CMD is set +if [ -n "$RETH_CMD" ]; then + echo "Running /app/reth with arguments: $RETH_CMD in the background" + $RETH_CMD & fi +sleep 5 + # Run rbuilder as the main process if [ -n "$RBUILDER_CONFIG" ]; then echo "Running /app/rbuilder with arguments: $RBUILDER_CONFIG" - exec /app/rbuilder + exec /app/rbuilder run else echo "RBUILDER_CONFIG is not set. Exiting." exit 1 fi - From ef7973753b55fe72c6e6958218e06b6c890f98a1 Mon Sep 17 00:00:00 2001 From: parithosh Date: Thu, 3 Oct 2024 12:23:09 +0200 Subject: [PATCH 07/10] adding dockerfile expose --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 4c5cfbc9..c345eb63 100644 --- a/Dockerfile +++ b/Dockerfile @@ -75,5 +75,5 @@ COPY ./entrypoint.sh /app/entrypoint.sh # Make the entrypoint script executable RUN chmod +x /app/entrypoint.sh -EXPOSE 30303 30303/udp 9001 8545 8546 +EXPOSE 30303 30303/udp 9001 8545 8546 8645 ENTRYPOINT ["/app/entrypoint.sh"] From 5c599758fe15c25ecba4547693c8df9ce3776c21 Mon Sep 17 00:00:00 2001 From: parithosh Date: Thu, 3 Oct 2024 12:25:31 +0200 Subject: [PATCH 08/10] update entrypoint --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 42ab6707..5df6e058 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -4,7 +4,7 @@ set -e # Run reth in the background if RETH_CMD is set if [ -n "$RETH_CMD" ]; then echo "Running /app/reth with arguments: $RETH_CMD in the background" - $RETH_CMD & + /app/$RETH_CMD & fi sleep 5 From 8568a7394e8f5b8c514f1917a9bd26c596722aea Mon Sep 17 00:00:00 2001 From: Barnabas Busa Date: Thu, 3 Oct 2024 19:12:57 +0200 Subject: [PATCH 09/10] Update Dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index c345eb63..487df124 100644 --- a/Dockerfile +++ b/Dockerfile @@ -57,7 +57,7 @@ RUN --mount=type=cache,target=/usr/local/cargo/registry \ --mount=type=cache,target=$SCCACHE_DIR,sharing=locked \ cargo build --release --features="$FEATURES" -FROM ethpandaops/reth:main-d6113e1 as reth +FROM ethpandaops/reth:main as reth # ## Runtime container with both rbuilder and reth + entrypoint script ## From 743921ea35bc8afb1a4a6c02290e08f59a659d67 Mon Sep 17 00:00:00 2001 From: Ryan Schneider Date: Tue, 22 Oct 2024 08:22:24 -0700 Subject: [PATCH 10/10] chore: Add some more logging around CL events and relays Should help pinpoint where things are stalling in kurtosis setup --- crates/rbuilder/src/live_builder/payload_events/mod.rs | 2 ++ .../src/live_builder/payload_events/relay_epoch_cache.rs | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/rbuilder/src/live_builder/payload_events/mod.rs b/crates/rbuilder/src/live_builder/payload_events/mod.rs index 2369be45..41e1e211 100644 --- a/crates/rbuilder/src/live_builder/payload_events/mod.rs +++ b/crates/rbuilder/src/live_builder/payload_events/mod.rs @@ -135,6 +135,7 @@ impl MevBoostSlotDataGenerator { if let Some(res) = relays.slot_data(event.data.proposal_slot).await { res } else { + debug!("No slot data for {:?}", event); continue; }; @@ -173,6 +174,7 @@ impl MevBoostSlotDataGenerator { break; } } + info!("MevBoostSlotDataGenerator: finishing"); // cancelling here because its a critical job self.global_cancellation.cancel(); diff --git a/crates/rbuilder/src/live_builder/payload_events/relay_epoch_cache.rs b/crates/rbuilder/src/live_builder/payload_events/relay_epoch_cache.rs index 26e7a56f..94b2efad 100644 --- a/crates/rbuilder/src/live_builder/payload_events/relay_epoch_cache.rs +++ b/crates/rbuilder/src/live_builder/payload_events/relay_epoch_cache.rs @@ -7,7 +7,7 @@ use alloy_primitives::Address; use futures::stream::FuturesOrdered; use primitive_types::H384; use tokio_stream::StreamExt; -use tracing::{info_span, trace, warn}; +use tracing::{debug, info_span, trace, warn}; /// Info about a slot obtained from a relay. #[derive(Debug, Clone, Hash, PartialEq, Eq)] @@ -110,7 +110,7 @@ impl RelaysForSlotData { res } Ok(None) => { - trace!("Relay does not have slot data"); + debug!("Relay does not have slot data"); continue; } Err(err) => {