Reduce hash calculations in Bonsai Tries (#1960)

Setting contract code on a bonsai account results in a re-hashing. To
reduce this only set the code if the code was changed.  In some cases
this was responsible for 40% of load.

Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com>
pull/1965/head
Danno Ferrin 4 years ago committed by GitHub
parent 8315ba6dc6
commit 2e87576245
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/BonsaiWorldStateUpdater.java

@ -217,7 +217,9 @@ public class BonsaiWorldStateUpdater extends AbstractWorldUpdater<BonsaiWorldVie
} else {
updatedAccount.setBalance(tracked.getBalance());
updatedAccount.setNonce(tracked.getNonce());
if (tracked.codeWasUpdated()) {
updatedAccount.setCode(tracked.getCode());
}
if (tracked.getStorageWasCleared()) {
updatedAccount.clearStorage();
}

Loading…
Cancel
Save