vote: remove DisableBscProtocol and add flag to skip votes assmebling (#1805)

This commit is contained in:
NathanBSC 2023-08-14 17:48:36 +08:00 committed by GitHub
parent c208d28a68
commit 9b95339c38
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 29 additions and 32 deletions

@ -72,7 +72,6 @@ var (
utils.DisableSnapProtocolFlag,
utils.DisableDiffProtocolFlag,
utils.EnableTrustProtocolFlag,
utils.DisableBscProtocolFlag,
utils.DiffSyncFlag,
utils.PipeCommitFlag,
utils.RangeLimitFlag,
@ -171,6 +170,7 @@ var (
utils.CheckSnapshotWithMPT,
utils.EnableDoubleSignMonitorFlag,
utils.VotingEnabledFlag,
utils.DisableVoteAttestationFlag,
utils.EnableMaliciousVoteMonitorFlag,
utils.BLSPasswordFileFlag,
utils.BLSWalletDirFlag,

@ -43,7 +43,6 @@ var AppHelpFlagGroups = []flags.FlagGroup{
utils.DisableSnapProtocolFlag,
utils.DisableDiffProtocolFlag,
utils.EnableTrustProtocolFlag,
utils.DisableBscProtocolFlag,
utils.RangeLimitFlag,
utils.SmartCardDaemonPathFlag,
utils.NetworkIdFlag,
@ -201,6 +200,7 @@ var AppHelpFlagGroups = []flags.FlagGroup{
utils.MinerDelayLeftoverFlag,
utils.MinerNoVerfiyFlag,
utils.VotingEnabledFlag,
utils.DisableVoteAttestationFlag,
},
},
{

@ -134,10 +134,6 @@ var (
Name: "enabletrustprotocol",
Usage: "Enable trust protocol",
}
DisableBscProtocolFlag = cli.BoolFlag{
Name: "disablebscprotocol",
Usage: "Disable bsc protocol",
}
DiffSyncFlag = cli.BoolFlag{
Name: "diffsync",
@ -908,6 +904,11 @@ var (
Usage: "Enable voting when mining",
}
DisableVoteAttestationFlag = cli.BoolFlag{
Name: "disablevoteattestation",
Usage: "Disable assembling vote attestation ",
}
EnableMaliciousVoteMonitorFlag = cli.BoolFlag{
Name: "monitor.maliciousvote",
Usage: "Enable malicious vote monitor to check whether any validator violates the voting rules of fast finality",
@ -1562,6 +1563,9 @@ func setMiner(ctx *cli.Context, cfg *miner.Config) {
if ctx.GlobalBool(VotingEnabledFlag.Name) {
cfg.VoteEnable = true
}
if ctx.GlobalBool(DisableVoteAttestationFlag.Name) {
cfg.DisableVoteAttestation = true
}
}
func setWhitelist(ctx *cli.Context, cfg *ethconfig.Config) {
@ -1720,9 +1724,6 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
if ctx.GlobalIsSet(EnableTrustProtocolFlag.Name) {
cfg.EnableTrustProtocol = ctx.GlobalIsSet(EnableTrustProtocolFlag.Name)
}
if ctx.GlobalIsSet(DisableBscProtocolFlag.Name) {
cfg.DisableBscProtocol = ctx.GlobalIsSet(DisableBscProtocolFlag.Name)
}
if ctx.GlobalIsSet(DiffSyncFlag.Name) {
log.Warn("The --diffsync flag is deprecated and will be removed in the future!")
}

@ -827,7 +827,7 @@ func (p *Parlia) assembleVoteAttestation(chain consensus.ChainHeaderReader, head
}
if p.VotePool == nil {
return errors.New("vote pool is nil")
return nil
}
// Fetch direct parent's votes

@ -284,7 +284,10 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
votePool := vote.NewVotePool(chainConfig, eth.blockchain, posa)
eth.votePool = votePool
if parlia, ok := eth.engine.(*parlia.Parlia); ok {
parlia.VotePool = votePool
if !config.Miner.DisableVoteAttestation {
// if there is no VotePool in Parlia Engine, the miner can't get votes for assembling
parlia.VotePool = votePool
}
} else {
return nil, fmt.Errorf("Engine is not Parlia type")
}
@ -627,9 +630,8 @@ func (s *Ethereum) Protocols() []p2p.Protocol {
if s.config.EnableTrustProtocol {
protos = append(protos, trust.MakeProtocols((*trustHandler)(s.handler), s.snapDialCandidates)...)
}
if !s.config.DisableBscProtocol {
protos = append(protos, bsc.MakeProtocols((*bscHandler)(s.handler), s.bscDialCandidates)...)
}
protos = append(protos, bsc.MakeProtocols((*bscHandler)(s.handler), s.bscDialCandidates)...)
return protos
}

@ -151,7 +151,6 @@ type Config struct {
DisableSnapProtocol bool //Whether disable snap protocol
DisableDiffProtocol bool //Whether disable diff protocol
EnableTrustProtocol bool //Whether enable trust protocol
DisableBscProtocol bool //Whether disable bsc protocol
DiffSync bool // Whether support diff sync
PipeCommit bool
RangeLimit bool

@ -32,7 +32,6 @@ func (c Config) MarshalTOML() (interface{}, error) {
DisableSnapProtocol bool
DisableDiffProtocol bool
EnableTrustProtocol bool
DisableBscProtocol bool
DiffSync bool
RangeLimit bool
TxLookupLimit uint64 `toml:",omitempty"`
@ -95,7 +94,6 @@ func (c Config) MarshalTOML() (interface{}, error) {
enc.DisableSnapProtocol = c.DisableSnapProtocol
enc.DisableDiffProtocol = c.DisableDiffProtocol
enc.EnableTrustProtocol = c.EnableTrustProtocol
enc.DisableBscProtocol = c.DisableBscProtocol
enc.DiffSync = c.DiffSync
enc.RangeLimit = c.RangeLimit
enc.TxLookupLimit = c.TxLookupLimit
@ -163,7 +161,6 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error {
DisableSnapProtocol *bool
DisableDiffProtocol *bool
EnableTrustProtocol *bool
DisableBscProtocol *bool
DiffSync *bool
RangeLimit *bool
TxLookupLimit *uint64 `toml:",omitempty"`
@ -255,9 +252,6 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error {
if dec.EnableTrustProtocol != nil {
c.EnableTrustProtocol = *dec.EnableTrustProtocol
}
if dec.DisableBscProtocol != nil {
c.DisableBscProtocol = *dec.DisableBscProtocol
}
if dec.DiffSync != nil {
c.DiffSync = *dec.DiffSync
}

@ -44,17 +44,18 @@ 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).
NotifyFull bool `toml:",omitempty"` // Notify with pending block headers instead of work packages
ExtraData hexutil.Bytes `toml:",omitempty"` // Block extra data set by the miner
DelayLeftOver time.Duration // Time reserved to finalize a block(calculate root, distribute income...)
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).
VoteEnable bool // Whether to vote when mining
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).
NotifyFull bool `toml:",omitempty"` // Notify with pending block headers instead of work packages
ExtraData hexutil.Bytes `toml:",omitempty"` // Block extra data set by the miner
DelayLeftOver time.Duration // Time reserved to finalize a block(calculate root, distribute income...)
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).
VoteEnable bool // Whether to vote when mining
DisableVoteAttestation bool // Whether to skip assembling vote attestation
}
// Miner creates blocks and searches for proof-of-work values.