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

[TODO] refactor: query expiring claims w/ index #671

Merged
merged 11 commits into from
Jul 15, 2024

Conversation

bryanchriswhite
Copy link
Contributor

@bryanchriswhite bryanchriswhite commented Jul 10, 2024

Summary

  • Leverages the sessionEndHeight index of claims to optimize the querying of expiring claims.
  • Fixes a bug in GetEarliestSupplierClaimCommitHeight() and GetEarliestSupplierProofCommitHeight() by eliminating incorrect and redundant functions GetClaimWindowSizeBlocks() and GetProofWindowSizeBlocks()

Issue

Type of change

Select one or more:

  • New feature, functionality or library
  • Bug fix
  • Code health or cleanup
  • Documentation
  • Other (specify)

Testing

Documentation changes (only if making doc changes)

  • make docusaurus_start; only needed if you make doc changes

Local Testing (only if making code changes)

  • Unit Tests: make go_develop_and_test
  • LocalNet E2E Tests: make test_e2e
  • See quickstart guide for instructions

PR Testing (only if making code changes)

  • DevNet E2E Tests: Add the devnet-test-e2e label to the PR.
    • THIS IS VERY EXPENSIVE, so only do it after all the reviews are complete.
    • Optionally run make trigger_ci if you want to re-trigger tests without any code changes
    • If tests fail, try re-running failed tests only using the GitHub UI as shown here

Sanity Checklist

  • I have tested my changes using the available tooling
  • I have commented my code
  • I have performed a self-review of my own code; both comments & source code
  • I create and reference any new tickets, if applicable
  • I have left TODOs throughout the codebase, if applicable

Summary by CodeRabbit

  • New Features

    • Introduced SessionKeeper for improved session handling within the tokenomics module.
    • Enhanced SettlePendingClaims function to handle errors, include shared parameters, and use pagination for claim retrieval.
  • Refactor

    • Integrated session-related calculations directly within methods, streamlining the logic.
    • Updated module inputs to include SessionKeeper in initialization functions.
  • Bug Fixes

    • Improved error handling for retrieving and settling claims, increasing reliability and efficiency.

@bryanchriswhite bryanchriswhite added on-chain On-chain business logic code health Cleans up some code labels Jul 10, 2024
@bryanchriswhite bryanchriswhite self-assigned this Jul 10, 2024
Copy link

coderabbitai bot commented Jul 10, 2024

Walkthrough

The changes integrate a session keeper into the tokenomics module, refactor window size calculations in shared sessions, and improve error handling and efficiency in settling pending claims. This involves modifying several structs and functions to include and utilize the new session keeper dependency, impacting how claims and proofs are managed.

Changes

File Change Summary
testutil/keeper/tokenomics.go Added a mock for session keeper and passed it to NewKeeper and NewTokenomicsModuleKeepers functions, introducing a session handling dependency in the tokenomics module.
x/shared/session.go Refactored window size calculations by integrating them into methods of sharedParams, removing redundant functions.
x/shared/session_test.go Updated tests to use the new methods from sharedParams for claim and proof window size blocks calculation.
x/tokenomics/keeper/keeper.go Added sessionKeeper and sharedQuerier fields to the Keeper struct, included sessionKeeper parameter in NewKeeper, and initialized sharedQuerier.
x/tokenomics/keeper/settle_pending_claims.go Enhanced SettlePendingClaims function with error handling and pagination for retrieving claims, refactored the logic for improved efficiency.
x/tokenomics/module/module.go Added SessionKeeper to the ModuleInputs struct and updated ProvideModule function to include SessionKeeper as an argument.
x/tokenomics/types/expected_keepers.go Added the SessionKeeper interface with methods GetSession, GetBlockHash, StoreBlockHash, and updated mock generation command to include SessionKeeper.

Poem

Amidst the code where tokens spin,
A session keeper joins within.
Claims and proofs in ordered rows,
With error checks, efficiency grows.
Hooray to changes, clear and bright,
Tokenomics soaring to new height!


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

The CI will now also run the e2e tests on devnet, which increases the time it takes to complete all CI checks.

You may need to run make trigger_ci to submit an empty commit that'll trigger the tests.

GCP workloads (requires changing the namespace to 671)
Grafana network dashboard for devnet-issue-{issue-id}

Copy link

The image is going to be pushed after the next commit.

You can use make trigger_ci to push an empty commit.

If you also want to run E2E tests, please add devnet-test-e2e label.

