Skip to content

Commit

Permalink
vote: remove DisableBscProtocol and add flag to skip votes assmebling
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanBSC committed Aug 7, 2023
1 parent c208d28 commit d259770
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 40 deletions.
2 changes: 1 addition & 1 deletion cmd/geth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ var (
utils.DisableSnapProtocolFlag,
utils.DisableDiffProtocolFlag,
utils.EnableTrustProtocolFlag,
utils.DisableBscProtocolFlag,
utils.DiffSyncFlag,
utils.PipeCommitFlag,
utils.RangeLimitFlag,
Expand Down Expand Up @@ -171,6 +170,7 @@ var (
utils.CheckSnapshotWithMPT,
utils.EnableDoubleSignMonitorFlag,
utils.VotingEnabledFlag,
utils.DisableVoteAttestationFlag,
utils.EnableMaliciousVoteMonitorFlag,
utils.BLSPasswordFileFlag,
utils.BLSWalletDirFlag,
Expand Down
2 changes: 1 addition & 1 deletion cmd/geth/usage.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ var AppHelpFlagGroups = []flags.FlagGroup{
utils.DisableSnapProtocolFlag,
utils.DisableDiffProtocolFlag,
utils.EnableTrustProtocolFlag,
utils.DisableBscProtocolFlag,
utils.RangeLimitFlag,
utils.SmartCardDaemonPathFlag,
utils.NetworkIdFlag,
Expand Down Expand Up @@ -201,6 +200,7 @@ var AppHelpFlagGroups = []flags.FlagGroup{
utils.MinerDelayLeftoverFlag,
utils.MinerNoVerfiyFlag,
utils.VotingEnabledFlag,
utils.DisableVoteAttestationFlag,
},
},
{
Expand Down
15 changes: 8 additions & 7 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -908,6 +904,11 @@ var (
Usage: "Enable voting when mining",
}

DisableVoteAttestationFlag = cli.BoolFlag{
Name: "DisableVoteAttestation",
Usage: "Disable 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",
Expand Down Expand Up @@ -1562,6 +1563,9 @@ func setMiner(ctx *cli.Context, cfg *miner.Config) {
if ctx.GlobalBool(VotingEnabledFlag.Name) {
cfg.VoteEnable = true
}
if ctx.GlobalIsSet(DisableVoteAttestationFlag.Name) {
cfg.DisableVoteAttestation = ctx.GlobalIsSet(DisableVoteAttestationFlag.Name)
}
}

func setWhitelist(ctx *cli.Context, cfg *ethconfig.Config) {
Expand Down Expand Up @@ -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!")
}
Expand Down
2 changes: 1 addition & 1 deletion consensus/parlia/parlia.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 6 additions & 4 deletions eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down Expand Up @@ -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
}

Expand Down
18 changes: 9 additions & 9 deletions eth/ethconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,15 @@ type Config struct {
TrustDiscoveryURLs []string
BscDiscoveryURLs []string

NoPruning bool // Whether to disable pruning and flush everything to disk
DirectBroadcast bool
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
NoPruning bool // Whether to disable pruning and flush everything to disk
DirectBroadcast bool
DisableSnapProtocol bool //Whether disable snap protocol
DisableDiffProtocol bool //Whether disable diff protocol
EnableTrustProtocol bool //Whether enable trust protocol
DisableVoteAttestation bool //Whether disable bsc protocol
DiffSync bool // Whether support diff sync
PipeCommit bool
RangeLimit bool

TxLookupLimit uint64 `toml:",omitempty"` // The maximum number of blocks from head whose tx indices are reserved.

Expand Down
6 changes: 0 additions & 6 deletions eth/ethconfig/gen_config.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,11 @@ require (
github.com/dustin/go-humanize v1.0.0 // indirect
github.com/elastic/gosigar v0.14.2 // indirect
github.com/ferranbt/fastssz v0.0.0-20210905181407-59cf6761a7d5 // indirect
github.com/fjl/gencodec v0.0.0-20230517082657-f9840df7b83e // indirect
github.com/flynn/noise v1.0.0 // indirect
github.com/francoispqt/gojay v1.2.13 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/garslo/gogen v0.0.0-20170306192744-1d203ffc1f61 // indirect
github.com/go-kit/kit v0.12.0 // indirect
github.com/go-kit/log v0.2.1 // indirect
github.com/go-logfmt/logfmt v0.5.1 // indirect
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,8 @@ github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga
github.com/ferranbt/fastssz v0.0.0-20210120143747-11b9eff30ea9/go.mod h1:DyEu2iuLBnb/T51BlsiO3yLYdJC6UbGMrIkqK1KmQxM=
github.com/ferranbt/fastssz v0.0.0-20210905181407-59cf6761a7d5 h1:6dVcS0LktRSyEEgldFY4N9J17WjUoiJStttH+RZj0Wo=
github.com/ferranbt/fastssz v0.0.0-20210905181407-59cf6761a7d5/go.mod h1:S8yiDeAXy8f88W4Ul+0dBMPx49S05byYbmZD6Uv94K4=
github.com/fjl/gencodec v0.0.0-20230517082657-f9840df7b83e h1:bBLctRc7kr01YGvaDfgLbTwjFNW5jdp5y5rj8XXBHfY=
github.com/fjl/gencodec v0.0.0-20230517082657-f9840df7b83e/go.mod h1:AzA8Lj6YtixmJWL+wkKoBGsLWy9gFrAzi4g+5bCKwpY=
github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 h1:FtmdgXiUlNeRsoNMFlKLDt+S+6hbjVMEW6RGQ7aUf7c=
github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0=
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
Expand All @@ -358,6 +360,8 @@ github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMo
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY=
github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw=
github.com/garslo/gogen v0.0.0-20170306192744-1d203ffc1f61 h1:IZqZOB2fydHte3kUgxrzK5E1fW7RQGeDwE8F/ZZnUYc=
github.com/garslo/gogen v0.0.0-20170306192744-1d203ffc1f61/go.mod h1:Q0X6pkwTILDlzrGEckF6HKjXe48EgsY/l7K7vhY4MW8=
github.com/garyburd/redigo v1.1.1-0.20170914051019-70e1b1943d4f/go.mod h1:NR3MbYisc3/PwhQ00EMzDiPmrwpPxAn5GI05/YaO1SY=
github.com/garyburd/redigo v1.6.0/go.mod h1:NR3MbYisc3/PwhQ00EMzDiPmrwpPxAn5GI05/YaO1SY=
github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww=
Expand Down
23 changes: 12 additions & 11 deletions miner/miner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit d259770

Please sign in to comment.