go-ethereum/rollup/tracing/mux_tracer.go
colin 60cbf64f9c
feat: add EIP-7702 (#1112)
* feat: add EIP-7702

* fix goimport

* add unit tests

* add api test

* sync txpool update

* update generated code

* make code readable

* fix goimport

* fix TestAsyncChecker unit test

* add AuthorizationList in fuzz tests for completeness sake

* add EuclidV2 test, EIP-7702 transaction in TestT8n

* clean up logs

* bump version

* fix TestAsyncChecker

* Revert "fix TestAsyncChecker"

This reverts commit 314478303d4a504a3948bd6595568916ba7d82f0.

* accept eip-7702 txns only after enabling eip-7702

* revert IntrinsicGas param name from setCodeAuthorizations to authList

* fix a bug

* align upstream implementation in Encoding Receipts

* fix one test case

* fix tracer

* return precode copy

* support setcode tx in EstimateGas and add unit tests

* add TestValidateAuthorizations

* poseidon hash fix

* migrate a fix before the fix pr is merged

* support setcode type transactions in TransactionData

* chore: auto version bump [bot]

* add a nonce-gapped-auth-does-not-block-pending-tx unit test

* make the auth invalid

* Apply suggestions from code review

* change usedAndLeftSlots and knownConflicts to util functions

* add comments about different return of applyAuthorization

* remove gencodec:required in transaction signatures

* fix goimport

* update StructLogger and AccessListTracer

* fix a bug

* fix flaky test

---------

Co-authored-by: colinlyguo <colinlyguo@users.noreply.github.com>
Co-authored-by: Péter Garamvölgyi <peter@scroll.io>
2025-02-25 14:56:51 +01:00

70 lines
2.6 KiB
Go

package tracing
import (
"math/big"
"time"
"github.com/scroll-tech/go-ethereum/common"
"github.com/scroll-tech/go-ethereum/core/types"
"github.com/scroll-tech/go-ethereum/core/vm"
_ "github.com/scroll-tech/go-ethereum/eth/tracers/native"
)
// MuxTracer is a tracer mux, to support running multiple tracers together
type MuxTracer struct {
tracers []vm.EVMLogger
}
// NewMuxTracer creates a new MuxTracer with multiple tracers
func NewMuxTracer(tracers ...vm.EVMLogger) *MuxTracer {
return &MuxTracer{tracers}
}
// CaptureStart runs CaptureStart for each tracer in the MuxTracer
func (t *MuxTracer) CaptureStart(env *vm.EVM, from common.Address, to common.Address, create bool, input []byte, gas uint64, value *big.Int, authorizationResults []types.AuthorizationResult) {
for _, tracer := range t.tracers {
tracer.CaptureStart(env, from, to, create, input, gas, value, authorizationResults)
}
}
// CaptureState runs CaptureState for each tracer in the MuxTracer
func (t *MuxTracer) CaptureState(pc uint64, op vm.OpCode, gas, cost uint64, scope *vm.ScopeContext, rData []byte, depth int, err error) {
for _, tracer := range t.tracers {
tracer.CaptureState(pc, op, gas, cost, scope, rData, depth, err)
}
}
// CaptureStateAfter runs CaptureStateAfter for each tracer in the MuxTracer
func (t *MuxTracer) CaptureStateAfter(pc uint64, op vm.OpCode, gas, cost uint64, scope *vm.ScopeContext, rData []byte, depth int, err error) {
for _, tracer := range t.tracers {
tracer.CaptureStateAfter(pc, op, gas, cost, scope, rData, depth, err)
}
}
// CaptureEnter runs CaptureEnter for each tracer in the MuxTracer
func (t *MuxTracer) CaptureEnter(typ vm.OpCode, from common.Address, to common.Address, input []byte, gas uint64, value *big.Int) {
for _, tracer := range t.tracers {
tracer.CaptureEnter(typ, from, to, input, gas, value)
}
}
// CaptureExit runs CaptureExit for each tracer in the MuxTracer
func (t *MuxTracer) CaptureExit(output []byte, gasUsed uint64, err error) {
for _, tracer := range t.tracers {
tracer.CaptureExit(output, gasUsed, err)
}
}
// CaptureFault runs CaptureFault for each tracer in the MuxTracer
func (t *MuxTracer) CaptureFault(pc uint64, op vm.OpCode, gas, cost uint64, scope *vm.ScopeContext, depth int, err error) {
for _, tracer := range t.tracers {
tracer.CaptureFault(pc, op, gas, cost, scope, depth, err)
}
}
// CaptureEnd runs CaptureEnd for each tracer in the MuxTracer
func (t *MuxTracer) CaptureEnd(output []byte, gasUsed uint64, d time.Duration, err error) {
for _, tracer := range t.tracers {
tracer.CaptureEnd(output, gasUsed, d, err)
}
}