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

WIP Active topic management #542

merged 29 commits into from
Aug 30, 2024

Conversation

RedBird96
Copy link
Contributor

Purpose of Changes and their Description

Currently active topics are in one large keyset that must be parsed in pages in order to find topics.
This is not scalable as the number of topics increases.
Furthermore, there are some minor issues with respect to how topic weight is calculated -- and EMA is often used where the non-EMA may be more appropriate.

This PR attempts to address these concerns by segmenting the list of active topics by block height of the next epoch.
So, there is no longer 1 keyset for all active topics.
Instead, we map block height to a bounded list of topics.
When a topic is (re)activated, we append it to this list but knock off the topic of lowest weight to maintain a bounded set size.
We also introduce a cache for topic weight and lowest topic weight per "active set for a block" to minimize compute.

Link(s) to Ticket(s) or Issue(s) resolved by this PR

https://linear.app/upshot/issue/ORA-2068/patch-active-topic-parsing

Are these changes tested and documented?

  • If tested, please describe how. If not, why tests are not needed.
  • If documented, please describe where. If not, describe why docs are not needed.
  • Added to Unreleased section of CHANGELOG.md?

Still Left Todo

Fill this out if this is a Draft PR so others can help.

@RedBird96 RedBird96 requested review from kpeluso, guilherme-brandao and relyt29 and removed request for kpeluso and guilherme-brandao August 23, 2024 19:55
@RedBird96 RedBird96 changed the title WIP Active topic WIP Active topic management Aug 23, 2024
Copy link
Collaborator

@kpeluso kpeluso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still looking for migration handler, its tests, and integration tests (esp what happens when there are more topics than there is space for at a block).

x/emissions/proto/emissions/v3/params.proto Outdated Show resolved Hide resolved
x/emissions/proto/emissions/v3/tx.proto Show resolved Hide resolved
x/emissions/keeper/keeper_test.go Outdated Show resolved Hide resolved
x/emissions/keeper/topic_activation.go Outdated Show resolved Hide resolved
x/emissions/keeper/topic_activation.go Outdated Show resolved Hide resolved
x/emissions/keeper/topic_activation.go Outdated Show resolved Hide resolved
x/emissions/keeper/topic_activation.go Outdated Show resolved Hide resolved
x/emissions/keeper/topic_activation.go Show resolved Hide resolved
Copy link

github-actions bot commented Aug 26, 2024

The latest Buf updates on your PR. Results from workflow Buf Linter / buf (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed⏩ skippedAug 30, 2024, 12:36 AM

RedBird96 and others added 2 commits August 29, 2024 15:23
## Purpose of Changes and their Description

This is a refactoring PR with no state changes. It renames testify
TestSuites to match with the packages they are actually testing.

## Are these changes tested and documented?

These changes are tested by running them / our existing tests

This is an internal change that does not require documentation.
@@ -1995,6 +1963,59 @@ func (k Keeper) GetIdsOfActiveTopics(ctx context.Context, pagination *types.Simp
}, nil
}

// Returns active topic ids at block using pagination
func (k Keeper) GetIdsActiveTopicAtBlock(ctx context.Context, blockHeight int64, pagination *types.SimpleCursorPaginationRequest) ([]TopicId, *types.SimpleCursorPaginationResponse, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we really need pagination here?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved in #557 + removed GetActiveTopics

@kpeluso
Copy link
Collaborator

kpeluso commented Aug 30, 2024

Approved changes I have coming in: #557

@kpeluso
Copy link
Collaborator

kpeluso commented Aug 30, 2024

Will also do changelog in a batch to add even more color to all recent PRs including this one

@kpeluso kpeluso merged commit 9d6b84d into dev Aug 30, 2024
7 checks passed
@kpeluso kpeluso deleted the patch-active-topic-parsing branch August 30, 2024 02:53
kpeluso added a commit that referenced this pull request Sep 3, 2024
# v0.4.0

### Summary

Implements fixes for our [June
2024](https://github.com/sherlock-audit/2024-06-allora-judging)
Sherlock.xyz audit, including important fixes for determining which
topics are considered active.

### Added

* [#542](#542) Add
scalable management of active topics with associated queries such as
`GetActiveTopicsAtBlock` and `GetNextChurningBlockByTopicId`
* [#556](#556) Scores
now take an exponential moving average of the score rather than using
the instantaneous score value from this epoch.
* [#564](#564)
Topic-epoch-length-aware effective revenue drip to ensure fairness of
distribution between topics of longer and shorter epochs.

### Removed

* [#542](#542) As
part of active topic management, we removed `GetActiveTopics` and other
(especially paginated) remnants of an unpartitioned store of active
topics.

### Fixed

* [#544](#544) Added
check against zero-rewards after conversion to cosmosInt
* [#547](#547)
Improve error handling on InsertPayload, fixed/added tests err handling
* [#550](#550) Fix
reputer window upper limit
* [#555](#555)
Refactor: Rename TestSuite names
* [#563](#563) Fix of
the reputer losses length consistency in scores calculation

### Security

* See our recent [June
2024](https://github.com/sherlock-audit/2024-06-allora-judging) security
audit for a full description of bugs found during that audit.
* [#554](#554) Check
Signature on Worker or Reputer Payload Matches
Inferer/Forecaster/Reputer inside Bundle

---------

Signed-off-by: web3-nodeops <[email protected]>
Signed-off-by: Tobi Okedeji <[email protected]>
Signed-off-by: Fernando Campos <[email protected]>
Signed-off-by: Guilherme Brandão <[email protected]>
Co-authored-by: web3-nodeops <[email protected]>
Co-authored-by: Guilherme Brandão <[email protected]>
Co-authored-by: T <[email protected]>
Co-authored-by: Diego C <[email protected]>
Co-authored-by: Tobi Okedeji <[email protected]>
Co-authored-by: RedBird96 <[email protected]>
Co-authored-by: fernandofcampos <[email protected]>
Co-authored-by: Elias Rad <[email protected]>
Co-authored-by: Tyler <[email protected]>
Co-authored-by: michael <[email protected]>
Co-authored-by: Guilherme Brandão <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants