Skip to content

Commit 9b514d1

Browse files
Bump covenant signer to require signature in request (#21)
1 parent c1f11fd commit 9b514d1

File tree

6 files changed

+18
-23
lines changed

6 files changed

+18
-23
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ require (
4747
)
4848

4949
require (
50-
github.com/babylonchain/covenant-signer v0.0.0-20240507155851-64756e393be2
50+
github.com/babylonchain/covenant-signer v0.0.0-20240509110821-b6017a54332f
5151
github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0
5252
github.com/btcsuite/btcwallet/wallet/txauthor v1.3.4
5353
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,8 @@ github.com/babylonchain/babylon v0.8.6-0.20240426101001-7778c798e236 h1:Ydna4VcP
281281
github.com/babylonchain/babylon v0.8.6-0.20240426101001-7778c798e236/go.mod h1:lfeASLNJgcUsX7LEns3HRUv0k+MjzcB2q2AMasfz38M=
282282
github.com/babylonchain/covenant-signer v0.0.0-20240507155851-64756e393be2 h1:v5h+81bOlENEw/cyXv/6+/5laUs/EOvxAfZTdWbOW5A=
283283
github.com/babylonchain/covenant-signer v0.0.0-20240507155851-64756e393be2/go.mod h1:alX7NoDE2m7gW4O17hLAsluU30P0XaP5RlThAco8Y9Q=
284+
github.com/babylonchain/covenant-signer v0.0.0-20240509110821-b6017a54332f h1:UKNyeBlPZgLB5+1ZUA1YCL6bPtREA+oP1OT6ibNadw0=
285+
github.com/babylonchain/covenant-signer v0.0.0-20240509110821-b6017a54332f/go.mod h1:alX7NoDE2m7gW4O17hLAsluU30P0XaP5RlThAco8Y9Q=
284286
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
285287
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
286288
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=

internal/services/expected_interfaces.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import (
1414
type SignRequest struct {
1515
// Unbonding transaction which should be signed
1616
UnbondingTransaction *wire.MsgTx
17+
// Staker signature of the unbonding transaction
18+
StakerUnbondingSig *schnorr.Signature
1719
// Staking output which was used to fund unbonding transaction
1820
FundingOutput *wire.TxOut
1921
// Script of the path which should be execute - unbonding path
@@ -29,12 +31,14 @@ type SignResult struct {
2931

3032
func NewSignRequest(
3133
tx *wire.MsgTx,
34+
stakerSig *schnorr.Signature,
3235
fundingOutput *wire.TxOut,
3336
script []byte,
3437
pubKey *btcec.PublicKey,
3538
) *SignRequest {
3639
return &SignRequest{
3740
UnbondingTransaction: tx,
41+
StakerUnbondingSig: stakerSig,
3842
FundingOutput: fundingOutput,
3943
UnbondingScript: script,
4044
SignerPubKey: pubKey,

internal/services/remote_signer.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ func (rs *RemoteSigner) SignUnbondingTransaction(req *SignRequest) (*PubKeySigPa
3939
url,
4040
rs.timeout,
4141
req.UnbondingTransaction,
42+
req.StakerUnbondingSig,
4243
req.SignerPubKey,
4344
req.UnbondingScript,
4445
)

internal/services/unbonding_pipeline.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ func NewUnbondingPipeline(
133133
// covenant signers in a concurrent manner
134134
func (up *UnbondingPipeline) signUnbondingTransaction(
135135
unbondingTransaction *wire.MsgTx,
136+
stakerSig *schnorr.Signature,
136137
fundingOutput *wire.TxOut,
137138
unbondingScript []byte,
138139
params *SystemParams,
@@ -142,6 +143,7 @@ func (up *UnbondingPipeline) signUnbondingTransaction(
142143
for _, pk := range params.CovenantPublicKeys {
143144
req := NewSignRequest(
144145
unbondingTransaction,
146+
stakerSig,
145147
fundingOutput,
146148
unbondingScript,
147149
pk,
@@ -262,6 +264,7 @@ func (up *UnbondingPipeline) processUnbondingTransactions(
262264

263265
sigs, err := up.signUnbondingTransaction(
264266
utx.UnbondingTransaction,
267+
utx.UnbondingTransactionSig,
265268
stakingOutputRecovered,
266269
stakingOutputRecovered.PkScript,
267270
params,

itest/e2e_test.go

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package e2etest
66
import (
77
"context"
88
"encoding/hex"
9+
"errors"
910
"fmt"
1011
"math"
1112
"testing"
@@ -518,7 +519,7 @@ func (tm *TestManager) updateSchnorSigInDb(newSig *schnorr.Signature, txHash *ch
518519
require.NoError(tm.t, err)
519520
}
520521

521-
func TestReSendingFailedTransactions(t *testing.T) {
522+
func TestHandlingCriticalError(t *testing.T) {
522523
m := StartManager(t, 10)
523524
d := defaultStakingData()
524525

@@ -553,26 +554,10 @@ func TestReSendingFailedTransactions(t *testing.T) {
553554

554555
// 2. Run pipeline
555556
err = m.pipeLine.ProcessNewTransactions(context.Background())
556-
require.NoError(t, err)
557-
558-
// 3. There should be one failed transaction
559-
failedTx, err := m.testStoreController.GetFailedUnbondingTransactions(context.TODO())
560-
require.NoError(t, err)
561-
require.Len(t, failedTx, 1)
557+
require.Error(t, err)
558+
// With invalid signature in db, signers will refuse to sign it, which should end
559+
// with critical error
560+
require.True(t, errors.Is(err, services.ErrCriticalError))
562561

563-
// 4. Fix sig in db
564-
unbondingTxHash := unbondingTx.unbondingTx.TxHash()
565-
m.updateSchnorSigInDb(unbondingTx.signature, &unbondingTxHash)
566-
567-
// 5. Run pipeline for failed tx
568-
err = m.pipeLine.ProcessFailedTransactions(context.Background())
569-
require.NoError(t, err)
570-
571-
failedTxNew, err := m.testStoreController.GetFailedUnbondingTransactions(context.TODO())
572-
require.NoError(t, err)
573-
require.Len(t, failedTxNew, 0)
574-
575-
sendUnbondingTx, err := m.testStoreController.GetSendUnbondingTransactions(context.TODO())
576-
require.NoError(t, err)
577-
require.Len(t, sendUnbondingTx, 1)
562+
// TODO:Find a way to simulate bitcoind not accepting transaction
578563
}

0 commit comments

Comments
 (0)