From 421a3be04817f95907943c3fa2d785e7b03cb4b0 Mon Sep 17 00:00:00 2001 From: Runchao Han Date: Mon, 20 Nov 2023 18:38:19 +1100 Subject: [PATCH] BTCStaking: generalise KVStore schema and parameters for restaking and multisig covenant (#108) --- cmd/babylond/cmd/flags.go | 4 +- cmd/babylond/cmd/genesis.go | 4 +- proto/babylon/btcstaking/v1/btcstaking.proto | 18 +- proto/babylon/btcstaking/v1/events.proto | 14 +- proto/babylon/btcstaking/v1/params.proto | 19 +- proto/babylon/btcstaking/v1/query.proto | 5 +- test/e2e/btc_staking_e2e_test.go | 18 +- testutil/datagen/btcstaking.go | 55 ++- x/btcstaking/keeper/btc_delegators.go | 59 ++- x/btcstaking/keeper/grpc_query.go | 2 +- x/btcstaking/keeper/grpc_query_test.go | 20 +- x/btcstaking/keeper/incentive_test.go | 6 +- x/btcstaking/keeper/msg_server.go | 39 +- x/btcstaking/keeper/msg_server_test.go | 39 +- .../keeper/voting_power_table_test.go | 17 +- x/btcstaking/types/btc_slashing_tx_test.go | 5 +- x/btcstaking/types/btcstaking.go | 22 +- x/btcstaking/types/btcstaking.pb.go | 405 ++++++++++++++---- x/btcstaking/types/btcstaking_test.go | 5 +- x/btcstaking/types/events.pb.go | 139 +++--- x/btcstaking/types/genesis_test.go | 6 +- x/btcstaking/types/params.go | 16 +- x/btcstaking/types/params.pb.go | 165 ++++--- x/btcstaking/types/query.pb.go | 199 ++++----- 24 files changed, 829 insertions(+), 452 deletions(-) diff --git a/cmd/babylond/cmd/flags.go b/cmd/babylond/cmd/flags.go index 8e63aa2cb..e467d58e3 100644 --- a/cmd/babylond/cmd/flags.go +++ b/cmd/babylond/cmd/flags.go @@ -28,7 +28,7 @@ const ( flagBlocksPerYear = "blocks-per-year" flagGenesisTime = "genesis-time" flagBlockGasLimit = "block-gas-limit" - flagCovenantPk = "covenant-pk" + flagCovenantPk = "covenant-pk" // TODO: multisig covenant flagSlashingAddress = "slashing-address" flagMinSlashingFee = "min-slashing-fee-sat" flagSlashingRate = "slashing-rate" @@ -75,7 +75,7 @@ func addGenesisFlags(cmd *cobra.Command) { cmd.Flags().String(flagBaseBtcHeaderHex, "0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a45068653ffff7f2002000000", "Hex of the base Bitcoin header.") cmd.Flags().Uint64(flagBaseBtcHeaderHeight, 0, "Height of the base Bitcoin header.") // btcstaking args - cmd.Flags().String(flagCovenantPk, btcstypes.DefaultParams().CovenantPk.MarshalHex(), "Bitcoin staking covenant public key") + cmd.Flags().String(flagCovenantPk, btcstypes.DefaultParams().CovenantPks[0].MarshalHex(), "Bitcoin staking covenant public key") cmd.Flags().String(flagSlashingAddress, btcstypes.DefaultParams().SlashingAddress, "Bitcoin staking slashing address") cmd.Flags().Int64(flagMinSlashingFee, 1000, "Bitcoin staking minimum slashing fee") cmd.Flags().String(flagMinCommissionRate, "0", "Bitcoin staking validator minimum commission rate") diff --git a/cmd/babylond/cmd/genesis.go b/cmd/babylond/cmd/genesis.go index b1a0b08df..929049c26 100644 --- a/cmd/babylond/cmd/genesis.go +++ b/cmd/babylond/cmd/genesis.go @@ -305,10 +305,12 @@ func TestnetGenesisParams(maxActiveValidators uint32, btcConfirmationDepth uint6 genParams.BtclightclientBaseBtcHeader = *baseBtcHeaderInfo genParams.BtcstakingParams = btcstakingtypes.DefaultParams() - genParams.BtcstakingParams.CovenantPk, err = bbn.NewBIP340PubKeyFromHex(covenantPk) + covenantPK, err := bbn.NewBIP340PubKeyFromHex(covenantPk) if err != nil { panic(err) } + genParams.BtcstakingParams.CovenantPks = []bbn.BIP340PubKey{*covenantPK} + genParams.BtcstakingParams.CovenantQuorum = 1 // TODO: multisig covenant genParams.BtcstakingParams.SlashingAddress = slashingAddress genParams.BtcstakingParams.MinSlashingTxFeeSat = minSlashingFee genParams.BtcstakingParams.MinCommissionRate = minCommissionRate diff --git a/proto/babylon/btcstaking/v1/btcstaking.proto b/proto/babylon/btcstaking/v1/btcstaking.proto index 3bb7e7103..81208a591 100644 --- a/proto/babylon/btcstaking/v1/btcstaking.proto +++ b/proto/babylon/btcstaking/v1/btcstaking.proto @@ -63,10 +63,11 @@ message BTCDelegation { bytes btc_pk = 2 [ (gogoproto.customtype) = "github.com/babylonchain/babylon/types.BIP340PubKey" ]; // pop is the proof of possession of babylon_pk and btc_pk ProofOfPossession pop = 3; - // val_btc_pk is the Bitcoin secp256k1 PK of the BTC validator that + // val_btc_pk_list is the list of BIP-340 PKs of the BTC validators that // this BTC delegation delegates to - // the PK follows encoding in BIP-340 spec - bytes val_btc_pk = 4 [ (gogoproto.customtype) = "github.com/babylonchain/babylon/types.BIP340PubKey" ]; + // If there is more than 1 PKs, then this means the delegation is restaked + // to multiple BTC validators + repeated bytes val_btc_pk_list = 4 [ (gogoproto.customtype) = "github.com/babylonchain/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; @@ -89,6 +90,7 @@ message BTCDelegation { // covenant_sig is the signature signature on the slashing tx // by the covenant (i.e., SK corresponding to covenant_pk in params) // It will be a part of the witness for the staking tx output. + // TODO: change to a set of (covenant PK, covenant adaptor signature) tuples bytes covenant_sig = 11 [ (gogoproto.customtype) = "github.com/babylonchain/babylon/types.BIP340Signature" ]; // if this object is present it menans that staker requested undelegation, and whole @@ -115,15 +117,18 @@ message BTCUndelegation { // covenant_slashing_sig is the signature on the slashing tx // by the covenant (i.e., SK corresponding to covenant_pk in params) // It must be provided after processing undelagate message by Babylon + // TODO: change to a set of (covenant PK, covenant adaptor signature) tuples bytes covenant_slashing_sig = 4 [ (gogoproto.customtype) = "github.com/babylonchain/babylon/types.BIP340Signature" ]; // covenant_unbonding_sig is the signature on the unbonding tx // by the covenant (i.e., SK corresponding to covenant_pk in params) // It must be provided after processing undelagate message by Babylon and after // validator sig will be provided by validator + // TODO: change to a set of (covenant PK, covenant Schnorr signature) tuples bytes covenant_unbonding_sig = 5 [ (gogoproto.customtype) = "github.com/babylonchain/babylon/types.BIP340Signature" ]; // validator_unbonding_sig is the signature on the unbonding tx // by the validator (i.e., SK corresponding to covenant_pk in params) // It must be provided after processing undelagate message by Babylon + // TODO: this is no longer needed bytes validator_unbonding_sig = 6 [ (gogoproto.customtype) = "github.com/babylonchain/babylon/types.BIP340Signature" ]; } @@ -139,11 +144,13 @@ message BTCUndelegationInfo { // by the validator (i.e., SK corresponding to the pk of the validator that the staker delegates to) // It must be provided after processing undelagate message by Babylon // It will be nil if validator didn't sign it yet + // TODO: this is no longer needed bytes validator_unbonding_sig = 2 [ (gogoproto.customtype) = "github.com/babylonchain/babylon/types.BIP340Signature" ]; // covenant_unbonding_sig is the signature on the unbonding tx // by the covenant (i.e., SK corresponding to covenant_pk in params) // it will be nil if covenant didn't sign it yet + // TODO: change to a set of (covenant PK, covenant Schnorr signature) tuples bytes covenant_unbonding_sig = 3 [ (gogoproto.customtype) = "github.com/babylonchain/babylon/types.BIP340Signature" ]; } @@ -190,3 +197,8 @@ enum BTCDelegationStatus { ANY = 4; } +// SignatureInfo is a BIP-340 signature together with its signer's BIP-340 PK +message SignatureInfo { + bytes pk = 1 [ (gogoproto.customtype) = "github.com/babylonchain/babylon/types.BIP340PubKey" ]; + bytes sig = 2 [ (gogoproto.customtype) = "github.com/babylonchain/babylon/types.BIP340Signature" ]; +} \ No newline at end of file diff --git a/proto/babylon/btcstaking/v1/events.proto b/proto/babylon/btcstaking/v1/events.proto index ef1117d46..b3b5513ba 100644 --- a/proto/babylon/btcstaking/v1/events.proto +++ b/proto/babylon/btcstaking/v1/events.proto @@ -24,10 +24,11 @@ message EventUnbondingBTCDelegation { // btc_pk is the Bitcoin secp256k1 PK of this BTC delegation // the PK follows encoding in BIP-340 spec bytes btc_pk = 1 [ (gogoproto.customtype) = "github.com/babylonchain/babylon/types.BIP340PubKey" ]; - // val_btc_pk is the Bitcoin secp256k1 PK of the BTC validator that + // val_btc_pk_list is the list of BIP-340 PKs of the BTC validators that // this BTC delegation delegates to - // the PK follows encoding in BIP-340 spec - bytes val_btc_pk = 2 [ (gogoproto.customtype) = "github.com/babylonchain/babylon/types.BIP340PubKey" ]; + // If there is more than 1 PKs, then this means the delegation is restaked + // to multiple BTC validators + repeated bytes val_btc_pk_list = 2 [ (gogoproto.customtype) = "github.com/babylonchain/babylon/types.BIP340PubKey" ]; // staking_tx_hash is the hash of the staking tx. // (val_pk, del_pk, staking_tx_hash) uniquely identifies a BTC delegation string staking_tx_hash = 3; @@ -41,10 +42,11 @@ message EventUnbondedBTCDelegation { // btc_pk is the Bitcoin secp256k1 PK of this BTC delegation // the PK follows encoding in BIP-340 spec bytes btc_pk = 1 [ (gogoproto.customtype) = "github.com/babylonchain/babylon/types.BIP340PubKey" ]; - // val_btc_pk is the Bitcoin secp256k1 PK of the BTC validator that + // val_btc_pk_list is the list of BIP-340 PKs of the BTC validators that // this BTC delegation delegates to - // the PK follows encoding in BIP-340 spec - bytes val_btc_pk = 2 [ (gogoproto.customtype) = "github.com/babylonchain/babylon/types.BIP340PubKey" ]; + // If there is more than 1 PKs, then this means the delegation is restaked + // to multiple BTC validators + repeated bytes val_btc_pk_list = 2 [ (gogoproto.customtype) = "github.com/babylonchain/babylon/types.BIP340PubKey" ]; // staking_tx_hash is the hash of the staking tx. // (val_pk, del_pk, staking_tx_hash) uniquely identifies a BTC delegation string staking_tx_hash = 3; diff --git a/proto/babylon/btcstaking/v1/params.proto b/proto/babylon/btcstaking/v1/params.proto index 9a3e56fb2..eaa266c1a 100644 --- a/proto/babylon/btcstaking/v1/params.proto +++ b/proto/babylon/btcstaking/v1/params.proto @@ -10,28 +10,31 @@ option go_package = "github.com/babylonchain/babylon/x/btcstaking/types"; message Params { option (gogoproto.goproto_stringer) = false; - // covenant_pk is the public key of covenant - // the PK follows encoding in BIP-340 spec on Bitcoin - bytes covenant_pk = 1 [ (gogoproto.customtype) = "github.com/babylonchain/babylon/types.BIP340PubKey" ]; + // covenant_pks is the list of public keys held by the covenant committee + // each PK follows encoding in BIP-340 spec on Bitcoin + repeated bytes covenant_pks = 1 [ (gogoproto.customtype) = "github.com/babylonchain/babylon/types.BIP340PubKey" ]; + // covenant_quorum is the minimum number of signatures needed for the covenant + // multisignature + uint32 covenant_quorum = 2; // slashing address is the address that the slashed BTC goes to // the address is in string on Bitcoin - string slashing_address = 2; + string slashing_address = 3; // min_slashing_tx_fee_sat is the minimum amount of tx fee (quantified // in Satoshi) needed for the pre-signed slashing tx // TODO: change to satoshi per byte? - int64 min_slashing_tx_fee_sat = 3; + int64 min_slashing_tx_fee_sat = 4; // min_commission_rate is the chain-wide minimum commission rate that a validator can charge their delegators - string min_commission_rate = 4 [ + string min_commission_rate = 5 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false ]; // slashing_rate determines the portion of the staked amount to be slashed, // expressed as a decimal (e.g., 0.5 for 50%). - string slashing_rate = 5 [ + string slashing_rate = 6 [ (cosmos_proto.scalar) = "cosmos.Dec", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false ]; // max_active_btc_validators is the maximum number of active BTC validators in the BTC staking protocol - uint32 max_active_btc_validators = 6; + uint32 max_active_btc_validators = 7; } diff --git a/proto/babylon/btcstaking/v1/query.proto b/proto/babylon/btcstaking/v1/query.proto index ae84a4e71..f24c669b7 100644 --- a/proto/babylon/btcstaking/v1/query.proto +++ b/proto/babylon/btcstaking/v1/query.proto @@ -222,10 +222,9 @@ message QueryBTCDelegationResponse { // btc_pk is the Bitcoin secp256k1 PK of this BTC delegation // the PK follows encoding in BIP-340 spec bytes btc_pk = 1 [ (gogoproto.customtype) = "github.com/babylonchain/babylon/types.BIP340PubKey" ]; - // val_btc_pk is the Bitcoin secp256k1 PK of the BTC validator that + // val_btc_pk_list is the list of BIP-340 PKs of the BTC validators that // this BTC delegation delegates to - // the PK follows encoding in BIP-340 spec - bytes val_btc_pk = 2 [ (gogoproto.customtype) = "github.com/babylonchain/babylon/types.BIP340PubKey" ]; + repeated bytes val_btc_pk_list = 2 [ (gogoproto.customtype) = "github.com/babylonchain/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 = 3; diff --git a/test/e2e/btc_staking_e2e_test.go b/test/e2e/btc_staking_e2e_test.go index e97ade831..eaff8c122 100644 --- a/test/e2e/btc_staking_e2e_test.go +++ b/test/e2e/btc_staking_e2e_test.go @@ -100,6 +100,11 @@ func (s *BTCStakingTestSuite) Test1CreateBTCValidatorAndDelegation() { */ // BTC staking params, BTC delegation key pairs and PoP params := nonValidatorNode.QueryBTCStakingParams() + // get covenant BTC PKs + covenantBTCPKs := []*btcec.PublicKey{} + for _, covenantPK := range params.CovenantPks { + covenantBTCPKs = append(covenantBTCPKs, covenantPK.MustToBTCPK()) + } // NOTE: we use the node's secret key as Babylon secret key for the BTC delegation delBabylonSK := nonValidatorNode.SecretKey pop, err := bstypes.NewPoP(delBabylonSK, delBTCSK) @@ -110,8 +115,8 @@ func (s *BTCStakingTestSuite) Test1CreateBTCValidatorAndDelegation() { r, net, delBTCSK, - btcVal.BtcPk.MustToBTCPK(), - params.CovenantPk.MustToBTCPK(), + []*btcec.PublicKey{btcVal.BtcPk.MustToBTCPK()}, + covenantBTCPKs, stakingTimeBlocks, stakingValue, params.SlashingAddress, changeAddress.String(), @@ -386,6 +391,11 @@ func (s *BTCStakingTestSuite) Test5SubmitStakerUnbonding() { // params for covenantPk and slashing address params := nonValidatorNode.QueryBTCStakingParams() + // get covenant BTC PKs + covenantBTCPKs := []*btcec.PublicKey{} + for _, covenantPK := range params.CovenantPks { + covenantBTCPKs = append(covenantBTCPKs, covenantPK.MustToBTCPK()) + } stakingTx := activeDel.StakingTx stakingMsgTx, err := stakingTx.ToMsgTx() @@ -404,8 +414,8 @@ func (s *BTCStakingTestSuite) Test5SubmitStakerUnbonding() { r, net, delBTCSK, - btcVal.BtcPk.MustToBTCPK(), - params.CovenantPk.MustToBTCPK(), + []*btcec.PublicKey{btcVal.BtcPk.MustToBTCPK()}, + covenantBTCPKs, wire.NewOutPoint(stakingTxChainHash, uint32(stakingOutputIdx)), initialization.BabylonBtcFinalizationPeriod+1, stakingValue-fee, diff --git a/testutil/datagen/btcstaking.go b/testutil/datagen/btcstaking.go index 3f05da94f..3a0ab1a8d 100644 --- a/testutil/datagen/btcstaking.go +++ b/testutil/datagen/btcstaking.go @@ -65,9 +65,9 @@ func GenRandomBTCValidatorWithBTCBabylonSKs(r *rand.Rand, btcSK *btcec.PrivateKe func GenRandomBTCDelegation( r *rand.Rand, - valBTCPK *bbn.BIP340PubKey, + valBTCPKs []bbn.BIP340PubKey, delSK *btcec.PrivateKey, - covenantSK *btcec.PrivateKey, + covenantSKs []*btcec.PrivateKey, slashingAddress, changeAddress string, startHeight, endHeight, totalSat uint64, slashingRate sdk.Dec, @@ -75,10 +75,19 @@ func GenRandomBTCDelegation( net := &chaincfg.SimNetParams delPK := delSK.PubKey() delBTCPK := bbn.NewBIP340PubKeyFromBTCPK(delPK) - covenantBTCPK := covenantSK.PubKey() - valPK, err := valBTCPK.ToBTCPK() - if err != nil { - return nil, err + // list of covenant PKs + covenantBTCPKs := []*btcec.PublicKey{} + for _, covenantSK := range covenantSKs { + covenantBTCPKs = append(covenantBTCPKs, covenantSK.PubKey()) + } + // list of validator PKs + valPKs := []*btcec.PublicKey{} + for _, valBTCPK := range valBTCPKs { + valPK, err := valBTCPK.ToBTCPK() + if err != nil { + return nil, err + } + valPKs = append(valPKs, valPK) } // BTC delegation Babylon key pairs @@ -100,8 +109,8 @@ func GenRandomBTCDelegation( r, net, delSK, - valPK, - covenantBTCPK, + valPKs, + covenantBTCPKs, uint16(endHeight-startHeight), int64(totalSat), slashingAddress, changeAddress, @@ -115,7 +124,8 @@ func GenRandomBTCDelegation( if err != nil { return nil, err } - covenantSig, err := slashingTx.Sign(stakingMsgTx, stakingTx.Script, covenantSK, net) + // TODO: covenant multisig + covenantSig, err := slashingTx.Sign(stakingMsgTx, stakingTx.Script, covenantSKs[0], net) if err != nil { return nil, err } @@ -128,7 +138,7 @@ func GenRandomBTCDelegation( BabylonPk: secp256k1PK, BtcPk: delBTCPK, Pop: pop, - ValBtcPk: valBTCPK, + ValBtcPkList: valBTCPKs, StartHeight: startHeight, EndHeight: endHeight, TotalSat: totalSat, @@ -144,18 +154,19 @@ func GenBTCStakingSlashingTxWithOutPoint( btcNet *chaincfg.Params, outPoint *wire.OutPoint, stakerSK *btcec.PrivateKey, - validatorPK *btcec.PublicKey, - covenantPK *btcec.PublicKey, + validatorPKs []*btcec.PublicKey, + covenantPKs []*btcec.PublicKey, stakingTimeBlocks uint16, stakingValue int64, slashingAddress, changeAddress string, slashingRate sdk.Dec, withChange bool, ) (*bstypes.BabylonBTCTaprootTx, *bstypes.BTCSlashingTx, error) { + // TODO: covenant multisig stakingOutput, stakingScript, err := btcstaking.BuildStakingOutput( stakerSK.PubKey(), - validatorPK, - covenantPK, + validatorPKs[0], + covenantPKs[0], stakingTimeBlocks, btcutil.Amount(stakingValue), btcNet, @@ -226,8 +237,8 @@ func GenBTCStakingSlashingTx( r *rand.Rand, btcNet *chaincfg.Params, stakerSK *btcec.PrivateKey, - validatorPK *btcec.PublicKey, - covenantPK *btcec.PublicKey, + validatorPKs []*btcec.PublicKey, + covenantPKs []*btcec.PublicKey, stakingTimeBlocks uint16, stakingValue int64, slashingAddress, changeAddress string, @@ -241,8 +252,8 @@ func GenBTCStakingSlashingTx( btcNet, outPoint, stakerSK, - validatorPK, - covenantPK, + validatorPKs, + covenantPKs, stakingTimeBlocks, stakingValue, slashingAddress, changeAddress, @@ -254,8 +265,8 @@ func GenBTCUnbondingSlashingTx( r *rand.Rand, btcNet *chaincfg.Params, stakerSK *btcec.PrivateKey, - validatorPK *btcec.PublicKey, - covenantPK *btcec.PublicKey, + validatorPKs []*btcec.PublicKey, + covenantPKs []*btcec.PublicKey, stakingTransactionOutpoint *wire.OutPoint, stakingTimeBlocks uint16, stakingValue int64, @@ -267,8 +278,8 @@ func GenBTCUnbondingSlashingTx( btcNet, stakingTransactionOutpoint, stakerSK, - validatorPK, - covenantPK, + validatorPKs, + covenantPKs, stakingTimeBlocks, stakingValue, slashingAddress, changeAddress, diff --git a/x/btcstaking/keeper/btc_delegators.go b/x/btcstaking/keeper/btc_delegators.go index bb5eab287..cffc91144 100644 --- a/x/btcstaking/keeper/btc_delegators.go +++ b/x/btcstaking/keeper/btc_delegators.go @@ -13,30 +13,37 @@ import ( // AddBTCDelegation indexes the given BTC delegation in the BTC delegator store, and saves // it under BTC delegation store func (k Keeper) AddBTCDelegation(ctx sdk.Context, btcDel *types.BTCDelegation) error { - var ( - btcDelIndex = types.NewBTCDelegatorDelegationIndex() - err error - ) - if k.hasBTCDelegatorDelegations(ctx, btcDel.ValBtcPk, btcDel.BtcPk) { - btcDelIndex, err = k.getBTCDelegatorDelegationIndex(ctx, btcDel.ValBtcPk, btcDel.BtcPk) - if err != nil { - // this can only be a programming error - panic(fmt.Errorf("failed to get BTC delegations while hasBTCDelegatorDelegations returns true")) - } + if err := btcDel.ValidateBasic(); err != nil { + return err } - // index staking tx hash of this BTC delegation + + // get staking tx hash stakingTxHash, err := btcDel.GetStakingTxHash() if err != nil { return err } - if err := btcDelIndex.Add(stakingTxHash); err != nil { - return types.ErrInvalidStakingTx.Wrapf(err.Error()) + + // for each BTC validator the delegation restakes to, update its index + for _, valBTCPK := range btcDel.ValBtcPkList { + var btcDelIndex = types.NewBTCDelegatorDelegationIndex() + if k.hasBTCDelegatorDelegations(ctx, &valBTCPK, btcDel.BtcPk) { + btcDelIndex, err = k.getBTCDelegatorDelegationIndex(ctx, &valBTCPK, btcDel.BtcPk) + if err != nil { + // this can only be a programming error + panic(fmt.Errorf("failed to get BTC delegations while hasBTCDelegatorDelegations returns true")) + } + } + + // index staking tx hash of this BTC delegation + if err := btcDelIndex.Add(stakingTxHash); err != nil { + return types.ErrInvalidStakingTx.Wrapf(err.Error()) + } + // save the index + store := k.btcDelegatorStore(ctx, &valBTCPK) + delBTCPKBytes := btcDel.BtcPk.MustMarshal() + btcDelIndexBytes := k.cdc.MustMarshal(btcDelIndex) + store.Set(delBTCPKBytes, btcDelIndexBytes) } - // save the index - store := k.btcDelegatorStore(ctx, btcDel.ValBtcPk) - delBTCPKBytes := btcDel.BtcPk.MustMarshal() - btcDelIndexBytes := k.cdc.MustMarshal(btcDelIndex) - store.Set(delBTCPKBytes, btcDelIndexBytes) // save this BTC delegation k.setBTCDelegation(ctx, btcDel) @@ -54,7 +61,7 @@ func (k Keeper) updateBTCDelegation( modifyFn func(*types.BTCDelegation) error, ) error { // get the BTC delegation - btcDel, err := k.GetBTCDelegation(ctx, valBTCPK, delBTCPK, stakingTxHashStr) + btcDel, err := k.GetBTCDelegation(ctx, stakingTxHashStr) if err != nil { return err } @@ -204,23 +211,13 @@ func (k Keeper) getBTCDelegatorDelegations(ctx sdk.Context, valBTCPK *bbn.BIP340 return &types.BTCDelegatorDelegations{Dels: btcDels}, nil } -// GetBTCDelegation gets the BTC delegation with a given BTC PK and staking tx hash under a given BTC validator -// TODO: only take stakingTxHash as input could be enough? -func (k Keeper) GetBTCDelegation(ctx sdk.Context, valBTCPK *bbn.BIP340PubKey, delBTCPK *bbn.BIP340PubKey, stakingTxHashStr string) (*types.BTCDelegation, error) { - // find the BTC delegation index - btcDelIndex, err := k.getBTCDelegatorDelegationIndex(ctx, valBTCPK, delBTCPK) - if err != nil { - return nil, err - } +// GetBTCDelegation gets the BTC delegation with a given staking tx hash +func (k Keeper) GetBTCDelegation(ctx sdk.Context, stakingTxHashStr string) (*types.BTCDelegation, error) { // decode staking tx hash string stakingTxHash, err := chainhash.NewHashFromStr(stakingTxHashStr) if err != nil { return nil, err } - // ensure the BTC delegation index has this staking tx hash - if !btcDelIndex.Has(*stakingTxHash) { - return nil, types.ErrBTCDelegatorNotFound.Wrapf(err.Error()) - } return k.getBTCDelegation(ctx, *stakingTxHash), nil } diff --git a/x/btcstaking/keeper/grpc_query.go b/x/btcstaking/keeper/grpc_query.go index 262cda22a..c81f00465 100644 --- a/x/btcstaking/keeper/grpc_query.go +++ b/x/btcstaking/keeper/grpc_query.go @@ -290,7 +290,7 @@ func (k Keeper) BTCDelegation(ctx context.Context, req *types.QueryBTCDelegation return &types.QueryBTCDelegationResponse{ BtcPk: btcDel.BtcPk, - ValBtcPk: btcDel.ValBtcPk, + ValBtcPkList: btcDel.ValBtcPkList, StartHeight: btcDel.StartHeight, EndHeight: btcDel.EndHeight, TotalSat: btcDel.TotalSat, diff --git a/x/btcstaking/keeper/grpc_query_test.go b/x/btcstaking/keeper/grpc_query_test.go index 76d42082e..d11f2598c 100644 --- a/x/btcstaking/keeper/grpc_query_test.go +++ b/x/btcstaking/keeper/grpc_query_test.go @@ -7,9 +7,11 @@ import ( "github.com/babylonchain/babylon/testutil/datagen" testkeeper "github.com/babylonchain/babylon/testutil/keeper" + bbn "github.com/babylonchain/babylon/types" btcctypes "github.com/babylonchain/babylon/x/btccheckpoint/types" btclctypes "github.com/babylonchain/babylon/x/btclightclient/types" "github.com/babylonchain/babylon/x/btcstaking/types" + "github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/chaincfg" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" @@ -206,9 +208,9 @@ func FuzzPendingBTCDelegations(f *testing.F) { require.NoError(t, err) btcDel, err := datagen.GenRandomBTCDelegation( r, - btcVal.BtcPk, + []bbn.BIP340PubKey{*btcVal.BtcPk}, delSK, - covenantSK, + []*btcec.PrivateKey{covenantSK}, slashingAddress.String(), changeAddress.String(), startHeight, endHeight, 10000, slashingRate, @@ -310,9 +312,9 @@ func FuzzUnbondingBTCDelegations(f *testing.F) { require.NoError(t, err) btcDel, err := datagen.GenRandomBTCDelegation( r, - btcVal.BtcPk, + []bbn.BIP340PubKey{*btcVal.BtcPk}, delSK, - covenantSK, + []*btcec.PrivateKey{covenantSK}, slashingAddress.String(), changeAddress.String(), startHeight, endHeight, 10000, slashingRate, @@ -491,9 +493,9 @@ func FuzzActiveBTCValidatorsAtHeight(f *testing.F) { require.NoError(t, err) btcDel, err := datagen.GenRandomBTCDelegation( r, - valBTCPK, + []bbn.BIP340PubKey{*valBTCPK}, delSK, - covenantSK, + []*btcec.PrivateKey{covenantSK}, slashingAddress.String(), changeAddress.String(), 1, 1000, 10000, slashingRate, @@ -595,9 +597,9 @@ func FuzzBTCValidatorDelegations(f *testing.F) { require.NoError(t, err) btcDel, err := datagen.GenRandomBTCDelegation( r, - btcVal.BtcPk, + []bbn.BIP340PubKey{*btcVal.BtcPk}, delSK, - covenantSK, + []*btcec.PrivateKey{covenantSK}, slashingAddress.String(), changeAddress.String(), startHeight, endHeight, 10000, slashingRate, @@ -638,7 +640,7 @@ func FuzzBTCValidatorDelegations(f *testing.F) { for _, btcDels := range resp.BtcDelegatorDelegations { require.Len(t, btcDels.Dels, 1) btcDel := btcDels.Dels[0] - require.Equal(t, btcVal.BtcPk, btcDel.ValBtcPk) + require.Equal(t, btcVal.BtcPk, &btcDel.ValBtcPkList[0]) // Check if the pk exists in the map _, ok := expectedBtcDelsMap[btcDel.BtcPk.MarshalHex()] require.True(t, ok) diff --git a/x/btcstaking/keeper/incentive_test.go b/x/btcstaking/keeper/incentive_test.go index 37f76eff9..de2db38bb 100644 --- a/x/btcstaking/keeper/incentive_test.go +++ b/x/btcstaking/keeper/incentive_test.go @@ -6,9 +6,11 @@ import ( "github.com/babylonchain/babylon/testutil/datagen" keepertest "github.com/babylonchain/babylon/testutil/keeper" + bbn "github.com/babylonchain/babylon/types" btcctypes "github.com/babylonchain/babylon/x/btccheckpoint/types" btclctypes "github.com/babylonchain/babylon/x/btclightclient/types" "github.com/babylonchain/babylon/x/btcstaking/types" + "github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/chaincfg" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/golang/mock/gomock" @@ -66,9 +68,9 @@ func FuzzRecordRewardDistCache(f *testing.F) { require.NoError(t, err) btcDel, err := datagen.GenRandomBTCDelegation( r, - btcVal.BtcPk, + []bbn.BIP340PubKey{*btcVal.BtcPk}, delSK, - covenantSK, + []*btcec.PrivateKey{covenantSK}, slashingAddress.String(), changeAddress.String(), 1, 1000, stakingValue, slashingRate, diff --git a/x/btcstaking/keeper/msg_server.go b/x/btcstaking/keeper/msg_server.go index ed91a75f2..000356831 100644 --- a/x/btcstaking/keeper/msg_server.go +++ b/x/btcstaking/keeper/msg_server.go @@ -119,6 +119,7 @@ func (ms msgServer) CreateBTCDelegation(goCtx context.Context, req *types.MsgCre kValue, wValue := btccParams.BtcConfirmationDepth, btccParams.CheckpointFinalizationTimeout // extract staking script from staking tx + // TODO: use new algorithm that reconstructs staking tx output then asserts consistency stakingOutputInfo, err := req.StakingTx.GetBabylonOutputInfo(ms.btcNet) if err != nil { return nil, err @@ -155,7 +156,7 @@ func (ms msgServer) CreateBTCDelegation(goCtx context.Context, req *types.MsgCre } // ensure staking tx is using correct covenant PK - paramCovenantPK := params.CovenantPk + paramCovenantPK := ¶ms.CovenantPks[0] // TODO: verifying covenant committee PKs if !covenantPK.Equals(paramCovenantPK) { return nil, types.ErrInvalidCovenantPK.Wrapf("expected: %s; actual: %s", hex.EncodeToString(*paramCovenantPK), hex.EncodeToString(*covenantPK)) } @@ -225,10 +226,11 @@ func (ms msgServer) CreateBTCDelegation(goCtx context.Context, req *types.MsgCre // have voting power only when 1) its corresponding staking tx is k-deep, // and 2) it receives a covenant signature newBTCDel := &types.BTCDelegation{ - BabylonPk: req.BabylonPk, - BtcPk: delBTCPK, - Pop: req.Pop, - ValBtcPk: valBTCPK, + BabylonPk: req.BabylonPk, + BtcPk: delBTCPK, + Pop: req.Pop, + // TODO: ValBtcPkList will be provided in the message + ValBtcPkList: []bbn.BIP340PubKey{*valBTCPK}, StartHeight: startHeight, EndHeight: endHeight, TotalSat: uint64(stakingOutputInfo.StakingAmount), @@ -311,10 +313,11 @@ func (ms msgServer) BTCUndelegate(goCtx context.Context, req *types.MsgBTCUndele // 5. Check Covenant Key from script is consistent with params publicKeyInfos := types.KeyDataFromScript(unbondingOutputInfo.StakingScriptData) - if !publicKeyInfos.CovenantKey.Equals(params.CovenantPk) { + paramCovenantPK := ¶ms.CovenantPks[0] // TODO: verifying covenant committee PKs + if !publicKeyInfos.CovenantKey.Equals(paramCovenantPK) { return nil, types.ErrInvalidCovenantPK.Wrapf( "expected: %s; actual: %s", - hex.EncodeToString(*params.CovenantPk), + hex.EncodeToString(*paramCovenantPK), hex.EncodeToString(*publicKeyInfos.CovenantKey), ) } @@ -322,7 +325,7 @@ func (ms msgServer) BTCUndelegate(goCtx context.Context, req *types.MsgBTCUndele // 6. Check delegation exists for the given validator and delegator and given staking tx hash // as all keys are taken from script, it effectively check that values in delegation staking script // matches the values in the unbonding tx staking script - del, err := ms.GetBTCDelegation(ctx, publicKeyInfos.ValidatorKey, publicKeyInfos.StakerKey, stakingTxHash) + del, err := ms.GetBTCDelegation(ctx, stakingTxHash) if err != nil { return nil, err @@ -381,7 +384,7 @@ func (ms msgServer) BTCUndelegate(goCtx context.Context, req *types.MsgBTCUndele // notify subscriber event := &types.EventUnbondingBTCDelegation{ BtcPk: del.BtcPk, - ValBtcPk: del.ValBtcPk, + ValBtcPkList: del.ValBtcPkList, StakingTxHash: stakingTxHash, UnbondingTxHash: unbondingMsgTx.TxHash().String(), } @@ -397,7 +400,7 @@ func (ms msgServer) AddCovenantSig(goCtx context.Context, req *types.MsgAddCoven ctx := sdk.UnwrapSDKContext(goCtx) // ensure BTC delegation exists - btcDel, err := ms.GetBTCDelegation(ctx, req.ValPk, req.DelPk, req.StakingTxHash) + btcDel, err := ms.GetBTCDelegation(ctx, req.StakingTxHash) if err != nil { return nil, err } @@ -411,7 +414,9 @@ func (ms msgServer) AddCovenantSig(goCtx context.Context, req *types.MsgAddCoven panic(fmt.Errorf("failed to get staking output info from a verified staking tx")) } - covenantPK, err := ms.GetParams(ctx).CovenantPk.ToBTCPK() + // TODO: covenant PK will be a field in the message. Then the verification will be + // that the given covenant PK has to be one of the covenant PKs in the parameter + covenantPK, err := ms.GetParams(ctx).CovenantPks[0].ToBTCPK() if err != nil { // failing to cast a verified covenant PK a programming error panic(fmt.Errorf("failed to cast a verified covenant public key")) @@ -449,7 +454,7 @@ func (ms msgServer) AddCovenantUnbondingSigs( wValue := ms.btccKeeper.GetParams(ctx).CheckpointFinalizationTimeout // 1. Check that delegation even exists for provided params - btcDel, err := ms.GetBTCDelegation(ctx, req.ValPk, req.DelPk, req.StakingTxHash) + btcDel, err := ms.GetBTCDelegation(ctx, req.StakingTxHash) if err != nil { return nil, err } @@ -485,7 +490,9 @@ func (ms msgServer) AddCovenantUnbondingSigs( panic(fmt.Errorf("failed to get staking output info from a verified staking tx")) } - covenantPK, err := ms.GetParams(ctx).CovenantPk.ToBTCPK() + // TODO: covenant PK will be a field in the message. Then the verification will be + // that the given covenant PK has to be one of the covenant PKs in the parameter + covenantPK, err := ms.GetParams(ctx).CovenantPks[0].ToBTCPK() if err != nil { // failing to cast a verified covenant PK is a programming error panic(fmt.Errorf("failed to cast a verified covenant public key")) @@ -538,7 +545,7 @@ func (ms msgServer) AddCovenantUnbondingSigs( if btcDel.BtcUndelegation.HasValidatorSig() { event := &types.EventUnbondedBTCDelegation{ BtcPk: btcDel.BtcPk, - ValBtcPk: btcDel.ValBtcPk, + ValBtcPkList: btcDel.ValBtcPkList, StakingTxHash: req.StakingTxHash, UnbondingTxHash: btcDel.BtcUndelegation.UnbondingTx.MustGetTxHashStr(), FromState: types.BTCDelegationStatus_UNBONDING, @@ -558,7 +565,7 @@ func (ms msgServer) AddValidatorUnbondingSig( wValue := ms.btccKeeper.GetParams(ctx).CheckpointFinalizationTimeout // 1. Check that delegation even exists for provided params - btcDel, err := ms.GetBTCDelegation(ctx, req.ValPk, req.DelPk, req.StakingTxHash) + btcDel, err := ms.GetBTCDelegation(ctx, req.StakingTxHash) if err != nil { return nil, err } @@ -612,7 +619,7 @@ func (ms msgServer) AddValidatorUnbondingSig( if btcDel.BtcUndelegation.HasCovenantSigs() { event := &types.EventUnbondedBTCDelegation{ BtcPk: btcDel.BtcPk, - ValBtcPk: btcDel.ValBtcPk, + ValBtcPkList: btcDel.ValBtcPkList, StakingTxHash: req.StakingTxHash, UnbondingTxHash: btcDel.BtcUndelegation.UnbondingTx.MustGetTxHashStr(), FromState: types.BTCDelegationStatus_UNBONDING, diff --git a/x/btcstaking/keeper/msg_server_test.go b/x/btcstaking/keeper/msg_server_test.go index 11224333b..bb79bd7d6 100644 --- a/x/btcstaking/keeper/msg_server_test.go +++ b/x/btcstaking/keeper/msg_server_test.go @@ -96,7 +96,8 @@ func getCovenantInfo(t *testing.T, slashingAddress, err := datagen.GenRandomBTCAddress(r, net) require.NoError(t, err) err = bsKeeper.SetParams(sdkCtx, types.Params{ - CovenantPk: bbn.NewBIP340PubKeyFromBTCPK(covenantPK), + CovenantPks: []bbn.BIP340PubKey{*bbn.NewBIP340PubKeyFromBTCPK(covenantPK)}, + CovenantQuorum: 1, SlashingAddress: slashingAddress.String(), MinSlashingTxFeeSat: 10, MinCommissionRate: sdk.MustNewDecFromStr("0.01"), @@ -153,8 +154,8 @@ func createDelegation( r, net, delSK, - validatorPK, - covenantPK, + []*btcec.PublicKey{validatorPK}, + []*btcec.PublicKey{covenantPK}, stakingTimeBlocks, stakingValue, slashingAddress, changeAddress, @@ -233,8 +234,9 @@ func createCovenantSig( ) require.NoError(t, err) msgAddCovenantSig := &types.MsgAddCovenantSig{ - Signer: msgCreateBTCDel.Signer, - ValPk: delegation.ValBtcPk, + Signer: msgCreateBTCDel.Signer, + // TODO: this will be removed after all + ValPk: &delegation.ValBtcPkList[0], DelPk: delegation.BtcPk, StakingTxHash: stakingTxHash, Sig: covenantSig, @@ -245,7 +247,7 @@ func createCovenantSig( /* ensure covenant sig is added successfully */ - actualDelWithCovenantSig, err := bsKeeper.GetBTCDelegation(sdkCtx, delegation.ValBtcPk, delegation.BtcPk, stakingTxHash) + actualDelWithCovenantSig, err := bsKeeper.GetBTCDelegation(sdkCtx, stakingTxHash) require.NoError(t, err) require.Equal(t, actualDelWithCovenantSig.CovenantSig.MustMarshal(), covenantSig.MustMarshal()) require.True(t, actualDelWithCovenantSig.HasCovenantSig()) @@ -262,7 +264,7 @@ func getDelegationAndCheckValues( delegatorPK *btcec.PublicKey, stakingTxHash string, ) *types.BTCDelegation { - actualDel, err := bsKeeper.GetBTCDelegation(sdkCtx, bbn.NewBIP340PubKeyFromBTCPK(validatorPK), bbn.NewBIP340PubKeyFromBTCPK(delegatorPK), stakingTxHash) + actualDel, err := bsKeeper.GetBTCDelegation(sdkCtx, stakingTxHash) require.NoError(t, err) require.Equal(t, msgCreateBTCDel.BabylonPk, actualDel.BabylonPk) require.Equal(t, msgCreateBTCDel.Pop, actualDel.Pop) @@ -300,8 +302,8 @@ func createUndelegation( r, net, delSK, - validatorPK, - covenantPK, + []*btcec.PublicKey{validatorPK}, + []*btcec.PublicKey{covenantPK}, wire.NewOutPoint(stkTxHash, stkOutputIdx), uint16(defaultParams.CheckpointFinalizationTimeout)+1, int64(actualDel.TotalSat)-1000, @@ -414,7 +416,8 @@ func TestDoNotAllowDelegationWithoutValidator(t *testing.T) { changeAddress, err := datagen.GenRandomBTCAddress(r, net) require.NoError(t, err) err = bsKeeper.SetParams(ctx, types.Params{ - CovenantPk: bbn.NewBIP340PubKeyFromBTCPK(covenantPK), + CovenantPks: []bbn.BIP340PubKey{*bbn.NewBIP340PubKeyFromBTCPK(covenantPK)}, + CovenantQuorum: 1, SlashingAddress: slashingAddress.String(), MinSlashingTxFeeSat: 10, MinCommissionRate: sdk.MustNewDecFromStr("0.01"), @@ -439,8 +442,8 @@ func TestDoNotAllowDelegationWithoutValidator(t *testing.T) { r, net, delSK, - validatorPK, - covenantPK, + []*btcec.PublicKey{validatorPK}, + []*btcec.PublicKey{covenantPK}, stakingTimeBlocks, stakingValue, slashingAddress.String(), changeAddress.String(), @@ -542,7 +545,7 @@ func FuzzCreateBTCDelegationAndUndelegation(f *testing.F) { bsKeeper.GetParams(ctx).SlashingRate, ) - actualDelegationWithUnbonding, err := bsKeeper.GetBTCDelegation(ctx, actualDel.ValBtcPk, actualDel.BtcPk, stakingTxHash) + actualDelegationWithUnbonding, err := bsKeeper.GetBTCDelegation(ctx, stakingTxHash) require.NoError(t, err) require.NotNil(t, actualDelegationWithUnbonding.BtcUndelegation) @@ -608,7 +611,7 @@ func FuzzAddCovenantAndValidatorSignaturesToUnbondind(f *testing.F) { bsKeeper.GetParams(ctx).SlashingRate, ) - del, err := bsKeeper.GetBTCDelegation(ctx, actualDel.ValBtcPk, actualDel.BtcPk, stakingTxHash) + del, err := bsKeeper.GetBTCDelegation(ctx, stakingTxHash) require.NoError(t, err) require.NotNil(t, del.BtcUndelegation) @@ -624,7 +627,7 @@ func FuzzAddCovenantAndValidatorSignaturesToUnbondind(f *testing.F) { require.NoError(t, err) msg := types.MsgAddValidatorUnbondingSig{ Signer: datagen.GenRandomAccount().Address, - ValPk: del.ValBtcPk, + ValPk: &del.ValBtcPkList[0], DelPk: del.BtcPk, StakingTxHash: stakingTxHash, UnbondingTxSig: ubondingTxSignatureValidator, @@ -633,7 +636,7 @@ func FuzzAddCovenantAndValidatorSignaturesToUnbondind(f *testing.F) { _, err = ms.AddValidatorUnbondingSig(goCtx, &msg) require.NoError(t, err) - delWithValSig, err := bsKeeper.GetBTCDelegation(ctx, actualDel.ValBtcPk, actualDel.BtcPk, stakingTxHash) + delWithValSig, err := bsKeeper.GetBTCDelegation(ctx, stakingTxHash) require.NoError(t, err) require.NotNil(t, delWithValSig.BtcUndelegation) require.NotNil(t, delWithValSig.BtcUndelegation.ValidatorUnbondingSig) @@ -662,7 +665,7 @@ func FuzzAddCovenantAndValidatorSignaturesToUnbondind(f *testing.F) { covenantSigsMsg := types.MsgAddCovenantUnbondingSigs{ Signer: datagen.GenRandomAccount().Address, - ValPk: del.ValBtcPk, + ValPk: &del.ValBtcPkList[0], DelPk: del.BtcPk, StakingTxHash: stakingTxHash, UnbondingTxSig: unbondingTxSignatureCovenant, @@ -673,7 +676,7 @@ func FuzzAddCovenantAndValidatorSignaturesToUnbondind(f *testing.F) { _, err = ms.AddCovenantUnbondingSigs(goCtx, &covenantSigsMsg) require.NoError(t, err) - delWithUnbondingSigs, err := bsKeeper.GetBTCDelegation(ctx, actualDel.ValBtcPk, actualDel.BtcPk, stakingTxHash) + delWithUnbondingSigs, err := bsKeeper.GetBTCDelegation(ctx, stakingTxHash) require.NoError(t, err) require.NotNil(t, delWithUnbondingSigs.BtcUndelegation) require.NotNil(t, delWithUnbondingSigs.BtcUndelegation.ValidatorUnbondingSig) diff --git a/x/btcstaking/keeper/voting_power_table_test.go b/x/btcstaking/keeper/voting_power_table_test.go index c1bd544fe..9fe9734c2 100644 --- a/x/btcstaking/keeper/voting_power_table_test.go +++ b/x/btcstaking/keeper/voting_power_table_test.go @@ -10,6 +10,7 @@ import ( btcctypes "github.com/babylonchain/babylon/x/btccheckpoint/types" btclctypes "github.com/babylonchain/babylon/x/btclightclient/types" "github.com/babylonchain/babylon/x/btcstaking/types" + "github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/chaincfg" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/golang/mock/gomock" @@ -64,9 +65,9 @@ func FuzzVotingPowerTable(f *testing.F) { require.NoError(t, err) btcDel, err := datagen.GenRandomBTCDelegation( r, - btcVals[i].BtcPk, + []bbn.BIP340PubKey{*btcVals[i].BtcPk}, delSK, - covenantSK, + []*btcec.PrivateKey{covenantSK}, slashingAddress.String(), changeAddress.String(), 1, 1000, stakingValue, slashingRate, @@ -230,9 +231,9 @@ func FuzzVotingPowerTable_ActiveBTCValidators(f *testing.F) { require.NoError(t, err) btcDel, err := datagen.GenRandomBTCDelegation( r, - valBTCPK, + []bbn.BIP340PubKey{*valBTCPK}, delSK, - covenantSK, + []*btcec.PrivateKey{covenantSK}, slashingAddress.String(), changeAddress.String(), 1, 1000, stakingValue, // timelock period: 1-1000 slashingRate, @@ -332,9 +333,9 @@ func FuzzVotingPowerTable_ActiveBTCValidatorRotation(f *testing.F) { require.NoError(t, err) btcDel, err := datagen.GenRandomBTCDelegation( r, - valBTCPK, + []bbn.BIP340PubKey{*valBTCPK}, delSK, - covenantSK, + []*btcec.PrivateKey{covenantSK}, slashingAddress.String(), changeAddress.String(), 1, 1000, stakingValue, // timelock period: 1-1000 slashingRate, @@ -378,9 +379,9 @@ func FuzzVotingPowerTable_ActiveBTCValidatorRotation(f *testing.F) { require.NoError(t, err) btcDel, err := datagen.GenRandomBTCDelegation( r, - activatedValBTCPK, + []bbn.BIP340PubKey{*activatedValBTCPK}, delSK, - covenantSK, + []*btcec.PrivateKey{covenantSK}, slashingAddress.String(), changeAddress.String(), 1, 1000, stakingValue, // timelock period: 1-1000 slashingRate, diff --git a/x/btcstaking/types/btc_slashing_tx_test.go b/x/btcstaking/types/btc_slashing_tx_test.go index 51ad987e0..e7edea0ad 100644 --- a/x/btcstaking/types/btc_slashing_tx_test.go +++ b/x/btcstaking/types/btc_slashing_tx_test.go @@ -6,6 +6,7 @@ import ( btctest "github.com/babylonchain/babylon/testutil/bitcoin" "github.com/babylonchain/babylon/testutil/datagen" + "github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/chaincfg" "github.com/btcsuite/btcd/txscript" sdk "github.com/cosmos/cosmos-sdk/types" @@ -46,8 +47,8 @@ func FuzzSlashingTxWithWitness(f *testing.F) { r, net, delSK, - valPK, - covenantPK, + []*btcec.PublicKey{valPK}, + []*btcec.PublicKey{covenantPK}, stakingTimeBlocks, stakingValue, slashingAddress.String(), changeAddress.String(), diff --git a/x/btcstaking/types/btcstaking.go b/x/btcstaking/types/btcstaking.go index b28cffbb1..8c7bb0357 100644 --- a/x/btcstaking/types/btcstaking.go +++ b/x/btcstaking/types/btcstaking.go @@ -67,8 +67,11 @@ func (d *BTCDelegation) ValidateBasic() error { if d.Pop == nil { return fmt.Errorf("empty proof of possession") } - if d.ValBtcPk == nil { - return fmt.Errorf("empty Validator BTC public key") + if len(d.ValBtcPkList) == 0 { + return fmt.Errorf("empty list of BTC validator PKs") + } + if existsDup(d.ValBtcPkList) { + return fmt.Errorf("list of BTC validator PKs has duplication") } if d.StakingTx == nil { return fmt.Errorf("empty staking tx") @@ -351,3 +354,18 @@ func FilterTopNBTCValidators(validators []*BTCValidatorWithMeta, n uint32) []*BT // Return the top n elements return validators[:n] } + +func existsDup(btcPKs []bbn.BIP340PubKey) bool { + seen := make(map[string]struct{}) + + for _, btcPK := range btcPKs { + pkStr := string(btcPK) + if _, found := seen[pkStr]; found { + return true + } else { + seen[pkStr] = struct{}{} + } + } + + return false +} diff --git a/x/btcstaking/types/btcstaking.pb.go b/x/btcstaking/types/btcstaking.pb.go index c460f28b7..1df7af0b1 100644 --- a/x/btcstaking/types/btcstaking.pb.go +++ b/x/btcstaking/types/btcstaking.pb.go @@ -258,10 +258,11 @@ type BTCDelegation struct { BtcPk *github_com_babylonchain_babylon_types.BIP340PubKey `protobuf:"bytes,2,opt,name=btc_pk,json=btcPk,proto3,customtype=github.com/babylonchain/babylon/types.BIP340PubKey" json:"btc_pk,omitempty"` // pop is the proof of possession of babylon_pk and btc_pk Pop *ProofOfPossession `protobuf:"bytes,3,opt,name=pop,proto3" json:"pop,omitempty"` - // val_btc_pk is the Bitcoin secp256k1 PK of the BTC validator that + // val_btc_pk_list is the list of BIP-340 PKs of the BTC validators that // this BTC delegation delegates to - // the PK follows encoding in BIP-340 spec - ValBtcPk *github_com_babylonchain_babylon_types.BIP340PubKey `protobuf:"bytes,4,opt,name=val_btc_pk,json=valBtcPk,proto3,customtype=github.com/babylonchain/babylon/types.BIP340PubKey" json:"val_btc_pk,omitempty"` + // If there is more than 1 PKs, then this means the delegation is restaked + // to multiple BTC validators + ValBtcPkList []github_com_babylonchain_babylon_types.BIP340PubKey `protobuf:"bytes,4,rep,name=val_btc_pk_list,json=valBtcPkList,proto3,customtype=github.com/babylonchain/babylon/types.BIP340PubKey" json:"val_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,5,opt,name=start_height,json=startHeight,proto3" json:"start_height,omitempty"` @@ -284,6 +285,7 @@ type BTCDelegation struct { // covenant_sig is the signature signature on the slashing tx // by the covenant (i.e., SK corresponding to covenant_pk in params) // It will be a part of the witness for the staking tx output. + // TODO: change to a set of (covenant PK, covenant adaptor signature) tuples CovenantSig *github_com_babylonchain_babylon_types.BIP340Signature `protobuf:"bytes,11,opt,name=covenant_sig,json=covenantSig,proto3,customtype=github.com/babylonchain/babylon/types.BIP340Signature" json:"covenant_sig,omitempty"` // if this object is present it menans that staker requested undelegation, and whole // delegation is being undelegated. @@ -391,15 +393,18 @@ type BTCUndelegation struct { // covenant_slashing_sig is the signature on the slashing tx // by the covenant (i.e., SK corresponding to covenant_pk in params) // It must be provided after processing undelagate message by Babylon + // TODO: change to a set of (covenant PK, covenant adaptor signature) tuples CovenantSlashingSig *github_com_babylonchain_babylon_types.BIP340Signature `protobuf:"bytes,4,opt,name=covenant_slashing_sig,json=covenantSlashingSig,proto3,customtype=github.com/babylonchain/babylon/types.BIP340Signature" json:"covenant_slashing_sig,omitempty"` // covenant_unbonding_sig is the signature on the unbonding tx // by the covenant (i.e., SK corresponding to covenant_pk in params) // It must be provided after processing undelagate message by Babylon and after // validator sig will be provided by validator + // TODO: change to a set of (covenant PK, covenant Schnorr signature) tuples CovenantUnbondingSig *github_com_babylonchain_babylon_types.BIP340Signature `protobuf:"bytes,5,opt,name=covenant_unbonding_sig,json=covenantUnbondingSig,proto3,customtype=github.com/babylonchain/babylon/types.BIP340Signature" json:"covenant_unbonding_sig,omitempty"` // validator_unbonding_sig is the signature on the unbonding tx // by the validator (i.e., SK corresponding to covenant_pk in params) // It must be provided after processing undelagate message by Babylon + // TODO: this is no longer needed ValidatorUnbondingSig *github_com_babylonchain_babylon_types.BIP340Signature `protobuf:"bytes,6,opt,name=validator_unbonding_sig,json=validatorUnbondingSig,proto3,customtype=github.com/babylonchain/babylon/types.BIP340Signature" json:"validator_unbonding_sig,omitempty"` } @@ -453,10 +458,12 @@ type BTCUndelegationInfo struct { // by the validator (i.e., SK corresponding to the pk of the validator that the staker delegates to) // It must be provided after processing undelagate message by Babylon // It will be nil if validator didn't sign it yet + // TODO: this is no longer needed ValidatorUnbondingSig *github_com_babylonchain_babylon_types.BIP340Signature `protobuf:"bytes,2,opt,name=validator_unbonding_sig,json=validatorUnbondingSig,proto3,customtype=github.com/babylonchain/babylon/types.BIP340Signature" json:"validator_unbonding_sig,omitempty"` // covenant_unbonding_sig is the signature on the unbonding tx // by the covenant (i.e., SK corresponding to covenant_pk in params) // it will be nil if covenant didn't sign it yet + // TODO: change to a set of (covenant PK, covenant Schnorr signature) tuples CovenantUnbondingSig *github_com_babylonchain_babylon_types.BIP340Signature `protobuf:"bytes,3,opt,name=covenant_unbonding_sig,json=covenantUnbondingSig,proto3,customtype=github.com/babylonchain/babylon/types.BIP340Signature" json:"covenant_unbonding_sig,omitempty"` } @@ -646,6 +653,45 @@ func (m *BabylonBTCTaprootTx) GetScript() []byte { return nil } +// SignatureInfo is a BIP-340 signature together with its signer's BIP-340 PK +type SignatureInfo struct { + Pk *github_com_babylonchain_babylon_types.BIP340PubKey `protobuf:"bytes,1,opt,name=pk,proto3,customtype=github.com/babylonchain/babylon/types.BIP340PubKey" json:"pk,omitempty"` + Sig *github_com_babylonchain_babylon_types.BIP340Signature `protobuf:"bytes,2,opt,name=sig,proto3,customtype=github.com/babylonchain/babylon/types.BIP340Signature" json:"sig,omitempty"` +} + +func (m *SignatureInfo) Reset() { *m = SignatureInfo{} } +func (m *SignatureInfo) String() string { return proto.CompactTextString(m) } +func (*SignatureInfo) ProtoMessage() {} +func (*SignatureInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_3851ae95ccfaf7db, []int{8} +} +func (m *SignatureInfo) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *SignatureInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_SignatureInfo.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *SignatureInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_SignatureInfo.Merge(m, src) +} +func (m *SignatureInfo) XXX_Size() int { + return m.Size() +} +func (m *SignatureInfo) XXX_DiscardUnknown() { + xxx_messageInfo_SignatureInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_SignatureInfo proto.InternalMessageInfo + func init() { proto.RegisterEnum("babylon.btcstaking.v1.BTCDelegationStatus", BTCDelegationStatus_name, BTCDelegationStatus_value) proto.RegisterType((*BTCValidator)(nil), "babylon.btcstaking.v1.BTCValidator") @@ -656,6 +702,7 @@ func init() { proto.RegisterType((*BTCDelegatorDelegations)(nil), "babylon.btcstaking.v1.BTCDelegatorDelegations") proto.RegisterType((*BTCDelegatorDelegationIndex)(nil), "babylon.btcstaking.v1.BTCDelegatorDelegationIndex") proto.RegisterType((*BabylonBTCTaprootTx)(nil), "babylon.btcstaking.v1.BabylonBTCTaprootTx") + proto.RegisterType((*SignatureInfo)(nil), "babylon.btcstaking.v1.SignatureInfo") } func init() { @@ -663,72 +710,74 @@ func init() { } var fileDescriptor_3851ae95ccfaf7db = []byte{ - // 1033 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0xdb, 0x6e, 0xdb, 0x46, - 0x13, 0x36, 0x25, 0x59, 0xb6, 0x46, 0xf4, 0x1f, 0x65, 0x7d, 0x88, 0x7e, 0x07, 0x95, 0x1c, 0x35, - 0x30, 0x84, 0xa0, 0x91, 0x6a, 0xe7, 0x80, 0xb4, 0x40, 0x0b, 0x44, 0x96, 0xd1, 0x08, 0x8d, 0x1d, - 0x95, 0xa2, 0xd3, 0x03,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, 0x3e, 0x30, 0xb7, 0x9b, 0x85, 0x34, 0x9a, 0x83, 0xf4, 0xf3, 0xdd, 0xef, - 0x0b, 0x99, 0xc6, 0xcb, 0x37, 0x27, 0x25, 0xe5, 0xed, 0x49, 0x49, 0xf9, 0xeb, 0xa4, 0xa4, 0xfc, - 0x76, 0x5a, 0x9a, 0x79, 0x7b, 0x5a, 0x9a, 0x79, 0x77, 0x5a, 0x9a, 0xf9, 0xe1, 0x1f, 0xaf, 0xc9, - 0x49, 0xf2, 0xf9, 0x2c, 0xd4, 0x32, 0xb2, 0xe2, 0xf9, 0xfc, 0xe8, 0xef, 0x00, 0x00, 0x00, 0xff, - 0xff, 0x3a, 0x84, 0xbc, 0x0b, 0x1b, 0x0c, 0x00, 0x00, + // 1063 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0xdb, 0x6e, 0x1b, 0x45, + 0x18, 0xce, 0xee, 0x3a, 0x6e, 0xfc, 0x7b, 0x43, 0xdc, 0xc9, 0xa1, 0x26, 0x15, 0x76, 0x30, 0x55, + 0x64, 0x55, 0xd4, 0x26, 0xe9, 0x41, 0x05, 0x09, 0xa4, 0x3a, 0x0e, 0xd4, 0x6a, 0x93, 0x9a, 0xb5, + 0x53, 0x0e, 0x02, 0xac, 0x3d, 0x4c, 0xec, 0x95, 0x9d, 0x9d, 0x65, 0x67, 0x6c, 0x9c, 0x7b, 0x1e, + 0x80, 0x87, 0xe0, 0x82, 0x07, 0xe0, 0x21, 0x7a, 0x59, 0x71, 0x55, 0xe5, 0xc2, 0x42, 0xc9, 0x8b, + 0xa0, 0x9d, 0x9d, 0x3d, 0x24, 0x4d, 0x02, 0xc1, 0xe9, 0x95, 0xfd, 0xcf, 0x7f, 0xfe, 0xbe, 0x4f, + 0x3b, 0x03, 0xeb, 0x86, 0x6e, 0x1c, 0x0e, 0x88, 0x53, 0x35, 0x98, 0x49, 0x99,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f, 0x0b, 0xd2, 0x6f, 0x27, + 0x85, 0x99, 0xd7, 0x27, 0x85, 0x99, 0x37, 0x27, 0x85, 0x99, 0xef, 0xff, 0x75, 0xe9, 0x71, 0xf2, + 0xb9, 0xcf, 0x07, 0x37, 0xd2, 0xfc, 0xb9, 0x7f, 0xff, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x2a, + 0x08, 0xdb, 0x22, 0xcb, 0x0c, 0x00, 0x00, } func (m *BTCValidator) Marshal() (dAtA []byte, err error) { @@ -974,17 +1023,19 @@ func (m *BTCDelegation) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x28 } - if m.ValBtcPk != nil { - { - size := m.ValBtcPk.Size() - i -= size - if _, err := m.ValBtcPk.MarshalTo(dAtA[i:]); err != nil { - return 0, err + if len(m.ValBtcPkList) > 0 { + for iNdEx := len(m.ValBtcPkList) - 1; iNdEx >= 0; iNdEx-- { + { + size := m.ValBtcPkList[iNdEx].Size() + i -= size + if _, err := m.ValBtcPkList[iNdEx].MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintBtcstaking(dAtA, i, uint64(size)) } - i = encodeVarintBtcstaking(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x22 } - i-- - dAtA[i] = 0x22 } if m.Pop != nil { { @@ -1285,6 +1336,53 @@ func (m *BabylonBTCTaprootTx) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *SignatureInfo) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *SignatureInfo) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *SignatureInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Sig != nil { + { + size := m.Sig.Size() + i -= size + if _, err := m.Sig.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintBtcstaking(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if m.Pk != nil { + { + size := m.Pk.Size() + i -= size + if _, err := m.Pk.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintBtcstaking(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintBtcstaking(dAtA []byte, offset int, v uint64) int { offset -= sovBtcstaking(v) base := offset @@ -1374,9 +1472,11 @@ func (m *BTCDelegation) Size() (n int) { l = m.Pop.Size() n += 1 + l + sovBtcstaking(uint64(l)) } - if m.ValBtcPk != nil { - l = m.ValBtcPk.Size() - n += 1 + l + sovBtcstaking(uint64(l)) + if len(m.ValBtcPkList) > 0 { + for _, e := range m.ValBtcPkList { + l = e.Size() + n += 1 + l + sovBtcstaking(uint64(l)) + } } if m.StartHeight != 0 { n += 1 + sovBtcstaking(uint64(m.StartHeight)) @@ -1511,6 +1611,23 @@ func (m *BabylonBTCTaprootTx) Size() (n int) { return n } +func (m *SignatureInfo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Pk != nil { + l = m.Pk.Size() + n += 1 + l + sovBtcstaking(uint64(l)) + } + if m.Sig != nil { + l = m.Sig.Size() + n += 1 + l + sovBtcstaking(uint64(l)) + } + return n +} + func sovBtcstaking(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -2083,7 +2200,7 @@ func (m *BTCDelegation) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 4: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ValBtcPk", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ValBtcPkList", wireType) } var byteLen int for shift := uint(0); ; shift += 7 { @@ -2111,8 +2228,8 @@ func (m *BTCDelegation) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } var v github_com_babylonchain_babylon_types.BIP340PubKey - m.ValBtcPk = &v - if err := m.ValBtcPk.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.ValBtcPkList = append(m.ValBtcPkList, v) + if err := m.ValBtcPkList[len(m.ValBtcPkList)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -3072,6 +3189,126 @@ func (m *BabylonBTCTaprootTx) Unmarshal(dAtA []byte) error { } return nil } +func (m *SignatureInfo) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBtcstaking + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: SignatureInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SignatureInfo: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pk", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBtcstaking + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthBtcstaking + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthBtcstaking + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var v github_com_babylonchain_babylon_types.BIP340PubKey + m.Pk = &v + if err := m.Pk.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sig", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBtcstaking + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthBtcstaking + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthBtcstaking + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var v github_com_babylonchain_babylon_types.BIP340Signature + m.Sig = &v + if err := m.Sig.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipBtcstaking(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthBtcstaking + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipBtcstaking(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/btcstaking/types/btcstaking_test.go b/x/btcstaking/types/btcstaking_test.go index 8b43650e7..3ad6d72ad 100644 --- a/x/btcstaking/types/btcstaking_test.go +++ b/x/btcstaking/types/btcstaking_test.go @@ -7,6 +7,7 @@ import ( "github.com/babylonchain/babylon/testutil/datagen" bbn "github.com/babylonchain/babylon/types" "github.com/babylonchain/babylon/x/btcstaking/types" + "github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/chaincfg" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" @@ -42,8 +43,8 @@ func FuzzStakingTx(f *testing.F) { r, net, stakerSK, - validatorPK, - covenantPK, + []*btcec.PublicKey{validatorPK}, + []*btcec.PublicKey{covenantPK}, stakingTimeBlocks, stakingValue, slashingAddress.String(), changeAddress.String(), diff --git a/x/btcstaking/types/events.pb.go b/x/btcstaking/types/events.pb.go index 02edf82bb..4cb448a80 100644 --- a/x/btcstaking/types/events.pb.go +++ b/x/btcstaking/types/events.pb.go @@ -168,10 +168,11 @@ type EventUnbondingBTCDelegation struct { // btc_pk is the Bitcoin secp256k1 PK of this BTC delegation // the PK follows encoding in BIP-340 spec BtcPk *github_com_babylonchain_babylon_types.BIP340PubKey `protobuf:"bytes,1,opt,name=btc_pk,json=btcPk,proto3,customtype=github.com/babylonchain/babylon/types.BIP340PubKey" json:"btc_pk,omitempty"` - // val_btc_pk is the Bitcoin secp256k1 PK of the BTC validator that + // val_btc_pk_list is the list of BIP-340 PKs of the BTC validators that // this BTC delegation delegates to - // the PK follows encoding in BIP-340 spec - ValBtcPk *github_com_babylonchain_babylon_types.BIP340PubKey `protobuf:"bytes,2,opt,name=val_btc_pk,json=valBtcPk,proto3,customtype=github.com/babylonchain/babylon/types.BIP340PubKey" json:"val_btc_pk,omitempty"` + // If there is more than 1 PKs, then this means the delegation is restaked + // to multiple BTC validators + ValBtcPkList []github_com_babylonchain_babylon_types.BIP340PubKey `protobuf:"bytes,2,rep,name=val_btc_pk_list,json=valBtcPkList,proto3,customtype=github.com/babylonchain/babylon/types.BIP340PubKey" json:"val_btc_pk_list,omitempty"` // staking_tx_hash is the hash of the staking tx. // (val_pk, del_pk, staking_tx_hash) uniquely identifies a BTC delegation StakingTxHash string `protobuf:"bytes,3,opt,name=staking_tx_hash,json=stakingTxHash,proto3" json:"staking_tx_hash,omitempty"` @@ -232,10 +233,11 @@ type EventUnbondedBTCDelegation struct { // btc_pk is the Bitcoin secp256k1 PK of this BTC delegation // the PK follows encoding in BIP-340 spec BtcPk *github_com_babylonchain_babylon_types.BIP340PubKey `protobuf:"bytes,1,opt,name=btc_pk,json=btcPk,proto3,customtype=github.com/babylonchain/babylon/types.BIP340PubKey" json:"btc_pk,omitempty"` - // val_btc_pk is the Bitcoin secp256k1 PK of the BTC validator that + // val_btc_pk_list is the list of BIP-340 PKs of the BTC validators that // this BTC delegation delegates to - // the PK follows encoding in BIP-340 spec - ValBtcPk *github_com_babylonchain_babylon_types.BIP340PubKey `protobuf:"bytes,2,opt,name=val_btc_pk,json=valBtcPk,proto3,customtype=github.com/babylonchain/babylon/types.BIP340PubKey" json:"val_btc_pk,omitempty"` + // If there is more than 1 PKs, then this means the delegation is restaked + // to multiple BTC validators + ValBtcPkList []github_com_babylonchain_babylon_types.BIP340PubKey `protobuf:"bytes,2,rep,name=val_btc_pk_list,json=valBtcPkList,proto3,customtype=github.com/babylonchain/babylon/types.BIP340PubKey" json:"val_btc_pk_list,omitempty"` // staking_tx_hash is the hash of the staking tx. // (val_pk, del_pk, staking_tx_hash) uniquely identifies a BTC delegation StakingTxHash string `protobuf:"bytes,3,opt,name=staking_tx_hash,json=stakingTxHash,proto3" json:"staking_tx_hash,omitempty"` @@ -312,34 +314,35 @@ func init() { } var fileDescriptor_74118427820fff75 = []byte{ - // 431 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x93, 0xcd, 0xaa, 0xd3, 0x40, - 0x18, 0x86, 0x9b, 0xea, 0x39, 0x7a, 0xc6, 0x9f, 0x83, 0xe1, 0x14, 0x4a, 0x85, 0x58, 0xa2, 0x94, - 0xd2, 0x45, 0x62, 0x5b, 0x71, 0xa5, 0x0b, 0x63, 0x05, 0x8b, 0x3f, 0x94, 0x18, 0xbb, 0xd0, 0x45, - 0x98, 0x49, 0xc6, 0x24, 0x74, 0x3a, 0x53, 0x9a, 0x2f, 0xb1, 0xbd, 0x0b, 0x57, 0x5e, 0x93, 0xcb, - 0x2e, 0xc5, 0x85, 0x94, 0xf6, 0x46, 0x24, 0x93, 0xb4, 0x8d, 0x50, 0x51, 0xd0, 0xa5, 0xbb, 0x49, - 0xf2, 0xbc, 0xcf, 0xc7, 0xf7, 0x92, 0x41, 0x3a, 0xc1, 0x64, 0xc9, 0x04, 0x37, 0x09, 0x78, 0x31, - 0xe0, 0x49, 0xc4,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x08, 0x78, 0xa3, 0x89, 0xea, 0x20, 0x94, - 0x62, 0xe6, 0x16, 0xca, 0xea, 0x5f, 0x29, 0xaf, 0xa6, 0x98, 0x59, 0xd2, 0xda, 0x42, 0xe7, 0xc5, - 0xa2, 0x2e, 0x2c, 0xdc, 0x10, 0xc7, 0x61, 0xfd, 0x52, 0x53, 0x69, 0x9f, 0xd9, 0x37, 0x8a, 0xd7, - 0xce, 0xe2, 0x39, 0x8e, 0x43, 0xb5, 0x83, 0x6e, 0x25, 0xbb, 0x35, 0xf7, 0xe4, 0x65, 0x49, 0x9e, - 0xef, 0x3f, 0xe4, 0xac, 0xbe, 0xae, 0x16, 0xb5, 0xe7, 0xc5, 0x50, 0xff, 0x7f, 0x2f, 0x92, 0x1d, - 0x22, 0xf4, 0x61, 0x2e, 0xa6, 0x6e, 0x0c, 0x18, 0x68, 0xfd, 0xa4, 0xa9, 0xb4, 0x6f, 0xf6, 0x3a, - 0x7f, 0xf2, 0xcb, 0xbd, 0x01, 0x0c, 0x49, 0x6c, 0x9f, 0x65, 0xe9, 0xec, 0x4c, 0xad, 0x97, 0x5f, - 0x36, 0x9a, 0xb2, 0xda, 0x68, 0xca, 0x7a, 0xa3, 0x29, 0x9f, 0xb6, 0x5a, 0x65, 0xb5, 0xd5, 0x2a, - 0x5f, 0xb7, 0x5a, 0xe5, 0xdd, 0x6f, 0xd7, 0x5e, 0x94, 0xaf, 0xb8, 0xec, 0x80, 0x9c, 0xca, 0xbb, - 0xdd, 0xff, 0x11, 0x00, 0x00, 0xff, 0xff, 0x66, 0x62, 0xb6, 0xdc, 0x56, 0x04, 0x00, 0x00, + // 447 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x93, 0xc1, 0x6a, 0xd4, 0x40, + 0x18, 0xc7, 0x37, 0x5b, 0x5b, 0xe9, 0x58, 0x5d, 0x0c, 0x2d, 0x84, 0x15, 0x62, 0x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0x3c, 0xd3, 0xe0, 0xf8, 0xf3, 0xc2, + 0x36, 0x4e, 0x17, 0xb6, 0xf1, 0x7d, 0x61, 0x1b, 0x1f, 0x97, 0x76, 0xeb, 0x74, 0x69, 0xb7, 0xbe, + 0x2c, 0xed, 0xd6, 0x9b, 0xdf, 0xae, 0x3e, 0x6b, 0x5e, 0x7a, 0xdd, 0x03, 0xd9, 0xd0, 0xb7, 0xfd, + 0xe0, 0x67, 0x00, 0x00, 0x00, 0xff, 0xff, 0xc9, 0xc7, 0xd4, 0x63, 0x68, 0x04, 0x00, 0x00, } func (m *EventNewBTCValidator) Marshal() (dAtA []byte, err error) { @@ -481,17 +484,19 @@ func (m *EventUnbondingBTCDelegation) MarshalToSizedBuffer(dAtA []byte) (int, er i-- dAtA[i] = 0x1a } - if m.ValBtcPk != nil { - { - size := m.ValBtcPk.Size() - i -= size - if _, err := m.ValBtcPk.MarshalTo(dAtA[i:]); err != nil { - return 0, err + if len(m.ValBtcPkList) > 0 { + for iNdEx := len(m.ValBtcPkList) - 1; iNdEx >= 0; iNdEx-- { + { + size := m.ValBtcPkList[iNdEx].Size() + i -= size + if _, err := m.ValBtcPkList[iNdEx].MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintEvents(dAtA, i, uint64(size)) } - i = encodeVarintEvents(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x12 } - i-- - dAtA[i] = 0x12 } if m.BtcPk != nil { { @@ -547,17 +552,19 @@ func (m *EventUnbondedBTCDelegation) MarshalToSizedBuffer(dAtA []byte) (int, err i-- dAtA[i] = 0x1a } - if m.ValBtcPk != nil { - { - size := m.ValBtcPk.Size() - i -= size - if _, err := m.ValBtcPk.MarshalTo(dAtA[i:]); err != nil { - return 0, err + if len(m.ValBtcPkList) > 0 { + for iNdEx := len(m.ValBtcPkList) - 1; iNdEx >= 0; iNdEx-- { + { + size := m.ValBtcPkList[iNdEx].Size() + i -= size + if _, err := m.ValBtcPkList[iNdEx].MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintEvents(dAtA, i, uint64(size)) } - i = encodeVarintEvents(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x12 } - i-- - dAtA[i] = 0x12 } if m.BtcPk != nil { { @@ -634,9 +641,11 @@ func (m *EventUnbondingBTCDelegation) Size() (n int) { l = m.BtcPk.Size() n += 1 + l + sovEvents(uint64(l)) } - if m.ValBtcPk != nil { - l = m.ValBtcPk.Size() - n += 1 + l + sovEvents(uint64(l)) + if len(m.ValBtcPkList) > 0 { + for _, e := range m.ValBtcPkList { + l = e.Size() + n += 1 + l + sovEvents(uint64(l)) + } } l = len(m.StakingTxHash) if l > 0 { @@ -659,9 +668,11 @@ func (m *EventUnbondedBTCDelegation) Size() (n int) { l = m.BtcPk.Size() n += 1 + l + sovEvents(uint64(l)) } - if m.ValBtcPk != nil { - l = m.ValBtcPk.Size() - n += 1 + l + sovEvents(uint64(l)) + if len(m.ValBtcPkList) > 0 { + for _, e := range m.ValBtcPkList { + l = e.Size() + n += 1 + l + sovEvents(uint64(l)) + } } l = len(m.StakingTxHash) if l > 0 { @@ -1007,7 +1018,7 @@ func (m *EventUnbondingBTCDelegation) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ValBtcPk", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ValBtcPkList", wireType) } var byteLen int for shift := uint(0); ; shift += 7 { @@ -1035,8 +1046,8 @@ func (m *EventUnbondingBTCDelegation) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } var v github_com_babylonchain_babylon_types.BIP340PubKey - m.ValBtcPk = &v - if err := m.ValBtcPk.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.ValBtcPkList = append(m.ValBtcPkList, v) + if err := m.ValBtcPkList[len(m.ValBtcPkList)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -1191,7 +1202,7 @@ func (m *EventUnbondedBTCDelegation) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ValBtcPk", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ValBtcPkList", wireType) } var byteLen int for shift := uint(0); ; shift += 7 { @@ -1219,8 +1230,8 @@ func (m *EventUnbondedBTCDelegation) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } var v github_com_babylonchain_babylon_types.BIP340PubKey - m.ValBtcPk = &v - if err := m.ValBtcPk.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.ValBtcPkList = append(m.ValBtcPkList, v) + if err := m.ValBtcPkList[len(m.ValBtcPkList)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex diff --git a/x/btcstaking/types/genesis_test.go b/x/btcstaking/types/genesis_test.go index da62eedb7..f3cfae1f4 100644 --- a/x/btcstaking/types/genesis_test.go +++ b/x/btcstaking/types/genesis_test.go @@ -24,7 +24,8 @@ func TestGenesisState_Validate(t *testing.T) { desc: "valid genesis state", genState: &types.GenesisState{ Params: types.Params{ - CovenantPk: types.DefaultParams().CovenantPk, + CovenantPks: types.DefaultParams().CovenantPks, + CovenantQuorum: types.DefaultParams().CovenantQuorum, SlashingAddress: types.DefaultParams().SlashingAddress, MinSlashingTxFeeSat: 500, MinCommissionRate: sdkmath.LegacyMustNewDecFromStr("0.5"), @@ -38,7 +39,8 @@ func TestGenesisState_Validate(t *testing.T) { desc: "invalid slashing rate in genesis", genState: &types.GenesisState{ Params: types.Params{ - CovenantPk: types.DefaultParams().CovenantPk, + CovenantPks: types.DefaultParams().CovenantPks, + CovenantQuorum: types.DefaultParams().CovenantQuorum, SlashingAddress: types.DefaultParams().SlashingAddress, MinSlashingTxFeeSat: 500, MinCommissionRate: sdkmath.LegacyMustNewDecFromStr("0.5"), diff --git a/x/btcstaking/types/params.go b/x/btcstaking/types/params.go index a78931fb1..8acb8e744 100644 --- a/x/btcstaking/types/params.go +++ b/x/btcstaking/types/params.go @@ -20,11 +20,12 @@ const ( var _ paramtypes.ParamSet = (*Params)(nil) -func defaultCovenantPk() *bbn.BIP340PubKey { +// TODO: default values for multisig covenant +func defaultCovenantPks() []bbn.BIP340PubKey { // 32 bytes skBytes := []byte{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1} _, defaultPK := btcec.PrivKeyFromBytes(skBytes) - return bbn.NewBIP340PubKeyFromBTCPK(defaultPK) + return []bbn.BIP340PubKey{*bbn.NewBIP340PubKeyFromBTCPK(defaultPK)} } func defaultSlashingAddress() string { @@ -45,7 +46,8 @@ func ParamKeyTable() paramtypes.KeyTable { // DefaultParams returns a default set of parameters func DefaultParams() Params { return Params{ - CovenantPk: defaultCovenantPk(), + CovenantPks: defaultCovenantPks(), // TODO: default values for multisig covenant + CovenantQuorum: 1, // TODO: default values for multisig covenant SlashingAddress: defaultSlashingAddress(), MinSlashingTxFeeSat: 1000, MinCommissionRate: math.LegacyZeroDec(), @@ -93,6 +95,14 @@ func validateMaxActiveBTCValidators(maxActiveBtcValidators uint32) error { // Validate validates the set of params func (p Params) Validate() error { + if p.CovenantQuorum == 0 { + return fmt.Errorf("covenant quorum size has to be positive") + } + if p.CovenantQuorum*3 <= uint32(len(p.CovenantPks))*2 { + // NOTE: we assume covenant member can be adversarial, including + // equivocation, so >2/3 quorum is needed + return fmt.Errorf("covenant quorum size has to be more than 2/3 of the covenant committee size") + } if err := validateMinSlashingTxFeeSat(p.MinSlashingTxFeeSat); err != nil { return err } diff --git a/x/btcstaking/types/params.pb.go b/x/btcstaking/types/params.pb.go index 3b7c0ca17..af5a903b5 100644 --- a/x/btcstaking/types/params.pb.go +++ b/x/btcstaking/types/params.pb.go @@ -28,23 +28,26 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Params defines the parameters for the module. type Params struct { - // covenant_pk is the public key of covenant - // the PK follows encoding in BIP-340 spec on Bitcoin - CovenantPk *github_com_babylonchain_babylon_types.BIP340PubKey `protobuf:"bytes,1,opt,name=covenant_pk,json=covenantPk,proto3,customtype=github.com/babylonchain/babylon/types.BIP340PubKey" json:"covenant_pk,omitempty"` + // covenant_pks is the list of public keys held by the covenant committee + // each PK follows encoding in BIP-340 spec on Bitcoin + CovenantPks []github_com_babylonchain_babylon_types.BIP340PubKey `protobuf:"bytes,1,rep,name=covenant_pks,json=covenantPks,proto3,customtype=github.com/babylonchain/babylon/types.BIP340PubKey" json:"covenant_pks,omitempty"` + // covenant_quorum is the minimum number of signatures needed for the covenant + // multisignature + CovenantQuorum uint32 `protobuf:"varint,2,opt,name=covenant_quorum,json=covenantQuorum,proto3" json:"covenant_quorum,omitempty"` // slashing address is the address that the slashed BTC goes to // the address is in string on Bitcoin - SlashingAddress string `protobuf:"bytes,2,opt,name=slashing_address,json=slashingAddress,proto3" json:"slashing_address,omitempty"` + SlashingAddress string `protobuf:"bytes,3,opt,name=slashing_address,json=slashingAddress,proto3" json:"slashing_address,omitempty"` // min_slashing_tx_fee_sat is the minimum amount of tx fee (quantified // in Satoshi) needed for the pre-signed slashing tx // TODO: change to satoshi per byte? - MinSlashingTxFeeSat int64 `protobuf:"varint,3,opt,name=min_slashing_tx_fee_sat,json=minSlashingTxFeeSat,proto3" json:"min_slashing_tx_fee_sat,omitempty"` + MinSlashingTxFeeSat int64 `protobuf:"varint,4,opt,name=min_slashing_tx_fee_sat,json=minSlashingTxFeeSat,proto3" json:"min_slashing_tx_fee_sat,omitempty"` // min_commission_rate is the chain-wide minimum commission rate that a validator can charge their delegators - MinCommissionRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,4,opt,name=min_commission_rate,json=minCommissionRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"min_commission_rate"` + MinCommissionRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,5,opt,name=min_commission_rate,json=minCommissionRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"min_commission_rate"` // slashing_rate determines the portion of the staked amount to be slashed, // expressed as a decimal (e.g., 0.5 for 50%). - SlashingRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,5,opt,name=slashing_rate,json=slashingRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"slashing_rate"` + SlashingRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,6,opt,name=slashing_rate,json=slashingRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"slashing_rate"` // max_active_btc_validators is the maximum number of active BTC validators in the BTC staking protocol - MaxActiveBtcValidators uint32 `protobuf:"varint,6,opt,name=max_active_btc_validators,json=maxActiveBtcValidators,proto3" json:"max_active_btc_validators,omitempty"` + MaxActiveBtcValidators uint32 `protobuf:"varint,7,opt,name=max_active_btc_validators,json=maxActiveBtcValidators,proto3" json:"max_active_btc_validators,omitempty"` } func (m *Params) Reset() { *m = Params{} } @@ -79,6 +82,13 @@ func (m *Params) XXX_DiscardUnknown() { var xxx_messageInfo_Params proto.InternalMessageInfo +func (m *Params) GetCovenantQuorum() uint32 { + if m != nil { + return m.CovenantQuorum + } + return 0 +} + func (m *Params) GetSlashingAddress() string { if m != nil { return m.SlashingAddress @@ -109,34 +119,36 @@ func init() { } var fileDescriptor_8d1392776a3e15b9 = []byte{ - // 432 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x92, 0x4f, 0x6f, 0xd3, 0x30, - 0x18, 0xc6, 0x63, 0x3a, 0x2a, 0x61, 0x36, 0x01, 0xe1, 0x5f, 0xb6, 0x43, 0x5a, 0xed, 0x80, 0xca, - 0x61, 0x09, 0x63, 0x13, 0x12, 0x88, 0xcb, 0x02, 0x42, 0x42, 0x70, 0xa8, 0x32, 0x04, 0x12, 0x07, - 0xac, 0x37, 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e, 0xdd, - 0x8e, 0xa3, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x85, 0x4c, 0x22, 0xe4, 0x8b, 0x02, 0x00, 0x00, + // 453 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x92, 0xcb, 0x6e, 0xd3, 0x40, + 0x18, 0x85, 0x6d, 0x52, 0x82, 0x18, 0x52, 0x0a, 0xe6, 0xe6, 0x76, 0xe1, 0x44, 0x5d, 0x40, 0x58, + 0xd4, 0xa6, 0xb4, 0x42, 0x02, 0xb1, 0xa9, 0x41, 0x48, 0x08, 0x16, 0xc1, 0x45, 0x48, 0xb0, 0x60, + 0xf4, 0x7b, 0x32, 0x38, 0xa3, 0x64, 0x66, 0x82, 0x67, 0x6c, 0x39, 0x6f, 0xc1, 0x92, 0x25, 0x0f, + 0xc1, 0x43, 0x74, 0x59, 0xb1, 0x42, 0x5d, 0x44, 0x28, 0x79, 0x02, 0xde, 0x00, 0x79, 0x7c, 0xa1, + 0x3b, 0xc4, 0xca, 0x9e, 0x73, 0x8e, 0xbe, 0x33, 0x97, 0x1f, 0xed, 0xc6, 0x10, 0x2f, 0x66, 0x52, + 0x04, 0xb1, 0x26, 0x4a, 0xc3, 0x94, 0x89, 0x24, 0xc8, 0xf7, 0x83, 0x39, 0xa4, 0xc0, 0x95, 0x3f, + 0x4f, 0xa5, 0x96, 0xce, 0xad, 0x3a, 0xe3, 0xff, 0xcd, 0xf8, 0xf9, 0xfe, 0xce, 0xcd, 0x44, 0x26, + 0xd2, 0x24, 0x82, 0xf2, 0xaf, 0x0a, 0xef, 0x6c, 0x13, 0xa9, 0xb8, 0x54, 0xb8, 0x32, 0xaa, 0x45, + 0x65, 0xed, 0xfe, 0xee, 0xa0, 0xee, 0xc8, 0x80, 0x9d, 0xf7, 0xa8, 0x47, 0x64, 0x4e, 0x05, 0x08, + 0x8d, 0xe7, 0x53, 0xe5, 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4, 0xa7, 0xff, 0x47, 0xfe, + 0xf1, 0x7d, 0x0f, 0xd5, 0xcf, 0x54, 0xf6, 0xf4, 0x1a, 0xa4, 0xa9, 0x78, 0x8c, 0xb6, 0x39, 0x14, + 0x18, 0x88, 0x66, 0x39, 0xc5, 0xb1, 0x26, 0x38, 0x87, 0x19, 0x1b, 0x83, 0x96, 0xa9, 0x72, 0x2f, + 0x99, 0x6b, 0xbd, 0xcd, 0xa1, 0x38, 0x32, 0x7e, 0xa8, 0xc9, 0xbb, 0xd6, 0x7d, 0xb2, 0xf1, 0xf5, + 0x5b, 0xdf, 0x0a, 0x5f, 0x9f, 0xac, 0x3c, 0xfb, 0x74, 0xe5, 0xd9, 0xbf, 0x56, 0x9e, 0xfd, 0x65, + 0xed, 0x59, 0xa7, 0x6b, 0xcf, 0xfa, 0xb9, 0xf6, 0xac, 0x0f, 0xff, 0x7c, 0xe8, 0xe2, 0xfc, 0x4c, + 0x9a, 0xed, 0xc6, 0x5d, 0x33, 0x48, 0x07, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0x89, 0x23, 0x96, + 0x04, 0xb6, 0x02, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -162,7 +174,7 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { if m.MaxActiveBtcValidators != 0 { i = encodeVarintParams(dAtA, i, uint64(m.MaxActiveBtcValidators)) i-- - dAtA[i] = 0x30 + dAtA[i] = 0x38 } { size := m.SlashingRate.Size() @@ -173,7 +185,7 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintParams(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x2a + dAtA[i] = 0x32 { size := m.MinCommissionRate.Size() i -= size @@ -183,30 +195,37 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintParams(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x22 + dAtA[i] = 0x2a if m.MinSlashingTxFeeSat != 0 { i = encodeVarintParams(dAtA, i, uint64(m.MinSlashingTxFeeSat)) i-- - dAtA[i] = 0x18 + dAtA[i] = 0x20 } if len(m.SlashingAddress) > 0 { i -= len(m.SlashingAddress) copy(dAtA[i:], m.SlashingAddress) i = encodeVarintParams(dAtA, i, uint64(len(m.SlashingAddress))) i-- - dAtA[i] = 0x12 + dAtA[i] = 0x1a } - if m.CovenantPk != nil { - { - size := m.CovenantPk.Size() - i -= size - if _, err := m.CovenantPk.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintParams(dAtA, i, uint64(size)) - } + if m.CovenantQuorum != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.CovenantQuorum)) i-- - dAtA[i] = 0xa + dAtA[i] = 0x10 + } + if len(m.CovenantPks) > 0 { + for iNdEx := len(m.CovenantPks) - 1; iNdEx >= 0; iNdEx-- { + { + size := m.CovenantPks[iNdEx].Size() + i -= size + if _, err := m.CovenantPks[iNdEx].MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } } return len(dAtA) - i, nil } @@ -228,9 +247,14 @@ func (m *Params) Size() (n int) { } var l int _ = l - if m.CovenantPk != nil { - l = m.CovenantPk.Size() - n += 1 + l + sovParams(uint64(l)) + if len(m.CovenantPks) > 0 { + for _, e := range m.CovenantPks { + l = e.Size() + n += 1 + l + sovParams(uint64(l)) + } + } + if m.CovenantQuorum != 0 { + n += 1 + sovParams(uint64(m.CovenantQuorum)) } l = len(m.SlashingAddress) if l > 0 { @@ -286,7 +310,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CovenantPk", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field CovenantPks", wireType) } var byteLen int for shift := uint(0); ; shift += 7 { @@ -314,12 +338,31 @@ func (m *Params) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } var v github_com_babylonchain_babylon_types.BIP340PubKey - m.CovenantPk = &v - if err := m.CovenantPk.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.CovenantPks = append(m.CovenantPks, v) + if err := m.CovenantPks[len(m.CovenantPks)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CovenantQuorum", wireType) + } + m.CovenantQuorum = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CovenantQuorum |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field SlashingAddress", wireType) } @@ -351,7 +394,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { } m.SlashingAddress = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 3: + case 4: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field MinSlashingTxFeeSat", wireType) } @@ -370,7 +413,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { break } } - case 4: + case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field MinCommissionRate", wireType) } @@ -404,7 +447,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 5: + case 6: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field SlashingRate", wireType) } @@ -438,7 +481,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 6: + case 7: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field MaxActiveBtcValidators", wireType) } diff --git a/x/btcstaking/types/query.pb.go b/x/btcstaking/types/query.pb.go index c73571379..a7a48e70f 100644 --- a/x/btcstaking/types/query.pb.go +++ b/x/btcstaking/types/query.pb.go @@ -998,10 +998,9 @@ type QueryBTCDelegationResponse struct { // btc_pk is the Bitcoin secp256k1 PK of this BTC delegation // the PK follows encoding in BIP-340 spec BtcPk *github_com_babylonchain_babylon_types.BIP340PubKey `protobuf:"bytes,1,opt,name=btc_pk,json=btcPk,proto3,customtype=github.com/babylonchain/babylon/types.BIP340PubKey" json:"btc_pk,omitempty"` - // val_btc_pk is the Bitcoin secp256k1 PK of the BTC validator that + // val_btc_pk_list is the list of BIP-340 PKs of the BTC validators that // this BTC delegation delegates to - // the PK follows encoding in BIP-340 spec - ValBtcPk *github_com_babylonchain_babylon_types.BIP340PubKey `protobuf:"bytes,2,opt,name=val_btc_pk,json=valBtcPk,proto3,customtype=github.com/babylonchain/babylon/types.BIP340PubKey" json:"val_btc_pk,omitempty"` + ValBtcPkList []github_com_babylonchain_babylon_types.BIP340PubKey `protobuf:"bytes,2,rep,name=val_btc_pk_list,json=valBtcPkList,proto3,customtype=github.com/babylonchain/babylon/types.BIP340PubKey" json:"val_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,3,opt,name=start_height,json=startHeight,proto3" json:"start_height,omitempty"` @@ -1130,86 +1129,86 @@ func init() { func init() { proto.RegisterFile("babylon/btcstaking/v1/query.proto", fileDescriptor_74d49d26f7429697) } var fileDescriptor_74d49d26f7429697 = []byte{ - // 1255 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x58, 0x4f, 0x6f, 0x1b, 0xc5, - 0x1b, 0xce, 0xa4, 0xa9, 0x7f, 0xc9, 0x9b, 0x7f, 0xfd, 0x4d, 0x0b, 0x75, 0x36, 0x8d, 0x93, 0x6e, - 0x9a, 0x3f, 0x0d, 0xea, 0x6e, 0xec, 0xa0, 0x1c, 0x48, 0x68, 0xa9, 0x1b, 0x68, 0x9a, 0x10, 0xc9, - 0x6c, 0x02, 0x95, 0xb8, 0x58, 0xb3, 0xce, 0x74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0, 0x31, 0x82, 0xeb, 0x4d, 0xc6, - 0x1d, 0xfc, 0x46, 0x5c, 0x35, 0x23, 0x5a, 0xc1, 0x4a, 0x57, 0xb1, 0x82, 0xc5, 0x06, 0x67, 0xb1, - 0x86, 0xb3, 0x5d, 0x5e, 0x44, 0xb0, 0x5f, 0xfc, 0xe8, 0xbd, 0x1e, 0x7e, 0x99, 0xb6, 0xaf, 0x47, - 0xc3, 0x74, 0x24, 0xa5, 0x3b, 0x88, 0xe8, 0xc0, 0x4b, 0x01, 0x98, 0xea, 0xb3, 0x88, 0xf1, 0xeb, - 0x28, 0xfb, 0xee, 0xf3, 0x93, 0x14, 0x7a, 0x71, 0x92, 0x42, 0x7f, 0x9e, 0xa4, 0xd0, 0x17, 0xa7, - 0xa9, 0x9e, 0x17, 0xa7, 0xa9, 0x9e, 0xdf, 0x4f, 0x53, 0x3d, 0x1f, 0xb6, 0x9d, 0x7d, 0x0e, 0x82, - 0x05, 0xf9, 0x20, 0xa4, 0x27, 0xf8, 0xbf, 0x86, 0x96, 0xfe, 0x09, 0x00, 0x00, 0xff, 0xff, 0x4c, - 0x47, 0x4f, 0x01, 0x02, 0x13, 0x00, 0x00, + // 1262 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x58, 0xcf, 0x6f, 0x1b, 0x45, + 0x14, 0xce, 0x24, 0xa9, 0x69, 0x5e, 0x7e, 0x95, 0x69, 0xa1, 0xee, 0xa6, 0x71, 0xd2, 0x4d, 0xf3, + 0xa3, 0x41, 0xdd, 0x8d, 0x1d, 0x94, 0x03, 0x09, 0x2d, 0x75, 0x03, 0x4d, 0x93, 0x46, 0x32, 0x9b, + 0x42, 0x25, 0x24, 0x64, 0xcd, 0x3a, 0xd3, 0xf5, 0x12, 0x67, 0xd7, 0xf5, 0x8e, 0x4d, 0xa2, 0x2a, + 0x17, 0x0e, 0x48, 0x88, 0x0b, 0x82, 0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xcd, 0x2b, 0xf8, 0xd1, 0x5b, 0x3c, 0x42, 0x13, 0x91, 0xa7, 0x64, 0xd0, 0xdb, + 0xb5, 0x0c, 0x7e, 0x41, 0x30, 0x16, 0x09, 0x55, 0x34, 0x65, 0x13, 0x46, 0xdd, 0xa6, 0x6c, 0xfb, + 0x5b, 0x42, 0x08, 0xd7, 0xe3, 0x80, 0xd6, 0x5c, 0x11, 0x05, 0xd2, 0x9e, 0x9d, 0x14, 0xb6, 0x61, + 0xba, 0xe1, 0x26, 0x73, 0xf6, 0xe7, 0xb4, 0x72, 0x87, 0xad, 0x51, 0xd3, 0x28, 0xb2, 0x4e, 0x74, + 0x81, 0xdf, 0x84, 0x44, 0x91, 0x47, 0x71, 0x48, 0xfd, 0x9a, 0xf8, 0x25, 0x6f, 0xc0, 0x4c, 0xbb, + 0x2a, 0xa2, 0x4f, 0xd7, 0x60, 0xa8, 0x66, 0x33, 0xd3, 0x32, 0xf2, 0x65, 0x77, 0x9f, 0x17, 0xe9, + 0xd7, 0x06, 0xbd, 0x35, 0x1e, 0x22, 0x6f, 0xc0, 0xf5, 0x86, 0x64, 0x77, 0xab, 0x95, 0x0a, 0xb5, + 0x18, 0x3f, 0xd0, 0x91, 0x92, 0xf5, 0x08, 0xfe, 0xe1, 0x64, 0x02, 0x98, 0x4f, 0x0d, 0x05, 0xa9, + 0x35, 0x00, 0xee, 0x6d, 0x04, 0xfc, 0x15, 0x82, 0x59, 0x5e, 0xe4, 0x4e, 0x81, 0x99, 0x35, 0x1a, + 0x32, 0x8a, 0xd3, 0x6d, 0x6e, 0x56, 0xe6, 0xac, 0x74, 0xfa, 0x3b, 0x82, 0xb9, 0xf6, 0x58, 0x04, + 0x67, 0xad, 0x89, 0x79, 0xbd, 0x15, 0xe3, 0x53, 0x7e, 0x64, 0xb2, 0xe2, 0x26, 0x65, 0xe4, 0x7f, + 0x33, 0xb1, 0x71, 0xf1, 0xc1, 0x71, 0x22, 0x84, 0xd1, 0xed, 0x50, 0x23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0xe5, + 0xae, 0x62, 0x05, 0x8b, 0x75, 0xce, 0x62, 0x15, 0x67, 0xbb, 0xbc, 0x88, 0xa0, 0x5f, 0xfc, 0xea, + 0xbd, 0x1e, 0x7e, 0x99, 0xb6, 0xaf, 0x47, 0xc3, 0x98, 0x24, 0xa5, 0x3b, 0x88, 0xe8, 0x40, 0x4b, + 0x01, 0x98, 0xea, 0xd3, 0x88, 0x39, 0xec, 0x20, 0xfb, 0xe0, 0xd9, 0x51, 0x0a, 0x3d, 0x3f, 0x4a, + 0xa1, 0x97, 0x47, 0x29, 0xf4, 0xcd, 0x71, 0xaa, 0xe7, 0xf9, 0x71, 0xaa, 0xe7, 0xaf, 0xe3, 0x54, + 0xcf, 0x27, 0x6d, 0xe7, 0x9f, 0xbd, 0x60, 0x41, 0x3e, 0x0c, 0xe9, 0x09, 0xfe, 0x3f, 0xa2, 0xc5, + 0xff, 0x02, 0x00, 0x00, 0xff, 0xff, 0x69, 0xcd, 0x35, 0xac, 0x0b, 0x13, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -2390,17 +2389,19 @@ func (m *QueryBTCDelegationResponse) MarshalToSizedBuffer(dAtA []byte) (int, err i-- dAtA[i] = 0x18 } - if m.ValBtcPk != nil { - { - size := m.ValBtcPk.Size() - i -= size - if _, err := m.ValBtcPk.MarshalTo(dAtA[i:]); err != nil { - return 0, err + if len(m.ValBtcPkList) > 0 { + for iNdEx := len(m.ValBtcPkList) - 1; iNdEx >= 0; iNdEx-- { + { + size := m.ValBtcPkList[iNdEx].Size() + i -= size + if _, err := m.ValBtcPkList[iNdEx].MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) } - i = encodeVarintQuery(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x12 } - i-- - dAtA[i] = 0x12 } if m.BtcPk != nil { { @@ -2712,9 +2713,11 @@ func (m *QueryBTCDelegationResponse) Size() (n int) { l = m.BtcPk.Size() n += 1 + l + sovQuery(uint64(l)) } - if m.ValBtcPk != nil { - l = m.ValBtcPk.Size() - n += 1 + l + sovQuery(uint64(l)) + if len(m.ValBtcPkList) > 0 { + for _, e := range m.ValBtcPkList { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } } if m.StartHeight != 0 { n += 1 + sovQuery(uint64(m.StartHeight)) @@ -4551,7 +4554,7 @@ func (m *QueryBTCDelegationResponse) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ValBtcPk", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ValBtcPkList", wireType) } var byteLen int for shift := uint(0); ; shift += 7 { @@ -4579,8 +4582,8 @@ func (m *QueryBTCDelegationResponse) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } var v github_com_babylonchain_babylon_types.BIP340PubKey - m.ValBtcPk = &v - if err := m.ValBtcPk.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.ValBtcPkList = append(m.ValBtcPkList, v) + if err := m.ValBtcPkList[len(m.ValBtcPkList)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex