Skip to content

Commit

Permalink
chore: Remove todos (#221)
Browse files Browse the repository at this point in the history
Remaining todos are tracked by:
- #222
- #223
- #224
- #225
- #219
- #196
  • Loading branch information
gitferry authored Dec 16, 2024
1 parent d8506b6 commit 4f702d6
Show file tree
Hide file tree
Showing 14 changed files with 22 additions and 38 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
* [#214](https://github.com/babylonlabs-io/finality-provider/pull/214) Gradual benchmark
* [#216](https://github.com/babylonlabs-io/finality-provider/pull/216) Add multiple fpd connecting to one eotsd in e2e tests
* [#218](https://github.com/babylonlabs-io/finality-provider/pull/218) Prune used merkle proof
* [#221](https://github.com/babylonlabs-io/finality-provider/pull/221) Cleanup TODOs

## v0.13.1

Expand Down
2 changes: 1 addition & 1 deletion clientcontroller/babylon.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ func (bc *BabylonController) SubmitFinalitySig(
fpPk *btcec.PublicKey,
block *types.BlockInfo,
pubRand *btcec.FieldVal,
proof []byte, // TODO: have a type for proof
proof []byte,
sig *btcec.ModNScalar,
) (*types.TxResponse, error) {
return bc.SubmitBatchFinalitySigs(
Expand Down
9 changes: 9 additions & 0 deletions docs/finality-provider-operation.md
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,12 @@ For more information on statuses please refer to diagram in the core documentati

<!-- vitsalis: TODO: native way of showing the finality provider has the statuses -->

After successful registration, you may start the finality provider instance
by running:
```shell
fpd start --eots-pk <hex-string-of-eots-public-key>
```

### 5.2. Withdrawing Rewards

As a participant in the Finality Provider Program, you will earn rewards that
Expand Down Expand Up @@ -607,6 +613,9 @@ Parameters:

> ⚠️ Before unjailing, ensure you've fixed the underlying issue that caused jailing
If unjailing is successful, you may start running the finality provider by
`fpd start --eots-pk <hex-string-of-eots-public-key>`.

### 5.4. Slashing

**Slashing occurs** when a finality provider **double signs**, meaning that the
Expand Down
5 changes: 0 additions & 5 deletions eotsmanager/localmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,6 @@ func (lm *LocalEOTSManager) LoadBIP340PubKeyFromKeyName(keyName string) (*bbntyp
}
}

// TODO the current implementation is a PoC, which does not contain any anti-slasher mechanism
//
// a simple anti-slasher mechanism could be that the manager remembers the tuple (fpPk, chainID, height) or
// the hash of each generated randomness and return error if the same randomness is requested twice
func (lm *LocalEOTSManager) CreateRandomnessPairList(fpPk []byte, chainID []byte, startHeight uint64, num uint32, passphrase string) ([]*btcec.FieldVal, error) {
prList := make([]*btcec.FieldVal, 0, num)

Expand Down Expand Up @@ -323,7 +319,6 @@ func (lm *LocalEOTSManager) getRandomnessPair(fpPk []byte, chainID []byte, heigh
return privRand, pubRand, nil
}

// TODO: we ignore passPhrase in local implementation for now
func (lm *LocalEOTSManager) KeyRecord(fpPk []byte, passphrase string) (*eotstypes.KeyRecord, error) {
name, err := lm.es.GetEOTSKeyName(fpPk)
if err != nil {
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.

2 changes: 0 additions & 2 deletions finality-provider/proto/finality_providers.proto
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,10 @@ message QueryFinalityProviderResponse {
}

message QueryFinalityProviderListRequest {
// TODO add pagination in case the list gets large
}

message QueryFinalityProviderListResponse {
repeated FinalityProviderInfo finality_providers = 1;
// TODO add pagination in case the list gets large
}

// FinalityProvider defines current state of finality provider.
Expand Down
8 changes: 1 addition & 7 deletions finality-provider/service/chain_poller.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,13 @@ import (
)

var (
// TODO: Maybe configurable?
RtyAttNum = uint(5)
RtyAtt = retry.Attempts(RtyAttNum)
RtyDel = retry.Delay(time.Millisecond * 400)
RtyErr = retry.LastErrorOnly(true)
)

const (
// TODO: Maybe configurable?
maxFailedCycles = 20
)

Expand Down Expand Up @@ -110,9 +108,7 @@ func (cp *ChainPoller) IsRunning() bool {
return cp.isStarted.Load()
}

// Return read only channel for incoming blocks
// TODO: Handle the case when there is more than one consumer. Currently with more than
// one consumer blocks most probably will be received out of order to those consumers.
// GetBlockInfoChan returns the read-only channel for incoming blocks
func (cp *ChainPoller) GetBlockInfoChan() <-chan *types.BlockInfo {
return cp.blockInfoChan
}
Expand Down Expand Up @@ -175,8 +171,6 @@ func (cp *ChainPoller) pollChain() {
for {
select {
case <-time.After(cp.cfg.PollInterval):
// TODO: Handlig of request cancellation, as otherwise shutdown will be blocked
// until request is finished
blockToRetrieve := cp.nextHeight
block, err := cp.blockWithRetry(blockToRetrieve)
if err != nil {
Expand Down
2 changes: 0 additions & 2 deletions finality-provider/service/chain_poller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ func FuzzChainPoller_Start(f *testing.F) {
mockClientController.EXPECT().QueryBlock(i).Return(resBlock, nil).AnyTimes()
}

// TODO: use mock metrics
m := metrics.NewFpMetrics()
pollerCfg := fpcfg.DefaultChainPollerConfig()
pollerCfg.PollInterval = 10 * time.Millisecond
Expand Down Expand Up @@ -98,7 +97,6 @@ func FuzzChainPoller_SkipHeight(f *testing.F) {
mockClientController.EXPECT().QueryBlock(i).Return(resBlock, nil).AnyTimes()
}

// TODO: use mock metrics
m := metrics.NewFpMetrics()
pollerCfg := fpcfg.DefaultChainPollerConfig()
pollerCfg.PollInterval = 1 * time.Second
Expand Down
5 changes: 2 additions & 3 deletions finality-provider/service/eots_manager_adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import (
"fmt"

bbntypes "github.com/babylonlabs-io/babylon/types"
"github.com/babylonlabs-io/finality-provider/types"
"github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/btcec/v2/schnorr"
"github.com/cometbft/cometbft/crypto/tmhash"
sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/babylonlabs-io/finality-provider/types"
)

func (fp *FinalityProviderInstance) getPubRandList(startHeight uint64, numPubRand uint32) ([]*btcec.FieldVal, error) {
Expand All @@ -26,7 +27,6 @@ func (fp *FinalityProviderInstance) getPubRandList(startHeight uint64, numPubRan
return pubRandList, nil
}

// TODO: have this function in Babylon side
func getHashToSignForCommitPubRand(startHeight uint64, numPubRand uint64, commitment []byte) ([]byte, error) {
hasher := tmhash.New()
if _, err := hasher.Write(sdk.Uint64ToBigEndian(startHeight)); err != nil {
Expand All @@ -51,7 +51,6 @@ func (fp *FinalityProviderInstance) signPubRandCommit(startHeight uint64, numPub
return fp.em.SignSchnorrSig(fp.btcPk.MustMarshal(), hash, fp.passphrase)
}

// TODO: have this function in Babylon side
func getMsgToSignForVote(blockHeight uint64, blockHash []byte) []byte {
return append(sdk.Uint64ToBigEndian(blockHeight), blockHash...)
}
Expand Down
13 changes: 4 additions & 9 deletions finality-provider/service/fp_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@ func (fp *FinalityProviderInstance) getAllBlocksFromChan() []*types.BlockInfo {
for {
select {
case b := <-fp.poller.GetBlockInfoChan():
// TODO: in cases of catching up, this could issue frequent RPC calls
shouldProcess, err := fp.shouldProcessBlock(b)
if err != nil {
if !errors.Is(err, ErrFinalityProviderShutDown) {
Expand Down Expand Up @@ -387,8 +386,8 @@ func (fp *FinalityProviderInstance) retrySubmitSigsUntilFinalized(targetBlocks [
zap.String("pk", fp.GetBtcPkHex()),
zap.Uint64("target_height", targetHeight),
)
// TODO: returning nil here is to safely break the loop
// the error still exists
// returning nil here is to safely break the loop
// the error still exists
return nil, nil
}

Expand Down Expand Up @@ -421,8 +420,6 @@ func (fp *FinalityProviderInstance) retryCommitPubRandUntilBlockFinalized(target
// this part should not be retried here. We need to separate the function into
// 1) determining the starting height to commit, 2) generating pub rand and inclusion
// proofs, and 3) committing public randomness.
// TODO: make 3) a part of `select` statement. The function terminates upon either the block
// is finalised or the pub rand is committed successfully
res, err := fp.CommitPubRand(targetBlock.Height)
if err != nil {
if clientcontroller.IsUnrecoverable(err) {
Expand Down Expand Up @@ -457,8 +454,8 @@ func (fp *FinalityProviderInstance) retryCommitPubRandUntilBlockFinalized(target
zap.String("pk", fp.GetBtcPkHex()),
zap.Uint64("target_height", targetBlock.Height),
)
// TODO: returning nil here is to safely break the loop
// the error still exists
// returning nil here is to safely break the loop
// the error still exists
return nil, nil
}

Expand Down Expand Up @@ -608,8 +605,6 @@ func (fp *FinalityProviderInstance) TestCommitPubRandWithStartHeight(startHeight

fp.logger.Info("Start committing pubrand from block height", zap.Uint64("start_height", startHeight))

// TODO: instead of sending multiple txs, a better way is to bundle all the commit messages into
// one like we do for batch finality signatures. see discussion https://bit.ly/3OmbjkN
for startHeight <= targetBlockHeight {
_, err = fp.commitPubRandPairs(startHeight)
if err != nil {
Expand Down
5 changes: 0 additions & 5 deletions finality-provider/service/rpcserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,6 @@ func (r *rpcServer) UnjailFinalityProvider(_ context.Context, req *proto.UnjailF
return nil, fmt.Errorf("failed to unjail the finality-provider: %w", err)
}

// todo: keep passphrase as empty for now
if err := r.app.StartFinalityProvider(fpPk, ""); err != nil {
return nil, fmt.Errorf("failed to start the finality provider instance after unjailing: %w", err)
}

return &proto.UnjailFinalityProviderResponse{TxHash: res.TxHash}, nil
}

Expand Down
1 change: 1 addition & 0 deletions finality-provider/store/pub_rand.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package store
import (
"bytes"
"fmt"

"github.com/btcsuite/btcwallet/walletdb"
sdk "github.com/cosmos/cosmos-sdk/types"

Expand Down
1 change: 0 additions & 1 deletion itest/test_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,6 @@ func (tm *TestManager) InsertCovenantSigForDelegation(t *testing.T, btcDel *bsty

stakingInfo, err := btcstaking.BuildStakingInfo(
btcDel.BtcPk.MustToBTCPK(),
// TODO: Handle multiple providers
[]*btcec.PublicKey{btcDel.FpBtcPkList[0].MustToBTCPK()},
params.CovenantPks,
params.CovenantQuorum,
Expand Down
4 changes: 2 additions & 2 deletions testutil/port.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package testutil

import (
"fmt"
mrand "math/rand" // todo(lazar): upgrade to v2 once we move to go1.23
mrand "math/rand/v2"
"net"
"sync"
"testing"
Expand All @@ -18,7 +18,7 @@ var (
// by testing multiple random ports within a specified range.
func AllocateUniquePort(t *testing.T) int {
randPort := func(base, spread int) int {
return base + mrand.Intn(spread)
return base + mrand.IntN(spread)
}

// Base port and spread range for port selection
Expand Down

0 comments on commit 4f702d6

Please sign in to comment.