@bryanchriswhite bryanchriswhite marked this pull request as ready for review July 10, 2024 21:03
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Outside diff range, codebase verification and nitpick comments (1)
x/tokenomics/module/module.go (1)

185-185: Add a comment for the new SessionKeeper field.

To maintain consistency and readability, add a comment explaining the purpose of the new SessionKeeper field in the ModuleInputs struct.

+ // SessionKeeper manages session-related functionalities.
	SessionKeeper     types.SessionKeeper
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between bdbc365 and 47b84bd.

Files selected for processing (8)
  • testutil/integration/app.go (1 hunks)
  • testutil/keeper/tokenomics.go (3 hunks)
  • x/shared/session.go (3 hunks)
  • x/shared/session_test.go (1 hunks)
  • x/tokenomics/keeper/keeper.go (4 hunks)
  • x/tokenomics/keeper/settle_pending_claims.go (3 hunks)
  • x/tokenomics/module/module.go (2 hunks)
  • x/tokenomics/types/expected_keepers.go (4 hunks)
Additional comments not posted (14)
x/tokenomics/keeper/keeper.go (2)

31-33: LGTM! Ensure correct usage of sessionKeeper and sharedQuerier.

The additions of sessionKeeper and sharedQuerier fields in the Keeper struct are approved.

However, ensure that all usages of these fields are correct and consistent throughout the codebase.


47-54: LGTM! Verify the initialization of sharedQuerier.

The initialization of sharedQuerier in the NewKeeper function is approved.

However, ensure that the initialization of sharedQuerier using prooftypes.NewSharedKeeperQueryClient is correct and consistent throughout the codebase.

Verification successful

The initialization of sharedQuerier using prooftypes.NewSharedKeeperQueryClient appears consistently across multiple files. However, to ensure correctness, let's verify the context and parameters in the identified files.


Verified: Initialization of sharedQuerier

The initialization of sharedQuerier using prooftypes.NewSharedKeeperQueryClient is consistent and correct across the codebase. Each instance passes the appropriate parameters (sharedKeeper and sessionKeeper).

  • x/tokenomics/keeper/keeper.go
  • x/proof/keeper/msg_server_submit_proof_test.go
  • x/proof/keeper/keeper.go
  • testutil/integration/app.go
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify correct initialization of `sharedQuerier` using `prooftypes.NewSharedKeeperQueryClient`.

# Test: Search for the initialization of `sharedQuerier`. Expect: Only valid initializations.
rg --type go --word-regexp 'NewSharedKeeperQueryClient'

Length of output: 958


Script:

#!/bin/bash
# Display context around each usage of NewSharedKeeperQueryClient to verify correctness.
rg --type go --word-regexp 'NewSharedKeeperQueryClient' -A 5 -B 5

Length of output: 6114

x/tokenomics/types/expected_keepers.go (2)

43-44: LGTM! Ensure correct implementation of AllClaims method.

The addition of the AllClaims method to the ProofKeeper interface is approved.

However, ensure that the AllClaims method is correctly implemented and used throughout the codebase.

Verification successful

The AllClaims method is implemented and used correctly in the codebase.

The method is defined in the Keeper and used consistently across various modules and tests. Here are the key points:

  • Definition:

    • x/proof/keeper/query_claim.go: func (k Keeper) AllClaims(ctx context.Context, req *types.QueryAllClaimsRequest) (*types.QueryAllClaimsResponse, error)
  • Usage:

    • x/tokenomics/keeper/settle_pending_claims.go
    • x/proof/types/query.pb.gw.go
    • x/proof/types/query.pb.go
    • x/proof/module/query_claim.go
    • Various test files

The implementation and usage of the AllClaims method appear consistent and correct across the codebase.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify correct implementation and usage of `AllClaims` method.

# Test: Search for the implementation of `AllClaims` method. Expect: Only valid implementations.
ast-grep --lang go --pattern $'func ($_).AllClaims($_, $_)'

# Test: Search for the usage of `AllClaims` method. Expect: Only valid usages.
rg --type go --word-regexp 'AllClaims'

Length of output: 4454


60-64: LGTM! Ensure correct implementation of SessionKeeper methods.

The addition of the SessionKeeper interface with methods GetSession, GetBlockHash, and StoreBlockHash is approved.

However, ensure that these methods are correctly implemented and used throughout the codebase.

x/shared/session_test.go (2)

