-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Open
Copy link
Labels
apihelp-wantedLooking for external contributorsLooking for external contributorsrestBeacon API related itemsBeacon API related items
Description
🚀 Feature Request
Description
Several Beacon API endpoints include a {state_id}
parameter, which can be substituted with a state root. This is limited to the last SLOTS_PER_HISTORICAL_ROOT
state roots (8192 on Mainnet). This is because there is no easy way to fetch an arbitrary state by root from the database, and we keep the latest SLOTS_PER_HISTORICAL_ROOT
state and block roots in memory, which allows us to do this:
for i, root := range headState.StateRoots() {
if bytes.Equal(root, stateRoot) { // stateRoot is the requested root
blockRoot := headState.BlockRoots()[i]
return p.StateGenService.StateByRoot(ctx, bytesutil.ToBytes32(blockRoot))
}
}
Describe the solution you'd like
It would be desirable to be able to use an arbitrary state root for the {state_id}
parameter. One possible solution is to create a state_root -> block_root
mapping in the database. This way we could get the block root efficiently and then use StateGenService
to fetch the entire state.
avsetsin, skhomuti, TheDZhon and loga4
Metadata
Metadata
Assignees
Labels
apihelp-wantedLooking for external contributorsLooking for external contributorsrestBeacon API related itemsBeacon API related items