Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP Active topic management #542

Merged
merged 29 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
4eac654
remove activetopic keyset
RedBird96 Aug 22, 2024
4f23b37
update topic active logic
RedBird96 Aug 23, 2024
0079f56
update test script for active topic mgmt
RedBird96 Aug 23, 2024
87b015c
fix bug on inactive topic in endblock
RedBird96 Aug 23, 2024
31953df
add migration scripts, query
RedBird96 Aug 26, 2024
e5e1544
Merge branch 'dev' into patch-active-topic-parsing
RedBird96 Aug 26, 2024
0fb1fe2
update test
RedBird96 Aug 27, 2024
b87d98c
update test
RedBird96 Aug 27, 2024
de2f739
fix unit test failing issue
RedBird96 Aug 27, 2024
5169749
Merge branch 'dev' into patch-active-topic-parsing
RedBird96 Aug 27, 2024
14d9120
remove unused variable
RedBird96 Aug 27, 2024
7ebcd39
fix unit test
RedBird96 Aug 27, 2024
6e6ad2d
fix integration test
RedBird96 Aug 27, 2024
75d2e5b
fix lint
RedBird96 Aug 27, 2024
b7219d9
fix remain lint issue
RedBird96 Aug 27, 2024
7efd283
update migration script
RedBird96 Aug 27, 2024
01e3e4f
Merge branch 'dev' into patch-active-topic-parsing
RedBird96 Aug 27, 2024
bdfce1d
Merge branch 'dev' into patch-active-topic-parsing
kpeluso Aug 28, 2024
799cca1
update checking reputer cadence
RedBird96 Aug 28, 2024
fb7b1f7
update cadence
RedBird96 Aug 28, 2024
891daca
update test fail issues
RedBird96 Aug 29, 2024
165d7d3
update test failure
RedBird96 Aug 29, 2024
0b983f2
fix lint CI issue
RedBird96 Aug 29, 2024
1f22a52
Merge branch 'dev' into patch-active-topic-parsing
RedBird96 Aug 29, 2024
c6e350c
update review
RedBird96 Aug 29, 2024
8c2c3bb
add description
RedBird96 Aug 29, 2024
0d9c809
update migration script
RedBird96 Aug 29, 2024
3683d4c
Refactor: Rename TestSuite names (#555)
relyt29 Aug 29, 2024
664bd67
small fix to comments
kpeluso Aug 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Implements merit based sortition for top N inferers, forecasters, and reputers.
* [#544](https://github.com/allora-network/allora-chain/pull/544) Added check against zero-rewards after conversion to cosmosInt
* [#547](https://github.com/allora-network/allora-chain/pull/547) Improve error handling on InsertPayload, fixed/added tests err handling
* [#550](https://github.com/allora-network/allora-chain/pull/550) Fix reputer window upper limit

* [#555](https://github.com/allora-network/allora-chain/pull/555) Refactor: Rename TestSuite names

### Security

Expand Down
41 changes: 14 additions & 27 deletions test/integration/worker_inference_and_forecast_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package integration_test
import (
"context"
"encoding/hex"
"errors"
"fmt"
"time"

Expand All @@ -14,32 +13,20 @@ import (
"github.com/stretchr/testify/require"
)

const defaultEpochLength = 10
const approximateBlockLengthSeconds = 5

func getNonZeroTopicEpochLastRan(m testCommon.TestConfig, topicID uint64, maxRetries int) (*types.Topic, error) {
func waitForNextChurningBlock(m testCommon.TestConfig, topicId uint64) (*types.Topic, error) {
ctx := context.Background()
sleepingTimeBlocks := defaultEpochLength
// Retry loop for a maximum of 5 times
for retries := 0; retries < maxRetries; retries++ {
topicResponse, err := m.Client.QueryEmissions().GetTopic(ctx, &types.QueryTopicRequest{TopicId: topicID})
if err == nil {
storedTopic := topicResponse.Topic
if storedTopic.EpochLastEnded != 0 {
return topicResponse.Topic, nil
}
sleepingTimeBlocks = int(storedTopic.EpochLength)
} else {
m.T.Log(time.Now(), "Error getting topic, retry...", err)
}
// Sleep for a while before retrying
m.T.Log(time.Now(), "Retrying sleeping for a default epoch, retry ", retries, " for sleeping time ", sleepingTimeBlocks)
time.Sleep(time.Duration(sleepingTimeBlocks*approximateBlockLengthSeconds) * time.Second)
topicResponse, err := m.Client.QueryEmissions().GetTopic(ctx, &types.QueryTopicRequest{TopicId: topicId})
if err != nil {
return nil, err
}

return nil, errors.New("topicEpochLastRan is still 0 after retrying")
nextBlockResponse, err := m.Client.QueryEmissions().GetNextChurningBlockByTopicId(ctx, &types.QueryNextChurningBlockByTopicIdRequest{TopicId: topicId})
if err != nil {
return nil, err
}
m.T.Log(time.Now(), "Wait for next churning block ", nextBlockResponse.BlockHeight, " for topic ", topicId)
err = m.Client.WaitForBlockHeight(ctx, nextBlockResponse.BlockHeight)
return topicResponse.Topic, err
}

func InsertSingleWorkerPayload(m testCommon.TestConfig, topic *types.Topic, blockHeight int64) error {
ctx := context.Background()
// Nonce: calculate from EpochLastRan + EpochLength
Expand Down Expand Up @@ -241,14 +228,14 @@ func WorkerInferenceAndForecastChecks(m testCommon.TestConfig) {
ctx := context.Background()
m.T.Log(time.Now(), "--- START Worker Inference, Forecast and Reputation test ---")
// Nonce: calculate from EpochLastRan + EpochLength
topic, err := getNonZeroTopicEpochLastRan(m, 1, 5)

topic, err := waitForNextChurningBlock(m, 1)
if err != nil {
m.T.Log(time.Now(), "--- Failed getting a topic that was ran ---")
require.NoError(m.T, err)
}
m.T.Log(time.Now(), "--- Insert Worker Bundle ---")
// Waiting for ground truth lag to pass
m.T.Log(time.Now(), "--- Waiting to Insert Reputer Bundle ---")
m.T.Log(time.Now(), "--- Waiting to Insert Worker Bundle ---")
blockHeightNonce, err := RunWithRetry(m, 3, 2*time.Second, func() (int64, error) {
topicResponse, err := m.Client.QueryEmissions().GetTopic(ctx, &types.QueryTopicRequest{TopicId: topic.Id})
if err != nil {
Expand Down
Loading
Loading