Skip to content

Commit

Permalink
add method to disable root verification for T8n and not Reference tes…
Browse files Browse the repository at this point in the history
…ts (hyperledger#6013)

* add method to disable root verification for T8n and not Reference tests

Signed-off-by: Karim TAAM <[email protected]>
  • Loading branch information
matkt authored Oct 10, 2023
1 parent 0536a18 commit dc2289e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 107 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderBuilder;
import org.hyperledger.besu.ethereum.core.MutableWorldState;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.core.TransactionReceipt;
import org.hyperledger.besu.ethereum.mainnet.BodyValidation;
Expand All @@ -42,6 +41,7 @@
import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec;
import org.hyperledger.besu.ethereum.mainnet.TransactionValidationParams;
import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult;
import org.hyperledger.besu.ethereum.referencetests.BonsaiReferenceTestWorldState;
import org.hyperledger.besu.ethereum.referencetests.ReferenceTestBlockchain;
import org.hyperledger.besu.ethereum.referencetests.ReferenceTestEnv;
import org.hyperledger.besu.ethereum.referencetests.ReferenceTestProtocolSchedules;
Expand Down Expand Up @@ -238,7 +238,9 @@ static T8nResult runTest(
ReferenceTestProtocolSchedules.create(
new StubGenesisConfigOptions().chainId(BigInteger.valueOf(chainId)));

final MutableWorldState worldState = initialWorldState.copy();
final BonsaiReferenceTestWorldState worldState =
(BonsaiReferenceTestWorldState) initialWorldState.copy();
worldState.disableRootHashVerification();

final ProtocolSchedule protocolSchedule = referenceTestProtocolSchedules.getByName(fork);
if (protocolSchedule == null) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ public class BonsaiReferenceTestWorldState extends BonsaiWorldState
private final BonsaiReferenceTestWorldStateStorage refTestStorage;
private final BonsaiPreImageProxy preImageProxy;

private boolean disableRootHashVerification;

protected BonsaiReferenceTestWorldState(
final BonsaiReferenceTestWorldStateStorage worldStateStorage,
final CachedMerkleTrieLoader cachedMerkleTrieLoader,
Expand Down Expand Up @@ -87,7 +89,7 @@ public ReferenceTestWorldState copy() {
*/
@Override
protected void verifyWorldStateRoot(final Hash calculatedStateRoot, final BlockHeader header) {
if (!header.getStateRoot().equals(Hash.ZERO)) {
if (!disableRootHashVerification) {
super.verifyWorldStateRoot(calculatedStateRoot, header);
}
}
Expand Down Expand Up @@ -125,6 +127,10 @@ public Stream<StreamableAccount> streamAccounts(final Bytes32 startKeyHash, fina
return this.refTestStorage.streamAccounts(this, startKeyHash, limit);
}

public void disableRootHashVerification() {
disableRootHashVerification = true;
}

static class NoOpTrieLogManager implements TrieLogManager {
private final Subscribers<TrieLogEvent.TrieLogObserver> trieLogObservers = Subscribers.create();
private final TrieLogFactory trieLogFactory = new TrieLogFactoryImpl();
Expand Down

0 comments on commit dc2289e

Please sign in to comment.