bonsai trie : reset updater when there is an invalid block (#2205)

Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
pull/2219/head
matkt 4 years ago committed by GitHub
parent e6c1a5a394
commit 425db2a9ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/BonsaiPersistedWorldState.java
  2. 8
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/AbstractBlockProcessor.java

@ -284,6 +284,7 @@ public class BonsaiPersistedWorldState implements MutableWorldState, BonsaiWorld
updater.reset();
} else {
stateUpdater.rollback();
updater.reset();
worldStateBlockHash = originalBlockHash;
worldStateRootHash = originalRootHash;
}

@ -14,6 +14,8 @@
*/
package org.hyperledger.besu.ethereum.mainnet;
import org.hyperledger.besu.ethereum.bonsai.BonsaiPersistedWorldState;
import org.hyperledger.besu.ethereum.bonsai.BonsaiWorldStateUpdater;
import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.core.Address;
import org.hyperledger.besu.ethereum.core.BlockHeader;
@ -187,6 +189,9 @@ public abstract class AbstractBlockProcessor implements BlockProcessor {
result.getValidationResult().getInvalidReason(),
blockHeader.getHash().toHexString(),
transaction.getHash().toHexString());
if (worldState instanceof BonsaiPersistedWorldState) {
((BonsaiWorldStateUpdater) worldStateUpdater).reset();
}
return AbstractBlockProcessor.Result.failed();
}
@ -202,6 +207,9 @@ public abstract class AbstractBlockProcessor implements BlockProcessor {
if (!rewardCoinbase(worldState, blockHeader, ommers, skipZeroBlockRewards)) {
// no need to log, rewardCoinbase logs the error.
if (worldState instanceof BonsaiPersistedWorldState) {
((BonsaiWorldStateUpdater) worldState.updater()).reset();
}
return AbstractBlockProcessor.Result.failed();
}

Loading…
Cancel
Save