mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
eth/tracers/logger: make structlog/json-log stack hex again
This commit is contained in:
parent
eede592372
commit
4d002e2ab7
2 changed files with 13 additions and 4 deletions
|
|
@ -23,7 +23,7 @@ func (s StructLog) MarshalJSON() ([]byte, error) {
|
|||
GasCost math.HexOrDecimal64 `json:"gasCost"`
|
||||
Memory hexutil.Bytes `json:"memory,omitempty"`
|
||||
MemorySize int `json:"memSize"`
|
||||
Stack []uint256.Int `json:"stack"`
|
||||
Stack []hexutil.U256 `json:"stack"`
|
||||
ReturnData hexutil.Bytes `json:"returnData,omitempty"`
|
||||
Storage map[common.Hash]common.Hash `json:"-"`
|
||||
Depth int `json:"depth"`
|
||||
|
|
@ -39,7 +39,12 @@ func (s StructLog) MarshalJSON() ([]byte, error) {
|
|||
enc.GasCost = math.HexOrDecimal64(s.GasCost)
|
||||
enc.Memory = s.Memory
|
||||
enc.MemorySize = s.MemorySize
|
||||
enc.Stack = s.Stack
|
||||
if s.Stack != nil {
|
||||
enc.Stack = make([]hexutil.U256, len(s.Stack))
|
||||
for k, v := range s.Stack {
|
||||
enc.Stack[k] = hexutil.U256(v)
|
||||
}
|
||||
}
|
||||
enc.ReturnData = s.ReturnData
|
||||
enc.Storage = s.Storage
|
||||
enc.Depth = s.Depth
|
||||
|
|
@ -59,7 +64,7 @@ func (s *StructLog) UnmarshalJSON(input []byte) error {
|
|||
GasCost *math.HexOrDecimal64 `json:"gasCost"`
|
||||
Memory *hexutil.Bytes `json:"memory,omitempty"`
|
||||
MemorySize *int `json:"memSize"`
|
||||
Stack []uint256.Int `json:"stack"`
|
||||
Stack []hexutil.U256 `json:"stack"`
|
||||
ReturnData *hexutil.Bytes `json:"returnData,omitempty"`
|
||||
Storage map[common.Hash]common.Hash `json:"-"`
|
||||
Depth *int `json:"depth"`
|
||||
|
|
@ -89,7 +94,10 @@ func (s *StructLog) UnmarshalJSON(input []byte) error {
|
|||
s.MemorySize = *dec.MemorySize
|
||||
}
|
||||
if dec.Stack != nil {
|
||||
s.Stack = dec.Stack
|
||||
s.Stack = make([]uint256.Int, len(dec.Stack))
|
||||
for k, v := range dec.Stack {
|
||||
s.Stack[k] = uint256.Int(v)
|
||||
}
|
||||
}
|
||||
if dec.ReturnData != nil {
|
||||
s.ReturnData = *dec.ReturnData
|
||||
|
|
|
|||
|
|
@ -83,6 +83,7 @@ type structLogMarshaling struct {
|
|||
GasCost math.HexOrDecimal64
|
||||
Memory hexutil.Bytes
|
||||
ReturnData hexutil.Bytes
|
||||
Stack []hexutil.U256
|
||||
OpName string `json:"opName"` // adds call to OpName() in MarshalJSON
|
||||
ErrorString string `json:"error,omitempty"` // adds call to ErrorString() in MarshalJSON
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue