Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions crates/blockchain/payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,7 @@ impl Blockchain {
let start = Instant::now();
const SECONDS_PER_SLOT: Duration = Duration::from_secs(12);
// Attempt to rebuild the payload as many times within the given timeframe to maximize fee revenue
// TODO(#4997): start with an empty block
let mut res = self.build_payload(payload.clone())?;
let mut res = self.build_initial_payload(payload.clone())?;
while start.elapsed() < SECONDS_PER_SLOT && !cancel_token.is_cancelled() {
let payload = payload.clone();
let self_clone = self.clone();
Expand All @@ -392,8 +391,22 @@ impl Blockchain {
Ok(res)
}

/// Completes the payload building process, return the block value
// We separate this into two functions, so we can build the initial empty payload and then start filling it
// TODO: once we implement a mechanism to gradually fill the payload with transactions we won't need this
pub fn build_payload(&self, payload: Block) -> Result<PayloadBuildResult, ChainError> {
self.build_payload_inner(payload, true)
}

pub fn build_initial_payload(&self, payload: Block) -> Result<PayloadBuildResult, ChainError> {
self.build_payload_inner(payload, false)
}

/// Completes the payload building process, return the block value
pub fn build_payload_inner(
&self,
payload: Block,
fill_transactions: bool,
) -> Result<PayloadBuildResult, ChainError> {
let since = Instant::now();
let gas_limit = payload.header.gas_limit;

Expand All @@ -405,8 +418,10 @@ impl Blockchain {
self.apply_system_operations(&mut context)?;
}
self.apply_withdrawals(&mut context)?;
self.fill_transactions(&mut context)?;
self.extract_requests(&mut context)?;
if fill_transactions {
self.fill_transactions(&mut context)?;
self.extract_requests(&mut context)?;
}
self.finalize_payload(&mut context)?;

let interval = Instant::now().duration_since(since).as_millis();
Expand Down
5 changes: 5 additions & 0 deletions tooling/reorgs/src/simulator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,11 @@ impl Node {
);
let payload_id = fork_choice_response.payload_id.unwrap();

// We need this sleep so the get_payload call doesn't return an empty block
// As of #5281 we build an empty block first before building a payload with the transactions to avoid missing slots
// This can cause issues in these tests if the payload is requested too early, the sleep is there to avoid it
tokio::time::sleep(Duration::from_millis(50)).await;

let payload_response = self
.engine_client
.engine_get_payload_v5(payload_id)
Expand Down
Loading