eth/tracers/native: set created address to nil in case of failure (#26779)
Fixes #26073
This commit is contained in:
+16
-14
@@ -42,17 +42,17 @@ type callLog struct {
|
||||
}
|
||||
|
||||
type callFrame struct {
|
||||
Type vm.OpCode `json:"-"`
|
||||
From common.Address `json:"from"`
|
||||
Gas uint64 `json:"gas"`
|
||||
GasUsed uint64 `json:"gasUsed"`
|
||||
To common.Address `json:"to,omitempty" rlp:"optional"`
|
||||
Input []byte `json:"input" rlp:"optional"`
|
||||
Output []byte `json:"output,omitempty" rlp:"optional"`
|
||||
Error string `json:"error,omitempty" rlp:"optional"`
|
||||
RevertReason string `json:"revertReason,omitempty"`
|
||||
Calls []callFrame `json:"calls,omitempty" rlp:"optional"`
|
||||
Logs []callLog `json:"logs,omitempty" rlp:"optional"`
|
||||
Type vm.OpCode `json:"-"`
|
||||
From common.Address `json:"from"`
|
||||
Gas uint64 `json:"gas"`
|
||||
GasUsed uint64 `json:"gasUsed"`
|
||||
To *common.Address `json:"to,omitempty" rlp:"optional"`
|
||||
Input []byte `json:"input" rlp:"optional"`
|
||||
Output []byte `json:"output,omitempty" rlp:"optional"`
|
||||
Error string `json:"error,omitempty" rlp:"optional"`
|
||||
RevertReason string `json:"revertReason,omitempty"`
|
||||
Calls []callFrame `json:"calls,omitempty" rlp:"optional"`
|
||||
Logs []callLog `json:"logs,omitempty" rlp:"optional"`
|
||||
// Placed at end on purpose. The RLP will be decoded to 0 instead of
|
||||
// nil if there are non-empty elements after in the struct.
|
||||
Value *big.Int `json:"value,omitempty" rlp:"optional"`
|
||||
@@ -74,7 +74,7 @@ func (f *callFrame) processOutput(output []byte, err error) {
|
||||
}
|
||||
f.Error = err.Error()
|
||||
if f.Type == vm.CREATE || f.Type == vm.CREATE2 {
|
||||
f.To = common.Address{}
|
||||
f.To = nil
|
||||
}
|
||||
if !errors.Is(err, vm.ErrExecutionReverted) || len(output) == 0 {
|
||||
return
|
||||
@@ -127,10 +127,11 @@ func newCallTracer(ctx *tracers.Context, cfg json.RawMessage) (tracers.Tracer, e
|
||||
|
||||
// CaptureStart implements the EVMLogger interface to initialize the tracing operation.
|
||||
func (t *callTracer) CaptureStart(env *vm.EVM, from common.Address, to common.Address, create bool, input []byte, gas uint64, value *big.Int) {
|
||||
toCopy := to
|
||||
t.callstack[0] = callFrame{
|
||||
Type: vm.CALL,
|
||||
From: from,
|
||||
To: to,
|
||||
To: &toCopy,
|
||||
Input: common.CopyBytes(input),
|
||||
Gas: gas,
|
||||
Value: value,
|
||||
@@ -191,10 +192,11 @@ func (t *callTracer) CaptureEnter(typ vm.OpCode, from common.Address, to common.
|
||||
return
|
||||
}
|
||||
|
||||
toCopy := to
|
||||
call := callFrame{
|
||||
Type: typ,
|
||||
From: from,
|
||||
To: to,
|
||||
To: &toCopy,
|
||||
Input: common.CopyBytes(input),
|
||||
Gas: gas,
|
||||
Value: value,
|
||||
|
||||
@@ -193,7 +193,7 @@ func (t *flatCallTracer) CaptureExit(output []byte, gasUsed uint64, err error) {
|
||||
to = call.To
|
||||
)
|
||||
if typ == vm.CALL || typ == vm.STATICCALL {
|
||||
if t.isPrecompiled(to) {
|
||||
if t.isPrecompiled(*to) {
|
||||
t.tracer.callstack[len(t.tracer.callstack)-1].Calls = parent.Calls[:len(parent.Calls)-1]
|
||||
}
|
||||
}
|
||||
@@ -299,7 +299,7 @@ func newFlatCreate(input *callFrame) *flatCallFrame {
|
||||
},
|
||||
Result: &flatCallResult{
|
||||
GasUsed: &input.GasUsed,
|
||||
Address: &input.To,
|
||||
Address: input.To,
|
||||
Code: &resultCode,
|
||||
},
|
||||
}
|
||||
@@ -315,7 +315,7 @@ func newFlatCall(input *callFrame) *flatCallFrame {
|
||||
Type: strings.ToLower(vm.CALL.String()),
|
||||
Action: flatCallAction{
|
||||
From: &input.From,
|
||||
To: &input.To,
|
||||
To: input.To,
|
||||
Gas: &input.Gas,
|
||||
Value: input.Value,
|
||||
CallType: strings.ToLower(input.Type.String()),
|
||||
@@ -334,7 +334,7 @@ func newFlatSuicide(input *callFrame) *flatCallFrame {
|
||||
Action: flatCallAction{
|
||||
SelfDestructed: &input.From,
|
||||
Balance: input.Value,
|
||||
RefundAddress: &input.To,
|
||||
RefundAddress: input.To,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,19 +16,19 @@ var _ = (*callFrameMarshaling)(nil)
|
||||
// MarshalJSON marshals as JSON.
|
||||
func (c callFrame) MarshalJSON() ([]byte, error) {
|
||||
type callFrame0 struct {
|
||||
Type vm.OpCode `json:"-"`
|
||||
From common.Address `json:"from"`
|
||||
Gas hexutil.Uint64 `json:"gas"`
|
||||
GasUsed hexutil.Uint64 `json:"gasUsed"`
|
||||
To common.Address `json:"to,omitempty" rlp:"optional"`
|
||||
Input hexutil.Bytes `json:"input" rlp:"optional"`
|
||||
Output hexutil.Bytes `json:"output,omitempty" rlp:"optional"`
|
||||
Error string `json:"error,omitempty" rlp:"optional"`
|
||||
RevertReason string `json:"revertReason,omitempty"`
|
||||
Calls []callFrame `json:"calls,omitempty" rlp:"optional"`
|
||||
Logs []callLog `json:"logs,omitempty" rlp:"optional"`
|
||||
Value *hexutil.Big `json:"value,omitempty" rlp:"optional"`
|
||||
TypeString string `json:"type"`
|
||||
Type vm.OpCode `json:"-"`
|
||||
From common.Address `json:"from"`
|
||||
Gas hexutil.Uint64 `json:"gas"`
|
||||
GasUsed hexutil.Uint64 `json:"gasUsed"`
|
||||
To *common.Address `json:"to,omitempty" rlp:"optional"`
|
||||
Input hexutil.Bytes `json:"input" rlp:"optional"`
|
||||
Output hexutil.Bytes `json:"output,omitempty" rlp:"optional"`
|
||||
Error string `json:"error,omitempty" rlp:"optional"`
|
||||
RevertReason string `json:"revertReason,omitempty"`
|
||||
Calls []callFrame `json:"calls,omitempty" rlp:"optional"`
|
||||
Logs []callLog `json:"logs,omitempty" rlp:"optional"`
|
||||
Value *hexutil.Big `json:"value,omitempty" rlp:"optional"`
|
||||
TypeString string `json:"type"`
|
||||
}
|
||||
var enc callFrame0
|
||||
enc.Type = c.Type
|
||||
@@ -80,7 +80,7 @@ func (c *callFrame) UnmarshalJSON(input []byte) error {
|
||||
c.GasUsed = uint64(*dec.GasUsed)
|
||||
}
|
||||
if dec.To != nil {
|
||||
c.To = *dec.To
|
||||
c.To = dec.To
|
||||
}
|
||||
if dec.Input != nil {
|
||||
c.Input = *dec.Input
|
||||
|
||||
Reference in New Issue
Block a user