Skip to content

Commit

Permalink
Merge pull request #11 from gattaca-com/audit-fixes
Browse files Browse the repository at this point in the history
Audit refactors + demotion fixes
  • Loading branch information
gd-0 authored Jan 30, 2024
2 parents 8733895 + fdd3ba4 commit 96fd863
Show file tree
Hide file tree
Showing 21 changed files with 107 additions and 434 deletions.
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ ARG AWS_ACCESS_KEY_ID
ARG AWS_SECRET_ACCESS_KEY
ARG REPO_NAME

RUN echo "REPO_NAME: $REPO_NAME"

# Test to make sure that aws access is set correctly
RUN test -n "$AWS_ACCESS_KEY_ID" || (echo "AWS_ACCESS_KEY_ID not set" && false)
RUN test -n "$AWS_SECRET_ACCESS_KEY" || (echo "AWS_SECRET_ACCESS_KEY not set" && false)
Expand All @@ -24,6 +26,9 @@ ENV SCCACHE_S3_USE_SSL=true
# Copy necessary contents into the container at /app
ADD ./repos /app/

RUN ls -lah /app
RUN ls -lah /app/${REPO_NAME}

# Set the working directory to /app
WORKDIR /app/${REPO_NAME}

Expand Down
2 changes: 1 addition & 1 deletion crates/api/src/builder/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ use crate::{
gossiper::{traits::GossipClientTrait, types::{BroadcastHeaderParams, BroadcastPayloadParams, GossipedMessage}},
};

pub const MAX_PAYLOAD_LENGTH: usize = 1024 * 1024 * 4;
pub(crate) const MAX_PAYLOAD_LENGTH: usize = 1024 * 1024 * 4;

