-
Notifications
You must be signed in to change notification settings - Fork 877
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bonsai archive feature #7475
base: main
Are you sure you want to change the base?
Bonsai archive feature #7475
Conversation
88f3968
to
7d4a524
Compare
782ae60
to
5752732
Compare
5b06b50
to
dce531e
Compare
Signed-off-by: Jason Frame <[email protected]>
…se constructor that reuses worldStateStorage so that we don't lose values in the EvmToolSpecTests Signed-off-by: Jason Frame <[email protected]>
Signed-off-by: Jason Frame <[email protected]>
Signed-off-by: Matthew Whitehead <[email protected]>
…d state, and freeze it Signed-off-by: Matthew Whitehead <[email protected]>
Signed-off-by: Matthew Whitehead <[email protected]>
…ten for blocks and move account state to new DB segment Signed-off-by: Matthew Whitehead <[email protected]>
Signed-off-by: Matthew Whitehead <[email protected]>
Signed-off-by: Matthew Whitehead <[email protected]>
…t block state has been frozen for Signed-off-by: Matthew Whitehead <[email protected]>
Signed-off-by: Matthew Whitehead <[email protected]>
Signed-off-by: Matthew Whitehead <[email protected]>
…age from the freezer segment Signed-off-by: Matthew Whitehead <[email protected]>
Signed-off-by: Matthew Whitehead <[email protected]>
Signed-off-by: Matthew Whitehead <[email protected]>
…ices/storage/rocksdb/configuration/BaseVersionedStorageFormat.java Co-authored-by: Sally MacFarlane <[email protected]> Signed-off-by: Matt Whitehead <[email protected]>
Signed-off-by: Matthew Whitehead <[email protected]>
Signed-off-by: Matthew Whitehead <[email protected]>
Signed-off-by: Matt Whitehead <[email protected]>
Signed-off-by: Matthew Whitehead <[email protected]>
Signed-off-by: Matthew Whitehead <[email protected]>
Signed-off-by: Matthew Whitehead <[email protected]>
@garyschulte @matkt I've added some commits that refactor the way archive world state and bonsai context work together. I think it's generally much cleaner now. There are some small things I think that could still be improved. I've updated I also added a new class |
I've re-run |
Signed-off-by: Matthew Whitehead <[email protected]>
…unction name Signed-off-by: Matthew Whitehead <[email protected]>
... Is there any time pressure for this feature? With the latest refactor, I'd like to at minimum archive and non-archive sync a network that predates cancun (where we nerfed SELFDESTRUCT). Ideally we would have time to full sync mainnet without archive to ensure no regression, but that is a months long process on commodity hardware. Either way - I will keep 👀 on this PR and kick off regression tests when you signal that it is ready again with your latest commits. |
I think almost all of the latest refactoring is isolated to archive-specific logic or classes. The |
Signed-off-by: Matthew Whitehead <[email protected]>
1b145a3
to
3873f8e
Compare
Signed-off-by: Matthew Whitehead <[email protected]>
// Update the block context before putting entries to storage via calculateRootHash() | ||
// TODO - rename calculateRootHash() to be clearer that it updates state, it doesn't just | ||
// calculate a hash | ||
if (worldStateKeyValueStorage.getFlatDbStrategy() instanceof BonsaiArchiveFlatDbStrategy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer to put it all the time, it doesn't really have a huge impact and avoids an additional condition
provideCachedWorldStorageManager(bonsaiCachedWorldStorageManager); | ||
loadPersistedState( | ||
new BonsaiWorldState( | ||
this, worldStateKeyValueStorage, evmConfiguration, defaultWorldStateConfig)); | ||
} | ||
|
||
@Override | ||
public Optional<MutableWorldState> getMutable( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it seems to be useless ? it's already in DiffBasesWorldStateProvider class
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed - I suspect I needed it before the refactoring I did. I've removed it in the latest commit.
* Puts the account data for the given account hash and block context. | ||
*/ | ||
@Override | ||
public void putFlatAccount( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we cannot add direlctly the blocknumber in the method fields instead of passing a context ? like that the implementation decide ot use it or not ? just a proposition
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The latest refactoring is cleaner in this regard I believe.
@@ -153,7 +155,7 @@ public synchronized Optional<MutableWorldState> getMutable( | |||
return rollMutableStateToBlockHash(persistedState, blockHash); | |||
} | |||
|
|||
Optional<MutableWorldState> rollMutableStateToBlockHash( | |||
protected Optional<MutableWorldState> rollMutableStateToBlockHash( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can go back to private
877a5f3
to
7d42770
Compare
Signed-off-by: Matthew Whitehead <[email protected]>
7d42770
to
633fad4
Compare
Signed-off-by: Matthew Whitehead <[email protected]>
7809755
to
3d8d8c7
Compare
Signed-off-by: Matt Whitehead <[email protected]>
Signed-off-by: Matthew Whitehead <[email protected]>
PR description
Introduces a new (experimental) "Bonsai Archive" DB mode which creates a full archive of the chain it syncs with. This allows JSON/RPC calls to be made with historic blocks as context, for example
eth_getBalance
to get the balance of an account at a historic block, oreth_call
to simulate a transaction at a given block in history.The PR is intended to provide part of the function currently offered by the (now deprecated)
FOREST
DB mode. Specifically it allows state to be queried at an arbitrary block in history, but does not currently offereth_getProof
for said state. A subsequent PR will implementeth_getProof
for historic blocks.Summary of the overall design & changes
This PR builds on PR #5865 which proved the basic concept of archiving state in the Bonsai flat DB by suffixing entries with the block in which they were changed.
For example the state for account
0x0e79065B5F11b5BD1e62B935A600976ffF3754B9
at block37834
is stored asIn order to minimise performance degradation over time, historic state and storage entries in the DB are "archived" by moving them into a separate DB segment.
Where account state is stored in segment
ACCOUNT_INFO_STATE
, state that has been archived is stored inACCOUNT_INFO_STATE_ARCHIVE
. Likewise where storage is held in segmentACCOUNT_STORAGE_STORAGE
, archived storage entries are stored inACCOUNT_STORAGE_ARCHIVE
.An example Rocks DB query to retrieve the state of the example account above would be:
Creating a Bonsai Archive node
The PR introduces an entirely new data storage format (as opposed to making it a configuration option of the existing
BONSAI
storage format.To create a bonsai archive node simply set
--data-storage-format=x_bonsai_archive
when creating it.An existing
FOREST
orBONSAI
node cannot be migrated toBONSAI_ARCHIVE
mode.Storage requirements
An archive node intrinsically requires more storage space than a non-archive node. Every state update is retained in the archive DB segments as outlined above. An archive node for the
holesky
testnet as of the raising of this PR requires approximately160Gi
of storage.Sync time
In order to create an archive of an entire chain,
FULL
sync mode must be used. This PR does not preventSNAP
syncing an archive node, but this will result in only a partial archive of the chain.While the node is performing a
FULL
sync with the chain it is also migrating entries from the regular DB segments to the archive DB segments. Overall this increases the time to create the archive node. For a public chain this might require 1 week or more to complete syncing and archiving.