-
Notifications
You must be signed in to change notification settings - Fork 29
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
ACP 99 reference implementation #700
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just leaving as a comment review. All looks pretty good
This reverts commit 2804658.
_initiateValidatorRemoval(validationID); | ||
Validator memory validator = getValidator(validationID); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The order of these calls matters, since _initiateValidatorRemoval
modifies the Validator
. I removed the Validator
return value from the ACP99Manager
interface since it was not strictly necessary, and can otherwise be accessed like it is here. If the internal ACP99Manager
functions do return a Validator
, it increases the ERC20TokenStakingManager
contract size by ~900 bytes, surpassing the size limit.
I settled on adding a @dev
comment to the ValidatorManager
implementation of these methods to warn developers that this function mutates accessible state.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should probably add a little blurb inline here.
// order matters for the next two lines, see...
Then reference an explanation somewhere? Ideally in a github permalink or something else that is guaranteed not to change. That is unless you can make the comment succinct, haha (I can't).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that a blurb should be added. I think it would be difficult for someone to discover the ordering constraint here without one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a comment above the call to getValidator
here. I also added a @dev
natspec comment to all of the methods in ValidatorManager
that touch the internal validator state.
_initiateValidatorRemoval(validationID); | ||
Validator memory validator = getValidator(validationID); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should probably add a little blurb inline here.
// order matters for the next two lines, see...
Then reference an explanation somewhere? Ideally in a github permalink or something else that is guaranteed not to change. That is unless you can make the comment succinct, haha (I can't).
There was a problem hiding this 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.
_initiateValidatorRemoval(validationID); | ||
Validator memory validator = getValidator(validationID); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that a blurb should be added. I think it would be difficult for someone to discover the ordering constraint here without one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
_initiateValidatorRemoval(validationID); | ||
|
||
// The validator must be fetched after the removal has been initiated, since the above call modifies | ||
// the validator's state. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
function _fixedNodeID(bytes memory nodeID) private pure returns (bytes20) { | ||
bytes20 fixedID; | ||
// solhint-disable-next-line no-inline-assembly | ||
assembly { | ||
fixedID := mload(add(nodeID, 32)) | ||
} | ||
return fixedID; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
tests/utils/validator_manager.go
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Excited to have the reference implementation merged and it's an improvement over the current in comments and function naming as well 👍
Why this should be merged
Implements ACP-99 as described in avalanche-foundation/ACPs#170
How this works
Adds
ACP99Manager
to the class hierarchy,.ValidatorManager
implementsACP99Manager
.How this was tested
CI, fixed breaking tests
How is this documented
Updates README to point to ACP-99
Future work
The following items are candidates to be included in this PR. They may also be deferred to later changes.
IValidatorManager
altogether, asACP99Manager
does the same job of defining the core validator manager functionalityinitialize*
methods toinitiate*
to match ACP-99.initialize
is a misnomer, since nothing is initialized as part of these function calls. Rather, theyinitiate
the process of registering/modifying a validator.