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

@ -454,12 +454,12 @@ var (
// 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.
// All operations have at least 7 elements on the stack when executed.
internalNativeTransferEvmOps = map[string]interface{}{
vm.CALL.String(): struct{}{},
vm.CALLCODE.String(): struct{}{},
vm.SELFDESTRUCT.String(): struct{}{},
vm.CREATE.String(): struct{}{},
vm.CREATE2.String(): struct{}{},
internalNativeTransferEvmOps = map[vm.OpCode]interface{}{
vm.CALL: struct{}{},
vm.CALLCODE: struct{}{},
vm.SELFDESTRUCT: struct{}{},
vm.CREATE: struct{}{},
vm.CREATE2: struct{}{},
}
)
@ -489,7 +489,7 @@ func getContractInternalTransferNativeOperations(
}
txStatus := status
if !(log.ParentIsSuccess && log.IsSuccess) {
if log.Reverted {
txStatus = common.FailureOperationStatus.Status
}

Loading…
Cancel
Save