Skip to content

Issue 1004 - prevent "Mining too far in future" message when using allowedfutureblocktime parameter #1023

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
}
Expand Down
4 changes: 2 additions & 2 deletions eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
}
Expand Down
3 changes: 1 addition & 2 deletions eth/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion eth/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func TestNodeInfo(t *testing.T) {
}{
{"ethash", nil, nil, false},
{"raft", nil, nil, true},
{"istanbul", nil, &params.IstanbulConfig{1, 1, big.NewInt(0), 0}, false},
{"istanbul", nil, &params.IstanbulConfig{1, 1, big.NewInt(0)}, false},
{"clique", &params.CliqueConfig{1, 1, 0}, nil, false},
}

Expand Down
17 changes: 9 additions & 8 deletions miner/miner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 4 additions & 1 deletion miner/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 3 additions & 4 deletions params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down