diff --git a/CHANGELOG.md b/CHANGELOG.md index a46048b82..db8f31ad1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ## Unreleased +### State Machine Breaking + +* [#181](https://github.com/babylonlabs-io/babylon/pull/181) Modify BTC heights + and depths to be of uint32 type instead of uint64. + ### Bug fixes * [#180](https://github.com/babylonlabs-io/babylon/pull/180) Non-determinism in diff --git a/btcstaking/types.go b/btcstaking/types.go index d6dc68f8c..482238035 100644 --- a/btcstaking/types.go +++ b/btcstaking/types.go @@ -616,6 +616,8 @@ func BuildRelativeTimelockTaprootScript( // ParseBlkHeightAndPubKeyFromStoreKey expects to receive a key with // BigEndianUint64(blkHeight) || BIP340PubKey(fpBTCPK) +// TODO: this function should not be in the btcstaking library +// it is related to our internal cosmos sdk storage func ParseBlkHeightAndPubKeyFromStoreKey(key []byte) (blkHeight uint64, fpBTCPK *bbn.BIP340PubKey, err error) { sizeBigEndian := 8 if len(key) < sizeBigEndian+1 { diff --git a/cmd/babylond/cmd/flags.go b/cmd/babylond/cmd/flags.go index 899f1d1b1..3c03e2c8e 100644 --- a/cmd/babylond/cmd/flags.go +++ b/cmd/babylond/cmd/flags.go @@ -52,12 +52,12 @@ const ( type GenesisCLIArgs struct { ChainID string MaxActiveValidators uint32 - BtcConfirmationDepth uint64 - BtcFinalizationTimeout uint64 + BtcConfirmationDepth uint32 + BtcFinalizationTimeout uint32 CheckpointTag string EpochInterval uint64 BaseBtcHeaderHex string - BaseBtcHeaderHeight uint64 + BaseBtcHeaderHeight uint32 AllowedReporterAddresses []string InflationRateChange float64 InflationMax float64 @@ -87,8 +87,8 @@ func addGenesisFlags(cmd *cobra.Command) { // staking flags cmd.Flags().Uint32(flagMaxActiveValidators, 10, "Maximum number of validators.") // btccheckpoint flags - cmd.Flags().Uint64(flagBtcConfirmationDepth, 6, "Confirmation depth for Bitcoin headers.") - cmd.Flags().Uint64(flagBtcFinalizationTimeout, 20, "Finalization timeout for Bitcoin headers.") + cmd.Flags().Uint32(flagBtcConfirmationDepth, 6, "Confirmation depth for Bitcoin headers.") + cmd.Flags().Uint32(flagBtcFinalizationTimeout, 20, "Finalization timeout for Bitcoin headers.") cmd.Flags().String(flagCheckpointTag, btcctypes.DefaultCheckpointTag, "Hex encoded tag for babylon checkpoint on btc") // epoch args cmd.Flags().Uint64(flagEpochInterval, 400, "Number of blocks between epochs. Must be more than 0.") @@ -96,7 +96,7 @@ func addGenesisFlags(cmd *cobra.Command) { // Genesis header for the simnet cmd.Flags().String(flagBaseBtcHeaderHex, "0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a45068653ffff7f2002000000", "Hex of the base Bitcoin header.") cmd.Flags().String(flagAllowedReporterAddresses, strings.Join(btcltypes.DefaultParams().InsertHeadersAllowList, ","), "addresses of reporters allowed to submit Bitcoin headers to babylon") - cmd.Flags().Uint64(flagBaseBtcHeaderHeight, 0, "Height of the base Bitcoin header.") + cmd.Flags().Uint32(flagBaseBtcHeaderHeight, 0, "Height of the base Bitcoin header.") // btcstaking args cmd.Flags().String(flagCovenantPks, strings.Join(btcstypes.DefaultParams().CovenantPksHex(), ","), "Bitcoin staking covenant public keys, comma separated") cmd.Flags().Uint32(flagCovenantQuorum, btcstypes.DefaultParams().CovenantQuorum, "Bitcoin staking covenant quorum") @@ -127,12 +127,12 @@ func addGenesisFlags(cmd *cobra.Command) { func parseGenesisFlags(cmd *cobra.Command) *GenesisCLIArgs { chainID, _ := cmd.Flags().GetString(flags.FlagChainID) maxActiveValidators, _ := cmd.Flags().GetUint32(flagMaxActiveValidators) - btcConfirmationDepth, _ := cmd.Flags().GetUint64(flagBtcConfirmationDepth) - btcFinalizationTimeout, _ := cmd.Flags().GetUint64(flagBtcFinalizationTimeout) + btcConfirmationDepth, _ := cmd.Flags().GetUint32(flagBtcConfirmationDepth) + btcFinalizationTimeout, _ := cmd.Flags().GetUint32(flagBtcFinalizationTimeout) checkpointTag, _ := cmd.Flags().GetString(flagCheckpointTag) epochInterval, _ := cmd.Flags().GetUint64(flagEpochInterval) baseBtcHeaderHex, _ := cmd.Flags().GetString(flagBaseBtcHeaderHex) - baseBtcHeaderHeight, _ := cmd.Flags().GetUint64(flagBaseBtcHeaderHeight) + baseBtcHeaderHeight, _ := cmd.Flags().GetUint32(flagBaseBtcHeaderHeight) reporterAddresses, _ := cmd.Flags().GetString(flagAllowedReporterAddresses) covenantPks, _ := cmd.Flags().GetString(flagCovenantPks) covenantQuorum, _ := cmd.Flags().GetUint32(flagCovenantQuorum) diff --git a/cmd/babylond/cmd/genesis.go b/cmd/babylond/cmd/genesis.go index 5babd4f31..71784cc90 100644 --- a/cmd/babylond/cmd/genesis.go +++ b/cmd/babylond/cmd/genesis.go @@ -265,12 +265,12 @@ type GenesisParams struct { func TestnetGenesisParams( maxActiveValidators uint32, - btcConfirmationDepth uint64, - btcFinalizationTimeout uint64, + btcConfirmationDepth uint32, + btcFinalizationTimeout uint32, checkpointTag string, epochInterval uint64, baseBtcHeaderHex string, - baseBtcHeaderHeight uint64, + baseBtcHeaderHeight uint32, allowedReporters []string, covenantPKs []string, covenantQuorum uint32, diff --git a/cmd/babylond/cmd/genhelpers/set_btc_delegations_test.go b/cmd/babylond/cmd/genhelpers/set_btc_delegations_test.go index dde1d54a7..7e0a2c6e2 100644 --- a/cmd/babylond/cmd/genhelpers/set_btc_delegations_test.go +++ b/cmd/babylond/cmd/genhelpers/set_btc_delegations_test.go @@ -67,8 +67,8 @@ func FuzzCmdSetBtcDels(f *testing.F) { slashingPkScript, err := txscript.PayToAddrScript(slashingAddress) require.NoError(t, err) - startHeight := datagen.RandomInt(r, 100) + 1 - endHeight := datagen.RandomInt(r, 1000) + startHeight + btcctypes.DefaultParams().CheckpointFinalizationTimeout + 1 + startHeight := uint32(datagen.RandomInt(r, 100)) + 1 + endHeight := uint32(datagen.RandomInt(r, 1000)) + startHeight + btcctypes.DefaultParams().CheckpointFinalizationTimeout + 1 slashingRate := sdkmath.LegacyNewDecWithPrec(int64(datagen.RandomInt(r, 41)+10), 2) slashingChangeLockTime := uint16(101) diff --git a/cmd/babylond/cmd/testnet.go b/cmd/babylond/cmd/testnet.go index 2e26b57b6..64e2ad368 100644 --- a/cmd/babylond/cmd/testnet.go +++ b/cmd/babylond/cmd/testnet.go @@ -3,7 +3,6 @@ package cmd import ( "bufio" "encoding/json" - "errors" "fmt" "net" "os" @@ -88,9 +87,6 @@ Example: btcNetwork, _ := cmd.Flags().GetString(flagBtcNetwork) additionalAccount, _ := cmd.Flags().GetBool(flagAdditionalSenderAccount) timeBetweenBlocks, _ := cmd.Flags().GetUint64(flagTimeBetweenBlocks) - if err != nil { - return errors.New("base Bitcoin header height should be a uint64") - } genesisParams := TestnetGenesisParams( genesisCliArgs.MaxActiveValidators, diff --git a/proto/babylon/btccheckpoint/v1/btccheckpoint.proto b/proto/babylon/btccheckpoint/v1/btccheckpoint.proto index 70b3b5aeb..693991548 100644 --- a/proto/babylon/btccheckpoint/v1/btccheckpoint.proto +++ b/proto/babylon/btccheckpoint/v1/btccheckpoint.proto @@ -138,7 +138,7 @@ message BTCCheckpointInfo { // epoch number of this checkpoint uint64 epoch_number = 1; // btc height of the best submission of the epoch - uint64 best_submission_btc_block_height = 2; + uint32 best_submission_btc_block_height = 2; // hash of the btc block which determines checkpoint btc block height i.e. // youngest block of best submission bytes best_submission_btc_block_hash = 3 diff --git a/proto/babylon/btccheckpoint/v1/params.proto b/proto/babylon/btccheckpoint/v1/params.proto index 3315aa03d..a1af891d1 100644 --- a/proto/babylon/btccheckpoint/v1/params.proto +++ b/proto/babylon/btccheckpoint/v1/params.proto @@ -12,7 +12,7 @@ message Params { // btc_confirmation_depth is the confirmation depth in BTC. // A block is considered irreversible only when it is at least k-deep in BTC // (k in research paper) - uint64 btc_confirmation_depth = 1 + uint32 btc_confirmation_depth = 1 [ (gogoproto.moretags) = "yaml:\"btc_confirmation_depth\"" ]; // checkpoint_finalization_timeout is the maximum time window (measured in BTC @@ -21,7 +21,7 @@ message Params { // - being reported back to BBN // If a checkpoint has not been reported back within w BTC blocks, then BBN // has dishonest majority and is stalling checkpoints (w in research paper) - uint64 checkpoint_finalization_timeout = 2 + uint32 checkpoint_finalization_timeout = 2 [ (gogoproto.moretags) = "yaml:\"checkpoint_finalization_timeout\"" ]; // 4byte tag in hex format, required to be present in the OP_RETURN transaction diff --git a/proto/babylon/btccheckpoint/v1/query.proto b/proto/babylon/btccheckpoint/v1/query.proto index d7ee344ef..dd63f1ca6 100644 --- a/proto/babylon/btccheckpoint/v1/query.proto +++ b/proto/babylon/btccheckpoint/v1/query.proto @@ -92,7 +92,7 @@ message BTCCheckpointInfoResponse { // EpochNumber of this checkpoint. uint64 epoch_number = 1; // btc height of the best submission of the epoch - uint64 best_submission_btc_block_height = 2; + uint32 best_submission_btc_block_height = 2; // hash of the btc block which determines checkpoint btc block height i.e. // youngest block of best submission Hexadecimal string best_submission_btc_block_hash = 3; diff --git a/proto/babylon/btclightclient/v1/btclightclient.proto b/proto/babylon/btclightclient/v1/btclightclient.proto index d38314f3d..395e26027 100644 --- a/proto/babylon/btclightclient/v1/btclightclient.proto +++ b/proto/babylon/btclightclient/v1/btclightclient.proto @@ -20,7 +20,7 @@ message BTCHeaderInfo { bytes hash = 2 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BTCHeaderHashBytes" ]; - uint64 height = 3; + uint32 height = 3; bytes work = 4 [ (gogoproto.customtype) = "cosmossdk.io/math.Uint" ]; } diff --git a/proto/babylon/btclightclient/v1/query.proto b/proto/babylon/btclightclient/v1/query.proto index 51ea46cf1..50cdead4e 100644 --- a/proto/babylon/btclightclient/v1/query.proto +++ b/proto/babylon/btclightclient/v1/query.proto @@ -133,7 +133,7 @@ message QueryHeaderDepthRequest { string hash = 1; } // QueryMainChainDepthResponse is the response type for the Query/MainChainDepth RPC // it contains depth of the block in main chain -message QueryHeaderDepthResponse { uint64 depth = 1; } +message QueryHeaderDepthResponse { uint32 depth = 1; } // BTCHeaderInfoResponse is a structure that contains all relevant information about a // BTC header response @@ -146,7 +146,7 @@ message QueryHeaderDepthResponse { uint64 depth = 1; } message BTCHeaderInfoResponse { string header_hex = 1; string hash_hex = 2; - uint64 height = 3; + uint32 height = 3; // Work is the sdkmath.Uint as string. string work = 4 [ (cosmos_proto.scalar) = "cosmos.Uint", diff --git a/proto/babylon/btcstaking/v1/btcstaking.proto b/proto/babylon/btcstaking/v1/btcstaking.proto index be43008d3..87fc45bfe 100644 --- a/proto/babylon/btcstaking/v1/btcstaking.proto +++ b/proto/babylon/btcstaking/v1/btcstaking.proto @@ -33,7 +33,7 @@ message FinalityProvider { // slashed_btc_height indicates the BTC height when // the finality provider is slashed. // if it's 0 then the finality provider is not slashed - uint64 slashed_btc_height = 7; + uint32 slashed_btc_height = 7; // jailed defines whether the finality provider is jailed bool jailed = 8; } @@ -54,7 +54,7 @@ message FinalityProviderWithMeta { // slashed_btc_height indicates the BTC height when // the finality provider is slashed. // if it's 0 then the finality provider is not slashed - uint64 slashed_btc_height = 5; + uint32 slashed_btc_height = 5; // jailed defines whether the finality provider is detected jailed bool jailed = 6; } @@ -77,10 +77,10 @@ message BTCDelegation { uint32 staking_time = 5; // start_height is the start BTC height of the BTC delegation // it is the start BTC height of the timelock - uint64 start_height = 6; + uint32 start_height = 6; // end_height is the end height of the BTC delegation // it is calculated by end_height = start_height + staking_time - uint64 end_height = 7; + uint32 end_height = 7; // total_sat is the total amount of BTC stakes in this delegation // quantified in satoshi uint64 total_sat = 8; diff --git a/proto/babylon/btcstaking/v1/genesis.proto b/proto/babylon/btcstaking/v1/genesis.proto index 2e5d5966e..203122d0b 100644 --- a/proto/babylon/btcstaking/v1/genesis.proto +++ b/proto/babylon/btcstaking/v1/genesis.proto @@ -54,7 +54,7 @@ message BlockHeightBbnToBtc { // block_height_bbn is the height of the block in the babylon chain. uint64 block_height_bbn = 1; // block_height_btc is the height of the block in the BTC. - uint64 block_height_btc = 2; + uint32 block_height_btc = 2; } // BTCDelegator BTC delegator information with the associated finality provider. @@ -72,7 +72,7 @@ message EventIndex { // idx is the index the event was stored. uint64 idx = 1; // block_height_btc is the height of the block in the BTC chain. - uint64 block_height_btc = 2; + uint32 block_height_btc = 2; // event the event stored. EventPowerDistUpdate event = 3; } diff --git a/proto/babylon/btcstaking/v1/query.proto b/proto/babylon/btcstaking/v1/query.proto index 95ce627dd..176c15b72 100644 --- a/proto/babylon/btcstaking/v1/query.proto +++ b/proto/babylon/btcstaking/v1/query.proto @@ -253,10 +253,10 @@ message BTCDelegationResponse { repeated bytes fp_btc_pk_list = 3 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340PubKey" ]; // start_height is the start BTC height of the BTC delegation // it is the start BTC height of the timelock - uint64 start_height = 4; + uint32 start_height = 4; // end_height is the end height of the BTC delegation // it is the end BTC height of the timelock - w - uint64 end_height = 5; + uint32 end_height = 5; // total_sat is the total amount of BTC stakes in this delegation // quantified in satoshi uint64 total_sat = 6; @@ -344,7 +344,7 @@ message FinalityProviderResponse { // slashed_btc_height indicates the BTC height when // the finality provider is slashed. // if it's 0 then the finality provider is not slashed - uint64 slashed_btc_height = 7; + uint32 slashed_btc_height = 7; // height is the queried Babylon height uint64 height = 8; // voting_power is the voting power of this finality provider at the given height diff --git a/proto/babylon/monitor/v1/query.proto b/proto/babylon/monitor/v1/query.proto index c77bfc8f2..2f102eea1 100644 --- a/proto/babylon/monitor/v1/query.proto +++ b/proto/babylon/monitor/v1/query.proto @@ -30,7 +30,7 @@ message QueryEndedEpochBtcHeightRequest { uint64 epoch_num = 1; } // EndedEpochBtcHeight RPC method message QueryEndedEpochBtcHeightResponse { // height of btc light client when epoch ended - uint64 btc_light_client_height = 1; + uint32 btc_light_client_height = 1; } // QueryReportedCheckpointBtcHeightRequest defines a query type for @@ -44,5 +44,5 @@ message QueryReportedCheckpointBtcHeightRequest { // ReportedCheckpointBtcHeight RPC method message QueryReportedCheckpointBtcHeightResponse { // height of btc light client when checkpoint is reported - uint64 btc_light_client_height = 1; + uint32 btc_light_client_height = 1; } diff --git a/test/e2e/btc_timestamping_e2e_test.go b/test/e2e/btc_timestamping_e2e_test.go index e55b43c60..09a9f35e2 100644 --- a/test/e2e/btc_timestamping_e2e_test.go +++ b/test/e2e/btc_timestamping_e2e_test.go @@ -67,7 +67,7 @@ func (s *BTCTimestampingTestSuite) Test1ConnectIbc() { func (s *BTCTimestampingTestSuite) Test2BTCBaseHeader() { hardcodedHeader, _ := bbn.NewBTCHeaderBytesFromHex("0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a45068653ffff7f2002000000") - hardcodedHeaderHeight := uint64(0) + hardcodedHeaderHeight := uint32(0) chainA := s.configurer.GetChainConfig(0) nonValidatorNode, err := chainA.GetNodeAtIndex(2) @@ -97,12 +97,12 @@ func (s *BTCTimestampingTestSuite) Test3SendTx() { // check that light client properly updates its state tip1Depth, err := nonValidatorNode.QueryHeaderDepth(tip1.HashHex) s.NoError(err) - s.Equal(tip1Depth, uint64(1)) + s.Equal(tip1Depth, uint32(1)) tip2Depth, err := nonValidatorNode.QueryHeaderDepth(tip2.HashHex) s.NoError(err) // tip should have 0 depth - s.Equal(tip2Depth, uint64(0)) + s.Equal(tip2Depth, uint32(0)) } func (s *BTCTimestampingTestSuite) Test4GenerateAndWithdrawReward() { diff --git a/test/e2e/configurer/chain/node.go b/test/e2e/configurer/chain/node.go index c07288c17..af2787e9c 100644 --- a/test/e2e/configurer/chain/node.go +++ b/test/e2e/configurer/chain/node.go @@ -130,8 +130,8 @@ func (n *NodeConfig) WaitForCondition(doneCondition func() bool, errorMsg string n.t.Errorf("node %s timed out waiting for condition. Msg: %s", n.Name, errorMsg) } -func (n *NodeConfig) WaitUntilBtcHeight(height uint64) { - var latestBlockHeight uint64 +func (n *NodeConfig) WaitUntilBtcHeight(height uint32) { + var latestBlockHeight uint32 n.WaitForCondition(func() bool { btcTip, err := n.QueryTip() require.NoError(n.t, err) diff --git a/test/e2e/configurer/chain/queries.go b/test/e2e/configurer/chain/queries.go index b5910568a..0a26c8129 100644 --- a/test/e2e/configurer/chain/queries.go +++ b/test/e2e/configurer/chain/queries.go @@ -248,7 +248,7 @@ func (n *NodeConfig) QueryTip() (*blc.BTCHeaderInfoResponse, error) { return blcResponse.Header, nil } -func (n *NodeConfig) QueryHeaderDepth(hash string) (uint64, error) { +func (n *NodeConfig) QueryHeaderDepth(hash string) (uint32, error) { path := fmt.Sprintf("babylon/btclightclient/v1/depth/%s", hash) bz, err := n.QueryGRPCGateway(path, url.Values{}) require.NoError(n.t, err) @@ -271,7 +271,7 @@ func (n *NodeConfig) QueryCurrentEpoch() (uint64, error) { return epochResponse.CurrentEpoch, nil } -func (n *NodeConfig) QueryLightClientHeightEpochEnd(epoch uint64) (uint64, error) { +func (n *NodeConfig) QueryLightClientHeightEpochEnd(epoch uint64) (uint32, error) { monitorPath := fmt.Sprintf("/babylon/monitor/v1/epochs/%d", epoch) bz, err := n.QueryGRPCGateway(monitorPath, url.Values{}) require.NoError(n.t, err) @@ -282,7 +282,7 @@ func (n *NodeConfig) QueryLightClientHeightEpochEnd(epoch uint64) (uint64, error return mResponse.BtcLightClientHeight, nil } -func (n *NodeConfig) QueryLightClientHeightCheckpointReported(ckptHash []byte) (uint64, error) { +func (n *NodeConfig) QueryLightClientHeightCheckpointReported(ckptHash []byte) (uint32, error) { monitorPath := fmt.Sprintf("/babylon/monitor/v1/checkpoints/%x", ckptHash) bz, err := n.QueryGRPCGateway(monitorPath, url.Values{}) require.NoError(n.t, err) diff --git a/testutil/datagen/btc_header_chain.go b/testutil/datagen/btc_header_chain.go index e28421ef3..d24649558 100644 --- a/testutil/datagen/btc_header_chain.go +++ b/testutil/datagen/btc_header_chain.go @@ -16,19 +16,19 @@ var initHeader = chaincfg.SimNetParams.GenesisBlock.Header type BTCHeaderPartialChain struct { // slice of Headers forming valid chain Headers []*wire.BlockHeader - initialHeaderHeight uint64 + initialHeaderHeight uint32 inititialHeaderTotalWork sdkmath.Uint } func NewBTCHeaderChainWithLength( r *rand.Rand, - initialHeaderHeight uint64, - initialHeaderTotalWork uint64, + initialHeaderHeight uint32, + initialHeaderTotalWork uint32, length uint32) *BTCHeaderPartialChain { return NewBTCHeaderChainFromParent( r, initialHeaderHeight, - sdkmath.NewUint(initialHeaderTotalWork), + sdkmath.NewUint(uint64(initialHeaderTotalWork)), &initHeader, length, ) @@ -50,14 +50,13 @@ func NewBTCHeaderChainFromParentInfo( func NewBTCHeaderChainFromParent( r *rand.Rand, - initialHeaderHeight uint64, + initialHeaderHeight uint32, initialHeaderTotalWork sdkmath.Uint, parent *wire.BlockHeader, length uint32, ) *BTCHeaderPartialChain { headers := GenRandomValidChainStartingFrom( r, - initialHeaderHeight, parent, nil, length, diff --git a/testutil/datagen/btc_header_info.go b/testutil/datagen/btc_header_info.go index c680acdef..796e0182e 100644 --- a/testutil/datagen/btc_header_info.go +++ b/testutil/datagen/btc_header_info.go @@ -161,9 +161,9 @@ func GenRandomBTCHeaderBytes(r *rand.Rand, parent *btclightclienttypes.BTCHeader return bbn.NewBTCHeaderBytesFromBlockHeader(btcdHeader) } -// GenRandomBTCHeight returns a random uint64 -func GenRandomBTCHeight(r *rand.Rand) uint64 { - return r.Uint64() +// GenRandomBTCHeight returns a random uint32 +func GenRandomBTCHeight(r *rand.Rand) uint32 { + return r.Uint32() } // GenRandomBTCHeaderInfoWithParentAndBits generates a BTCHeaderInfo object in which the `header.PrevBlock` points to the `parent` @@ -253,7 +253,6 @@ func GenRandomBtcdValidHeader( func GenRandomValidChainStartingFrom( r *rand.Rand, - parentHeaderHeight uint64, parentHeader *wire.BlockHeader, timeBetweenBlocks *TimeBetweenBlocksInfo, numHeaders uint32, @@ -283,8 +282,8 @@ func GenRandBtcChainInsertingInKeeper( r *rand.Rand, k *btclightclientk.Keeper, ctx context.Context, - initialHeight uint64, - chainLength uint64, + initialHeight uint32, + chainLength uint32, ) (*btclightclienttypes.BTCHeaderInfo, *BTCHeaderPartialChain) { genesisHeader := NewBTCHeaderChainWithLength(r, initialHeight, 0, 1) genesisHeaderInfo := genesisHeader.GetChainInfo()[0] @@ -292,7 +291,7 @@ func GenRandBtcChainInsertingInKeeper( randomChain := NewBTCHeaderChainFromParentInfo( r, genesisHeaderInfo, - uint32(chainLength), + chainLength, ) err := k.InsertHeadersWithHookAndEvents(ctx, randomChain.ChainToBytes()) require.NoError(t, err) @@ -304,7 +303,7 @@ func GenRandBtcChainInsertingInKeeper( func ChainToInfoChain( chain []*wire.BlockHeader, - initialHeaderNumber uint64, + initialHeaderNumber uint32, initialHeaderTotalWork sdkmath.Uint, ) []*btclightclienttypes.BTCHeaderInfo { if len(chain) == 0 { @@ -321,7 +320,7 @@ func ChainToInfoChain( hash := header.BlockHash() headerBytes := bbn.NewBTCHeaderBytesFromBlockHeader(header) headerHash := bbn.NewBTCHeaderHashBytesFromChainhash(&hash) - headerNumber := initialHeaderNumber + uint64(i) + headerNumber := initialHeaderNumber + uint32(i) headerInfo := btclightclienttypes.NewBTCHeaderInfo( &headerBytes, @@ -340,7 +339,7 @@ func ChainToInfoChain( func ChainToInfoResponseChain( chain []*wire.BlockHeader, - initialHeaderNumber uint64, + initialHeaderNumber uint32, initialHeaderTotalWork sdkmath.Uint, ) []*btclightclienttypes.BTCHeaderInfoResponse { if len(chain) == 0 { @@ -357,7 +356,7 @@ func ChainToInfoResponseChain( hash := header.BlockHash() headerBytes := bbn.NewBTCHeaderBytesFromBlockHeader(header) headerHash := bbn.NewBTCHeaderHashBytesFromChainhash(&hash) - headerNumber := initialHeaderNumber + uint64(i) + headerNumber := initialHeaderNumber + uint32(i) headerInfoResponse := btclightclienttypes.NewBTCHeaderInfoResponse( &headerBytes, diff --git a/testutil/datagen/btcstaking.go b/testutil/datagen/btcstaking.go index 010e1bdfd..ca3bbe7a6 100644 --- a/testutil/datagen/btcstaking.go +++ b/testutil/datagen/btcstaking.go @@ -89,7 +89,8 @@ func GenRandomBTCDelegation( covenantPks []*btcec.PublicKey, covenantQuorum uint32, slashingPkScript []byte, - startHeight, endHeight, totalSat uint64, + startHeight, endHeight uint32, + totalSat uint64, slashingRate sdkmath.LegacyDec, slashingChangeLockTime uint16, ) (*bstypes.BTCDelegation, error) { diff --git a/wasmbinding/bindings/query.go b/wasmbinding/bindings/query.go index cc81ecbff..cd1da2085 100644 --- a/wasmbinding/bindings/query.go +++ b/wasmbinding/bindings/query.go @@ -14,7 +14,7 @@ type BtcHeaderByHash struct { } type BtcHeaderByHeight struct { - Height uint64 `json:"height"` + Height uint32 `json:"height"` } type CurrentEpochResponse struct { @@ -41,7 +41,7 @@ type BtcBlockHeader struct { type BtcBlockHeaderInfo struct { Header *BtcBlockHeader `json:"header,omitempty"` - Height uint64 `json:"height"` + Height uint32 `json:"height"` } type BtcTipResponse struct { diff --git a/x/btccheckpoint/genesis_test.go b/x/btccheckpoint/genesis_test.go index 62b36760c..3032f15dd 100644 --- a/x/btccheckpoint/genesis_test.go +++ b/x/btccheckpoint/genesis_test.go @@ -35,6 +35,6 @@ func TestInitGenesis(t *testing.T) { } btccheckpoint.InitGenesis(ctx, app.BtcCheckpointKeeper, genesisState) - require.Equal(t, app.BtcCheckpointKeeper.GetParams(ctx).BtcConfirmationDepth, uint64(888)) - require.Equal(t, app.BtcCheckpointKeeper.GetParams(ctx).CheckpointFinalizationTimeout, uint64(999)) + require.Equal(t, app.BtcCheckpointKeeper.GetParams(ctx).BtcConfirmationDepth, uint32(888)) + require.Equal(t, app.BtcCheckpointKeeper.GetParams(ctx).CheckpointFinalizationTimeout, uint32(999)) } diff --git a/x/btccheckpoint/keeper/grpc_query_params_test.go b/x/btccheckpoint/keeper/grpc_query_params_test.go index 9624ef04a..3f45131cd 100644 --- a/x/btccheckpoint/keeper/grpc_query_params_test.go +++ b/x/btccheckpoint/keeper/grpc_query_params_test.go @@ -14,11 +14,11 @@ import ( // 2. When EpochInterval is 0, ensure `Validate` returns an error // 3. Randomly set the param via query and check if the param has been updated func FuzzParamsQuery(f *testing.F) { - f.Add(uint64(11111), uint64(3232), int64(23)) - f.Add(uint64(22222), uint64(444), int64(330)) - f.Add(uint64(22222), uint64(12333), int64(101)) + f.Add(uint32(11111), uint32(3232), int64(23)) + f.Add(uint32(22222), uint32(444), int64(330)) + f.Add(uint32(22222), uint32(12333), int64(101)) - f.Fuzz(func(t *testing.T, btcConfirmationDepth uint64, checkpointFinalizationTimeout uint64, seed int64) { + f.Fuzz(func(t *testing.T, btcConfirmationDepth uint32, checkpointFinalizationTimeout uint32, seed int64) { r := rand.New(rand.NewSource(seed)) // params generated by fuzzer @@ -31,7 +31,7 @@ func FuzzParamsQuery(f *testing.F) { if btcConfirmationDepth == 0 { // validation should not pass with zero EpochInterval require.Error(t, params.Validate()) - params.BtcConfirmationDepth = uint64(r.Int()) + params.BtcConfirmationDepth = uint32(r.Int31()) } // test the case of CheckpointFinalizationTimeout == 0 @@ -39,7 +39,7 @@ func FuzzParamsQuery(f *testing.F) { if checkpointFinalizationTimeout == 0 { // validation should not pass with zero EpochInterval require.Error(t, params.Validate()) - params.CheckpointFinalizationTimeout = uint64(r.Int()) + params.CheckpointFinalizationTimeout = uint32(r.Int31()) } if btcConfirmationDepth >= checkpointFinalizationTimeout { diff --git a/x/btccheckpoint/keeper/grpc_query_test.go b/x/btccheckpoint/keeper/grpc_query_test.go index f1b32d76d..7767124cf 100644 --- a/x/btccheckpoint/keeper/grpc_query_test.go +++ b/x/btccheckpoint/keeper/grpc_query_test.go @@ -28,8 +28,8 @@ func TestBtcCheckpointInfo(t *testing.T) { proofs := dg.BlockCreationResultToProofs(blockResults) msg := dg.GenerateMessageWithRandomSubmitter(blockResults) - tk.BTCLightClient.SetDepth(blck1.HeaderBytes.Hash(), uint64(1)) - tk.BTCLightClient.SetDepth(blck2.HeaderBytes.Hash(), uint64(1)) + tk.BTCLightClient.SetDepth(blck1.HeaderBytes.Hash(), uint32(1)) + tk.BTCLightClient.SetDepth(blck2.HeaderBytes.Hash(), uint32(1)) _, err := tk.insertProofMsg(msg) require.NoErrorf(t, err, "Unexpected message processing error: %v", err) diff --git a/x/btccheckpoint/keeper/keeper.go b/x/btccheckpoint/keeper/keeper.go index befa51f04..c5bda7f99 100644 --- a/x/btccheckpoint/keeper/keeper.go +++ b/x/btccheckpoint/keeper/keeper.go @@ -102,24 +102,24 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) } -func (k Keeper) GetBlockHeight(ctx context.Context, b *bbn.BTCHeaderHashBytes) (uint64, error) { +func (k Keeper) GetBlockHeight(ctx context.Context, b *bbn.BTCHeaderHashBytes) (uint32, error) { return k.btcLightClientKeeper.BlockHeight(ctx, b) } -func (k Keeper) headerDepth(ctx context.Context, headerHash *bbn.BTCHeaderHashBytes) (uint64, error) { +func (k Keeper) headerDepth(ctx context.Context, headerHash *bbn.BTCHeaderHashBytes) (uint32, error) { blockDepth, err := k.btcLightClientKeeper.MainChainDepth(ctx, headerHash) if err != nil { // one of blocks is not known to light client return 0, submissionUnknownErr } - return uint64(blockDepth), nil + return blockDepth, nil } // checkAncestors checks if there is at least one ancestor in previous epoch submissions // previous epoch submission is considered ancestor when: // - it is on main chain -// - its lowest depth is larger than highest depth of new submission +// - its lowest depth is larger than the highest depth of new submission func (k Keeper) checkAncestors( ctx context.Context, submisionEpoch uint64, diff --git a/x/btccheckpoint/keeper/keeper_test.go b/x/btccheckpoint/keeper/keeper_test.go index 5ed112659..f1a0ded46 100644 --- a/x/btccheckpoint/keeper/keeper_test.go +++ b/x/btccheckpoint/keeper/keeper_test.go @@ -13,7 +13,7 @@ import ( func TestKeeper_GetSubmissionBtcInfo(t *testing.T) { type TxKeyDesc struct { TxIdx uint32 - Depth uint64 + Depth uint32 } type args struct { @@ -24,9 +24,9 @@ func TestKeeper_GetSubmissionBtcInfo(t *testing.T) { tests := []struct { name string args args - expectedYoungestBlockDepth uint64 + expectedYoungestBlockDepth uint32 expectedTxIndex uint32 - expectedOldestBlockDepth uint64 + expectedOldestBlockDepth uint32 }{ {"First header older. TxIndex larger in older header.", args{TxKeyDesc{TxIdx: 5, Depth: 10}, TxKeyDesc{TxIdx: 1, Depth: 0}}, 0, 1, 10}, {"First header older. TxIndex larger in younger header.", args{TxKeyDesc{TxIdx: 1, Depth: 10}, TxKeyDesc{TxIdx: 5, Depth: 0}}, 0, 5, 10}, @@ -90,23 +90,23 @@ func FuzzGetSubmissionBtcInfo(f *testing.F) { {Index: txidx2, Hash: hash2}, }} - k.BTCLightClient.SetDepth(hash1, uint64(depth1)) - k.BTCLightClient.SetDepth(hash2, uint64(depth2)) + k.BTCLightClient.SetDepth(hash1, depth1) + k.BTCLightClient.SetDepth(hash2, depth2) info, err := k.BTCCheckpoint.GetSubmissionBtcInfo(k.SdkCtx, sk) require.NoError(t, err) - var expectedOldestDepth uint64 - var expectedYoungestDepth uint64 + var expectedOldestDepth uint32 + var expectedYoungestDepth uint32 var expectedTxIdx uint32 if depth1 > depth2 { - expectedOldestDepth = uint64(depth1) - expectedYoungestDepth = uint64(depth2) + expectedOldestDepth = depth1 + expectedYoungestDepth = depth2 expectedTxIdx = txidx2 } else if depth1 < depth2 { - expectedOldestDepth = uint64(depth2) - expectedYoungestDepth = uint64(depth1) + expectedOldestDepth = depth2 + expectedYoungestDepth = depth1 expectedTxIdx = txidx1 } else { if txidx1 > txidx2 { @@ -114,8 +114,8 @@ func FuzzGetSubmissionBtcInfo(f *testing.F) { } else { expectedTxIdx = txidx1 } - expectedOldestDepth = uint64(depth1) - expectedYoungestDepth = uint64(depth1) + expectedOldestDepth = depth1 + expectedYoungestDepth = depth1 } require.Equal(t, info.YoungestBlockDepth, expectedYoungestDepth) diff --git a/x/btccheckpoint/keeper/msg_server_test.go b/x/btccheckpoint/keeper/msg_server_test.go index 4943ba159..8b234d59d 100644 --- a/x/btccheckpoint/keeper/msg_server_test.go +++ b/x/btccheckpoint/keeper/msg_server_test.go @@ -92,8 +92,8 @@ func TestRejectDuplicatedSubmission(t *testing.T) { msg := dg.GenerateMessageWithRandomSubmitter([]*dg.BlockCreationResult{blck1, blck2}) // Now we will return depth enough for moving submission to be submitted - tk.BTCLightClient.SetDepth(blck1.HeaderBytes.Hash(), uint64(1)) - tk.BTCLightClient.SetDepth(blck2.HeaderBytes.Hash(), uint64(1)) + tk.BTCLightClient.SetDepth(blck1.HeaderBytes.Hash(), uint32(1)) + tk.BTCLightClient.SetDepth(blck2.HeaderBytes.Hash(), uint32(1)) _, err := tk.insertProofMsg(msg) @@ -130,7 +130,7 @@ func TestRejectUnknownToBtcLightClient(t *testing.T) { require.ErrorContainsf(t, err, btcctypes.ErrInvalidHeader.Error(), "Processing should return invalid header error") // even if one header is known, submission should still be considered invalid - tk.BTCLightClient.SetDepth(blck1.HeaderBytes.Hash(), uint64(1)) + tk.BTCLightClient.SetDepth(blck1.HeaderBytes.Hash(), uint32(1)) _, err = tk.insertProofMsg(msg) @@ -150,8 +150,8 @@ func TestSubmitValidNewCheckpoint(t *testing.T) { msg := dg.GenerateMessageWithRandomSubmitter([]*dg.BlockCreationResult{blck1, blck2}) // Now we will return depth enough for moving submission to be submitted - tk.BTCLightClient.SetDepth(blck1.HeaderBytes.Hash(), uint64(1)) - tk.BTCLightClient.SetDepth(blck2.HeaderBytes.Hash(), uint64(1)) + tk.BTCLightClient.SetDepth(blck1.HeaderBytes.Hash(), uint32(1)) + tk.BTCLightClient.SetDepth(blck2.HeaderBytes.Hash(), uint32(1)) _, err := tk.insertProofMsg(msg) @@ -216,8 +216,8 @@ func TestRejectSubmissionWithoutSubmissionsForPreviousEpoch(t *testing.T) { msg := dg.GenerateMessageWithRandomSubmitter([]*dg.BlockCreationResult{blck1, blck2}) // Now we will return depth enough for moving submission to be submitted - tk.BTCLightClient.SetDepth(blck1.HeaderBytes.Hash(), uint64(0)) - tk.BTCLightClient.SetDepth(blck2.HeaderBytes.Hash(), uint64(1)) + tk.BTCLightClient.SetDepth(blck1.HeaderBytes.Hash(), uint32(0)) + tk.BTCLightClient.SetDepth(blck2.HeaderBytes.Hash(), uint32(1)) _, err := tk.insertProofMsg(msg) @@ -241,8 +241,8 @@ func TestRejectSubmissionWithoutAncestorsOnMainchainInPreviousEpoch(t *testing.T msg := dg.GenerateMessageWithRandomSubmitter([]*dg.BlockCreationResult{epoch1Block1, epoch1Block2}) // Now we will return depth enough for moving submission to be submitted - tk.BTCLightClient.SetDepth(epoch1Block1.HeaderBytes.Hash(), uint64(5)) - tk.BTCLightClient.SetDepth(epoch1Block2.HeaderBytes.Hash(), uint64(4)) + tk.BTCLightClient.SetDepth(epoch1Block1.HeaderBytes.Hash(), uint32(5)) + tk.BTCLightClient.SetDepth(epoch1Block2.HeaderBytes.Hash(), uint32(4)) _, err := tk.insertProofMsg(msg) @@ -255,8 +255,8 @@ func TestRejectSubmissionWithoutAncestorsOnMainchainInPreviousEpoch(t *testing.T msg2 := dg.GenerateMessageWithRandomSubmitter([]*dg.BlockCreationResult{epoch2Block1, epoch2Block2}) // Both headers are deeper than epoch 1 submission, fail - tk.BTCLightClient.SetDepth(epoch2Block1.HeaderBytes.Hash(), uint64(7)) - tk.BTCLightClient.SetDepth(epoch2Block2.HeaderBytes.Hash(), uint64(6)) + tk.BTCLightClient.SetDepth(epoch2Block1.HeaderBytes.Hash(), uint32(7)) + tk.BTCLightClient.SetDepth(epoch2Block2.HeaderBytes.Hash(), uint32(6)) _, err = tk.insertProofMsg(msg2) @@ -268,8 +268,8 @@ func TestRejectSubmissionWithoutAncestorsOnMainchainInPreviousEpoch(t *testing.T ) // one header deeper than headers of previous epoch, one fresher, fail - tk.BTCLightClient.SetDepth(epoch2Block1.HeaderBytes.Hash(), uint64(7)) - tk.BTCLightClient.SetDepth(epoch2Block2.HeaderBytes.Hash(), uint64(3)) + tk.BTCLightClient.SetDepth(epoch2Block1.HeaderBytes.Hash(), uint32(7)) + tk.BTCLightClient.SetDepth(epoch2Block2.HeaderBytes.Hash(), uint32(3)) _, err = tk.insertProofMsg(msg2) @@ -281,8 +281,8 @@ func TestRejectSubmissionWithoutAncestorsOnMainchainInPreviousEpoch(t *testing.T ) // one header on the same depth as previous epoch, one fresher, fail - tk.BTCLightClient.SetDepth(epoch2Block1.HeaderBytes.Hash(), uint64(4)) - tk.BTCLightClient.SetDepth(epoch2Block2.HeaderBytes.Hash(), uint64(3)) + tk.BTCLightClient.SetDepth(epoch2Block1.HeaderBytes.Hash(), uint32(4)) + tk.BTCLightClient.SetDepth(epoch2Block2.HeaderBytes.Hash(), uint32(3)) _, err = tk.insertProofMsg(msg2) @@ -294,8 +294,8 @@ func TestRejectSubmissionWithoutAncestorsOnMainchainInPreviousEpoch(t *testing.T ) // Both Headers fresher that previous epoch, succeed - tk.BTCLightClient.SetDepth(epoch2Block1.HeaderBytes.Hash(), uint64(3)) - tk.BTCLightClient.SetDepth(epoch2Block2.HeaderBytes.Hash(), uint64(2)) + tk.BTCLightClient.SetDepth(epoch2Block1.HeaderBytes.Hash(), uint32(3)) + tk.BTCLightClient.SetDepth(epoch2Block2.HeaderBytes.Hash(), uint32(2)) _, err = tk.insertProofMsg(msg2) @@ -308,38 +308,38 @@ func TestClearChildEpochsWhenNoParenNotOnMainChain(t *testing.T) { tk := InitTestKeepers(t) msg1 := dg.GenerateMessageWithRandomSubmitterForEpoch(r, 1) - tk.BTCLightClient.SetDepth(b1Hash(msg1), uint64(5)) - tk.BTCLightClient.SetDepth(b2Hash(msg1), uint64(4)) + tk.BTCLightClient.SetDepth(b1Hash(msg1), uint32(5)) + tk.BTCLightClient.SetDepth(b2Hash(msg1), uint32(4)) _, err := tk.insertProofMsg(msg1) require.NoError(t, err, "failed to insert submission for epoch 1") msg1a := dg.GenerateMessageWithRandomSubmitterForEpoch(r, 1) - tk.BTCLightClient.SetDepth(b1Hash(msg1a), uint64(4)) - tk.BTCLightClient.SetDepth(b2Hash(msg1a), uint64(5)) + tk.BTCLightClient.SetDepth(b1Hash(msg1a), uint32(4)) + tk.BTCLightClient.SetDepth(b2Hash(msg1a), uint32(5)) _, err = tk.insertProofMsg(msg1a) require.NoError(t, err, "failed to insert submission for epoch 1") msg2 := dg.GenerateMessageWithRandomSubmitterForEpoch(r, 2) - tk.BTCLightClient.SetDepth(b1Hash(msg2), uint64(3)) - tk.BTCLightClient.SetDepth(b2Hash(msg2), uint64(2)) + tk.BTCLightClient.SetDepth(b1Hash(msg2), uint32(3)) + tk.BTCLightClient.SetDepth(b2Hash(msg2), uint32(2)) _, err = tk.insertProofMsg(msg2) require.NoError(t, err, "failed to insert submission for epoch 2") msg2a := dg.GenerateMessageWithRandomSubmitterForEpoch(r, 2) - tk.BTCLightClient.SetDepth(b1Hash(msg2a), uint64(3)) - tk.BTCLightClient.SetDepth(b2Hash(msg2a), uint64(2)) + tk.BTCLightClient.SetDepth(b1Hash(msg2a), uint32(3)) + tk.BTCLightClient.SetDepth(b2Hash(msg2a), uint32(2)) _, err = tk.insertProofMsg(msg2a) require.NoError(t, err, "failed to insert submission for epoch 2") msg3 := dg.GenerateMessageWithRandomSubmitterForEpoch(r, 3) - tk.BTCLightClient.SetDepth(b1Hash(msg3), uint64(1)) - tk.BTCLightClient.SetDepth(b2Hash(msg3), uint64(0)) + tk.BTCLightClient.SetDepth(b1Hash(msg3), uint32(1)) + tk.BTCLightClient.SetDepth(b2Hash(msg3), uint32(0)) _, err = tk.insertProofMsg(msg3) require.NoError(t, err, "failed to insert submission for epoch 3") msg3a := dg.GenerateMessageWithRandomSubmitterForEpoch(r, 3) - tk.BTCLightClient.SetDepth(b1Hash(msg3a), uint64(1)) - tk.BTCLightClient.SetDepth(b2Hash(msg3a), uint64(0)) + tk.BTCLightClient.SetDepth(b1Hash(msg3a), uint32(1)) + tk.BTCLightClient.SetDepth(b2Hash(msg3a), uint32(0)) _, err = tk.insertProofMsg(msg3a) require.NoError(t, err, "failed to insert submission for epoch 3") @@ -394,20 +394,20 @@ func TestLeaveOnlyBestSubmissionWhenEpochFinalized(t *testing.T) { wDeep := defaultParams.CheckpointFinalizationTimeout msg1 := dg.GenerateMessageWithRandomSubmitterForEpoch(r, 1) - tk.BTCLightClient.SetDepth(b1Hash(msg1), uint64(1)) - tk.BTCLightClient.SetDepth(b2Hash(msg1), uint64(0)) + tk.BTCLightClient.SetDepth(b1Hash(msg1), uint32(1)) + tk.BTCLightClient.SetDepth(b2Hash(msg1), uint32(0)) _, err := tk.insertProofMsg(msg1) require.NoError(t, err, "failed to insert submission") msg2 := dg.GenerateMessageWithRandomSubmitterForEpoch(r, 1) - tk.BTCLightClient.SetDepth(b1Hash(msg2), uint64(1)) - tk.BTCLightClient.SetDepth(b2Hash(msg2), uint64(0)) + tk.BTCLightClient.SetDepth(b1Hash(msg2), uint32(1)) + tk.BTCLightClient.SetDepth(b2Hash(msg2), uint32(0)) _, err = tk.insertProofMsg(msg2) require.NoError(t, err, "failed to insert submission") msg3 := dg.GenerateMessageWithRandomSubmitterForEpoch(r, 1) - tk.BTCLightClient.SetDepth(b1Hash(msg3), uint64(1)) - tk.BTCLightClient.SetDepth(b2Hash(msg3), uint64(0)) + tk.BTCLightClient.SetDepth(b1Hash(msg3), uint32(1)) + tk.BTCLightClient.SetDepth(b2Hash(msg3), uint32(0)) _, err = tk.insertProofMsg(msg3) require.NoError(t, err, "failed to insert submission") @@ -443,14 +443,14 @@ func TestTxIdxShouldBreakTies(t *testing.T) { wDeep := defaultParams.CheckpointFinalizationTimeout msg1 := dg.GenerateMessageWithRandomSubmitterForEpoch(r, 1) - tk.BTCLightClient.SetDepth(b1Hash(msg1), uint64(1)) - tk.BTCLightClient.SetDepth(b2Hash(msg1), uint64(0)) + tk.BTCLightClient.SetDepth(b1Hash(msg1), uint32(1)) + tk.BTCLightClient.SetDepth(b2Hash(msg1), uint32(0)) _, err := tk.insertProofMsg(msg1) require.NoError(t, err, "failed to insert submission") msg2 := dg.GenerateMessageWithRandomSubmitterForEpoch(r, 1) - tk.BTCLightClient.SetDepth(b1Hash(msg2), uint64(1)) - tk.BTCLightClient.SetDepth(b2Hash(msg2), uint64(0)) + tk.BTCLightClient.SetDepth(b1Hash(msg2), uint32(1)) + tk.BTCLightClient.SetDepth(b2Hash(msg2), uint32(0)) _, err = tk.insertProofMsg(msg2) require.NoError(t, err, "failed to insert submission") @@ -501,8 +501,8 @@ func TestStateTransitionOfValidSubmission(t *testing.T) { msg := dg.GenerateMessageWithRandomSubmitter([]*dg.BlockCreationResult{blck1, blck2}) // Now we will return depth enough for moving submission to confirmed - tk.BTCLightClient.SetDepth(blck1.HeaderBytes.Hash(), uint64(1)) - tk.BTCLightClient.SetDepth(blck2.HeaderBytes.Hash(), uint64(1)) + tk.BTCLightClient.SetDepth(blck1.HeaderBytes.Hash(), uint32(1)) + tk.BTCLightClient.SetDepth(blck2.HeaderBytes.Hash(), uint32(1)) _, err := tk.insertProofMsg(msg) @@ -571,7 +571,7 @@ func FuzzConfirmAndDinalizeManyEpochs(f *testing.F) { numOfEpochs := numFinalizedEpochs + numConfirmedEpochs + numSubmittedEpochs - bestSumbissionInfos := make(map[uint64]uint64) + bestSumbissionInfos := make(map[uint64]uint32) for i := 1; i <= numOfEpochs; i++ { epoch := uint64(i) @@ -587,13 +587,13 @@ func FuzzConfirmAndDinalizeManyEpochs(f *testing.F) { msg := dg.GenerateMessageWithRandomSubmitter([]*dg.BlockCreationResult{blck1, blck2}) if epoch <= uint64(numFinalizedEpochs) { - tk.BTCLightClient.SetDepth(blck1.HeaderBytes.Hash(), uint64(finalizationDepth)) + tk.BTCLightClient.SetDepth(blck1.HeaderBytes.Hash(), uint32(finalizationDepth)) finalizationDepth = finalizationDepth - 1 - tk.BTCLightClient.SetDepth(blck2.HeaderBytes.Hash(), uint64(finalizationDepth)) + tk.BTCLightClient.SetDepth(blck2.HeaderBytes.Hash(), uint32(finalizationDepth)) // first submission is always deepest one, and second block is the most recent one if j == 1 { - bestSumbissionInfos[epoch] = uint64(finalizationDepth) + bestSumbissionInfos[epoch] = uint32(finalizationDepth) } finalizationDepth = finalizationDepth - 1 } else if epoch <= uint64(numFinalizedEpochs+numConfirmedEpochs) { diff --git a/x/btccheckpoint/keeper/submissions.go b/x/btccheckpoint/keeper/submissions.go index 3af9cc743..3ea2cc2b1 100644 --- a/x/btccheckpoint/keeper/submissions.go +++ b/x/btccheckpoint/keeper/submissions.go @@ -132,12 +132,12 @@ func (k Keeper) checkSubmissionStatus(ctx context.Context, info *types.Submissio func (k Keeper) GetSubmissionBtcInfo(ctx context.Context, sk types.SubmissionKey) (*types.SubmissionBtcInfo, error) { - var youngestBlockDepth uint64 = math.MaxUint64 + var youngestBlockDepth uint32 = math.MaxUint32 var youngestBlockHash *bbn.BTCHeaderHashBytes var lowestIndexInMostFreshBlock uint32 = math.MaxUint32 - var oldestBlockDepth = uint64(0) + var oldestBlockDepth = uint32(0) for _, tk := range sk.Key { currentBlockDepth, err := k.headerDepth(ctx, tk.Hash) diff --git a/x/btccheckpoint/types/btccheckpoint.pb.go b/x/btccheckpoint/types/btccheckpoint.pb.go index 4e9ac7678..c65ba6c80 100644 --- a/x/btccheckpoint/types/btccheckpoint.pb.go +++ b/x/btccheckpoint/types/btccheckpoint.pb.go @@ -513,7 +513,7 @@ type BTCCheckpointInfo struct { // epoch number of this checkpoint EpochNumber uint64 `protobuf:"varint,1,opt,name=epoch_number,json=epochNumber,proto3" json:"epoch_number,omitempty"` // btc height of the best submission of the epoch - BestSubmissionBtcBlockHeight uint64 `protobuf:"varint,2,opt,name=best_submission_btc_block_height,json=bestSubmissionBtcBlockHeight,proto3" json:"best_submission_btc_block_height,omitempty"` + BestSubmissionBtcBlockHeight uint32 `protobuf:"varint,2,opt,name=best_submission_btc_block_height,json=bestSubmissionBtcBlockHeight,proto3" json:"best_submission_btc_block_height,omitempty"` // hash of the btc block which determines checkpoint btc block height i.e. // youngest block of best submission BestSubmissionBtcBlockHash *github_com_babylonlabs_io_babylon_types.BTCHeaderHashBytes `protobuf:"bytes,3,opt,name=best_submission_btc_block_hash,json=bestSubmissionBtcBlockHash,proto3,customtype=github.com/babylonlabs-io/babylon/types.BTCHeaderHashBytes" json:"best_submission_btc_block_hash,omitempty"` @@ -563,7 +563,7 @@ func (m *BTCCheckpointInfo) GetEpochNumber() uint64 { return 0 } -func (m *BTCCheckpointInfo) GetBestSubmissionBtcBlockHeight() uint64 { +func (m *BTCCheckpointInfo) GetBestSubmissionBtcBlockHeight() uint32 { if m != nil { return m.BestSubmissionBtcBlockHeight } @@ -601,58 +601,58 @@ func init() { } var fileDescriptor_e096cac78d49b0a6 = []byte{ - // 816 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0xcd, 0x8b, 0xdb, 0x46, - 0x14, 0xf7, 0xd8, 0xda, 0x34, 0x1e, 0x7b, 0x9d, 0xed, 0x78, 0x53, 0x84, 0x59, 0x14, 0x47, 0x85, - 0xc6, 0x29, 0x8d, 0x4d, 0xb6, 0xd0, 0xc2, 0x06, 0x0a, 0x2b, 0x7f, 0x60, 0x93, 0xc4, 0x9b, 0xca, - 0x4a, 0x0f, 0x39, 0x54, 0x48, 0xf2, 0xd8, 0x1a, 0x6c, 0x6b, 0x8c, 0x66, 0x6c, 0xec, 0xdc, 0x5a, - 0x28, 0x94, 0x9e, 0x4a, 0xef, 0x3d, 0xf5, 0x9f, 0xe9, 0xa1, 0x87, 0x1c, 0xcb, 0x1e, 0x96, 0xb2, - 0xfb, 0x2f, 0xf4, 0x5a, 0x28, 0x33, 0xd2, 0xfa, 0x6b, 0xd7, 0x6d, 0x0d, 0xbd, 0xf9, 0xbd, 0xf9, - 0xbd, 0x8f, 0xdf, 0xef, 0xbd, 0x67, 0xc1, 0x4f, 0x5c, 0xc7, 0x9d, 0x0f, 0x69, 0x50, 0x71, 0xb9, - 0xe7, 0xf9, 0xd8, 0x1b, 0x8c, 0x29, 0x09, 0x78, 0x65, 0xfa, 0x74, 0xdd, 0x51, 0x1e, 0x87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0xf1, 0x4f, 0x00, 0xa6, 0x17, 0xdb, 0x85, 0x1e, 0xc3, 0x0f, 0xea, 0xaf, 0xce, - 0xaa, 0x4d, 0xbb, 0x63, 0x9d, 0x5a, 0xaf, 0x3b, 0x76, 0xe7, 0xb5, 0xf1, 0xb2, 0x65, 0x59, 0xf5, - 0xda, 0x41, 0xa2, 0xb0, 0xff, 0xc3, 0xcf, 0xc5, 0x74, 0x27, 0xde, 0xa5, 0xee, 0x0d, 0x68, 0xf5, - 0xac, 0xdd, 0x68, 0x99, 0x2f, 0xeb, 0xb5, 0x03, 0x10, 0x41, 0xab, 0xd1, 0xbf, 0xeb, 0x2d, 0xd0, - 0x46, 0xab, 0x7d, 0xfa, 0xa2, 0xf5, 0xa6, 0x5e, 0x3b, 0x48, 0x46, 0xd0, 0x06, 0x09, 0x9c, 0x21, - 0x79, 0x8b, 0xbb, 0x05, 0xe5, 0xfb, 0x5f, 0xb4, 0x84, 0xf1, 0xe5, 0xaf, 0x97, 0x1a, 0x78, 0x77, - 0xa9, 0x81, 0x3f, 0x2e, 0x35, 0xf0, 0xe3, 0x95, 0x96, 0x78, 0x77, 0xa5, 0x25, 0x7e, 0xbf, 0xd2, - 0x12, 0x6f, 0x3e, 0xff, 0xf7, 0xb9, 0xcf, 0x36, 0x3e, 0x8c, 0x72, 0x0f, 0xdc, 0x3b, 0xf2, 0xf3, - 0xf6, 0xe9, 0xdf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x35, 0x29, 0x9d, 0x36, 0x3e, 0x07, 0x00, 0x00, + // 814 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0xcd, 0x6b, 0xe3, 0x46, + 0x14, 0xf7, 0xd8, 0xce, 0x76, 0x3d, 0x76, 0xbc, 0xe9, 0x38, 0x5b, 0x84, 0x09, 0x5a, 0xaf, 0x0a, + 0x5d, 0x6f, 0xe9, 0xda, 0x6c, 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c, 0x94, 0x84, 0x8c, 0x9c, 0x0e, 0x75, 0x2d, + 0xa1, 0x42, 0x3e, 0x7c, 0xec, 0x52, 0xbf, 0x4b, 0x82, 0x21, 0xf1, 0x7b, 0x96, 0xc8, 0xe0, 0x61, + 0xbb, 0x83, 0x03, 0x25, 0x29, 0xb0, 0xfa, 0xd1, 0xe5, 0xd5, 0x93, 0xcf, 0x7a, 0x84, 0x7b, 0x63, + 0xa7, 0xe4, 0xd2, 0x61, 0x39, 0xea, 0x76, 0x60, 0x3b, 0xec, 0x05, 0xa1, 0xb7, 0x62, 0x99, 0xcf, + 0x46, 0x98, 0x95, 0x74, 0xb3, 0xd2, 0x90, 0xce, 0xfa, 0x8c, 0x63, 0x66, 0xe4, 0x16, 0x81, 0x75, + 0xee, 0x86, 0x16, 0xed, 0x1c, 0x66, 0x97, 0xca, 0x7c, 0x8d, 0x67, 0x68, 0x1f, 0xee, 0x84, 0x8d, + 0x00, 0xd9, 0x48, 0x28, 0x20, 0x03, 0x26, 0x3d, 0x9b, 0x79, 0xb2, 0xbb, 0x8c, 0xfe, 0xc5, 0xe5, + 0xd5, 0x93, 0xa3, 0xad, 0xcb, 0x68, 0xd8, 0xcc, 0x0b, 0x4b, 0x91, 0xb1, 0xb4, 0xd7, 0x70, 0xb7, + 0x3d, 0x76, 0x86, 0x84, 0xb1, 0x28, 0xf5, 0x11, 0x4c, 0xf4, 0xf1, 0x4c, 0x01, 0x85, 0x44, 0x31, + 0x7d, 0x58, 0x2c, 0x6d, 0x1a, 0x65, 0x69, 0xb5, 0x62, 0x43, 0x38, 0x69, 0xdf, 0x01, 0xf8, 0x68, + 0x85, 0xf0, 0x2e, 0x5d, 0xc4, 0x03, 0x5b, 0xc7, 0x43, 0x05, 0x98, 0x5e, 0x5e, 0x82, 0x78, 0x38, + 0xaa, 0x25, 0x95, 0x20, 0x6a, 0x24, 0x76, 0x26, 0x1a, 0x63, 0x28, 0x68, 0xbf, 0x01, 0x98, 0x5d, + 0x74, 0x55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, 0x55, 0x70, 0x71, 0xad, + 0x82, 0x3f, 0xae, 0x55, 0xf0, 0xe3, 0x8d, 0x1a, 0xbb, 0xb8, 0x51, 0x63, 0xbf, 0xdf, 0xa8, 0xb1, + 0xb3, 0xcf, 0xff, 0x7d, 0xee, 0xd3, 0xb5, 0x87, 0x51, 0xee, 0x81, 0xf3, 0x40, 0x3e, 0x6f, 0x9f, + 0xfe, 0x1d, 0x00, 0x00, 0xff, 0xff, 0xbb, 0x84, 0x86, 0x4f, 0x3e, 0x07, 0x00, 0x00, } func (m *BTCSpvProof) Marshal() (dAtA []byte, err error) { @@ -2158,7 +2158,7 @@ func (m *BTCCheckpointInfo) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.BestSubmissionBtcBlockHeight |= uint64(b&0x7F) << shift + m.BestSubmissionBtcBlockHeight |= uint32(b&0x7F) << shift if b < 0x80 { break } diff --git a/x/btccheckpoint/types/expected_keepers.go b/x/btccheckpoint/types/expected_keepers.go index 395611ec6..e411b2ff7 100644 --- a/x/btccheckpoint/types/expected_keepers.go +++ b/x/btccheckpoint/types/expected_keepers.go @@ -12,10 +12,10 @@ type BTCLightClientKeeper interface { // BlockHeight should validate if header with given hash is valid and if it is // part of known chain. In case this is true it should return this block height // in case this is false it should return error - BlockHeight(ctx context.Context, headerHash *bbn.BTCHeaderHashBytes) (uint64, error) + BlockHeight(ctx context.Context, headerHash *bbn.BTCHeaderHashBytes) (uint32, error) // MainChainDepth returns the depth of the header in the main chain or error if the header does not exist - MainChainDepth(ctx context.Context, headerBytes *bbn.BTCHeaderHashBytes) (uint64, error) + MainChainDepth(ctx context.Context, headerBytes *bbn.BTCHeaderHashBytes) (uint32, error) } type CheckpointingKeeper interface { diff --git a/x/btccheckpoint/types/mock_keepers.go b/x/btccheckpoint/types/mock_keepers.go index 5e4037a9c..bc4e809d6 100644 --- a/x/btccheckpoint/types/mock_keepers.go +++ b/x/btccheckpoint/types/mock_keepers.go @@ -10,7 +10,7 @@ import ( ) type MockBTCLightClientKeeper struct { - headers map[string]uint64 + headers map[string]uint32 } type MockCheckpointingKeeper struct { @@ -22,7 +22,7 @@ type MockIncentiveKeeper struct { func NewMockBTCLightClientKeeper() *MockBTCLightClientKeeper { lc := MockBTCLightClientKeeper{ - headers: make(map[string]uint64), + headers: make(map[string]uint32), } return &lc } @@ -46,7 +46,7 @@ func (mc *MockCheckpointingKeeper) ReturnSuccess() { mc.returnError = false } -func (mc *MockBTCLightClientKeeper) SetDepth(header *bbn.BTCHeaderHashBytes, dd uint64) { +func (mc *MockBTCLightClientKeeper) SetDepth(header *bbn.BTCHeaderHashBytes, dd uint32) { mc.headers[header.String()] = dd } @@ -54,12 +54,12 @@ func (mc *MockBTCLightClientKeeper) DeleteHeader(header *bbn.BTCHeaderHashBytes) delete(mc.headers, header.String()) } -func (mb MockBTCLightClientKeeper) BlockHeight(ctx context.Context, header *bbn.BTCHeaderHashBytes) (uint64, error) { +func (mb MockBTCLightClientKeeper) BlockHeight(ctx context.Context, header *bbn.BTCHeaderHashBytes) (uint32, error) { // todo not used - return uint64(10), nil + return uint32(10), nil } -func (ck MockBTCLightClientKeeper) MainChainDepth(ctx context.Context, headerBytes *bbn.BTCHeaderHashBytes) (uint64, error) { +func (ck MockBTCLightClientKeeper) MainChainDepth(ctx context.Context, headerBytes *bbn.BTCHeaderHashBytes) (uint32, error) { depth, ok := ck.headers[headerBytes.String()] if ok { return depth, nil diff --git a/x/btccheckpoint/types/params.go b/x/btccheckpoint/types/params.go index 68b62f4b7..fc3d42011 100644 --- a/x/btccheckpoint/types/params.go +++ b/x/btccheckpoint/types/params.go @@ -8,13 +8,13 @@ import ( ) const ( - DefaultBtcConfirmationDepth uint64 = 10 - DefaultCheckpointFinalizationTimeout uint64 = 100 + DefaultBtcConfirmationDepth uint32 = 10 + DefaultCheckpointFinalizationTimeout uint32 = 100 DefaultCheckpointTag = "01020304" ) // NewParams creates a new Params instance -func NewParams(btcConfirmationDepth uint64, checkpointFinalizationTimeout uint64, checkpointTag string) Params { +func NewParams(btcConfirmationDepth uint32, checkpointFinalizationTimeout uint32, checkpointTag string) Params { return Params{ BtcConfirmationDepth: btcConfirmationDepth, CheckpointFinalizationTimeout: checkpointFinalizationTimeout, @@ -52,7 +52,7 @@ func (p Params) Validate() error { } func validateBtcConfirmationDepth(i interface{}) error { - v, ok := i.(uint64) + v, ok := i.(uint32) if !ok { return fmt.Errorf("invalid parameter type: %T", i) } @@ -65,7 +65,7 @@ func validateBtcConfirmationDepth(i interface{}) error { } func validateCheckpointFinalizationTimeout(i interface{}) error { - v, ok := i.(uint64) + v, ok := i.(uint32) if !ok { return fmt.Errorf("invalid parameter type: %T", i) } diff --git a/x/btccheckpoint/types/params.pb.go b/x/btccheckpoint/types/params.pb.go index a2f432d08..07ab0102a 100644 --- a/x/btccheckpoint/types/params.pb.go +++ b/x/btccheckpoint/types/params.pb.go @@ -28,14 +28,14 @@ type Params struct { // btc_confirmation_depth is the confirmation depth in BTC. // A block is considered irreversible only when it is at least k-deep in BTC // (k in research paper) - BtcConfirmationDepth uint64 `protobuf:"varint,1,opt,name=btc_confirmation_depth,json=btcConfirmationDepth,proto3" json:"btc_confirmation_depth,omitempty" yaml:"btc_confirmation_depth"` + BtcConfirmationDepth uint32 `protobuf:"varint,1,opt,name=btc_confirmation_depth,json=btcConfirmationDepth,proto3" json:"btc_confirmation_depth,omitempty" yaml:"btc_confirmation_depth"` // checkpoint_finalization_timeout is the maximum time window (measured in BTC // blocks) between a checkpoint // - being submitted to BTC, and // - being reported back to BBN // If a checkpoint has not been reported back within w BTC blocks, then BBN // has dishonest majority and is stalling checkpoints (w in research paper) - CheckpointFinalizationTimeout uint64 `protobuf:"varint,2,opt,name=checkpoint_finalization_timeout,json=checkpointFinalizationTimeout,proto3" json:"checkpoint_finalization_timeout,omitempty" yaml:"checkpoint_finalization_timeout"` + CheckpointFinalizationTimeout uint32 `protobuf:"varint,2,opt,name=checkpoint_finalization_timeout,json=checkpointFinalizationTimeout,proto3" json:"checkpoint_finalization_timeout,omitempty" yaml:"checkpoint_finalization_timeout"` // 4byte tag in hex format, required to be present in the OP_RETURN transaction // related to babylon CheckpointTag string `protobuf:"bytes,3,opt,name=checkpoint_tag,json=checkpointTag,proto3" json:"checkpoint_tag,omitempty" yaml:"checkpoint_tag"` @@ -74,14 +74,14 @@ func (m *Params) XXX_DiscardUnknown() { var xxx_messageInfo_Params proto.InternalMessageInfo -func (m *Params) GetBtcConfirmationDepth() uint64 { +func (m *Params) GetBtcConfirmationDepth() uint32 { if m != nil { return m.BtcConfirmationDepth } return 0 } -func (m *Params) GetCheckpointFinalizationTimeout() uint64 { +func (m *Params) GetCheckpointFinalizationTimeout() uint32 { if m != nil { return m.CheckpointFinalizationTimeout } @@ -112,7 +112,7 @@ var fileDescriptor_5445a19005ae983c = []byte{ 0x9e, 0x0f, 0x56, 0xa4, 0x0f, 0x62, 0x41, 0xd4, 0x2b, 0xcd, 0x65, 0xe2, 0x62, 0x0b, 0x00, 0x1b, 0x20, 0x14, 0xce, 0x25, 0x96, 0x54, 0x92, 0x1c, 0x9f, 0x9c, 0x9f, 0x97, 0x96, 0x59, 0x94, 0x9b, 0x58, 0x92, 0x99, 0x9f, 0x17, 0x9f, 0x92, 0x5a, 0x50, 0x92, 0x21, 0xc1, 0xa8, 0xc0, 0xa8, 0xc1, - 0xe2, 0xa4, 0xf8, 0xe9, 0x9e, 0xbc, 0x6c, 0x65, 0x62, 0x6e, 0x8e, 0x95, 0x12, 0x76, 0x75, 0x4a, + 0xeb, 0xa4, 0xf8, 0xe9, 0x9e, 0xbc, 0x6c, 0x65, 0x62, 0x6e, 0x8e, 0x95, 0x12, 0x76, 0x75, 0x4a, 0x41, 0x22, 0x49, 0x25, 0xc9, 0xce, 0x48, 0xe2, 0x2e, 0x20, 0x61, 0xa1, 0x22, 0x2e, 0x79, 0x84, 0x53, 0xe2, 0xd3, 0x32, 0xf3, 0x12, 0x73, 0x32, 0xab, 0x20, 0xfa, 0x4a, 0x32, 0x73, 0x53, 0xf3, 0x4b, 0x4b, 0x24, 0x98, 0xc0, 0x36, 0x68, 0x7d, 0xba, 0x27, 0xaf, 0x06, 0xb1, 0x81, 0x80, 0x06, @@ -123,7 +123,7 @@ var fileDescriptor_5445a19005ae983c = []byte{ 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0x99, 0xa7, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x43, 0x03, 0x3d, 0x27, 0x31, 0xa9, 0x58, 0x37, 0x33, 0x1f, 0xc6, 0xd5, 0xaf, 0x40, 0x8b, 0xac, 0x92, 0xca, 0x82, 0xd4, - 0xe2, 0x24, 0x36, 0x70, 0xc8, 0x1b, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x8e, 0x82, 0xde, 0x0b, + 0xe2, 0x24, 0x36, 0x70, 0xc8, 0x1b, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0xc3, 0x4e, 0xe2, 0x30, 0xd2, 0x01, 0x00, 0x00, } @@ -276,7 +276,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.BtcConfirmationDepth |= uint64(b&0x7F) << shift + m.BtcConfirmationDepth |= uint32(b&0x7F) << shift if b < 0x80 { break } @@ -295,7 +295,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.CheckpointFinalizationTimeout |= uint64(b&0x7F) << shift + m.CheckpointFinalizationTimeout |= uint32(b&0x7F) << shift if b < 0x80 { break } diff --git a/x/btccheckpoint/types/query.pb.go b/x/btccheckpoint/types/query.pb.go index 88a83251e..e989b2b2d 100644 --- a/x/btccheckpoint/types/query.pb.go +++ b/x/btccheckpoint/types/query.pb.go @@ -410,7 +410,7 @@ type BTCCheckpointInfoResponse struct { // EpochNumber of this checkpoint. EpochNumber uint64 `protobuf:"varint,1,opt,name=epoch_number,json=epochNumber,proto3" json:"epoch_number,omitempty"` // btc height of the best submission of the epoch - BestSubmissionBtcBlockHeight uint64 `protobuf:"varint,2,opt,name=best_submission_btc_block_height,json=bestSubmissionBtcBlockHeight,proto3" json:"best_submission_btc_block_height,omitempty"` + BestSubmissionBtcBlockHeight uint32 `protobuf:"varint,2,opt,name=best_submission_btc_block_height,json=bestSubmissionBtcBlockHeight,proto3" json:"best_submission_btc_block_height,omitempty"` // hash of the btc block which determines checkpoint btc block height i.e. // youngest block of best submission Hexadecimal BestSubmissionBtcBlockHash string `protobuf:"bytes,3,opt,name=best_submission_btc_block_hash,json=bestSubmissionBtcBlockHash,proto3" json:"best_submission_btc_block_hash,omitempty"` @@ -460,7 +460,7 @@ func (m *BTCCheckpointInfoResponse) GetEpochNumber() uint64 { return 0 } -func (m *BTCCheckpointInfoResponse) GetBestSubmissionBtcBlockHeight() uint64 { +func (m *BTCCheckpointInfoResponse) GetBestSubmissionBtcBlockHeight() uint32 { if m != nil { return m.BestSubmissionBtcBlockHeight } @@ -720,67 +720,67 @@ func init() { } var fileDescriptor_6b9a2f46ada7d854 = []byte{ - // 950 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x56, 0x41, 0x6f, 0x1b, 0x45, - 0x14, 0xce, 0x3a, 0x9b, 0x28, 0x7e, 0x69, 0xa1, 0x9d, 0x1a, 0xe1, 0x38, 0xc1, 0x75, 0x57, 0x6d, - 0x1a, 0x21, 0xbc, 0x2b, 0x37, 0xd0, 0x50, 0x81, 0x90, 0x70, 0x44, 0x4b, 0x05, 0x42, 0xe9, 0x36, - 0x70, 0xe0, 0xb2, 0x9a, 0x5d, 0x4f, 0xd6, 0xa3, 0xd8, 0x3b, 0xdb, 0x9d, 0x71, 0x14, 0xab, 0xe2, - 0xc2, 0x0d, 0x71, 0x00, 0x89, 0xbf,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0x5c, 0xd1, 0x7e, 0xab, 0xbd, 0x7b, 0x71, 0xa2, 0xb6, 0xdc, 0x94, 0x96, 0x6f, 0xa3, 0x5b, 0xc5, - 0x96, 0x9f, 0x8e, 0x3f, 0x64, 0x5f, 0xa1, 0x1f, 0x0d, 0x40, 0xb3, 0x1b, 0x05, 0x5d, 0xa8, 0x7e, - 0x7e, 0xdf, 0xd5, 0xee, 0xbd, 0x04, 0x53, 0x5b, 0xbf, 0x21, 0xad, 0xaf, 0xa3, 0xb5, 0x42, 0xeb, - 0xe8, 0x57, 0x03, 0xae, 0x4c, 0x6f, 0x01, 0x74, 0x77, 0x4e, 0xc9, 0x82, 0x9d, 0x53, 0xdb, 0xb9, - 0x30, 0x4f, 0x1b, 0xbd, 0x27, 0x8d, 0x6e, 0xa3, 0xd6, 0xb9, 0x32, 0x76, 0xb2, 0xaf, 0x21, 0x6f, - 0x3f, 0x7a, 0x76, 0x52, 0x37, 0x9e, 0x9f, 0xd4, 0x8d, 0x7f, 0x4f, 0xea, 0xc6, 0xf7, 0xa7, 0xf5, - 0x85, 0xe7, 0xa7, 0xf5, 0x85, 0xbf, 0x4f, 0xeb, 0x0b, 0x5f, 0xee, 0x84, 0x54, 0x74, 0x07, 0xbe, - 0x1d, 0xb0, 0xfe, 0x48, 0xb6, 0x87, 0x7d, 0xde, 0xa4, 0x6c, 0x5c, 0xe5, 0x78, 0xaa, 0x8e, 0x18, - 0xc6, 0x84, 0xfb, 0xcb, 0xf2, 0x1f, 0xb4, 0xed, 0xff, 0x03, 0x00, 0x00, 0xff, 0xff, 0x12, 0x02, - 0x0c, 0x21, 0x84, 0x0a, 0x00, 0x00, + // 948 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x56, 0x4f, 0x6f, 0x1b, 0x45, + 0x14, 0xcf, 0x26, 0x4e, 0x14, 0xbf, 0x34, 0xd0, 0x4e, 0x8d, 0x70, 0x9c, 0xe0, 0xba, 0xab, 0x36, + 0x8d, 0x10, 0xde, 0x95, 0x1b, 0x68, 0xa8, 0x40, 0x48, 0x38, 0xa2, 0xa5, 0x02, 0xa1, 0x74, 0x1b, + 0x38, 0x70, 0x59, 0xcd, 0xae, 0x27, 0xeb, 0x51, 0xec, 0x9d, 0xed, 0xce, 0x38, 0x8a, 0x55, 0x71, + 0xe1, 0x86, 0x38, 0x80, 0xc4, 0xd7, 0xe0, 0x08, 0x37, 0x84, 0xc4, 0x01, 0xa9, 0x12, 0x97, 0x0a, + 0x2e, 0x9c, 0x10, 0x4a, 0xf8, 0x20, 0x68, 0x67, 0xc6, 0xbb, 0x6b, 0x3b, 0x5b, 0x27, 0xb9, 0x79, + 0x77, 0x7e, 0xff, 0xe6, 0xbd, 0x97, 0x7d, 0x81, 0x5b, 0x1e, 0xf6, 0x86, 0x3d, 0x16, 0xda, 0x9e, + 0xf0, 0xfd, 0x2e, 0xf1, 0x0f, 0x23, 0x46, 0x43, 0x61, 0x1f, 0xb5, 0xec, 0xa7, 0x03, 0x12, 0x0f, + 0xad, 0x28, 0x66, 0x82, 0xa1, 0xaa, 0x46, 0x59, 0x63, 0x28, 0xeb, 0xa8, 0x55, 0xab, 0x04, 0x2c, + 0x60, 0x12, 0x64, 0x27, 0xbf, 0x14, 0xbe, 0xb6, 0xe6, 0x33, 0xde, 0x67, 0xdc, 0x55, 0x07, 0xea, + 0x41, 0x1f, 0x6d, 0x04, 0x8c, 0x05, 0x3d, 0x62, 0xe3, 0x88, 0xda, 0x38, 0x0c, 0x99, 0xc0, 0x82, + 0xb2, 0x70, 0x74, 0xfa, 0xa6, 0xc2, 0xda, 0x1e, 0xe6, 0x44, 0x25, 0xb0, 0x8f, 0x5a, 0x1e, 0x11, + 0xb8, 0x65, 0x47, 0x38, 0xa0, 0xa1, 0x04, 0x6b, 0xec, 0xed, 0xc2, 0xe8, 0x11, 0x8e, 0x71, 0x5f, + 0x4b, 0x9a, 0x15, 0x40, 0x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ff, 0x28, 0x69, 0xd2, 0x93, 0x81, + 0xd7, 0xa7, 0x9c, 0x27, 0x03, 0x7b, 0xae, 0x86, 0x76, 0xf4, 0x38, 0x4c, 0x93, 0xf5, 0xc5, 0x77, + 0xa1, 0x74, 0x48, 0x86, 0x5c, 0xdf, 0xd9, 0x2e, 0xbe, 0x73, 0x46, 0xfe, 0x84, 0x0c, 0xb3, 0x5e, + 0x26, 0x64, 0xf3, 0x8f, 0x05, 0x58, 0x2b, 0xac, 0x09, 0xba, 0x09, 0x57, 0xd2, 0x80, 0x1e, 0x89, + 0x75, 0xc6, 0x95, 0x51, 0x46, 0x8f, 0xc4, 0xe8, 0x01, 0x34, 0x3c, 0xc2, 0x85, 0xcb, 0x53, 0x13, + 0xd7, 0x13, 0xbe, 0xeb, 0xf5, 0x98, 0x7f, 0xe8, 0x76, 0x09, 0x0d, 0xba, 0x42, 0x96, 0x70, 0xd5, + 0xd9, 0x48, 0x70, 0x59, 0x96, 0xb6, 0xf0, 0xdb, 0x09, 0xe8, 0x63, 0x89, 0x41, 0x6d, 0xa8, 0xbf, + 0x44, 0x07, 0xf3, 0x6e, 0x75, 0xa1, 0x61, 0x6c, 0x95, 0x9d, 0x5a, 0x81, 0x0a, 0xe6, 0x5d, 0xc4, + 0x61, 0x63, 0x52, 0x43, 0xc4, 0x38, 0xe4, 0xd8, 0x97, 0xdf, 0x89, 0x6a, 0x49, 0x56, 0xaa, 0x55, + 0x5c, 0xa9, 0xfd, 0x0c, 0x3d, 0x36, 0x1b, 0x13, 0xa6, 0x39, 0x18, 0x47, 0xdf, 0x18, 0xb0, 0x39, + 0xe9, 0x7a, 0x44, 0x03, 0xda, 0xc3, 0xa1, 0x20, 0x2e, 0xee, 0x74, 0x62, 0xc2, 0xb9, 0x9a, 0xce, + 0x45, 0xe9, 0xff, 0x4e, 0xb1, 0x7f, 0xd6, 0x86, 0x0f, 0x15, 0x8f, 0xa4, 0xed, 0x76, 0xcc, 0xf1, + 0x0c, 0x5f, 0x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c, + 0x84, 0x0a, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -2373,7 +2373,7 @@ func (m *BTCCheckpointInfoResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.BestSubmissionBtcBlockHeight |= uint64(b&0x7F) << shift + m.BestSubmissionBtcBlockHeight |= uint32(b&0x7F) << shift if b < 0x80 { break } diff --git a/x/btccheckpoint/types/types.go b/x/btccheckpoint/types/types.go index 63d5eba3d..7a55899d2 100644 --- a/x/btccheckpoint/types/types.go +++ b/x/btccheckpoint/types/types.go @@ -29,10 +29,10 @@ type RawCheckpointSubmission struct { type SubmissionBtcInfo struct { SubmissionKey SubmissionKey // Depth of the oldest btc header of the submission - OldestBlockDepth uint64 + OldestBlockDepth uint32 // Depth of the youngest btc header of the submission - YoungestBlockDepth uint64 + YoungestBlockDepth uint32 // Hash of the youngest btc header of the submission YoungestBlockHash types.BTCHeaderHashBytes @@ -136,7 +136,7 @@ func (submission *SubmissionBtcInfo) HappenedAfter(parentEpochSubmission *Submis // SubmissionDepth return depth of the submission. Due to the fact that submissions // are split between several btc blocks, in Babylon submission depth is the depth // of the youngest btc block -func (submission *SubmissionBtcInfo) SubmissionDepth() uint64 { +func (submission *SubmissionBtcInfo) SubmissionDepth() uint32 { return submission.YoungestBlockDepth } diff --git a/x/btclightclient/README.md b/x/btclightclient/README.md index 7b7134b97..e43943bf6 100644 --- a/x/btclightclient/README.md +++ b/x/btclightclient/README.md @@ -119,7 +119,7 @@ message BTCHeaderInfo { bytes hash = 2 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BTCHeaderHashBytes" ]; - uint64 height = 3; + uint32 height = 3; bytes work = 4 [ (gogoproto.customtype) = "cosmossdk.io/math.Uint" ]; } diff --git a/x/btclightclient/genesis_test.go b/x/btclightclient/genesis_test.go index e51628156..62ad9f028 100644 --- a/x/btclightclient/genesis_test.go +++ b/x/btclightclient/genesis_test.go @@ -55,7 +55,6 @@ func TestImportExport(t *testing.T) { chainExtension := datagen.GenRandomValidChainStartingFrom( r, - initTip.Height, initTip.Header.ToBlockHeader(), nil, 10, @@ -71,7 +70,6 @@ func TestImportExport(t *testing.T) { newChainExt := datagen.GenRandomValidChainStartingFrom( r, - newTip.Height, newTip.Header.ToBlockHeader(), nil, 10, diff --git a/x/btclightclient/keeper/grpc_query.go b/x/btclightclient/keeper/grpc_query.go index 91d3792e8..9024cc605 100644 --- a/x/btclightclient/keeper/grpc_query.go +++ b/x/btclightclient/keeper/grpc_query.go @@ -2,6 +2,7 @@ package keeper import ( "context" + "fmt" bbn "github.com/babylonlabs-io/babylon/types" "github.com/babylonlabs-io/babylon/x/btclightclient/types" @@ -11,6 +12,8 @@ import ( "google.golang.org/grpc/status" ) +const MaxHeadersPerRequest uint32 = 1000 + var _ types.QueryServer = Keeper{} func (k Keeper) Params(c context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { @@ -91,6 +94,10 @@ func (k Keeper) MainChain(c context.Context, req *types.QueryMainChainRequest) ( req.Pagination.Limit = query.DefaultLimit } + if req.Pagination.Limit > uint64(MaxHeadersPerRequest) { + return nil, status.Error(codes.InvalidArgument, fmt.Sprintf("pagination limit is larger than the maximum limit of %d", MaxHeadersPerRequest)) + } + var keyHeader *types.BTCHeaderInfo if len(req.Pagination.Key) != 0 { headerHash, err := bbn.NewBTCHeaderHashBytesFromBytes(req.Pagination.Key) @@ -106,7 +113,7 @@ func (k Keeper) MainChain(c context.Context, req *types.QueryMainChainRequest) ( var headers []*types.BTCHeaderInfo var nextKey []byte if req.Pagination.Reverse { - var start, end uint64 + var start, end uint32 baseHeader := k.headersState(ctx).BaseHeader() // The base header is located at the end of the mainchain // which requires starting at the end @@ -118,19 +125,20 @@ func (k Keeper) MainChain(c context.Context, req *types.QueryMainChainRequest) ( } else { start = keyHeader.Height - baseHeader.Height } - end = start + req.Pagination.Limit + // req.Pagination.Limit can be safely converted as `MaxHeadersPerRequest` is a uint32 + end = start + uint32(req.Pagination.Limit) - if end >= uint64(len(mainchain)) { - end = uint64(len(mainchain)) + if int(end) >= len(mainchain) { + end = uint32(len(mainchain)) } // If the header's position on the mainchain is larger than the entire mainchain, then it is not part of the mainchain // Also, if the element at the header's position on the mainchain is not the provided one, then it is not part of the mainchain - if start >= uint64(len(mainchain)) || !mainchain[start].Eq(keyHeader) { + if int(start) >= len(mainchain) || !mainchain[start].Eq(keyHeader) { return nil, status.Error(codes.InvalidArgument, "header specified by key is not a part of the mainchain") } headers = mainchain[start:end] - if end < uint64(len(mainchain)) { + if int(end) < len(mainchain) { nextKey = mainchain[end].Hash.MustMarshal() } } else { @@ -143,11 +151,12 @@ func (k Keeper) MainChain(c context.Context, req *types.QueryMainChainRequest) ( startHeaderDepth := tip.Height - keyHeader.Height // The depth that we want to retrieve up to // -1 because the depth denotes how many headers have been built on top of it - depth := startHeaderDepth + req.Pagination.Limit - 1 + // req.Pagination.Limit can be safely converted as `MaxHeadersPerRequest` is a uint32 + depth := startHeaderDepth + uint32(req.Pagination.Limit) - 1 // Retrieve the mainchain up to the depth mainchain := k.GetMainChainUpTo(ctx, depth) // Check whether the key provided is part of the mainchain - if uint64(len(mainchain)) <= startHeaderDepth || !mainchain[startHeaderDepth].Eq(keyHeader) { + if uint32(len(mainchain)) <= startHeaderDepth || !mainchain[startHeaderDepth].Eq(keyHeader) { return nil, status.Error(codes.InvalidArgument, "header specified by key is not a part of the mainchain") } @@ -205,5 +214,5 @@ func (k Keeper) HeaderDepth(ctx context.Context, req *types.QueryHeaderDepthRequ return nil, err } - return &types.QueryHeaderDepthResponse{Depth: uint64(depth)}, nil + return &types.QueryHeaderDepthResponse{Depth: depth}, nil } diff --git a/x/btclightclient/keeper/grpc_query_test.go b/x/btclightclient/keeper/grpc_query_test.go index 6a6fed783..4e97f58c5 100644 --- a/x/btclightclient/keeper/grpc_query_test.go +++ b/x/btclightclient/keeper/grpc_query_test.go @@ -65,7 +65,7 @@ func FuzzHashesQuery(f *testing.F) { blcKeeper, ctx, 0, - datagen.RandomInt(r, 50)+100, + uint32(datagen.RandomInt(r, 50))+100, ) // Get the headers map @@ -74,17 +74,17 @@ func FuzzHashesQuery(f *testing.F) { // + 1 is necessary to account for the base header totalChainLength := chain.ChainLength() + 1 - chainSize := uint64(totalChainLength) - limit := uint64(r.Int63n(int64(totalChainLength)) + 1) + chainSize := uint32(totalChainLength) + limit := uint32(r.Int31n(int32(totalChainLength))) + 1 // Generate a page request with a limit and a nil key - pagination = constructRequestWithLimit(r, limit) + pagination = constructRequestWithLimit(r, uint64(limit)) // Generate the initial query hashesRequest = types.NewQueryHashesRequest(pagination) // Construct a mapping from the hashes found to a boolean value // Will be used later to evaluate whether all the hashes were returned hashesFound := make(map[string]bool, 0) - for headersRetrieved := uint64(0); headersRetrieved < chainSize; headersRetrieved += limit { + for headersRetrieved := uint32(0); headersRetrieved < chainSize; headersRetrieved += limit { resp, err = blcKeeper.Hashes(ctx, hashesRequest) if err != nil { t.Errorf("Valid request led to an error %s", err) @@ -93,11 +93,11 @@ func FuzzHashesQuery(f *testing.F) { t.Fatalf("Valid request led to a nil response") } // If we are on the last page the elements retrieved should be equal to the remaining ones - if headersRetrieved+limit >= chainSize && uint64(len(resp.Hashes)) != chainSize-headersRetrieved { + if headersRetrieved+uint32(limit) >= chainSize && uint32(len(resp.Hashes)) != chainSize-headersRetrieved { t.Fatalf("On the last page expected %d elements but got %d", chainSize-headersRetrieved, len(resp.Hashes)) } // Otherwise, the elements retrieved should be equal to the limit - if headersRetrieved+limit < chainSize && uint64(len(resp.Hashes)) != limit { + if headersRetrieved+uint32(limit) < chainSize && uint32(len(resp.Hashes)) != limit { t.Fatalf("On an intermediate page expected %d elements but got %d", limit, len(resp.Hashes)) } @@ -110,7 +110,7 @@ func FuzzHashesQuery(f *testing.F) { } // Construct the next page request - pagination = constructRequestWithKeyAndLimit(r, resp.Pagination.NextKey, limit) + pagination = constructRequestWithKeyAndLimit(r, resp.Pagination.NextKey, uint64(limit)) hashesRequest = types.NewQueryHashesRequest(pagination) } @@ -151,7 +151,7 @@ func FuzzContainsQuery(f *testing.F) { blcKeeper, ctx, 0, - datagen.RandomInt(r, 50)+100, + uint32(datagen.RandomInt(r, 50))+100, ) // Test with a non-existent header @@ -232,7 +232,7 @@ func FuzzMainChainQuery(f *testing.F) { blcKeeper, ctx, 0, - datagen.RandomInt(r, 50)+100, + uint32(datagen.RandomInt(r, 50))+100, ) // Check whether the key being set to an element that does not exist leads to an error @@ -261,12 +261,12 @@ func FuzzMainChainQuery(f *testing.F) { // Index into the current element of mainchain that we are iterating mcIdx := 0 // Generate a random limit - mcSize := uint64(len(mainchain)) - limit := uint64(r.Int63n(int64(len(mainchain))) + 1) + mcSize := uint32(len(mainchain)) + limit := uint32(r.Int31n(int32(len(mainchain))) + 1) // 50% of the time, do a reverse request // Generate a page request with a limit and a nil key - pagination = constructRequestWithLimit(r, limit) + pagination = constructRequestWithLimit(r, uint64(limit)) reverse := false if datagen.OneInN(r, 2) { reverse = true @@ -274,7 +274,7 @@ func FuzzMainChainQuery(f *testing.F) { } // Generate the initial query mainchainRequest = types.NewQueryMainChainRequest(pagination) - for headersRetrieved := uint64(0); headersRetrieved < mcSize; headersRetrieved += limit { + for headersRetrieved := uint32(0); headersRetrieved < mcSize; headersRetrieved += limit { resp, err = blcKeeper.MainChain(ctx, mainchainRequest) if err != nil { t.Errorf("Valid request led to an error %s", err) @@ -283,11 +283,11 @@ func FuzzMainChainQuery(f *testing.F) { t.Fatalf("Valid request led to nil response") } // If we are on the last page the elements retrieved should be equal to the remaining ones - if headersRetrieved+limit >= mcSize && uint64(len(resp.Headers)) != mcSize-headersRetrieved { + if headersRetrieved+limit >= mcSize && uint32(len(resp.Headers)) != mcSize-headersRetrieved { t.Fatalf("On the last page expected %d elements but got %d", mcSize-headersRetrieved, len(resp.Headers)) } // Otherwise, the elements retrieved should be equal to the limit - if headersRetrieved+limit < mcSize && uint64(len(resp.Headers)) != limit { + if headersRetrieved+limit < mcSize && uint32(len(resp.Headers)) != limit { t.Fatalf("On an intermediate page expected %d elements but got %d", limit, len(resp.Headers)) } @@ -306,7 +306,7 @@ func FuzzMainChainQuery(f *testing.F) { } // Construct the next page request - pagination = constructRequestWithKeyAndLimit(r, resp.Pagination.NextKey, limit) + pagination = constructRequestWithKeyAndLimit(r, resp.Pagination.NextKey, uint64(limit)) if reverse { pagination.Reverse = true } @@ -345,7 +345,7 @@ func FuzzTipQuery(f *testing.F) { blcKeeper, ctx, 0, - datagen.RandomInt(r, 50)+100, + uint32(datagen.RandomInt(r, 50))+100, ) resp, err = blcKeeper.Tip(ctx, types.NewQueryTipRequest()) @@ -391,7 +391,7 @@ func FuzzBaseHeaderQuery(f *testing.F) { blcKeeper, ctx, 0, - datagen.RandomInt(r, 50)+100, + uint32(datagen.RandomInt(r, 50))+100, ) resp, err = blcKeeper.BaseHeader(ctx, types.NewQueryBaseHeaderRequest()) @@ -411,7 +411,7 @@ func FuzzBaseHeaderQuery(f *testing.F) { func constructRequestWithKeyAndLimit(r *rand.Rand, key []byte, limit uint64) *query.PageRequest { // If limit is 0, set one randomly if limit == 0 { - limit = uint64(r.Int63() + 1) // Use Int63 instead of Uint64 to avoid overflows + limit = uint64(r.Int31n(100) + 1) // Use Int31 instead to avoid overflows } return &query.PageRequest{ Key: key, diff --git a/x/btclightclient/keeper/keeper.go b/x/btclightclient/keeper/keeper.go index a5a741044..ecc1b3d3f 100644 --- a/x/btclightclient/keeper/keeper.go +++ b/x/btclightclient/keeper/keeper.go @@ -188,7 +188,7 @@ func btcHeadersBytesToBlockHeader(headers []bbn.BTCHeaderBytes) []*wire.BlockHea } // BlockHeight returns the height of the provided header -func (k Keeper) BlockHeight(ctx context.Context, headerHash *bbn.BTCHeaderHashBytes) (uint64, error) { +func (k Keeper) BlockHeight(ctx context.Context, headerHash *bbn.BTCHeaderHashBytes) (uint32, error) { if headerHash == nil { return 0, types.ErrEmptyMessage } @@ -202,8 +202,8 @@ func (k Keeper) BlockHeight(ctx context.Context, headerHash *bbn.BTCHeaderHashBy return headerInfo.Height, nil } -// MainChainDepth returns the depth of the header in the main chain, or error if it does not exists -func (k Keeper) MainChainDepth(ctx context.Context, headerHashBytes *bbn.BTCHeaderHashBytes) (uint64, error) { +// MainChainDepth returns the depth of the header in the main chain, or error if it does not exist +func (k Keeper) MainChainDepth(ctx context.Context, headerHashBytes *bbn.BTCHeaderHashBytes) (uint32, error) { if headerHashBytes == nil { return 0, types.ErrEmptyMessage } @@ -241,7 +241,7 @@ func (k Keeper) GetHeaderByHash(ctx context.Context, hash *bbn.BTCHeaderHashByte } // GetHeaderByHeight returns header with given height from main chain, returns nil if such header is not found -func (k Keeper) GetHeaderByHeight(ctx context.Context, height uint64) *types.BTCHeaderInfo { +func (k Keeper) GetHeaderByHeight(ctx context.Context, height uint32) *types.BTCHeaderInfo { header, err := k.headersState(ctx).GetHeaderByHeight(height) if err != nil { @@ -254,7 +254,7 @@ func (k Keeper) GetHeaderByHeight(ctx context.Context, height uint64) *types.BTC // GetMainChainFrom returns the current canonical chain from the given height up to the tip // If the height is higher than the tip, it returns an empty slice // If startHeight is 0, it returns the entire main chain -func (k Keeper) GetMainChainFrom(ctx context.Context, startHeight uint64) []*types.BTCHeaderInfo { +func (k Keeper) GetMainChainFrom(ctx context.Context, startHeight uint32) []*types.BTCHeaderInfo { headers := make([]*types.BTCHeaderInfo, 0) accHeaderFn := func(header *types.BTCHeaderInfo) bool { headers = append(headers, header) @@ -267,7 +267,7 @@ func (k Keeper) GetMainChainFrom(ctx context.Context, startHeight uint64) []*typ // GetMainChainFromWithLimit returns the current canonical chain from the given height up to the tip // If the height is higher than the tip, it returns an empty slice // If startHeight is 0, it returns the entire main chain -func (k Keeper) GetMainChainFromWithLimit(ctx context.Context, startHeight uint64, limit uint32) []*types.BTCHeaderInfo { +func (k Keeper) GetMainChainFromWithLimit(ctx context.Context, startHeight uint32, limit uint32) []*types.BTCHeaderInfo { headers := make([]*types.BTCHeaderInfo, 0, limit) fn := func(header *types.BTCHeaderInfo) bool { if len(headers) >= int(limit) { @@ -282,10 +282,10 @@ func (k Keeper) GetMainChainFromWithLimit(ctx context.Context, startHeight uint6 // GetMainChainUpTo returns the current canonical chain as a collection of block headers // starting from the tip and ending on the header that has `depth` distance from it. -func (k Keeper) GetMainChainUpTo(ctx context.Context, depth uint64) []*types.BTCHeaderInfo { +func (k Keeper) GetMainChainUpTo(ctx context.Context, depth uint32) []*types.BTCHeaderInfo { headers := make([]*types.BTCHeaderInfo, 0) - var currentDepth = uint64(0) + var currentDepth = uint32(0) accHeaderFn := func(header *types.BTCHeaderInfo) bool { // header header is at depth 0. if currentDepth > depth { diff --git a/x/btclightclient/keeper/keeper_test.go b/x/btclightclient/keeper/keeper_test.go index 6db96ae53..89aaa3b83 100644 --- a/x/btclightclient/keeper/keeper_test.go +++ b/x/btclightclient/keeper/keeper_test.go @@ -59,7 +59,7 @@ func FuzzKeeperMainChainDepth(f *testing.F) { blcKeeper, ctx, 0, - datagen.RandomInt(r, 50)+10, + uint32(datagen.RandomInt(r, 50))+10, ) randomHeader := chain.GetRandomHeaderInfo(r) depth, err = blcKeeper.MainChainDepth(ctx, randomHeader.Hash) @@ -112,7 +112,7 @@ func FuzzKeeperBlockHeight(f *testing.F) { blcKeeper, ctx, 0, - datagen.RandomInt(r, 50)+10, + uint32(datagen.RandomInt(r, 50))+10, ) header := chain.GetRandomHeaderInfo(r) @@ -137,8 +137,8 @@ func FuzzKeeperInsertValidChainExtension(f *testing.F) { r, blcKeeper, ctx, - datagen.RandomInt(r, 50)+10, - datagen.RandomInt(r, 50)+10, + uint32(datagen.RandomInt(r, 50))+10, + uint32(datagen.RandomInt(r, 50))+10, ) mockHooks := NewMockHooks() @@ -148,7 +148,6 @@ func FuzzKeeperInsertValidChainExtension(f *testing.F) { chainToInsert := datagen.GenRandomValidChainStartingFrom( r, - chain.GetTipInfo().Height, chain.GetTipInfo().Header.ToBlockHeader(), nil, newChainLength, @@ -158,7 +157,7 @@ func FuzzKeeperInsertValidChainExtension(f *testing.F) { ctx = ctx.WithEventManager(sdk.NewEventManager()) oldTip := blcKeeper.HeadersState(ctx).GetTip() extendedChainWork := oldTip.Work.Add(*chainExtensionWork) - extendedChainHeight := uint64(uint32(oldTip.Height) + newChainLength) + extendedChainHeight := oldTip.Height + newChainLength err := blcKeeper.InsertHeadersWithHookAndEvents(ctx, keepertest.NewBTCHeaderBytesList(chainToInsert)) require.NoError(t, err) @@ -219,8 +218,8 @@ func FuzzKeeperInsertValidBetterChain(f *testing.F) { r, blcKeeper, ctx, - datagen.RandomInt(r, 50)+10, - datagen.RandomInt(r, 50)+10, + uint32(datagen.RandomInt(r, 50))+10, + uint32(datagen.RandomInt(r, 50))+10, ) mockHooks := NewMockHooks() @@ -231,7 +230,6 @@ func FuzzKeeperInsertValidBetterChain(f *testing.F) { newChainLength := uint32(chain.ChainLength() + 1) chainToInsert := datagen.GenRandomValidChainStartingFrom( r, - forkHeaderParent.Height, forkHeaderParent.Header.ToBlockHeader(), nil, newChainLength, @@ -240,7 +238,7 @@ func FuzzKeeperInsertValidBetterChain(f *testing.F) { ctx = ctx.WithEventManager(sdk.NewEventManager()) extendedChainWork := forkHeaderParent.Work.Add(*chainExtensionWork) - extendedChainHeight := uint64(uint32(forkHeaderParent.Height) + newChainLength) + extendedChainHeight := forkHeaderParent.Height + newChainLength oldTip := blcKeeper.HeadersState(ctx).GetTip() removedBranch := blcKeeper.GetMainChainFrom(ctx, forkHeaderParent.Height+1) @@ -326,7 +324,7 @@ func FuzzKeeperInsertInvalidChain(f *testing.F) { blcKeeper, ctx, 0, - datagen.RandomInt(r, 50)+10, + uint32(datagen.RandomInt(r, 50))+10, ) currentTip := blcKeeper.GetTipInfo(ctx) require.NotNil(t, currentTip) @@ -350,7 +348,6 @@ func FuzzKeeperInsertInvalidChain(f *testing.F) { // valid chain with at least 5 headers chainToInsert := datagen.GenRandomValidChainStartingFrom( r, - chain.GetTipInfo().Height, chain.GetTipInfo().Header.ToBlockHeader(), nil, newChainLength, @@ -369,7 +366,6 @@ func FuzzKeeperInsertInvalidChain(f *testing.F) { require.NotNil(t, headerBeforeTip) worseChain := datagen.GenRandomValidChainStartingFrom( r, - headerBeforeTip.Height, headerBeforeTip.Header.ToBlockHeader(), nil, 1, @@ -420,7 +416,7 @@ func FuzzKeeperValdateHeaderAtDifficultyAdjustmentBoundaries(f *testing.F) { currentTip := blcKeeper.GetTipInfo(ctx) require.NotNil(t, currentTip) - require.Equal(t, currentTip.Height, uint64(numBlockPerRetarget)-1) + require.Equal(t, currentTip.Height, uint32(numBlockPerRetarget)-1) invalidAdjustedHeader := datagen.GenRandomBtcdValidHeader( r, @@ -452,7 +448,7 @@ func FuzzKeeperValdateHeaderAtDifficultyAdjustmentBoundaries(f *testing.F) { newTip := blcKeeper.GetTipInfo(ctx) require.NotNil(t, newTip) // tip should be at adjustment boundary now - require.Equal(t, newTip.Height, uint64(numBlockPerRetarget)) + require.Equal(t, newTip.Height, uint32(numBlockPerRetarget)) require.True(t, newTip.Header.Eq(&validAdjustedHeaderBytes)) require.True(t, types.IsRetargetBlock(newTip, &chaincfg.SimNetParams)) }) diff --git a/x/btclightclient/keeper/msg_server_test.go b/x/btclightclient/keeper/msg_server_test.go index 343b6859a..26eaac2aa 100644 --- a/x/btclightclient/keeper/msg_server_test.go +++ b/x/btclightclient/keeper/msg_server_test.go @@ -43,8 +43,8 @@ func FuzzMsgServerInsertNewTip(f *testing.F) { r, blcKeeper, ctx, - datagen.RandomInt(r, 50)+10, - datagen.RandomInt(r, 50)+10, + uint32(datagen.RandomInt(r, 50))+10, + uint32(datagen.RandomInt(r, 50))+10, ) initTip := chain.GetTipInfo() @@ -60,7 +60,6 @@ func FuzzMsgServerInsertNewTip(f *testing.F) { chainExenstionLength := uint32(r.Int31n(200) + 1) chainExtension := datagen.GenRandomValidChainStartingFrom( r, - initTip.Height, initTip.Header.ToBlockHeader(), nil, chainExenstionLength, @@ -73,7 +72,7 @@ func FuzzMsgServerInsertNewTip(f *testing.F) { require.NoError(t, err) extendedChainWork := initTip.Work.Add(*chainExtensionWork) - extendedChainHeight := uint64(uint32(initTip.Height) + chainExenstionLength) + extendedChainHeight := initTip.Height + chainExenstionLength checkTip( t, @@ -98,13 +97,13 @@ func FuzzMsgServerReorgChain(f *testing.F) { srv, blcKeeper, sdkCtx := setupMsgServer(t) ctx := sdk.UnwrapSDKContext(sdkCtx) - chainLength := datagen.RandomInt(r, 50) + 10 + chainLength := uint32(datagen.RandomInt(r, 50)) + 10 _, chain := datagen.GenRandBtcChainInsertingInKeeper( t, r, blcKeeper, ctx, - datagen.RandomInt(r, 50)+10, + uint32(datagen.RandomInt(r, 50))+10, chainLength, ) initTip := chain.GetTipInfo() @@ -118,17 +117,16 @@ func FuzzMsgServerReorgChain(f *testing.F) { initTip.Header.ToBlockHeader(), ) - reorgDepth := r.Intn(int(chainLength-1)) + 1 + reorgDepth := r.Int31n(int32(chainLength-1)) + 1 - forkHeaderHeight := initTip.Height - uint64(reorgDepth) + forkHeaderHeight := initTip.Height - uint32(reorgDepth) forkHeader := blcKeeper.GetHeaderByHeight(ctx, forkHeaderHeight) require.NotNil(t, forkHeader) // fork chain will always be longer that current c - forkChainLen := reorgDepth + 10 + forkChainLen := uint32(reorgDepth + 10) chainExtension := datagen.GenRandomValidChainStartingFrom( r, - forkHeader.Height, forkHeader.Header.ToBlockHeader(), nil, uint32(forkChainLen), @@ -140,7 +138,7 @@ func FuzzMsgServerReorgChain(f *testing.F) { require.NoError(t, err) extendedChainWork := forkHeader.Work.Add(*chainExtensionWork) - extendedChainHeight := forkHeader.Height + uint64(forkChainLen) + extendedChainHeight := forkHeader.Height + forkChainLen checkTip( t, @@ -194,7 +192,6 @@ func TestAllowUpdatesOnlyFromReportesInTheList(t *testing.T) { chainExtension := datagen.GenRandomValidChainStartingFrom( r, - initTip.Height, initTip.Header.ToBlockHeader(), nil, 10, @@ -210,7 +207,6 @@ func TestAllowUpdatesOnlyFromReportesInTheList(t *testing.T) { newChainExt := datagen.GenRandomValidChainStartingFrom( r, - newTip.Height, newTip.Header.ToBlockHeader(), nil, 10, diff --git a/x/btclightclient/keeper/state.go b/x/btclightclient/keeper/state.go index 55ddb4e71..55986659d 100644 --- a/x/btclightclient/keeper/state.go +++ b/x/btclightclient/keeper/state.go @@ -40,7 +40,7 @@ func (s headersState) insertHeader(h *types.BTCHeaderInfo) { // save concrete object s.headers.Set(headersKey, s.cdc.MustMarshal(h)) - s.hashToHeight.Set(heightKey, sdk.Uint64ToBigEndian(h.Height)) + s.hashToHeight.Set(heightKey, sdk.Uint64ToBigEndian(uint64(h.Height))) } func (s headersState) deleteHeader(h *types.BTCHeaderInfo) { @@ -53,7 +53,7 @@ func (s headersState) deleteHeader(h *types.BTCHeaderInfo) { s.hashToHeight.Delete(heightKey) } -func (s headersState) rollBackHeadersUpTo(height uint64) { +func (s headersState) rollBackHeadersUpTo(height uint32) { headersToDelete := make([]*types.BTCHeaderInfo, 0) handleInfoFn := func(header *types.BTCHeaderInfo) bool { @@ -80,7 +80,7 @@ func (s headersState) rollBackHeadersUpTo(height uint64) { } // GetHeaderByHeight Retrieve a header by its height and hash -func (s headersState) GetHeaderByHeight(height uint64) (*types.BTCHeaderInfo, error) { +func (s headersState) GetHeaderByHeight(height uint32) (*types.BTCHeaderInfo, error) { headersKey := types.HeadersObjectKey(height) // Retrieve the raw bytes @@ -165,7 +165,7 @@ func (s headersState) IterateReverseHeaders(fn func(*types.BTCHeaderInfo) bool) // - if startPoint is lower that the lowest height, it will start from the lowest height // - if startPoint is higher than the highest height, it will not iterate at all i.e provided // callback will not be called -func (s headersState) IterateForwardHeaders(startPoint uint64, fn func(*types.BTCHeaderInfo) bool) { +func (s headersState) IterateForwardHeaders(startPoint uint32, fn func(*types.BTCHeaderInfo) bool) { // Iterate it in increasing order to get lowest heights first var startKey []byte = nil if startPoint != 0 { diff --git a/x/btclightclient/keeper/state_test.go b/x/btclightclient/keeper/state_test.go index 10d5e34e8..018e194e9 100644 --- a/x/btclightclient/keeper/state_test.go +++ b/x/btclightclient/keeper/state_test.go @@ -22,7 +22,7 @@ func FuzzHeadersStateCreateHeader(f *testing.F) { Data generation: - Create four headers: 1. The Base header. This will test whether the tip is set. - 2. Create random chain of of headers, and insert them into the state + 2. Create random chain of headers, and insert them into the state 3. All operations should be consistent with each other. */ datagen.AddRandomSeedsToFuzzer(f, 10) @@ -57,9 +57,9 @@ func FuzzHeadersStateCreateHeader(f *testing.F) { require.Error(t, err) // 10 to 60 headers - chainLength := datagen.RandomInt(r, 50) + 10 + chainLength := uint32(datagen.RandomInt(r, 50) + 10) // height from 10 to 60 - initchainHeight := datagen.RandomInt(r, 50) + 10 + initchainHeight := uint32(datagen.RandomInt(r, 50) + 10) // populate the state with random chain _, chain := datagen.GenRandBtcChainInsertingInKeeper( @@ -86,8 +86,8 @@ func FuzzHeadersStateCreateHeader(f *testing.F) { numBackward++ return false }) - require.Equal(t, chainLength+1, uint64(numForward)) - require.Equal(t, chainLength+1, uint64(numBackward)) + require.Equal(t, chainLength+1, uint32(numForward)) + require.Equal(t, chainLength+1, uint32(numBackward)) chainInfos := chain.GetChainInfo() diff --git a/x/btclightclient/keeper/utils_test.go b/x/btclightclient/keeper/utils_test.go index cbf1a3421..7c4504e15 100644 --- a/x/btclightclient/keeper/utils_test.go +++ b/x/btclightclient/keeper/utils_test.go @@ -56,7 +56,7 @@ func checkTip( ctx context.Context, blcKeeper *keeper.Keeper, expectedWork sdkmath.Uint, - expectedHeight uint64, + expectedHeight uint32, expectedTipHeader *wire.BlockHeader) { currentTip := blcKeeper.GetTipInfo(ctx) diff --git a/x/btclightclient/types/btc_header_info.go b/x/btclightclient/types/btc_header_info.go index 2cfdb00f6..866e08e97 100644 --- a/x/btclightclient/types/btc_header_info.go +++ b/x/btclightclient/types/btc_header_info.go @@ -8,7 +8,7 @@ import ( bbn "github.com/babylonlabs-io/babylon/types" ) -func NewBTCHeaderInfo(header *bbn.BTCHeaderBytes, headerHash *bbn.BTCHeaderHashBytes, height uint64, work *sdkmath.Uint) *BTCHeaderInfo { +func NewBTCHeaderInfo(header *bbn.BTCHeaderBytes, headerHash *bbn.BTCHeaderHashBytes, height uint32, work *sdkmath.Uint) *BTCHeaderInfo { return &BTCHeaderInfo{ Header: header, Hash: headerHash, @@ -55,7 +55,7 @@ func (m *BTCHeaderInfo) Validate() error { return nil } -func NewBTCHeaderInfoResponse(header *bbn.BTCHeaderBytes, headerHash *bbn.BTCHeaderHashBytes, height uint64, work *sdkmath.Uint) *BTCHeaderInfoResponse { +func NewBTCHeaderInfoResponse(header *bbn.BTCHeaderBytes, headerHash *bbn.BTCHeaderHashBytes, height uint32, work *sdkmath.Uint) *BTCHeaderInfoResponse { return &BTCHeaderInfoResponse{ HeaderHex: header.MarshalHex(), HashHex: headerHash.MarshalHex(), diff --git a/x/btclightclient/types/btc_light_client.go b/x/btclightclient/types/btc_light_client.go index d6cf28ec4..25ad59f70 100644 --- a/x/btclightclient/types/btc_light_client.go +++ b/x/btclightclient/types/btc_light_client.go @@ -14,7 +14,7 @@ import ( type BtcChainReadStore interface { GetHeaderByHash(hash *bbn.BTCHeaderHashBytes) (*BTCHeaderInfo, error) - GetHeaderByHeight(height uint64) (*BTCHeaderInfo, error) + GetHeaderByHeight(height uint32) (*BTCHeaderInfo, error) GetTip() *BTCHeaderInfo } @@ -82,13 +82,13 @@ func (l *lightChainCtx) FindPreviousCheckpoint() (blockchain.HeaderCtx, error) { type localHeaderInfo struct { header *wire.BlockHeader - height uint64 + height uint32 totalWork sdkmath.Uint } func newLocalHeaderInfo( header *wire.BlockHeader, - height uint64, + height uint32, totalWork sdkmath.Uint) *localHeaderInfo { return &localHeaderInfo{ @@ -132,7 +132,7 @@ func toBTCHeaderInfos(infos []*localHeaderInfo) []*BTCHeaderInfo { // based on neutrio light client // https://github.com/lightninglabs/neutrino/blob/master/blockmanager.go#L2944 type lightHeaderCtx struct { - height uint64 + height uint32 bits uint32 timestamp int64 store *storeWithExtensionChain @@ -140,7 +140,7 @@ type lightHeaderCtx struct { var _ blockchain.HeaderCtx = (*lightHeaderCtx)(nil) -func newLightHeaderCtx(height uint64, header *wire.BlockHeader, +func newLightHeaderCtx(height uint32, header *wire.BlockHeader, store *storeWithExtensionChain) *lightHeaderCtx { return &lightHeaderCtx{ @@ -184,16 +184,16 @@ func (l *lightHeaderCtx) RelativeAncestorCtx( return nil } - ancU64 := uint64(ancestorHeight) + ancU32 := uint32(ancestorHeight) - ancestor := l.store.getHeaderAtHeight(ancU64) + ancestor := l.store.getHeaderAtHeight(ancU32) if ancestor == nil { return nil } return newLightHeaderCtx( - ancU64, ancestor.header, l.store, + ancU32, ancestor.header, l.store, ) } @@ -285,7 +285,7 @@ func (s *storeWithExtensionChain) addHeader(header *localHeaderInfo) { s.headers = append(s.headers, header) } -func (s *storeWithExtensionChain) getHeaderAtHeight(height uint64) *localHeaderInfo { +func (s *storeWithExtensionChain) getHeaderAtHeight(height uint32) *localHeaderInfo { if len(s.headers) == 0 || height < s.headers[0].height { h, err := s.store.GetHeaderByHeight(height) @@ -397,7 +397,7 @@ func (l *BtcLightClient) InsertHeaders(readStore BtcChainReadStore, headers []*w return &InsertResult{ HeadersToInsert: toBTCHeaderInfos(store.headers), RollbackInfo: &RollbackInfo{ - // we need to rollback to fork parent + // we need to roll back to fork parent HeaderToRollbackTo: forkParent, }, }, nil diff --git a/x/btclightclient/types/btclightclient.pb.go b/x/btclightclient/types/btclightclient.pb.go index 5384959e7..d3025f25b 100644 --- a/x/btclightclient/types/btclightclient.pb.go +++ b/x/btclightclient/types/btclightclient.pb.go @@ -36,7 +36,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type BTCHeaderInfo struct { Header *github_com_babylonlabs_io_babylon_types.BTCHeaderBytes `protobuf:"bytes,1,opt,name=header,proto3,customtype=github.com/babylonlabs-io/babylon/types.BTCHeaderBytes" json:"header,omitempty"` Hash *github_com_babylonlabs_io_babylon_types.BTCHeaderHashBytes `protobuf:"bytes,2,opt,name=hash,proto3,customtype=github.com/babylonlabs-io/babylon/types.BTCHeaderHashBytes" json:"hash,omitempty"` - Height uint64 `protobuf:"varint,3,opt,name=height,proto3" json:"height,omitempty"` + Height uint32 `protobuf:"varint,3,opt,name=height,proto3" json:"height,omitempty"` Work *cosmossdk_io_math.Uint `protobuf:"bytes,4,opt,name=work,proto3,customtype=cosmossdk.io/math.Uint" json:"work,omitempty"` } @@ -73,7 +73,7 @@ func (m *BTCHeaderInfo) XXX_DiscardUnknown() { var xxx_messageInfo_BTCHeaderInfo proto.InternalMessageInfo -func (m *BTCHeaderInfo) GetHeight() uint64 { +func (m *BTCHeaderInfo) GetHeight() uint32 { if m != nil { return m.Height } @@ -101,13 +101,13 @@ var fileDescriptor_84bf438d909b681d = []byte{ 0x6a, 0xb1, 0x1e, 0xdc, 0x28, 0xa7, 0xca, 0x92, 0xd4, 0xe2, 0x20, 0xa8, 0x49, 0x42, 0x41, 0x5c, 0x2c, 0x19, 0x89, 0xc5, 0x19, 0x12, 0x4c, 0x60, 0x13, 0xed, 0x6e, 0xdd, 0x93, 0xb7, 0x22, 0xd9, 0x44, 0x8f, 0xc4, 0xe2, 0x0c, 0x88, 0xa9, 0x60, 0xb3, 0x84, 0xc4, 0x40, 0xee, 0x04, 0x79, 0x51, - 0x82, 0x59, 0x81, 0x51, 0x83, 0x25, 0x08, 0xca, 0x13, 0xd2, 0xe3, 0x62, 0x29, 0xcf, 0x2f, 0xca, + 0x82, 0x59, 0x81, 0x51, 0x83, 0x37, 0x08, 0xca, 0x13, 0xd2, 0xe3, 0x62, 0x29, 0xcf, 0x2f, 0xca, 0x96, 0x60, 0x01, 0xdb, 0x25, 0x75, 0xeb, 0x9e, 0xbc, 0x58, 0x72, 0x7e, 0x71, 0x6e, 0x7e, 0x71, 0x71, 0x4a, 0xb6, 0x5e, 0x66, 0xbe, 0x7e, 0x6e, 0x62, 0x49, 0x86, 0x5e, 0x68, 0x66, 0x5e, 0x49, 0x10, 0x58, 0x9d, 0x53, 0xd0, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0x59, 0x10, 0x76, 0x63, 0x05, 0x7a, 0xc4, 0x80, 0x1d, 0x9d, 0xc4, 0x06, 0x0e, 0x5c, 0x63, 0x40, 0x00, - 0x00, 0x00, 0xff, 0xff, 0x93, 0x3f, 0xdd, 0x6c, 0xbf, 0x01, 0x00, 0x00, + 0x00, 0x00, 0xff, 0xff, 0x5d, 0xd6, 0x30, 0xf9, 0xbf, 0x01, 0x00, 0x00, } func (m *BTCHeaderInfo) Marshal() (dAtA []byte, err error) { @@ -328,7 +328,7 @@ func (m *BTCHeaderInfo) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Height |= uint64(b&0x7F) << shift + m.Height |= uint32(b&0x7F) << shift if b < 0x80 { break } diff --git a/x/btclightclient/types/keys.go b/x/btclightclient/types/keys.go index 4761c2be8..1927fbfb8 100644 --- a/x/btclightclient/types/keys.go +++ b/x/btclightclient/types/keys.go @@ -28,8 +28,8 @@ var ( ParamsKey = []byte{0x03} // key for params ) -func HeadersObjectKey(height uint64) []byte { - return sdk.Uint64ToBigEndian(height) +func HeadersObjectKey(height uint32) []byte { + return sdk.Uint64ToBigEndian(uint64(height)) } func HeadersObjectHeightKey(hash *bbn.BTCHeaderHashBytes) []byte { diff --git a/x/btclightclient/types/keys_test.go b/x/btclightclient/types/keys_test.go index e7095b95c..82acf1fba 100644 --- a/x/btclightclient/types/keys_test.go +++ b/x/btclightclient/types/keys_test.go @@ -16,9 +16,9 @@ func FuzzHeadersObjectKey(f *testing.F) { f.Fuzz(func(t *testing.T, seed int64) { r := rand.New(rand.NewSource(seed)) - height := r.Uint64() + height := r.Uint32() // get chainhash and height - heightBytes := sdk.Uint64ToBigEndian(height) + heightBytes := sdk.Uint64ToBigEndian(uint64(height)) // construct the expected key var expectedKey []byte expectedKey = append(expectedKey, heightBytes...) diff --git a/x/btclightclient/types/query.pb.go b/x/btclightclient/types/query.pb.go index b8eb8bb97..2b47da48d 100644 --- a/x/btclightclient/types/query.pb.go +++ b/x/btclightclient/types/query.pb.go @@ -698,7 +698,7 @@ func (m *QueryHeaderDepthRequest) GetHash() string { // QueryMainChainDepthResponse is the response type for the Query/MainChainDepth RPC // it contains depth of the block in main chain type QueryHeaderDepthResponse struct { - Depth uint64 `protobuf:"varint,1,opt,name=depth,proto3" json:"depth,omitempty"` + Depth uint32 `protobuf:"varint,1,opt,name=depth,proto3" json:"depth,omitempty"` } func (m *QueryHeaderDepthResponse) Reset() { *m = QueryHeaderDepthResponse{} } @@ -734,7 +734,7 @@ func (m *QueryHeaderDepthResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryHeaderDepthResponse proto.InternalMessageInfo -func (m *QueryHeaderDepthResponse) GetDepth() uint64 { +func (m *QueryHeaderDepthResponse) GetDepth() uint32 { if m != nil { return m.Depth } @@ -752,7 +752,7 @@ func (m *QueryHeaderDepthResponse) GetDepth() uint64 { type BTCHeaderInfoResponse struct { HeaderHex string `protobuf:"bytes,1,opt,name=header_hex,json=headerHex,proto3" json:"header_hex,omitempty"` HashHex string `protobuf:"bytes,2,opt,name=hash_hex,json=hashHex,proto3" json:"hash_hex,omitempty"` - Height uint64 `protobuf:"varint,3,opt,name=height,proto3" json:"height,omitempty"` + Height uint32 `protobuf:"varint,3,opt,name=height,proto3" json:"height,omitempty"` // Work is the sdkmath.Uint as string. Work cosmossdk_io_math.Uint `protobuf:"bytes,4,opt,name=work,proto3,customtype=cosmossdk.io/math.Uint" json:"work"` } @@ -804,7 +804,7 @@ func (m *BTCHeaderInfoResponse) GetHashHex() string { return "" } -func (m *BTCHeaderInfoResponse) GetHeight() uint64 { +func (m *BTCHeaderInfoResponse) GetHeight() uint32 { if m != nil { return m.Height } @@ -838,63 +838,63 @@ func init() { var fileDescriptor_3961270631e52721 = []byte{ // 924 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x96, 0xcf, 0x6f, 0x1b, 0x45, - 0x14, 0xc7, 0x33, 0x89, 0xeb, 0x26, 0x2f, 0x20, 0x60, 0x48, 0x83, 0xb3, 0x02, 0x27, 0xdd, 0x92, - 0x1f, 0x4d, 0xf1, 0x4e, 0x9c, 0x80, 0x54, 0x71, 0x00, 0xe1, 0x20, 0x08, 0x48, 0x48, 0x65, 0x15, - 0x7a, 0x40, 0x95, 0xa2, 0x59, 0x67, 0xd8, 0x5d, 0x1a, 0xef, 0x6c, 0xbd, 0x9b, 0x90, 0x08, 0x71, - 0xe1, 0xc0, 0x19, 0xc1, 0x8d, 0x03, 0x07, 0x2e, 0x5c, 0x80, 0x13, 0xe2, 0x6f, 0xe8, 0xb1, 0x82, - 0x0b, 0xea, 0x21, 0x42, 0x09, 0x7f, 0x04, 0x47, 0x34, 0x33, 0x6f, 0x6d, 0xaf, 0x9d, 0x7a, 0x6d, - 0x35, 0x97, 0x28, 0x33, 0xf3, 0xde, 0xfb, 0x7e, 0xe6, 0xf9, 0xed, 0x77, 0x17, 0x96, 0x3d, 0xee, - 0x9d, 0x1c, 0xc8, 0x88, 0x79, 0x69, 0xf3, 0x20, 0xf4, 0x03, 0xf5, 0x57, 0x44, 0x29, 0x3b, 0xaa, - 0xb3, 0x07, 0x87, 0xa2, 0x7d, 0xe2, 0xc4, 0x6d, 0x99, 0x4a, 0xba, 0x80, 0x61, 0x4e, 0x3e, 0xcc, - 0x39, 0xaa, 0x5b, 0x73, 0xbe, 0xf4, 0xa5, 0x8e, 0x62, 0xea, 0x3f, 0x93, 0x60, 0x2d, 0x34, 0x65, - 0xd2, 0x92, 0xc9, 0x9e, 0x39, 0x30, 0x0b, 0x3c, 0x7a, 0xd9, 0x97, 0xd2, 0x3f, 0x10, 0x8c, 0xc7, - 0x21, 0xe3, 0x51, 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 0xee, 0xdd, 0xfe, 0x2f, + 0x00, 0x00, 0xff, 0xff, 0xc6, 0x41, 0x02, 0xa9, 0xde, 0x0b, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -3330,7 +3330,7 @@ func (m *QueryHeaderDepthResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Depth |= uint64(b&0x7F) << shift + m.Depth |= uint32(b&0x7F) << shift if b < 0x80 { break } @@ -3463,7 +3463,7 @@ func (m *BTCHeaderInfoResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Height |= uint64(b&0x7F) << shift + m.Height |= uint32(b&0x7F) << shift if b < 0x80 { break } diff --git a/x/btclightclient/types/utils.go b/x/btclightclient/types/utils.go index 1d77dfd5d..2de6de5d2 100644 --- a/x/btclightclient/types/utils.go +++ b/x/btclightclient/types/utils.go @@ -17,5 +17,5 @@ func IsRetargetBlock(info *BTCHeaderInfo, params *chaincfg.Params) bool { if blocksPerRetarget < 0 { panic("Invalid blocks per retarget value") } - return info.Height%uint64(blocksPerRetarget) == 0 + return info.Height%uint32(blocksPerRetarget) == 0 } diff --git a/x/btcstaking/README.md b/x/btcstaking/README.md index 188c53125..de878c840 100644 --- a/x/btcstaking/README.md +++ b/x/btcstaking/README.md @@ -179,7 +179,7 @@ message FinalityProvider { // slashed_btc_height indicates the BTC height when // the finality provider is slashed. // if it's 0 then the finality provider is not slashed - uint64 slashed_btc_height = 7; + uint32 slashed_btc_height = 7; } ``` @@ -211,10 +211,10 @@ message BTCDelegation { repeated bytes fp_btc_pk_list = 4 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340PubKey" ]; // start_height is the start BTC height of the BTC delegation // it is the start BTC height of the timelock - uint64 start_height = 5; + uint32 start_height = 5; // end_height is the end height of the BTC delegation // it is the end BTC height of the timelock - w - uint64 end_height = 6; + uint32 end_height = 6; // total_sat is the total amount of BTC stakes in this delegation // quantified in satoshi uint64 total_sat = 7; diff --git a/x/btcstaking/keeper/btc_height_index.go b/x/btcstaking/keeper/btc_height_index.go index 1f7adcc64..17ef33657 100644 --- a/x/btcstaking/keeper/btc_height_index.go +++ b/x/btcstaking/keeper/btc_height_index.go @@ -2,6 +2,7 @@ package keeper import ( "context" + "math" "cosmossdk.io/store/prefix" "github.com/babylonlabs-io/babylon/x/btcstaking/types" @@ -18,10 +19,10 @@ func (k Keeper) IndexBTCHeight(ctx context.Context) { } btcHeight := btcTip.Height store := k.btcHeightStore(ctx) - store.Set(sdk.Uint64ToBigEndian(babylonHeight), sdk.Uint64ToBigEndian(btcHeight)) + store.Set(sdk.Uint64ToBigEndian(babylonHeight), sdk.Uint64ToBigEndian(uint64(btcHeight))) } -func (k Keeper) GetBTCHeightAtBabylonHeight(ctx context.Context, babylonHeight uint64) uint64 { +func (k Keeper) GetBTCHeightAtBabylonHeight(ctx context.Context, babylonHeight uint64) uint32 { store := k.btcHeightStore(ctx) btcHeightBytes := store.Get(sdk.Uint64ToBigEndian(babylonHeight)) if len(btcHeightBytes) == 0 { @@ -29,10 +30,14 @@ func (k Keeper) GetBTCHeightAtBabylonHeight(ctx context.Context, babylonHeight u // use the base header return k.btclcKeeper.GetBaseBTCHeader(ctx).Height } - return sdk.BigEndianToUint64(btcHeightBytes) + btcHeightUint64 := sdk.BigEndianToUint64(btcHeightBytes) + if btcHeightUint64 > math.MaxUint32 { + panic("Storage involves a btc height that is larger than math.MaxUint32") + } + return uint32(btcHeightUint64) } -func (k Keeper) GetCurrentBTCHeight(ctx context.Context) uint64 { +func (k Keeper) GetCurrentBTCHeight(ctx context.Context) uint32 { babylonHeight := uint64(sdk.UnwrapSDKContext(ctx).HeaderInfo().Height) return k.GetBTCHeightAtBabylonHeight(ctx, babylonHeight) } diff --git a/x/btcstaking/keeper/btc_height_index_test.go b/x/btcstaking/keeper/btc_height_index_test.go index b3d7e951f..8b30b78d3 100644 --- a/x/btcstaking/keeper/btc_height_index_test.go +++ b/x/btcstaking/keeper/btc_height_index_test.go @@ -28,7 +28,7 @@ func FuzzBTCHeightIndex(f *testing.F) { // randomise Babylon height and BTC height babylonHeight := datagen.RandomInt(r, 100) ctx = datagen.WithCtxHeight(ctx, babylonHeight) - btcHeight := datagen.RandomInt(r, 100) + btcHeight := uint32(datagen.RandomInt(r, 100)) btclcKeeper.EXPECT().GetTipInfo(gomock.Any()).Return(&btclctypes.BTCHeaderInfo{Height: btcHeight}).Times(1) keeper.IndexBTCHeight(ctx) diff --git a/x/btcstaking/keeper/genesis.go b/x/btcstaking/keeper/genesis.go index dc787b62a..70cd1b2c9 100644 --- a/x/btcstaking/keeper/genesis.go +++ b/x/btcstaking/keeper/genesis.go @@ -3,6 +3,7 @@ package keeper import ( "context" "fmt" + "math" btcstk "github.com/babylonlabs-io/babylon/btcstaking" bbn "github.com/babylonlabs-io/babylon/types" @@ -164,9 +165,13 @@ func (k Keeper) blockHeightChains(ctx context.Context) []*types.BlockHeightBbnTo blocks := make([]*types.BlockHeightBbnToBtc, 0) for ; iter.Valid(); iter.Next() { + blkHeightUint64 := sdk.BigEndianToUint64(iter.Value()) + if blkHeightUint64 > math.MaxUint32 { + panic("block height value in storage is larger than math.MaxUint64") + } blocks = append(blocks, &types.BlockHeightBbnToBtc{ BlockHeightBbn: sdk.BigEndianToUint64(iter.Key()), - BlockHeightBtc: sdk.BigEndianToUint64(iter.Value()), + BlockHeightBtc: uint32(blkHeightUint64), }) } @@ -248,7 +253,7 @@ func (k Keeper) votingPowersDistCacheBlkHeight(ctx context.Context) ([]*types.Vo func (k Keeper) setBlockHeightChains(ctx context.Context, blocks *types.BlockHeightBbnToBtc) { store := k.btcHeightStore(ctx) - store.Set(sdk.Uint64ToBigEndian(blocks.BlockHeightBbn), sdk.Uint64ToBigEndian(blocks.BlockHeightBtc)) + store.Set(sdk.Uint64ToBigEndian(blocks.BlockHeightBbn), sdk.Uint64ToBigEndian(uint64(blocks.BlockHeightBtc))) } // setEventIdx sets an event into the store. @@ -269,13 +274,18 @@ func (k Keeper) setEventIdx( // parseUintsFromStoreKey expects to receive a key with // BigEndianUint64(blkHeight) || BigEndianUint64(Idx) -func parseUintsFromStoreKey(key []byte) (blkHeight, idx uint64, err error) { +func parseUintsFromStoreKey(key []byte) (blkHeight uint32, idx uint64, err error) { sizeBigEndian := 8 if len(key) < sizeBigEndian*2 { return 0, 0, fmt.Errorf("key not long enough to parse two uint64: %s", key) } - return sdk.BigEndianToUint64(key[:sizeBigEndian]), sdk.BigEndianToUint64(key[sizeBigEndian:]), nil + blkHeightUint64 := sdk.BigEndianToUint64(key[:sizeBigEndian]) + if blkHeightUint64 > math.MaxUint32 { + return 0, 0, fmt.Errorf("block height %d is larger than math.MaxUint32", blkHeightUint64) + } + idx = sdk.BigEndianToUint64(key[sizeBigEndian:]) + return uint32(blkHeightUint64), idx, nil } // parseBIP340PubKeysFromStoreKey expects to receive a key with diff --git a/x/btcstaking/keeper/genesis_test.go b/x/btcstaking/keeper/genesis_test.go index f9d5e7d0f..d9998ecbe 100644 --- a/x/btcstaking/keeper/genesis_test.go +++ b/x/btcstaking/keeper/genesis_test.go @@ -38,7 +38,7 @@ func TestExportGenesis(t *testing.T) { for _, fp := range fps { btcHead := btclcK.GetTipInfo(ctx) - btcHead.Height = blkHeight + 100 + btcHead.Height = uint32(blkHeight + 100) btclcK.InsertHeaderInfos(ctx, []*btclightclientt.BTCHeaderInfo{ btcHead, }) diff --git a/x/btcstaking/keeper/grpc_query_test.go b/x/btcstaking/keeper/grpc_query_test.go index df9691f0e..7d5a5df34 100644 --- a/x/btcstaking/keeper/grpc_query_test.go +++ b/x/btcstaking/keeper/grpc_query_test.go @@ -203,10 +203,10 @@ func FuzzPendingBTCDelegations(f *testing.F) { } // Generate a random number of BTC delegations under each finality provider - startHeight := datagen.RandomInt(r, 100) + 1 + startHeight := uint32(datagen.RandomInt(r, 100)) + 1 btclcKeeper.EXPECT().GetTipInfo(gomock.Any()).Return(&btclctypes.BTCHeaderInfo{Height: startHeight}).AnyTimes() - endHeight := datagen.RandomInt(r, 1000) + startHeight + btcctypes.DefaultParams().CheckpointFinalizationTimeout + 1 + endHeight := uint32(datagen.RandomInt(r, 1000)) + startHeight + btcctypes.DefaultParams().CheckpointFinalizationTimeout + 1 numBTCDels := datagen.RandomInt(r, 10) + 1 pendingBtcDelsMap := make(map[string]*types.BTCDelegation) for _, fp := range fps { @@ -522,8 +522,8 @@ func FuzzFinalityProviderDelegations(f *testing.F) { require.NoError(t, err) AddFinalityProvider(t, ctx, *keeper, fp) - startHeight := datagen.RandomInt(r, 100) + 1 - endHeight := datagen.RandomInt(r, 1000) + startHeight + btcctypes.DefaultParams().CheckpointFinalizationTimeout + 1 + startHeight := uint32(datagen.RandomInt(r, 100)) + 1 + endHeight := uint32(datagen.RandomInt(r, 1000)) + startHeight + btcctypes.DefaultParams().CheckpointFinalizationTimeout + 1 btclcKeeper.EXPECT().GetTipInfo(gomock.Any()).Return(&btclctypes.BTCHeaderInfo{Height: startHeight}).AnyTimes() // Generate a random number of BTC delegations under this finality provider numBTCDels := datagen.RandomInt(r, 10) + 1 diff --git a/x/btcstaking/keeper/inclusion_proof.go b/x/btcstaking/keeper/inclusion_proof.go index 161a16587..96150db56 100644 --- a/x/btcstaking/keeper/inclusion_proof.go +++ b/x/btcstaking/keeper/inclusion_proof.go @@ -15,9 +15,9 @@ import ( func (k Keeper) VerifyInclusionProofAndGetHeight( ctx sdk.Context, stakingTx *btcutil.Tx, - stakingTime uint64, + stakingTime uint32, inclusionProof *types.ParsedProofOfInclusion, -) (uint64, error) { +) (uint32, error) { btccParams := k.btccKeeper.GetParams(ctx) // Check: // - timelock of staking tx diff --git a/x/btcstaking/keeper/keeper_test.go b/x/btcstaking/keeper/keeper_test.go index b7c404752..605a61ffe 100644 --- a/x/btcstaking/keeper/keeper_test.go +++ b/x/btcstaking/keeper/keeper_test.go @@ -25,7 +25,7 @@ import ( var ( net = &chaincfg.SimNetParams - btcTipHeight = uint64(30) + btcTipHeight = uint32(30) ) type Helper struct { @@ -90,7 +90,7 @@ func (h *Helper) SetCtxHeight(height uint64) { func (h *Helper) GenAndApplyCustomParams( r *rand.Rand, - finalizationTimeout uint64, + finalizationTimeout uint32, minUnbondingTime uint32, ) ([]*btcec.PrivateKey, []*btcec.PublicKey) { // mock base header diff --git a/x/btcstaking/keeper/msg_server.go b/x/btcstaking/keeper/msg_server.go index 03872241a..6bd56a9c4 100644 --- a/x/btcstaking/keeper/msg_server.go +++ b/x/btcstaking/keeper/msg_server.go @@ -181,19 +181,19 @@ func (ms msgServer) CreateBTCDelegation(goCtx context.Context, req *types.MsgCre // 6. If the delegation contains the inclusion proof, we need to verify the proof // and set start height and end height - var startHeight, endHeight uint64 + var startHeight, endHeight uint32 if parsedMsg.StakingTxProofOfInclusion != nil { inclusionHeight, err := ms.VerifyInclusionProofAndGetHeight( ctx, btcutil.NewTx(parsedMsg.StakingTx.Transaction), - uint64(parsedMsg.StakingTime), + uint32(parsedMsg.StakingTime), parsedMsg.StakingTxProofOfInclusion) if err != nil { return nil, fmt.Errorf("invalid inclusion proof: %w", err) } startHeight = inclusionHeight - endHeight = startHeight + uint64(parsedMsg.StakingTime) + endHeight = startHeight + uint32(parsedMsg.StakingTime) } else { // NOTE: here we consume more gas to protect Babylon chain and covenant members against spamming // i.e creating delegation that will never reach BTC @@ -279,7 +279,7 @@ func (ms msgServer) AddBTCDelegationInclusionProof( inclusionHeight, err := ms.VerifyInclusionProofAndGetHeight( ctx, btcutil.NewTx(stakingTx), - uint64(btcDel.StakingTime), + btcDel.StakingTime, parsedInclusionProof, ) @@ -289,7 +289,7 @@ func (ms msgServer) AddBTCDelegationInclusionProof( // 6. set start height and end height and save it to db btcDel.StartHeight = inclusionHeight - btcDel.EndHeight = btcDel.StartHeight + uint64(btcDel.StakingTime) + btcDel.EndHeight = btcDel.StartHeight + btcDel.StakingTime ms.setBTCDelegation(ctx, btcDel) // 7. emit events diff --git a/x/btcstaking/keeper/msg_server_test.go b/x/btcstaking/keeper/msg_server_test.go index 1f8ae3b9a..1c327e733 100644 --- a/x/btcstaking/keeper/msg_server_test.go +++ b/x/btcstaking/keeper/msg_server_test.go @@ -808,7 +808,7 @@ func TestDoNotAllowDelegationWithoutFinalityProvider(t *testing.T) { func TestCorrectUnbondingTimeInDelegation(t *testing.T) { tests := []struct { name string - finalizationTimeout uint64 + finalizationTimeout uint32 minUnbondingTime uint32 unbondingTimeInDelegation uint16 err error diff --git a/x/btcstaking/keeper/power_dist_change.go b/x/btcstaking/keeper/power_dist_change.go index 94e961fa1..e6a00c5e4 100644 --- a/x/btcstaking/keeper/power_dist_change.go +++ b/x/btcstaking/keeper/power_dist_change.go @@ -363,7 +363,7 @@ func (k Keeper) ProcessAllPowerDistUpdateEvents( // to the store func (k Keeper) addPowerDistUpdateEvent( ctx context.Context, - btcHeight uint64, + btcHeight uint32, event *types.EventPowerDistUpdate, ) { store := k.powerDistUpdateEventBtcHeightStore(ctx, btcHeight) @@ -385,7 +385,7 @@ func (k Keeper) addPowerDistUpdateEvent( // at a given BTC height // This is called after processing all BTC delegation events in `BeginBlocker` // nolint:unused -func (k Keeper) ClearPowerDistUpdateEvents(ctx context.Context, btcHeight uint64) { +func (k Keeper) ClearPowerDistUpdateEvents(ctx context.Context, btcHeight uint32) { store := k.powerDistUpdateEventBtcHeightStore(ctx, btcHeight) keys := [][]byte{} @@ -407,7 +407,7 @@ func (k Keeper) ClearPowerDistUpdateEvents(ctx context.Context, btcHeight uint64 } // GetAllPowerDistUpdateEvents gets all voting power update events -func (k Keeper) GetAllPowerDistUpdateEvents(ctx context.Context, lastBTCTip uint64, curBTCTip uint64) []*types.EventPowerDistUpdate { +func (k Keeper) GetAllPowerDistUpdateEvents(ctx context.Context, lastBTCTip uint32, curBTCTip uint32) []*types.EventPowerDistUpdate { events := []*types.EventPowerDistUpdate{} for i := lastBTCTip; i <= curBTCTip; i++ { k.IteratePowerDistUpdateEvents(ctx, i, func(event *types.EventPowerDistUpdate) bool { @@ -423,7 +423,7 @@ func (k Keeper) GetAllPowerDistUpdateEvents(ctx context.Context, lastBTCTip uint // This is called in `BeginBlocker` func (k Keeper) IteratePowerDistUpdateEvents( ctx context.Context, - btcHeight uint64, + btcHeight uint32, handleFunc func(event *types.EventPowerDistUpdate) bool, ) { store := k.powerDistUpdateEventBtcHeightStore(ctx, btcHeight) @@ -444,9 +444,9 @@ func (k Keeper) IteratePowerDistUpdateEvents( // prefix: PowerDistUpdateKey || BTC height // key: event index) // value: BTCDelegationStatus -func (k Keeper) powerDistUpdateEventBtcHeightStore(ctx context.Context, btcHeight uint64) prefix.Store { +func (k Keeper) powerDistUpdateEventBtcHeightStore(ctx context.Context, btcHeight uint32) prefix.Store { store := k.powerDistUpdateEventStore(ctx) - return prefix.NewStore(store, sdk.Uint64ToBigEndian(btcHeight)) + return prefix.NewStore(store, sdk.Uint64ToBigEndian(uint64(btcHeight))) } // powerDistUpdateEventStore returns the KVStore of events that affect diff --git a/x/btcstaking/types/btc_delegation.go b/x/btcstaking/types/btc_delegation.go index e5726090d..521cdeb77 100644 --- a/x/btcstaking/types/btc_delegation.go +++ b/x/btcstaking/types/btc_delegation.go @@ -101,7 +101,7 @@ func (d *BTCDelegation) FinalityProviderKeys() []string { // Pending: the BTC height is in the range of d's [startHeight, endHeight-w] and the delegation does not have covenant signatures // Active: the BTC height is in the range of d's [startHeight, endHeight-w] and the delegation has quorum number of signatures over slashing tx, unbonding tx, and slashing unbonding tx from covenant committee // Unbonded: the BTC height is larger than `endHeight-w` or the BTC delegation has received a signature on unbonding tx from the delegator -func (d *BTCDelegation) GetStatus(btcHeight uint64, w uint64, covenantQuorum uint32) BTCDelegationStatus { +func (d *BTCDelegation) GetStatus(btcHeight uint32, w uint32, covenantQuorum uint32) BTCDelegationStatus { if d.IsUnbondedEarly() { return BTCDelegationStatus_UNBONDED } @@ -135,7 +135,7 @@ func (d *BTCDelegation) GetStatus(btcHeight uint64, w uint64, covenantQuorum uin // VotingPower returns the voting power of the BTC delegation at a given BTC height // and a given w value. // The BTC delegation d has voting power iff it is active. -func (d *BTCDelegation) VotingPower(btcHeight uint64, w uint64, covenantQuorum uint32) uint64 { +func (d *BTCDelegation) VotingPower(btcHeight uint32, w uint32, covenantQuorum uint32) uint64 { if d.GetStatus(btcHeight, w, covenantQuorum) != BTCDelegationStatus_ACTIVE { return 0 } @@ -476,7 +476,7 @@ func (i *BTCDelegatorDelegationIndex) Add(stakingTxHash chainhash.Hash) error { } // VotingPower calculates the total voting power of all BTC delegations -func (dels *BTCDelegatorDelegations) VotingPower(btcHeight uint64, w uint64, covenantQuorum uint32) uint64 { +func (dels *BTCDelegatorDelegations) VotingPower(btcHeight uint32, w uint32, covenantQuorum uint32) uint64 { power := uint64(0) for _, del := range dels.Dels { power += del.VotingPower(btcHeight, w, covenantQuorum) diff --git a/x/btcstaking/types/btc_delegation_test.go b/x/btcstaking/types/btc_delegation_test.go index aaaf9e9f7..06ec13301 100644 --- a/x/btcstaking/types/btc_delegation_test.go +++ b/x/btcstaking/types/btc_delegation_test.go @@ -50,12 +50,12 @@ func FuzzBTCDelegation(f *testing.F) { } // randomise start height and end height - btcDel.StartHeight = datagen.RandomInt(r, 100) + 1 - btcDel.EndHeight = btcDel.StartHeight + datagen.RandomInt(r, 100) + 1 + btcDel.StartHeight = uint32(datagen.RandomInt(r, 100)) + 1 + btcDel.EndHeight = btcDel.StartHeight + uint32(datagen.RandomInt(r, 100)) + 1 // randomise BTC tip and w - btcHeight := btcDel.StartHeight + datagen.RandomInt(r, 50) - w := datagen.RandomInt(r, 50) + btcHeight := btcDel.StartHeight + uint32(datagen.RandomInt(r, 50)) + w := uint32(datagen.RandomInt(r, 50)) // test expected voting power hasVotingPower := hasCovenantSig && btcDel.StartHeight <= btcHeight && btcHeight+w <= btcDel.EndHeight @@ -123,7 +123,7 @@ func FuzzBTCDelegation_SlashingTx(f *testing.F) { covenantQuorum, slashingPkScript, 1000, - uint64(1000+stakingTimeBlocks), + uint32(1000+stakingTimeBlocks), uint64(stakingValue), slashingRate, slashingChangeLockTime, diff --git a/x/btcstaking/types/btc_undelegation_test.go b/x/btcstaking/types/btc_undelegation_test.go index 59694c426..2388ea12e 100644 --- a/x/btcstaking/types/btc_undelegation_test.go +++ b/x/btcstaking/types/btc_undelegation_test.go @@ -73,7 +73,7 @@ func FuzzBTCUndelegation_SlashingTx(f *testing.F) { covenantQuorum, slashingPkScript, 1000, - uint64(1000+stakingTimeBlocks), + uint32(stakingTimeBlocks)+1000, uint64(stakingValue), slashingRate, slashingChangeLockTime, diff --git a/x/btcstaking/types/btcstaking.go b/x/btcstaking/types/btcstaking.go index 354b27a53..9279adc3f 100644 --- a/x/btcstaking/types/btcstaking.go +++ b/x/btcstaking/types/btcstaking.go @@ -124,7 +124,7 @@ func GetOrderedCovenantSignatures(fpIdx int, covSigsList []*CovenantAdaptorSigna covSigsMap[covSigs.CovPk.MarshalHex()] = covSig } - // sort covenant PKs in reverse reverse lexicographical order + // sort covenant PKs in reverse lexicographical order orderedCovenantPKs := bbn.SortBIP340PKs(params.CovenantPks) // get ordered list of covenant signatures w.r.t. the order of sorted covenant PKs @@ -146,9 +146,9 @@ func GetOrderedCovenantSignatures(fpIdx int, covSigsList []*CovenantAdaptorSigna // - CheckpointFinalizationTimeout func MinimumUnbondingTime( stakingParams *Params, - checkpointingParams *btcctypes.Params) uint64 { - return math.Max[uint64]( - uint64(stakingParams.MinUnbondingTimeBlocks), + checkpointingParams *btcctypes.Params) uint32 { + return math.Max[uint32]( + stakingParams.MinUnbondingTimeBlocks, checkpointingParams.CheckpointFinalizationTimeout, ) } diff --git a/x/btcstaking/types/btcstaking.pb.go b/x/btcstaking/types/btcstaking.pb.go index fb86e9a1e..40c20ed91 100644 --- a/x/btcstaking/types/btcstaking.pb.go +++ b/x/btcstaking/types/btcstaking.pb.go @@ -101,7 +101,7 @@ type FinalityProvider struct { // slashed_btc_height indicates the BTC height when // the finality provider is slashed. // if it's 0 then the finality provider is not slashed - SlashedBtcHeight uint64 `protobuf:"varint,7,opt,name=slashed_btc_height,json=slashedBtcHeight,proto3" json:"slashed_btc_height,omitempty"` + SlashedBtcHeight uint32 `protobuf:"varint,7,opt,name=slashed_btc_height,json=slashedBtcHeight,proto3" json:"slashed_btc_height,omitempty"` // jailed defines whether the finality provider is jailed Jailed bool `protobuf:"varint,8,opt,name=jailed,proto3" json:"jailed,omitempty"` } @@ -167,7 +167,7 @@ func (m *FinalityProvider) GetSlashedBabylonHeight() uint64 { return 0 } -func (m *FinalityProvider) GetSlashedBtcHeight() uint64 { +func (m *FinalityProvider) GetSlashedBtcHeight() uint32 { if m != nil { return m.SlashedBtcHeight } @@ -197,7 +197,7 @@ type FinalityProviderWithMeta struct { // slashed_btc_height indicates the BTC height when // the finality provider is slashed. // if it's 0 then the finality provider is not slashed - SlashedBtcHeight uint64 `protobuf:"varint,5,opt,name=slashed_btc_height,json=slashedBtcHeight,proto3" json:"slashed_btc_height,omitempty"` + SlashedBtcHeight uint32 `protobuf:"varint,5,opt,name=slashed_btc_height,json=slashedBtcHeight,proto3" json:"slashed_btc_height,omitempty"` // jailed defines whether the finality provider is detected jailed Jailed bool `protobuf:"varint,6,opt,name=jailed,proto3" json:"jailed,omitempty"` } @@ -256,7 +256,7 @@ func (m *FinalityProviderWithMeta) GetSlashedBabylonHeight() uint64 { return 0 } -func (m *FinalityProviderWithMeta) GetSlashedBtcHeight() uint64 { +func (m *FinalityProviderWithMeta) GetSlashedBtcHeight() uint32 { if m != nil { return m.SlashedBtcHeight } @@ -288,10 +288,10 @@ type BTCDelegation struct { StakingTime uint32 `protobuf:"varint,5,opt,name=staking_time,json=stakingTime,proto3" json:"staking_time,omitempty"` // start_height is the start BTC height of the BTC delegation // it is the start BTC height of the timelock - StartHeight uint64 `protobuf:"varint,6,opt,name=start_height,json=startHeight,proto3" json:"start_height,omitempty"` + StartHeight uint32 `protobuf:"varint,6,opt,name=start_height,json=startHeight,proto3" json:"start_height,omitempty"` // end_height is the end height of the BTC delegation // it is calculated by end_height = start_height + staking_time - EndHeight uint64 `protobuf:"varint,7,opt,name=end_height,json=endHeight,proto3" json:"end_height,omitempty"` + EndHeight uint32 `protobuf:"varint,7,opt,name=end_height,json=endHeight,proto3" json:"end_height,omitempty"` // total_sat is the total amount of BTC stakes in this delegation // quantified in satoshi TotalSat uint64 `protobuf:"varint,8,opt,name=total_sat,json=totalSat,proto3" json:"total_sat,omitempty"` @@ -374,14 +374,14 @@ func (m *BTCDelegation) GetStakingTime() uint32 { return 0 } -func (m *BTCDelegation) GetStartHeight() uint64 { +func (m *BTCDelegation) GetStartHeight() uint32 { if m != nil { return m.StartHeight } return 0 } -func (m *BTCDelegation) GetEndHeight() uint64 { +func (m *BTCDelegation) GetEndHeight() uint32 { if m != nil { return m.EndHeight } @@ -843,87 +843,87 @@ func init() { var fileDescriptor_3851ae95ccfaf7db = []byte{ // 1299 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x57, 0x5f, 0x73, 0xda, 0xc6, - 0x16, 0xb7, 0x00, 0x63, 0xfb, 0xc8, 0xd8, 0x64, 0x43, 0x1c, 0x25, 0x9e, 0x6b, 0xfb, 0x72, 0x73, - 0x33, 0xcc, 0xbd, 0x31, 0xc4, 0x4e, 0x66, 0x9a, 0xb6, 0xd3, 0x07, 0x63, 0x48, 0xc3, 0x34, 0xc1, - 0x54, 0xe0, 0x74, 0xda, 0x99, 0x8e, 0xba, 0x48, 0x6b, 0x50, 0x01, 0xad, 0xaa, 0x5d, 0x28, 0xfe, - 0x14, 0xed, 0x53, 0xdf, 0xfa, 0xd2, 0xa7, 0x7e, 0x80, 0x7c, 0x88, 0x3c, 0x66, 0xf2, 0xd4, 0xf1, - 0x83, 0xa7, 0xe3, 0x7c, 0x91, 0xce, 0xae, 0x16, 0x21, 0xd2, 0x38, 0x4d, 0x62, 0xbf, 0xb1, 0xe7, - 0xdf, 0xef, 0xe8, 0x77, 0x7e, 0x3a, 0x2b, 0xe0, 0x76,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xb0, 0xe8, 0xf3, 0x22, 0xf2, 0x3a, 0x86, 0x3c, 0xfc, 0xaf, 0x05, 0x57, + 0xe7, 0x24, 0xdd, 0x62, 0x16, 0x1b, 0x51, 0x94, 0x82, 0xa5, 0x66, 0xad, 0x51, 0xad, 0x37, 0x3e, + 0xcf, 0x2e, 0xa0, 0x34, 0x2c, 0x3f, 0xad, 0x19, 0xf5, 0x87, 0xf5, 0x5a, 0x35, 0xab, 0x21, 0x80, + 0xe4, 0xde, 0x7e, 0xbb, 0xfe, 0xb4, 0x96, 0x8d, 0x71, 0xcf, 0x61, 0xa3, 0x72, 0xd0, 0xa8, 0xd6, + 0xaa, 0xd9, 0x38, 0x5a, 0x82, 0xf8, 0x5e, 0xe3, 0xeb, 0x6c, 0xa2, 0xd2, 0x78, 0x7e, 0xb6, 0xa9, + 0xbd, 0x38, 0xdb, 0xd4, 0xfe, 0x3c, 0xdb, 0xd4, 0x7e, 0x7e, 0xb5, 0xb9, 0xf0, 0xe2, 0xd5, 0xe6, + 0xc2, 0x1f, 0xaf, 0x36, 0x17, 0xbe, 0x79, 0x07, 0x02, 0x27, 0xd1, 0x7f, 0x2b, 0x82, 0xcd, 0x4e, + 0x52, 0xfc, 0xff, 0xb8, 0xf7, 0x57, 0x00, 0x00, 0x00, 0xff, 0xff, 0x78, 0x96, 0x48, 0x3b, 0x66, 0x0d, 0x00, 0x00, } @@ -2128,7 +2128,7 @@ func (m *FinalityProvider) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.SlashedBtcHeight |= uint64(b&0x7F) << shift + m.SlashedBtcHeight |= uint32(b&0x7F) << shift if b < 0x80 { break } @@ -2309,7 +2309,7 @@ func (m *FinalityProviderWithMeta) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.SlashedBtcHeight |= uint64(b&0x7F) << shift + m.SlashedBtcHeight |= uint32(b&0x7F) << shift if b < 0x80 { break } @@ -2555,7 +2555,7 @@ func (m *BTCDelegation) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.StartHeight |= uint64(b&0x7F) << shift + m.StartHeight |= uint32(b&0x7F) << shift if b < 0x80 { break } @@ -2574,7 +2574,7 @@ func (m *BTCDelegation) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.EndHeight |= uint64(b&0x7F) << shift + m.EndHeight |= uint32(b&0x7F) << shift if b < 0x80 { break } diff --git a/x/btcstaking/types/events.go b/x/btcstaking/types/events.go index 0bfc3c443..99844c2f2 100644 --- a/x/btcstaking/types/events.go +++ b/x/btcstaking/types/events.go @@ -72,14 +72,14 @@ func NewEventFinalityProviderEdited(fp *FinalityProvider) *EventFinalityProvider func NewInclusionProofEvent( stakingTxHash string, - startHeight uint64, - endHeight uint64, + startHeight uint32, + endHeight uint32, state BTCDelegationStatus, ) *EventBTCDelegationInclusionProofReceived { return &EventBTCDelegationInclusionProofReceived{ StakingTxHash: stakingTxHash, - StartHeight: strconv.FormatUint(startHeight, 10), - EndHeight: strconv.FormatUint(endHeight, 10), + StartHeight: strconv.FormatUint(uint64(startHeight), 10), + EndHeight: strconv.FormatUint(uint64(endHeight), 10), NewState: state.String(), } } diff --git a/x/btcstaking/types/genesis.pb.go b/x/btcstaking/types/genesis.pb.go index 3994319ac..0f7efa606 100644 --- a/x/btcstaking/types/genesis.pb.go +++ b/x/btcstaking/types/genesis.pb.go @@ -252,7 +252,7 @@ type BlockHeightBbnToBtc struct { // block_height_bbn is the height of the block in the babylon chain. BlockHeightBbn uint64 `protobuf:"varint,1,opt,name=block_height_bbn,json=blockHeightBbn,proto3" json:"block_height_bbn,omitempty"` // block_height_btc is the height of the block in the BTC. - BlockHeightBtc uint64 `protobuf:"varint,2,opt,name=block_height_btc,json=blockHeightBtc,proto3" json:"block_height_btc,omitempty"` + BlockHeightBtc uint32 `protobuf:"varint,2,opt,name=block_height_btc,json=blockHeightBtc,proto3" json:"block_height_btc,omitempty"` } func (m *BlockHeightBbnToBtc) Reset() { *m = BlockHeightBbnToBtc{} } @@ -295,7 +295,7 @@ func (m *BlockHeightBbnToBtc) GetBlockHeightBbn() uint64 { return 0 } -func (m *BlockHeightBbnToBtc) GetBlockHeightBtc() uint64 { +func (m *BlockHeightBbnToBtc) GetBlockHeightBtc() uint32 { if m != nil { return m.BlockHeightBtc } @@ -357,7 +357,7 @@ type EventIndex struct { // idx is the index the event was stored. Idx uint64 `protobuf:"varint,1,opt,name=idx,proto3" json:"idx,omitempty"` // block_height_btc is the height of the block in the BTC chain. - BlockHeightBtc uint64 `protobuf:"varint,2,opt,name=block_height_btc,json=blockHeightBtc,proto3" json:"block_height_btc,omitempty"` + BlockHeightBtc uint32 `protobuf:"varint,2,opt,name=block_height_btc,json=blockHeightBtc,proto3" json:"block_height_btc,omitempty"` // event the event stored. Event *EventPowerDistUpdate `protobuf:"bytes,3,opt,name=event,proto3" json:"event,omitempty"` } @@ -402,7 +402,7 @@ func (m *EventIndex) GetIdx() uint64 { return 0 } -func (m *EventIndex) GetBlockHeightBtc() uint64 { +func (m *EventIndex) GetBlockHeightBtc() uint32 { if m != nil { return m.BlockHeightBtc } @@ -430,51 +430,51 @@ func init() { } var fileDescriptor_85d7b95fa5620238 = []byte{ - // 694 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x95, 0x4f, 0x4f, 0xd4, 0x40, - 0x18, 0xc6, 0x29, 0xbb, 0x2c, 0x38, 0xbb, 0x2c, 0x30, 0x68, 0xd2, 0x90, 0xb0, 0xc2, 0xe2, 0x9f, - 0x8d, 0xc6, 0xae, 0x2c, 0x98, 0xe8, 0xd1, 0xb2, 0xa2, 0x68, 0x34, 0x4d, 0xc5, 0x3d, 0x70, 0x69, - 0x3a, 0xed, 0x6c, 0x77, 0xb2, 0x65, 0xa6, 0xe9, 0x0c, 0x95, 0xbd, 0x7a, 0xf5, 0xe2, 0xd1, 0xef, - 0xe0, 0x17, 0xf1, 0xc8, 0xd1, 0x78, 0x30, 0x06, 0xbe, 0x81, 0x9f, 0xc0, 0x74, 0x5a, 0x68, 0xc1, - 0x5d, 0x58, 0x63, 0xbc, 0x75, 0x26, 0xcf, 0xfb, 0x9b, 0xf7, 0x79, 0xe7, 0x99, 0x14, 0xac, 0x21, - 0x1b, 0x0d, 0x7c, 0x46, 0x9b, 0x48, 0x38, 0x5c, 0xd8, 0x7d, 0x42, 0xbd, 0x66, 0xb4, 0xde, 0xf4, - 0x30, 0xc5, 0x9c, 0x70, 0x2d, 0x08, 0x99, 0x60, 0xf0, 0x46, 0x2a, 0xd2, 0x32, 0x91, 0x16, 0xad, - 0x2f, 0x5d, 0xf7, 0x98, 0xc7, 0xa4, 0xa2, 0x19, 0x7f, 0x25, 0xe2, 0xa5, 0xfa, 0x70, 0x62, 0x60, - 0x87, 0xf6, 0x7e, 0x0a, 0x5c, 0xba, 0x33, 0x5c, 0x93, 0xc3, 0x27, 0xba, 0xdb, 0xc3, 0x75, 0x84, - 0x3a, 0x98, 0x0a, 0x12, 0xe1, 0xcb, 0x8f, 0xc4, 0x11, 0xa6, 0x22, 0x3d, 0xb2, 0xfe, 0xab, 0x08, - 0x2a, 0xcf, 0x13, 0x57, 0x6f, 0x85, 0x2d, 0x30, 0x7c, 0x04, 0x4a, 0x49, 0x4f, 0xaa, 0xb2, 0x52, - 0x68, 0x94, 0x5b, 0xcb, 0xda, 0x50, 0x97, 0x9a, 0x21, 0x45, 0x66, 0x2a, 0x86, 0x1d, 0x00, 0xbb, - 0x84, 0xda, 0x3e, 0x11, 0x03, 0x2b, 0x08, 0x59, 0x44, 0x5c, 0x1c, 0x72, 0x75, 0x52, 0x22, 0xee, - 0x8e, 0x40, 0x6c, 0xa7, 0x05, 0x46, 0xaa, 0x37, 0x17, 0xba, 0x17, 0x76, 0x38, 0x7c, 0x0d, 0xe6, - 0x90, 0x70, 0x2c, 0x17, 0xfb, 0xd8, 0xb3, 0x05, 0x61, 0x94, 0xab, 0x05, 0x09, 0xbd, 0x35, 0x02, - 0xaa, 0xef, 0x6e, 0xb5, 0xcf, 0xc4, 0x66, 0x15, 0x09, 0x27, 0x5b, 0x72, 0xb8, 0x03, 0x66, 0x23, - 0x26, 0x08, 0xf5, 0xac, 0x80, 0xbd, 0x8f, 0x3b, 0x2c, 0x5e, 0x0a, 0xeb, 0x48, 0xad, 0x11, 0x4b, - 0xb7, 0x0d, 0xb3, 0x12, 0x65, 0x4b, 0x0e, 0xf7, 0xc0, 0x22, 0xf2, 0x99, 0xd3, 0xb7, 0x7a, 0x98, - 0x78, 0x3d, 0x61, 0x39, 0x3d, 0x9b, 0x50, 0xae, 0x4e, 0x49, 0xe0, 0xbd, 0x51, 0xdd, 0xc5, 0x15, - 0x2f, 0x64, 0x81, 0x8e, 0xe8, 0x2e, 0xd3, 0x85, 0x63, 0x2e, 0xa0, 0x6c, 0x73, 0x4b, 0x42, 0xe0, - 0x4b, 0x50, 0xcd, 0xb9, 0x66, 0x21, 0x57, 0x4b, 0x12, 0xbb, 0x76, 0xa5, 0x69, 0x16, 0x9a, 0xb3, - 0x99, 0x67, 0x16, 0x72, 0xf8, 0x04, 0x94, 0x92, 0x1b, 0x57, 0xa7, 0x25, 0x63, 0x75, 0x04, 0xe3, - 0x59, 0x2c, 0xda, 0xa1, 0x2e, 0x3e, 0x34, 0xd3, 0x02, 0xd8, 0x01, 0x95, 0x28, 0xb0, 0x5c, 0x2e, - 0x2c, 0xc7, 0x76, 0x7a, 0x58, 0x9d, 0x91, 0x80, 0xcd, 0xab, 0x87, 0xd5, 0x26, 0x5c, 0x6c, 0xc5, - 0x25, 0xba, 0x9f, 0x1a, 0x33, 0x41, 0x14, 0xb4, 0xd3, 0xcd, 0xfa, 0x17, 0x05, 0xcc, 0x9e, 0x1b, - 0x2d, 0x5c, 0x05, 0x95, 0xfc, 0x30, 0x55, 0x65, 0x45, 0x69, 0x14, 0xcd, 0x72, 0x6e, 0x32, 0x70, - 0x17, 0x5c, 0x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0xce, 0xd8, 0xf3, 0x84, 0x4f, 0xc1, 0x94, - 0x7c, 0x65, 0xb2, 0xbb, 0xd1, 0x31, 0x90, 0xa7, 0x9d, 0xa5, 0xe0, 0x5d, 0xe0, 0xda, 0x02, 0x9b, - 0x49, 0xa5, 0xfe, 0xe6, 0xeb, 0x71, 0x4d, 0x39, 0x3a, 0xae, 0x29, 0x3f, 0x8f, 0x6b, 0xca, 0xa7, - 0x93, 0xda, 0xc4, 0xd1, 0x49, 0x6d, 0xe2, 0xdb, 0x49, 0x6d, 0x62, 0x6f, 0x0c, 0x9f, 0x87, 0xf9, - 0xbf, 0x82, 0x34, 0x8d, 0x4a, 0xf2, 0x97, 0xb0, 0xf1, 0x3b, 0x00, 0x00, 0xff, 0xff, 0x9a, 0xc8, - 0x8f, 0x84, 0xfd, 0x06, 0x00, 0x00, + // 697 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x95, 0xcd, 0x6e, 0xd3, 0x4e, + 0x14, 0xc5, 0xeb, 0x26, 0x4d, 0xfb, 0x9f, 0x7c, 0xb4, 0x9d, 0xfe, 0x91, 0xac, 0x4a, 0x0d, 0xad, + 0xcb, 0x47, 0x04, 0xc2, 0xa1, 0x69, 0x91, 0x60, 0x89, 0x1b, 0x0a, 0x05, 0x81, 0x2c, 0x53, 0xb2, + 0xe8, 0xc6, 0xf2, 0xd8, 0x13, 0x67, 0x14, 0xd7, 0x63, 0x79, 0xa6, 0xa6, 0xd9, 0xb2, 0x65, 0xc3, + 0x92, 0x77, 0xe0, 0x45, 0x58, 0x76, 0x89, 0x58, 0x20, 0xd4, 0xbe, 0x01, 0x4f, 0x80, 0x3c, 0x76, + 0x6b, 0x07, 0x92, 0x34, 0x08, 0xb1, 0xf3, 0x8c, 0xce, 0xfd, 0xcd, 0x3d, 0x77, 0xce, 0xc8, 0x60, + 0x13, 0x59, 0x68, 0xe0, 0x51, 0xbf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ba, 0x74, 0x7a, 0x56, 0x97, 0xbe, 0x9f, 0xd5, + 0xa5, 0x0f, 0xe7, 0xf5, 0x99, 0xd3, 0xf3, 0xfa, 0xcc, 0x97, 0xf3, 0xfa, 0xcc, 0xe1, 0x14, 0x3e, + 0x4f, 0xf2, 0x7f, 0x05, 0x61, 0x1a, 0x95, 0xc4, 0x2f, 0x61, 0xfb, 0x67, 0x00, 0x00, 0x00, 0xff, + 0xff, 0xbe, 0x5e, 0x58, 0xd0, 0xfd, 0x06, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -1610,7 +1610,7 @@ func (m *BlockHeightBbnToBtc) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.BlockHeightBtc |= uint64(b&0x7F) << shift + m.BlockHeightBtc |= uint32(b&0x7F) << shift if b < 0x80 { break } @@ -1854,7 +1854,7 @@ func (m *EventIndex) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.BlockHeightBtc |= uint64(b&0x7F) << shift + m.BlockHeightBtc |= uint32(b&0x7F) << shift if b < 0x80 { break } diff --git a/x/btcstaking/types/query.pb.go b/x/btcstaking/types/query.pb.go index 0a3c690df..95d2cc2bf 100644 --- a/x/btcstaking/types/query.pb.go +++ b/x/btcstaking/types/query.pb.go @@ -1165,10 +1165,10 @@ type BTCDelegationResponse struct { FpBtcPkList []github_com_babylonlabs_io_babylon_types.BIP340PubKey `protobuf:"bytes,3,rep,name=fp_btc_pk_list,json=fpBtcPkList,proto3,customtype=github.com/babylonlabs-io/babylon/types.BIP340PubKey" json:"fp_btc_pk_list,omitempty"` // start_height is the start BTC height of the BTC delegation // it is the start BTC height of the timelock - StartHeight uint64 `protobuf:"varint,4,opt,name=start_height,json=startHeight,proto3" json:"start_height,omitempty"` + StartHeight uint32 `protobuf:"varint,4,opt,name=start_height,json=startHeight,proto3" json:"start_height,omitempty"` // end_height is the end height of the BTC delegation // it is the end BTC height of the timelock - w - EndHeight uint64 `protobuf:"varint,5,opt,name=end_height,json=endHeight,proto3" json:"end_height,omitempty"` + EndHeight uint32 `protobuf:"varint,5,opt,name=end_height,json=endHeight,proto3" json:"end_height,omitempty"` // total_sat is the total amount of BTC stakes in this delegation // quantified in satoshi TotalSat uint64 `protobuf:"varint,6,opt,name=total_sat,json=totalSat,proto3" json:"total_sat,omitempty"` @@ -1239,14 +1239,14 @@ func (m *BTCDelegationResponse) GetStakerAddr() string { return "" } -func (m *BTCDelegationResponse) GetStartHeight() uint64 { +func (m *BTCDelegationResponse) GetStartHeight() uint32 { if m != nil { return m.StartHeight } return 0 } -func (m *BTCDelegationResponse) GetEndHeight() uint64 { +func (m *BTCDelegationResponse) GetEndHeight() uint32 { if m != nil { return m.EndHeight } @@ -1499,7 +1499,7 @@ type FinalityProviderResponse struct { // slashed_btc_height indicates the BTC height when // the finality provider is slashed. // if it's 0 then the finality provider is not slashed - SlashedBtcHeight uint64 `protobuf:"varint,7,opt,name=slashed_btc_height,json=slashedBtcHeight,proto3" json:"slashed_btc_height,omitempty"` + SlashedBtcHeight uint32 `protobuf:"varint,7,opt,name=slashed_btc_height,json=slashedBtcHeight,proto3" json:"slashed_btc_height,omitempty"` // height is the queried Babylon height Height uint64 `protobuf:"varint,8,opt,name=height,proto3" json:"height,omitempty"` // voting_power is the voting power of this finality provider at the given height @@ -1569,7 +1569,7 @@ func (m *FinalityProviderResponse) GetSlashedBabylonHeight() uint64 { return 0 } -func (m *FinalityProviderResponse) GetSlashedBtcHeight() uint64 { +func (m *FinalityProviderResponse) GetSlashedBtcHeight() uint32 { if m != nil { return m.SlashedBtcHeight } @@ -1629,7 +1629,7 @@ func init() { func init() { proto.RegisterFile("babylon/btcstaking/v1/query.proto", fileDescriptor_74d49d26f7429697) } var fileDescriptor_74d49d26f7429697 = []byte{ - // 1893 bytes of a gzipped FileDescriptorProto + // 1894 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x59, 0xcb, 0x6f, 0xdb, 0xc8, 0x19, 0x0f, 0x6d, 0x45, 0x89, 0x3f, 0xd9, 0x8e, 0x33, 0xeb, 0x24, 0x8c, 0x1c, 0xdb, 0x09, 0x9b, 0x4d, 0x9c, 0x87, 0xc5, 0x58, 0xf1, 0xee, 0xb6, 0x0d, 0xd2, 0xc4, 0xb2, 0x77, 0x93, 0xec, 0xae, @@ -1687,68 +1687,68 @@ var fileDescriptor_74d49d26f7429697 = []byte{ 0xba, 0xec, 0x92, 0xf0, 0x53, 0x67, 0xbb, 0x4d, 0x4c, 0x0b, 0xa5, 0x47, 0xe5, 0xdb, 0xab, 0xb7, 0xca, 0xad, 0xea, 0x67, 0x78, 0xd7, 0x38, 0x5e, 0x0d, 0x90, 0x89, 0x7e, 0x02, 0xd3, 0x11, 0x72, 0x1b, 0x2e, 0x65, 0xea, 0xf8, 0xc5, 0xf1, 0x43, 0x19, 0xce, 0x49, 0xd0, 0x7f, 0xee, 0xf2, 0xc6, - 0x98, 0xa4, 0xcc, 0xf4, 0x59, 0x45, 0xb6, 0x58, 0x46, 0x10, 0x25, 0x1f, 0x13, 0x7d, 0x88, 0xe6, - 0x01, 0xb0, 0x67, 0x87, 0x02, 0xc7, 0xb9, 0xc0, 0x04, 0xf6, 0x64, 0x9b, 0xa2, 0x39, 0x98, 0x60, - 0x84, 0x99, 0x8d, 0x0a, 0x35, 0x99, 0x9a, 0xe5, 0xb3, 0x27, 0xf9, 0xc0, 0x96, 0xc9, 0xd0, 0x65, - 0x98, 0x8e, 0xa3, 0x00, 0xb7, 0xd5, 0x13, 0x1c, 0x00, 0x93, 0x11, 0x00, 0x70, 0x1b, 0x5d, 0x81, - 0x53, 0xb4, 0x61, 0xd2, 0x7a, 0x4c, 0xec, 0x24, 0x17, 0x9b, 0x0a, 0x87, 0x85, 0xdc, 0x07, 0x70, - 0x2e, 0xea, 0x14, 0x3e, 0x55, 0xa1, 0xae, 0xc3, 0xe5, 0x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d3, - 0x8e, 0x91, 0x42, 0x94, 0xa6, 0x58, 0xed, 0xbb, 0x30, 0x17, 0xad, 0x76, 0xa4, 0x13, 0xae, 0xf8, - 0x18, 0x57, 0x52, 0x3b, 0x22, 0x4f, 0x43, 0x09, 0xb9, 0xea, 0x16, 0xcc, 0x75, 0x56, 0xbd, 0x5b, - 0xbb, 0xd3, 0x45, 0xb9, 0xe2, 0xe5, 0x94, 0xb2, 0x74, 0x16, 0xfd, 0x91, 0x57, 0x23, 0x86, 0x1a, - 0x1a, 0x8a, 0xfb, 0xe0, 0xed, 0x93, 0x80, 0xdc, 0x4c, 0x12, 0x72, 0xef, 0x40, 0xbe, 0x07, 0xb9, - 0xf1, 0x54, 0x8e, 0x73, 0x95, 0x73, 0xdd, 0xe0, 0x8d, 0x32, 0xa9, 0xc1, 0xd9, 0x08, 0xbf, 0x31, - 0x5d, 0xaa, 0x66, 0x0f, 0x08, 0xe4, 0xd9, 0x0e, 0x90, 0x23, 0x4f, 0x54, 0xb3, 0x60, 0x71, 0x9f, - 0x4d, 0x05, 0xdd, 0x87, 0x8c, 0x8d, 0x1b, 0x07, 0x3b, 0x39, 0x73, 0x4d, 0xed, 0x8b, 0x0c, 0xa8, - 0xa9, 0x97, 0x99, 0x8f, 0x21, 0x17, 0x74, 0x81, 0xef, 0x36, 0x63, 0x24, 0xff, 0x8d, 0x70, 0x6f, - 0x8a, 0x3c, 0x88, 0x8d, 0x69, 0x23, 0x12, 0x35, 0xe2, 0x7a, 0x68, 0x13, 0xc0, 0x22, 0xdb, 0xdb, - 0x2e, 0xa5, 0xe1, 0x0e, 0x37, 0x51, 0x5a, 0x7e, 0xfd, 0x66, 0x71, 0x4e, 0x18, 0xa2, 0xf6, 0xb3, - 0x82, 0x4b, 0xf4, 0x6d, 0x93, 0xd5, 0x0b, 0x9f, 0x63, 0xc7, 0xb4, 0x76, 0x37, 0xb0, 0xf5, 0xea, - 0xe5, 0x32, 0x48, 0x3f, 0x1b, 0xd8, 0x32, 0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 0xcd, 0xab, 0xe3, 0x6e, + 0x63, 0x75, 0x9a, 0xbb, 0x98, 0xea, 0x8c, 0x3e, 0x71, 0xb7, 0x31, 0xb2, 0xe0, 0x4c, 0xcb, 0x8b, + 0x1a, 0xa4, 0xe2, 0x4b, 0x30, 0xab, 0xa7, 0x78, 0xa7, 0x14, 0xd2, 0x3b, 0xe5, 0x69, 0x4c, 0xad, + 0xd3, 0x2b, 0xb3, 0xad, 0x84, 0xd1, 0x20, 0x16, 0x71, 0x1f, 0xa8, 0x84, 0x77, 0x90, 0x19, 0x11, + 0x8b, 0x18, 0x95, 0x37, 0x0e, 0xed, 0xe5, 0x38, 0x9c, 0x4b, 0x31, 0x8c, 0x96, 0x60, 0x26, 0x96, + 0x4e, 0x3b, 0x46, 0x0a, 0x51, 0x9a, 0x62, 0xb5, 0xef, 0xc2, 0x5c, 0xb4, 0xda, 0x91, 0x4e, 0xb8, + 0xe2, 0x63, 0x5c, 0x49, 0xed, 0x88, 0x3c, 0x0d, 0x25, 0xe4, 0xaa, 0x5b, 0x30, 0xd7, 0x59, 0xf5, + 0x6e, 0xed, 0x4e, 0x17, 0xe5, 0x8a, 0x97, 0x53, 0xca, 0xd2, 0x59, 0xf4, 0x47, 0x5e, 0x8d, 0x18, + 0x6a, 0x68, 0x28, 0xee, 0x83, 0xb7, 0x4f, 0x02, 0x72, 0x33, 0x49, 0xc8, 0xbd, 0x03, 0xf9, 0x1e, + 0xe4, 0xc6, 0x53, 0x39, 0xce, 0x55, 0xce, 0x75, 0x83, 0x37, 0xca, 0xa4, 0x06, 0x67, 0x23, 0xfc, + 0xc6, 0x74, 0xa9, 0x9a, 0x3d, 0x20, 0x90, 0x67, 0x3b, 0x40, 0x8e, 0x3c, 0x51, 0xcd, 0x82, 0xc5, + 0x7d, 0x36, 0x15, 0x74, 0x1f, 0x32, 0x36, 0x6e, 0x1c, 0xec, 0xe4, 0xcc, 0x35, 0xb5, 0x2f, 0x32, + 0xa0, 0xa6, 0x5e, 0x66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 0x57, 0x6f, 0x17, 0x94, 0xbf, 0xbf, 0x5d, 0x50, 0x7e, 0xfd, 0x6e, 0xe1, 0xd8, 0x57, + 0xef, 0x16, 0x8e, 0xfd, 0xed, 0xdd, 0xc2, 0xb1, 0x1f, 0x0e, 0x71, 0xe8, 0x6b, 0xc7, 0x3d, 0xf2, + 0x13, 0x60, 0x35, 0xcb, 0xff, 0x6f, 0xba, 0xfd, 0xbf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x71, 0x38, + 0x32, 0x57, 0xb9, 0x1b, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -5980,7 +5980,7 @@ func (m *BTCDelegationResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.StartHeight |= uint64(b&0x7F) << shift + m.StartHeight |= uint32(b&0x7F) << shift if b < 0x80 { break } @@ -5999,7 +5999,7 @@ func (m *BTCDelegationResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.EndHeight |= uint64(b&0x7F) << shift + m.EndHeight |= uint32(b&0x7F) << shift if b < 0x80 { break } @@ -6886,7 +6886,7 @@ func (m *FinalityProviderResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.SlashedBtcHeight |= uint64(b&0x7F) << shift + m.SlashedBtcHeight |= uint32(b&0x7F) << shift if b < 0x80 { break } diff --git a/x/btcstaking/types/validate_parsed_message.go b/x/btcstaking/types/validate_parsed_message.go index f6f7e40ca..6660b79ec 100644 --- a/x/btcstaking/types/validate_parsed_message.go +++ b/x/btcstaking/types/validate_parsed_message.go @@ -27,7 +27,7 @@ func ValidateParsedMessageAgainstTheParams( // which is larger value from: // - MinUnbondingTime // - CheckpointFinalizationTimeout - if uint64(pm.UnbondingTime) <= minUnbondingTime { + if uint32(pm.UnbondingTime) <= minUnbondingTime { return nil, ErrInvalidUnbondingTx.Wrapf("unbonding time %d must be larger than %d", pm.UnbondingTime, minUnbondingTime) } diff --git a/x/monitor/keeper/grpc_query_test.go b/x/monitor/keeper/grpc_query_test.go index 9f47095b4..623498a58 100644 --- a/x/monitor/keeper/grpc_query_test.go +++ b/x/monitor/keeper/grpc_query_test.go @@ -35,7 +35,6 @@ func FuzzQueryEndedEpochBtcHeight(f *testing.F) { root := lck.GetBaseBTCHeader(ctx) chain := datagen.GenRandomValidChainStartingFrom( r, - 0, root.Header.ToBlockHeader(), nil, 10, @@ -92,7 +91,6 @@ func FuzzQueryReportedCheckpointBtcHeight(f *testing.F) { root := lck.GetBaseBTCHeader(ctx) chain := datagen.GenRandomValidChainStartingFrom( r, - 0, root.Header.ToBlockHeader(), nil, 10, diff --git a/x/monitor/keeper/keeper.go b/x/monitor/keeper/keeper.go index c7ada1120..9b711c2cf 100644 --- a/x/monitor/keeper/keeper.go +++ b/x/monitor/keeper/keeper.go @@ -4,6 +4,7 @@ import ( "context" corestoretypes "cosmossdk.io/core/store" "fmt" + "math" ckpttypes "github.com/babylonlabs-io/babylon/x/checkpointing/types" @@ -37,18 +38,23 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) } -func bytesToUint64(bytes []byte) (uint64, error) { - if len(bytes) != 8 { - return 0, fmt.Errorf("epoch bytes must have exactly 8 bytes") +func bytesToBtcHeight(heightBytes []byte) (uint32, error) { + if len(heightBytes) != 8 { + return 0, fmt.Errorf("height bytes must have exactly 8 bytes") } - return sdk.BigEndianToUint64(bytes), nil + heightUint64 := sdk.BigEndianToUint64(heightBytes) + if heightUint64 > math.MaxUint32 { + return 0, fmt.Errorf("height should not be higher than math.MaxUint32") + } + + return uint32(heightUint64), nil } func (k Keeper) updateBtcLightClientHeightForEpoch(ctx context.Context, epoch uint64) { store := k.storeService.OpenKVStore(ctx) currentTipHeight := k.btcLightClientKeeper.GetTipInfo(ctx).Height - if err := store.Set(types.GetEpochEndLightClientHeightKey(epoch), sdk.Uint64ToBigEndian(currentTipHeight)); err != nil { + if err := store.Set(types.GetEpochEndLightClientHeightKey(epoch), sdk.Uint64ToBigEndian(uint64(currentTipHeight))); err != nil { panic(err) } } @@ -74,7 +80,7 @@ func (k Keeper) updateBtcLightClientHeightForCheckpoint(ctx context.Context, ckp } currentTipHeight := k.btcLightClientKeeper.GetTipInfo(ctx).Height - return store.Set(storeKey, sdk.Uint64ToBigEndian(currentTipHeight)) + return store.Set(storeKey, sdk.Uint64ToBigEndian(uint64(currentTipHeight))) } func (k Keeper) removeCheckpointRecord(ctx context.Context, ckpt *ckpttypes.RawCheckpoint) error { @@ -92,7 +98,7 @@ func (k Keeper) removeCheckpointRecord(ctx context.Context, ckpt *ckpttypes.RawC return nil } -func (k Keeper) LightclientHeightAtEpochEnd(ctx context.Context, epoch uint64) (uint64, error) { +func (k Keeper) LightclientHeightAtEpochEnd(ctx context.Context, epoch uint64) (uint32, error) { if epoch == 0 { return k.btcLightClientKeeper.GetBaseBTCHeader(ctx).Height, nil } @@ -110,7 +116,7 @@ func (k Keeper) LightclientHeightAtEpochEnd(ctx context.Context, epoch uint64) ( return 0, types.ErrEpochNotEnded.Wrapf("epoch %d", epoch) } - btcHeight, err := bytesToUint64(btcHeightBytes) + btcHeight, err := bytesToBtcHeight(btcHeightBytes) if err != nil { panic("Invalid data in database") @@ -119,7 +125,7 @@ func (k Keeper) LightclientHeightAtEpochEnd(ctx context.Context, epoch uint64) ( return btcHeight, nil } -func (k Keeper) LightclientHeightAtCheckpointReported(ctx context.Context, hashString string) (uint64, error) { +func (k Keeper) LightclientHeightAtCheckpointReported(ctx context.Context, hashString string) (uint32, error) { store := k.storeService.OpenKVStore(ctx) storeKey, err := types.GetCheckpointReportedLightClientHeightKey(hashString) @@ -136,7 +142,7 @@ func (k Keeper) LightclientHeightAtCheckpointReported(ctx context.Context, hashS return 0, types.ErrCheckpointNotReported.Wrapf("checkpoint hash: %s", hashString) } - btcHeight, err := bytesToUint64(btcHeightBytes) + btcHeight, err := bytesToBtcHeight(btcHeightBytes) if err != nil { panic("invalid data in database") } diff --git a/x/monitor/types/query.pb.go b/x/monitor/types/query.pb.go index 321e6d2de..ea4ce0689 100644 --- a/x/monitor/types/query.pb.go +++ b/x/monitor/types/query.pb.go @@ -78,7 +78,7 @@ func (m *QueryEndedEpochBtcHeightRequest) GetEpochNum() uint64 { // EndedEpochBtcHeight RPC method type QueryEndedEpochBtcHeightResponse struct { // height of btc light client when epoch ended - BtcLightClientHeight uint64 `protobuf:"varint,1,opt,name=btc_light_client_height,json=btcLightClientHeight,proto3" json:"btc_light_client_height,omitempty"` + BtcLightClientHeight uint32 `protobuf:"varint,1,opt,name=btc_light_client_height,json=btcLightClientHeight,proto3" json:"btc_light_client_height,omitempty"` } func (m *QueryEndedEpochBtcHeightResponse) Reset() { *m = QueryEndedEpochBtcHeightResponse{} } @@ -114,7 +114,7 @@ func (m *QueryEndedEpochBtcHeightResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryEndedEpochBtcHeightResponse proto.InternalMessageInfo -func (m *QueryEndedEpochBtcHeightResponse) GetBtcLightClientHeight() uint64 { +func (m *QueryEndedEpochBtcHeightResponse) GetBtcLightClientHeight() uint32 { if m != nil { return m.BtcLightClientHeight } @@ -174,7 +174,7 @@ func (m *QueryReportedCheckpointBtcHeightRequest) GetCkptHash() string { // ReportedCheckpointBtcHeight RPC method type QueryReportedCheckpointBtcHeightResponse struct { // height of btc light client when checkpoint is reported - BtcLightClientHeight uint64 `protobuf:"varint,1,opt,name=btc_light_client_height,json=btcLightClientHeight,proto3" json:"btc_light_client_height,omitempty"` + BtcLightClientHeight uint32 `protobuf:"varint,1,opt,name=btc_light_client_height,json=btcLightClientHeight,proto3" json:"btc_light_client_height,omitempty"` } func (m *QueryReportedCheckpointBtcHeightResponse) Reset() { @@ -212,7 +212,7 @@ func (m *QueryReportedCheckpointBtcHeightResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryReportedCheckpointBtcHeightResponse proto.InternalMessageInfo -func (m *QueryReportedCheckpointBtcHeightResponse) GetBtcLightClientHeight() uint64 { +func (m *QueryReportedCheckpointBtcHeightResponse) GetBtcLightClientHeight() uint32 { if m != nil { return m.BtcLightClientHeight } @@ -229,33 +229,33 @@ func init() { func init() { proto.RegisterFile("babylon/monitor/v1/query.proto", fileDescriptor_a8aafb034c55a8f2) } var fileDescriptor_a8aafb034c55a8f2 = []byte{ - // 405 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x53, 0x4d, 0xab, 0x13, 0x31, - 0x14, 0xed, 0xf8, 0x45, 0x9b, 0x65, 0x14, 0x94, 0x56, 0xc6, 0x32, 0x0b, 0x2d, 0x48, 0x27, 0xd4, - 0xea, 0x4a, 0x71, 0xd1, 0x52, 0x29, 0x28, 0x82, 0xb3, 0xd3, 0xcd, 0x90, 0x49, 0xc3, 0x24, 0x74, - 0x26, 0x49, 0x27, 0x99, 0x62, 0x29, 0xdd, 0xb8, 0x74, 0x25, 0xf8, 0x47, 0xfc, 0x19, 0x6e, 0x84, - 0x82, 0x1b, 0x97, 0xd2, 0xfa, 0x43, 0x64, 0xd2, 0x79, 0xb3, 0x79, 0xd3, 0x57, 0xde, 0x7b, 0xcb, - 0xdc, 0x93, 0x73, 0xee, 0x3d, 0xf7, 0x24, 0xc0, 0x8d, 0x70, 0xb4, 0x4a, 0xa4, 0x40, 0xa9, 0x14, - 0xdc, 0xc8, 0x0c, 0x2d, 0x07, 0x68, 0x91, 0xd3, 0x6c, 0xe5, 0xab, 0x4c, 0x1a, 0x09, 0x61, 0x89, - 0xfb, 0x25, 0xee, 0x2f, 0x07, 0xed, 0x87, 0xb1, 0x94, 0x71, 0x42, 0x11, 0x56, 0x1c, 0x61, 0x21, - 0xa4, 0xc1, 0x86, 0x4b, 0xa1, 0x0f, 0x0c, 0xef, 0x35, 0x78, 0xf4, 0xa1, 0x10, 0x98, 0x88, 0x19, - 0x9d, 0x4d, 0x94, 0x24, 0x6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, 0x75, 0x56, 0x48, 0x45, 0xd4, 0x68, - 0x5d, 0xc5, 0xbf, 0x19, 0xbd, 0xfd, 0xb9, 0x73, 0x9d, 0xed, 0xce, 0x75, 0xfe, 0xee, 0x5c, 0xe7, - 0xdb, 0xde, 0x6d, 0x6c, 0xf7, 0x6e, 0xe3, 0xcf, 0xde, 0x6d, 0x7c, 0x1a, 0xc4, 0xdc, 0xb0, 0x3c, - 0xf2, 0x89, 0x4c, 0xcf, 0x04, 0x13, 0x1c, 0xe9, 0x3e, 0x97, 0x95, 0xfe, 0xe7, 0xaa, 0x83, 0x59, - 0x29, 0xaa, 0xa3, 0x3b, 0xf6, 0x9b, 0x0c, 0xff, 0x07, 0x00, 0x00, 0xff, 0xff, 0x10, 0xaa, 0x98, - 0x3e, 0x7a, 0x03, 0x00, 0x00, + // 408 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x53, 0xcf, 0x8b, 0x13, 0x31, + 0x18, 0xed, 0xf8, 0x8b, 0x36, 0xe0, 0x25, 0x0a, 0x4a, 0x2b, 0x63, 0x99, 0x83, 0x16, 0xa4, 0x13, + 0x6a, 0xf5, 0xa4, 0x78, 0x68, 0xa9, 0x14, 0x14, 0xc1, 0xb9, 0xe9, 0x65, 0xc8, 0xa4, 0x61, 0x12, + 0x3a, 0x93, 0xa4, 0x93, 0x4c, 0xb1, 0x94, 0x5e, 0x3c, 0x7a, 0x12, 0xfc, 0x47, 0xfc, 0x33, 0xbc, + 0x08, 0x05, 0x2f, 0x1e, 0x97, 0x76, 0xff, 0x90, 0x65, 0xd2, 0xee, 0x5c, 0x76, 0xba, 0x65, 0x77, + 0x8f, 0xf9, 0x5e, 0xde, 0xfb, 0xbe, 0xf7, 0xbd, 0x04, 0xb8, 0x11, 0x8e, 0x16, 0x89, 0x14, 0x28, + 0x95, 0x82, 0x1b, 0x99, 0xa1, 0x79, 0x0f, 0xcd, 0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+ 0x3c, 0x78, 0xfe, 0xf7, 0x7f, 0xa7, 0xbf, 0x6e, 0x75, 0xe0, 0x33, 0x54, 0xf1, 0x5a, 0x6c, 0x70, + 0x1a, 0x2d, 0xcb, 0x44, 0x57, 0xf0, 0xaf, 0x03, 0x5a, 0x97, 0xec, 0x06, 0xbe, 0x39, 0x38, 0xc5, + 0xf1, 0x64, 0x9a, 0x6f, 0xaf, 0x47, 0xde, 0x5b, 0xe9, 0x5b, 0x2b, 0x5d, 0xf8, 0xa2, 0xca, 0x0a, + 0x29, 0x89, 0x1a, 0x2d, 0xcb, 0xf8, 0x57, 0x83, 0x0f, 0x7f, 0x36, 0xae, 0xb3, 0xde, 0xb8, 0xce, + 0xc9, 0xc6, 0x75, 0x7e, 0x6e, 0xdd, 0xda, 0x7a, 0xeb, 0xd6, 0xfe, 0x6f, 0xdd, 0xda, 0xd7, 0x5e, + 0xcc, 0x0d, 0xcb, 0x23, 0x9f, 0xc8, 0xf4, 0x5c, 0x30, 0xc1, 0x91, 0xee, 0x72, 0x59, 0xea, 0x7f, + 0x2b, 0x3b, 0x98, 0x85, 0xa2, 0x3a, 0xba, 0x67, 0xbf, 0x49, 0xff, 0x2c, 0x00, 0x00, 0xff, 0xff, + 0x85, 0xb8, 0x2a, 0x58, 0x7a, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -674,7 +674,7 @@ func (m *QueryEndedEpochBtcHeightResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.BtcLightClientHeight |= uint64(b&0x7F) << shift + m.BtcLightClientHeight |= uint32(b&0x7F) << shift if b < 0x80 { break } @@ -825,7 +825,7 @@ func (m *QueryReportedCheckpointBtcHeightResponse) Unmarshal(dAtA []byte) error } b := dAtA[iNdEx] iNdEx++ - m.BtcLightClientHeight |= uint64(b&0x7F) << shift + m.BtcLightClientHeight |= uint32(b&0x7F) << shift if b < 0x80 { break }