add code hash check to fast sync CodeNodeDataRequest to ensure code is not only present, but matches the expected hash (#3793)

Signed-off-by: garyschulte <garyschulte@gmail.com>

Co-authored-by: Sally MacFarlane <sally.macfarlane@consensys.net>
pull/3806/head
garyschulte 3 years ago committed by GitHub
parent 37f44049d6
commit 76ca97085c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/worldstate/CodeNodeDataRequest.java

@ -46,7 +46,9 @@ class CodeNodeDataRequest extends NodeDataRequest {
@Override
public Optional<Bytes> getExistingData(final WorldStateStorage worldStateStorage) {
return worldStateStorage.getCode(getHash(), accountHash.orElse(Hash.EMPTY));
return worldStateStorage
.getCode(getHash(), accountHash.orElse(Hash.EMPTY))
.filter(codeBytes -> Hash.hash(codeBytes).equals(getHash()));
}
public Optional<Hash> getAccountHash() {

Loading…
Cancel
Save