Skip to content

Commit

Permalink
Merge branch 'dev' into gai/switch-to-trunk
Browse files Browse the repository at this point in the history
  • Loading branch information
gitferry committed Sep 3, 2024
2 parents cbcaa00 + 27a503b commit 7869271
Show file tree
Hide file tree
Showing 17 changed files with 254 additions and 209 deletions.
27 changes: 27 additions & 0 deletions clientcontroller/babylon.go
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,15 @@ func (bc *BabylonController) QueryBtcLightClientTip() (*btclctypes.BTCHeaderInfo
return res.Header, nil
}

func (bc *BabylonController) QueryCurrentEpoch() (uint64, error) {
res, err := bc.bbnClient.QueryClient.CurrentEpoch()
if err != nil {
return 0, fmt.Errorf("failed to query BTC tip: %v", err)
}

return res.CurrentEpoch, nil
}

func (bc *BabylonController) QueryVotesAtHeight(height uint64) ([]bbntypes.BIP340PubKey, error) {
res, err := bc.bbnClient.QueryClient.VotesAtHeight(height)
if err != nil {
Expand Down Expand Up @@ -589,3 +598,21 @@ func (bc *BabylonController) SubmitCovenantSigs(

return &types.TxResponse{TxHash: res.TxHash, Events: res.Events}, nil
}

func (bc *BabylonController) GetBBNClient() *bbnclient.Client {
return bc.bbnClient
}

func (bc *BabylonController) InsertSpvProofs(submitter string, proofs []*btcctypes.BTCSpvProof) (*provider.RelayerTxResponse, error) {
msg := &btcctypes.MsgInsertBTCSpvProof{
Submitter: submitter,
Proofs: proofs,
}

res, err := bc.reliablySendMsg(msg, emptyErrs, emptyErrs)
if err != nil {
return nil, err
}

return res, nil
}
1 change: 1 addition & 0 deletions clientcontroller/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"go.uber.org/zap"

finalitytypes "github.com/babylonlabs-io/babylon/x/finality/types"

fpcfg "github.com/babylonlabs-io/finality-provider/finality-provider/config"
"github.com/babylonlabs-io/finality-provider/types"
)
Expand Down
2 changes: 1 addition & 1 deletion eotsmanager/proto/eotsmanager.pb.go

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

37 changes: 25 additions & 12 deletions eotsmanager/proto/eotsmanager_grpc.pb.go

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

6 changes: 3 additions & 3 deletions finality-provider/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ const (
defaultFinalityProviderKeyName = "finality-provider"
DefaultRPCPort = 12581
defaultConfigFileName = "fpd.conf"
defaultNumPubRand = 100
defaultNumPubRandMax = 200
defaultMinRandHeightGap = 20
defaultNumPubRand = 70000 // support running of 1 week with block production time as 10s
defaultNumPubRandMax = 100000
defaultMinRandHeightGap = 35000
defaultStatusUpdateInterval = 20 * time.Second
defaultRandomInterval = 30 * time.Second
defaultSubmitRetryInterval = 1 * time.Second
Expand Down
2 changes: 1 addition & 1 deletion finality-provider/proto/finality_providers.pb.go

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

42 changes: 28 additions & 14 deletions finality-provider/proto/finality_providers_grpc.pb.go

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

8 changes: 0 additions & 8 deletions finality-provider/service/fastsync.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,6 @@ func (fp *FinalityProviderInstance) FastSync(startHeight, endHeight uint64) (*Fa
fp.metrics.IncrementFpTotalBlocksWithoutVotingPower(fp.GetBtcPkHex())
continue
}
// check whether the randomness has been committed
hasRand, err := fp.hasRandomness(b)
if err != nil {
return nil, err
}
if !hasRand {
break
}
// all good, add the block for catching up
catchUpBlocks = append(catchUpBlocks, b)
}
Expand Down
11 changes: 9 additions & 2 deletions finality-provider/service/fastsync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,17 @@ func FuzzFastSync_NoRandomness(f *testing.F) {
_, err := fpIns.CommitPubRand(randomStartingHeight)
require.NoError(t, err)

mockClientController.EXPECT().QueryFinalityProviderVotingPower(fpIns.GetBtcPk(), gomock.Any()).
Return(uint64(1), nil).AnyTimes()
// the last height with pub rand is a random value inside [finalizedHeight+1, currentHeight]
lastHeightWithPubRand := uint64(rand.Intn(int(currentHeight)-int(finalizedHeight))) + finalizedHeight + 1
for i := randomStartingHeight; i <= currentHeight; i++ {
if i <= lastHeightWithPubRand {
mockClientController.EXPECT().QueryFinalityProviderVotingPower(fpIns.GetBtcPk(), i).
Return(uint64(1), nil).AnyTimes()
} else {
mockClientController.EXPECT().QueryFinalityProviderVotingPower(fpIns.GetBtcPk(), i).
Return(uint64(0), nil).AnyTimes()
}
}
lastCommittedPubRandMap := make(map[uint64]*ftypes.PubRandCommitResponse)
lastCommittedPubRandMap[lastHeightWithPubRand-10] = &ftypes.PubRandCommitResponse{
NumPubRand: 10 + 1,
Expand Down
Loading

0 comments on commit 7869271

Please sign in to comment.