diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e201dea8..7a7e1cc00 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) * [#224](https://github.com/babylonlabs-io/babylon/pull/224) Make injected checkpoint a standard tx * [#207](https://github.com/babylonlabs-io/babylon/pull/207) Rename total voting power to total bonded sat +* [#204](https://github.com/babylonlabs-io/babylon/pull/204) Add babylon finality +activation block height to start processing finality messages in `x/finality` params. * [#215](https://github.com/babylonlabs-io/babylon/pull/215) Implement ADR-29 generalized unbonding handler diff --git a/app/upgrades/v1/mainnet/finality_params.go b/app/upgrades/v1/mainnet/finality_params.go index 4874b2045..ea21af3ab 100644 --- a/app/upgrades/v1/mainnet/finality_params.go +++ b/app/upgrades/v1/mainnet/finality_params.go @@ -7,5 +7,6 @@ const FinalityParamStr = `{ "finality_sig_timeout": 3, "min_signed_per_window": "0.1", "min_pub_rand": 100, - "jail_duration": "86400s" + "jail_duration": "86400s", + "finality_activation_height": 17500 }` diff --git a/app/upgrades/v1/testnet/finality_params.go b/app/upgrades/v1/testnet/finality_params.go index 6ee0ded30..13f8e03a1 100644 --- a/app/upgrades/v1/testnet/finality_params.go +++ b/app/upgrades/v1/testnet/finality_params.go @@ -7,5 +7,6 @@ const FinalityParamStr = `{ "finality_sig_timeout": 3, "min_signed_per_window": "0.1", "min_pub_rand": 100, - "jail_duration": "86400s" + "jail_duration": "86400s", + "finality_activation_height": 75 }` diff --git a/btcstaking/staking_test.go b/btcstaking/staking_test.go index d8c7f0745..b91265847 100644 --- a/btcstaking/staking_test.go +++ b/btcstaking/staking_test.go @@ -545,6 +545,7 @@ func TestCheckPreSignedTxSanity(t *testing.T) { }, } for _, tt := range tests { + tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() err := btcstaking.CheckPreSignedTxSanity( diff --git a/client/docs/swagger-ui/swagger.yaml b/client/docs/swagger-ui/swagger.yaml index a41de9c5e..6499e284f 100644 --- a/client/docs/swagger-ui/swagger.yaml +++ b/client/docs/swagger-ui/swagger.yaml @@ -24,8 +24,8 @@ paths: format: uint64 description: EpochNumber of this checkpoint. best_submission_btc_block_height: - type: string - format: uint64 + type: integer + format: int64 title: btc height of the best submission of the epoch best_submission_btc_block_hash: type: string @@ -229,8 +229,8 @@ paths: type: object properties: btc_confirmation_depth: - type: string - format: uint64 + type: integer + format: int64 title: >- btc_confirmation_depth is the confirmation depth in BTC. @@ -239,8 +239,8 @@ paths: (k in research paper) checkpoint_finalization_timeout: - type: string - format: uint64 + type: integer + format: int64 title: >- checkpoint_finalization_timeout is the maximum time window (measured in BTC @@ -308,8 +308,8 @@ paths: format: uint64 description: EpochNumber of this checkpoint. best_submission_btc_block_height: - type: string - format: uint64 + type: integer + format: int64 title: btc height of the best submission of the epoch best_submission_btc_block_hash: type: string @@ -520,8 +520,8 @@ paths: hash_hex: type: string height: - type: string - format: uint64 + type: integer + format: int64 work: type: string description: Work is the sdkmath.Uint as string. @@ -676,8 +676,8 @@ paths: type: object properties: depth: - type: string - format: uint64 + type: integer + format: int64 title: >- QueryMainChainDepthResponse is the response type for the Query/MainChainDepth RPC @@ -859,8 +859,8 @@ paths: hash_hex: type: string height: - type: string - format: uint64 + type: integer + format: int64 work: type: string description: Work is the sdkmath.Uint as string. @@ -1055,8 +1055,8 @@ paths: hash_hex: type: string height: - type: string - format: uint64 + type: integer + format: int64 work: type: string description: Work is the sdkmath.Uint as string. @@ -3726,9 +3726,8 @@ paths: validator_address: type: string title: validator_address is the address of the validator - bls_pub_key: + bls_pub_key_hex: type: string - format: byte title: bls_pub_key is the BLS public key of the validator voting_power: type: string @@ -3737,8 +3736,8 @@ paths: voting_power is the voting power of the validator at the given epoch title: >- - ValidatorWithBlsKey couples validator address, voting power, - and its bls + BlsPublicKeyListResponse couples validator address, voting + power, and its bls public key pagination: @@ -4747,8 +4746,8 @@ definitions: format: uint64 description: EpochNumber of this checkpoint. best_submission_btc_block_height: - type: string - format: uint64 + type: integer + format: int64 title: btc height of the best submission of the epoch best_submission_btc_block_hash: type: string @@ -4839,8 +4838,8 @@ definitions: type: object properties: btc_confirmation_depth: - type: string - format: uint64 + type: integer + format: int64 title: >- btc_confirmation_depth is the confirmation depth in BTC. @@ -4849,8 +4848,8 @@ definitions: (k in research paper) checkpoint_finalization_timeout: - type: string - format: uint64 + type: integer + format: int64 title: >- checkpoint_finalization_timeout is the maximum time window (measured in BTC @@ -4885,8 +4884,8 @@ definitions: format: uint64 description: EpochNumber of this checkpoint. best_submission_btc_block_height: - type: string - format: uint64 + type: integer + format: int64 title: btc height of the best submission of the epoch best_submission_btc_block_hash: type: string @@ -4970,8 +4969,8 @@ definitions: format: uint64 description: EpochNumber of this checkpoint. best_submission_btc_block_height: - type: string - format: uint64 + type: integer + format: int64 title: btc height of the best submission of the epoch best_submission_btc_block_hash: type: string @@ -5119,8 +5118,8 @@ definitions: type: object properties: btc_confirmation_depth: - type: string - format: uint64 + type: integer + format: int64 title: >- btc_confirmation_depth is the confirmation depth in BTC. @@ -5129,8 +5128,8 @@ definitions: (k in research paper) checkpoint_finalization_timeout: - type: string - format: uint64 + type: integer + format: int64 title: >- checkpoint_finalization_timeout is the maximum time window (measured in BTC @@ -5635,8 +5634,8 @@ definitions: hash_hex: type: string height: - type: string - format: uint64 + type: integer + format: int64 work: type: string description: Work is the sdkmath.Uint as string. @@ -5675,8 +5674,8 @@ definitions: hash_hex: type: string height: - type: string - format: uint64 + type: integer + format: int64 work: type: string description: Work is the sdkmath.Uint as string. @@ -5749,8 +5748,8 @@ definitions: type: object properties: depth: - type: string - format: uint64 + type: integer + format: int64 title: >- QueryMainChainDepthResponse is the response type for the Query/MainChainDepth RPC @@ -5769,8 +5768,8 @@ definitions: hash_hex: type: string height: - type: string - format: uint64 + type: integer + format: int64 work: type: string description: Work is the sdkmath.Uint as string. @@ -5842,8 +5841,8 @@ definitions: hash_hex: type: string height: - type: string - format: uint64 + type: integer + format: int64 work: type: string description: Work is the sdkmath.Uint as string. @@ -6598,6 +6597,24 @@ definitions: NOTE: The amount field is an Int which implements the custom method signatures required by gogoproto. + babylon.checkpointing.v1.BlsPublicKeyListResponse: + type: object + properties: + validator_address: + type: string + title: validator_address is the address of the validator + bls_pub_key_hex: + type: string + title: bls_pub_key is the BLS public key of the validator + voting_power: + type: string + format: uint64 + title: voting_power is the voting power of the validator at the given epoch + title: >- + BlsPublicKeyListResponse couples validator address, voting power, and its + bls + + public key babylon.checkpointing.v1.CheckpointStateUpdateResponse: type: object properties: @@ -6669,9 +6686,8 @@ definitions: validator_address: type: string title: validator_address is the address of the validator - bls_pub_key: + bls_pub_key_hex: type: string - format: byte title: bls_pub_key is the BLS public key of the validator voting_power: type: string @@ -6680,8 +6696,8 @@ definitions: voting_power is the voting power of the validator at the given epoch title: >- - ValidatorWithBlsKey couples validator address, voting power, and its - bls + BlsPublicKeyListResponse couples validator address, voting power, + and its bls public key pagination: @@ -7342,20 +7358,3 @@ definitions: transition and the time (in both timestamp and block height) of this transition. description: RawCheckpointWithMetaResponse wraps the raw checkpoint with metadata. - babylon.checkpointing.v1.ValidatorWithBlsKey: - type: object - properties: - validator_address: - type: string - title: validator_address is the address of the validator - bls_pub_key: - type: string - format: byte - title: bls_pub_key is the BLS public key of the validator - voting_power: - type: string - format: uint64 - title: voting_power is the voting power of the validator at the given epoch - title: |- - ValidatorWithBlsKey couples validator address, voting power, and its bls - public key diff --git a/cmd/babylond/cmd/flags.go b/cmd/babylond/cmd/flags.go index 06642a51c..2ade8ab09 100644 --- a/cmd/babylond/cmd/flags.go +++ b/cmd/babylond/cmd/flags.go @@ -49,46 +49,48 @@ const ( flagSlashingRate = "slashing-rate" flagMinCommissionRate = "min-commission-rate" flagSignedBlocksWindow = "signed-blocks-window" + flagActivationHeight = "activation-height" flagMinSignedPerWindow = "min-signed-per-window" flagFinalitySigTimeout = "finality-sig-timeout" flagJailDuration = "jail-duration" ) type GenesisCLIArgs struct { - ChainID string - MaxActiveValidators uint32 - BtcConfirmationDepth uint32 - BtcFinalizationTimeout uint32 - CheckpointTag string - EpochInterval uint64 - BaseBtcHeaderHex string - BaseBtcHeaderHeight uint32 - AllowedReporterAddresses []string - InflationRateChange float64 - InflationMax float64 - InflationMin float64 - GoalBonded float64 - BlocksPerYear uint64 - GenesisTime time.Time - BlockGasLimit int64 - VoteExtensionEnableHeight int64 - CovenantPKs []string - CovenantQuorum uint32 - MinStakingAmtSat int64 - MaxStakingAmtSat int64 - MinStakingTimeBlocks uint16 - MaxStakingTimeBlocks uint16 - SlashingPkScript string - MinSlashingTransactionFeeSat int64 - SlashingRate math.LegacyDec - MaxActiveFinalityProviders uint32 - MinUnbondingTime uint16 - UnbondingFeeSat int64 - MinCommissionRate math.LegacyDec - SignedBlocksWindow int64 - MinSignedPerWindow math.LegacyDec - FinalitySigTimeout int64 - JailDuration time.Duration + ChainID string + MaxActiveValidators uint32 + BtcConfirmationDepth uint32 + BtcFinalizationTimeout uint32 + CheckpointTag string + EpochInterval uint64 + BaseBtcHeaderHex string + BaseBtcHeaderHeight uint32 + AllowedReporterAddresses []string + InflationRateChange float64 + InflationMax float64 + InflationMin float64 + GoalBonded float64 + BlocksPerYear uint64 + GenesisTime time.Time + BlockGasLimit int64 + VoteExtensionEnableHeight int64 + CovenantPKs []string + CovenantQuorum uint32 + MinStakingAmtSat int64 + MaxStakingAmtSat int64 + MinStakingTimeBlocks uint16 + MaxStakingTimeBlocks uint16 + SlashingPkScript string + MinSlashingTransactionFeeSat int64 + SlashingRate math.LegacyDec + MaxActiveFinalityProviders uint32 + MinUnbondingTime uint16 + UnbondingFeeSat int64 + MinCommissionRate math.LegacyDec + SignedBlocksWindow int64 + MinSignedPerWindow math.LegacyDec + FinalitySigTimeout int64 + JailDuration time.Duration + FinalityActivationBlockHeight uint64 } func addGenesisFlags(cmd *cobra.Command) { @@ -135,6 +137,8 @@ func addGenesisFlags(cmd *cobra.Command) { cmd.Flags().String(flagMinSignedPerWindow, ftypes.DefaultMinSignedPerWindow.String(), "Minimum number of blocks that a finality provider is required to sign within the sliding window to avoid being jailed") cmd.Flags().Int64(flagFinalitySigTimeout, ftypes.DefaultFinalitySigTimeout, "How much time (in terms of blocks) finality providers have to cast a finality vote before being judged as missing their voting turn on the given block") cmd.Flags().String(flagJailDuration, ftypes.DefaultJailDuration.String(), "Minimum period of time that a finality provider remains jailed") + // finality flags + cmd.Flags().Uint64(flagActivationHeight, ftypes.DefaultFinalityActivationHeight, "Finality bbn block height activation to start accepting finality vote and pub rand") } func parseGenesisFlags(cmd *cobra.Command) (*GenesisCLIArgs, error) { @@ -172,6 +176,7 @@ func parseGenesisFlags(cmd *cobra.Command) (*GenesisCLIArgs, error) { minSignedPerWindowStr, _ := cmd.Flags().GetString(flagMinSignedPerWindow) finalitySigTimeout, _ := cmd.Flags().GetInt64(flagFinalitySigTimeout) jailDurationStr, _ := cmd.Flags().GetString(flagJailDuration) + finalityActivationBlockHeight, _ := cmd.Flags().GetUint64(flagActivationHeight) if chainID == "" { chainID = "chain-" + tmrand.NewRand().Str(6) @@ -195,39 +200,40 @@ func parseGenesisFlags(cmd *cobra.Command) (*GenesisCLIArgs, error) { } return &GenesisCLIArgs{ - ChainID: chainID, - MaxActiveValidators: maxActiveValidators, - BtcConfirmationDepth: btcConfirmationDepth, - BtcFinalizationTimeout: btcFinalizationTimeout, - CheckpointTag: checkpointTag, - EpochInterval: epochInterval, - BaseBtcHeaderHeight: baseBtcHeaderHeight, - BaseBtcHeaderHex: baseBtcHeaderHex, - AllowedReporterAddresses: allowedReporterAddresses, - CovenantPKs: strings.Split(covenantPks, ","), - CovenantQuorum: covenantQuorum, - MinStakingAmtSat: minStakingAmtSat, - MaxStakingAmtSat: maxStakingAmtSat, - MinStakingTimeBlocks: minStakingTimeBlocks, - MaxStakingTimeBlocks: maxStakingTimeBlocks, - SlashingPkScript: slashingPkScript, - MinSlashingTransactionFeeSat: minSlashingFee, - MinCommissionRate: math.LegacyMustNewDecFromStr(minCommissionRate), - SlashingRate: math.LegacyMustNewDecFromStr(slashingRate), - MaxActiveFinalityProviders: maxActiveFinalityProviders, - MinUnbondingTime: minUnbondingTime, - UnbondingFeeSat: unbondingFeeSat, - GenesisTime: genesisTime, - InflationRateChange: inflationRateChange, - InflationMax: inflationMax, - InflationMin: inflationMin, - GoalBonded: goalBonded, - BlocksPerYear: blocksPerYear, - BlockGasLimit: blockGasLimit, - VoteExtensionEnableHeight: voteExtensionEnableHeight, - SignedBlocksWindow: signedBlocksWindow, - MinSignedPerWindow: minSignedPerWindow, - FinalitySigTimeout: finalitySigTimeout, - JailDuration: jailDuration, + ChainID: chainID, + MaxActiveValidators: maxActiveValidators, + BtcConfirmationDepth: btcConfirmationDepth, + BtcFinalizationTimeout: btcFinalizationTimeout, + CheckpointTag: checkpointTag, + EpochInterval: epochInterval, + BaseBtcHeaderHeight: baseBtcHeaderHeight, + BaseBtcHeaderHex: baseBtcHeaderHex, + AllowedReporterAddresses: allowedReporterAddresses, + CovenantPKs: strings.Split(covenantPks, ","), + CovenantQuorum: covenantQuorum, + MinStakingAmtSat: minStakingAmtSat, + MaxStakingAmtSat: maxStakingAmtSat, + MinStakingTimeBlocks: minStakingTimeBlocks, + MaxStakingTimeBlocks: maxStakingTimeBlocks, + SlashingPkScript: slashingPkScript, + MinSlashingTransactionFeeSat: minSlashingFee, + MinCommissionRate: math.LegacyMustNewDecFromStr(minCommissionRate), + SlashingRate: math.LegacyMustNewDecFromStr(slashingRate), + MaxActiveFinalityProviders: maxActiveFinalityProviders, + MinUnbondingTime: minUnbondingTime, + UnbondingFeeSat: unbondingFeeSat, + GenesisTime: genesisTime, + InflationRateChange: inflationRateChange, + InflationMax: inflationMax, + InflationMin: inflationMin, + GoalBonded: goalBonded, + BlocksPerYear: blocksPerYear, + BlockGasLimit: blockGasLimit, + VoteExtensionEnableHeight: voteExtensionEnableHeight, + SignedBlocksWindow: signedBlocksWindow, + MinSignedPerWindow: minSignedPerWindow, + FinalitySigTimeout: finalitySigTimeout, + JailDuration: jailDuration, + FinalityActivationBlockHeight: finalityActivationBlockHeight, }, nil } diff --git a/cmd/babylond/cmd/genesis.go b/cmd/babylond/cmd/genesis.go index 70caf71e0..08a97d625 100644 --- a/cmd/babylond/cmd/genesis.go +++ b/cmd/babylond/cmd/genesis.go @@ -106,6 +106,7 @@ Example: genesisCliArgs.MinSignedPerWindow, genesisCliArgs.FinalitySigTimeout, genesisCliArgs.JailDuration, + genesisCliArgs.FinalityActivationBlockHeight, ) } else if network == "mainnet" { panic("Mainnet params not implemented.") @@ -302,6 +303,7 @@ func TestnetGenesisParams( minSignedPerWindow sdkmath.LegacyDec, finalitySigTimeout int64, jailDuration time.Duration, + finalityActivationBlockHeight uint64, ) GenesisParams { genParams := GenesisParams{} @@ -438,6 +440,7 @@ func TestnetGenesisParams( genParams.FinalityParams.MinSignedPerWindow = minSignedPerWindow genParams.FinalityParams.FinalitySigTimeout = finalitySigTimeout genParams.FinalityParams.JailDuration = jailDuration + genParams.FinalityParams.FinalityActivationHeight = finalityActivationBlockHeight if err := genParams.FinalityParams.Validate(); err != nil { panic(err) } diff --git a/cmd/babylond/cmd/testnet.go b/cmd/babylond/cmd/testnet.go index 369836701..22d880afc 100644 --- a/cmd/babylond/cmd/testnet.go +++ b/cmd/babylond/cmd/testnet.go @@ -126,6 +126,7 @@ Example: genesisCliArgs.MinSignedPerWindow, genesisCliArgs.FinalitySigTimeout, genesisCliArgs.JailDuration, + genesisCliArgs.FinalityActivationBlockHeight, ) return InitTestnet( diff --git a/proto/babylon/finality/v1/params.proto b/proto/babylon/finality/v1/params.proto index 711626486..80a7d7220 100644 --- a/proto/babylon/finality/v1/params.proto +++ b/proto/babylon/finality/v1/params.proto @@ -30,4 +30,8 @@ message Params { // jail_duration is the minimum period of time that a finality provider remains jailed google.protobuf.Duration jail_duration = 5 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true, (gogoproto.stdduration) = true]; + // finality_activation_height is the babylon block height which the finality module will + // start to accept finality voting and the minimum allowed value for the public randomness + // commit start height. + uint64 finality_activation_height = 6; } diff --git a/test/e2e/containers/containers.go b/test/e2e/containers/containers.go index 170f35db4..90411add9 100644 --- a/test/e2e/containers/containers.go +++ b/test/e2e/containers/containers.go @@ -132,6 +132,9 @@ func (m *Manager) ExecCmd(t *testing.T, fullContainerName string, command []stri // Note that this does not match all errors. // This only works if CLI outputs "Error" or "error" // to stderr. + fmt.Printf("\n Debug: errOut %s", errBufString) + fmt.Printf("\n Debug: output %s", outBuf.String()) + if (errRegex.MatchString(errBufString) || m.isDebugLogEnabled) && maxDebugLogTriesLeft > 0 { t.Log("\nstderr:") t.Log(errBufString) diff --git a/test/e2e/initialization/config.go b/test/e2e/initialization/config.go index da4d7c423..bc181dac4 100644 --- a/test/e2e/initialization/config.go +++ b/test/e2e/initialization/config.go @@ -29,6 +29,7 @@ import ( blctypes "github.com/babylonlabs-io/babylon/x/btclightclient/types" btclighttypes "github.com/babylonlabs-io/babylon/x/btclightclient/types" checkpointingtypes "github.com/babylonlabs-io/babylon/x/checkpointing/types" + finalitytypes "github.com/babylonlabs-io/babylon/x/finality/types" "github.com/babylonlabs-io/babylon/test/e2e/util" ) @@ -264,6 +265,11 @@ func initGenesis( return err } + err = updateModuleGenesis(appGenState, finalitytypes.ModuleName, &finalitytypes.GenesisState{}, updateFinalityGenesis) + if err != nil { + return err + } + bz, err := json.MarshalIndent(appGenState, "", " ") if err != nil { return err @@ -352,6 +358,11 @@ func updateBtccheckpointGenesis(btccheckpointGenState *btccheckpointtypes.Genesi btccheckpointGenState.Params.CheckpointTag = BabylonOpReturnTag } +func updateFinalityGenesis(finalityGenState *finalitytypes.GenesisState) { + finalityGenState.Params = finalitytypes.DefaultParams() + finalityGenState.Params.FinalityActivationHeight = 0 +} + func updateGenUtilGenesis(c *internalChain) func(*genutiltypes.GenesisState) { return func(genUtilGenState *genutiltypes.GenesisState) { // generate genesis txs diff --git a/test/e2e/software_upgrade_e2e_signet_launch_test.go b/test/e2e/software_upgrade_e2e_signet_launch_test.go index a19018fe2..43b39e335 100644 --- a/test/e2e/software_upgrade_e2e_signet_launch_test.go +++ b/test/e2e/software_upgrade_e2e_signet_launch_test.go @@ -1,6 +1,9 @@ package e2e import ( + "math/rand" + "time" + sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/suite" @@ -9,6 +12,7 @@ import ( appparams "github.com/babylonlabs-io/babylon/app/params" v1 "github.com/babylonlabs-io/babylon/app/upgrades/v1" "github.com/babylonlabs-io/babylon/app/upgrades/v1/testnet" + "github.com/babylonlabs-io/babylon/testutil/datagen" btclighttypes "github.com/babylonlabs-io/babylon/x/btclightclient/types" "github.com/babylonlabs-io/babylon/test/e2e/configurer" @@ -94,13 +98,22 @@ func (s *SoftwareUpgradeV1TestnetTestSuite) TearDownSuite() { func (s *SoftwareUpgradeV1TestnetTestSuite) TestUpgradeSignetLaunch() { // chain is already upgraded, only checks for differences in state are expected chainA := s.configurer.GetChainConfig(0) - chainA.WaitUntilHeight(30) // five blocks more than upgrade - n, err := chainA.GetDefaultNode() + n, err := chainA.GetNodeAtIndex(2) s.NoError(err) govProp, err := s.configurer.ParseGovPropFromFile() s.NoError(err) + chainA.WaitUntilHeight(govProp.Plan.Height + 1) // waits for chain to produce blocks + + r := rand.New(rand.NewSource(time.Now().Unix())) + fptBTCSK, _, _ := datagen.GenRandomBTCKeyPair(r) + fp := CreateNodeFP( + s.T(), + r, + fptBTCSK, + n, + ) bbnApp := app.NewTmpBabylonApp() @@ -145,6 +158,42 @@ func (s *SoftwareUpgradeV1TestnetTestSuite) TestUpgradeSignetLaunch() { s.NoError(err) s.EqualValues(finalityParamsFromData, *finalityParams) + // FP tries to commit with start height before finality activation height + // it should fail, after commits with start height = finality activation height + // and it should work. + _, msgCommitPubRandList, err := datagen.GenRandomMsgCommitPubRandList(r, fptBTCSK, finalityParamsFromData.FinalityActivationHeight-1, finalityParamsFromData.MinPubRand) + s.NoError(err) + n.CommitPubRandList( + fp.BtcPk, + msgCommitPubRandList.StartHeight, + msgCommitPubRandList.NumPubRand, + msgCommitPubRandList.Commitment, + msgCommitPubRandList.Sig, + ) + // the tx does not fails, but it actually + // does not commits for that height. + listByHeight := n.QueryListPubRandCommit(fp.BtcPk) + _, listFound := listByHeight[finalityParamsFromData.FinalityActivationHeight] + s.False(listFound, "this list should not exists, because the msg should have failed") + + // commits with valid start height + _, msgCommitPubRandList, err = datagen.GenRandomMsgCommitPubRandList(r, fptBTCSK, finalityParamsFromData.FinalityActivationHeight, finalityParamsFromData.MinPubRand) + s.NoError(err) + n.WaitForNextBlock() + n.CommitPubRandList( + msgCommitPubRandList.FpBtcPk, + msgCommitPubRandList.StartHeight, + msgCommitPubRandList.NumPubRand, + msgCommitPubRandList.Commitment, + msgCommitPubRandList.Sig, + ) + + n.WaitForNextBlock() + + listByHeight = n.QueryListPubRandCommit(msgCommitPubRandList.FpBtcPk) + _, listFound = listByHeight[finalityParamsFromData.FinalityActivationHeight] + s.True(listFound, "this list should exists, because the msg sent is after the activation height") + // Verifies the balance differences were really executed tokenDistData, err := v1.LoadTokenDistributionFromData(testnet.TokensDistributionStr) s.NoError(err) diff --git a/testutil/keeper/finality.go b/testutil/keeper/finality.go index 1b8a2adee..bfd83ce30 100644 --- a/testutil/keeper/finality.go +++ b/testutil/keeper/finality.go @@ -46,7 +46,9 @@ func FinalityKeeper(t testing.TB, bsKeeper types.BTCStakingKeeper, iKeeper types ctx = ctx.WithHeaderInfo(header.Info{}) // Initialize params - if err := k.SetParams(ctx, types.DefaultParams()); err != nil { + dParams := types.DefaultParams() + dParams.FinalityActivationHeight = 0 + if err := k.SetParams(ctx, dParams); err != nil { panic(err) } diff --git a/x/btcstaking/keeper/power_dist_change.go b/x/btcstaking/keeper/power_dist_change.go index 6a0097ad5..0d051ff7e 100644 --- a/x/btcstaking/keeper/power_dist_change.go +++ b/x/btcstaking/keeper/power_dist_change.go @@ -19,7 +19,8 @@ import ( // UpdatePowerDist updates the voting power table and distribution cache. // This is triggered upon each `BeginBlock` func (k Keeper) UpdatePowerDist(ctx context.Context) { - height := uint64(sdk.UnwrapSDKContext(ctx).HeaderInfo().Height) + sdkCtx := sdk.UnwrapSDKContext(ctx) + height := uint64(sdkCtx.HeaderInfo().Height) btcTipHeight := k.GetCurrentBTCHeight(ctx) // get the power dist cache in the last height @@ -43,6 +44,9 @@ func (k Keeper) UpdatePowerDist(ctx context.Context) { // reconcile old voting power distribution cache and new events // to construct the new distribution + k.Logger(sdkCtx).With( + "eventsLen", len(events), + ).Info("processing voting power update events") newDc := k.ProcessAllPowerDistUpdateEvents(ctx, dc, events) // record voting power and cache for this height diff --git a/x/finality/abci.go b/x/finality/abci.go index 93ef8852a..7d2e20dd8 100644 --- a/x/finality/abci.go +++ b/x/finality/abci.go @@ -22,7 +22,7 @@ func EndBlocker(ctx context.Context, k keeper.Keeper) ([]abci.ValidatorUpdate, e // if the BTC staking protocol is activated, i.e., there exists a height where a finality provider // has voting power, start indexing and tallying blocks - if _, err := k.BTCStakingKeeper.GetBTCStakingActivatedHeight(ctx); err == nil { + if k.IsFinalityActive(ctx) { // index the current block k.IndexBlock(ctx) // tally all non-finalised blocks diff --git a/x/finality/keeper/keeper.go b/x/finality/keeper/keeper.go index d569896f9..25e3549e9 100644 --- a/x/finality/keeper/keeper.go +++ b/x/finality/keeper/keeper.go @@ -95,3 +95,14 @@ func (k Keeper) GetCurrentEpoch(ctx context.Context) uint64 { return currentEpoch.EpochNumber } + +// IsFinalityActive returns true if the finality is activated and ready +// to start handling liveness, tally and index blocks. +func (k Keeper) IsFinalityActive(ctx context.Context) (activated bool) { + if uint64(sdk.UnwrapSDKContext(ctx).HeaderInfo().Height) < k.GetParams(ctx).FinalityActivationHeight { + return false + } + + _, err := k.BTCStakingKeeper.GetBTCStakingActivatedHeight(ctx) + return err == nil +} diff --git a/x/finality/keeper/msg_server.go b/x/finality/keeper/msg_server.go index 444bdab9f..38eecb539 100644 --- a/x/finality/keeper/msg_server.go +++ b/x/finality/keeper/msg_server.go @@ -53,9 +53,13 @@ func (ms msgServer) AddFinalitySig(goCtx context.Context, req *types.MsgAddFinal return nil, err } - fpPK := req.FpBtcPk - ctx := sdk.UnwrapSDKContext(goCtx) + activationHeight, errMod := ms.validateActivationHeight(ctx, req.BlockHeight) + if errMod != nil { + return nil, errMod.Wrapf("finality block height: %d is lower than activation height %d", req.BlockHeight, activationHeight) + } + + fpPK := req.FpBtcPk // ensure the finality provider exists fp, err := ms.BTCStakingKeeper.GetFinalityProvider(ctx, req.FpBtcPk.MustMarshal()) @@ -188,6 +192,13 @@ func (ms msgServer) CommitPubRandList(goCtx context.Context, req *types.MsgCommi defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), types.MetricsKeyCommitPubRandList) ctx := sdk.UnwrapSDKContext(goCtx) + activationHeight, errMod := ms.validateActivationHeight(ctx, req.StartHeight) + if errMod != nil { + return nil, types.ErrFinalityNotActivated.Wrapf( + "public rand commit start block height: %d is lower than activation height %d", + req.StartHeight, activationHeight, + ) + } // ensure the request contains enough number of public randomness minPubRand := ms.GetParams(ctx).MinPubRand @@ -303,3 +314,18 @@ func (k Keeper) slashFinalityProvider(ctx context.Context, fpBtcPk *bbn.BIP340Pu panic(fmt.Errorf("failed to emit EventSlashedFinalityProvider event: %w", err)) } } + +// validateActivationHeight returns error if the height received is lower than the finality +// activation block height +func (ms msgServer) validateActivationHeight(ctx sdk.Context, height uint64) (uint64, *errorsmod.Error) { + // TODO: remove it after Phase-2 launch in a future coordinated upgrade + activationHeight := ms.GetParams(ctx).FinalityActivationHeight + if height < activationHeight { + ms.Logger(ctx).With( + "height", height, + "activationHeight", activationHeight, + ).Info("BTC finality is not activated yet") + return activationHeight, types.ErrFinalityNotActivated + } + return activationHeight, nil +} diff --git a/x/finality/keeper/msg_server_test.go b/x/finality/keeper/msg_server_test.go index 7445e103c..224dcd343 100644 --- a/x/finality/keeper/msg_server_test.go +++ b/x/finality/keeper/msg_server_test.go @@ -444,3 +444,46 @@ func TestDoNotPanicOnNilProof(t *testing.T) { _, err = ms.AddFinalitySig(ctx, msg) require.Error(t, err) } + +func TestVerifyActivationHeight(t *testing.T) { + r := rand.New(rand.NewSource(time.Now().Unix())) + fKeeper, ctx := keepertest.FinalityKeeper(t, nil, nil, nil) + ms := keeper.NewMsgServerImpl(*fKeeper) + err := fKeeper.SetParams(ctx, types.DefaultParams()) + require.NoError(t, err) + activationHeight := fKeeper.GetParams(ctx).FinalityActivationHeight + + // checks pub rand commit + btcSK, _, err := datagen.GenRandomBTCKeyPair(r) + require.NoError(t, err) + startHeight := activationHeight - 1 + numPubRand := uint64(200) + randListInfo, msgCommitPubRandList, err := datagen.GenRandomMsgCommitPubRandList(r, btcSK, startHeight, numPubRand) + require.NoError(t, err) + + _, err = ms.CommitPubRandList(ctx, msgCommitPubRandList) + require.EqualError(t, err, types.ErrFinalityNotActivated.Wrapf( + "public rand commit start block height: %d is lower than activation height %d", + startHeight, activationHeight, + ).Error()) + + // check finality vote + blockHeight := activationHeight - 1 + blockAppHash := datagen.GenRandomByteArray(r, 32) + signer := datagen.GenRandomAccount().Address + msgFinality, err := datagen.NewMsgAddFinalitySig( + signer, + btcSK, + startHeight, + blockHeight, + randListInfo, + blockAppHash, + ) + require.NoError(t, err) + + _, err = ms.AddFinalitySig(ctx, msgFinality) + require.EqualError(t, err, types.ErrFinalityNotActivated.Wrapf( + "finality block height: %d is lower than activation height %d", + blockHeight, activationHeight, + ).Error()) +} diff --git a/x/finality/types/errors.go b/x/finality/types/errors.go index e7ffc6877..8ae4bcdd2 100644 --- a/x/finality/types/errors.go +++ b/x/finality/types/errors.go @@ -19,4 +19,5 @@ var ( ErrNoSlashableEvidence = errorsmod.Register(ModuleName, 1110, "there is no slashable evidence") ErrPubRandCommitNotBTCTimestamped = errorsmod.Register(ModuleName, 1111, "the public randomness commit is not BTC timestamped yet") ErrJailingPeriodNotPassed = errorsmod.Register(ModuleName, 1112, "the jailing period is not passed") + ErrFinalityNotActivated = errorsmod.Register(ModuleName, 1113, "finality is not active yet") ) diff --git a/x/finality/types/params.go b/x/finality/types/params.go index 1bf540a06..2575f4f06 100644 --- a/x/finality/types/params.go +++ b/x/finality/types/params.go @@ -15,6 +15,13 @@ const ( DefaultMinPubRand = 100 DefaultFinalitySigTimeout = 3 DefaultJailDuration = 24 * 60 * 60 * 1 * time.Second // 1 day + // For mainnet considering we want 48 hours + // at a block time of 10s that would be 17280 blocks + // considering the upgrade for Phase-2 will happen at block + // 220, the mainnet activation height for btcstaking should + // be 17280 + 220 = 17500. + // For now it is set to 1 to avoid breaking dependencies. + DefaultFinalityActivationHeight = 1 ) var ( @@ -26,11 +33,12 @@ var _ paramtypes.ParamSet = (*Params)(nil) // DefaultParams returns a default set of parameters func DefaultParams() Params { return Params{ - FinalitySigTimeout: DefaultFinalitySigTimeout, - SignedBlocksWindow: DefaultSignedBlocksWindow, - MinSignedPerWindow: DefaultMinSignedPerWindow, - MinPubRand: DefaultMinPubRand, - JailDuration: DefaultJailDuration, + FinalitySigTimeout: DefaultFinalitySigTimeout, + SignedBlocksWindow: DefaultSignedBlocksWindow, + MinSignedPerWindow: DefaultMinSignedPerWindow, + MinPubRand: DefaultMinPubRand, + JailDuration: DefaultJailDuration, + FinalityActivationHeight: DefaultFinalityActivationHeight, } } @@ -53,6 +61,7 @@ func (p Params) String() string { } // Validate validates the params +// finality activation height can be any value, even 0. func (p Params) Validate() error { if err := validateSignedBlocksWindow(p.SignedBlocksWindow); err != nil { return err diff --git a/x/finality/types/params.pb.go b/x/finality/types/params.pb.go index 1fe6ea1a4..12df641e1 100644 --- a/x/finality/types/params.pb.go +++ b/x/finality/types/params.pb.go @@ -45,6 +45,10 @@ type Params struct { MinPubRand uint64 `protobuf:"varint,4,opt,name=min_pub_rand,json=minPubRand,proto3" json:"min_pub_rand,omitempty"` // jail_duration is the minimum period of time that a finality provider remains jailed JailDuration time.Duration `protobuf:"bytes,5,opt,name=jail_duration,json=jailDuration,proto3,stdduration" json:"jail_duration"` + // finality_activation_height is the babylon block height which the finality module will + // start to accept finality voting and the minimum allowed value for the public randomness + // commit start height. + FinalityActivationHeight uint64 `protobuf:"varint,6,opt,name=finality_activation_height,json=finalityActivationHeight,proto3" json:"finality_activation_height,omitempty"` } func (m *Params) Reset() { *m = Params{} } @@ -107,6 +111,13 @@ func (m *Params) GetJailDuration() time.Duration { return 0 } +func (m *Params) GetFinalityActivationHeight() uint64 { + if m != nil { + return m.FinalityActivationHeight + } + return 0 +} + func init() { proto.RegisterType((*Params)(nil), "babylon.finality.v1.Params") } @@ -114,34 +125,36 @@ func init() { func init() { proto.RegisterFile("babylon/finality/v1/params.proto", fileDescriptor_25539c9a61c72ee9) } var fileDescriptor_25539c9a61c72ee9 = []byte{ - // 420 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x44, 0x92, 0x31, 0x6f, 0xd4, 0x30, - 0x14, 0xc7, 0xe3, 0xf6, 0xe8, 0x10, 0xae, 0x03, 0xa1, 0x48, 0xd7, 0x22, 0xe5, 0x22, 0xa6, 0x13, - 0x52, 0x6d, 0x5a, 0x24, 0x06, 0xc6, 0xd3, 0x8d, 0x45, 0x3a, 0x5d, 0x91, 0x90, 0x58, 0x22, 0x3b, - 0x71, 0xdd, 0x47, 0x63, 0xbf, 0x28, 0x4e, 0x5a, 0xf2, 0x2d, 0x18, 0x3b, 0x32, 0x32, 0x32, 0xf0, - 0x21, 0x3a, 0xa1, 0x8a, 0x09, 0x31, 0x1c, 0xe8, 0x6e, 0xe0, 0x6b, 0xa0, 0xc4, 0xb1, 0x58, 0xa2, - 0xbc, 0xfc, 0xfe, 0x2f, 0xff, 0xff, 0x7b, 0x76, 0x98, 0x08, 0x2e, 0xda, 0x02, 0x0d, 0xbb, 0x00, - 0xc3, 0x0b, 0xa8, 0x5b, 0x76, 0x7d, 0xc2, 0x4a, 0x5e, 0x71, 0x6d, 0x69, 0x59, 0x61, 0x8d, 0xd1, - 0xe3, 0x41, 0x41, 0xbd, 0x82, 0x5e, 0x9f, 0x1c, 0x1d, 0x28, 0x54, 0xd8, 0x73, 0xd6, 0xbd, 0x39, - 0xe9, 0xd1, 0x23, 0xae, 0xc1, 0x20, 0xeb, 0x9f, 0xc3, 0xa7, 0xc3, 0x0c, 0xad, 0x46, 0x9b, 0x3a, - 0xad, 0x2b, 0x06, 0x14, 0x2b, 0x44, 0x55, 0x48, 0xd6, 0x57, 0xa2, 0xb9, 0x60, 0x79, 0x53, 0xf1, - 0x1a, 0xd0, 0x38, 0xfe, 0xec, 0xfb, 0x4e, 0xb8, 0xb7, 0xec, 0x93, 0x44, 0x2f, 0xc2, 0x03, 0x0b, - 0xca, 0xc8, 0x3c, 0x15, 0x05, 0x66, 0x57, 0x36, 0xbd, 0x01, 0x93, 0xe3, 0xcd, 0x84, 0x24, 0x64, - 0xb6, 0xbb, 0x8a, 0x1c, 0x9b, 0xf7, 0xe8, 0x5d, 0x4f, 0xba, 0x0e, 0x9f, 0x37, 0xb5, 0xa0, 0xd2, - 0x1a, 0xb4, 0xc4, 0xa6, 0x9e, 0xec, 0xb8, 0x0e, 0xcf, 0xce, 0x41, 0xbd, 0x75, 0x24, 0x82, 0xf0, - 0x89, 0x06, 0x93, 0x0e, 0x3e, 0xa5, 0xac, 0xbc, 0xc9, 0x6e, 0x42, 0x66, 0xe3, 0xf9, 0xab, 0xbb, - 0xf5, 0x34, 0xf8, 0xb5, 0x9e, 0x3e, 0x75, 0x33, 0xd8, 0xfc, 0x8a, 0x02, 0x32, 0xcd, 0xeb, 0x4b, - 0x7a, 0x26, 0x15, 0xcf, 0xda, 0x85, 0xcc, 0x7e, 0x7c, 0x3b, 0x0e, 0x87, 0x11, 0x17, 0x32, 0xfb, - 0xf2, 0xf7, 0xeb, 0x73, 0xb2, 0x8a, 0x34, 0x98, 0xf3, 0xfe, 0x9f, 0x4b, 0x59, 0x0d, 0xe1, 0x92, - 0x70, 0xdc, 0x59, 0x95, 0x8d, 0x48, 0x2b, 0x6e, 0xf2, 0xc9, 0x28, 0x21, 0xb3, 0xd1, 0x2a, 0xd4, - 0x60, 0x96, 0x8d, 0x58, 0x71, 0x93, 0x47, 0x6f, 0xc2, 0xfd, 0x0f, 0x1c, 0x8a, 0xd4, 0xaf, 0x64, - 0xf2, 0x20, 0x21, 0xb3, 0x87, 0xa7, 0x87, 0xd4, 0xed, 0x8c, 0xfa, 0x9d, 0xd1, 0xc5, 0x20, 0x98, - 0xef, 0x77, 0xf9, 0x6e, 0x7f, 0x4f, 0x89, 0xb3, 0x1d, 0x77, 0xed, 0x1e, 0xbe, 0x1e, 0xdd, 0x7e, - 0x9e, 0x06, 0xf3, 0xb3, 0xbb, 0x4d, 0x4c, 0xee, 0x37, 0x31, 0xf9, 0xb3, 0x89, 0xc9, 0xa7, 0x6d, - 0x1c, 0xdc, 0x6f, 0xe3, 0xe0, 0xe7, 0x36, 0x0e, 0xde, 0x9f, 0x2a, 0xa8, 0x2f, 0x1b, 0x41, 0x33, - 0xd4, 0x6c, 0x38, 0xee, 0x82, 0x0b, 0x7b, 0x0c, 0xe8, 0x4b, 0xf6, 0xf1, 0xff, 0x0d, 0xa9, 0xdb, - 0x52, 0x5a, 0xb1, 0xd7, 0x67, 0x78, 0xf9, 0x2f, 0x00, 0x00, 0xff, 0xff, 0xf4, 0xd4, 0xa2, 0x2b, - 0x42, 0x02, 0x00, 0x00, + // 450 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x44, 0x92, 0x31, 0x8f, 0xd3, 0x30, + 0x14, 0xc7, 0x6b, 0x5a, 0x3a, 0x84, 0xde, 0x40, 0x38, 0xa4, 0x5c, 0x91, 0xd2, 0x88, 0xa9, 0x42, + 0xba, 0x98, 0x3b, 0x24, 0x06, 0xc4, 0x42, 0xd5, 0x81, 0xe1, 0x90, 0xaa, 0x1e, 0x12, 0x12, 0x4b, + 0x64, 0x27, 0x3e, 0xf7, 0x71, 0xb1, 0x1d, 0xc5, 0x4e, 0x8f, 0x7e, 0x07, 0x06, 0xc6, 0x1b, 0x19, + 0x19, 0x19, 0xf8, 0x10, 0x37, 0x9e, 0x98, 0x10, 0xc3, 0x81, 0xda, 0x81, 0xaf, 0x81, 0x62, 0xc7, + 0xc7, 0x12, 0xe5, 0xf9, 0xf7, 0x7f, 0xfe, 0xbf, 0xf7, 0x97, 0x83, 0x84, 0x12, 0xba, 0x29, 0x95, + 0xc4, 0x67, 0x20, 0x49, 0x09, 0x66, 0x83, 0xd7, 0x47, 0xb8, 0x22, 0x35, 0x11, 0x3a, 0xad, 0x6a, + 0x65, 0x54, 0xf8, 0xa0, 0x53, 0xa4, 0x5e, 0x91, 0xae, 0x8f, 0xc6, 0xfb, 0x5c, 0x71, 0x65, 0x39, + 0x6e, 0xff, 0x9c, 0x74, 0x7c, 0x9f, 0x08, 0x90, 0x0a, 0xdb, 0x6f, 0x77, 0x74, 0x90, 0x2b, 0x2d, + 0x94, 0xce, 0x9c, 0xd6, 0x15, 0x1d, 0x8a, 0xb9, 0x52, 0xbc, 0x64, 0xd8, 0x56, 0xb4, 0x39, 0xc3, + 0x45, 0x53, 0x13, 0x03, 0x4a, 0x3a, 0xfe, 0xf8, 0x53, 0x3f, 0x18, 0x2e, 0xec, 0x24, 0xe1, 0xd3, + 0x60, 0x5f, 0x03, 0x97, 0xac, 0xc8, 0x68, 0xa9, 0xf2, 0x73, 0x9d, 0x5d, 0x80, 0x2c, 0xd4, 0x45, + 0x84, 0x12, 0x34, 0xed, 0x2f, 0x43, 0xc7, 0x66, 0x16, 0xbd, 0xb3, 0xa4, 0xed, 0xf0, 0xf3, 0x66, + 0x1a, 0x78, 0x66, 0x40, 0x30, 0xd5, 0x98, 0xe8, 0x8e, 0xeb, 0xf0, 0xec, 0x14, 0xf8, 0x5b, 0x47, + 0x42, 0x08, 0x1e, 0x0a, 0x90, 0x59, 0xe7, 0x53, 0xb1, 0xda, 0x9b, 0xf4, 0x13, 0x34, 0x1d, 0xcd, + 0x9e, 0x5f, 0xdd, 0x4c, 0x7a, 0xbf, 0x6e, 0x26, 0x8f, 0xdc, 0x0e, 0xba, 0x38, 0x4f, 0x41, 0x61, + 0x41, 0xcc, 0x2a, 0x3d, 0x61, 0x9c, 0xe4, 0x9b, 0x39, 0xcb, 0x7f, 0x7c, 0x3f, 0x0c, 0xba, 0x15, + 0xe7, 0x2c, 0xff, 0xfa, 0xf7, 0xdb, 0x13, 0xb4, 0x0c, 0x05, 0xc8, 0x53, 0x7b, 0xe7, 0x82, 0xd5, + 0xdd, 0x70, 0x49, 0x30, 0x6a, 0xad, 0xaa, 0x86, 0x66, 0x35, 0x91, 0x45, 0x34, 0x48, 0xd0, 0x74, + 0xb0, 0x0c, 0x04, 0xc8, 0x45, 0x43, 0x97, 0x44, 0x16, 0xe1, 0x9b, 0x60, 0xef, 0x03, 0x81, 0x32, + 0xf3, 0x91, 0x44, 0x77, 0x13, 0x34, 0xbd, 0x77, 0x7c, 0x90, 0xba, 0xcc, 0x52, 0x9f, 0x59, 0x3a, + 0xef, 0x04, 0xb3, 0xbd, 0x76, 0xbe, 0xcb, 0xdf, 0x13, 0xe4, 0x6c, 0x47, 0x6d, 0xbb, 0x87, 0xe1, + 0xcb, 0x60, 0x7c, 0x9b, 0x06, 0xc9, 0x0d, 0xac, 0xed, 0x71, 0xb6, 0x62, 0xc0, 0x57, 0x26, 0x1a, + 0x5a, 0xfb, 0xc8, 0x2b, 0x5e, 0xdd, 0x0a, 0x5e, 0x5b, 0xfe, 0x62, 0x70, 0xf9, 0x65, 0xd2, 0x9b, + 0x9d, 0x5c, 0x6d, 0x63, 0x74, 0xbd, 0x8d, 0xd1, 0x9f, 0x6d, 0x8c, 0x3e, 0xef, 0xe2, 0xde, 0xf5, + 0x2e, 0xee, 0xfd, 0xdc, 0xc5, 0xbd, 0xf7, 0xc7, 0x1c, 0xcc, 0xaa, 0xa1, 0x69, 0xae, 0x04, 0xee, + 0x1e, 0x4b, 0x49, 0xa8, 0x3e, 0x04, 0xe5, 0x4b, 0xfc, 0xf1, 0xff, 0xfb, 0x32, 0x9b, 0x8a, 0x69, + 0x3a, 0xb4, 0x1b, 0x3c, 0xfb, 0x17, 0x00, 0x00, 0xff, 0xff, 0xd2, 0xae, 0x74, 0x01, 0x80, 0x02, + 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -164,6 +177,11 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.FinalityActivationHeight != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.FinalityActivationHeight)) + i-- + dAtA[i] = 0x30 + } n1, err1 := github_com_cosmos_gogoproto_types.StdDurationMarshalTo(m.JailDuration, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.JailDuration):]) if err1 != nil { return 0, err1 @@ -230,6 +248,9 @@ func (m *Params) Size() (n int) { } l = github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.JailDuration) n += 1 + l + sovParams(uint64(l)) + if m.FinalityActivationHeight != 0 { + n += 1 + sovParams(uint64(m.FinalityActivationHeight)) + } return n } @@ -391,6 +412,25 @@ func (m *Params) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field FinalityActivationHeight", wireType) + } + m.FinalityActivationHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.FinalityActivationHeight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipParams(dAtA[iNdEx:])