diff --git a/tools/t8n/helpers.nim b/tools/t8n/helpers.nim index c99af1d66..35771f0bb 100644 --- a/tools/t8n/helpers.nim +++ b/tools/t8n/helpers.nim @@ -158,7 +158,7 @@ proc parseEnv*(ctx: var TransContext, n: JsonNode) = if n.hasKey("blockHashes"): let w = n["blockHashes"] for k, v in w: - ctx.env.blockHashes[fromHex[uint64](k)] = Hash256.fromHex(v.getStr()) + ctx.env.blockHashes[parseHexOrInt[uint64](k)] = Hash256.fromHex(v.getStr()) if n.hasKey("ommers"): let w = n["ommers"] diff --git a/tools/t8n/t8n_test.nim b/tools/t8n/t8n_test.nim index cae9beda0..72098a158 100644 --- a/tools/t8n/t8n_test.nim +++ b/tools/t8n/t8n_test.nim @@ -367,6 +367,42 @@ const ), output: T8nOutput(alloc: true, result: true), expOut: "exp.json", + ), + TestSpec( + name : "testOpcode 40 Berlin", + base : "testdata/00-507", + input : t8nInput( + "alloc.json", "txs.json", "env.json", "Berlin", "2000000000000000000" + ), + output: T8nOutput(alloc: true, result: true), + expOut: "exp.json", + ), + TestSpec( + name : "suicideCoinbaseState Berlin", + base : "testdata/00-508", + input : t8nInput( + "alloc.json", "txs.json", "env.json", "Berlin", "2000000000000000000" + ), + output: T8nOutput(alloc: true, result: true), + expOut: "exp.json", + ), + TestSpec( + name : "BLOCKHASH Bounds", + base : "testdata/00-509", + input : t8nInput( + "alloc.json", "txs.json", "env.json", "Berlin", "2000000000000000000" + ), + output: T8nOutput(alloc: true, result: true), + expOut: "exp.json", + ), + TestSpec( + name : "Suicides Mixing Coinbase", + base : "testdata/00-510", + input : t8nInput( + "alloc.json", "txs.json", "env.json", "Berlin", "2000000000000000000" + ), + output: T8nOutput(alloc: true, result: true), + expOut: "exp.json", ) ] diff --git a/tools/t8n/testdata/00-507/alloc.json b/tools/t8n/testdata/00-507/alloc.json new file mode 100644 index 000000000..3e4b71dbb --- /dev/null +++ b/tools/t8n/testdata/00-507/alloc.json @@ -0,0 +1,44 @@ +{ + "0x0000000000000000000000000000000000000000" : { + "balance" : "0x99", + "code" : "0x", + "nonce" : "0x0", + "storage" : { + } + }, + "0x00000000000000000000000000000000000000ff" : { + "balance" : "0x99", + "code" : "0x6000ff", + "nonce" : "0x0", + "storage" : { + } + }, + "0x7e57c0de00000000000000000000000000000040" : { + "balance" : "0x100000000000000", + "code" : "0x60004060004014600b57fd5b00", + "nonce" : "0x0", + "storage" : { + } + }, + "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "0xf000000000000000", + "code" : "0x", + "nonce" : "0x0", + "storage" : { + } + }, + "0xb1607e5700000000000000000000000000000000" : { + "balance" : "0x100000000000000", + "code" : "0x60ba601e5360d0601f5360006000602060006000737e57c0de0000000000000000000000000000004062989680f160405500", + "nonce" : "0x0", + "storage" : { + } + }, + "0xca11ed0000000000000000000000000000000000" : { + "balance" : "0x100000000000000", + "code" : "0x60de60105360ad60115360be60125360ef601353610dad610dad5560046010f3", + "nonce" : "0x0", + "storage" : { + } + } +} \ No newline at end of file diff --git a/tools/t8n/testdata/00-507/env.json b/tools/t8n/testdata/00-507/env.json new file mode 100644 index 000000000..c0e6ec4b7 --- /dev/null +++ b/tools/t8n/testdata/00-507/env.json @@ -0,0 +1,9 @@ +{ + "currentCoinbase" : "0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", + "currentDifficulty" : "0x20000", + "currentNumber" : "0x1", + "currentTimestamp" : "0x54c99069", + "currentGasLimit" : "0xf00000000000", + "previousHash" : "0x1080e9305dde8c3b2d83e5bdf78de7df65da4927c6277fe83e1663965123f926", + "blockHashes" : { "0" : "0x1080e9305dde8c3b2d83e5bdf78de7df65da4927c6277fe83e1663965123f926"} +} \ No newline at end of file diff --git a/tools/t8n/testdata/00-507/exp.json b/tools/t8n/testdata/00-507/exp.json new file mode 100644 index 000000000..db623b192 --- /dev/null +++ b/tools/t8n/testdata/00-507/exp.json @@ -0,0 +1,56 @@ +{ + "alloc": { + "0x0000000000000000000000000000000000000000": { + "balance": "0x99" + }, + "0x00000000000000000000000000000000000000ff": { + "code": "0x6000ff", + "balance": "0x99" + }, + "0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba": { + "balance": "0x1bc16d674ed5fc00" + }, + "0x7e57c0de00000000000000000000000000000040": { + "code": "0x60004060004014600b57fd5b00", + "balance": "0x100000000000000" + }, + "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b": { + "balance": "0xeffffffffff20400", + "nonce": "0x1" + }, + "0xb1607e5700000000000000000000000000000000": { + "code": "0x60ba601e5360d0601f5360006000602060006000737e57c0de0000000000000000000000000000004062989680f160405500", + "storage": { + "0x0000000000000000000000000000000000000000000000000000000000000040": "0x0000000000000000000000000000000000000000000000000000000000000001" + }, + "balance": "0x100000000000000" + }, + "0xca11ed0000000000000000000000000000000000": { + "code": "0x60de60105360ad60115360be60125360ef601353610dad610dad5560046010f3", + "balance": "0x100000000000000" + } + }, + "result": { + "stateRoot": "0x310f5ce9045a3a0985455b050991ae544480ac935813b3dbd3127dba8e296b07", + "txRoot": "0xca4aa5460bc77da41068859422f931298587bb4bf3c00acb64ae9b761756cd3b", + "receiptsRoot": "0xadea37258a0826d29ed9960af6e5c5222b7253b0d05fca3c64d001a6035d2d64", + "logsHash": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "receipts": [ + { + "root": "0x", + "status": "0x1", + "cumulativeGasUsed": "0xb300", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "logs": null, + "transactionHash": "0x1c95d0a8814c921893f5a07b7346c483f46593810cf2e168295a34fd70762832", + "contractAddress": "0x0000000000000000000000000000000000000000", + "gasUsed": "0xb300", + "blockHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "transactionIndex": "0x0" + } + ], + "currentDifficulty": "0x20000", + "gasUsed": "0xb300" + } +} diff --git a/tools/t8n/testdata/00-507/txs.json b/tools/t8n/testdata/00-507/txs.json new file mode 100644 index 000000000..2a2a3dff8 --- /dev/null +++ b/tools/t8n/testdata/00-507/txs.json @@ -0,0 +1,14 @@ +[ + { + "input" : "0xff", + "gas" : "0xf00000000000", + "gasPrice" : "0x14", + "nonce" : "0x0", + "r" : "0x7a72862325cd2e4a434fdd44ba0e3e2519a37ba3c51389d3f3ba2241b2f4430f", + "s" : "0x45e7ee970f5b639a317f7266ad01dc6bd79081c5dfa6a1f1678510d63eec86e1", + "sender" : "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", + "to" : "0xb1607e5700000000000000000000000000000000", + "v" : "0x1b", + "value" : "0x0" + } +] \ No newline at end of file diff --git a/tools/t8n/testdata/00-508/alloc.json b/tools/t8n/testdata/00-508/alloc.json new file mode 100644 index 000000000..362879756 --- /dev/null +++ b/tools/t8n/testdata/00-508/alloc.json @@ -0,0 +1,16 @@ +{ + "0x095e7baea6a6c7c4c2dfeb977efac326af552d87" : { + "balance" : "0xde0b6b3a7640000", + "code" : "0x73a94f5374fce5edbc8e2a8697c15331677e6ebf0bff00", + "nonce" : "0x0", + "storage" : { + } + }, + "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "0xde0b6b3a7640000", + "code" : "0x", + "nonce" : "0x0", + "storage" : { + } + } +} \ No newline at end of file diff --git a/tools/t8n/testdata/00-508/env.json b/tools/t8n/testdata/00-508/env.json new file mode 100644 index 000000000..a75194b5e --- /dev/null +++ b/tools/t8n/testdata/00-508/env.json @@ -0,0 +1,9 @@ +{ + "currentCoinbase" : "0x095e7baea6a6c7c4c2dfeb977efac326af552d87", + "currentDifficulty" : "0x20000", + "currentNumber" : "0x1", + "currentTimestamp" : "0x7d0", + "currentGasLimit" : "0x989680", + "previousHash" : "0x24dddc078ea7b2cfd8c443c87730c632ac1228974872118779477fecc0d9363c", + "blockHashes" : { "0" : "0x24dddc078ea7b2cfd8c443c87730c632ac1228974872118779477fecc0d9363c"} +} \ No newline at end of file diff --git a/tools/t8n/testdata/00-508/exp.json b/tools/t8n/testdata/00-508/exp.json new file mode 100644 index 000000000..e421ce508 --- /dev/null +++ b/tools/t8n/testdata/00-508/exp.json @@ -0,0 +1,34 @@ +{ + "alloc": { + "0x095e7baea6a6c7c4c2dfeb977efac326af552d87": { + "balance": "0x1bc16d674ec80000" + }, + "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b": { + "balance": "0x1bc16d674e019af0", + "nonce": "0x1" + } + }, + "result": { + "stateRoot": "0x683c353700562e58561fe29e900bec7c32413de0971ec167c2bbfc8914a844ba", + "txRoot": "0x66c27666d884a7d657a089f961c801c86b7985187f4113fa57bf23af6fcba6e9", + "receiptsRoot": "0xbdc6970604c358a6e29ea6d74bc6182566b1d8479b2d5fdae39ff17df01813d7", + "logsHash": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "receipts": [ + { + "root": "0x", + "status": "0x1", + "cumulativeGasUsed": "0x32ca", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "logs": null, + "transactionHash": "0xee2dde6ff74a32c0a53f9522585b4922d8eb5f44aeab41e6db2f626a0022b529", + "contractAddress": "0x0000000000000000000000000000000000000000", + "gasUsed": "0x32ca", + "blockHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "transactionIndex": "0x0" + } + ], + "currentDifficulty": "0x20000", + "gasUsed": "0x32ca" + } +} diff --git a/tools/t8n/testdata/00-508/txs.json b/tools/t8n/testdata/00-508/txs.json new file mode 100644 index 000000000..e9de7d7e8 --- /dev/null +++ b/tools/t8n/testdata/00-508/txs.json @@ -0,0 +1,14 @@ +[ + { + "input" : "0x", + "gas" : "0xf4240", + "gasPrice" : "0x3e8", + "nonce" : "0x0", + "r" : "0x2d5a297e84b8340eea9113867331e4ac4355fba652c1d3159580524c3f95037e", + "s" : "0x4679e26a49b130eca8a2b05e427a69c1d20d69e739c17bf1715c110bbc24203c", + "sender" : "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", + "to" : "0x095e7baea6a6c7c4c2dfeb977efac326af552d87", + "v" : "0x1c", + "value" : "0x186a0" + } +] \ No newline at end of file diff --git a/tools/t8n/testdata/00-509/alloc.json b/tools/t8n/testdata/00-509/alloc.json new file mode 100644 index 000000000..af0823544 --- /dev/null +++ b/tools/t8n/testdata/00-509/alloc.json @@ -0,0 +1,37 @@ +{ + "0x1000000000000000000000000000000000000000" : { + "balance" : "0x0", + "code" : "0x60004060005563ffffffff4060015567ffffffffffffffff406002556fffffffffffffffffffffffffffffffff406003557fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff40600455", + "nonce" : "0x0", + "storage" : { + } + }, + "0x1000000000000000000000000000000000000001" : { + "balance" : "0x0", + "code" : "0x60004060005563ffffffff4060015567ffffffffffffffff406002556fffffffffffffffffffffffffffffffff406003557fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff40600455", + "nonce" : "0x0", + "storage" : { + } + }, + "0x37c5d39d78433a054b0a470ade8ac1998abfcc06" : { + "balance" : "0x7fffffffffffffff", + "code" : "0x", + "nonce" : "0x0", + "storage" : { + } + }, + "0x55d786df68385b59b919e0bfee2a8ada2d23ecf8" : { + "balance" : "0x7fffffffffffffff", + "code" : "0x", + "nonce" : "0x0", + "storage" : { + } + }, + "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "0x7fffffffffffffff", + "code" : "0x", + "nonce" : "0x0", + "storage" : { + } + } +} \ No newline at end of file diff --git a/tools/t8n/testdata/00-509/env.json b/tools/t8n/testdata/00-509/env.json new file mode 100644 index 000000000..589d4a74d --- /dev/null +++ b/tools/t8n/testdata/00-509/env.json @@ -0,0 +1,9 @@ +{ + "currentCoinbase" : "0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", + "currentDifficulty" : "0x20000", + "currentNumber" : "0x1", + "currentTimestamp" : "0x79e", + "currentGasLimit" : "0x7fffffffffffffff", + "previousHash" : "0x1a2d72fae575f4c3290d192f6f65ce1018583c01eae4323bfb8eb0bf21655169", + "blockHashes" : { "0" : "0x1a2d72fae575f4c3290d192f6f65ce1018583c01eae4323bfb8eb0bf21655169"} +} \ No newline at end of file diff --git a/tools/t8n/testdata/00-509/exp.json b/tools/t8n/testdata/00-509/exp.json new file mode 100644 index 000000000..e4489ea25 --- /dev/null +++ b/tools/t8n/testdata/00-509/exp.json @@ -0,0 +1,83 @@ +{ + "alloc": { + "0x1000000000000000000000000000000000000000": { + "code": "0x60004060005563ffffffff4060015567ffffffffffffffff406002556fffffffffffffffffffffffffffffffff406003557fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff40600455", + "storage": { + "0x0000000000000000000000000000000000000000000000000000000000000000": "0x1a2d72fae575f4c3290d192f6f65ce1018583c01eae4323bfb8eb0bf21655169" + }, + "balance": "0x1" + }, + "0x1000000000000000000000000000000000000001": { + "code": "0x60004060005563ffffffff4060015567ffffffffffffffff406002556fffffffffffffffffffffffffffffffff406003557fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff40600455", + "storage": { + "0x0000000000000000000000000000000000000000000000000000000000000000": "0x1a2d72fae575f4c3290d192f6f65ce1018583c01eae4323bfb8eb0bf21655169" + }, + "balance": "0x1" + }, + "0x1000000000000000000000000000000000000002": { + "balance": "0x1" + }, + "0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba": { + "balance": "0x1bc16d67563c43a0" + }, + "0x37c5d39d78433a054b0a470ade8ac1998abfcc06": { + "balance": "0x7ffffffffebf90be", + "nonce": "0x1" + }, + "0x55d786df68385b59b919e0bfee2a8ada2d23ecf8": { + "balance": "0x7ffffffffce615ce", + "nonce": "0x1" + }, + "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b": { + "balance": "0x7ffffffffce615ce", + "nonce": "0x1" + } + }, + "result": { + "stateRoot": "0xd68ced8de913797eda5834d87f3b23b89f3b5fd13c80a87441c768e1866620bd", + "txRoot": "0x7f06626288d8c93e0a9a35928d4a2ceaae325b35df73a21203555bc4e6803f4e", + "receiptsRoot": "0xdabfd8655b94abbfee33cb3881810d01163119e66d476a1079a6bbe11e4fc276", + "logsHash": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "receipts": [ + { + "root": "0x", + "status": "0x1", + "cumulativeGasUsed": "0xcb3e", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "logs": null, + "transactionHash": "0x4895e5b5881883d2523179d79fcf7813e7d4e82a2149e1d887d8e270f896b2d4", + "contractAddress": "0x0000000000000000000000000000000000000000", + "gasUsed": "0xcb3e", + "blockHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "transactionIndex": "0x0" + }, + { + "root": "0x", + "status": "0x1", + "cumulativeGasUsed": "0x1967c", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "logs": null, + "transactionHash": "0xcb36cb7fca9d8a42e6fa19f031b596924b170d76e98a267382fcfb041dc86760", + "contractAddress": "0x0000000000000000000000000000000000000000", + "gasUsed": "0xcb3e", + "blockHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "transactionIndex": "0x1" + }, + { + "root": "0x", + "status": "0x1", + "cumulativeGasUsed": "0x1e884", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "logs": null, + "transactionHash": "0x981d0b346e1a3cb4377c95b607d6e0c863dac0c6a38cdc0b5d4e3910a8f5b3d8", + "contractAddress": "0x0000000000000000000000000000000000000000", + "gasUsed": "0x5208", + "blockHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "transactionIndex": "0x2" + } + ], + "currentDifficulty": "0x20000", + "gasUsed": "0x1e884" + } +} diff --git a/tools/t8n/testdata/00-509/txs.json b/tools/t8n/testdata/00-509/txs.json new file mode 100644 index 000000000..1ed0ec48f --- /dev/null +++ b/tools/t8n/testdata/00-509/txs.json @@ -0,0 +1,38 @@ +[ + { + "input" : "0x", + "gas" : "0x249f0", + "gasPrice" : "0x3e8", + "nonce" : "0x0", + "r" : "0x36fd4f85802471f3ca398acbc42cd94eb622f8e84a29b2aed321c9a1a08c70a2", + "s" : "0x727f67e64d733d1b6fd6e875ff4640104187cdc0107b35e47a034f719e1cffe7", + "sender" : "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", + "to" : "0x1000000000000000000000000000000000000000", + "v" : "0x1c", + "value" : "0x1" + }, + { + "input" : "0x", + "gas" : "0xf4240", + "gasPrice" : "0x3e8", + "nonce" : "0x0", + "r" : "0x8a21ae3da32ba93164b7ffc41c19fcb3eca5e13966b6ccfe1eb67665e1d683d3", + "s" : "0x44ba0667ad0e394d97058ee335ecac2c536c8b30b3696428055bdad5cd2c050e", + "sender" : "0x55d786df68385b59b919e0bfee2a8ada2d23ecf8", + "to" : "0x1000000000000000000000000000000000000001", + "v" : "0x1c", + "value" : "0x1" + }, + { + "input" : "0x", + "gas" : "0xee6b280", + "gasPrice" : "0x3e8", + "nonce" : "0x0", + "r" : "0xb3a72d78cad07bfcee68190e2133266daf3c91dc558e73a78c80cac2d92a908d", + "s" : "0x5a70e7b9b7757564d7a562eaa8487692785dc9cfaf821a48fcac7bd18d9ed53b", + "sender" : "0x37c5d39d78433a054b0a470ade8ac1998abfcc06", + "to" : "0x1000000000000000000000000000000000000002", + "v" : "0x1c", + "value" : "0x1" + } +] \ No newline at end of file diff --git a/tools/t8n/testdata/00-510/alloc.json b/tools/t8n/testdata/00-510/alloc.json new file mode 100644 index 000000000..d0e9ebeb3 --- /dev/null +++ b/tools/t8n/testdata/00-510/alloc.json @@ -0,0 +1,16 @@ +{ + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b": { + "nonce": "0x1", + "balance": "0x81d63860", + "codehash": "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470", + "storageRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "storage": {} + }, + "b94f5374fce5edbc8e2a8697c15331677e6ebf0b": { + "nonce": "0x0", + "balance": "0x1bc16d6750132188", + "codehash": "0xcb8d91cbd7d300b278f412c51f7d24a853dda10761aef4fd23b5a90f6fa23bf0", + "storageRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "storage": {} + } +} diff --git a/tools/t8n/testdata/00-510/env.json b/tools/t8n/testdata/00-510/env.json new file mode 100644 index 000000000..54fa86f78 --- /dev/null +++ b/tools/t8n/testdata/00-510/env.json @@ -0,0 +1,9 @@ +{ + "currentCoinbase" : "0xb24f5374fce5edbc8e2a8697c15331677e6ebf0b", + "currentDifficulty" : "0x20000", + "currentNumber" : "0x2", + "currentTimestamp" : "0xbb8", + "currentGasLimit" : "0xf4240", + "previousHash" : "0x8d137c53a0bc7ea9e03286a5248106a69051877f947073f6ae5fdc0dd79899d0", + "blockHashes" : { "0" : "0x8d137c53a0bc7ea9e03286a5248106a69051877f947073f6ae5fdc0dd79899d0"} +} \ No newline at end of file diff --git a/tools/t8n/testdata/00-510/exp.json b/tools/t8n/testdata/00-510/exp.json new file mode 100644 index 000000000..c2c2cf6a5 --- /dev/null +++ b/tools/t8n/testdata/00-510/exp.json @@ -0,0 +1,37 @@ +{ + "alloc": { + "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b": { + "balance": "0x8095c916", + "nonce": "0x2" + }, + "0xb24f5374fce5edbc8e2a8697c15331677e6ebf0b": { + "balance": "0x1bc16d6750086f4a" + }, + "0xb94f5374fce5edbc8e2a8697c15331677e6ebf0b": { + "balance": "0x1bc16d6750132188" + } + }, + "result": { + "stateRoot": "0x3f5811b52295bb04a4f602fb37c36e67d503a07dbba48235fa569ad4e7713714", + "txRoot": "0xe5d9d104a39ad50255f8280a0b2d6eb9b5ff9213065e9fb5eae9b2b0e31f44e0", + "receiptsRoot": "0x056b23fbba480696b65fe5a59b8f2148a1299103c4f57df839233af2cf4ca2d2", + "logsHash": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "receipts": [ + { + "root": "0x", + "status": "0x1", + "cumulativeGasUsed": "0x5208", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "logs": null, + "transactionHash": "0x6a2c683e88ffde256fd203cbe29fbbc1a8ef77226e3b63047793a6e74effe141", + "contractAddress": "0x0000000000000000000000000000000000000000", + "gasUsed": "0x5208", + "blockHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "transactionIndex": "0x0" + } + ], + "currentDifficulty": "0x20000", + "gasUsed": "0x5208" + } +} diff --git a/tools/t8n/testdata/00-510/txs.json b/tools/t8n/testdata/00-510/txs.json new file mode 100644 index 000000000..7f5ed9178 --- /dev/null +++ b/tools/t8n/testdata/00-510/txs.json @@ -0,0 +1,14 @@ +[ + { + "input" : "0x", + "gas" : "0xea60", + "gasPrice" : "0x3e8", + "nonce" : "0x1", + "r" : "0xd2e54e989b91bd0b9e3ff0d67ea5ff8b1c9f5e031d6166bcf7019198616c63b4", + "s" : "0x350bf6ea8761dadb683ff1cfcf34e008c4c82ff9e3e7a836245f54ec62514a94", + "sender" : "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", + "to" : "0xb24f5374fce5edbc8e2a8697c15331677e6ebf0b", + "v" : "0x1b", + "value" : "0xa" + } +] diff --git a/tools/t8n/transition.nim b/tools/t8n/transition.nim index 8b6678bce..9c99eb0bf 100644 --- a/tools/t8n/transition.nim +++ b/tools/t8n/transition.nim @@ -222,16 +222,14 @@ proc exec(ctx: var TransContext, db.persist(clearCache = false) let miner = ctx.env.currentCoinbase - vmState.mutateStateDB: - if miner in vmState.selfDestructs: - db.deleteAccount miner - if vmState.com.forkGTE(Spurious): - # EIP158/161 state clearing + if vmState.com.forkGTE(Spurious): + # EIP158/161 state clearing + vmState.mutateStateDB: if db.accountExists(miner) and db.isEmptyAccount(miner): db.deleteAccount(miner) - # do not clear cache, we need the cache when constructing - # post state - db.persist(clearCache = false) + # do not clear cache, we need the cache when constructing + # post state + db.persist(clearCache = false) let stateDB = vmState.stateDB stateDB.postState(result.alloc) @@ -281,7 +279,9 @@ method getAncestorHash(vmState: TestVMState; blockNumber: BlockNumber): Hash256 vmState.hashError = "getAncestorHash($1) invoked, no blockhashes provided" % [$num] return h - if not vmState.blockHashes.take(num, h): + vmState.blockHashes.withValue(num, val) do: + h = val[] + do: vmState.hashError = "getAncestorHash($1) invoked, blockhash for that block not provided" % [$num] return h @@ -402,11 +402,8 @@ proc transitionAction*(ctx: var TransContext, conf: T8NConf) = let header = envToHeader(ctx.env) - # set parent total difficulty - #chainDB.setScore(parent.blockHash, 0.u256) - let vmState = TestVMState( - blockHashes: system.move(ctx.env.blockHashes), + blockHashes: ctx.env.blockHashes, hashError: "" )