Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,9 @@ private void traceTestSpecs(
final MainnetTransactionProcessor processor = protocolSpec.getTransactionProcessor();
final WorldUpdater worldStateUpdater = worldState.updater();
final Stopwatch timer = Stopwatch.createStarted();
// Todo: EIP-4844 use the excessBlobGas of the parent instead of BlobGas.ZERO
final Wei blobGasPrice = protocolSpec.getFeeMarket().blobGasPricePerGas(BlobGas.ZERO);
// EIP-4844: use excessBlobGas from block header for correct blob gas price calculation
final BlobGas excessBlobGas = blockHeader.getExcessBlobGas().orElse(BlobGas.ZERO);
final Wei blobGasPrice = protocolSpec.getFeeMarket().blobGasPricePerGas(excessBlobGas);
final TransactionProcessingResult result =
processor.processTransaction(
worldStateUpdater,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,4 +154,26 @@ void invalidTransactionShouldNotModifyState() {
// Both error and validationError fields should be present for invalid transactions
assertThat(output).contains("\"error\":\"Upfront gas cost cannot exceed 2^256 Wei\"");
}

@Test
void shouldUseExcessBlobGasFromEnvironment() {
// Tests that BLOBBASEFEE opcode uses currentExcessBlobGas from the test environment.
// With excessBlobGas=0x240000 and Cancun blob fee fraction (3338477), blob price = 2.
// The contract stores BLOBBASEFEE result in storage slot 0.
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
EvmToolCommand parentCommand =
new EvmToolCommand(System.in, new PrintWriter(baos, true, UTF_8));
final StateTestSubCommand stateTestSubCommand = new StateTestSubCommand(parentCommand);
final CommandLine cmd = new CommandLine(stateTestSubCommand);
cmd.parseArgs(
StateTestSubCommandTest.class.getResource("state-test/excess-blob-gas.json").getPath());
stateTestSubCommand.run();

final String output = baos.toString(UTF_8);
// State root should match expected value (computed with correct blob gas price = 2)
assertThat(output)
.contains(
"\"stateRoot\":\"0x4f0dafcdc942cf538ffe1f870ab031c2761857b3066f595e56c74bcb222eb0bb\"");
assertThat(output).contains("\"pass\":true");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"excessBlobGasTest": {
"_info": {
"comment": "Test that verifies BLOBBASEFEE opcode correctly uses currentExcessBlobGas from environment"
},
"env": {
"currentCoinbase": "0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
"currentGasLimit": "0x05f5e100",
"currentNumber": "0x01",
"currentTimestamp": "0x03e8",
"currentRandom": "0x0000000000000000000000000000000000000000000000000000000000000000",
"currentDifficulty": "0x00",
"currentBaseFee": "0x0a",
"currentExcessBlobGas": "0x240000"
},
"pre": {
"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b": {
"nonce": "0x00",
"balance": "0x3635c9adc5dea00000",
"code": "0x",
"storage": {}
},
"0x1000000000000000000000000000000000000000": {
"nonce": "0x00",
"balance": "0x00",
"code": "0x4a600055",
"storage": {}
}
},
"transaction": {
"nonce": "0x00",
"gasPrice": "0x0a",
"gasLimit": [
"0x030d40"
],
"to": "0x1000000000000000000000000000000000000000",
"value": [
"0x00"
],
"data": [
"0x"
],
"sender": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b",
"secretKey": "0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8"
},
"post": {
"Cancun": [
{
"hash": "0x4f0dafcdc942cf538ffe1f870ab031c2761857b3066f595e56c74bcb222eb0bb",
"logs": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
"indexes": {
"data": 0,
"gas": 0,
"value": 0
}
}
]
}
}
}
Loading