-
Notifications
You must be signed in to change notification settings - Fork 32
Replay fix for Validator Manager #743
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
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
abi-bindings/go/validator-manager/ERC20TokenStakingManager/ERC20TokenStakingManager.go
Large diffs are not rendered by default.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
abi-bindings/go/validator-manager/NativeTokenStakingManager/NativeTokenStakingManager.go
Large diffs are not rendered by default.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
abi-bindings/go/validator-manager/ValidatorManager/ValidatorManager.go
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,13 @@ import { | |
WarpMessage, | ||
IWarpMessenger | ||
} from "@avalabs/[email protected]/contracts/interfaces/IWarpMessenger.sol"; | ||
import {ACP99Manager, ConversionData, InitialValidator, PChainOwner} from "../ACP99Manager.sol"; | ||
import { | ||
ACP99Manager, | ||
ConversionData, | ||
InitialValidator, | ||
PChainOwner, | ||
ValidatorStatus | ||
} from "../ACP99Manager.sol"; | ||
import {OwnableUpgradeable} from | ||
"@openzeppelin/[email protected]/access/OwnableUpgradeable.sol"; | ||
|
||
|
@@ -279,6 +285,48 @@ abstract contract ValidatorManagerTest is Test { | |
_completeValidatorRemoval(0); | ||
} | ||
|
||
function testReplayValidatorRegistration() public virtual { | ||
bytes32 validationID = _registerDefaultValidator(); | ||
bytes memory setWeightMessage = | ||
ValidatorMessages.packL1ValidatorWeightMessage(validationID, 1, 0); | ||
bytes memory uptimeMessage; | ||
_initiateValidatorRemoval({ | ||
validationID: validationID, | ||
completionTimestamp: DEFAULT_COMPLETION_TIMESTAMP, | ||
setWeightMessage: setWeightMessage, | ||
includeUptime: false, | ||
uptimeMessage: uptimeMessage, | ||
force: false | ||
}); | ||
|
||
bytes memory l1ValidatorRegistrationMessage = | ||
ValidatorMessages.packL1ValidatorRegistrationMessage(validationID, false); | ||
|
||
_mockGetPChainWarpMessage(l1ValidatorRegistrationMessage, true); | ||
|
||
vm.expectEmit(true, true, true, true, address(validatorManager)); | ||
emit CompletedValidatorRemoval(validationID); | ||
|
||
_completeValidatorRemoval(0); | ||
|
||
vm.warp(DEFAULT_EXPIRY - 1); | ||
_beforeSend(_weightToValue(DEFAULT_WEIGHT), address(this)); | ||
|
||
vm.expectRevert( | ||
abi.encodeWithSelector( | ||
ValidatorManager.InvalidValidatorStatus.selector, ValidatorStatus.Completed | ||
) | ||
); | ||
_initiateValidatorRegistration({ | ||
nodeID: DEFAULT_NODE_ID, | ||
blsPublicKey: DEFAULT_BLS_PUBLIC_KEY, | ||
remainingBalanceOwner: DEFAULT_P_CHAIN_OWNER, | ||
disableOwner: DEFAULT_P_CHAIN_OWNER, | ||
registrationExpiry: DEFAULT_EXPIRY, | ||
weight: DEFAULT_WEIGHT | ||
}); | ||
} | ||
|
||
function testCompleteInvalidatedValidation() public { | ||
bytes32 validationID = _setUpInitializeValidatorRegistration( | ||
DEFAULT_NODE_ID, | ||
|
@@ -482,8 +530,9 @@ abstract contract ValidatorManagerTest is Test { | |
uint64 weight, | ||
uint64 registrationExpiry, | ||
bytes memory blsPublicKey | ||
) internal returns (bytes32 validationID) { | ||
(validationID,) = ValidatorMessages.packRegisterL1ValidatorMessage( | ||
) internal returns (bytes32) { | ||
(bytes32 validationID, bytes memory registerL1ValidatorMessage) = ValidatorMessages | ||
.packRegisterL1ValidatorMessage( | ||
Comment on lines
+533
to
+535
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unrelated fix that simplified this code :) |
||
ValidatorMessages.ValidationPeriod({ | ||
nodeID: nodeID, | ||
subnetID: subnetID, | ||
|
@@ -494,19 +543,8 @@ abstract contract ValidatorManagerTest is Test { | |
weight: weight | ||
}) | ||
); | ||
|
||
bytes20 fixedID = _fixedNodeID(nodeID); | ||
(, bytes memory registerL1ValidatorMessage) = ValidatorMessages | ||
.packRegisterL1ValidatorMessage( | ||
ValidatorMessages.ValidationPeriod({ | ||
subnetID: subnetID, | ||
nodeID: nodeID, | ||
blsPublicKey: blsPublicKey, | ||
registrationExpiry: registrationExpiry, | ||
remainingBalanceOwner: DEFAULT_P_CHAIN_OWNER, | ||
disableOwner: DEFAULT_P_CHAIN_OWNER, | ||
weight: weight | ||
}) | ||
); | ||
vm.warp(registrationExpiry - 1); | ||
_mockSendWarpMessage(registerL1ValidatorMessage, bytes32(0)); | ||
|
||
|
@@ -524,6 +562,8 @@ abstract contract ValidatorManagerTest is Test { | |
registrationExpiry: registrationExpiry, | ||
weight: weight | ||
}); | ||
|
||
return validationID; | ||
} | ||
|
||
function _registerValidator( | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Is this change required for this fix?
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.
Not required, no, but aligns with the value the p-chain uses.