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

[Tokenomics] Harden settlement (part 1: TLM isolation) #889

Open
wants to merge 176 commits into
base: main
Choose a base branch
from

Conversation

bryanchriswhite
Copy link
Contributor

@bryanchriswhite bryanchriswhite commented Oct 22, 2024

Summary

Refactors claim settlement and token logic module processing:

  • Isolates TLM processors from the tokenomics keeper
  • Restructures settlement and TLM processing to avoid non-determinism
  • Consolidates and postpones ALL state modification until the end of settlement

Issue

Type of change

Select one or more from the following:

Testing

  • Documentation: make docusaurus_start; only needed if you make doc changes
  • Unit Tests: make go_develop_and_test
  • LocalNet E2E Tests: make test_e2e
  • DevNet E2E Tests: Add the devnet-test-e2e label to the PR.

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

@bryanchriswhite bryanchriswhite added on-chain On-chain business logic code health Cleans up some code devnet-test-e2e tokenomics Token Economics - what else do you need? labels Oct 22, 2024
@bryanchriswhite bryanchriswhite self-assigned this Oct 22, 2024
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 889)
Grafana network dashboard for devnet-issue-889

@github-actions github-actions bot added devnet push-image CI related - pushes images to ghcr.io labels Oct 22, 2024
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit

linter-name (fail-on-found)

x/tokenomics/token_logic_module/result.go|76 col 4| // TODO_IN_THIS_COMMIT: godoc...
x/tokenomics/token_logic_module/result.go|88 col 4| // TODO_IN_THIS_COMMIT: godoc...
x/tokenomics/token_logic_module/result.go|93 col 4| // TODO_IN_THIS_COMMIT: godoc...
x/tokenomics/token_logic_module/result.go|98 col 4| // TODO_IN_THIS_COMMIT: godoc...
x/tokenomics/token_logic_module/result.go|103 col 4| // TODO_IN_THIS_COMMIT: godoc...
x/tokenomics/token_logic_module/result.go|108 col 4| // TODO_IN_THIS_COMMIT: godoc...
x/tokenomics/token_logic_module/result.go|113 col 4| // TODO_IN_THIS_COMMIT: godoc... use for determinstic loops
x/tokenomics/token_logic_module/result.go|118 col 4| // TODO_IN_THIS_COMMIT: godoc...
x/tokenomics/token_logic_module/result.go|123 col 4| // TODO_IN_THIS_COMMIT: godoc...
x/tokenomics/token_logic_module/result.go|128 col 4| // TODO_IN_THIS_COMMIT: godoc...
x/tokenomics/token_logic_module/result.go|133 col 4| // TODO_IN_THIS_COMMIT: godoc...
x/tokenomics/token_logic_module/result.go|138 col 4| // TODO_IN_THIS_COMMIT: godoc...
x/tokenomics/token_logic_module/result.go|152 col 4| // TODO_IN_THIS_COMMIT: godoc...
x/tokenomics/token_logic_module/result.go|166 col 4| // TODO_IN_THIS_COMMIT: godoc...
x/tokenomics/token_logic_module/result.go|172 col 4| // TODO_IN_THIS_COMMIT: godoc...
x/tokenomics/token_logic_module/result.go|180 col 4| // TODO_IN_THIS_COMMIT: godoc...
x/tokenomics/token_logic_module/result.go|188 col 4| // TODO_IN_THIS_COMMIT: godoc... use for determinstic loops
x/tokenomics/token_logic_module/result.go|196 col 4| // TODO_IN_THIS_COMMIT: godoc... // SHOULD NEVER be used for loops
x/tokenomics/token_logic_module/result.go|213 col 4| // TODO_IN_THIS_COMMIT: godoc... // SHOULD NEVER be used for loops