223-224: LGTM! Ensure correct usage of GetProofWindowCloseOffsetBlocks method.

The replacement of GetProofWindowSizeBlocks with GetProofWindowCloseOffsetBlocks method from sharedParams is approved.

However, ensure that the GetProofWindowCloseOffsetBlocks method is correctly used throughout the codebase.

Verification successful

Verified: Correct usage of GetProofWindowCloseOffsetBlocks method.

The method GetProofWindowCloseOffsetBlocks is used correctly throughout the codebase. Each instance appropriately retrieves and uses the ProofWindowCloseOffsetBlocks value.

  • x/shared/types/params.pb.go: Method implementation.
  • x/shared/session_test.go: Test assertions.
  • x/shared/session.go: Calculation of proof window close height and distribution window size.
  • x/tokenomics/keeper/settle_pending_claims.go: Calculation involving block heights.
  • api/poktroll/shared/params.pulsar.go: Method implementation.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify correct usage of `GetProofWindowCloseOffsetBlocks` method.

# Test: Search for the usage of `GetProofWindowCloseOffsetBlocks` method. Expect: Only valid usages.
rg --type go --word-regexp 'GetProofWindowCloseOffsetBlocks'

Length of output: 646


Script:

#!/bin/bash
# Extracting context around usages of GetProofWindowCloseOffsetBlocks

# Extract context in x/shared/types/params.pb.go
echo "Context in x/shared/types/params.pb.go"
rg --type go --word-regexp 'GetProofWindowCloseOffsetBlocks' -A 5 -B 5 x/shared/types/params.pb.go

# Extract context in x/shared/session_test.go
echo "Context in x/shared/session_test.go"
rg --type go --word-regexp 'GetProofWindowCloseOffsetBlocks' -A 5 -B 5 x/shared/session_test.go

# Extract context in x/shared/session.go
echo "Context in x/shared/session.go"
rg --type go --word-regexp 'GetProofWindowCloseOffsetBlocks' -A 5 -B 5 x/shared/session.go

# Extract context in x/tokenomics/keeper/settle_pending_claims.go
echo "Context in x/tokenomics/keeper/settle_pending_claims.go"
rg --type go --word-regexp 'GetProofWindowCloseOffsetBlocks' -A 5 -B 5 x/tokenomics/keeper/settle_pending_claims.go

# Extract context in api/poktroll/shared/params.pulsar.go
echo "Context in api/poktroll/shared/params.pulsar.go"
rg --type go --word-regexp 'GetProofWindowCloseOffsetBlocks' -A 5 -B 5 api/poktroll/shared/params.pulsar.go

Length of output: 3255


220-221: LGTM! Ensure correct usage of GetClaimWindowCloseOffsetBlocks method.

The replacement of GetClaimWindowSizeBlocks with GetClaimWindowCloseOffsetBlocks method from sharedParams is approved.

However, ensure that the GetClaimWindowCloseOffsetBlocks method is correctly used throughout the codebase.

Verification successful

Verify correct usage of GetClaimWindowCloseOffsetBlocks method.

The GetClaimWindowCloseOffsetBlocks method is used in the following files:

  • x/shared/session_test.go
  • x/shared/types/params.pb.go
  • x/shared/session.go
  • x/tokenomics/keeper/settle_pending_claims.go
  • api/poktroll/shared/params.pulsar.go

We need to ensure that this method is used correctly in each of these files.


Verified: Correct usage of GetClaimWindowCloseOffsetBlocks method

The method GetClaimWindowCloseOffsetBlocks is correctly used throughout the codebase in the following files:

  • x/shared/session_test.go
  • x/shared/types/params.pb.go
  • x/shared/session.go
  • x/tokenomics/keeper/settle_pending_claims.go
  • api/poktroll/shared/params.pulsar.go

Each instance adheres to the intended functionality of the method.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify correct usage of `GetClaimWindowCloseOffsetBlocks` method.

# Test: Search for the usage of `GetClaimWindowCloseOffsetBlocks` method. Expect: Only valid usages.
rg --type go --word-regexp 'GetClaimWindowCloseOffsetBlocks'

Length of output: 677


Script:

#!/bin/bash
# Extract surrounding lines for context around the usage of GetClaimWindowCloseOffsetBlocks method.

# Get 10 lines of context before and after the usage of the method for better understanding.
rg --type go --word-regexp 'GetClaimWindowCloseOffsetBlocks' -A 10 -B 10

Length of output: 8220

