Blockhash lookup in test harness (#7104)

* Blockhash lookup in test harness

Another change to the blockhash operation in the test harness.

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

* also in t8n executor

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

---------

Signed-off-by: Danno Ferrin <danno@numisight.com>
Co-authored-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
pull/7128/head
Danno Ferrin 6 months ago committed by GitHub
parent f9a61a0b83
commit 0fa31b49bb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/StateTestSubCommand.java
  2. 2
      ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/T8nExecutor.java
  3. 82
      ethereum/evmtool/src/test/resources/org/hyperledger/besu/evmtool/state-test/shanghai-blockhash.json
  4. 21
      ethereum/evmtool/src/test/resources/org/hyperledger/besu/evmtool/t8n/shanghai-blockhash.json

@ -261,7 +261,7 @@ public class StateTestSubCommand implements Runnable {
blockHashLookup =
(messageFrame, number) -> {
long lookback = messageFrame.getBlockValues().getNumber() - number;
if (lookback < 0 || lookback > BlockHashOperation.MAX_RELATIVE_BLOCK) {
if (lookback <= 0 || lookback > BlockHashOperation.MAX_RELATIVE_BLOCK) {
return Hash.ZERO;
} else {
return Hash.hash(Bytes.wrap(Long.toString(number).getBytes(UTF_8)));

@ -298,7 +298,7 @@ public class T8nExecutor {
blockHashLookup =
(frame, number) -> {
long lookback = frame.getBlockValues().getNumber() - number;
if (lookback < 0 || lookback > BlockHashOperation.MAX_RELATIVE_BLOCK) {
if (lookback <= 0 || lookback > BlockHashOperation.MAX_RELATIVE_BLOCK) {
return Hash.ZERO;
} else {
return referenceTestEnv.getBlockhashByNumber(number).orElse(Hash.ZERO);

@ -0,0 +1,82 @@
{
"cli": [
"state-test",
"stdin",
"--trace",
"--trace.memory",
"--trace.stack",
"--trace.returndata",
"--notime"
],
"stdin": {
"shanghai-blockhash": {
"env": {
"currentCoinbase": "b94f5374fce5edbc8e2a8697c15331677e6ebf0b",
"currentDifficulty": "0x20000",
"currentRandom": "0x0000000000000000000000000000000000000000000000000000000000020000",
"currentGasLimit": "0x26e1f476fe1e22",
"currentNumber": "0x2",
"currentTimestamp": "0x3e8",
"previousHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"currentBaseFee": "0x10"
},
"pre": {
"0x1000000000000000000000000000000000000000": {
"nonce": "0x00",
"balance": "0x0ba1a9ce0ba1a9ce",
"code": "0x600040600055600140600155434060025500",
"storage": {}
},
"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b": {
"balance": "0x1319ad251a00",
"storage": {}
}
},
"transaction": {
"gasPrice": "0x10",
"nonce": "0x0",
"to": "0x1000000000000000000000000000000000000000",
"data": [
"0x"
],
"gasLimit": [
"0x7a1200"
],
"value": [
"0x0"
],
"secretKey": "0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8"
},
"out": "0x",
"post": {
"Shanghai": [
{
"hash": "0xb3967c897314312cf275055d754c6742d351a2a4bcf0121ed2f896971bf56563",
"logs": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
"indexes": {
"data": 0,
"gas": 0,
"value": 0
}
}
]
}
}
},
"stdout": [
{"pc":0,"op":96,"gas":"0x79bff8","gasCost":"0x3","memSize":0,"stack":[],"depth":1,"refund":0,"opName":"PUSH1"},
{"pc":2,"op":64,"gas":"0x79bff5","gasCost":"0x14","memSize":0,"stack":["0x0"],"depth":1,"refund":0,"opName":"BLOCKHASH"},
{"pc":3,"op":96,"gas":"0x79bfe1","gasCost":"0x3","memSize":0,"stack":["0x44852b2a670ade5407e78fb2863c51de9fcb96542a07186fe3aeda6bb8a116d"],"depth":1,"refund":0,"opName":"PUSH1"},
{"pc":5,"op":85,"gas":"0x79bfde","gasCost":"0x5654","memSize":0,"stack":["0x44852b2a670ade5407e78fb2863c51de9fcb96542a07186fe3aeda6bb8a116d","0x0"],"depth":1,"refund":0,"opName":"SSTORE"},
{"pc":6,"op":96,"gas":"0x79698a","gasCost":"0x3","memSize":0,"stack":[],"depth":1,"refund":0,"opName":"PUSH1"},
{"pc":8,"op":64,"gas":"0x796987","gasCost":"0x14","memSize":0,"stack":["0x1"],"depth":1,"refund":0,"opName":"BLOCKHASH"},
{"pc":9,"op":96,"gas":"0x796973","gasCost":"0x3","memSize":0,"stack":["0xc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc6"],"depth":1,"refund":0,"opName":"PUSH1"},
{"pc":11,"op":85,"gas":"0x796970","gasCost":"0x5654","memSize":0,"stack":["0xc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc6","0x1"],"depth":1,"refund":0,"opName":"SSTORE"},
{"pc":12,"op":67,"gas":"0x79131c","gasCost":"0x2","memSize":0,"stack":[],"depth":1,"refund":0,"opName":"NUMBER"},
{"pc":13,"op":64,"gas":"0x79131a","gasCost":"0x14","memSize":0,"stack":["0x2"],"depth":1,"refund":0,"opName":"BLOCKHASH"},
{"pc":14,"op":96,"gas":"0x791306","gasCost":"0x3","memSize":0,"stack":["0x0"],"depth":1,"refund":0,"opName":"PUSH1"},
{"pc":16,"op":85,"gas":"0x791303","gasCost":"0x898","memSize":0,"stack":["0x0","0x2"],"depth":1,"refund":0,"opName":"SSTORE"},
{"pc":17,"op":0,"gas":"0x790a6b","gasCost":"0x0","memSize":0,"stack":[],"depth":1,"refund":0,"opName":"STOP"},
{"output":"","gasUsed":"0x10795","test":"shanghai-blockhash","fork":"Shanghai","d":0,"g":0,"v":0,"postHash":"0xb3967c897314312cf275055d754c6742d351a2a4bcf0121ed2f896971bf56563","postLogsHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","pass":true}
]
}

@ -16,7 +16,7 @@
"0x1000000000000000000000000000000000000000": {
"nonce": "0x00",
"balance": "0x0ba1a9ce0ba1a9ce",
"code": "0x60004060005560014060015500",
"code": "0x600040600055600140600155434060025500",
"storage": {}
},
"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b": {
@ -55,7 +55,8 @@
"parentTimestamp": "12",
"blockHashes": {
"0": "0x651666d6d8727a6478a750dc8406c1bda0be85abc99094dca694807fa772f83c",
"1": "0x0275fc82fe832100726ec7c26078ffb1c1dbff14a3b52d93dc359768fc8c7baa"
"1": "0x0275fc82fe832100726ec7c26078ffb1c1dbff14a3b52d93dc359768fc8c7baa",
"257": "0x0275fc82fe832100726ec7c26078ffb1c1dbff14a3b52d93dc359768fc8c7baa"
},
"ommers": [],
"withdrawals": [],
@ -66,43 +67,43 @@
"stdout": {
"alloc": {
"0x1000000000000000000000000000000000000000": {
"code": "0x60004060005560014060015500",
"code": "0x600040600055600140600155434060025500",
"storage": {
"0x0000000000000000000000000000000000000000000000000000000000000001": "0x0275fc82fe832100726ec7c26078ffb1c1dbff14a3b52d93dc359768fc8c7baa"
},
"balance": "0xba1a9ce0ba1a9ce"
},
"0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba": {
"balance": "0x21378"
"balance": "0x22d8b"
},
"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b": {
"balance": "0x1319ad1e2e70",
"balance": "0x1319ad1dd786",
"nonce": "0x1"
}
},
"body": "0xf862f860800a8307a12094100000000000000000000000000000000000000080801ca091df80a63242846dcf1cc16c35e6ba39212cde92aad946f9c286fa0029782b54a0446170c2fb714c717885485ea7d93bf9277f3fb3d89ffd73e9b7f5f8eda3997b",
"result": {
"stateRoot": "0x89412c0f1bb31b983d0317e6e2801a4e604e1ef9987a132ab63c52f2d5a3994b",
"stateRoot": "0x5538cf875e8e464ff08398cd8ab7cb03281e8264da450d471bcf67a4db2a9122",
"txRoot": "0x8e987be72f36f97a98838e03d9e5d1b3d22795606240f16684532b1c994b4ee7",
"receiptsRoot": "0x8046ec5911721c453253b45a350eb90247e1a047bdc7cf1e2c7885b4c2403276",
"receiptsRoot": "0xb5c544c869a9a9de6177db6d326610105f678fc1add50ad05f3e2384655268e9",
"logsHash": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"receipts": [
{
"root": "0x",
"status": "0x1",
"cumulativeGasUsed": "0xb128",
"cumulativeGasUsed": "0xb9d9",
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"logs": null,
"transactionHash": "0x6c4a22ee7d2d9ae9307b09aac69a34600978e34313088917a7e69fd12e8f959a",
"contractAddress": "0x0000000000000000000000000000000000000000",
"gasUsed": "0xb128",
"gasUsed": "0xb9d9",
"blockHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"transactionIndex": "0x0"
}
],
"currentDifficulty": null,
"gasUsed": "0xb128",
"gasUsed": "0xb9d9",
"currentBaseFee": "0x7",
"withdrawalsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"
}

Loading…
Cancel
Save