Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gitferry committed Dec 18, 2024
1 parent dc93487 commit 0b7a53c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 34 deletions.
4 changes: 2 additions & 2 deletions finality-provider/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const (
defaultConfigFileName = "fpd.conf"
defaultNumPubRand = 70000 // support running of 1 week with block production time as 10s
defaultNumPubRandMax = 100000
defaultMinRandHeightGap = 35000
defaultTimestampingDelayBlocks = 6000 // 100 BTC blocks * 600s / 10s
defaultBatchSubmissionSize = 1000
defaultRandomInterval = 30 * time.Second
defaultSubmitRetryInterval = 1 * time.Second
Expand Down Expand Up @@ -92,7 +92,7 @@ func DefaultConfigWithHome(homePath string) Config {
PollerConfig: &pollerCfg,
NumPubRand: defaultNumPubRand,
NumPubRandMax: defaultNumPubRandMax,
TimestampingDelayBlocks: defaultMinRandHeightGap,
TimestampingDelayBlocks: defaultTimestampingDelayBlocks,
BatchSubmissionSize: defaultBatchSubmissionSize,
RandomnessCommitInterval: defaultRandomInterval,
SubmissionRetryInterval: defaultSubmitRetryInterval,
Expand Down
28 changes: 0 additions & 28 deletions finality-provider/service/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"sync"

sdkmath "cosmossdk.io/math"
"github.com/avast/retry-go/v4"
bbntypes "github.com/babylonlabs-io/babylon/types"
bstypes "github.com/babylonlabs-io/babylon/x/btcstaking/types"
"github.com/btcsuite/btcd/btcec/v2"
Expand All @@ -26,7 +25,6 @@ import (
"github.com/babylonlabs-io/finality-provider/finality-provider/store"
fpkr "github.com/babylonlabs-io/finality-provider/keyring"
"github.com/babylonlabs-io/finality-provider/metrics"
"github.com/babylonlabs-io/finality-provider/types"
)

type FinalityProviderApp struct {
Expand Down Expand Up @@ -545,32 +543,6 @@ func (app *FinalityProviderApp) setFinalityProviderJailed(fpi *FinalityProviderI
}
}

func (app *FinalityProviderApp) getLatestBlockWithRetry() (*types.BlockInfo, error) {
var (
latestBlock *types.BlockInfo
err error
)

if err := retry.Do(func() error {
latestBlock, err = app.cc.QueryBestBlock()
if err != nil {
return err
}
return nil
}, RtyAtt, RtyDel, RtyErr, retry.OnRetry(func(n uint, err error) {
app.logger.Debug(
"failed to query the consumer chain for the latest block",
zap.Uint("attempt", n+1),
zap.Uint("max_attempts", RtyAttNum),
zap.Error(err),
)
})); err != nil {
return nil, err
}

return latestBlock, nil
}

// NOTE: this is not safe in production, so only used for testing purpose
func (app *FinalityProviderApp) getFpPrivKey(fpPk []byte) (*btcec.PrivateKey, error) {
record, err := app.eotsManager.KeyRecord(fpPk, "")
Expand Down
7 changes: 4 additions & 3 deletions finality-provider/service/fp_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,13 +325,14 @@ func (fp *FinalityProviderInstance) ShouldCommitRandomness() (bool, uint64, erro
tipHeightWithDelay := tipHeight + uint64(fp.cfg.TimestampingDelayBlocks)

var startHeight uint64
if lastCommittedHeight < tipHeightWithDelay {
switch {
case lastCommittedHeight < tipHeightWithDelay:
// the start height should consider the timestamping delay
// as it is only available to use after tip height + estimated timestamping delay
startHeight = tipHeightWithDelay
} else if lastCommittedHeight < tipHeightWithDelay+uint64(fp.cfg.NumPubRand) {
case lastCommittedHeight < tipHeightWithDelay+uint64(fp.cfg.NumPubRand):
startHeight = lastCommittedHeight + 1
} else {
default:
// the randomness is sufficient, no need to make another commit
fp.logger.Debug(
"the finality-provider has sufficient public randomness, skip committing more",
Expand Down
2 changes: 1 addition & 1 deletion itest/test_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,7 @@ func defaultFpConfig(keyringDir, homeDir string) *fpcfg.Config {

cfg.NumPubRand = 1000
cfg.NumPubRandMax = 1000
cfg.TimestampingDelayBlocks = 500
cfg.TimestampingDelayBlocks = 0

cfg.BitcoinNetwork = "simnet"
cfg.BTCNetParams = chaincfg.SimNetParams
Expand Down

0 comments on commit 0b7a53c

Please sign in to comment.