Skip to content

Commit f623c91

Browse files
lightclientmarioevzholimanfjl
authored andcommitted
all: implement eip-7702 set code tx (ethereum#30078)
This PR implements EIP-7702: "Set EOA account code". Specification: https://eips.ethereum.org/EIPS/eip-7702 > Add a new transaction type that adds a list of `[chain_id, address, nonce, y_parity, r, s]` authorization tuples. For each tuple, write a delegation designator `(0xef0100 ++ address)` to the signing account’s code. All code reading operations must load the code pointed to by the designator. --------- Co-authored-by: Mario Vega <[email protected]> Co-authored-by: Martin Holst Swende <[email protected]> Co-authored-by: Felix Lange <[email protected]>
1 parent bfc8efe commit f623c91

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+1606
-115
lines changed

accounts/external/backend.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ func (api *ExternalSigner) SignTx(account accounts.Account, tx *types.Transactio
215215
switch tx.Type() {
216216
case types.LegacyTxType, types.AccessListTxType:
217217
args.GasPrice = (*hexutil.Big)(tx.GasPrice())
218-
case types.DynamicFeeTxType, types.BlobTxType:
218+
case types.DynamicFeeTxType, types.BlobTxType, types.SetCodeTxType:
219219
args.MaxFeePerGas = (*hexutil.Big)(tx.GasFeeCap())
220220
args.MaxPriorityFeePerGas = (*hexutil.Big)(tx.GasTipCap())
221221
default:

cmd/evm/eofparse.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ var jt vm.JumpTable
3636
const initcode = "INITCODE"
3737

3838
func init() {
39-
jt = vm.NewPragueEOFInstructionSetForTesting()
39+
jt = vm.NewEOFInstructionSetForTesting()
4040
}
4141

4242
var (

cmd/evm/eofparse_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func FuzzEofParsing(f *testing.F) {
4343
// And do the fuzzing
4444
f.Fuzz(func(t *testing.T, data []byte) {
4545
var (
46-
jt = vm.NewPragueEOFInstructionSetForTesting()
46+
jt = vm.NewEOFInstructionSetForTesting()
4747
c vm.Container
4848
)
4949
cpy := common.CopyBytes(data)

cmd/evm/internal/t8ntool/execution.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@ type ExecutionResult struct {
7070
CurrentExcessBlobGas *math.HexOrDecimal64 `json:"currentExcessBlobGas,omitempty"`
7171
CurrentBlobGasUsed *math.HexOrDecimal64 `json:"blobGasUsed,omitempty"`
7272
RequestsHash *common.Hash `json:"requestsHash,omitempty"`
73-
Requests [][]byte `json:"requests,omitempty"`
73+
Requests [][]byte `json:"requests"`
7474
}
7575

7676
type executionResultMarshaling struct {
77-
Requests []hexutil.Bytes `json:"requests,omitempty"`
77+
Requests []hexutil.Bytes `json:"requests"`
7878
}
7979

8080
type ommer struct {

cmd/evm/internal/t8ntool/gen_execresult.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/evm/internal/t8ntool/transaction.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ func Transaction(ctx *cli.Context) error {
133133
r.Address = sender
134134
}
135135
// Check intrinsic gas
136-
if gas, err := core.IntrinsicGas(tx.Data(), tx.AccessList(), tx.To() == nil,
136+
if gas, err := core.IntrinsicGas(tx.Data(), tx.AccessList(), tx.AuthList(), tx.To() == nil,
137137
chainConfig.IsHomestead(new(big.Int)), chainConfig.IsIstanbul(new(big.Int)), chainConfig.IsShanghai(new(big.Int), 0)); err != nil {
138138
r.Error = err
139139
results = append(results, r)

cmd/evm/t8n_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,14 @@ func TestT8n(t *testing.T) {
287287
output: t8nOutput{alloc: true, result: true},
288288
expOut: "exp.json",
289289
},
290+
{ // Prague test, EIP-7702 transaction
291+
base: "./testdata/33",
292+
input: t8nInput{
293+
"alloc.json", "txs.json", "env.json", "Prague", "",
294+
},
295+
output: t8nOutput{alloc: true, result: true},
296+
expOut: "exp.json",
297+
},
290298
} {
291299
args := []string{"t8n"}
292300
args = append(args, tc.output.get()...)

cmd/evm/testdata/1/exp.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
}
4141
],
4242
"currentDifficulty": "0x20000",
43-
"gasUsed": "0x5208"
43+
"gasUsed": "0x5208",
44+
"requests": null
4445
}
4546
}

cmd/evm/testdata/13/exp2.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
],
3838
"currentDifficulty": "0x20000",
3939
"gasUsed": "0x109a0",
40-
"currentBaseFee": "0x36b"
40+
"currentBaseFee": "0x36b",
41+
"requests": null
4142
}
4243
}

cmd/evm/testdata/14/exp.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"currentDifficulty": "0x2000020000000",
99
"receipts": [],
1010
"gasUsed": "0x0",
11-
"currentBaseFee": "0x500"
11+
"currentBaseFee": "0x500",
12+
"requests": null
1213
}
1314
}

0 commit comments

Comments
 (0)