diff options
author | Martin Holst Swende <martin@swende.se> | 2017-06-07 23:09:08 +0800 |
---|---|---|
committer | Felix Lange <fjl@users.noreply.github.com> | 2017-06-07 23:09:08 +0800 |
commit | 80f7c6c2996ad47f70a5070c400b1fd87a20c59c (patch) | |
tree | 8ad4108832ddd5e0b0c2223ebef8c5dad26ad3cd /core/vm/gen_structlog.go | |
parent | bc24b7a91218ab34f10a145467f6ef380a5d22aa (diff) | |
download | go-tangerine-80f7c6c2996ad47f70a5070c400b1fd87a20c59c.tar.gz go-tangerine-80f7c6c2996ad47f70a5070c400b1fd87a20c59c.tar.zst go-tangerine-80f7c6c2996ad47f70a5070c400b1fd87a20c59c.zip |
cmd/evm: add --prestate, --sender, --json flags for fuzzing (#14476)
Diffstat (limited to 'core/vm/gen_structlog.go')
-rw-r--r-- | core/vm/gen_structlog.go | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/core/vm/gen_structlog.go b/core/vm/gen_structlog.go new file mode 100644 index 000000000..1c86b2256 --- /dev/null +++ b/core/vm/gen_structlog.go @@ -0,0 +1,95 @@ +// Code generated by github.com/fjl/gencodec. DO NOT EDIT. + +package vm + +import ( + "encoding/json" + "math/big" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/ethereum/go-ethereum/common/math" +) + +func (s StructLog) MarshalJSON() ([]byte, error) { + type StructLog struct { + Pc uint64 `json:"pc"` + Op OpCode `json:"op"` + Gas math.HexOrDecimal64 `json:"gas"` + GasCost math.HexOrDecimal64 `json:"gasCost"` + Memory hexutil.Bytes `json:"memory"` + Stack []*math.HexOrDecimal256 `json:"stack"` + Storage map[common.Hash]common.Hash `json:"-"` + Depth int `json:"depth"` + Err error `json:"error"` + OpName string `json:"opName"` + MemorySize int `json:"memSize"` + } + var enc StructLog + enc.Pc = s.Pc + enc.Op = s.Op + enc.Gas = math.HexOrDecimal64(s.Gas) + enc.GasCost = math.HexOrDecimal64(s.GasCost) + enc.Memory = s.Memory + if s.Stack != nil { + enc.Stack = make([]*math.HexOrDecimal256, len(s.Stack)) + for k, v := range s.Stack { + enc.Stack[k] = (*math.HexOrDecimal256)(v) + } + } + enc.Storage = s.Storage + enc.Depth = s.Depth + enc.Err = s.Err + enc.OpName = s.OpName() + enc.MemorySize = s.MemorySize() + return json.Marshal(&enc) +} + +func (s *StructLog) UnmarshalJSON(input []byte) error { + type StructLog struct { + Pc *uint64 `json:"pc"` + Op *OpCode `json:"op"` + Gas *math.HexOrDecimal64 `json:"gas"` + GasCost *math.HexOrDecimal64 `json:"gasCost"` + Memory hexutil.Bytes `json:"memory"` + Stack []*math.HexOrDecimal256 `json:"stack"` + Storage map[common.Hash]common.Hash `json:"-"` + Depth *int `json:"depth"` + Err *error `json:"error"` + } + var dec StructLog + if err := json.Unmarshal(input, &dec); err != nil { + return err + } + if dec.Pc != nil { + s.Pc = *dec.Pc + } + if dec.Op != nil { + s.Op = *dec.Op + } + if dec.Gas != nil { + s.Gas = uint64(*dec.Gas) + } + if dec.GasCost != nil { + s.GasCost = uint64(*dec.GasCost) + } + if dec.Memory != nil { + s.Memory = dec.Memory + } + if dec.Stack != nil { + s.Stack = make([]*big.Int, len(dec.Stack)) + for k, v := range dec.Stack { + s.Stack[k] = (*big.Int)(v) + } + } + if dec.Storage != nil { + s.Storage = dec.Storage + } + if dec.Depth != nil { + s.Depth = *dec.Depth + } + if dec.Err != nil { + s.Err = *dec.Err + } + return nil +} |