Prague t8n and referenceTests fixes for EEST (#8167)

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>
This commit is contained in:
Simon Dudley
2025-01-30 17:08:08 +10:00
committed by GitHub
parent 5ac3247d38
commit ccd3582630
4 changed files with 14 additions and 6 deletions

View File

@@ -27,6 +27,7 @@ import org.hyperledger.besu.crypto.SignatureAlgorithm;
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;
@@ -348,10 +349,12 @@ public class T8nExecutor {
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()) {

View File

@@ -247,6 +247,10 @@ public class ReferenceTestEnv extends BlockHeader {
return blockHashes;
}
public String getParentExcessBlobGas() {
return parentExcessBlobGas;
}
public boolean isStateTest() {
return isStateTest;
}

View File

@@ -26,6 +26,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
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;
@@ -252,7 +253,7 @@ public class GeneralStateReferenceTestTools {
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());
}

View File

@@ -62,7 +62,7 @@ public class CancunGasCalculator extends ShanghaiGasCalculator {
/**
* 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;