diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/worldstate/CodeNodeDataRequest.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/worldstate/CodeNodeDataRequest.java index 1286561ef1e..5151268c7db 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/worldstate/CodeNodeDataRequest.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/worldstate/CodeNodeDataRequest.java @@ -15,6 +15,7 @@ package org.hyperledger.besu.ethereum.eth.sync.worldstate; import org.hyperledger.besu.datatypes.Hash; +import org.hyperledger.besu.ethereum.bonsai.BonsaiWorldStateKeyValueStorage; import org.hyperledger.besu.ethereum.rlp.RLPOutput; import org.hyperledger.besu.ethereum.worldstate.WorldStateStorage; import org.hyperledger.besu.ethereum.worldstate.WorldStateStorage.Updater; @@ -46,7 +47,12 @@ public Stream getChildRequests(final WorldStateStorage worldSta @Override public Optional getExistingData(final WorldStateStorage worldStateStorage) { - return worldStateStorage.getCode(getHash(), accountHash.orElse(Hash.EMPTY)); + return worldStateStorage + .getCode(getHash(), accountHash.orElse(Hash.EMPTY)) + .filter( + node -> + !(worldStateStorage instanceof BonsaiWorldStateKeyValueStorage) + || Hash.hash(node).equals(getHash())); } public Optional getAccountHash() { diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/worldstate/StorageTrieNodeDataRequest.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/worldstate/StorageTrieNodeDataRequest.java index a054311bc10..49217bfcf3c 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/worldstate/StorageTrieNodeDataRequest.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/worldstate/StorageTrieNodeDataRequest.java @@ -46,8 +46,13 @@ protected void doPersist(final Updater updater) { @Override public Optional getExistingData(final WorldStateStorage worldStateStorage) { - return worldStateStorage.getAccountStorageTrieNode( - getAccountHash().orElse(Hash.EMPTY), getLocation().orElse(Hash.EMPTY), getHash()); + return worldStateStorage + .getAccountStorageTrieNode( + getAccountHash().orElse(Hash.EMPTY), getLocation().orElse(Hash.EMPTY), getHash()) + .filter( + node -> + !(worldStateStorage instanceof BonsaiWorldStateKeyValueStorage) + || Hash.hash(node).equals(getHash())); } @Override