Skip to content

Commit

Permalink
chore: rollback to use covenant sigs as pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
RafilxTenfen committed Oct 10, 2024
1 parent edeaf99 commit 562052f
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion clientcontroller/babylon.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func (bc *BabylonController) reliablySendMsgs(msgs []sdk.Msg) (*provider.Relayer

// SubmitCovenantSigs submits the Covenant signature via a MsgAddCovenantSig to Babylon if the daemon runs in Covenant mode
// it returns tx hash and error
func (bc *BabylonController) SubmitCovenantSigs(covSigs []types.CovenantSigs) (*types.TxResponse, error) {
func (bc *BabylonController) SubmitCovenantSigs(covSigs []*types.CovenantSigs) (*types.TxResponse, error) {
msgs := make([]sdk.Msg, 0, len(covSigs))
for _, covSig := range covSigs {
bip340UnbondingSig := bbntypes.NewBIP340SignatureFromBTCSig(covSig.UnbondingSig)
Expand Down
2 changes: 1 addition & 1 deletion clientcontroller/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type ClientController interface {
// SubmitCovenantSigs submits Covenant signatures to the consumer chain, each corresponding to
// a finality provider that the delegation is (re-)staked to
// it returns tx hash and error
SubmitCovenantSigs(covSigMsgs []types.CovenantSigs) (*types.TxResponse, error)
SubmitCovenantSigs(covSigMsgs []*types.CovenantSigs) (*types.TxResponse, error)

// QueryPendingDelegations queries BTC delegations that are in status of pending
QueryPendingDelegations(limit uint64) ([]*types.Delegation, error)
Expand Down
10 changes: 5 additions & 5 deletions covenant/covenant.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,10 @@ func (ce *CovenantEmulator) AddCovenantSignatures(btcDels []*types.Delegation) (
}

// BuildCovenantSigs creates the covenant signatures from the signature response
func BuildCovenantSigs(pk *secp.PublicKey, resp SigningResponse) []types.CovenantSigs {
covenantSigs := make([]types.CovenantSigs, 0, len(resp.SignaturesByStkTxHash))
func BuildCovenantSigs(pk *secp.PublicKey, resp SigningResponse) []*types.CovenantSigs {
covenantSigs := make([]*types.CovenantSigs, 0, len(resp.SignaturesByStkTxHash))
for stkTxHash, signatures := range resp.SignaturesByStkTxHash {
covenantSigs = append(covenantSigs, types.CovenantSigs{
covenantSigs = append(covenantSigs, &types.CovenantSigs{
PublicKey: pk,
StakingTxHash: stkTxHash,
SlashingSigs: signatures.SlashSigs,
Expand Down Expand Up @@ -608,8 +608,8 @@ func (ce *CovenantEmulator) Stop() error {
}

// SortCovenantSigs helper function to sort all covenant signatures by the staking tx hash
func SortCovenantSigs(covSigs []types.CovenantSigs) []types.CovenantSigs {
sorted := make([]types.CovenantSigs, len(covSigs))
func SortCovenantSigs(covSigs []*types.CovenantSigs) []*types.CovenantSigs {
sorted := make([]*types.CovenantSigs, len(covSigs))
copy(sorted, covSigs)
sort.SliceStable(sorted, func(i, j int) bool {
return strings.Compare(sorted[i].StakingTxHash.String(), sorted[j].StakingTxHash.String()) == 1
Expand Down
4 changes: 2 additions & 2 deletions covenant/covenant_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func FuzzAddCovenantSig(f *testing.F) {
require.NoError(t, err)

numDels := datagen.RandomInt(r, 3) + 1
covSigsSet := make([]types.CovenantSigs, 0, numDels)
covSigsSet := make([]*types.CovenantSigs, 0, numDels)
btcDels := make([]*types.Delegation, 0, numDels)
for i := 0; uint64(i) < numDels; i++ {
// generate BTC delegation
Expand Down Expand Up @@ -179,7 +179,7 @@ func FuzzAddCovenantSig(f *testing.F) {
require.NoError(t, err)
unbondingCovSlashingSigs = append(unbondingCovSlashingSigs, covenantSig.MustMarshal())
}
covSigsSet = append(covSigsSet, types.CovenantSigs{
covSigsSet = append(covSigsSet, &types.CovenantSigs{
PublicKey: covKeyPair.PublicKey,
StakingTxHash: testInfo.StakingTx.TxHash(),
SlashingSigs: covSigs,
Expand Down
2 changes: 1 addition & 1 deletion testutil/mocks/babylon.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 562052f

Please sign in to comment.