x/shared/session.go (2)

142-144: LGTM! Ensure correct usage of GetProofWindowCloseOffsetBlocks method.

The replacement of GetProofWindowSizeBlocks with GetProofWindowCloseOffsetBlocks method from sharedParams in GetEarliestSupplierProofCommitHeight is approved.

However, ensure that the GetProofWindowCloseOffsetBlocks method is correctly used throughout the codebase.

Verification successful

The usage of GetProofWindowCloseOffsetBlocks is correct throughout the codebase.

The method is used appropriately in the following files:

  • x/shared/session_test.go
  • x/tokenomics/keeper/settle_pending_claims.go
  • x/shared/session.go

No issues found with the current implementation.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify correct usage of `GetProofWindowCloseOffsetBlocks` method.

# Test: Search for the usage of `GetProofWindowCloseOffsetBlocks` method. Expect: Only valid usages.
rg --type go --word-regexp 'GetProofWindowCloseOffsetBlocks'

Length of output: 646


Script:

#!/bin/bash
# Description: Gather detailed context around each usage of `GetProofWindowCloseOffsetBlocks`

# Get context around the usage in session_test.go
rg --type go --word-regexp 'GetProofWindowCloseOffsetBlocks' -A 5 -B 5 x/shared/session_test.go

# Get context around the usage in settle_pending_claims.go
rg --type go --word-regexp 'GetProofWindowCloseOffsetBlocks' -A 5 -B 5 x/tokenomics/keeper/settle_pending_claims.go

# Get context around the usage in session.go
rg --type go --word-regexp 'GetProofWindowCloseOffsetBlocks' -A 5 -B 5 x/shared/session.go

Length of output: 2213


121-123: LGTM! Ensure correct usage of GetClaimWindowCloseOffsetBlocks method.

The replacement of GetClaimWindowSizeBlocks with GetClaimWindowCloseOffsetBlocks method from sharedParams in GetEarliestSupplierClaimCommitHeight is approved.

However, ensure that the GetClaimWindowCloseOffsetBlocks method is correctly used throughout the codebase.

Verification successful

Verified: Correct usage of GetClaimWindowCloseOffsetBlocks method.

The GetClaimWindowCloseOffsetBlocks method is correctly utilized across the codebase, ensuring consistency and correctness in fetching the ClaimWindowCloseOffsetBlocks parameter.

  • x/tokenomics/keeper/settle_pending_claims.go
  • x/shared/session_test.go
  • x/shared/types/params.pb.go
  • x/shared/session.go
  • api/poktroll/shared/params.pulsar.go
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify correct usage of `GetClaimWindowCloseOffsetBlocks` method.

# Test: Search for the usage of `GetClaimWindowCloseOffsetBlocks` method. Expect: Only valid usages.
rg --type go --word-regexp 'GetClaimWindowCloseOffsetBlocks'

Length of output: 677


Script:

#!/bin/bash
# Description: Verify the context of `GetClaimWindowCloseOffsetBlocks` method usage.

# Display context around the usage in `x/tokenomics/keeper/settle_pending_claims.go`
rg --type go --word-regexp 'GetClaimWindowCloseOffsetBlocks' -A 5 -B 5 x/tokenomics/keeper/settle_pending_claims.go

# Display context around the usage in `x/shared/session_test.go`
rg --type go --word-regexp 'GetClaimWindowCloseOffsetBlocks' -A 5 -B 5 x/shared/session_test.go

# Display context around the usage in `x/shared/types/params.pb.go`
rg --type go --word-regexp 'GetClaimWindowCloseOffsetBlocks' -A 5 -B 5 x/shared/types/params.pb.go

# Display context around the usage in `x/shared/session.go`
rg --type go --word-regexp 'GetClaimWindowCloseOffsetBlocks' -A 5 -B 5 x/shared/session.go

# Display context around the usage in `api/poktroll/shared/params.pulsar.go`
rg --type go --word-regexp 'GetClaimWindowCloseOffsetBlocks' -A 5 -B 5 api/poktroll/shared/params.pulsar.go

Length of output: 2988

x/tokenomics/module/module.go (1)

211-211: LGTM! The new dependency injection is correctly implemented.

The ProvideModule function correctly initializes the sessionKeeper as a new dependency.

x/tokenomics/keeper/settle_pending_claims.go (1)

164-206: Ensure proper pagination handling for getExpiringClaims.

