diff --git a/cmd/geth/blsaccountcmd.go b/cmd/geth/blsaccountcmd.go index 07c6b24814..45d11269e7 100644 --- a/cmd/geth/blsaccountcmd.go +++ b/cmd/geth/blsaccountcmd.go @@ -15,6 +15,7 @@ import ( "github.com/prysmaticlabs/prysm/v3/crypto/bls" "github.com/prysmaticlabs/prysm/v3/encoding/bytesutil" "github.com/prysmaticlabs/prysm/v3/io/prompt" + "github.com/prysmaticlabs/prysm/v3/proto/eth/service" "github.com/prysmaticlabs/prysm/v3/validator/accounts" "github.com/prysmaticlabs/prysm/v3/validator/accounts/iface" "github.com/prysmaticlabs/prysm/v3/validator/accounts/petnames" @@ -381,7 +382,7 @@ func blsAccountImport(ctx *cli.Context) error { password := utils.GetPassPhrase("Enter the password for your imported account.", false) fmt.Println("Importing BLS account, this may take a while...") - _, err = accounts.ImportAccounts(context.Background(), &accounts.ImportAccountsConfig{ + statuses, err := accounts.ImportAccounts(context.Background(), &accounts.ImportAccountsConfig{ Importer: k, Keystores: []*keymanager.Keystore{keystore}, AccountPassword: password, @@ -389,7 +390,12 @@ func blsAccountImport(ctx *cli.Context) error { if err != nil { utils.Fatalf("Import BLS account failed: %v.", err) } - fmt.Println("Successfully import BLS account.") + // len(statuses)==len(Keystores) when err==nil + if statuses[0].Status == service.ImportedKeystoreStatus_ERROR { + fmt.Printf("Could not import keystore: %v.", statuses[0].Message) + } else { + fmt.Println("Successfully import BLS account.") + } return nil } diff --git a/cmd/geth/main.go b/cmd/geth/main.go index e65ac3dd08..6c08754809 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -169,6 +169,7 @@ var ( utils.BlockAmountReserved, utils.CheckSnapshotWithMPT, utils.EnableDoubleSignMonitorFlag, + utils.VotingEnabledFlag, utils.BLSPasswordFileFlag, utils.BLSWalletDirFlag, utils.VoteJournalDirFlag, diff --git a/cmd/geth/usage.go b/cmd/geth/usage.go index 52b3bcd09d..ab813a92f9 100644 --- a/cmd/geth/usage.go +++ b/cmd/geth/usage.go @@ -199,6 +199,7 @@ var AppHelpFlagGroups = []flags.FlagGroup{ utils.MinerRecommitIntervalFlag, utils.MinerDelayLeftoverFlag, utils.MinerNoVerfiyFlag, + utils.VotingEnabledFlag, }, }, { diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index f7b0abcfe0..19f084f51a 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -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", @@ -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) { diff --git a/eth/backend.go b/eth/backend.go index 25d0f908b3..73c4dbd51e 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -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 @@ -266,11 +261,17 @@ 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.Error("Failed to Initialize voteManager", "err", err) + return nil, err + } + log.Info("Create voteManager successfully") } - log.Info("Create voteManager successfully") } // Permit the downloader to use the trie cache allowance during fast sync diff --git a/miner/miner.go b/miner/miner.go index 7f0f1583e8..de575ee69c 100644 --- a/miner/miner.go +++ b/miner/miner.go @@ -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.