core/types, core/vm, eth, tests: regenerate gencodec files

This commit is contained in:
Felix Lange 2018-01-04 13:26:42 +01:00
parent 07c081238b
commit 3f7bf811b1
11 changed files with 57 additions and 73 deletions

View file

@ -89,8 +89,8 @@ type Header struct {
type headerMarshaling struct { type headerMarshaling struct {
Difficulty *hexutil.Big Difficulty *hexutil.Big
Number *hexutil.Big Number *hexutil.Big
GasLimit *hexutil.Uint64 GasLimit hexutil.Uint64
GasUsed *hexutil.Uint64 GasUsed hexutil.Uint64
Time *hexutil.Big Time *hexutil.Big
Extra hexutil.Bytes Extra hexutil.Bytes
Hash common.Hash `json:"hash"` // adds call to Hash() in MarshalJSON Hash common.Hash `json:"hash"` // adds call to Hash() in MarshalJSON

View file

@ -11,6 +11,8 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/common/hexutil"
) )
var _ = (*headerMarshaling)(nil)
func (h Header) MarshalJSON() ([]byte, error) { func (h Header) MarshalJSON() ([]byte, error) {
type Header struct { type Header struct {
ParentHash common.Hash `json:"parentHash" gencodec:"required"` ParentHash common.Hash `json:"parentHash" gencodec:"required"`
@ -111,11 +113,11 @@ func (h *Header) UnmarshalJSON(input []byte) error {
if dec.GasLimit == nil { if dec.GasLimit == nil {
return errors.New("missing required field 'gasLimit' for Header") return errors.New("missing required field 'gasLimit' for Header")
} }
h.GasLimit = (uint64)(*dec.GasLimit) h.GasLimit = uint64(*dec.GasLimit)
if dec.GasUsed == nil { if dec.GasUsed == nil {
return errors.New("missing required field 'gasUsed' for Header") return errors.New("missing required field 'gasUsed' for Header")
} }
h.GasUsed = (uint64)(*dec.GasUsed) h.GasUsed = uint64(*dec.GasUsed)
if dec.Time == nil { if dec.Time == nil {
return errors.New("missing required field 'timestamp' for Header") return errors.New("missing required field 'timestamp' for Header")
} }

View file

@ -10,6 +10,8 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/common/hexutil"
) )
var _ = (*logMarshaling)(nil)
func (l Log) MarshalJSON() ([]byte, error) { func (l Log) MarshalJSON() ([]byte, error) {
type Log struct { type Log struct {
Address common.Address `json:"address" gencodec:"required"` Address common.Address `json:"address" gencodec:"required"`

View file

@ -10,6 +10,8 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/common/hexutil"
) )
var _ = (*receiptMarshaling)(nil)
func (r Receipt) MarshalJSON() ([]byte, error) { func (r Receipt) MarshalJSON() ([]byte, error) {
type Receipt struct { type Receipt struct {
PostState hexutil.Bytes `json:"root"` PostState hexutil.Bytes `json:"root"`

View file

@ -11,6 +11,8 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/common/hexutil"
) )
var _ = (*txdataMarshaling)(nil)
func (t txdata) MarshalJSON() ([]byte, error) { func (t txdata) MarshalJSON() ([]byte, error) {
type txdata struct { type txdata struct {
AccountNonce hexutil.Uint64 `json:"nonce" gencodec:"required"` AccountNonce hexutil.Uint64 `json:"nonce" gencodec:"required"`

View file

@ -11,6 +11,8 @@ import (
"github.com/ethereum/go-ethereum/common/math" "github.com/ethereum/go-ethereum/common/math"
) )
var _ = (*structLogMarshaling)(nil)
func (s StructLog) MarshalJSON() ([]byte, error) { func (s StructLog) MarshalJSON() ([]byte, error) {
type StructLog struct { type StructLog struct {
Pc uint64 `json:"pc"` Pc uint64 `json:"pc"`
@ -22,8 +24,9 @@ func (s StructLog) MarshalJSON() ([]byte, error) {
Stack []*math.HexOrDecimal256 `json:"stack"` Stack []*math.HexOrDecimal256 `json:"stack"`
Storage map[common.Hash]common.Hash `json:"-"` Storage map[common.Hash]common.Hash `json:"-"`
Depth int `json:"depth"` Depth int `json:"depth"`
Err error `json:"error"` Err error `json:"-"`
OpName string `json:"opName"` OpName string `json:"opName"`
ErrorString string `json:"error"`
} }
var enc StructLog var enc StructLog
enc.Pc = s.Pc enc.Pc = s.Pc
@ -42,6 +45,7 @@ func (s StructLog) MarshalJSON() ([]byte, error) {
enc.Depth = s.Depth enc.Depth = s.Depth
enc.Err = s.Err enc.Err = s.Err
enc.OpName = s.OpName() enc.OpName = s.OpName()
enc.ErrorString = s.ErrorString()
return json.Marshal(&enc) return json.Marshal(&enc)
} }
@ -56,7 +60,7 @@ func (s *StructLog) UnmarshalJSON(input []byte) error {
Stack []*math.HexOrDecimal256 `json:"stack"` Stack []*math.HexOrDecimal256 `json:"stack"`
Storage map[common.Hash]common.Hash `json:"-"` Storage map[common.Hash]common.Hash `json:"-"`
Depth *int `json:"depth"` Depth *int `json:"depth"`
Err *error `json:"error"` Err error `json:"-"`
} }
var dec StructLog var dec StructLog
if err := json.Unmarshal(input, &dec); err != nil { if err := json.Unmarshal(input, &dec); err != nil {
@ -93,7 +97,7 @@ func (s *StructLog) UnmarshalJSON(input []byte) error {
s.Depth = *dec.Depth s.Depth = *dec.Depth
} }
if dec.Err != nil { if dec.Err != nil {
s.Err = *dec.Err s.Err = dec.Err
} }
return nil return nil
} }

View file

@ -62,7 +62,7 @@ type StructLog struct {
Stack []*big.Int `json:"stack"` Stack []*big.Int `json:"stack"`
Storage map[common.Hash]common.Hash `json:"-"` Storage map[common.Hash]common.Hash `json:"-"`
Depth int `json:"depth"` Depth int `json:"depth"`
Err error `json:"error"` Err error `json:"-"`
} }
// overrides for gencodec // overrides for gencodec
@ -71,13 +71,21 @@ type structLogMarshaling struct {
Gas math.HexOrDecimal64 Gas math.HexOrDecimal64
GasCost math.HexOrDecimal64 GasCost math.HexOrDecimal64
Memory hexutil.Bytes Memory hexutil.Bytes
OpName string `json:"opName"` OpName string `json:"opName"` // adds call to OpName() in MarshalJSON
ErrorString string `json:"error"` // adds call to ErrorString() in MarshalJSON
} }
func (s *StructLog) OpName() string { func (s *StructLog) OpName() string {
return s.Op.String() return s.Op.String()
} }
func (s *StructLog) ErrorString() string {
if s.Err != nil {
return s.Err.Error()
}
return ""
}
// Tracer is used to collect execution traces from an EVM transaction // Tracer is used to collect execution traces from an EVM transaction
// execution. CaptureState is called for each step of the VM with the // execution. CaptureState is called for each step of the VM with the
// current VM state. // current VM state.

View file

@ -13,6 +13,8 @@ import (
"github.com/ethereum/go-ethereum/eth/gasprice" "github.com/ethereum/go-ethereum/eth/gasprice"
) )
var _ = (*configMarshaling)(nil)
func (c Config) MarshalTOML() (interface{}, error) { func (c Config) MarshalTOML() (interface{}, error) {
type Config struct { type Config struct {
Genesis *core.Genesis `toml:",omitempty"` Genesis *core.Genesis `toml:",omitempty"`
@ -20,7 +22,6 @@ func (c Config) MarshalTOML() (interface{}, error) {
SyncMode downloader.SyncMode SyncMode downloader.SyncMode
LightServ int `toml:",omitempty"` LightServ int `toml:",omitempty"`
LightPeers int `toml:",omitempty"` LightPeers int `toml:",omitempty"`
MaxPeers int `toml:"-"`
SkipBcVersionCheck bool `toml:"-"` SkipBcVersionCheck bool `toml:"-"`
DatabaseHandles int `toml:"-"` DatabaseHandles int `toml:"-"`
DatabaseCache int DatabaseCache int
@ -28,17 +29,11 @@ func (c Config) MarshalTOML() (interface{}, error) {
MinerThreads int `toml:",omitempty"` MinerThreads int `toml:",omitempty"`
ExtraData hexutil.Bytes `toml:",omitempty"` ExtraData hexutil.Bytes `toml:",omitempty"`
GasPrice *big.Int GasPrice *big.Int
EthashCacheDir string Ethash ethash.Config
EthashCachesInMem int
EthashCachesOnDisk int
EthashDatasetDir string
EthashDatasetsInMem int
EthashDatasetsOnDisk int
TxPool core.TxPoolConfig TxPool core.TxPoolConfig
GPO gasprice.Config GPO gasprice.Config
EnablePreimageRecording bool EnablePreimageRecording bool
DocRoot string `toml:"-"` DocRoot string `toml:"-"`
PowMode ethash.Mode `toml:"-"`
} }
var enc Config var enc Config
enc.Genesis = c.Genesis enc.Genesis = c.Genesis
@ -53,17 +48,11 @@ func (c Config) MarshalTOML() (interface{}, error) {
enc.MinerThreads = c.MinerThreads enc.MinerThreads = c.MinerThreads
enc.ExtraData = c.ExtraData enc.ExtraData = c.ExtraData
enc.GasPrice = c.GasPrice enc.GasPrice = c.GasPrice
enc.EthashCacheDir = c.Ethash.CacheDir enc.Ethash = c.Ethash
enc.EthashCachesInMem = c.Ethash.CachesInMem
enc.EthashCachesOnDisk = c.Ethash.CachesOnDisk
enc.EthashDatasetDir = c.Ethash.DatasetDir
enc.EthashDatasetsInMem = c.Ethash.DatasetsInMem
enc.EthashDatasetsOnDisk = c.Ethash.DatasetsOnDisk
enc.TxPool = c.TxPool enc.TxPool = c.TxPool
enc.GPO = c.GPO enc.GPO = c.GPO
enc.EnablePreimageRecording = c.EnablePreimageRecording enc.EnablePreimageRecording = c.EnablePreimageRecording
enc.DocRoot = c.DocRoot enc.DocRoot = c.DocRoot
enc.PowMode = c.Ethash.PowMode
return &enc, nil return &enc, nil
} }
@ -74,7 +63,6 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error {
SyncMode *downloader.SyncMode SyncMode *downloader.SyncMode
LightServ *int `toml:",omitempty"` LightServ *int `toml:",omitempty"`
LightPeers *int `toml:",omitempty"` LightPeers *int `toml:",omitempty"`
MaxPeers *int `toml:"-"`
SkipBcVersionCheck *bool `toml:"-"` SkipBcVersionCheck *bool `toml:"-"`
DatabaseHandles *int `toml:"-"` DatabaseHandles *int `toml:"-"`
DatabaseCache *int DatabaseCache *int
@ -82,17 +70,11 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error {
MinerThreads *int `toml:",omitempty"` MinerThreads *int `toml:",omitempty"`
ExtraData hexutil.Bytes `toml:",omitempty"` ExtraData hexutil.Bytes `toml:",omitempty"`
GasPrice *big.Int GasPrice *big.Int
EthashCacheDir *string Ethash *ethash.Config
EthashCachesInMem *int
EthashCachesOnDisk *int
EthashDatasetDir *string
EthashDatasetsInMem *int
EthashDatasetsOnDisk *int
TxPool *core.TxPoolConfig TxPool *core.TxPoolConfig
GPO *gasprice.Config GPO *gasprice.Config
EnablePreimageRecording *bool EnablePreimageRecording *bool
DocRoot *string `toml:"-"` DocRoot *string `toml:"-"`
PowMode *ethash.Mode `toml:"-"`
} }
var dec Config var dec Config
if err := unmarshal(&dec); err != nil { if err := unmarshal(&dec); err != nil {
@ -134,23 +116,8 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error {
if dec.GasPrice != nil { if dec.GasPrice != nil {
c.GasPrice = dec.GasPrice c.GasPrice = dec.GasPrice
} }
if dec.EthashCacheDir != nil { if dec.Ethash != nil {
c.Ethash.CacheDir = *dec.EthashCacheDir c.Ethash = *dec.Ethash
}
if dec.EthashCachesInMem != nil {
c.Ethash.CachesInMem = *dec.EthashCachesInMem
}
if dec.EthashCachesOnDisk != nil {
c.Ethash.CachesOnDisk = *dec.EthashCachesOnDisk
}
if dec.EthashDatasetDir != nil {
c.Ethash.DatasetDir = *dec.EthashDatasetDir
}
if dec.EthashDatasetsInMem != nil {
c.Ethash.DatasetsInMem = *dec.EthashDatasetsInMem
}
if dec.EthashDatasetsOnDisk != nil {
c.Ethash.DatasetsOnDisk = *dec.EthashDatasetsOnDisk
} }
if dec.TxPool != nil { if dec.TxPool != nil {
c.TxPool = *dec.TxPool c.TxPool = *dec.TxPool
@ -164,8 +131,5 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error {
if dec.DocRoot != nil { if dec.DocRoot != nil {
c.DocRoot = *dec.DocRoot c.DocRoot = *dec.DocRoot
} }
if dec.PowMode != nil {
c.Ethash.PowMode = *dec.PowMode
}
return nil return nil
} }

View file

@ -86,8 +86,8 @@ type btHeaderMarshaling struct {
ExtraData hexutil.Bytes ExtraData hexutil.Bytes
Number *math.HexOrDecimal256 Number *math.HexOrDecimal256
Difficulty *math.HexOrDecimal256 Difficulty *math.HexOrDecimal256
GasLimit *math.HexOrDecimal64 GasLimit math.HexOrDecimal64
GasUsed *math.HexOrDecimal64 GasUsed math.HexOrDecimal64
Timestamp *math.HexOrDecimal256 Timestamp *math.HexOrDecimal256
} }

View file

@ -47,8 +47,8 @@ func (b btHeader) MarshalJSON() ([]byte, error) {
enc.UncleHash = b.UncleHash enc.UncleHash = b.UncleHash
enc.ExtraData = b.ExtraData enc.ExtraData = b.ExtraData
enc.Difficulty = (*math.HexOrDecimal256)(b.Difficulty) enc.Difficulty = (*math.HexOrDecimal256)(b.Difficulty)
enc.GasLimit = (math.HexOrDecimal64)(b.GasLimit) enc.GasLimit = math.HexOrDecimal64(b.GasLimit)
enc.GasUsed = (math.HexOrDecimal64)(b.GasUsed) enc.GasUsed = math.HexOrDecimal64(b.GasUsed)
enc.Timestamp = (*math.HexOrDecimal256)(b.Timestamp) enc.Timestamp = (*math.HexOrDecimal256)(b.Timestamp)
return json.Marshal(&enc) return json.Marshal(&enc)
} }

View file

@ -28,7 +28,7 @@ func (t ttTransaction) MarshalJSON() ([]byte, error) {
} }
var enc ttTransaction var enc ttTransaction
enc.Data = t.Data enc.Data = t.Data
enc.GasLimit = (math.HexOrDecimal64)(t.GasLimit) enc.GasLimit = math.HexOrDecimal64(t.GasLimit)
enc.GasPrice = (*math.HexOrDecimal256)(t.GasPrice) enc.GasPrice = (*math.HexOrDecimal256)(t.GasPrice)
enc.Nonce = math.HexOrDecimal64(t.Nonce) enc.Nonce = math.HexOrDecimal64(t.Nonce)
enc.Value = (*math.HexOrDecimal256)(t.Value) enc.Value = (*math.HexOrDecimal256)(t.Value)