Skip to content

Commit

Permalink
Merge pull request #42 from gattaca-com/duplicated_block_hash
Browse files Browse the repository at this point in the history
Duplicated block hash
  • Loading branch information
gd-0 authored Feb 5, 2024
2 parents f2042a1 + 8ec545a commit 15520c6
Showing 1 changed file with 52 additions and 16 deletions.
68 changes: 52 additions & 16 deletions crates/api/src/builder/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,14 +228,32 @@ where
.await?;

// Handle duplicates.
api.check_for_duplicate_block_hash(
&block_hash,
payload.slot(),
payload.parent_hash(),
payload.proposer_public_key(),
&request_id,
)
.await?;
if let Err(err) = api
.check_for_duplicate_block_hash(
&block_hash,
payload.slot(),
payload.parent_hash(),
payload.proposer_public_key(),
&request_id,
)
.await
{
match err {
BuilderApiError::DuplicateBlockHash { block_hash } => {
// We dont return the error here as we want to continue processing the request.
// This mitigates the risk of someone sending an invalid payload
// with a valid header, which would block subsequent submissions with the same
// header and valid payload.
debug!(
request_id = %request_id,
block_hash = ?block_hash,
builder_pub_key = ?payload.builder_public_key(),
"block hash already seen"
);
}
_ => return Err(err),
}
}

// Verify the payload value is above the floor bid
let floor_bid_value = api
Expand Down Expand Up @@ -432,14 +450,32 @@ where
}

// Handle duplicates.
api.check_for_duplicate_block_hash(
&block_hash,
payload.slot(),
payload.parent_hash(),
payload.proposer_public_key(),
&request_id,
)
.await?;
if let Err(err) = api
.check_for_duplicate_block_hash(
&block_hash,
payload.slot(),
payload.parent_hash(),
payload.proposer_public_key(),
&request_id,
)
.await
{
match err {
BuilderApiError::DuplicateBlockHash { block_hash } => {
// We dont return the error here as we want to continue processing the request.
// This mitigates the risk of someone sending an invalid payload
// with a valid header, which would block subsequent submissions with the same
// header and valid payload.
debug!(
request_id = %request_id,
block_hash = ?block_hash,
builder_pub_key = ?payload.builder_public_key(),
"block hash already seen"
);
}
_ => return Err(err),
}
}

// Discard any OptimisticV2 submissions if the proposer has censoring enabled
if next_duty.entry.preferences.censoring {
Expand Down

0 comments on commit 15520c6

Please sign in to comment.