Skip to content

Commit

Permalink
Prague t8n and referenceTests fixes for EEST (#8167)
Browse files Browse the repository at this point in the history
Fix referenceTests bug with fallback EMPTY Address.
T8n support for excessBlobGas for both state tests and blockchain test. State tests should use the given excessBlobGas rather than computing from the parent header.

Signed-off-by: Simon Dudley <simon.dudley@consensys.net>
  • Loading branch information
siladu authored Jan 30, 2025
1 parent 5ac3247 commit ccd3582
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.hyperledger.besu.crypto.SignatureAlgorithmFactory;
import org.hyperledger.besu.datatypes.AccessListEntry;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.BlobGas;
import org.hyperledger.besu.datatypes.CodeDelegation;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.datatypes.TransactionType;
Expand Down Expand Up @@ -348,10 +349,12 @@ static T8nResult runTest(
Blockchain blockchain = new T8nBlockchain(referenceTestEnv, protocolSpec);
final BlockHeader blockHeader = referenceTestEnv.parentBlockHeader(protocolSpec);
final MainnetTransactionProcessor processor = protocolSpec.getTransactionProcessor();
final Wei blobGasPrice =
protocolSpec
.getFeeMarket()
.blobGasPricePerGas(calculateExcessBlobGasForParent(protocolSpec, blockHeader));
final BlobGas excessBlobGas =
Optional.ofNullable(referenceTestEnv.getParentExcessBlobGas())
.map(
__ -> calculateExcessBlobGasForParent(protocolSpec, blockHeader)) // blockchain-test
.orElse(blockHeader.getExcessBlobGas().orElse(BlobGas.ZERO)); // state-test
final Wei blobGasPrice = protocolSpec.getFeeMarket().blobGasPricePerGas(excessBlobGas);
long blobGasLimit = protocolSpec.getGasLimitCalculator().currentBlobGasLimit();

if (!referenceTestEnv.isStateTest()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,10 @@ public Map<Long, Hash> getBlockHashes() {
return blockHashes;
}

public String getParentExcessBlobGas() {
return parentExcessBlobGas;
}

public boolean isStateTest() {
return isStateTest;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.fasterxml.jackson.databind.node.ObjectNode;
import org.apache.tuweni.bytes.Bytes;
import org.apache.tuweni.bytes.Bytes32;
import org.apache.tuweni.bytes.DelegatingBytes;
import org.apache.tuweni.units.bigints.UInt256;
import org.assertj.core.api.SoftAssertions;
import org.hyperledger.besu.datatypes.Address;
Expand Down Expand Up @@ -252,7 +253,7 @@ private static void logWorldState(final ReferenceTestWorldState worldState) {
if (!storageEntries.isEmpty()) {
accountJson.set("storage", storageJson);
}
worldStateJson.set(account.getAddress().orElse(Address.wrap(Bytes.EMPTY)).toHexString(), accountJson);
worldStateJson.set(account.getAddress().map(DelegatingBytes::toHexString).orElse(Bytes.EMPTY.toHexString()), accountJson);
});
LOG.error("Calculated world state: \n{}", worldStateJson.toPrettyString());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ protected CancunGasCalculator(final int maxPrecompile, final int targetBlobsPerB

/**
* The blob gas cost per blob. This is the gas cost for each blob of data that is added to the
* block.
* block. 1 << 17 = 131072 = 0x20000
*/
private static final long BLOB_GAS_PER_BLOB = 1 << 17;

Expand Down

0 comments on commit ccd3582

Please sign in to comment.