Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,12 @@ public void commit() {
public Optional<Bytes> getCode(final Address address, final Hash codeHash) {
final BonsaiValue<Bytes> localCode = codeToUpdate.get(address);
if (localCode == null) {
return wrappedWorldView().getCode(address, codeHash);
final Optional<Bytes> code = wrappedWorldView().getCode(address, codeHash);
if (code.isEmpty() && !codeHash.equals(Hash.EMPTY)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this instead hash code and compare it to codeHash rather than just checking empty? or is the hashing prohibitively expensive

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes this is enough because the hash check is already done at the storage level. And if it is not good we will have an Empty. So I prefer to avoid adding an unnecessary extra shot for this check

throw new MerkleTrieException(
"invalid account code", Optional.of(address), codeHash, Bytes.EMPTY);
}
return code;
} else {
return Optional.ofNullable(localCode.getUpdated());
}
Expand Down