From 7a8b5e0c232a3281d20a0744fb252c0a879675ec Mon Sep 17 00:00:00 2001 From: Goran Rojovic Date: Tue, 5 Sep 2023 11:00:09 +0200 Subject: [PATCH] Comments fix --- command/genesis/genesis.go | 2 +- command/genesis/polybft_params.go | 6 ++++-- consensus/polybft/governance_manager.go | 13 ++++++++----- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/command/genesis/genesis.go b/command/genesis/genesis.go index 4bb5911760..1f0269f1cc 100644 --- a/command/genesis/genesis.go +++ b/command/genesis/genesis.go @@ -240,7 +240,7 @@ func setFlags(cmd *cobra.Command) { ¶ms.checkpointInterval, checkpointIntervalFlag, defaultCheckpointInterval, - "number of blocks after which a new checkpoint is submitted", + "checkpoint submission interval in blocks", ) cmd.Flags().Uint64Var( diff --git a/command/genesis/polybft_params.go b/command/genesis/polybft_params.go index 42bccbe975..439c92e44e 100644 --- a/command/genesis/polybft_params.go +++ b/command/genesis/polybft_params.go @@ -68,6 +68,8 @@ const ( ecdsaAddressLength = 40 blsKeyLength = 256 + + proposalQuorumMax = uint64(100) ) var ( @@ -168,9 +170,9 @@ func (p *genesisParams) generatePolyBftChainConfig(o command.OutputFormatter) er } proposalQuorum := p.proposalQuorum - if proposalQuorum > 100 { + if proposalQuorum > proposalQuorumMax { // proposal can be from 0 to 100, so we sanitize the value - proposalQuorum = 100 + proposalQuorum = proposalQuorumMax } polyBftConfig := &polybft.PolyBFTConfig{ diff --git a/consensus/polybft/governance_manager.go b/consensus/polybft/governance_manager.go index 32c603ba3a..e8fd0fb7e1 100644 --- a/consensus/polybft/governance_manager.go +++ b/consensus/polybft/governance_manager.go @@ -7,15 +7,16 @@ import ( "math/big" "time" + "github.com/hashicorp/go-hclog" + "github.com/umbracle/ethgo" + "github.com/umbracle/ethgo/abi" + "github.com/0xPolygon/polygon-edge/chain" "github.com/0xPolygon/polygon-edge/consensus/polybft/contractsapi" "github.com/0xPolygon/polygon-edge/crypto" "github.com/0xPolygon/polygon-edge/forkmanager" "github.com/0xPolygon/polygon-edge/helper/common" "github.com/0xPolygon/polygon-edge/types" - "github.com/hashicorp/go-hclog" - "github.com/umbracle/ethgo" - "github.com/umbracle/ethgo/abi" ) const ( @@ -23,7 +24,10 @@ const ( newRewardLookbackSize = uint64(1) ) -var errUnknownGovernanceEvent = errors.New("unknown event from governance") +var ( + errUnknownGovernanceEvent = errors.New("unknown event from governance") + stringABIType = abi.MustNewType("tuple(string)") +) // isRewardDistributionBlock indicates if reward distribution transaction // should happen in given block @@ -106,7 +110,6 @@ func newGovernanceManager(genesisConfig *PolyBFTConfig, // cache all fork name hashes that we have in code allForkNameHashes := map[types.Hash]string{} - stringABIType := abi.MustNewType("tuple(string)") for name := range *chain.AllForksEnabled { encoded, err := stringABIType.Encode([]interface{}{name})