diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index d3a339a953..4ea0b0098e 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -1494,6 +1494,9 @@ func setMiner(ctx *cli.Context, cfg *miner.Config) { if ctx.GlobalIsSet(MinerNoVerfiyFlag.Name) { cfg.Noverify = ctx.Bool(MinerNoVerfiyFlag.Name) } + if ctx.GlobalIsSet(AllowedFutureBlockTimeFlag.Name) { + cfg.AllowedFutureBlockTime = ctx.GlobalUint64(AllowedFutureBlockTimeFlag.Name) //Quorum + } } func setWhitelist(ctx *cli.Context, cfg *eth.Config) { @@ -1610,8 +1613,6 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) { setIstanbul(ctx, cfg) setRaft(ctx, cfg) - cfg.AllowedFutureBlockTime = ctx.GlobalUint64(AllowedFutureBlockTimeFlag.Name) //Quorum - if ctx.GlobalIsSet(SyncModeFlag.Name) { cfg.SyncMode = *GlobalTextMarshaler(ctx, SyncModeFlag.Name).(*downloader.SyncMode) } diff --git a/eth/backend.go b/eth/backend.go index 4ea7a8748c..0773985d0f 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -284,7 +284,7 @@ func makeExtraData(extra []byte, isQuorum bool) []byte { func CreateConsensusEngine(ctx *node.ServiceContext, chainConfig *params.ChainConfig, config *Config, notify []string, noverify bool, db ethdb.Database) consensus.Engine { // If proof-of-authority is requested, set it up if chainConfig.Clique != nil { - chainConfig.Clique.AllowedFutureBlockTime = config.AllowedFutureBlockTime //Quorum + chainConfig.Clique.AllowedFutureBlockTime = config.Miner.AllowedFutureBlockTime //Quorum return clique.New(chainConfig.Clique, db) } // If Istanbul is requested, set it up @@ -294,7 +294,7 @@ func CreateConsensusEngine(ctx *node.ServiceContext, chainConfig *params.ChainCo } config.Istanbul.ProposerPolicy = istanbul.ProposerPolicy(chainConfig.Istanbul.ProposerPolicy) config.Istanbul.Ceil2Nby3Block = chainConfig.Istanbul.Ceil2Nby3Block - config.Istanbul.AllowedFutureBlockTime = config.AllowedFutureBlockTime + config.Istanbul.AllowedFutureBlockTime = config.Miner.AllowedFutureBlockTime //Quorum return istanbulBackend.New(&config.Istanbul, ctx.NodeKey(), db) } diff --git a/eth/config.go b/eth/config.go index 14bc7a3bb0..74861925c1 100644 --- a/eth/config.go +++ b/eth/config.go @@ -146,8 +146,7 @@ type Config struct { Istanbul istanbul.Config // Miscellaneous options - DocRoot string `toml:"-"` - AllowedFutureBlockTime uint64 //Quorum + DocRoot string `toml:"-"` // Type of the EWASM interpreter ("" for default) EWASMInterpreter string diff --git a/eth/handler_test.go b/eth/handler_test.go index 21f2613945..d2b2ec9c8b 100644 --- a/eth/handler_test.go +++ b/eth/handler_test.go @@ -51,7 +51,7 @@ func TestNodeInfo(t *testing.T) { }{ {"ethash", nil, nil, false}, {"raft", nil, nil, true}, - {"istanbul", nil, ¶ms.IstanbulConfig{1, 1, big.NewInt(0), 0}, false}, + {"istanbul", nil, ¶ms.IstanbulConfig{1, 1, big.NewInt(0)}, false}, {"clique", ¶ms.CliqueConfig{1, 1, 0}, nil, false}, } diff --git a/miner/miner.go b/miner/miner.go index 824007c6ca..06977a93ba 100644 --- a/miner/miner.go +++ b/miner/miner.go @@ -45,14 +45,15 @@ type Backend interface { // Config is the configuration parameters of mining. type Config struct { - Etherbase common.Address `toml:",omitempty"` // Public address for block mining rewards (default = first account) - Notify []string `toml:",omitempty"` // HTTP URL list to be notified of new work packages(only useful in ethash). - ExtraData hexutil.Bytes `toml:",omitempty"` // Block extra data set by the miner - GasFloor uint64 // Target gas floor for mined blocks. - GasCeil uint64 // Target gas ceiling for mined blocks. - GasPrice *big.Int // Minimum gas price for mining a transaction - Recommit time.Duration // The time interval for miner to re-create mining work. - Noverify bool // Disable remote mining solution verification(only useful in ethash). + Etherbase common.Address `toml:",omitempty"` // Public address for block mining rewards (default = first account) + Notify []string `toml:",omitempty"` // HTTP URL list to be notified of new work packages(only useful in ethash). + ExtraData hexutil.Bytes `toml:",omitempty"` // Block extra data set by the miner + GasFloor uint64 // Target gas floor for mined blocks. + GasCeil uint64 // Target gas ceiling for mined blocks. + GasPrice *big.Int // Minimum gas price for mining a transaction + Recommit time.Duration // The time interval for miner to re-create mining work. + Noverify bool // Disable remote mining solution verification(only useful in ethash). + AllowedFutureBlockTime uint64 // Max time (in seconds) from current time allowed for blocks, before they're considered future blocks } // Miner creates blocks and searches for proof-of-work values. diff --git a/miner/worker.go b/miner/worker.go index 8a0792f7e5..8488b5e8ff 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -916,8 +916,11 @@ func (w *worker) commitNewWork(interrupt *int32, noempty bool, timestamp int64) if parent.Time() >= uint64(timestamp) { timestamp = int64(parent.Time() + 1) } + + allowedFutureBlockTime := int64(w.config.AllowedFutureBlockTime) //Quorum - get AllowedFutureBlockTime to fix issue # 1004 + // this will ensure we're not going off too far in the future - if now := time.Now().Unix(); timestamp > now+1 { + if now := time.Now().Unix(); timestamp > now+1+allowedFutureBlockTime { wait := time.Duration(timestamp-now) * time.Second log.Info("Mining too far in the future", "wait", common.PrettyDuration(wait)) time.Sleep(wait) diff --git a/params/config.go b/params/config.go index bcc8313ab5..d87a5bb41c 100644 --- a/params/config.go +++ b/params/config.go @@ -342,10 +342,9 @@ func (c *CliqueConfig) String() string { // IstanbulConfig is the consensus engine configs for Istanbul based sealing. type IstanbulConfig struct { - Epoch uint64 `json:"epoch"` // Epoch length to reset votes and checkpoint - ProposerPolicy uint64 `json:"policy"` // The policy for proposer selection - Ceil2Nby3Block *big.Int `json:"ceil2Nby3Block,omitempty"` // Number of confirmations required to move from one state to next [2F + 1 to Ceil(2N/3)] - AllowedFutureBlockTime uint64 `json:"allowedFutureBlockTime"` // Max time (in seconds) from current time allowed for blocks, before they're considered future blocks + Epoch uint64 `json:"epoch"` // Epoch length to reset votes and checkpoint + ProposerPolicy uint64 `json:"policy"` // The policy for proposer selection + Ceil2Nby3Block *big.Int `json:"ceil2Nby3Block,omitempty"` // Number of confirmations required to move from one state to next [2F + 1 to Ceil(2N/3)] } // String implements the stringer interface, returning the consensus engine details.