Wire EIP-2935 into evmtool (#7096)

Cover one missed case where the BlockHashLookup changes in the EIP-2935
handling, ensureing the `state-test` tool gets proper prague handling.

Signed-off-by: Danno Ferrin <danno@numisight.com>

Signed-off-by: Danno Ferrin <danno@numisight.com>
pull/7100/head
Danno Ferrin 6 months ago committed by GitHub
parent 5f965b5984
commit 02a991f620
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 24
      ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/StateTestSubCommand.java
  2. 13
      ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/T8nExecutor.java
  3. 15
      ethereum/evmtool/src/test/resources/org/hyperledger/besu/evmtool/t8n/shanghai-blockhash.json

@ -32,10 +32,13 @@ import org.hyperledger.besu.ethereum.mainnet.TransactionValidationParams;
import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult;
import org.hyperledger.besu.ethereum.referencetests.GeneralStateTestCaseEipSpec;
import org.hyperledger.besu.ethereum.referencetests.GeneralStateTestCaseSpec;
import org.hyperledger.besu.ethereum.referencetests.ReferenceTestBlockchain;
import org.hyperledger.besu.ethereum.referencetests.ReferenceTestProtocolSchedules;
import org.hyperledger.besu.ethereum.rlp.RLP;
import org.hyperledger.besu.ethereum.vm.CachingBlockHashLookup;
import org.hyperledger.besu.evm.account.Account;
import org.hyperledger.besu.evm.log.Log;
import org.hyperledger.besu.evm.operation.BlockHashOperation;
import org.hyperledger.besu.evm.tracing.OperationTracer;
import org.hyperledger.besu.evm.tracing.StandardJsonTracer;
import org.hyperledger.besu.evm.worldstate.WorldUpdater;
@ -248,14 +251,31 @@ public class StateTestSubCommand implements Runnable {
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);
BlockHashOperation.BlockHashLookup blockHashLookup =
protocolSpec
.getBlockHashProcessor()
.getBlockHashLookup(
blockHeader, new ReferenceTestBlockchain(blockHeader.getNumber()));
if (blockHashLookup instanceof CachingBlockHashLookup) {
blockHashLookup =
(messageFrame, number) -> {
long lookback = messageFrame.getBlockValues().getNumber() - number;
if (lookback < 0 || lookback > BlockHashOperation.MAX_RELATIVE_BLOCK) {
return Hash.ZERO;
} else {
return Hash.hash(Bytes.wrap(Long.toString(number).getBytes(UTF_8)));
}
};
}
final TransactionProcessingResult result =
processor.processTransaction(
worldStateUpdater,
blockHeader,
transaction,
blockHeader.getCoinbase(),
(blockheight, blockNumber) ->
Hash.hash(Bytes.wrap(Long.toString(blockNumber).getBytes(UTF_8))),
blockHashLookup,
false,
TransactionValidationParams.processingBlock(),
tracer,

@ -296,11 +296,14 @@ public class T8nExecutor {
if (blockHashLookup instanceof CachingBlockHashLookup) {
// caching lookup won't work, use our own secret sauce
blockHashLookup =
(frame, number) ->
(referenceTestEnv.getNumber() - frame.getBlockValues().getNumber()
> BlockHashOperation.MAX_RELATIVE_BLOCK)
? Hash.ZERO
: referenceTestEnv.getBlockhashByNumber(number).orElse(Hash.ZERO);
(frame, number) -> {
long lookback = frame.getBlockValues().getNumber() - number;
if (lookback < 0 || lookback > BlockHashOperation.MAX_RELATIVE_BLOCK) {
return Hash.ZERO;
} else {
return referenceTestEnv.getBlockhashByNumber(number).orElse(Hash.ZERO);
}
};
}
result =
processor.processTransaction(

@ -68,42 +68,41 @@
"0x1000000000000000000000000000000000000000": {
"code": "0x60004060005560014060015500",
"storage": {
"0x0000000000000000000000000000000000000000000000000000000000000000": "0x651666d6d8727a6478a750dc8406c1bda0be85abc99094dca694807fa772f83c",
"0x0000000000000000000000000000000000000000000000000000000000000001": "0x0275fc82fe832100726ec7c26078ffb1c1dbff14a3b52d93dc359768fc8c7baa"
},
"balance": "0xba1a9ce0ba1a9ce"
},
"0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba": {
"balance": "0x2fcac"
"balance": "0x21378"
},
"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b": {
"balance": "0x1319ad1b2518",
"balance": "0x1319ad1e2e70",
"nonce": "0x1"
}
},
"body": "0xf862f860800a8307a12094100000000000000000000000000000000000000080801ca091df80a63242846dcf1cc16c35e6ba39212cde92aad946f9c286fa0029782b54a0446170c2fb714c717885485ea7d93bf9277f3fb3d89ffd73e9b7f5f8eda3997b",
"result": {
"stateRoot": "0xefe246c92bca7a73025ab56d2c19601329ee290b682ae191775dc9edfae52805",
"stateRoot": "0x89412c0f1bb31b983d0317e6e2801a4e604e1ef9987a132ab63c52f2d5a3994b",
"txRoot": "0x8e987be72f36f97a98838e03d9e5d1b3d22795606240f16684532b1c994b4ee7",
"receiptsRoot": "0xecc52ec2cee2a0aceb962c49145060a75e14513e53a01451b61547e9ff84f498",
"receiptsRoot": "0x8046ec5911721c453253b45a350eb90247e1a047bdc7cf1e2c7885b4c2403276",
"logsHash": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"receipts": [
{
"root": "0x",
"status": "0x1",
"cumulativeGasUsed": "0xfee4",
"cumulativeGasUsed": "0xb128",
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"logs": null,
"transactionHash": "0x6c4a22ee7d2d9ae9307b09aac69a34600978e34313088917a7e69fd12e8f959a",
"contractAddress": "0x0000000000000000000000000000000000000000",
"gasUsed": "0xfee4",
"gasUsed": "0xb128",
"blockHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"transactionIndex": "0x0"
}
],
"currentDifficulty": null,
"gasUsed": "0xfee4",
"gasUsed": "0xb128",
"currentBaseFee": "0x7",
"withdrawalsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"
}

Loading…
Cancel
Save