Skip to content

Commit

Permalink
fix proto
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianElvis committed Nov 27, 2024
1 parent 8180c5c commit 1d65bd7
Show file tree
Hide file tree
Showing 6 changed files with 204 additions and 190 deletions.
46 changes: 23 additions & 23 deletions proto/babylon/btcstaking/v1/packet.proto
Original file line number Diff line number Diff line change
Expand Up @@ -99,29 +99,29 @@ message ActiveBTCDelegation {

// BTCUndelegationInfo provides all necessary info about the undeleagation
message BTCUndelegationInfo {
// unbonding_tx is the transaction which will transfer the funds from staking
// output to unbonding output. Unbonding output will usually have lower timelock
// than staking output.
bytes unbonding_tx = 1;
// delegator_unbonding_sig is the signature on the unbonding tx
// by the delegator (i.e., SK corresponding to btc_pk).
// It effectively proves that the delegator wants to unbond and thus
// Babylon will consider this BTC delegation unbonded. Delegator's BTC
// on Bitcoin will be unbonded after timelock.
bytes delegator_unbonding_sig = 2;
// covenant_unbonding_sig_list is the list of signatures on the unbonding tx
// by covenant members
repeated SignatureInfo covenant_unbonding_sig_list = 3;
// slashing_tx is the unbonding slashing tx
bytes slashing_tx = 4;
// delegator_slashing_sig is the signature on the slashing tx
// by the delegator (i.e., SK corresponding to btc_pk).
// It will be a part of the witness for the unbonding tx output.
bytes delegator_slashing_sig = 5;
// covenant_slashing_sigs is a list of adaptor signatures on the
// unbonding slashing tx by each covenant member
// It will be a part of the witness for the staking tx output.
repeated CovenantAdaptorSignatures covenant_slashing_sigs = 6;
// unbonding_tx is the transaction which will transfer the funds from staking
// output to unbonding output. Unbonding output will usually have lower timelock
// than staking output.
bytes unbonding_tx = 1;
// slashing_tx is the slashing tx for unbonding transactions
// It is partially signed by SK corresponding to btc_pk, but not signed by
// finality provider or covenant yet.
bytes slashing_tx = 2;
// delegator_slashing_sig is the signature on the slashing tx
// by the delegator (i.e., SK corresponding to btc_pk).
// It will be a part of the witness for the unbonding tx output.
bytes delegator_slashing_sig = 3;
// covenant_slashing_sigs is a list of adaptor signatures on the slashing tx
// by each covenant member
// It will be a part of the witness for the staking tx output.
repeated CovenantAdaptorSignatures covenant_slashing_sigs = 4;
// covenant_unbonding_sig_list is the list of signatures on the unbonding tx
// by covenant members
// It must be provided after processing undelegate message by Babylon
repeated SignatureInfo covenant_unbonding_sig_list = 5;
// delegator_unbonding_info is the information about transaction which spent
// the staking output
DelegatorUnbondingInfo delegator_unbonding_info = 6;
}

// SlashedBTCDelegation is an IBC packet sent from Babylon to consumer
Expand Down
16 changes: 10 additions & 6 deletions test/e2e/bcd_consumer_integration/clientcontroller/cosmwasm/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,16 @@ type SignatureInfo struct {
}

type BtcUndelegationInfo struct {
UnbondingTx []byte `json:"unbonding_tx"`
DelegatorUnbondingSig []byte `json:"delegator_unbonding_sig"`
CovenantUnbondingSigs []SignatureInfo `json:"covenant_unbonding_sig_list"`
SlashingTx []byte `json:"slashing_tx"`
DelegatorSlashingSig []byte `json:"delegator_slashing_sig"`
CovenantSlashingSigs []CovenantAdaptorSignatures `json:"covenant_slashing_sigs"`
UnbondingTx []byte `json:"unbonding_tx"`
SlashingTx []byte `json:"slashing_tx"`
DelegatorSlashingSig []byte `json:"delegator_slashing_sig"`
CovenantSlashingSigs []*CovenantAdaptorSignatures `json:"covenant_slashing_sigs"`
CovenantUnbondingSigList []*SignatureInfo `json:"covenant_unbonding_sig_list"`
DelegatorUnbondingInfo *DelegatorUnbondingInfo `json:"delegator_unbonding_info"`
}

type DelegatorUnbondingInfo struct {
SpendStakeTx []byte `json:"spend_stake_tx"`
}

type ActiveBtcDelegation struct {
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/bcd_consumer_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ func (s *BCDConsumerIntegrationTestSuite) Test5ActivateDelegation() {
}, time.Second*30, time.Second)

// Assert delegation details
s.Empty(dataFromContract.Delegations[0].UndelegationInfo.DelegatorUnbondingSig)
s.Empty(dataFromContract.Delegations[0].UndelegationInfo)
s.Equal(activeDel.BtcPk.MarshalHex(), dataFromContract.Delegations[0].BtcPkHex)
s.Len(dataFromContract.Delegations[0].FpBtcPkList, 2)
s.Equal(activeDel.FpBtcPkList[0].MarshalHex(), dataFromContract.Delegations[0].FpBtcPkList[0])
Expand Down
5 changes: 3 additions & 2 deletions x/btcstaking/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ func (k Keeper) FinalityProvider(c context.Context, req *types.QueryFinalityProv
}

ctx := sdk.UnwrapSDKContext(c)
currBlockHeight := uint64(ctx.BlockHeight())

fp, err := k.GetFinalityProvider(ctx, key)
if err != nil {
// Try in the btcstkconsumer module
Expand All @@ -80,13 +82,12 @@ func (k Keeper) FinalityProvider(c context.Context, req *types.QueryFinalityProv
return nil, err
}
// FPs for consumers are not stored in the voting power table
fpResp := types.NewFinalityProviderResponse(fp, 0)
fpResp := types.NewFinalityProviderResponse(fp, currBlockHeight)
return &types.QueryFinalityProviderResponse{FinalityProvider: fpResp}, nil
}
return nil, err
}

currBlockHeight := uint64(ctx.BlockHeight())
fpResp := types.NewFinalityProviderResponse(fp, currBlockHeight)
return &types.QueryFinalityProviderResponse{FinalityProvider: fpResp}, nil
}
Expand Down
1 change: 1 addition & 0 deletions x/btcstaking/types/btc_staking_consumer_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ func CreateActiveBTCDelegationEvent(activeDel *BTCDelegation) (*BTCStakingConsum
DelegatorSlashingSig: delegatorUnbondingSlashingSigBytes,
CovenantUnbondingSigList: activeDel.BtcUndelegation.CovenantUnbondingSigList,
CovenantSlashingSigs: activeDel.BtcUndelegation.CovenantSlashingSigs,
DelegatorUnbondingInfo: activeDel.BtcUndelegation.DelegatorUnbondingInfo,
},
ParamsVersion: activeDel.ParamsVersion,
},
Expand Down
Loading

0 comments on commit 1d65bd7

Please sign in to comment.