all: implement EIP-1559 (#22837)
This is the initial implementation of EIP-1559 in packages core/types and core. Mining, RPC, etc. will be added in subsequent commits. Co-authored-by: Marius van der Wijden <m.vanderwijden@live.de> Co-authored-by: lightclient@protonmail.com <lightclient@protonmail.com> Co-authored-by: Felix Lange <fjl@twurst.com>
This commit is contained in:
committed by
GitHub
parent
14bc6e5130
commit
94451c2788
11
cmd/evm/testdata/9/alloc.json
vendored
Normal file
11
cmd/evm/testdata/9/alloc.json
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"0x000000000000000000000000000000000000aaaa": {
|
||||
"balance": "0x03",
|
||||
"code": "0x58585454",
|
||||
"nonce": "0x1"
|
||||
},
|
||||
"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b": {
|
||||
"balance": "0x100000000000000",
|
||||
"nonce": "0x00"
|
||||
}
|
||||
}
|
8
cmd/evm/testdata/9/env.json
vendored
Normal file
8
cmd/evm/testdata/9/env.json
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"currentCoinbase": "0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
|
||||
"currentDifficulty": "0x20000",
|
||||
"currentGasTarget": "0x1000000000",
|
||||
"currentBaseFee": "0x3B9ACA00",
|
||||
"currentNumber": "0x1000000",
|
||||
"currentTimestamp": "0x04"
|
||||
}
|
75
cmd/evm/testdata/9/readme.md
vendored
Normal file
75
cmd/evm/testdata/9/readme.md
vendored
Normal file
@ -0,0 +1,75 @@
|
||||
## EIP-1559 testing
|
||||
|
||||
This test contains testcases for EIP-1559, which uses an new transaction type and has a new block parameter.
|
||||
|
||||
### Prestate
|
||||
|
||||
The alloc portion contains one contract (`0x000000000000000000000000000000000000aaaa`), containing the
|
||||
following code: `0x58585454`: `PC; PC; SLOAD; SLOAD`.
|
||||
|
||||
Essentialy, this contract does `SLOAD(0)` and `SLOAD(1)`.
|
||||
|
||||
The alloc also contains some funds on `0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b`.
|
||||
|
||||
## Transactions
|
||||
|
||||
There are two transactions, each invokes the contract above.
|
||||
|
||||
1. EIP-1559 ACL-transaction, which contains the `0x0` slot for `0xaaaa`
|
||||
2. Legacy transaction
|
||||
|
||||
## Execution
|
||||
|
||||
Running it yields:
|
||||
```
|
||||
$ dir=./testdata/9 && ./evm t8n --state.fork=London --input.alloc=$dir/alloc.json --input.txs=$dir/txs.json --input.env=$dir/env.json --trace && cat trace-* | grep SLOAD
|
||||
{"pc":2,"op":84,"gas":"0x48c28","gasCost":"0x834","memory":"0x","memSize":0,"stack":["0x0","0x1"],"returnStack":null,"returnD
|
||||
ata":"0x","depth":1,"refund":0,"opName":"SLOAD","error":""}
|
||||
{"pc":3,"op":84,"gas":"0x483f4","gasCost":"0x64","memory":"0x","memSize":0,"stack":["0x0","0x0"],"returnStack":null,"returnDa
|
||||
ta":"0x","depth":1,"refund":0,"opName":"SLOAD","error":""}
|
||||
{"pc":2,"op":84,"gas":"0x49cf4","gasCost":"0x834","memory":"0x","memSize":0,"stack":["0x0","0x1"],"returnStack":null,"returnD
|
||||
ata":"0x","depth":1,"refund":0,"opName":"SLOAD","error":""}
|
||||
{"pc":3,"op":84,"gas":"0x494c0","gasCost":"0x834","memory":"0x","memSize":0,"stack":["0x0","0x0"],"returnStack":null,"returnD
|
||||
ata":"0x","depth":1,"refund":0,"opName":"SLOAD","error":""}
|
||||
```
|
||||
|
||||
We can also get the post-alloc:
|
||||
```
|
||||
$ dir=./testdata/9 && ./evm t8n --state.fork=London --input.alloc=$dir/alloc.json --input.txs=$dir/txs.json --input.env=$dir/env.json --output.alloc=stdout
|
||||
{
|
||||
"alloc": {
|
||||
"0x000000000000000000000000000000000000aaaa": {
|
||||
"code": "0x58585454",
|
||||
"balance": "0x3",
|
||||
"nonce": "0x1"
|
||||
},
|
||||
"0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba": {
|
||||
"balance": "0xbfc02677a000"
|
||||
},
|
||||
"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b": {
|
||||
"balance": "0xff104fcfea7800",
|
||||
"nonce": "0x2"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
If we try to execute it on older rules:
|
||||
```
|
||||
dir=./testdata/9 && ./evm t8n --state.fork=Berlin --input.alloc=$dir/alloc.json --input.txs=$dir/txs.json --input.env=$dir/env.json --output.alloc=stdout
|
||||
ERROR(10): Failed signing transactions: ERROR(10): Tx 0: failed to sign tx: transaction type not supported
|
||||
```
|
||||
|
||||
It fails, due to the `evm t8n` cannot sign them in with the given signer. We can bypass that, however,
|
||||
by feeding it presigned transactions, located in `txs_signed.json`.
|
||||
|
||||
```
|
||||
dir=./testdata/9 && ./evm t8n --state.fork=Berlin --input.alloc=$dir/alloc.json --input.txs=$dir/txs_signed.json --input.env=$dir/env.json
|
||||
INFO [05-07|12:28:42.072] rejected tx index=0 hash=b4821e..536819 error="transaction type not supported"
|
||||
INFO [05-07|12:28:42.072] rejected tx index=1 hash=a9c6c6..fa4036 from=0xa94f5374Fce5edBC8E2a8697C15331677e6EbF0B error="nonce too high: address 0xa94f5374Fce5edBC8E2a8697C15331677e6EbF0B, tx: 1 state: 0"
|
||||
INFO [05-07|12:28:42.073] Wrote file file=alloc.json
|
||||
INFO [05-07|12:28:42.073] Wrote file file=result.json
|
||||
```
|
||||
|
||||
Number `0` is not applicable, and therefore number `1` has wrong nonce, and both are rejected.
|
||||
|
37
cmd/evm/testdata/9/txs.json
vendored
Normal file
37
cmd/evm/testdata/9/txs.json
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
[
|
||||
{
|
||||
"gas": "0x4ef00",
|
||||
"tip": "0x2",
|
||||
"feeCap": "0x12A05F200",
|
||||
"chainId": "0x1",
|
||||
"input": "0x",
|
||||
"nonce": "0x0",
|
||||
"to": "0x000000000000000000000000000000000000aaaa",
|
||||
"value": "0x0",
|
||||
"type" : "0x2",
|
||||
"accessList": [
|
||||
{"address": "0x000000000000000000000000000000000000aaaa",
|
||||
"storageKeys": [
|
||||
"0x0000000000000000000000000000000000000000000000000000000000000000"
|
||||
]
|
||||
}
|
||||
],
|
||||
"v": "0x0",
|
||||
"r": "0x0",
|
||||
"s": "0x0",
|
||||
"secretKey": "0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8"
|
||||
},
|
||||
{
|
||||
"gas": "0x4ef00",
|
||||
"gasPrice": "0x12A05F200",
|
||||
"chainId": "0x1",
|
||||
"input": "0x",
|
||||
"nonce": "0x1",
|
||||
"to": "0x000000000000000000000000000000000000aaaa",
|
||||
"value": "0x0",
|
||||
"v": "0x0",
|
||||
"r": "0x0",
|
||||
"s": "0x0",
|
||||
"secretKey": "0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8"
|
||||
}
|
||||
]
|
Reference in New Issue
Block a user