remove root call

pull/4065/head
Lutty 3 years ago
parent 4b7a8e065e
commit 3715a9cbcb
  1. 44
      hmy/tracers/rosetta_block_tracer.go
  2. 14
      rosetta/services/tx_operation.go

@ -23,13 +23,13 @@ import (
) )
type RosettaLogItem struct { type RosettaLogItem struct {
IsSuccess bool IsSuccess bool
ParentIsSuccess bool Reverted bool
OP vm.OpCode OP vm.OpCode
Depth []int Depth []int
From common.Address From common.Address
To common.Address To common.Address
Value *big.Int Value *big.Int
} }
type RosettaBlockTracer struct { type RosettaBlockTracer struct {
@ -43,28 +43,38 @@ func (rbt *RosettaBlockTracer) formatAction(depth []int, parentErr error, ac *ac
} }
return &RosettaLogItem{ return &RosettaLogItem{
IsSuccess: ac.err == nil, IsSuccess: ac.err == nil,
ParentIsSuccess: parentErr == nil, Reverted: !(parentErr == nil && ac.err == nil),
OP: ac.op, OP: ac.op,
Depth: depth, Depth: depth,
From: ac.from, From: ac.from,
To: ac.to, To: ac.to,
Value: val, Value: val,
} }
} }
func (rbt *RosettaBlockTracer) GetResult() ([]*RosettaLogItem, error) { func (rbt *RosettaBlockTracer) GetResult() ([]*RosettaLogItem, error) {
root := &rbt.action root := &rbt.action
var results []*RosettaLogItem var results = make([]*RosettaLogItem, 0)
var err error var err error
var finalize func(ac *action, parentErr error, traceAddress []int) var finalize func(ac *action, parentErr error, traceAddress []int)
finalize = func(ac *action, parentErr error, traceAddress []int) { finalize = func(ac *action, parentErr error, traceAddress []int) {
results = append(results, rbt.formatAction(traceAddress, parentErr, ac)) results = append(results, rbt.formatAction(traceAddress, parentErr, ac))
nextErr := parentErr
if ac.err != nil {
nextErr = ac.err
}
for i, subAc := range ac.subCalls { for i, subAc := range ac.subCalls {
finalize(subAc, ac.err, append(traceAddress[:], i)) finalize(subAc, nextErr, append(traceAddress[:], i))
} }
} }
finalize(root, nil, make([]int, 0))
traceAddress := make([]int, 0)
for i, subAc := range root.subCalls {
finalize(subAc, root.err, append(traceAddress[:], i))
}
return results, err return results, err
} }

@ -454,12 +454,12 @@ var (
// internalNativeTransferEvmOps are the EVM operations that can execute a native transfer // internalNativeTransferEvmOps are the EVM operations that can execute a native transfer
// where the sender is a contract address. This is also known as ops for an 'internal' transaction. // where the sender is a contract address. This is also known as ops for an 'internal' transaction.
// All operations have at least 7 elements on the stack when executed. // All operations have at least 7 elements on the stack when executed.
internalNativeTransferEvmOps = map[string]interface{}{ internalNativeTransferEvmOps = map[vm.OpCode]interface{}{
vm.CALL.String(): struct{}{}, vm.CALL: struct{}{},
vm.CALLCODE.String(): struct{}{}, vm.CALLCODE: struct{}{},
vm.SELFDESTRUCT.String(): struct{}{}, vm.SELFDESTRUCT: struct{}{},
vm.CREATE.String(): struct{}{}, vm.CREATE: struct{}{},
vm.CREATE2.String(): struct{}{}, vm.CREATE2: struct{}{},
} }
) )
@ -489,7 +489,7 @@ func getContractInternalTransferNativeOperations(
} }
txStatus := status txStatus := status
if !(log.ParentIsSuccess && log.IsSuccess) { if log.Reverted {
txStatus = common.FailureOperationStatus.Status txStatus = common.FailureOperationStatus.Status
} }

Loading…
Cancel
Save