Skip to content

Commit

Permalink
fix: only validator need bls wallet
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanBSC committed Apr 14, 2023
1 parent 91f9993 commit 7c3ac81
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 9 deletions.
1 change: 1 addition & 0 deletions cmd/geth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ var (
utils.BlockAmountReserved,
utils.CheckSnapshotWithMPT,
utils.EnableDoubleSignMonitorFlag,
utils.VotingEnabledFlag,
utils.BLSPasswordFileFlag,
utils.BLSWalletDirFlag,
utils.VoteJournalDirFlag,
Expand Down
1 change: 1 addition & 0 deletions cmd/geth/usage.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ var AppHelpFlagGroups = []flags.FlagGroup{
utils.MinerRecommitIntervalFlag,
utils.MinerDelayLeftoverFlag,
utils.MinerNoVerfiyFlag,
utils.VotingEnabledFlag,
},
},
{
Expand Down
8 changes: 8 additions & 0 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -897,6 +897,11 @@ var (
Usage: "Enable double sign monitor to check whether any validator signs multiple blocks",
}

VotingEnabledFlag = cli.BoolFlag{
Name: "vote",
Usage: "Enable voting",
}

BLSPasswordFileFlag = cli.StringFlag{
Name: "blspassword",
Usage: "File path for the BLS password, which contains the password to unlock BLS wallet for managing votes in fast_finality feature",
Expand Down Expand Up @@ -1532,6 +1537,9 @@ func setMiner(ctx *cli.Context, cfg *miner.Config) {
if ctx.GlobalIsSet(LegacyMinerGasTargetFlag.Name) {
log.Warn("The generic --miner.gastarget flag is deprecated and will be removed in the future!")
}
if ctx.GlobalBool(VotingEnabledFlag.Name) {
cfg.VoteEnable = true
}
}

func setWhitelist(ctx *cli.Context, cfg *ethconfig.Config) {
Expand Down
18 changes: 9 additions & 9 deletions eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,6 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
}
eth.txPool = core.NewTxPool(config.TxPool, chainConfig, eth.blockchain)

conf := stack.Config()
blsPasswordPath := stack.ResolvePath(conf.BLSPasswordFile)
blsWalletPath := stack.ResolvePath(conf.BLSWalletDir)
voteJournalPath := stack.ResolvePath(conf.VoteJournalDir)

// Create voteManager instance
if posa, ok := eth.engine.(consensus.PoSA); ok {
// Create votePool instance
Expand All @@ -266,11 +261,16 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
}
log.Info("Create votePool successfully")

if _, err := vote.NewVoteManager(eth.EventMux(), chainConfig, eth.blockchain, votePool, voteJournalPath, blsPasswordPath, blsWalletPath, posa); err != nil {
log.Error("Failed to Initialize voteManager", "err", err)
return nil, err
if config.Miner.VoteEnable {
conf := stack.Config()
blsPasswordPath := stack.ResolvePath(conf.BLSPasswordFile)
blsWalletPath := stack.ResolvePath(conf.BLSWalletDir)
voteJournalPath := stack.ResolvePath(conf.VoteJournalDir)
if _, err := vote.NewVoteManager(eth.EventMux(), chainConfig, eth.blockchain, votePool, voteJournalPath, blsPasswordPath, blsWalletPath, posa); err != nil {
log.Warn("Failed to Initialize voteManager", "err", err)
}
log.Info("Create voteManager successfully")
}
log.Info("Create voteManager successfully")
}

// Permit the downloader to use the trie cache allowance during fast sync
Expand Down
1 change: 1 addition & 0 deletions miner/miner.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ type Config struct {
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 enable voting
}

// Miner creates blocks and searches for proof-of-work values.
Expand Down

0 comments on commit 7c3ac81

Please sign in to comment.