Skip to content

Commit

Permalink
slasher works
Browse files Browse the repository at this point in the history
  • Loading branch information
Lazar955 committed Oct 23, 2024
1 parent 752dc39 commit 4cbe4de
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
11 changes: 10 additions & 1 deletion btcstaking-tracker/btcslasher/bootstrapping_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,17 @@ func FuzzSlasher_Bootstrapping(f *testing.F) {
// mock an evidence with this finality provider
evidence, err := datagen.GenRandomEvidence(r, fpSK, 100)
require.NoError(t, err)
er := &ftypes.EvidenceResponse{
FpBtcPkHex: evidence.FpBtcPk.MarshalHex(),
BlockHeight: evidence.BlockHeight,
PubRand: evidence.PubRand,
CanonicalAppHash: evidence.CanonicalAppHash,
ForkAppHash: evidence.ForkAppHash,
CanonicalFinalitySig: evidence.CanonicalFinalitySig,
ForkFinalitySig: evidence.ForkFinalitySig,
}
mockBabylonQuerier.EXPECT().ListEvidences(gomock.Any(), gomock.Any()).Return(&ftypes.QueryListEvidencesResponse{
Evidences: []*ftypes.Evidence{evidence},
Evidences: []*ftypes.EvidenceResponse{er},
Pagination: &query.PageResponse{NextKey: nil},
}, nil).Times(1)

Expand Down
8 changes: 4 additions & 4 deletions btcstaking-tracker/btcslasher/slasher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,10 @@ func FuzzSlasher(f *testing.F) {
err = unbondingSlashingInfo.UnbondingTx.Serialize(&unbondingTxBuffer)
require.NoError(t, err)
unbondingBTCDel.BtcUndelegation = &bstypes.BTCUndelegation{
UnbondingTx: unbondingTxBuffer.Bytes(),
SlashingTx: unbondingSlashingInfo.SlashingTx,
DelegatorSlashingSig: delSlashingSig,
DelegatorUnbondingSig: delSlashingSig,
UnbondingTx: unbondingTxBuffer.Bytes(),
SlashingTx: unbondingSlashingInfo.SlashingTx,
DelegatorSlashingSig: delSlashingSig,
DelegatorUnbondingInfo: &bstypes.DelegatorUnbondingInfo{SpendStakeTx: unbondingTxBuffer.Bytes()},
// TODO: currently requires only one sig, in reality requires all of them
CovenantSlashingSigs: covenantSlashingSigs,
CovenantUnbondingSigList: covenantUnbondingSigs,
Expand Down
3 changes: 1 addition & 2 deletions btcstaking-tracker/btcslasher/slasher_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -423,8 +423,7 @@ func (bs *BTCSlasher) getAllActiveAndUnbondedBTCDelegations(
activeDels = append(activeDels, dels.Dels[i])
}
if strings.EqualFold(del.StatusDesc, bstypes.BTCDelegationStatus_UNBONDED.String()) &&
len(del.UndelegationResponse.CovenantSlashingSigs) >= int(bsParams.CovenantQuorum) &&
len(del.UndelegationResponse.DelegatorUnbondingInfoResponse.SpendStakeTxHex) > 0 {
len(del.UndelegationResponse.CovenantSlashingSigs) >= int(bsParams.CovenantQuorum) {
// NOTE: Babylon considers a BTC delegation to be unbonded once it
// receives staker signature for unbonding transaction, no matter
// whether the unbonding tx's timelock has expired. In monitor's view we need to try to slash every
Expand Down
5 changes: 2 additions & 3 deletions e2etest/container/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,13 @@ const (

// NewImageConfig returns ImageConfig needed for running e2e test.
func NewImageConfig(t *testing.T) ImageConfig {
babylondVersion, err := testutil.GetBabylonVersion()
_, err := testutil.GetBabylonVersion()
require.NoError(t, err)
babylondVersion = "6a0ccacc41435a249316a77fe6e1e06aeb654d13" // todo(lazar): remove this when we have a tag

return ImageConfig{
BitcoindRepository: dockerBitcoindRepository,
BitcoindVersion: dockerBitcoindVersionTag,
BabylonRepository: dockerBabylondRepository,
BabylonVersion: babylondVersion,
BabylonVersion: "6a0ccacc41435a249316a77fe6e1e06aeb654d13", // todo(lazar): remove this when we have a tag
}
}

0 comments on commit 4cbe4de

Please sign in to comment.