#[derive(Clone)]
pub struct BuilderApi<A, DB, S, G>
Expand Down
29 changes: 19 additions & 10 deletions crates/api/src/builder/simulator/optimistic_simulator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,24 @@ impl<A: Auctioneer + 'static, DB: DatabaseService + 'static> OptimisticSimulator
{
if let BlockSimError::BlockValidationFailed(_) = err {
if builder_info.is_optimistic {
warn!(
request_id=%request_id,
builder=%request.message.builder_public_key,
block_hash=%request.execution_payload.block_hash(),
err=%err,
"Block simulation resulted in an error. Demoting builder...",
);
//self.demote_builder_due_to_error(&request.message.builder_public_key, request.execution_payload.block_hash(), err.to_string()).await;
if err.is_severe() {
warn!(
request_id=%request_id,
builder=%request.message.builder_public_key,
block_hash=%request.execution_payload.block_hash(),
err=%err,
"Block simulation resulted in an error. Demoting builder...",
);
self.demote_builder_due_to_error(&request.message.builder_public_key, request.execution_payload.block_hash(), err.to_string()).await;
} else {
warn!(
request_id=%request_id,
builder=%request.message.builder_public_key,
block_hash=%request.execution_payload.block_hash(),
err=%err,
"Block simulation resulted in a non-severe error. NOT demoting builder...",
);
}
}
}
return Err(err);
Expand Down Expand Up @@ -162,8 +172,7 @@ impl<A: Auctioneer, DB: DatabaseService> BlockSimulator for OptimisticSimulator<
) -> Result<bool, BlockSimError> {
let builder_info = self.fetch_builder_info(&request).await;

// if self.should_process_optimistically(&request, &builder_info).await {
if true {
if self.should_process_optimistically(&request, &builder_info).await {
debug!(
request_id=%request_id,
block_hash=%request.execution_payload.block_hash(),
Expand Down
10 changes: 5 additions & 5 deletions crates/api/src/builder/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ use std::{sync::Arc, time::SystemTime};
use ethereum_consensus::primitives::BlsPublicKey;
use helix_common::{bellatrix::ByteVector, bid_submission::{SignedBidSubmission, v2::header_submission::SignedHeaderSubmission}, simulator::BlockSimError, GossipedHeaderTrace, GossipedPayloadTrace, HeaderSubmissionTrace, SubmissionTrace};

pub const PATH_BUILDER_API: &str = "/relay/v1/builder";
pub(crate) const PATH_BUILDER_API: &str = "/relay/v1/builder";

pub const PATH_GET_VALIDATORS: &str = "/validators";
pub const PATH_SUBMIT_BLOCK: &str = "/blocks";
pub const PATH_SUBMIT_BLOCK_OPTIMISTIC: &str = "/blocks_optimistic";
pub const PATH_SUBMIT_HEADER: &str = "/headers";
pub(crate) const PATH_GET_VALIDATORS: &str = "/validators";
pub(crate) const PATH_SUBMIT_BLOCK: &str = "/blocks";
pub(crate) const PATH_SUBMIT_BLOCK_OPTIMISTIC: &str = "/blocks_optimistic";
pub(crate) const PATH_SUBMIT_HEADER: &str = "/headers";


#[derive(Clone)]
Expand Down
2 changes: 1 addition & 1 deletion crates/api/src/proposer/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ where
// Spin up the housekeep task
let api_clone = api.clone();
tokio::spawn(async move {
if let Err(err) = api_clone.housekeep(slot_update_subscription.clone()).await {
if let Err(err) = api_clone.housekeep(slot_update_subscription).await {
error!(
error = %err,
"ProposerApi. housekeep task encountered an error",
Expand Down
12 changes: 6 additions & 6 deletions crates/api/src/proposer/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ use serde::Deserialize;

use crate::proposer::error::ProposerApiError;

pub const PATH_PROPOSER_API: &str = "/eth/v1/builder";
pub(crate) const PATH_PROPOSER_API: &str = "/eth/v1/builder";

pub const PATH_STATUS: &str = "/status";
pub const PATH_REGISTER_VALIDATORS: &str = "/validators";
pub const PATH_GET_HEADER: &str = "/header/:slot/:parent_hash/:pubkey";
pub const PATH_GET_PAYLOAD: &str = "/blinded_blocks";
pub(crate) const PATH_STATUS: &str = "/status";
pub(crate) const PATH_REGISTER_VALIDATORS: &str = "/validators";
pub(crate) const PATH_GET_HEADER: &str = "/header/:slot/:parent_hash/:pubkey";
pub(crate) const PATH_GET_PAYLOAD: &str = "/blinded_blocks";

pub const GET_HEADER_REQUEST_CUTOFF_MS: i64 = 3000;
pub(crate) const GET_HEADER_REQUEST_CUTOFF_MS: i64 = 3000;

#[derive(Debug, Deserialize)]
pub struct GetHeaderParams {
Expand Down
14 changes: 7 additions & 7 deletions crates/api/src/relay_data/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ use helix_common::api::data_api::{

use crate::relay_data::error::DataApiError;

pub const PATH_DATA_API: &str = "/relay/v1/data";
pub(crate) const PATH_DATA_API: &str = "/relay/v1/data";

pub const PATH_PROPOSER_PAYLOAD_DELIVERED: &str = "/bidtraces/proposer_payload_delivered";
pub const PATH_BUILDER_BIDS_RECEIVED: &str = "/bidtraces/builder_blocks_received";
pub const PATH_VALIDATOR_REGISTRATION: &str = "/validator_registration";
pub(crate) const PATH_PROPOSER_PAYLOAD_DELIVERED: &str = "/bidtraces/proposer_payload_delivered";
pub(crate) const PATH_BUILDER_BIDS_RECEIVED: &str = "/bidtraces/builder_blocks_received";
pub(crate) const PATH_VALIDATOR_REGISTRATION: &str = "/validator_registration";

#[derive(Clone)]
pub struct DataApi<DB: DatabaseService> {
Expand All @@ -31,7 +31,7 @@ impl<DB: DatabaseService + 'static> DataApi<DB> {
Self { db }
}

/// Implements this API: https://flashbots.github.io/relay-specs/#/Data/getDeliveredPayloads
/// Implements this API: <https://flashbots.github.io/relay-specs/#/Data/getDeliveredPayloads>
pub async fn proposer_payload_delivered(
Extension(data_api): Extension<Arc<DataApi<DB>>>,
Query(params): Query<ProposerPayloadDeliveredParams>,
Expand All @@ -56,7 +56,7 @@ impl<DB: DatabaseService + 'static> DataApi<DB> {
}
}

/// Implements this API: https://flashbots.github.io/relay-specs/#/Data/getReceivedBids
/// Implements this API: <https://flashbots.github.io/relay-specs/#/Data/getReceivedBids>
pub async fn builder_bids_received(
Extension(data_api): Extension<Arc<DataApi<DB>>>,
Query(params): Query<BuilderBlocksReceivedParams>,
Expand Down Expand Up @@ -87,7 +87,7 @@ impl<DB: DatabaseService + 'static> DataApi<DB> {
}
}

/// Implements this API: https://flashbots.github.io/relay-specs/#/Data/getValidatorRegistration
/// Implements this API: <https://flashbots.github.io/relay-specs/#/Data/getValidatorRegistration>
pub async fn validator_registration(
Extension(data_api): Extension<Arc<DataApi<DB>>>,
Query(params): Query<ValidatorRegistrationParams>,
Expand Down
2 changes: 1 addition & 1 deletion crates/api/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ impl ApiService {
);

let (mut chain_event_updater, slot_update_sender) =
ChainEventUpdater::new_with_channel(db.clone());
ChainEventUpdater::new(db.clone());

let mbc_clone = multi_beacon_client.clone();
tokio::spawn(async move {
Expand Down
Loading

0 comments on commit 96fd863

Please sign in to comment.