The pagination logic seems correct, but ensure that the Offset is properly managed to avoid infinite loops or missed claims.

testutil/keeper/tokenomics.go (3)

158-160: LGTM! The session keeper mock is correctly added.

The mock for sessionKeeper is correctly added.


171-171: LGTM! The session keeper is correctly integrated.

The sessionKeeper is correctly integrated into the TokenomicsKeeper initialization.


338-338: LGTM! The session keeper is correctly initialized.

The sessionKeeper is correctly initialized in the NewTokenomicsModuleKeepers function.

testutil/integration/app.go (1)

396-396: Ensure the new session keeper is correctly passed and used.

The sessionKeeper parameter is added but ensure it's correctly passed and used.

Verification successful

Ensure the new session keeper is correctly passed and used.

The sessionKeeper parameter is added and correctly used within the testutil/integration/app.go file. The sessionKeeper is instantiated and used as expected in various parts of the file.

  • sessionKeeper is instantiated and used in the following locations:
    • sessionkeeper.NewKeeper
    • sessiontypes.RegisterMsgServer
    • sessiontypes.RegisterQueryServer
    • sessionKeeper.SetParams
    • prooftypes.NewSharedKeeperQueryClient
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of the new `sessionKeeper` parameter.

# Test: Search for the function usage. Expect: Proper passing and usage of `sessionKeeper`.
rg --type go -A 5 'NewCompleteIntegrationApp'

Length of output: 2159


Script:

#!/bin/bash
# Description: Verify the usage of the `sessionKeeper` parameter within the `NewCompleteIntegrationApp` function.

# Test: Search for the `sessionKeeper` variable usage within the `NewCompleteIntegrationApp` function.
rg --type go -A 30 'func NewCompleteIntegrationApp' testutil/integration/app.go | rg 'sessionKeeper'

Length of output: 100


Script:

#!/bin/bash
# Description: Verify the usage of the `sessionKeeper` parameter within the `NewCompleteIntegrationApp` function and the entire file.

# Test: Search for the complete definition of the `NewCompleteIntegrationApp` function.
rg --type go -A 100 'func NewCompleteIntegrationApp' testutil/integration/app.go

# Test: Search for any usage of the `sessionKeeper` within the `testutil/integration/app.go` file.
rg --type go 'sessionKeeper' testutil/integration/app.go

Length of output: 3648

Comment on lines 31 to 34
expiringClaims, err := k.getExpiringClaims(ctx)
if err != nil {
return 0, 0, relaysPerServiceMap, computeUnitsPerServiceMap, err
}
Copy link

Choose a reason for hiding this comment

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

Ensure relaysPerServiceMap and computeUnitsPerServiceMap are initialized before use.

The variables relaysPerServiceMap and computeUnitsPerServiceMap should be initialized before being used in the return statement to avoid potential nil map issues.

	expiringClaims, err := k.getExpiringClaims(ctx)
	if err != nil {
+		relaysPerServiceMap = make(map[string]uint64)
+		computeUnitsPerServiceMap = make(map[string]uint64)
		return 0, 0, relaysPerServiceMap, computeUnitsPerServiceMap, err
	}
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
expiringClaims, err := k.getExpiringClaims(ctx)
if err != nil {
return 0, 0, relaysPerServiceMap, computeUnitsPerServiceMap, err
}
expiringClaims, err := k.getExpiringClaims(ctx)
if err != nil {
relaysPerServiceMap = make(map[string]uint64)
computeUnitsPerServiceMap = make(map[string]uint64)
return 0, 0, relaysPerServiceMap, computeUnitsPerServiceMap, err
}

