mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-02-24 01:38:33 +00:00
Add EVM tracer test case for EIP-2929 opcodes
This commit is contained in:
parent
7ae333ac8b
commit
47fae1bb71
@ -59,7 +59,7 @@ const
|
||||
let address = cpt.stack.popAddress()
|
||||
|
||||
cpt.asyncChainTo(ifNecessaryGetAccount(cpt.vmState, address)):
|
||||
let gasCost = cpt.gasCosts[Balance].cost + cpt.gasEip2929AccountCheck(address)
|
||||
let gasCost = cpt.gasEip2929AccountCheck(address)
|
||||
cpt.opcodeGastCost(Balance, gasCost, reason = "Balance EIP2929")
|
||||
cpt.stack.push:
|
||||
cpt.getBalance(address)
|
||||
@ -169,7 +169,7 @@ const
|
||||
let address = cpt.stack.popAddress()
|
||||
|
||||
cpt.asyncChainTo(ifNecessaryGetCode(cpt.vmState, address)):
|
||||
let gasCost = cpt.gasCosts[ExtCodeSize].cost + cpt.gasEip2929AccountCheck(address)
|
||||
let gasCost = cpt.gasEip2929AccountCheck(address)
|
||||
cpt.opcodeGastCost(ExtCodeSize, gasCost, reason = "ExtCodeSize EIP2929")
|
||||
cpt.stack.push:
|
||||
cpt.getCodeSize(address)
|
||||
@ -256,7 +256,7 @@ const
|
||||
let address = k.cpt.stack.popAddress()
|
||||
|
||||
cpt.asyncChainTo(ifNecessaryGetCode(cpt.vmState, address)):
|
||||
let gasCost = cpt.gasCosts[ExtCodeHash].cost + cpt.gasEip2929AccountCheck(address)
|
||||
let gasCost = cpt.gasEip2929AccountCheck(address)
|
||||
cpt.opcodeGastCost(ExtCodeHash, gasCost, reason = "ExtCodeHash EIP2929")
|
||||
|
||||
cpt.stack.push:
|
||||
|
@ -182,8 +182,7 @@ const
|
||||
let (slot) = cpt.stack.popInt(1)
|
||||
|
||||
cpt.asyncChainTo(ifNecessaryGetSlot(cpt.vmState, cpt.msg.contractAddress, slot)):
|
||||
let gasCost = cpt.gasEip2929AccountCheck(cpt.msg.contractAddress, slot) +
|
||||
cpt.gasCosts[Sload].cost
|
||||
let gasCost = cpt.gasEip2929AccountCheck(cpt.msg.contractAddress, slot)
|
||||
cpt.opcodeGastCost(Sload, gasCost, reason = "sloadEIP2929")
|
||||
cpt.stack.push:
|
||||
cpt.getStorage(slot)
|
||||
|
@ -23,8 +23,10 @@ template wrapException(body) =
|
||||
except T8NError as e:
|
||||
stderr.writeLine(e.msg)
|
||||
quit(e.exitCode.int)
|
||||
except:
|
||||
let e = getCurrentException()
|
||||
except CatchableError as e:
|
||||
stderr.writeLine($e.name & " : " & e.msg)
|
||||
quit(QuitFailure)
|
||||
except AssertionDefect as e:
|
||||
stderr.writeLine($e.name & " : " & e.msg)
|
||||
quit(QuitFailure)
|
||||
else:
|
||||
|
@ -542,6 +542,33 @@ const
|
||||
output: T8nOutput(alloc: true, result: true),
|
||||
expOut: "exp.json",
|
||||
),
|
||||
TestSpec(
|
||||
name : "Trace EIP-2929 Balance, Sload, ExtCodeSize, ExtCodeHash",
|
||||
base : "testdata/00-522",
|
||||
input : t8nInput(
|
||||
"alloc.json", "txs.json", "env.json", "Berlin", "0",
|
||||
),
|
||||
output: T8nOutput(trace: true, result: true),
|
||||
expOut: "exp.txt",
|
||||
),
|
||||
TestSpec(
|
||||
name : "Trace Post EIP-2929 Balance, Sload, ExtCodeSize, ExtCodeHash",
|
||||
base : "testdata/00-522",
|
||||
input : t8nInput(
|
||||
"alloc.json", "txs.json", "env.json", "London", "0",
|
||||
),
|
||||
output: T8nOutput(trace: true, result: true),
|
||||
expOut: "exp.txt",
|
||||
),
|
||||
TestSpec(
|
||||
name : "Trace Pre EIP-2929 Balance, Sload, ExtCodeSize, ExtCodeHash",
|
||||
base : "testdata/00-522",
|
||||
input : t8nInput(
|
||||
"alloc.json", "txs.json", "env.json", "Istanbul", "0",
|
||||
),
|
||||
output: T8nOutput(trace: true, result: true),
|
||||
expOut: "istanbul.txt",
|
||||
),
|
||||
]
|
||||
|
||||
proc main() =
|
||||
|
14
tools/t8n/testdata/00-522/alloc.json
vendored
Normal file
14
tools/t8n/testdata/00-522/alloc.json
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"0x00000000000000000000000000000000000000f1": {
|
||||
"code": "0x60016002556002543031303b303f",
|
||||
"storage": {},
|
||||
"balance": "0x0",
|
||||
"nonce": "0x0"
|
||||
},
|
||||
"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b": {
|
||||
"code": "0x",
|
||||
"storage": {},
|
||||
"balance": "0xffffffffff",
|
||||
"nonce": "0x0"
|
||||
}
|
||||
}
|
9
tools/t8n/testdata/00-522/env.json
vendored
Normal file
9
tools/t8n/testdata/00-522/env.json
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"currentCoinbase": "b94f5374fce5edbc8e2a8697c15331677e6ebf0b",
|
||||
"currentDifficulty": "0x200000",
|
||||
"currentGasLimit": "0x26e1f476fe1e22",
|
||||
"currentNumber": "0x1",
|
||||
"currentTimestamp": "0x3e8",
|
||||
"previousHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
|
||||
"currentBaseFee": "0x10"
|
||||
}
|
12
tools/t8n/testdata/00-522/exp.txt
vendored
Normal file
12
tools/t8n/testdata/00-522/exp.txt
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
{"pc":0,"op":96,"gas":"0xb4803","gasCost":"0x3","memSize":0,"stack":[],"depth":1,"refund":0,"opName":"PUSH1"}
|
||||
{"pc":2,"op":96,"gas":"0xb4800","gasCost":"0x3","memSize":0,"stack":["0x1"],"depth":1,"refund":0,"opName":"PUSH1"}
|
||||
{"pc":4,"op":85,"gas":"0xb47fd","gasCost":"0x5654","memSize":0,"stack":["0x1","0x2"],"depth":1,"refund":0,"opName":"SSTORE"}
|
||||
{"pc":5,"op":96,"gas":"0xaf1a9","gasCost":"0x3","memSize":0,"stack":[],"depth":1,"refund":0,"opName":"PUSH1"}
|
||||
{"pc":7,"op":84,"gas":"0xaf1a6","gasCost":"0x64","memSize":0,"stack":["0x2"],"depth":1,"refund":0,"opName":"SLOAD"}
|
||||
{"pc":8,"op":48,"gas":"0xaf142","gasCost":"0x2","memSize":0,"stack":["0x1"],"depth":1,"refund":0,"opName":"ADDRESS"}
|
||||
{"pc":9,"op":49,"gas":"0xaf140","gasCost":"0x64","memSize":0,"stack":["0x1","0xf1"],"depth":1,"refund":0,"opName":"BALANCE"}
|
||||
{"pc":10,"op":48,"gas":"0xaf0dc","gasCost":"0x2","memSize":0,"stack":["0x1","0x1"],"depth":1,"refund":0,"opName":"ADDRESS"}
|
||||
{"pc":11,"op":59,"gas":"0xaf0da","gasCost":"0x64","memSize":0,"stack":["0x1","0x1","0xf1"],"depth":1,"refund":0,"opName":"EXTCODESIZE"}
|
||||
{"pc":12,"op":48,"gas":"0xaf076","gasCost":"0x2","memSize":0,"stack":["0x1","0x1","0xe"],"depth":1,"refund":0,"opName":"ADDRESS"}
|
||||
{"pc":13,"op":63,"gas":"0xaf074","gasCost":"0x64","memSize":0,"stack":["0x1","0x1","0xe","0xf1"],"depth":1,"refund":0,"opName":"EXTCODEHASH"}
|
||||
{"output":"","gasUsed":"0x57f3"}
|
12
tools/t8n/testdata/00-522/istanbul.txt
vendored
Normal file
12
tools/t8n/testdata/00-522/istanbul.txt
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
{"pc":0,"op":96,"gas":"0xb4803","gasCost":"0x3","memSize":0,"stack":[],"depth":1,"refund":0,"opName":"PUSH1"}
|
||||
{"pc":2,"op":96,"gas":"0xb4800","gasCost":"0x3","memSize":0,"stack":["0x1"],"depth":1,"refund":0,"opName":"PUSH1"}
|
||||
{"pc":4,"op":85,"gas":"0xb47fd","gasCost":"0x4e20","memSize":0,"stack":["0x1","0x2"],"depth":1,"refund":0,"opName":"SSTORE"}
|
||||
{"pc":5,"op":96,"gas":"0xaf9dd","gasCost":"0x3","memSize":0,"stack":[],"depth":1,"refund":0,"opName":"PUSH1"}
|
||||
{"pc":7,"op":84,"gas":"0xaf9da","gasCost":"0x320","memSize":0,"stack":["0x2"],"depth":1,"refund":0,"opName":"SLOAD"}
|
||||
{"pc":8,"op":48,"gas":"0xaf6ba","gasCost":"0x2","memSize":0,"stack":["0x1"],"depth":1,"refund":0,"opName":"ADDRESS"}
|
||||
{"pc":9,"op":49,"gas":"0xaf6b8","gasCost":"0x2bc","memSize":0,"stack":["0x1","0xf1"],"depth":1,"refund":0,"opName":"BALANCE"}
|
||||
{"pc":10,"op":48,"gas":"0xaf3fc","gasCost":"0x2","memSize":0,"stack":["0x1","0x1"],"depth":1,"refund":0,"opName":"ADDRESS"}
|
||||
{"pc":11,"op":59,"gas":"0xaf3fa","gasCost":"0x2bc","memSize":0,"stack":["0x1","0x1","0xf1"],"depth":1,"refund":0,"opName":"EXTCODESIZE"}
|
||||
{"pc":12,"op":48,"gas":"0xaf13e","gasCost":"0x2","memSize":0,"stack":["0x1","0x1","0xe"],"depth":1,"refund":0,"opName":"ADDRESS"}
|
||||
{"pc":13,"op":63,"gas":"0xaf13c","gasCost":"0x2bc","memSize":0,"stack":["0x1","0x1","0xe","0xf1"],"depth":1,"refund":0,"opName":"EXTCODEHASH"}
|
||||
{"output":"","gasUsed":"0x5983"}
|
10
tools/t8n/testdata/00-522/txs.json
vendored
Normal file
10
tools/t8n/testdata/00-522/txs.json
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
[{
|
||||
"sender": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b",
|
||||
"gasPrice": "0x10",
|
||||
"nonce": "0x0",
|
||||
"to": "0x00000000000000000000000000000000000000f1",
|
||||
"input": "0x",
|
||||
"gas": "0xb9a0b",
|
||||
"value": "0x01",
|
||||
"secretKey": "0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8"
|
||||
}]
|
Loading…
x
Reference in New Issue
Block a user