diff --git a/consensus/istanbul/config.go b/consensus/istanbul/config.go new file mode 100644 index 0000000000..e6cb762604 --- /dev/null +++ b/consensus/istanbul/config.go @@ -0,0 +1,40 @@ +// Copyright 2017 The go-ethereum Authors +// This file is part of the go-ethereum library. +// +// The go-ethereum library is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// The go-ethereum library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with the go-ethereum library. If not, see . + +package istanbul + +type ProposerPolicy uint64 + +const ( + RoundRobin ProposerPolicy = iota + Sticky +) + +type Config struct { + RequestTimeout uint64 `toml:",omitempty"` // The timeout for each Istanbul round in milliseconds. This timeout should be larger than BlockPauseTime. + BlockPeriod uint64 `toml:",omitempty"` // Default minimum difference between two consecutive block's timestamps in second + BlockPauseTime uint64 `toml:",omitempty"` // Pause time when zero tx in previous block, values should be larger than istanbul_block_period + ProposerPolicy ProposerPolicy `toml:",omitempty"` // The policy for proposer, the detail is not determined + Epoch uint64 `toml:",omitempty"` // The number of blocks after which to checkpoint and reset the pending votes +} + +var DefaultConfig = &Config{ + RequestTimeout: 10000, + BlockPeriod: 1, + BlockPauseTime: 2, + ProposerPolicy: RoundRobin, + Epoch: 30000, +} diff --git a/eth/config.go b/eth/config.go index dd7f42c7d9..6786b42bca 100644 --- a/eth/config.go +++ b/eth/config.go @@ -27,6 +27,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/consensus/ethash" + "github.com/ethereum/go-ethereum/consensus/istanbul" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/eth/downloader" "github.com/ethereum/go-ethereum/eth/gasprice" @@ -55,6 +56,8 @@ var DefaultConfig = Config{ Blocks: 20, Percentile: 60, }, + + Istanbul: *istanbul.DefaultConfig, } func init() { @@ -112,6 +115,9 @@ type Config struct { // Enables tracking of SHA3 preimages in the VM EnablePreimageRecording bool + // Istanbul options + Istanbul istanbul.Config + // Miscellaneous options DocRoot string `toml:"-"` } diff --git a/eth/gen_config.go b/eth/gen_config.go index 4f2e82d941..8c27a40ed3 100644 --- a/eth/gen_config.go +++ b/eth/gen_config.go @@ -8,6 +8,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/consensus/ethash" + "github.com/ethereum/go-ethereum/consensus/istanbul" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/eth/downloader" "github.com/ethereum/go-ethereum/eth/gasprice" @@ -34,6 +35,7 @@ func (c Config) MarshalTOML() (interface{}, error) { GPO gasprice.Config EnablePreimageRecording bool DocRoot string `toml:"-"` + Istanbul istanbul.Config } var enc Config enc.Genesis = c.Genesis @@ -52,6 +54,7 @@ func (c Config) MarshalTOML() (interface{}, error) { enc.TxPool = c.TxPool enc.GPO = c.GPO enc.EnablePreimageRecording = c.EnablePreimageRecording + enc.Istanbul = c.Istanbul enc.DocRoot = c.DocRoot return &enc, nil } @@ -75,6 +78,7 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error { GPO *gasprice.Config EnablePreimageRecording *bool DocRoot *string `toml:"-"` + Istanbul *istanbul.Config } var dec Config if err := unmarshal(&dec); err != nil { @@ -128,6 +132,9 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error { if dec.EnablePreimageRecording != nil { c.EnablePreimageRecording = *dec.EnablePreimageRecording } + if dec.Istanbul != nil { + c.Istanbul = *dec.Istanbul + } if dec.DocRoot != nil { c.DocRoot = *dec.DocRoot }