Skip to content

Capella proposer preparation clones a beacon state #3998

@paulhauner

Description

@paulhauner

Description

In BeaconChain::prepare_beacon_proposer, we're always cloning the state in order to compute the list of withdrawals:

// We must use the advanced state because balances can change at epoch boundaries
// and balances affect withdrawals.
// FIXME(mark)
// Might implement caching here in the future..
let prepare_state = self
.state_at_slot(prepare_slot, StateSkipConfig::WithoutStateRoots)
.map_err(|e| {
error!(self.log, "State advance for withdrawals failed"; "error" => ?e);
e
})?;

It's nice to avoid state clones since they're generally slow (10s of millis) and use a bunch of RAM (100s of MBs). I think there's at least one case were we can avoid the the state clone; when producing a block in the same epoch as its parent. Hopefully there's some more cases too.

We could also look at some sort of caching here to avoid repeat calls to the same method.

I think this behavior is OK for Sepolia, however I think we should optimise it before mainnet.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions