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

[Application] feat: Add past delegation proofs #518

Merged
merged 17 commits into from
May 15, 2024

Conversation

red-0ne
Copy link
Contributor

@red-0ne red-0ne commented May 6, 2024

Summary

This PR adds support for old delegations verification by:

  • Update Application proto to add undelegations map
  • Adding a map of session end block heights to undelegations updated at undelegation time
  • EndBlocker procedure that prunes old delegations past a retention time
  • Pass in target block height to the ring client to generate the right gateway list at the provided block height
  • Fix ring cache invalidation
  • Fix the block hash used to generate the proof
  • Fix account querier returning account with nil pub keys (accounts created at genesis time)
  • Remove unused pubkey client code

1129 LOC out of 1314 are autogenerated pulsar code

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

@Olshansk
Copy link
Member

Olshansk commented May 7, 2024

@red-0ne Confirming that this is not ready for initial review yet. Right?

@red-0ne red-0ne marked this pull request as ready for review May 8, 2024 09:15
@red-0ne
Copy link
Contributor Author

red-0ne commented May 8, 2024

@red-0ne Confirming that this is not ready for initial review yet. Right?

It is, just lacking E2E tests from the previous PR to be ported to this one

@Olshansk Olshansk added the protocol General core protocol related changes label May 8, 2024
@Olshansk Olshansk added this to the Shannon Public TestNet milestone May 8, 2024
Copy link
Member

@Olshansk Olshansk left a comment

Choose a reason for hiding this comment

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

@red-0ne Please do the following:

  1. See my comments. Even if they're outdated (based on code), PTAL at all of them
  2. Review my commit in 82abcc8 (#518). Note the comments I made and the var changes I made.
  3. Let's make the same changes as in (2) everywhere across the PR
  4. Please respond to my comments in (1)
  5. Re-request the review (even if it's still not complete) once I can start taking a look at what we have.

Other than that, love how much simpler this is!

x/application/keeper/prune_undelegations.go Outdated Show resolved Hide resolved
x/application/keeper/msg_server_undelegate_from_gateway.go Outdated Show resolved Hide resolved
proto/poktroll/application/application.proto Outdated Show resolved Hide resolved
x/application/keeper/msg_server_undelegate_from_gateway.go Outdated Show resolved Hide resolved
@red-0ne red-0ne requested a review from Olshansk May 9, 2024 18:12
x/application/keeper/prune_undelegations.go Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
pkg/crypto/rings/client.go Outdated Show resolved Hide resolved
// that have been undelegated after the target session end height.
func GetRingAddressesAtBlock(app *apptypes.Application, blockHeight int64) []string {
// Get the target session end height at which we want to get the active delegations.
targetSessionEndHeight := uint64(sessionkeeper.GetSessionEndBlockHeight(blockHeight))
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to take grace period into account here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Grace period as a special block count/height interval, should not be taken into account.

Getting the delegatee gateway addresses when in a session's grace period effectively involves looking past SessionGracePeriod number of sessions, so all it needs is that the pending undelegations are not pruned which is ensured by GetNumBlocksUndelegationRetention.

Copy link
Member

Choose a reason for hiding this comment

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

Does this implicitly assume that GetNumBlocksUndelegationRetention > SessionGracePeriod?

Copy link
Contributor Author

@red-0ne red-0ne May 14, 2024

Choose a reason for hiding this comment

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

Yes, pruning is guarenteed to be >= SessionGracePeriod

func GetNumBlocksUndelegationRetention() int64 {
	return sessionkeeper.GetSessionGracePeriodBlockCount() +
		(sessionkeeper.NumBlocksPerSession * NumSessionsAppToGatewayUndelegationRetention)
}

x/application/keeper/application_test.go Outdated Show resolved Hide resolved
pkg/crypto/rings/client.go Outdated Show resolved Hide resolved
@red-0ne red-0ne requested a review from Olshansk May 13, 2024 11:00
Makefile Outdated Show resolved Hide resolved
pkg/crypto/rings/client.go Outdated Show resolved Hide resolved
Copy link
Contributor

@bryanchriswhite bryanchriswhite left a comment

Choose a reason for hiding this comment

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

Nice one @red-0ne! 😎

I have to take a break on this for now but I'm almost to the end:
image

Great comments! 💪

pkg/crypto/rings/client.go Outdated Show resolved Hide resolved
pkg/crypto/rings/client.go Outdated Show resolved Hide resolved
pkg/crypto/rings/client.go Outdated Show resolved Hide resolved
pkg/crypto/rings/client.go Outdated Show resolved Hide resolved
pkg/crypto/rings/client.go Outdated Show resolved Hide resolved
x/application/keeper/msg_server_undelegate_from_gateway.go Outdated Show resolved Hide resolved
proto/poktroll/application/application.proto Show resolved Hide resolved
Copy link
Member

@Olshansk Olshansk left a comment

Choose a reason for hiding this comment

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

Please see my last two comments but pre-emtively approving.

Makefile Outdated Show resolved Hide resolved
proto/poktroll/application/application.proto Show resolved Hide resolved
Copy link
Contributor

@bryanchriswhite bryanchriswhite left a comment

Choose a reason for hiding this comment

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

💯

@red-0ne red-0ne added application Changes related to the Application actor gateway Changes related to the Gateway actor devnet-test-e2e labels May 15, 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. If you just created a pull request, you might need to push another commit to produce a container image DevNet can utilize to spin up infrastructure. You can use make trigger_ci to push an empty commit.

@github-actions github-actions bot added devnet push-image CI related - pushes images to ghcr.io labels May 15, 2024
@red-0ne red-0ne merged commit 5dcf69f into main May 15, 2024
10 checks passed
@bryanchriswhite bryanchriswhite removed push-image CI related - pushes images to ghcr.io devnet-test-e2e labels May 16, 2024
@Olshansk Olshansk deleted the feat/past-delegation-proofs branch May 29, 2024 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
application Changes related to the Application actor gateway Changes related to the Gateway actor protocol General core protocol related changes
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

None yet

3 participants