Skip to content

Commit

Permalink
Bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
geoff-vball committed Nov 28, 2024
1 parent 557facd commit 7a812ad
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 33 deletions.
2 changes: 1 addition & 1 deletion contracts/validator-manager/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ Disabled L1 validators can re-activate at any time by increasing their balance w
### (PoS only) Remove a Delegator

Delegators removal may be initiated by calling `initializeEndDelegation`, as long as churn restrictions are not violated. Similar to `initializeEndValidation`, an uptime proof may be provided to be used to determine delegator rewards eligibility. If no proof is provided, the latest known uptime will be used (see [(PoS only) Submit and Uptime Proof](#pos-only-submit-an-uptime-proof)). The validator's weight is updated on the P-Chain by the same mechanism used to register a delegator. The `SubnetValidatorWeightUpdateMessage` from the P-Chain is delivered to the `PoSValidatorManager` in the call to `completeEndDelegation`.
Delegators removal may be initiated by calling `initializeEndDelegation`, as long as churn restrictions are not violated. Similar to `initializeEndValidation`, an uptime proof may be provided to be used to determine delegator rewards eligibility. If no proof is provided, the latest known uptime will be used (see [(PoS only) Submit and Uptime Proof](#pos-only-submit-an-uptime-proof)). The validator's weight is updated on the P-Chain by the same mechanism used to register a delegator. The `L1ValidatorWeightMessage` from the P-Chain is delivered to the `PoSValidatorManager` in the call to `completeEndDelegation`.

Either the delegator owner or the validator owner may initiate removing a delegator. This is to prevent the validator from being unable to remove itself due to churn limitations if it is has too high a proportion of the Subnet's total weight due to delegator additions. The validator owner may only remove Delegators after the minimum stake duration has elapsed.

Expand Down
38 changes: 19 additions & 19 deletions contracts/validator-manager/tests/ValidatorMessagesTests.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ contract ValidatorMessagesTest is Test {
DEFAULT_P_CHAIN_OWNER = PChainOwner({threshold: 1, addresses: addresses});
}

function testSubnetConversionMessageInvalidInputLength() public {
function testSubnetToL1ConversionMessageInvalidInputLength() public {
bytes memory packed =
ValidatorMessages.packSubnetToL1ConversionMessage(DEFAULT_SUBNET_CONVERSION_ID);
// Invalid length
Expand All @@ -47,7 +47,7 @@ contract ValidatorMessagesTest is Test {
ValidatorMessages.unpackSubnetToL1ConversionMessage(invalidPacked);
}

function testSubnetConversionMessageInvalidCodecID() public {
function testSubnetToL1ConversionMessageInvalidCodecID() public {
bytes memory packed =
ValidatorMessages.packSubnetToL1ConversionMessage(DEFAULT_SUBNET_CONVERSION_ID);

Expand All @@ -60,7 +60,7 @@ contract ValidatorMessagesTest is Test {
ValidatorMessages.unpackSubnetToL1ConversionMessage(invalidPacked2);
}

function testSubnetConversionMessageInvalidTypeID() public {
function testSubnetToL1ConversionMessageInvalidTypeID() public {
bytes memory packed =
ValidatorMessages.packSubnetToL1ConversionMessage(DEFAULT_SUBNET_CONVERSION_ID);
// Invalid message type
Expand All @@ -70,7 +70,7 @@ contract ValidatorMessagesTest is Test {
ValidatorMessages.unpackSubnetToL1ConversionMessage(invalidPacked3);
}

function testRegisterSubnetValidatorMessageInvalidBLSKey() public {
function testRegisterL1ValidatorMessageInvalidBLSKey() public {
vm.expectRevert(ValidatorMessages.InvalidBLSPublicKey.selector);
// 47 bytes
bytes memory invalidBLSKey = bytes(
Expand All @@ -89,7 +89,7 @@ contract ValidatorMessagesTest is Test {
);
}

function testRegisterSubnetValidatorMessageInvalidInputLength() public {
function testRegisterL1ValidatorMessageInvalidInputLength() public {
bytes memory packed = _getPackedRegisterL1ValidatorMessage();
// Invalid length
bytes memory invalidPacked = new bytes(packed.length - 1);
Expand All @@ -104,7 +104,7 @@ contract ValidatorMessagesTest is Test {
ValidatorMessages.unpackRegisterL1ValidatorMessage(invalidPacked);
}

function testRegisterSubnetValidatorMessageInvalidCodecID() public {
function testRegisterL1ValidatorMessageInvalidCodecID() public {
bytes memory packed = _getPackedRegisterL1ValidatorMessage();

// Invalid codec ID
Expand All @@ -116,7 +116,7 @@ contract ValidatorMessagesTest is Test {
ValidatorMessages.unpackRegisterL1ValidatorMessage(invalidPacked2);
}

function testRegisterSubnetValidatorMessageInvalidTypeID() public {
function testRegisterL1ValidatorMessageInvalidTypeID() public {
bytes memory packed = _getPackedRegisterL1ValidatorMessage();

// Invalid message type
Expand All @@ -126,7 +126,7 @@ contract ValidatorMessagesTest is Test {
ValidatorMessages.unpackRegisterL1ValidatorMessage(invalidPacked3);
}

function testSubnetValidatorRegistrationMessageInvalidInputLength() public {
function testL1ValidatorRegistrationMessageInvalidInputLength() public {
bytes memory packed =
ValidatorMessages.packL1ValidatorRegistrationMessage(DEFAULT_VALIDATION_ID, true);

Expand All @@ -141,7 +141,7 @@ contract ValidatorMessagesTest is Test {
ValidatorMessages.unpackL1ValidatorRegistrationMessage(invalidPacked);
}

function testSubnetValidatorRegistrationMessageInvalidCodecID() public {
function testL1ValidatorRegistrationMessageInvalidCodecID() public {
bytes memory packed =
ValidatorMessages.packL1ValidatorRegistrationMessage(DEFAULT_VALIDATION_ID, true);

Expand All @@ -154,7 +154,7 @@ contract ValidatorMessagesTest is Test {
ValidatorMessages.unpackL1ValidatorRegistrationMessage(invalidPacked2);
}

function testSubnetValidatorRegistrationMessageInvalidTypeID() public {
function testL1ValidatorRegistrationMessageInvalidTypeID() public {
bytes memory packed =
ValidatorMessages.packL1ValidatorRegistrationMessage(DEFAULT_VALIDATION_ID, true);

Expand Down Expand Up @@ -204,7 +204,7 @@ contract ValidatorMessagesTest is Test {
ValidatorMessages.unpackValidationUptimeMessage(invalidPacked3);
}

function testSetSubnetValidatorWeightMessageInvalidInputLength() public {
function testSetL1ValidatorWeightMessageInvalidInputLength() public {
bytes memory packed = ValidatorMessages.packL1ValidatorWeightMessage(
DEFAULT_VALIDATION_ID, 100, DEFAULT_WEIGHT
);
Expand All @@ -220,7 +220,7 @@ contract ValidatorMessagesTest is Test {
ValidatorMessages.unpackL1ValidatorWeightMessage(invalidPacked);
}

function testSetSubnetValidatorWeightMessageInvalidCodecID() public {
function testSetL1ValidatorWeightMessageInvalidCodecID() public {
bytes memory packed = ValidatorMessages.packL1ValidatorWeightMessage(
DEFAULT_VALIDATION_ID, 100, DEFAULT_WEIGHT
);
Expand All @@ -234,7 +234,7 @@ contract ValidatorMessagesTest is Test {
ValidatorMessages.unpackL1ValidatorWeightMessage(invalidPacked2);
}

function testSetSubnetValidatorWeightMessageInvalidTypeID() public {
function testSetL1ValidatorWeightMessageInvalidTypeID() public {
bytes memory packed = ValidatorMessages.packL1ValidatorWeightMessage(
DEFAULT_VALIDATION_ID, 100, DEFAULT_WEIGHT
);
Expand All @@ -246,7 +246,7 @@ contract ValidatorMessagesTest is Test {
ValidatorMessages.unpackL1ValidatorWeightMessage(invalidPacked3);
}

function testRegisterSubnetValidatorMessage() public view {
function testRegisterL1ValidatorMessage() public view {
(bytes32 validationID, bytes memory packed) = ValidatorMessages
.packRegisterL1ValidatorMessage(
ValidatorMessages.ValidationPeriod({
Expand All @@ -272,7 +272,7 @@ contract ValidatorMessagesTest is Test {
assertEq(recoveredID, validationID);
}

function testSubnetConversionMessage() public pure {
function testSubnetToL1ConversionMessage() public pure {
bytes memory packed =
ValidatorMessages.packSubnetToL1ConversionMessage(DEFAULT_SUBNET_CONVERSION_ID);
bytes32 conversionID = ValidatorMessages.unpackSubnetToL1ConversionMessage(packed);
Expand All @@ -298,7 +298,7 @@ contract ValidatorMessagesTest is Test {
assertEq(packed.length, 186);
}

function testSubnetValidatorRegistrationMessage() public pure {
function testL1ValidatorRegistrationMessage() public pure {
bytes memory packed =
ValidatorMessages.packL1ValidatorRegistrationMessage(DEFAULT_VALIDATION_ID, true);
(bytes32 validationID, bool valid) =
Expand All @@ -307,7 +307,7 @@ contract ValidatorMessagesTest is Test {
assert(valid);
}

function testSetSubnetValidatorWeightMessage() public pure {
function testSetL1ValidatorWeightMessage() public pure {
bytes memory packed = ValidatorMessages.packL1ValidatorWeightMessage(
DEFAULT_VALIDATION_ID, 100, DEFAULT_WEIGHT
);
Expand All @@ -318,7 +318,7 @@ contract ValidatorMessagesTest is Test {
assertEq(weight, DEFAULT_WEIGHT);
}

function testSubnetValidatorWeightUpdateMessage() public pure {
function testL1ValidatorWeightMessage() public pure {
bytes memory packed = ValidatorMessages.packL1ValidatorWeightMessage(
DEFAULT_VALIDATION_ID, 100, DEFAULT_WEIGHT
);
Expand All @@ -338,7 +338,7 @@ contract ValidatorMessagesTest is Test {
assertEq(uptime, 100);
}

function _getPackedRegisterL1ValidatorMessage() internal returns (bytes memory) {
function _getPackedRegisterL1ValidatorMessage() internal view returns (bytes memory) {
(, bytes memory packed) = ValidatorMessages.packRegisterL1ValidatorMessage(
ValidatorMessages.ValidationPeriod({
l1ID: DEFAULT_L1_ID,
Expand Down
12 changes: 6 additions & 6 deletions tests/flows/validator-manager/erc20_token_staking.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func ERC20TokenStakingManager(network *localnetwork.LocalNetwork) {
aggregator := network.GetSignatureAggregator()
defer aggregator.Shutdown()

// Gather subnet-evm Warp signatures for the SubnetValidatorWeightUpdateMessage & relay to the P-Chain
// Gather subnet-evm Warp signatures for the L1ValidatorWeightMessage & relay to the P-Chain
signedWarpMessage := utils.ConstructSignedWarpMessage(
context.Background(),
receipt,
Expand All @@ -163,8 +163,8 @@ func ERC20TokenStakingManager(network *localnetwork.LocalNetwork) {
utils.PChainProposerVMWorkaround(network.GetPChainWallet())
utils.AdvanceProposerVM(ctx, l1AInfo, fundedKey, 5)

// Construct an L1ValidatorWeightUpdateMessage Warp message from the P-Chain
registrationSignedMessage := utils.ConstructL1ValidatorWeightUpdateMessage(
// Construct an L1ValidatorWeightMessage Warp message from the P-Chain
registrationSignedMessage := utils.ConstructL1ValidatorWeightMessage(
validationID,
nonce,
newValidatorWeight,
Expand Down Expand Up @@ -217,7 +217,7 @@ func ERC20TokenStakingManager(network *localnetwork.LocalNetwork) {
aggregator := network.GetSignatureAggregator()
defer aggregator.Shutdown()

// Gather subnet-evm Warp signatures for the SetSubnetValidatorWeightMessage & relay to the P-Chain
// Gather subnet-evm Warp signatures for the SetL1ValidatorWeightMessage & relay to the P-Chain
// (Sending to the P-Chain will be skipped for now)
signedWarpMessage := utils.ConstructSignedWarpMessage(
context.Background(),
Expand All @@ -234,8 +234,8 @@ func ERC20TokenStakingManager(network *localnetwork.LocalNetwork) {
utils.PChainProposerVMWorkaround(network.GetPChainWallet())
utils.AdvanceProposerVM(ctx, l1AInfo, fundedKey, 5)

// Construct an L1ValidatorWeightUpdateMessage Warp message from the P-Chain
signedMessage := utils.ConstructL1ValidatorWeightUpdateMessage(
// Construct an L1ValidatorWeightMessage Warp message from the P-Chain
signedMessage := utils.ConstructL1ValidatorWeightMessage(
validationID,
nonce,
nodes[0].Weight,
Expand Down
12 changes: 6 additions & 6 deletions tests/flows/validator-manager/native_token_staking.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func NativeTokenStakingManager(network *localnetwork.LocalNetwork) {
aggregator := network.GetSignatureAggregator()
defer aggregator.Shutdown()

// Gather subnet-evm Warp signatures for the SubnetValidatorWeightUpdateMessage & relay to the P-Chain
// Gather subnet-evm Warp signatures for the L1ValidatorWeightMessage & relay to the P-Chain
signedWarpMessage := utils.ConstructSignedWarpMessage(
context.Background(),
receipt,
Expand All @@ -157,8 +157,8 @@ func NativeTokenStakingManager(network *localnetwork.LocalNetwork) {
utils.PChainProposerVMWorkaround(network.GetPChainWallet())
utils.AdvanceProposerVM(ctx, l1AInfo, fundedKey, 5)

// Construct a L1ValidatorWeightUpdateMessage Warp message from the P-Chain
registrationSignedMessage := utils.ConstructL1ValidatorWeightUpdateMessage(
// Construct a L1ValidatorWeightMessage Warp message from the P-Chain
registrationSignedMessage := utils.ConstructL1ValidatorWeightMessage(
validationID,
nonce,
newValidatorWeight,
Expand Down Expand Up @@ -210,7 +210,7 @@ func NativeTokenStakingManager(network *localnetwork.LocalNetwork) {
aggregator := network.GetSignatureAggregator()
defer aggregator.Shutdown()

// Gather subnet-evm Warp signatures for the SetSubnetValidatorWeightMessage & relay to the P-Chain
// Gather subnet-evm Warp signatures for the SetL1ValidatorWeightMessage & relay to the P-Chain
// (Sending to the P-Chain will be skipped for now)
signedWarpMessage := utils.ConstructSignedWarpMessage(
context.Background(),
Expand All @@ -227,8 +227,8 @@ func NativeTokenStakingManager(network *localnetwork.LocalNetwork) {
utils.PChainProposerVMWorkaround(network.GetPChainWallet())
utils.AdvanceProposerVM(ctx, l1AInfo, fundedKey, 5)

// Construct a SubnetValidatorWeightUpdateMessage Warp message from the P-Chain
signedMessage := utils.ConstructL1ValidatorWeightUpdateMessage(
// Construct a L1ValidatorWeightMessage Warp message from the P-Chain
signedMessage := utils.ConstructL1ValidatorWeightMessage(
validationID,
nonce,
nodes[0].Weight,
Expand Down
2 changes: 1 addition & 1 deletion tests/utils/validator_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -1452,7 +1452,7 @@ func ConstructL1ValidatorRegistrationMessage(
return registrationSignedMessage
}

func ConstructL1ValidatorWeightUpdateMessage(
func ConstructL1ValidatorWeightMessage(
validationID ids.ID,
nonce uint64,
weight uint64,
Expand Down

0 comments on commit 7a812ad

Please sign in to comment.