diff --git a/eth/tracers/api_tracing_rip7560.go b/eth/tracers/api_tracing_rip7560.go index 31d1b0a5c4..f57e88889c 100644 --- a/eth/tracers/api_tracing_rip7560.go +++ b/eth/tracers/api_tracing_rip7560.go @@ -5,6 +5,7 @@ import ( "encoding/json" "errors" "fmt" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/types" @@ -49,14 +50,14 @@ func (api *Rip7560API) TraceRip7560Validation( return nil, err } var ( - msg = args.ToMessage(vmctx.BaseFee) + //msg = args.ToMessage(vmctx.BaseFee) tx = args.ToTransaction() traceConfig *TraceConfig ) if config != nil { traceConfig = &config.TraceConfig } - traceResult, err := api.traceTx(ctx, tx, msg, new(Context), vmctx, statedb, traceConfig) + traceResult, err := api.traceTx(ctx, tx, new(Context), block, vmctx, statedb, traceConfig) if err != nil { return nil, err } @@ -86,12 +87,12 @@ func (api *Rip7560API) chainContext(ctx context.Context) core.ChainContext { return ethapi.NewChainContext(ctx, api.backend) } -func (api *Rip7560API) traceTx(ctx context.Context, tx *types.Transaction, message *core.Message, txctx *Context, vmctx vm.BlockContext, statedb *state.StateDB, config *TraceConfig) (interface{}, error) { +func (api *Rip7560API) traceTx(ctx context.Context, tx *types.Transaction, txctx *Context, block *types.Block, vmctx vm.BlockContext, statedb *state.StateDB, config *TraceConfig) (interface{}, error) { var ( tracer *Tracer err error timeout = defaultTraceTimeout - usedGas uint64 + //usedGas uint64 ) if config == nil { config = &TraceConfig{} @@ -132,8 +133,15 @@ func (api *Rip7560API) traceTx(ctx context.Context, tx *types.Transaction, messa // Call Prepare to clear out the statedb access list statedb.SetTxContext(txctx.TxHash, txctx.TxIndex) - message.IsRip7560Frame = true - _, err = core.ApplyTransactionWithEVM(message, api.backend.ChainConfig(), new(core.GasPool).AddGas(message.GasLimit), statedb, vmctx.BlockNumber, txctx.BlockHash, tx, &usedGas, vmenv) + gp := new(core.GasPool).AddGas(10000000) + + // TODO: this is added to allow our bundler checking the 'TraceValidation' API is supported on Geth + if tx.Rip7560TransactionData().Sender.Cmp(common.HexToAddress("0x0000000000000000000000000000000000000000")) == 0 { + return tracer.GetResult() + } + + _, err = core.ApplyRip7560ValidationPhases(api.backend.ChainConfig(), api.chainContext(ctx), nil, gp, statedb, block.Header(), tx, vmenv.Config) + //_, err = core.ApplyTransactionWithEVM(message, api.backend.ChainConfig(), new(core.GasPool).AddGas(message.GasLimit), statedb, vmctx.BlockNumber, txctx.BlockHash, tx, &usedGas, vmenv) if err != nil { return nil, fmt.Errorf("tracing failed: %w", err) } diff --git a/eth/tracers/native/rip7560_validation.go b/eth/tracers/native/rip7560_validation.go index 336fb8edee..459e3c50ff 100644 --- a/eth/tracers/native/rip7560_validation.go +++ b/eth/tracers/native/rip7560_validation.go @@ -14,6 +14,8 @@ func init() { tracers.DefaultDirectory.Register("rip7560Validation", newRip7560Tracer, false) } +const ValidationFramesMaxCount = 3 + func newRip7560Tracer(ctx *tracers.Context, cfg json.RawMessage) (*tracers.Tracer, error) { var config prestateTracerConfig if cfg != nil { @@ -22,10 +24,10 @@ func newRip7560Tracer(ctx *tracers.Context, cfg json.RawMessage) (*tracers.Trace } } t := &rip7560ValidationTracer{ - TraceResults: make([]stateMap, 0), - UsedOpcodes: make([]map[byte]bool, 0), - Created: make([]map[common.Address]bool, 0), - Deleted: make([]map[common.Address]bool, 0), + TraceResults: make([]stateMap, ValidationFramesMaxCount), + UsedOpcodes: make([]map[string]bool, ValidationFramesMaxCount), + Created: make([]map[common.Address]bool, ValidationFramesMaxCount), + Deleted: make([]map[common.Address]bool, ValidationFramesMaxCount), } return &tracers.Tracer{ Hooks: &tracing.Hooks{ @@ -42,7 +44,7 @@ func newRip7560Tracer(ctx *tracers.Context, cfg json.RawMessage) (*tracers.Trace type rip7560ValidationTracer struct { env *tracing.VMContext TraceResults []stateMap `json:"traceResults"` - UsedOpcodes []map[byte]bool `json:"usedOpcodes"` + UsedOpcodes []map[string]bool `json:"usedOpcodes"` Created []map[common.Address]bool `json:"created"` Deleted []map[common.Address]bool `json:"deleted"` // todo @@ -58,7 +60,12 @@ func (t *rip7560ValidationTracer) OnTxEnd(receipt *types.Receipt, err error) { } func (t *rip7560ValidationTracer) OnOpcode(pc uint64, opcode byte, gas, cost uint64, scope tracing.OpContext, rData []byte, depth int, err error) { - fmt.Printf("%s %d %d", vm.OpCode(opcode).String(), cost, depth) + opcodeName := vm.OpCode(opcode).String() + fmt.Printf("%s %d %d\n", opcodeName, cost, depth) + if t.UsedOpcodes[0] == nil { + t.UsedOpcodes[0] = make(map[string]bool) + } + t.UsedOpcodes[0][opcodeName] = true } func (t *rip7560ValidationTracer) GetResult() (json.RawMessage, error) { diff --git a/internal/ethapi/transaction_args.go b/internal/ethapi/transaction_args.go index 5683b0a2de..06b5ae6089 100644 --- a/internal/ethapi/transaction_args.go +++ b/internal/ethapi/transaction_args.go @@ -80,8 +80,8 @@ type TransactionArgs struct { Signature *hexutil.Bytes Paymaster *common.Address `json:"paymaster,omitempty"` PaymasterData *hexutil.Bytes `json:"paymasterData,omitempty"` - Deployer *common.Address `json:"factory,omitempty"` - DeployerData *hexutil.Bytes `json:"factoryData,omitempty"` + Deployer *common.Address `json:"deployer,omitempty"` + DeployerData *hexutil.Bytes `json:"deployerData,omitempty"` BuilderFee *hexutil.Big ValidationGas *hexutil.Uint64 `json:"verificationGasLimit"` PaymasterGas *hexutil.Uint64 `json:"paymasterVerificationGasLimit"`