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

ValidatorManager is PoA when deployed on its own #711

Merged

Conversation

cam-schultz
Copy link
Contributor

@cam-schultz cam-schultz commented Jan 29, 2025

Why this should be merged

To implement a multi contract validator manager, ValidatorManager functions that modify validator state are restricted to the "specialization" contract (e.g. PoSValidatorManager) via an onlyAdmin modifier. This is identical to how OpenZeppelin Ownable contracts work, which is the only meaningful logic contained in PoAValidatorManager. Given these similarities, folding the PoA use case into ValidatorManager directly is the simpler approach.

One consequence of this design is that in the PoA case, only the admin may deliver ICM messages to complete validator registration or removal. This can of course be worked around, but I'm not convinced this is a use case worth supporting, since permissionless interaction with a PoA contract is antithetical.

How this works

Removes PoAValidatorManager and modifies ValidatorManager to implement OwnableUpgradeable.

How this was tested

Updated e2e subnet conversion flow to support `

  • deploying a standalone ValidatorManager (i.e. PoA)
  • converting to PoS by deploying a separate PoS contract, and setting that as the ValidatorManager's owner

How is this documented

Updated README and class diagrams

@@ -53,12 +53,11 @@
*
* @custom:security-contact https://github.com/ava-labs/icm-contracts/blob/main/SECURITY.md
*/
contract ValidatorManager is Initializable, ContextUpgradeable, ACP99Manager {
contract ValidatorManager is Initializable, OwnableUpgradeable, ACP99Manager {

Check notice

Code scanning / Semgrep OSS

Semgrep Finding: solidity.best-practice.use-ownable2step.use-ownable2step Note

By demanding that the receiver of the owner permissions actively accept via a contract call of its own, Ownable2Step and Ownable2StepUpgradeable prevent the contract ownership from accidentally being transferred to an address that cannot handle it.
Copy link
Contributor

@iansuvak iansuvak left a comment

Choose a reason for hiding this comment

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

I really like this simplification -- even if the majority of the deletion delta is from the .sol and bindings, I think it also makes it simpler to explain and being able to verbally distinguish between "staking manager" and "validator manager' without the "validator manager" term being overloaded.

Copy link
Contributor

@iansuvak iansuvak left a comment

Choose a reason for hiding this comment

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

I really like this simplification -- even if the majority of the deletion delta is from the .sol and bindings, I think it also makes it simpler to explain and being able to verbally distinguish between "staking manager" and "validator manager' without the "validator manager" term being overloaded.

@cam-schultz
Copy link
Contributor Author

verbally distinguish between "staking manager" and "validator manager"

To solidify that, I renamed PoSValidatorManager to StakingManager. Not only does that emphasize the separation from ValidatorManager, it emphasizes the relationship between it and ERC20TokenStakingManager/NativeTokenStakingManager.

Copy link
Contributor

@iansuvak iansuvak left a comment

Choose a reason for hiding this comment

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

This is actually a comment in my draft that I can drop now from the main separation PR. I was happy to wait until the big one is merged to suggest it but I agree that now is as good a time as any!

It's also more accurate since it no longer handles validator state updates just stake related ones.

Copy link
Contributor

@bernard-avalabs bernard-avalabs left a comment

Choose a reason for hiding this comment

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

Generally makes sense to me.

@cam-schultz cam-schultz merged commit 1a13fa0 into acp-99-reference-impl-multi-contract Jan 31, 2025
12 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants