-
Notifications
You must be signed in to change notification settings - Fork 16
feat: implement eip-7702 #196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
e295ad8
26cb8a5
fc46268
2bccdae
6e5f726
8464a96
44f7e1e
21f6f6c
aca4a1f
8cbae34
f45010c
7df31ab
7fab3d1
1f528e9
849f4ee
eb94f81
e297e46
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,152 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Copyright 2024 The go-ethereum Authors | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // This file is part of go-ethereum. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // go-ethereum is free software: you can redistribute it and/or modify | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // it under the terms of the GNU General Public License as published by | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // the Free Software Foundation, either version 3 of the License, or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // (at your option) any later version. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // go-ethereum is distributed in the hope that it will be useful, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // GNU General Public License for more details. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // You should have received a copy of the GNU General Public License | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // along with go-ethereum. If not, see <http://www.gnu.org/licenses/>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| package t8ntool | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "encoding/json" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "fmt" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "io" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "math/big" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "os" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "path/filepath" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "github.com/morph-l2/go-ethereum/common" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "github.com/morph-l2/go-ethereum/core/tracing" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "github.com/morph-l2/go-ethereum/core/types" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "github.com/morph-l2/go-ethereum/eth/tracers" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "github.com/morph-l2/go-ethereum/log" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // fileWritingTracer wraps either a tracer or a logger. On tx start, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // it instantiates a tracer/logger, creates a new file to direct output to, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // and on tx end it closes the file. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type fileWritingTracer struct { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| txIndex int // transaction counter | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| inner *tracing.Hooks // inner hooks | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| destination io.WriteCloser // the currently open file (if any) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| baseDir string // baseDir to write output-files to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| suffix string // suffix is the suffix to use when creating files | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // for custom tracing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| getResult func() (json.RawMessage, error) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| func (l *fileWritingTracer) Write(p []byte) (n int, err error) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if l.destination != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return l.destination.Write(p) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| log.Warn("Tracer wrote to non-existing output") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // It is tempting to return an error here, however, the json encoder | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // will no retry writing to an io.Writer once it has returned an error once. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Therefore, we must squash the error. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return n, nil | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+48
to
+57
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Return len(p) when dropping writes to avoid Writer contract ambiguity. Returning 0, nil can confuse callers; signal that bytes were “accepted” even if ignored. - return n, nil
+ return len(p), nil📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // newFileWriter creates a set of hooks which wraps inner hooks (typically a logger), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // and writes the output to a file, one file per transaction. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| func newFileWriter(baseDir string, innerFn func(out io.Writer) *tracing.Hooks) *tracing.Hooks { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| t := &fileWritingTracer{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| baseDir: baseDir, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| suffix: "jsonl", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| t.inner = innerFn(t) // instantiate the inner tracer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return t.hooks() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // newResultWriter creates a set of hooks wraps and invokes an underlying tracer, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // and writes the result (getResult-output) to file, one per transaction. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| func newResultWriter(baseDir string, tracer *tracers.Tracer) *tracing.Hooks { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| t := &fileWritingTracer{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| baseDir: baseDir, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| getResult: tracer.GetResult, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| inner: tracer.Hooks, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| suffix: "json", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return t.hooks() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // OnTxStart creates a new output-file specific for this transaction, and invokes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // the inner OnTxStart handler. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| func (l *fileWritingTracer) OnTxStart(env *tracing.VMContext, tx *types.Transaction, from common.Address) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Open a new file, or print a warning log if it's failed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fname := filepath.Join(l.baseDir, fmt.Sprintf("trace-%d-%v.%v", l.txIndex, tx.Hash().String(), l.suffix)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| traceFile, err := os.Create(fname) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if err != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| log.Warn("Failed creating trace-file", "err", err) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| log.Info("Created tracing-file", "path", fname) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| l.destination = traceFile | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+85
to
+93
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Create baseDir before file create; minor filename formatting. Ensure directory exists to avoid silent drops; use %s for hash. - fname := filepath.Join(l.baseDir, fmt.Sprintf("trace-%d-%v.%v", l.txIndex, tx.Hash().String(), l.suffix))
- traceFile, err := os.Create(fname)
+ fname := filepath.Join(l.baseDir, fmt.Sprintf("trace-%d-%s.%s", l.txIndex, tx.Hash(), l.suffix))
+ if mkErr := os.MkdirAll(l.baseDir, 0o755); mkErr != nil {
+ log.Warn("Failed ensuring trace directory", "dir", l.baseDir, "err", mkErr)
+ }
+ traceFile, err := os.Create(fname)📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if l.inner != nil && l.inner.OnTxStart != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| l.inner.OnTxStart(env, tx, from) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // OnTxEnd writes result (if getResult exist), closes any currently open output-file, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // and invokes the inner OnTxEnd handler. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| func (l *fileWritingTracer) OnTxEnd(receipt *types.Receipt, err error) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if l.inner != nil && l.inner.OnTxEnd != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| l.inner.OnTxEnd(receipt, err) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if l.getResult != nil && l.destination != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if result, err := l.getResult(); result != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| json.NewEncoder(l.destination).Encode(result) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| log.Warn("Error obtaining tracer result", "err", err) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| l.destination.Close() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| l.destination = nil | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| l.txIndex++ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+101
to
+115
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Always close the per-tx file; current logic leaks FDs when getResult is nil. When using newFileWriter (jsonl), getResult is nil, so the file never closes. This leaks descriptors and can truncate subsequent writes. Apply this diff to always close and to handle result/encoding errors: func (l *fileWritingTracer) OnTxEnd(receipt *types.Receipt, err error) {
if l.inner != nil && l.inner.OnTxEnd != nil {
l.inner.OnTxEnd(receipt, err)
}
- if l.getResult != nil && l.destination != nil {
- if result, err := l.getResult(); result != nil {
- json.NewEncoder(l.destination).Encode(result)
- } else {
- log.Warn("Error obtaining tracer result", "err", err)
- }
- l.destination.Close()
- l.destination = nil
- }
+ if l.destination != nil {
+ if l.getResult != nil {
+ if result, rerr := l.getResult(); rerr != nil {
+ log.Warn("Error obtaining tracer result", "err", rerr)
+ } else if result != nil {
+ if encErr := json.NewEncoder(l.destination).Encode(result); encErr != nil {
+ log.Warn("Error writing tracer result", "err", encErr)
+ }
+ }
+ }
+ if cerr := l.destination.Close(); cerr != nil {
+ log.Warn("Failed closing trace-file", "err", cerr)
+ }
+ l.destination = nil
+ }
l.txIndex++
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| func (l *fileWritingTracer) hooks() *tracing.Hooks { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return &tracing.Hooks{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| OnTxStart: l.OnTxStart, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| OnTxEnd: l.OnTxEnd, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| OnEnter: func(depth int, typ byte, from common.Address, to common.Address, input []byte, gas uint64, value *big.Int) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if l.inner != nil && l.inner.OnEnter != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| l.inner.OnEnter(depth, typ, from, to, input, gas, value) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| OnExit: func(depth int, output []byte, gasUsed uint64, err error, reverted bool) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if l.inner != nil && l.inner.OnExit != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| l.inner.OnExit(depth, output, gasUsed, err, reverted) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| OnOpcode: func(pc uint64, op byte, gas, cost uint64, scope tracing.OpContext, rData []byte, depth int, err error) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if l.inner != nil && l.inner.OnOpcode != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| l.inner.OnOpcode(pc, op, gas, cost, scope, rData, depth, err) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| OnFault: func(pc uint64, op byte, gas, cost uint64, scope tracing.OpContext, depth int, err error) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if l.inner != nil && l.inner.OnFault != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| l.inner.OnFault(pc, op, gas, cost, scope, depth, err) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| OnSystemCallStart: func() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if l.inner != nil && l.inner.OnSystemCallStart != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| l.inner.OnSystemCallStart() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| OnSystemCallEnd: func() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if l.inner != nil && l.inner.OnSystemCallEnd != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| l.inner.OnSystemCallEnd() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+117
to
+151
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Pass through all inner hooks; current wrapper drops many (GasChange, Block, State, etc.).** Only a subset is forwarded, causing lost events when using this wrapper. Would you like me to add passthroughs for the remaining hooks (OnGasChange, OnBlockchainInit, OnClose, OnBlockStart/End/Skipped/Genesis, OnSystemCallStartV2, OnBalanceChange, OnNonceChange/OnNonceChangeV2, OnCodeChange, OnStorageChange, OnLog, OnBlockHashRead)? I can provide a patch once you confirm desired coverage. 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
SetCodeTxType gas handling OK; also propagate AuthorizationList to signer args
Dynamic-fee handling for SetCode is good. But the authorization list is not forwarded to clef, risking data loss when signing SetCode txs.
@@ func (api *ExternalSigner) SignTx(account accounts.Account, tx *types.Transaction, chainID *big.Int) (*types.Transaction, error) { - accessList := tx.AccessList() - args.AccessList = &accessList + accessList := tx.AccessList() + args.AccessList = &accessList + // For EIP-7702 SetCodeTxType, forward authorizations to the external signer (requires apitypes support). + if tx.Type() == types.SetCodeTxType { + auth := tx.SetCodeAuthorizations() + if len(auth) > 0 { + args.AuthorizationList = &auth + } + }Verification:
🏁 Script executed:
Length of output: 563
🏁 Script executed:
Length of output: 1056
Add AuthorizationList to SendTxArgs and forward SetCode authorizations
The
SendTxArgsstruct insigner/core/apitypes/types.godoesn’t include anAuthorizationListfield. Add it just aboveChainID:type SendTxArgs struct { … AccessList *types.AccessList `json:"accessList,omitempty"` + // For EIP-7702 SetCode transactions + AuthorizationList *[]types.Authorization `json:"authorizationList,omitempty"` ChainID *hexutil.Big `json:"chainId,omitempty"` }Then in
accounts/external/backend.goinsideSignTx, propagate the authorizations forSetCodeTxType:accessList := tx.AccessList() args.AccessList = &accessList + if tx.Type() == types.SetCodeTxType { + auth := tx.SetCodeAuthorizations() + if len(auth) > 0 { + args.AuthorizationList = &auth + } + }This ensures the external signer (e.g., clef) receives the authorization list when signing SetCode transactions.