From 86e3a02490b9a3aae9bf8c414e0af10cf28e880c Mon Sep 17 00:00:00 2001 From: Nathan Date: Wed, 15 May 2024 15:27:05 +0800 Subject: [PATCH] cmd/utils: add a flag to change breathe block interval for testing (#2462) --- cmd/geth/config.go | 3 +++ cmd/geth/main.go | 1 + cmd/utils/flags.go | 6 ++++++ consensus/parlia/feynmanfork.go | 5 ++--- params/protocol_params.go | 1 + 5 files changed, 13 insertions(+), 3 deletions(-) diff --git a/cmd/geth/config.go b/cmd/geth/config.go index a3b69113f4..ca7e7810a7 100644 --- a/cmd/geth/config.go +++ b/cmd/geth/config.go @@ -203,6 +203,9 @@ func makeFullNode(ctx *cli.Context) (*node.Node, ethapi.Backend) { if ctx.IsSet(utils.OverrideDefaultExtraReserveForBlobRequests.Name) { params.DefaultExtraReserveForBlobRequests = ctx.Uint64(utils.OverrideDefaultExtraReserveForBlobRequests.Name) } + if ctx.IsSet(utils.OverrideBreatheBlockInterval.Name) { + params.BreatheBlockInterval = ctx.Uint64(utils.OverrideBreatheBlockInterval.Name) + } backend, eth := utils.RegisterEthService(stack, &cfg.Eth) diff --git a/cmd/geth/main.go b/cmd/geth/main.go index f2c7a9ab46..d4be86c012 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -77,6 +77,7 @@ var ( utils.OverrideFullImmutabilityThreshold, utils.OverrideMinBlocksForBlobRequests, utils.OverrideDefaultExtraReserveForBlobRequests, + utils.OverrideBreatheBlockInterval, utils.EnablePersonal, utils.TxPoolLocalsFlag, utils.TxPoolNoLocalsFlag, diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index c7a01e5e28..c2653dd66e 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -333,6 +333,12 @@ var ( Value: params.DefaultExtraReserveForBlobRequests, Category: flags.EthCategory, } + OverrideBreatheBlockInterval = &cli.Uint64Flag{ + Name: "override.breatheblockinterval", + Usage: "It changes the interval between breathe blocks, only for testing purpose", + Value: params.BreatheBlockInterval, + Category: flags.EthCategory, + } SyncModeFlag = &flags.TextMarshalerFlag{ Name: "syncmode", Usage: `Blockchain sync mode ("snap" or "full")`, diff --git a/consensus/parlia/feynmanfork.go b/consensus/parlia/feynmanfork.go index 32f9951d85..88d2ae17cc 100644 --- a/consensus/parlia/feynmanfork.go +++ b/consensus/parlia/feynmanfork.go @@ -15,14 +15,13 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/internal/ethapi" "github.com/ethereum/go-ethereum/log" + "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/rpc" ) -const SecondsPerDay uint64 = 86400 - // the params should be two blocks' time(timestamp) func sameDayInUTC(first, second uint64) bool { - return first/SecondsPerDay == second/SecondsPerDay + return first/params.BreatheBlockInterval == second/params.BreatheBlockInterval } func isBreatheBlock(lastBlockTime, blockTime uint64) bool { diff --git a/params/protocol_params.go b/params/protocol_params.go index 0ab8b6a396..c750405e08 100644 --- a/params/protocol_params.go +++ b/params/protocol_params.go @@ -189,6 +189,7 @@ const ( var ( MinBlocksForBlobRequests uint64 = 524288 // it keeps blob data available for ~18.2 days in local, ref: https://github.com/bnb-chain/BEPs/blob/master/BEPs/BEP-336.md#51-parameters. DefaultExtraReserveForBlobRequests uint64 = 1 * (24 * 3600) / 3 // it adds more time for expired blobs for some request cases, like expiry blob when remote peer is syncing, default 1 day. + BreatheBlockInterval uint64 = 86400 // Controls the interval for updateValidatorSetV2 ) // Gas discount table for BLS12-381 G1 and G2 multi exponentiation operations