-
Notifications
You must be signed in to change notification settings - Fork 847
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
Default bonsai to fully flat db and code storage by codehash #6894
Changes from all commits
185f102
1093a31
9367070
5943456
25596cc
1cf6a64
5e67090
120f331
f7055ec
4be991e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
|
||
import static org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier.CODE_STORAGE; | ||
import static org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier.TRIE_BRANCH_STORAGE; | ||
import static org.hyperledger.besu.ethereum.trie.diffbased.common.storage.DiffBasedWorldStateKeyValueStorage.WORLD_ROOT_HASH_KEY; | ||
|
||
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.storage.flat.FullFlatDbStrategy; | ||
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.storage.flat.PartialFlatDbStrategy; | ||
|
@@ -70,12 +71,36 @@ public void loadFlatDbStrategy(final SegmentedKeyValueStorage composedWorldState | |
|
||
@VisibleForTesting | ||
FlatDbMode deriveFlatDbStrategy(final SegmentedKeyValueStorage composedWorldStateStorage) { | ||
final FlatDbMode requestedFlatDbMode = | ||
dataStorageConfiguration.getUnstable().getBonsaiFullFlatDbEnabled() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this flag still in unstable ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it is, but the generated classes have to be rebuilt to see it. Pretty much all of the bonsai configs are in unstable, we should move them all out of unstable when we change the default to bonsai 👍 |
||
? FlatDbMode.FULL | ||
: FlatDbMode.PARTIAL; | ||
|
||
final var existingTrieData = | ||
composedWorldStateStorage.get(TRIE_BRANCH_STORAGE, WORLD_ROOT_HASH_KEY).isPresent(); | ||
|
||
var flatDbMode = | ||
FlatDbMode.fromVersion( | ||
composedWorldStateStorage | ||
.get(TRIE_BRANCH_STORAGE, FLAT_DB_MODE) | ||
.map(Bytes::wrap) | ||
.orElse(FlatDbMode.PARTIAL.getVersion())); | ||
.orElseGet( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
() -> { | ||
// if we do not have a db-supplied config for flatdb, derive it: | ||
// default to partial if trie data exists, but the flat config does not, | ||
// and default to the storage config otherwise | ||
var flatDbModeVal = | ||
existingTrieData | ||
? FlatDbMode.PARTIAL.getVersion() | ||
: requestedFlatDbMode.getVersion(); | ||
// persist this config in the db | ||
var setDbModeTx = composedWorldStateStorage.startTransaction(); | ||
setDbModeTx.put( | ||
TRIE_BRANCH_STORAGE, FLAT_DB_MODE, flatDbModeVal.toArrayUnsafe()); | ||
setDbModeTx.commit(); | ||
|
||
return flatDbModeVal; | ||
})); | ||
LOG.info("Bonsai flat db mode found {}", flatDbMode); | ||
|
||
return flatDbMode; | ||
|
@@ -123,7 +148,7 @@ public FlatDbStrategy getFlatDbStrategy( | |
public void upgradeToFullFlatDbMode(final SegmentedKeyValueStorage composedWorldStateStorage) { | ||
final SegmentedKeyValueStorageTransaction transaction = | ||
composedWorldStateStorage.startTransaction(); | ||
// TODO: consider ARCHIVE mode | ||
LOG.info("setting FlatDbStrategy to FULL"); | ||
transaction.put( | ||
TRIE_BRANCH_STORAGE, FLAT_DB_MODE, FlatDbMode.FULL.getVersion().toArrayUnsafe()); | ||
transaction.commit(); | ||
|
@@ -134,6 +159,7 @@ public void downgradeToPartialFlatDbMode( | |
final SegmentedKeyValueStorage composedWorldStateStorage) { | ||
final SegmentedKeyValueStorageTransaction transaction = | ||
composedWorldStateStorage.startTransaction(); | ||
LOG.info("setting FlatDbStrategy to PARTIAL"); | ||
transaction.put( | ||
TRIE_BRANCH_STORAGE, FLAT_DB_MODE, FlatDbMode.PARTIAL.getVersion().toArrayUnsafe()); | ||
transaction.commit(); | ||
|
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 should not add the new full flat db flag ?