diff --git a/besu/src/test/java/org/hyperledger/besu/cli/options/stable/DataStorageOptionsTest.java b/besu/src/test/java/org/hyperledger/besu/cli/options/stable/DataStorageOptionsTest.java index 6be6429adb9..0ea1e8dea1e 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/options/stable/DataStorageOptionsTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/options/stable/DataStorageOptionsTest.java @@ -43,8 +43,8 @@ public void bonsaiTrieLogPruningLimitLegacyOption() { internalTestSuccess( dataStorageConfiguration -> assertThat(dataStorageConfiguration.getBonsaiTrieLogPruningWindowSize()).isEqualTo(600), - "--Xbonsai-limit-trie-logs-enabled", - "--Xbonsai-trie-logs-pruning-window-size", + "--bonsai-limit-trie-logs-enabled", + "--bonsai-trie-logs-pruning-window-size", "600"); } diff --git a/besu/src/test/resources/everything_config.toml b/besu/src/test/resources/everything_config.toml index e89442f7f78..ac8911d6269 100644 --- a/besu/src/test/resources/everything_config.toml +++ b/besu/src/test/resources/everything_config.toml @@ -220,6 +220,7 @@ bonsai-historical-block-limit=512 bonsai-limit-trie-logs-enabled=true bonsai-trie-logs-pruning-window-size=100_000 receipt-compaction-enabled=true +hash-preimage-storage-enabled=true # feature flags Xsecp256k1-native-enabled=false @@ -248,4 +249,4 @@ Xevm-jumpdest-cache-weight-kb=32000 # plugins Xplugins-external-enabled=true plugins=["none"] -plugin-continue-on-error=false \ No newline at end of file +plugin-continue-on-error=false diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/diffbased/bonsai/worldview/BonsaiWorldState.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/diffbased/bonsai/worldview/BonsaiWorldState.java index c029c403c73..d43f585b45d 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/diffbased/bonsai/worldview/BonsaiWorldState.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/diffbased/bonsai/worldview/BonsaiWorldState.java @@ -192,7 +192,7 @@ private void updateTheAccounts( final BonsaiAccount updatedAccount = bonsaiValue.getUpdated(); try { if (updatedAccount == null) { - final Hash addressHash = preImageProxy.hashAndSaveAddressPreImage(accountKey); + final Hash addressHash = getPreImageProxy().hashAndSaveAddressPreImage(accountKey); accountTrie.remove(addressHash); maybeStateUpdater.ifPresent( bonsaiUpdater -> bonsaiUpdater.removeAccountInfoState(addressHash)); @@ -202,7 +202,7 @@ private void updateTheAccounts( maybeStateUpdater.ifPresent( bonsaiUpdater -> bonsaiUpdater.putAccountInfoState( - preImageProxy.hashAndSaveAddressPreImage(accountKey), accountValue)); + getPreImageProxy().hashAndSaveAddressPreImage(accountKey), accountValue)); accountTrie.put(addressHash, accountValue); } } catch (MerkleTrieException e) { diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/diffbased/bonsai/worldview/BonsaiWorldStateUpdateAccumulator.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/diffbased/bonsai/worldview/BonsaiWorldStateUpdateAccumulator.java index afeeed05349..49e8fe03dc1 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/diffbased/bonsai/worldview/BonsaiWorldStateUpdateAccumulator.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/diffbased/bonsai/worldview/BonsaiWorldStateUpdateAccumulator.java @@ -20,7 +20,6 @@ import org.hyperledger.besu.datatypes.StorageSlotKey; import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.BonsaiAccount; -import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.storage.CachingPreImageStorage; import org.hyperledger.besu.ethereum.trie.diffbased.common.DiffBasedValue; import org.hyperledger.besu.ethereum.trie.diffbased.common.worldview.DiffBasedWorldView; import org.hyperledger.besu.ethereum.trie.diffbased.common.worldview.accumulator.DiffBasedWorldStateUpdateAccumulator; @@ -95,9 +94,4 @@ protected void assertCloseEnoughForDiffing( final BonsaiAccount source, final AccountValue account, final String context) { BonsaiAccount.assertCloseEnoughForDiffing(source, account, context); } - - @Override - public CachingPreImageStorage getPreImageProxy() { - return world.getPreImageProxy(); - } } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/diffbased/common/storage/DiffBasedWorldStateKeyValueStorage.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/diffbased/common/storage/DiffBasedWorldStateKeyValueStorage.java index 0e01a9a9d60..4043089fc62 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/diffbased/common/storage/DiffBasedWorldStateKeyValueStorage.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/diffbased/common/storage/DiffBasedWorldStateKeyValueStorage.java @@ -65,7 +65,8 @@ public abstract class DiffBasedWorldStateKeyValueStorage LoggerFactory.getLogger(DiffBasedWorldStateKeyValueStorage.class); // TODO: config this based on dataStorageConfiguration, use real storage where appropriate - protected final CachingPreImageStorage preImageProxy = + // currently hard-coded to Unbounded preimage store so ref/spec tests pass + private static final CachingPreImageStorage preImageProxy = new CachingPreImageStorage.UnboundedPreImageStorage(); // 0x776f726c64526f6f74 @@ -109,6 +110,10 @@ public SegmentedKeyValueStorage getComposedWorldStateStorage() { return composedWorldStateStorage; } + public CachingPreImageStorage getPreImageProxy() { + return preImageProxy; + } + public KeyValueStorage getTrieLogStorage() { return trieLogStorage; } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/diffbased/common/worldview/DiffBasedWorldState.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/diffbased/common/worldview/DiffBasedWorldState.java index de35ed7c409..5eacb87f777 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/diffbased/common/worldview/DiffBasedWorldState.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/diffbased/common/worldview/DiffBasedWorldState.java @@ -54,10 +54,6 @@ public abstract class DiffBasedWorldState private static final Logger LOG = LoggerFactory.getLogger(DiffBasedWorldState.class); - // TODO: where the shit to initialize you? just use unbounded for now to ensure ref tests pass - protected static final CachingPreImageStorage preImageProxy = - new CachingPreImageStorage.UnboundedPreImageStorage(); // CachingOnlyPreImageStorage(); - protected DiffBasedWorldStateKeyValueStorage worldStateKeyValueStorage; protected final DiffBasedCachedWorldStorageManager cachedWorldStorageManager; protected final TrieLogManager trieLogManager; @@ -124,7 +120,7 @@ private boolean isPersisted(final WorldStateKeyValueStorage worldStateKeyValueSt @Override public CachingPreImageStorage getPreImageProxy() { - return preImageProxy; + return worldStateKeyValueStorage.getPreImageProxy(); } /** diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/diffbased/common/worldview/accumulator/DiffBasedWorldStateUpdateAccumulator.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/diffbased/common/worldview/accumulator/DiffBasedWorldStateUpdateAccumulator.java index daec20a412e..efa9002f7ad 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/diffbased/common/worldview/accumulator/DiffBasedWorldStateUpdateAccumulator.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/diffbased/common/worldview/accumulator/DiffBasedWorldStateUpdateAccumulator.java @@ -21,6 +21,7 @@ import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.rlp.RLP; import org.hyperledger.besu.ethereum.trie.MerkleTrieException; +import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.storage.CachingPreImageStorage; import org.hyperledger.besu.ethereum.trie.diffbased.common.DiffBasedAccount; import org.hyperledger.besu.ethereum.trie.diffbased.common.DiffBasedValue; import org.hyperledger.besu.ethereum.trie.diffbased.common.storage.DiffBasedWorldStateKeyValueStorage; @@ -614,6 +615,11 @@ public DiffBasedWorldStateKeyValueStorage getWorldStateStorage() { return wrappedWorldView().getWorldStateStorage(); } + @Override + public CachingPreImageStorage getPreImageProxy() { + return wrappedWorldView().getPreImageProxy(); + } + public void rollForward(final TrieLog layer) { layer .getAccountChanges() @@ -881,7 +887,7 @@ public void reset() { protected Hash hashAndSaveAccountPreImage(final Address address) { // default to using address static hash cache: - return address.addressHash(); + return getPreImageProxy().hashAndSaveAddressPreImage(address); } public abstract DiffBasedWorldStateUpdateAccumulator copy();