params: fix golint warnings (#16853)

params: fix golint warnings
This commit is contained in:
kiel barry 2018-06-05 03:31:34 -07:00 committed by Felix Lange
parent 4cf2b4110e
commit cbfb40b0aa
22 changed files with 72 additions and 61 deletions

@ -474,7 +474,7 @@ func (f *faucet) apiHandler(conn *websocket.Conn) {
amount = new(big.Int).Div(amount, new(big.Int).Exp(big.NewInt(2), big.NewInt(int64(msg.Tier)), nil)) amount = new(big.Int).Div(amount, new(big.Int).Exp(big.NewInt(2), big.NewInt(int64(msg.Tier)), nil))
tx := types.NewTransaction(f.nonce+uint64(len(f.reqs)), address, amount, 21000, f.price, nil) tx := types.NewTransaction(f.nonce+uint64(len(f.reqs)), address, amount, 21000, f.price, nil)
signed, err := f.keystore.SignTx(f.account, tx, f.config.ChainId) signed, err := f.keystore.SignTx(f.account, tx, f.config.ChainID)
if err != nil { if err != nil {
f.lock.Unlock() f.lock.Unlock()
if err = sendError(conn, err); err != nil { if err = sendError(conn, err); err != nil {

@ -103,8 +103,8 @@ func newCppEthereumGenesisSpec(network string, genesis *core.Genesis) (*cppEther
spec.Params.ByzantiumForkBlock = (hexutil.Uint64)(genesis.Config.ByzantiumBlock.Uint64()) spec.Params.ByzantiumForkBlock = (hexutil.Uint64)(genesis.Config.ByzantiumBlock.Uint64())
spec.Params.ConstantinopleForkBlock = (hexutil.Uint64)(math.MaxUint64) spec.Params.ConstantinopleForkBlock = (hexutil.Uint64)(math.MaxUint64)
spec.Params.NetworkID = (hexutil.Uint64)(genesis.Config.ChainId.Uint64()) spec.Params.NetworkID = (hexutil.Uint64)(genesis.Config.ChainID.Uint64())
spec.Params.ChainID = (hexutil.Uint64)(genesis.Config.ChainId.Uint64()) spec.Params.ChainID = (hexutil.Uint64)(genesis.Config.ChainID.Uint64())
spec.Params.MaximumExtraDataSize = (hexutil.Uint64)(params.MaximumExtraDataSize) spec.Params.MaximumExtraDataSize = (hexutil.Uint64)(params.MaximumExtraDataSize)
spec.Params.MinGasLimit = (hexutil.Uint64)(params.MinGasLimit) spec.Params.MinGasLimit = (hexutil.Uint64)(params.MinGasLimit)
@ -284,7 +284,7 @@ func newParityChainSpec(network string, genesis *core.Genesis, bootnodes []strin
spec.Params.MaximumExtraDataSize = (hexutil.Uint64)(params.MaximumExtraDataSize) spec.Params.MaximumExtraDataSize = (hexutil.Uint64)(params.MaximumExtraDataSize)
spec.Params.MinGasLimit = (hexutil.Uint64)(params.MinGasLimit) spec.Params.MinGasLimit = (hexutil.Uint64)(params.MinGasLimit)
spec.Params.GasLimitBoundDivisor = (hexutil.Uint64)(params.GasLimitBoundDivisor) spec.Params.GasLimitBoundDivisor = (hexutil.Uint64)(params.GasLimitBoundDivisor)
spec.Params.NetworkID = (hexutil.Uint64)(genesis.Config.ChainId.Uint64()) spec.Params.NetworkID = (hexutil.Uint64)(genesis.Config.ChainID.Uint64())
spec.Params.MaxCodeSize = params.MaxCodeSize spec.Params.MaxCodeSize = params.MaxCodeSize
spec.Params.EIP155Transition = genesis.Config.EIP155Block.Uint64() spec.Params.EIP155Transition = genesis.Config.EIP155Block.Uint64()
spec.Params.EIP98Transition = math.MaxUint64 spec.Params.EIP98Transition = math.MaxUint64

@ -609,7 +609,7 @@ func deployDashboard(client *sshClient, network string, conf *config, config *da
} }
template.Must(template.New("").Parse(dashboardContent)).Execute(indexfile, map[string]interface{}{ template.Must(template.New("").Parse(dashboardContent)).Execute(indexfile, map[string]interface{}{
"Network": network, "Network": network,
"NetworkID": conf.Genesis.Config.ChainId, "NetworkID": conf.Genesis.Config.ChainID,
"NetworkTitle": strings.Title(network), "NetworkTitle": strings.Title(network),
"EthstatsPage": config.ethstats, "EthstatsPage": config.ethstats,
"ExplorerPage": config.explorer, "ExplorerPage": config.explorer,

@ -49,7 +49,7 @@ func (w *wizard) deployFaucet() {
existed := err == nil existed := err == nil
infos.node.genesis, _ = json.MarshalIndent(w.conf.Genesis, "", " ") infos.node.genesis, _ = json.MarshalIndent(w.conf.Genesis, "", " ")
infos.node.network = w.conf.Genesis.Config.ChainId.Int64() infos.node.network = w.conf.Genesis.Config.ChainID.Int64()
// Figure out which port to listen on // Figure out which port to listen on
fmt.Println() fmt.Println()

@ -121,7 +121,7 @@ func (w *wizard) makeGenesis() {
// Query the user for some custom extras // Query the user for some custom extras
fmt.Println() fmt.Println()
fmt.Println("Specify your chain/network ID if you want an explicit one (default = random)") fmt.Println("Specify your chain/network ID if you want an explicit one (default = random)")
genesis.Config.ChainId = new(big.Int).SetUint64(uint64(w.readDefaultInt(rand.Intn(65536)))) genesis.Config.ChainID = new(big.Int).SetUint64(uint64(w.readDefaultInt(rand.Intn(65536))))
// All done, store the genesis and flush to disk // All done, store the genesis and flush to disk
log.Info("Configured new genesis block") log.Info("Configured new genesis block")

@ -56,7 +56,7 @@ func (w *wizard) deployNode(boot bool) {
existed := err == nil existed := err == nil
infos.genesis, _ = json.MarshalIndent(w.conf.Genesis, "", " ") infos.genesis, _ = json.MarshalIndent(w.conf.Genesis, "", " ")
infos.network = w.conf.Genesis.Config.ChainId.Int64() infos.network = w.conf.Genesis.Config.ChainID.Int64()
// Figure out where the user wants to store the persistent data // Figure out where the user wants to store the persistent data
fmt.Println() fmt.Println()

@ -52,7 +52,7 @@ func (w *wizard) deployWallet() {
existed := err == nil existed := err == nil
infos.genesis, _ = json.MarshalIndent(w.conf.Genesis, "", " ") infos.genesis, _ = json.MarshalIndent(w.conf.Genesis, "", " ")
infos.network = w.conf.Genesis.Config.ChainId.Int64() infos.network = w.conf.Genesis.Config.ChainID.Int64()
// Figure out which port to listen on // Figure out which port to listen on
fmt.Println() fmt.Println()

@ -578,7 +578,7 @@ func TestFastVsFullChains(t *testing.T) {
Alloc: GenesisAlloc{address: {Balance: funds}}, Alloc: GenesisAlloc{address: {Balance: funds}},
} }
genesis = gspec.MustCommit(gendb) genesis = gspec.MustCommit(gendb)
signer = types.NewEIP155Signer(gspec.Config.ChainId) signer = types.NewEIP155Signer(gspec.Config.ChainID)
) )
blocks, receipts := GenerateChain(gspec.Config, genesis, ethash.NewFaker(), gendb, 1024, func(i int, block *BlockGen) { blocks, receipts := GenerateChain(gspec.Config, genesis, ethash.NewFaker(), gendb, 1024, func(i int, block *BlockGen) {
block.SetCoinbase(common.Address{0x00}) block.SetCoinbase(common.Address{0x00})
@ -753,7 +753,7 @@ func TestChainTxReorgs(t *testing.T) {
}, },
} }
genesis = gspec.MustCommit(db) genesis = gspec.MustCommit(db)
signer = types.NewEIP155Signer(gspec.Config.ChainId) signer = types.NewEIP155Signer(gspec.Config.ChainID)
) )
// Create two transactions shared between the chains: // Create two transactions shared between the chains:
@ -859,7 +859,7 @@ func TestLogReorgs(t *testing.T) {
code = common.Hex2Bytes("60606040525b7f24ec1d3ff24c2f6ff210738839dbc339cd45a5294d85c79361016243157aae7b60405180905060405180910390a15b600a8060416000396000f360606040526008565b00") code = common.Hex2Bytes("60606040525b7f24ec1d3ff24c2f6ff210738839dbc339cd45a5294d85c79361016243157aae7b60405180905060405180910390a15b600a8060416000396000f360606040526008565b00")
gspec = &Genesis{Config: params.TestChainConfig, Alloc: GenesisAlloc{addr1: {Balance: big.NewInt(10000000000000)}}} gspec = &Genesis{Config: params.TestChainConfig, Alloc: GenesisAlloc{addr1: {Balance: big.NewInt(10000000000000)}}}
genesis = gspec.MustCommit(db) genesis = gspec.MustCommit(db)
signer = types.NewEIP155Signer(gspec.Config.ChainId) signer = types.NewEIP155Signer(gspec.Config.ChainID)
) )
blockchain, _ := NewBlockChain(db, nil, gspec.Config, ethash.NewFaker(), vm.Config{}) blockchain, _ := NewBlockChain(db, nil, gspec.Config, ethash.NewFaker(), vm.Config{})
@ -906,7 +906,7 @@ func TestReorgSideEvent(t *testing.T) {
Alloc: GenesisAlloc{addr1: {Balance: big.NewInt(10000000000000)}}, Alloc: GenesisAlloc{addr1: {Balance: big.NewInt(10000000000000)}},
} }
genesis = gspec.MustCommit(db) genesis = gspec.MustCommit(db)
signer = types.NewEIP155Signer(gspec.Config.ChainId) signer = types.NewEIP155Signer(gspec.Config.ChainID)
) )
blockchain, _ := NewBlockChain(db, nil, gspec.Config, ethash.NewFaker(), vm.Config{}) blockchain, _ := NewBlockChain(db, nil, gspec.Config, ethash.NewFaker(), vm.Config{})
@ -1032,7 +1032,7 @@ func TestEIP155Transition(t *testing.T) {
funds = big.NewInt(1000000000) funds = big.NewInt(1000000000)
deleteAddr = common.Address{1} deleteAddr = common.Address{1}
gspec = &Genesis{ gspec = &Genesis{
Config: &params.ChainConfig{ChainId: big.NewInt(1), EIP155Block: big.NewInt(2), HomesteadBlock: new(big.Int)}, Config: &params.ChainConfig{ChainID: big.NewInt(1), EIP155Block: big.NewInt(2), HomesteadBlock: new(big.Int)},
Alloc: GenesisAlloc{address: {Balance: funds}, deleteAddr: {Balance: new(big.Int)}}, Alloc: GenesisAlloc{address: {Balance: funds}, deleteAddr: {Balance: new(big.Int)}},
} }
genesis = gspec.MustCommit(db) genesis = gspec.MustCommit(db)
@ -1063,7 +1063,7 @@ func TestEIP155Transition(t *testing.T) {
} }
block.AddTx(tx) block.AddTx(tx)
tx, err = basicTx(types.NewEIP155Signer(gspec.Config.ChainId)) tx, err = basicTx(types.NewEIP155Signer(gspec.Config.ChainID))
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -1075,7 +1075,7 @@ func TestEIP155Transition(t *testing.T) {
} }
block.AddTx(tx) block.AddTx(tx)
tx, err = basicTx(types.NewEIP155Signer(gspec.Config.ChainId)) tx, err = basicTx(types.NewEIP155Signer(gspec.Config.ChainID))
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -1103,7 +1103,7 @@ func TestEIP155Transition(t *testing.T) {
} }
// generate an invalid chain id transaction // generate an invalid chain id transaction
config := &params.ChainConfig{ChainId: big.NewInt(2), EIP155Block: big.NewInt(2), HomesteadBlock: new(big.Int)} config := &params.ChainConfig{ChainID: big.NewInt(2), EIP155Block: big.NewInt(2), HomesteadBlock: new(big.Int)}
blocks, _ = GenerateChain(config, blocks[len(blocks)-1], ethash.NewFaker(), db, 4, func(i int, block *BlockGen) { blocks, _ = GenerateChain(config, blocks[len(blocks)-1], ethash.NewFaker(), db, 4, func(i int, block *BlockGen) {
var ( var (
tx *types.Transaction tx *types.Transaction
@ -1137,7 +1137,7 @@ func TestEIP161AccountRemoval(t *testing.T) {
theAddr = common.Address{1} theAddr = common.Address{1}
gspec = &Genesis{ gspec = &Genesis{
Config: &params.ChainConfig{ Config: &params.ChainConfig{
ChainId: big.NewInt(1), ChainID: big.NewInt(1),
HomesteadBlock: new(big.Int), HomesteadBlock: new(big.Int),
EIP155Block: new(big.Int), EIP155Block: new(big.Int),
EIP158Block: big.NewInt(2), EIP158Block: big.NewInt(2),
@ -1153,7 +1153,7 @@ func TestEIP161AccountRemoval(t *testing.T) {
var ( var (
tx *types.Transaction tx *types.Transaction
err error err error
signer = types.NewEIP155Signer(gspec.Config.ChainId) signer = types.NewEIP155Signer(gspec.Config.ChainID)
) )
switch i { switch i {
case 0: case 0:

@ -222,7 +222,7 @@ func NewTxPool(config TxPoolConfig, chainconfig *params.ChainConfig, chain block
config: config, config: config,
chainconfig: chainconfig, chainconfig: chainconfig,
chain: chain, chain: chain,
signer: types.NewEIP155Signer(chainconfig.ChainId), signer: types.NewEIP155Signer(chainconfig.ChainID),
pending: make(map[common.Address]*txList), pending: make(map[common.Address]*txList),
queue: make(map[common.Address]*txList), queue: make(map[common.Address]*txList),
beats: make(map[common.Address]time.Time), beats: make(map[common.Address]time.Time),

@ -43,7 +43,7 @@ func MakeSigner(config *params.ChainConfig, blockNumber *big.Int) Signer {
var signer Signer var signer Signer
switch { switch {
case config.IsEIP155(blockNumber): case config.IsEIP155(blockNumber):
signer = NewEIP155Signer(config.ChainId) signer = NewEIP155Signer(config.ChainID)
case config.IsHomestead(blockNumber): case config.IsHomestead(blockNumber):
signer = HomesteadSigner{} signer = HomesteadSigner{}
default: default:

@ -52,7 +52,7 @@ type Config struct {
func setDefaults(cfg *Config) { func setDefaults(cfg *Config) {
if cfg.ChainConfig == nil { if cfg.ChainConfig == nil {
cfg.ChainConfig = &params.ChainConfig{ cfg.ChainConfig = &params.ChainConfig{
ChainId: big.NewInt(1), ChainID: big.NewInt(1),
HomesteadBlock: new(big.Int), HomesteadBlock: new(big.Int),
DAOForkBlock: new(big.Int), DAOForkBlock: new(big.Int),
DAOForkSupport: false, DAOForkSupport: false,

@ -354,7 +354,7 @@ func (s *PrivateAccountAPI) signTransaction(ctx context.Context, args SendTxArgs
var chainID *big.Int var chainID *big.Int
if config := s.b.ChainConfig(); config.IsEIP155(s.b.CurrentBlock().Number()) { if config := s.b.ChainConfig(); config.IsEIP155(s.b.CurrentBlock().Number()) {
chainID = config.ChainId chainID = config.ChainID
} }
return wallet.SignTxWithPassphrase(account, passwd, tx, chainID) return wallet.SignTxWithPassphrase(account, passwd, tx, chainID)
} }
@ -1096,7 +1096,7 @@ func (s *PublicTransactionPoolAPI) sign(addr common.Address, tx *types.Transacti
// Request the wallet to sign the transaction // Request the wallet to sign the transaction
var chainID *big.Int var chainID *big.Int
if config := s.b.ChainConfig(); config.IsEIP155(s.b.CurrentBlock().Number()) { if config := s.b.ChainConfig(); config.IsEIP155(s.b.CurrentBlock().Number()) {
chainID = config.ChainId chainID = config.ChainID
} }
return wallet.SignTx(account, tx, chainID) return wallet.SignTx(account, tx, chainID)
} }
@ -1216,7 +1216,7 @@ func (s *PublicTransactionPoolAPI) SendTransaction(ctx context.Context, args Sen
var chainID *big.Int var chainID *big.Int
if config := s.b.ChainConfig(); config.IsEIP155(s.b.CurrentBlock().Number()) { if config := s.b.ChainConfig(); config.IsEIP155(s.b.CurrentBlock().Number()) {
chainID = config.ChainId chainID = config.ChainID
} }
signed, err := wallet.SignTx(account, tx, chainID) signed, err := wallet.SignTx(account, tx, chainID)
if err != nil { if err != nil {

@ -89,7 +89,7 @@ type TxRelayBackend interface {
func NewTxPool(config *params.ChainConfig, chain *LightChain, relay TxRelayBackend) *TxPool { func NewTxPool(config *params.ChainConfig, chain *LightChain, relay TxRelayBackend) *TxPool {
pool := &TxPool{ pool := &TxPool{
config: config, config: config,
signer: types.NewEIP155Signer(config.ChainId), signer: types.NewEIP155Signer(config.ChainID),
nonce: make(map[common.Address]uint64), nonce: make(map[common.Address]uint64),
pending: make(map[common.Hash]*types.Transaction), pending: make(map[common.Hash]*types.Transaction),
mined: make(map[common.Hash][]*types.Transaction), mined: make(map[common.Hash][]*types.Transaction),

@ -360,7 +360,7 @@ func (self *worker) makeCurrent(parent *types.Block, header *types.Header) error
} }
work := &Work{ work := &Work{
config: self.config, config: self.config,
signer: types.NewEIP155Signer(self.config.ChainId), signer: types.NewEIP155Signer(self.config.ChainID),
state: state, state: state,
ancestors: set.New(), ancestors: set.New(),
family: set.New(), family: set.New(),

@ -23,15 +23,16 @@ import (
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
) )
// Genesis hashes to enforce below configs on.
var ( var (
MainnetGenesisHash = common.HexToHash("0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3") // Mainnet genesis hash to enforce below configs on MainnetGenesisHash = common.HexToHash("0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3")
TestnetGenesisHash = common.HexToHash("0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d") // Testnet genesis hash to enforce below configs on TestnetGenesisHash = common.HexToHash("0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d")
) )
var ( var (
// MainnetChainConfig is the chain parameters to run a node on the main network. // MainnetChainConfig is the chain parameters to run a node on the main network.
MainnetChainConfig = &ChainConfig{ MainnetChainConfig = &ChainConfig{
ChainId: big.NewInt(1), ChainID: big.NewInt(1),
HomesteadBlock: big.NewInt(1150000), HomesteadBlock: big.NewInt(1150000),
DAOForkBlock: big.NewInt(1920000), DAOForkBlock: big.NewInt(1920000),
DAOForkSupport: true, DAOForkSupport: true,
@ -46,7 +47,7 @@ var (
// TestnetChainConfig contains the chain parameters to run a node on the Ropsten test network. // TestnetChainConfig contains the chain parameters to run a node on the Ropsten test network.
TestnetChainConfig = &ChainConfig{ TestnetChainConfig = &ChainConfig{
ChainId: big.NewInt(3), ChainID: big.NewInt(3),
HomesteadBlock: big.NewInt(0), HomesteadBlock: big.NewInt(0),
DAOForkBlock: nil, DAOForkBlock: nil,
DAOForkSupport: true, DAOForkSupport: true,
@ -61,7 +62,7 @@ var (
// RinkebyChainConfig contains the chain parameters to run a node on the Rinkeby test network. // RinkebyChainConfig contains the chain parameters to run a node on the Rinkeby test network.
RinkebyChainConfig = &ChainConfig{ RinkebyChainConfig = &ChainConfig{
ChainId: big.NewInt(4), ChainID: big.NewInt(4),
HomesteadBlock: big.NewInt(1), HomesteadBlock: big.NewInt(1),
DAOForkBlock: nil, DAOForkBlock: nil,
DAOForkSupport: true, DAOForkSupport: true,
@ -101,7 +102,7 @@ var (
// that any network, identified by its genesis block, can have its own // that any network, identified by its genesis block, can have its own
// set of configuration options. // set of configuration options.
type ChainConfig struct { type ChainConfig struct {
ChainId *big.Int `json:"chainId"` // Chain id identifies the current chain and is used for replay protection ChainID *big.Int `json:"chainId"` // chainId identifies the current chain and is used for replay protection
HomesteadBlock *big.Int `json:"homesteadBlock,omitempty"` // Homestead switch block (nil = no fork, 0 = already homestead) HomesteadBlock *big.Int `json:"homesteadBlock,omitempty"` // Homestead switch block (nil = no fork, 0 = already homestead)
@ -154,7 +155,7 @@ func (c *ChainConfig) String() string {
engine = "unknown" engine = "unknown"
} }
return fmt.Sprintf("{ChainID: %v Homestead: %v DAO: %v DAOSupport: %v EIP150: %v EIP155: %v EIP158: %v Byzantium: %v Constantinople: %v Engine: %v}", return fmt.Sprintf("{ChainID: %v Homestead: %v DAO: %v DAOSupport: %v EIP150: %v EIP155: %v EIP158: %v Byzantium: %v Constantinople: %v Engine: %v}",
c.ChainId, c.ChainID,
c.HomesteadBlock, c.HomesteadBlock,
c.DAOForkBlock, c.DAOForkBlock,
c.DAOForkSupport, c.DAOForkSupport,
@ -172,27 +173,32 @@ func (c *ChainConfig) IsHomestead(num *big.Int) bool {
return isForked(c.HomesteadBlock, num) return isForked(c.HomesteadBlock, num)
} }
// IsDAO returns whether num is either equal to the DAO fork block or greater. // IsDAOFork returns whether num is either equal to the DAO fork block or greater.
func (c *ChainConfig) IsDAOFork(num *big.Int) bool { func (c *ChainConfig) IsDAOFork(num *big.Int) bool {
return isForked(c.DAOForkBlock, num) return isForked(c.DAOForkBlock, num)
} }
// IsEIP150 returns whether num is either equal to the EIP150 fork block or greater.
func (c *ChainConfig) IsEIP150(num *big.Int) bool { func (c *ChainConfig) IsEIP150(num *big.Int) bool {
return isForked(c.EIP150Block, num) return isForked(c.EIP150Block, num)
} }
// IsEIP155 returns whether num is either equal to the EIP155 fork block or greater.
func (c *ChainConfig) IsEIP155(num *big.Int) bool { func (c *ChainConfig) IsEIP155(num *big.Int) bool {
return isForked(c.EIP155Block, num) return isForked(c.EIP155Block, num)
} }
// IsEIP158 returns whether num is either equal to the EIP158 fork block or greater.
func (c *ChainConfig) IsEIP158(num *big.Int) bool { func (c *ChainConfig) IsEIP158(num *big.Int) bool {
return isForked(c.EIP158Block, num) return isForked(c.EIP158Block, num)
} }
// IsByzantium returns whether num is either equal to the Byzantium fork block or greater.
func (c *ChainConfig) IsByzantium(num *big.Int) bool { func (c *ChainConfig) IsByzantium(num *big.Int) bool {
return isForked(c.ByzantiumBlock, num) return isForked(c.ByzantiumBlock, num)
} }
// IsConstantinople returns whether num is either equal to the Constantinople fork block or greater.
func (c *ChainConfig) IsConstantinople(num *big.Int) bool { func (c *ChainConfig) IsConstantinople(num *big.Int) bool {
return isForked(c.ConstantinopleBlock, num) return isForked(c.ConstantinopleBlock, num)
} }
@ -251,7 +257,7 @@ func (c *ChainConfig) checkCompatible(newcfg *ChainConfig, head *big.Int) *Confi
if isForkIncompatible(c.EIP158Block, newcfg.EIP158Block, head) { if isForkIncompatible(c.EIP158Block, newcfg.EIP158Block, head) {
return newCompatError("EIP158 fork block", c.EIP158Block, newcfg.EIP158Block) return newCompatError("EIP158 fork block", c.EIP158Block, newcfg.EIP158Block)
} }
if c.IsEIP158(head) && !configNumEqual(c.ChainId, newcfg.ChainId) { if c.IsEIP158(head) && !configNumEqual(c.ChainID, newcfg.ChainID) {
return newCompatError("EIP158 chain ID", c.EIP158Block, newcfg.EIP158Block) return newCompatError("EIP158 chain ID", c.EIP158Block, newcfg.EIP158Block)
} }
if isForkIncompatible(c.ByzantiumBlock, newcfg.ByzantiumBlock, head) { if isForkIncompatible(c.ByzantiumBlock, newcfg.ByzantiumBlock, head) {
@ -324,15 +330,16 @@ func (err *ConfigCompatError) Error() string {
// Rules is a one time interface meaning that it shouldn't be used in between transition // Rules is a one time interface meaning that it shouldn't be used in between transition
// phases. // phases.
type Rules struct { type Rules struct {
ChainId *big.Int ChainID *big.Int
IsHomestead, IsEIP150, IsEIP155, IsEIP158 bool IsHomestead, IsEIP150, IsEIP155, IsEIP158 bool
IsByzantium bool IsByzantium bool
} }
// Rules ensures c's ChainID is not nil.
func (c *ChainConfig) Rules(num *big.Int) Rules { func (c *ChainConfig) Rules(num *big.Int) Rules {
chainId := c.ChainId chainID := c.ChainID
if chainId == nil { if chainID == nil {
chainId = new(big.Int) chainID = new(big.Int)
} }
return Rules{ChainId: new(big.Int).Set(chainId), IsHomestead: c.IsHomestead(num), IsEIP150: c.IsEIP150(num), IsEIP155: c.IsEIP155(num), IsEIP158: c.IsEIP158(num), IsByzantium: c.IsByzantium(num)} return Rules{ChainID: new(big.Int).Set(chainID), IsHomestead: c.IsHomestead(num), IsEIP150: c.IsEIP150(num), IsEIP155: c.IsEIP155(num), IsEIP158: c.IsEIP158(num), IsByzantium: c.IsByzantium(num)}
} }

@ -16,12 +16,12 @@
package params package params
// These are the multipliers for ether denominations.
// Example: To get the wei value of an amount in 'douglas', use
//
// new(big.Int).Mul(value, big.NewInt(params.Douglas))
//
const ( const (
// These are the multipliers for ether denominations.
// Example: To get the wei value of an amount in 'douglas', use
//
// new(big.Int).Mul(value, big.NewInt(params.Douglas))
//
Wei = 1 Wei = 1
Ada = 1e3 Ada = 1e3
Babbage = 1e6 Babbage = 1e6

@ -16,6 +16,7 @@
package params package params
// GasTable organizes gas prices for different ethereum phases.
type GasTable struct { type GasTable struct {
ExtcodeSize uint64 ExtcodeSize uint64
ExtcodeCopy uint64 ExtcodeCopy uint64
@ -34,6 +35,7 @@ type GasTable struct {
CreateBySuicide uint64 CreateBySuicide uint64
} }
// Variables containing gas prices for different ethereum phases.
var ( var (
// GasTableHomestead contain the gas prices for // GasTableHomestead contain the gas prices for
// the homestead phase. // the homestead phase.
@ -47,8 +49,8 @@ var (
ExpByte: 10, ExpByte: 10,
} }
// GasTableHomestead contain the gas re-prices for // GasTableEIP150 contain the gas re-prices for
// the homestead phase. // the EIP150 phase.
GasTableEIP150 = GasTable{ GasTableEIP150 = GasTable{
ExtcodeSize: 700, ExtcodeSize: 700,
ExtcodeCopy: 700, ExtcodeCopy: 700,
@ -60,7 +62,8 @@ var (
CreateBySuicide: 25000, CreateBySuicide: 25000,
} }
// GasTableEIP158 contain the gas re-prices for
// the EIP15* phase.
GasTableEIP158 = GasTable{ GasTableEIP158 = GasTable{
ExtcodeSize: 700, ExtcodeSize: 700,
ExtcodeCopy: 700, ExtcodeCopy: 700,

@ -19,7 +19,7 @@ package params
import "math/big" import "math/big"
var ( var (
TargetGasLimit uint64 = GenesisGasLimit // The artificial target TargetGasLimit = GenesisGasLimit // The artificial target
) )
const ( const (

@ -42,6 +42,7 @@ type BlockTest struct {
json btJSON json btJSON
} }
// UnmarshalJSON implements json.Unmarshaler interface.
func (t *BlockTest) UnmarshalJSON(in []byte) error { func (t *BlockTest) UnmarshalJSON(in []byte) error {
return json.Unmarshal(in, &t.json) return json.Unmarshal(in, &t.json)
} }

@ -27,7 +27,7 @@ import (
var ( var (
mainnetChainConfig = params.ChainConfig{ mainnetChainConfig = params.ChainConfig{
ChainId: big.NewInt(1), ChainID: big.NewInt(1),
HomesteadBlock: big.NewInt(1150000), HomesteadBlock: big.NewInt(1150000),
DAOForkBlock: big.NewInt(1920000), DAOForkBlock: big.NewInt(1920000),
DAOForkSupport: true, DAOForkSupport: true,

@ -26,26 +26,26 @@ import (
// Forks table defines supported forks and their chain config. // Forks table defines supported forks and their chain config.
var Forks = map[string]*params.ChainConfig{ var Forks = map[string]*params.ChainConfig{
"Frontier": { "Frontier": {
ChainId: big.NewInt(1), ChainID: big.NewInt(1),
}, },
"Homestead": { "Homestead": {
ChainId: big.NewInt(1), ChainID: big.NewInt(1),
HomesteadBlock: big.NewInt(0), HomesteadBlock: big.NewInt(0),
}, },
"EIP150": { "EIP150": {
ChainId: big.NewInt(1), ChainID: big.NewInt(1),
HomesteadBlock: big.NewInt(0), HomesteadBlock: big.NewInt(0),
EIP150Block: big.NewInt(0), EIP150Block: big.NewInt(0),
}, },
"EIP158": { "EIP158": {
ChainId: big.NewInt(1), ChainID: big.NewInt(1),
HomesteadBlock: big.NewInt(0), HomesteadBlock: big.NewInt(0),
EIP150Block: big.NewInt(0), EIP150Block: big.NewInt(0),
EIP155Block: big.NewInt(0), EIP155Block: big.NewInt(0),
EIP158Block: big.NewInt(0), EIP158Block: big.NewInt(0),
}, },
"Byzantium": { "Byzantium": {
ChainId: big.NewInt(1), ChainID: big.NewInt(1),
HomesteadBlock: big.NewInt(0), HomesteadBlock: big.NewInt(0),
EIP150Block: big.NewInt(0), EIP150Block: big.NewInt(0),
EIP155Block: big.NewInt(0), EIP155Block: big.NewInt(0),
@ -54,22 +54,22 @@ var Forks = map[string]*params.ChainConfig{
ByzantiumBlock: big.NewInt(0), ByzantiumBlock: big.NewInt(0),
}, },
"FrontierToHomesteadAt5": { "FrontierToHomesteadAt5": {
ChainId: big.NewInt(1), ChainID: big.NewInt(1),
HomesteadBlock: big.NewInt(5), HomesteadBlock: big.NewInt(5),
}, },
"HomesteadToEIP150At5": { "HomesteadToEIP150At5": {
ChainId: big.NewInt(1), ChainID: big.NewInt(1),
HomesteadBlock: big.NewInt(0), HomesteadBlock: big.NewInt(0),
EIP150Block: big.NewInt(5), EIP150Block: big.NewInt(5),
}, },
"HomesteadToDaoAt5": { "HomesteadToDaoAt5": {
ChainId: big.NewInt(1), ChainID: big.NewInt(1),
HomesteadBlock: big.NewInt(0), HomesteadBlock: big.NewInt(0),
DAOForkBlock: big.NewInt(5), DAOForkBlock: big.NewInt(5),
DAOForkSupport: true, DAOForkSupport: true,
}, },
"EIP158ToByzantiumAt5": { "EIP158ToByzantiumAt5": {
ChainId: big.NewInt(1), ChainID: big.NewInt(1),
HomesteadBlock: big.NewInt(0), HomesteadBlock: big.NewInt(0),
EIP150Block: big.NewInt(0), EIP150Block: big.NewInt(0),
EIP155Block: big.NewInt(0), EIP155Block: big.NewInt(0),

@ -35,7 +35,7 @@ func TestTransaction(t *testing.T) {
EIP150Block: big.NewInt(0), EIP150Block: big.NewInt(0),
EIP155Block: big.NewInt(0), EIP155Block: big.NewInt(0),
EIP158Block: big.NewInt(0), EIP158Block: big.NewInt(0),
ChainId: big.NewInt(1), ChainID: big.NewInt(1),
}) })
txt.config(`^Byzantium/`, params.ChainConfig{ txt.config(`^Byzantium/`, params.ChainConfig{
HomesteadBlock: big.NewInt(0), HomesteadBlock: big.NewInt(0),