From 6dcb67f91935f82da52479c8658539d9322d778c Mon Sep 17 00:00:00 2001 From: Fangyu Gai Date: Wed, 28 Aug 2024 00:25:50 +0800 Subject: [PATCH] fix e2e --- finality-provider/config/config.go | 4 ++-- finality-provider/service/fp_instance.go | 16 ++++++------- go.mod | 2 +- go.sum | 4 ++-- itest/e2e_test.go | 5 +--- itest/test_manager.go | 29 ++++++++++++++++++++---- tools/go.mod | 2 +- tools/go.sum | 4 ++-- 8 files changed, 42 insertions(+), 24 deletions(-) diff --git a/finality-provider/config/config.go b/finality-provider/config/config.go index 3fa4b51f..f6af37a8 100644 --- a/finality-provider/config/config.go +++ b/finality-provider/config/config.go @@ -25,8 +25,8 @@ const ( defaultFinalityProviderKeyName = "finality-provider" DefaultRPCPort = 12581 defaultConfigFileName = "fpd.conf" - defaultNumPubRand = 100 - defaultNumPubRandMax = 200 + defaultNumPubRand = 1000 + defaultNumPubRandMax = 1000 defaultMinRandHeightGap = 20 defaultStatusUpdateInterval = 20 * time.Second defaultRandomInterval = 30 * time.Second diff --git a/finality-provider/service/fp_instance.go b/finality-provider/service/fp_instance.go index 32815f0f..d1595a62 100644 --- a/finality-provider/service/fp_instance.go +++ b/finality-provider/service/fp_instance.go @@ -711,14 +711,14 @@ func (fp *FinalityProviderInstance) SubmitBatchFinalitySignatures(blocks []*type // Note: this should not be used in the submission loop func (fp *FinalityProviderInstance) TestSubmitFinalitySignatureAndExtractPrivKey(b *types.BlockInfo) (*types.TxResponse, *btcec.PrivateKey, error) { // check last committed height - lastCommittedHeight, err := fp.GetLastCommittedHeight() - if err != nil { - return nil, nil, err - } - if lastCommittedHeight < b.Height { - return nil, nil, fmt.Errorf("the finality-provider's last committed height %v is lower than the current block height %v", - lastCommittedHeight, b.Height) - } + // lastCommittedHeight, err := fp.GetLastCommittedHeight() + // if err != nil { + // return nil, nil, err + // } + // if lastCommittedHeight < b.Height { + // return nil, nil, fmt.Errorf("the finality-provider's last committed height %v is lower than the current block height %v", + // lastCommittedHeight, b.Height) + // } // get public randomness prList, err := fp.getPubRandList(b.Height, 1) diff --git a/go.mod b/go.mod index 8e402a99..a443bdce 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( cosmossdk.io/errors v1.0.1 cosmossdk.io/math v1.3.0 github.com/avast/retry-go/v4 v4.5.1 - github.com/babylonlabs-io/babylon v0.9.2-0.20240821052344-8e14b994a747 + github.com/babylonlabs-io/babylon v0.9.3-0.20240827161405-b74b8b715b45 github.com/btcsuite/btcd v0.24.2 github.com/btcsuite/btcd/btcec/v2 v2.3.2 github.com/btcsuite/btcd/btcutil v1.1.5 diff --git a/go.sum b/go.sum index 9e6d3b27..591513dd 100644 --- a/go.sum +++ b/go.sum @@ -281,8 +281,8 @@ github.com/aws/aws-sdk-go v1.44.122/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX github.com/aws/aws-sdk-go v1.44.312 h1:llrElfzeqG/YOLFFKjg1xNpZCFJ2xraIi3PqSuP+95k= github.com/aws/aws-sdk-go v1.44.312/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g= -github.com/babylonlabs-io/babylon v0.9.2-0.20240821052344-8e14b994a747 h1:OC30WmlVHhmjAHqcB6QJi6xnaHupyedDMkFjeDsBJCY= -github.com/babylonlabs-io/babylon v0.9.2-0.20240821052344-8e14b994a747/go.mod h1:9VUUAwVaalXiDdPZT65SPoawKWpp6ple6tBr8Vw0NI8= +github.com/babylonlabs-io/babylon v0.9.3-0.20240827161405-b74b8b715b45 h1:hcjNRjmgRTWemJswGgeYjQZUiWJXyRV2sc1Ru0Z4fE0= +github.com/babylonlabs-io/babylon v0.9.3-0.20240827161405-b74b8b715b45/go.mod h1:9VUUAwVaalXiDdPZT65SPoawKWpp6ple6tBr8Vw0NI8= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= diff --git a/itest/e2e_test.go b/itest/e2e_test.go index 71f9664b..45de223b 100644 --- a/itest/e2e_test.go +++ b/itest/e2e_test.go @@ -1,6 +1,3 @@ -//go:build e2e -// +build e2e - package e2etest import ( @@ -18,7 +15,7 @@ import ( ) var ( - stakingTime = uint16(100) + stakingTime = uint16(1000) stakingAmount = int64(20000) ) diff --git a/itest/test_manager.go b/itest/test_manager.go index bb8a4fe8..b2b51222 100644 --- a/itest/test_manager.go +++ b/itest/test_manager.go @@ -104,6 +104,16 @@ func StartManager(t *testing.T) *TestManager { bc, err := fpcc.NewBabylonController(cfg.BabylonConfig, &cfg.BTCNetParams, logger) require.NoError(t, err) + var currentEpoch uint64 + require.Eventually(t, func() bool { + currentEpoch, err = bc.QueryCurrentEpoch() + if err != nil { + return false + } + return currentEpoch > 0 + }, eventuallyWaitTimeOut, eventuallyPollTime) + t.Logf("current epoch is %d", currentEpoch) + // 3. prepare EOTS manager eotsHomeDir := filepath.Join(testDir, "eots-home") eotsCfg := eotsconfig.DefaultConfigWithHomePath(eotsHomeDir) @@ -241,21 +251,30 @@ func (tm *TestManager) Stop(t *testing.T) { } func (tm *TestManager) WaitForFpPubRandTimestamped(t *testing.T, fpIns *service.FinalityProviderInstance) { + var lastCommittedHeight uint64 + var err error + require.Eventually(t, func() bool { - lastCommittedHeight, err := fpIns.GetLastCommittedHeight() + lastCommittedHeight, err = fpIns.GetLastCommittedHeight() if err != nil { return false } return lastCommittedHeight > 0 }, eventuallyWaitTimeOut, eventuallyPollTime) + t.Logf("public randomness is successfully committed, last committed height: %d", lastCommittedHeight) + // wait until the last registered epoch is finalised currentEpoch, err := tm.BBNClient.QueryCurrentEpoch() require.NoError(t, err) tm.FinalizeUntilEpoch(t, currentEpoch) - t.Logf("public randomness is successfully committed") + res, err := tm.BBNClient.GetBBNClient().LatestEpochFromStatus(ckpttypes.Finalized) + require.NoError(t, err) + t.Logf("last finalized epoch: %d", res.RawCheckpoint.EpochNum) + + t.Logf("public randomness is successfully timestamped, last finalized epoch: %d", currentEpoch) } func (tm *TestManager) WaitForNPendingDels(t *testing.T, n int) []*bstypes.BTCDelegationResponse { @@ -563,7 +582,7 @@ func (tm *TestManager) FinalizeUntilEpoch(t *testing.T, epoch uint64) { // get all checkpoints of these epochs pagination := &sdkquerytypes.PageRequest{ - Key: ckpttypes.CkptsObjectKey(1), + Key: ckpttypes.CkptsObjectKey(0), Limit: epoch, } resp, err := bbnClient.RawCheckpoints(pagination) @@ -616,7 +635,9 @@ func (tm *TestManager) FinalizeUntilEpoch(t *testing.T, epoch uint64) { // wait until this checkpoint is submitted require.Eventually(t, func() bool { ckpt, err := bbnClient.RawCheckpoint(checkpoint.Ckpt.EpochNum) - require.NoError(t, err) + if err != nil { + return false + } return ckpt.RawCheckpoint.Status == ckpttypes.Submitted }, eventuallyWaitTimeOut, eventuallyPollTime) } diff --git a/tools/go.mod b/tools/go.mod index 5f45553c..fb643416 100644 --- a/tools/go.mod +++ b/tools/go.mod @@ -4,7 +4,7 @@ go 1.21 toolchain go1.21.4 -require github.com/babylonlabs-io/babylon v0.9.2-0.20240821052344-8e14b994a747 +require github.com/babylonlabs-io/babylon v0.9.3-0.20240827161405-b74b8b715b45 require ( cloud.google.com/go v0.112.0 // indirect diff --git a/tools/go.sum b/tools/go.sum index 096a38fd..9b6c0b44 100644 --- a/tools/go.sum +++ b/tools/go.sum @@ -268,8 +268,8 @@ github.com/aws/aws-sdk-go v1.44.122/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX github.com/aws/aws-sdk-go v1.44.312 h1:llrElfzeqG/YOLFFKjg1xNpZCFJ2xraIi3PqSuP+95k= github.com/aws/aws-sdk-go v1.44.312/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g= -github.com/babylonlabs-io/babylon v0.9.2-0.20240821052344-8e14b994a747 h1:OC30WmlVHhmjAHqcB6QJi6xnaHupyedDMkFjeDsBJCY= -github.com/babylonlabs-io/babylon v0.9.2-0.20240821052344-8e14b994a747/go.mod h1:9VUUAwVaalXiDdPZT65SPoawKWpp6ple6tBr8Vw0NI8= +github.com/babylonlabs-io/babylon v0.9.3-0.20240827161405-b74b8b715b45 h1:hcjNRjmgRTWemJswGgeYjQZUiWJXyRV2sc1Ru0Z4fE0= +github.com/babylonlabs-io/babylon v0.9.3-0.20240827161405-b74b8b715b45/go.mod h1:9VUUAwVaalXiDdPZT65SPoawKWpp6ple6tBr8Vw0NI8= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=