x/tokenomics/keeper/settle_pending_claims.go Outdated Show resolved Hide resolved
x/tokenomics/keeper/settle_pending_claims.go Outdated Show resolved Hide resolved
x/tokenomics/keeper/settle_pending_claims.go Outdated Show resolved Hide resolved
x/tokenomics/keeper/settle_pending_claims.go Outdated Show resolved Hide resolved
x/tokenomics/keeper/settle_pending_claims.go Outdated Show resolved Hide resolved
x/tokenomics/token_logic_module/result.go Outdated Show resolved Hide resolved
x/tokenomics/token_logic_module/result.go Outdated Show resolved Hide resolved
x/tokenomics/token_logic_module/result.go Outdated Show resolved Hide resolved
x/tokenomics/token_logic_module/result.go Outdated Show resolved Hide resolved
x/tokenomics/token_logic_module/result.go Outdated Show resolved Hide resolved
@bryanchriswhite bryanchriswhite linked an issue Oct 23, 2024 that may be closed by this pull request
6 tasks
testutil/keeper/tokenomics.go Outdated Show resolved Hide resolved
testutil/integration/options.go Outdated Show resolved Hide resolved
tests/integration/tokenomics/token_logic_modules_test.go Outdated Show resolved Hide resolved
x/tokenomics/token_logic_module/result.go Outdated Show resolved Hide resolved
x/tokenomics/token_logic_module/result.go Outdated Show resolved Hide resolved
x/tokenomics/token_logic_module/result.go Outdated Show resolved Hide resolved
x/tokenomics/token_logic_module/result.go Outdated Show resolved Hide resolved
x/tokenomics/token_logic_module/result.go Outdated Show resolved Hide resolved
x/tokenomics/token_logic_module/result.go Outdated Show resolved Hide resolved
x/tokenomics/token_logic_module/result.go Outdated Show resolved Hide resolved
testutil/sample/sample.go Outdated Show resolved Hide resolved
testutil/sample/sample.go Outdated Show resolved Hide resolved
testutil/sample/sample.go Outdated Show resolved Hide resolved
tests/integration/tokenomics/token_logic_modules_test.go Outdated Show resolved Hide resolved
tests/integration/tokenomics/token_logic_modules_test.go Outdated Show resolved Hide resolved
tests/integration/tokenomics/token_logic_modules_test.go Outdated Show resolved Hide resolved
tests/integration/tokenomics/token_logic_modules_test.go Outdated Show resolved Hide resolved
tests/integration/tokenomics/token_logic_modules_test.go Outdated Show resolved Hide resolved
x/tokenomics/token_logic_module/distribution.go Outdated Show resolved Hide resolved
x/tokenomics/token_logic_module/global_mint.go Outdated Show resolved Hide resolved
config.yml Outdated Show resolved Hide resolved
@bryanchriswhite bryanchriswhite marked this pull request as ready for review November 18, 2024 13:11
x/tokenomics/types/settlement_result.go Outdated Show resolved Hide resolved

// GetNumComputeUnits returns the number of claimed compute units in the result's claim.
func (r *SettlementResult) GetNumComputeUnits() (uint64, error) {
return r.Claim.GetNumClaimedComputeUnits()
Copy link
Member

Choose a reason for hiding this comment

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

OPTIONAL NIT (here and below):

if r.Claim == nil {
    return 0, fmt.Errorf("Claim is nil in SettlementResult")
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

#Claim is not a pointer.

proto/poktroll/tokenomics/types.proto Outdated Show resolved Hide resolved
proto/poktroll/tokenomics/types.proto Outdated Show resolved Hide resolved
proto/poktroll/tokenomics/types.proto Outdated Show resolved Hide resolved
logger.Error(fmt.Sprintf("error slashing supplier %s: %s", expiredResult.GetSupplierOperatorAddr(), err))
return err
}
//}
Copy link
Member

Choose a reason for hiding this comment

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

rm

x/tokenomics/keeper/settle_pending_claims.go Outdated Show resolved Hide resolved
//slices.Sort(expiredClaimSupplierOperatorAddresses)
//for _, supplierOperatorAddress := range expiredClaimSupplierOperatorAddresses {
// slashingCount := supplierToExpiredClaimCount[supplierOperatorAddress]
if err := k.slashSupplierStake(ctx, expiredResult, expiredResult.GetSupplierOperatorAddr()); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

Why not just pass expiredResult and that's it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for calling this out! 🙌

I think this was an incomplete refactor. This PR has gotten quite large and has been around for a bit. 😅 🎂 ➕

x/tokenomics/keeper/settle_pending_claims.go Outdated Show resolved Hide resolved
if err := k.bankKeeper.SendCoinsFromModuleToModule(ctx, suppliertypes.ModuleName, tokenomicstypes.ModuleName, cosmostypes.NewCoins(totalSlashingCoin)); err != nil {
return err
}
//if err := k.bankKeeper.SendCoinsFromModuleToModule(ctx, suppliertypes.ModuleName, tokenomicstypes.ModuleName, cosmostypes.NewCoins(slashingCoin)); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

rm

bryanchriswhite and others added 5 commits November 18, 2024 23:16
* pokt/main:
  [C&P] Populate NumEstimatedComputeUnits and ClaimedUpokt of Claim and Proof events (#927)
  [Tokenomics] feat: add `dao_reward_address` param to tokenomics module (#922)
* todo_beta/upnext:
  [C&P] Populate NumEstimatedComputeUnits and ClaimedUpokt of Claim and Proof events (#927)
  [Tokenomics] feat: add `dao_reward_address` param to tokenomics module (#922)
  chore: review feedback improvements
  chore: review feedback improvements
  [Service] Return the default RelayMinerDifficuly for services that have none. (#926)
  [Upgrade] Alpha TestNet v0.0.10 upgrade (#894)
  Update reviewdog.yml
…tlement

* pokt/main:
  [Tokenomics] Consolidate `mint_allocation_<actor>` params & CLI cleanup (#923)
@bryanchriswhite bryanchriswhite changed the base branch from todo_beta/upnext to main November 19, 2024 00:05
@bryanchriswhite bryanchriswhite added the consensus-breaking IMPORTANT! If the PR with this tag is merged, next release WILL HAVE TO BE an upgrade. label Nov 19, 2024
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 consensus-breaking IMPORTANT! If the PR with this tag is merged, next release WILL HAVE TO BE an upgrade. devnet devnet-test-e2e on-chain On-chain business logic push-image CI related - pushes images to ghcr.io tokenomics Token Economics - what else do you need?
Projects
Status: 👀 In review
Development

Successfully merging this pull request may close these issues.

[Tokenomics] Settlement safety
3 participants