@bryanchriswhite bryanchriswhite linked an issue Jul 10, 2024 that may be closed by this pull request
15 tasks
x/tokenomics/keeper/settle_pending_claims.go Outdated Show resolved Hide resolved
x/tokenomics/keeper/settle_pending_claims.go Outdated Show resolved Hide resolved
Offset: uint64(len(expiringClaims)),
},
Filter: &prooftypes.QueryAllClaimsRequest_SessionEndHeight{
SessionEndHeight: uint64(previousSessionEndHeight),
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't it be easier to just use SessionNumber for filtering?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure but at the moment we don't have any such index; we have:

 oneof filter {
    string supplier_address= 2;
    string session_id = 3;
    uint64 session_end_height = 4;
  }

Even if we had a session_number index, we would still have to do something more sophistocated than simply currentHeight / num_blocks_per_session. Do you think it's worth adding a TODO_CONSIDERATION or something?

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe.

My concern is about the potential case where the session we want to settle is n-2 or older (relative to the current session).

If claim and proof window offsets do not allow that, then we should be fine, Otherwise we should consider other means to retrieve the session we want to settle.

Copy link
Contributor Author

@bryanchriswhite bryanchriswhite Jul 15, 2024

Choose a reason for hiding this comment

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

This method will be called for each block, progressively "draining" all expiring claims as the current height climbs. Since this is part of consensus, all sessions considered here MUST be from the same, most recently expiring session number.

x/tokenomics/keeper/settle_pending_claims.go Outdated Show resolved Hide resolved
…ation-use-index

* pokt/main:
  [TODOs] refactor: proof path calculation (#659)
  [Dependencies] bump go-getter and ibc-go (#691)
  [Relayminer] refactor: `relayerSessionsManager#waitForBlock()` (#648)
  [Observables] chore: add `ReplayObservable#SubscribeFromLatestBufferedOffset()` (#647)
  [Observability] Add claim relays counter (#644)
  [Code Health] chore: log unused error when updating relay mining difficulty (#683)
  [Testing] chore: uncomment proof CLI query tests (#668)
  build(deps): bump ws from 7.5.9 to 7.5.10 in /docusaurus (#686)
  build(deps): bump webpack-dev-middleware from 5.3.3 to 5.3.4 in /docusaurus (#688)
  build(deps): bump express from 4.18.2 to 4.19.2 in /docusaurus (#687)
  build(deps): bump follow-redirects from 1.15.3 to 1.15.6 in /docusaurus (#685)
  build(deps): bump braces from 3.0.2 to 3.0.3 in /docusaurus (#689)
  [CosmosSDK] Bump to v0.50.7 (#682)
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 47b84bd and 4bc2bb6.

Files selected for processing (1)
  • x/tokenomics/keeper/settle_pending_claims.go (3 hunks)
Files skipped from review as they are similar to previous changes (1)
  • x/tokenomics/keeper/settle_pending_claims.go

Copy link
Contributor

@red-0ne red-0ne left a comment

Choose a reason for hiding this comment

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

Left a comment about session filtering consideration but otherwise, LGTM.

Preemptively approving!

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 4bc2bb6 and 84226fe.

Files selected for processing (3)
  • testutil/keeper/tokenomics.go (3 hunks)
  • x/tokenomics/keeper/settle_pending_claims.go (3 hunks)
  • x/tokenomics/types/expected_keepers.go (4 hunks)
Files skipped from review as they are similar to previous changes (3)
  • testutil/keeper/tokenomics.go
  • x/tokenomics/keeper/settle_pending_claims.go
  • x/tokenomics/types/expected_keepers.go

@bryanchriswhite bryanchriswhite merged commit c25b655 into main Jul 15, 2024
10 checks passed
@bryanchriswhite bryanchriswhite deleted the issues/584/claims/expiration-use-index branch July 15, 2024 18:20
bryanchriswhite added a commit that referenced this pull request Jul 16, 2024
…ation-overserviced

* pokt/main:
  [TODO] Blockers @okdas (#674)
  [TODO_BLOCKER] chore: Remove stale TODO_BLOCKERs (#694)
  [TODO] refactor: query expiring claims w/ index (#671)
  [TODOs] `grace_period_end_offset_blocks` validation & cleanup (#667)
  [Testing] add account balance coverage to account settlement (#670)
  [Application] Auto-undelegation of unstaked gateways (#692)
  [RelayMiner] Fix LeanClient mutiple suppliers support (#662)
bryanchriswhite added a commit that referenced this pull request Jul 16, 2024
…-root

* pokt/main:
  [TODO] Blockers @okdas (#674)
  [TODO_BLOCKER] chore: Remove stale TODO_BLOCKERs (#694)
  [TODO] refactor: query expiring claims w/ index (#671)
  [TODOs] `grace_period_end_offset_blocks` validation & cleanup (#667)
  [Testing] add account balance coverage to account settlement (#670)
  [Application] Auto-undelegation of unstaked gateways (#692)
  [RelayMiner] Fix LeanClient mutiple suppliers support (#662)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code health Cleans up some code devnet devnet-test-e2e on-chain On-chain business logic push-image CI related - pushes images to ghcr.io
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

[TODO] @Olshansk's (and now @Bryan's) Blocker TODOs
2 participants