support rosetta tracer

pull/4065/head
Lutty 3 years ago
parent d9e933c7f3
commit a3875d08a3
  1. 7
      core/vm/evm.go
  2. 11
      hmy/tracers/rosetta_block_tracer.go
  3. 4
      rosetta/services/tx_operation.go

@ -32,8 +32,13 @@ import (
// deployed contract addresses (relevant after the account abstraction).
var emptyCodeHash = crypto.Keccak256Hash(nil)
type RosettaLogAddressItem struct {
Account, SubAccount common.Address
Metadata map[string]interface{}
}
type RosettaTracer interface {
AddRosettaLog(op OpCode, from, to common.Address, val *big.Int)
AddRosettaLog(op OpCode, from, to *RosettaLogAddressItem, val *big.Int)
}
type (

@ -17,7 +17,6 @@
package tracers
import (
"github.com/ethereum/go-ethereum/common"
"github.com/harmony-one/harmony/core/vm"
"math/big"
)
@ -27,8 +26,8 @@ type RosettaLogItem struct {
Reverted bool
OP vm.OpCode
Depth []int
From common.Address
To common.Address
From *vm.RosettaLogAddressItem
To *vm.RosettaLogAddressItem
Value *big.Int
}
@ -49,13 +48,13 @@ func (rbt *RosettaBlockTracer) formatAction(depth []int, parentErr error, ac *ac
Reverted: !(parentErr == nil && ac.err == nil),
OP: ac.op,
Depth: depth,
From: ac.from,
To: ac.to,
From: &vm.RosettaLogAddressItem{Account: ac.from},
To: &vm.RosettaLogAddressItem{Account: ac.to},
Value: val,
}
}
func (rbt *RosettaBlockTracer) AddRosettaLog(op vm.OpCode, from, to common.Address, val *big.Int) {
func (rbt *RosettaBlockTracer) AddRosettaLog(op vm.OpCode, from, to *vm.RosettaLogAddressItem, val *big.Int) {
rbt.logs = append(rbt.logs, &RosettaLogItem{
IsSuccess: true,
Reverted: false,

@ -478,12 +478,12 @@ func getContractInternalTransferNativeOperations(
for _, log := range executionResult {
// skip meaningless information
if log.Value.Cmp(big.NewInt(0)) != 0 {
fromAccID, rosettaError := newAccountIdentifier(log.From)
fromAccID, rosettaError := newAccountIdentifier(log.From.Account)
if rosettaError != nil {
return nil, rosettaError
}
toAccID, rosettaError := newAccountIdentifier(log.To)
toAccID, rosettaError := newAccountIdentifier(log.To.Account)
if rosettaError != nil {
return nil, rosettaError
}

Loading…
Cancel
Save