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

[staking] use object id to identify a staking pool instead of validator address #8371

Merged
merged 1 commit into from
Feb 26, 2023

Conversation

emmazzz
Copy link
Contributor

@emmazzz emmazzz commented Feb 17, 2023

Since we may make validator account pubkey rotatable and thus validator address changeable, it makes sense to use staking pool's object id to identify a staking pool instead.

@vercel
Copy link

vercel bot commented Feb 17, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated
explorer ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Feb 26, 2023 at 6:16AM (UTC)
explorer-storybook ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Feb 26, 2023 at 6:16AM (UTC)
frenemies ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Feb 26, 2023 at 6:16AM (UTC)
wallet-adapter ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Feb 26, 2023 at 6:16AM (UTC)

@vercel vercel bot temporarily deployed to Preview – wallet-adapter February 20, 2023 23:42 Inactive
@vercel vercel bot temporarily deployed to Preview – explorer-storybook February 20, 2023 23:43 Inactive
@vercel vercel bot temporarily deployed to Preview – frenemies February 20, 2023 23:43 Inactive
@vercel vercel bot temporarily deployed to Preview – wallet-adapter February 22, 2023 04:52 Inactive
@vercel vercel bot temporarily deployed to Preview – explorer-storybook February 22, 2023 04:52 Inactive
@vercel vercel bot temporarily deployed to Preview – frenemies February 22, 2023 04:53 Inactive
Copy link
Contributor

@tzakian tzakian left a comment

Choose a reason for hiding this comment

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

Overall looks good! Just the one question around the removal of starting_epoch in the StakingPool, and possibly a new test is needed to make sure the staking_pool_mapping is updated correctly is needed before landing.

Not sure what the process is if this is a breaking change but I'm sure you know what it is if there is one, so please land responsibly :)

validator_address: address,
/// The epoch at which this pool started operating. Should be the epoch at which the validator became active.
starting_epoch: u64,
struct StakingPool has key, store {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason for the starting_epoch to also be removed here? It seems like something we'd want to keep in but I'm probably misunderstanding something :) Was the tuple of (address, u64) being used as some kind of UID for the staking pool before this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It does look like the starting_epoch needs to be kept because wallet / explorer depends on it to calculate APY. I'm adding it back.

Was the tuple of (address, u64) being used as some kind of UID for the staking pool before this?

yup

@@ -193,7 +193,6 @@ module sui::delegation_tests {
assert!(vector::length(&staked_sui_ids) == 1, 0);
let staked_sui = test_scenario::take_from_sender_by_id(scenario, *vector::borrow(&staked_sui_ids, 0));
assert!(staking_pool::staked_sui_amount(&staked_sui) == 50, 0);
assert!(staking_pool::validator_address(&staked_sui) == VALIDATOR_ADDR_2, 0);
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: can/should this assertion be replaced with a check that the validator address in the staking_pool_mappings in the ValidatorSet object is equal to VALIDATOR_ADDR_2?

More generally, are there any tests that should have the additional check about the correctness of the staking_pool_mapping? If not it may be worthwhile writing one to make sure that it stays in-synch.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Absolutely. I'm working on testing now.

({ fields }) =>
fields.delegation_staking_pool.fields.validator_address ===
validatorAddress
({ fields }) => fields.delegation_staking_pool.fields.id.id === pool_id
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Jibz1 does this look okay?

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we derive the validator meta data from the staking pool id?

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 added a Table staking_pool_mappings storing mappings from staking pool id to validator address so I think the answer is yes. It uses dynamic fields though.

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 see there are a few other places where validator_address is being used so I'm keeping it in the staked sui for now. We can work on removing these usages.

@vercel vercel bot temporarily deployed to Preview – explorer-storybook February 25, 2023 23:27 Inactive
@vercel vercel bot temporarily deployed to Preview – explorer-storybook February 25, 2023 23:54 Inactive
@vercel vercel bot temporarily deployed to Preview – wallet-adapter February 25, 2023 23:54 Inactive
@vercel vercel bot temporarily deployed to Preview – explorer-storybook February 26, 2023 04:43 Inactive
@vercel vercel bot temporarily deployed to Preview – wallet-adapter February 26, 2023 04:44 Inactive
@vercel vercel bot temporarily deployed to Preview – wallet-adapter February 26, 2023 05:29 Inactive
@vercel vercel bot temporarily deployed to Preview – explorer-storybook February 26, 2023 05:30 Inactive
@vercel vercel bot temporarily deployed to Preview – explorer-storybook February 26, 2023 05:33 Inactive
@vercel vercel bot temporarily deployed to Preview – wallet-adapter February 26, 2023 05:33 Inactive
@vercel vercel bot temporarily deployed to Preview – wallet-adapter February 26, 2023 06:15 Inactive
@vercel vercel bot temporarily deployed to Preview – explorer-storybook February 26, 2023 06:16 Inactive
@emmazzz emmazzz merged commit 5c3b00c into MystenLabs:main Feb 26, 2023
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.

3 participants