-
Notifications
You must be signed in to change notification settings - Fork 5
IPC-304: add permissioned flag to disable validator changes #305
Changes from 1 commit
d9b41b9
67abb24
aba8632
37c8fd7
724e396
9bea1ae
a86b398
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
// SPDX-License-Identifier: MIT OR Apache-2.0 | ||
pragma solidity 0.8.19; | ||
|
||
import {SubnetAlreadyBootstrapped, NotEnoughFunds, CollateralIsZero, CannotReleaseZero, NotOwnerOfPublicKey, EmptyAddress, NotEnoughBalance, NotEnoughBalanceForRewards, NotEnoughCollateral, NotValidator, NotAllValidatorsHaveLeft, NotStakedBefore, InvalidSignatureErr, InvalidCheckpointEpoch, InvalidCheckpointMessagesHash, InvalidPublicKeyLength} from "../errors/IPCErrors.sol"; | ||
import {SubnetAlreadyBootstrapped, NotEnoughFunds, CollateralIsZero, CannotReleaseZero, NotOwnerOfPublicKey, EmptyAddress, NotEnoughBalance, NotEnoughBalanceForRewards, NotEnoughCollateral, NotValidator, NotAllValidatorsHaveLeft, NotStakedBefore, InvalidSignatureErr, InvalidCheckpointEpoch, InvalidCheckpointMessagesHash, InvalidPublicKeyLength, MethodNotAllowed} from "../errors/IPCErrors.sol"; | ||
import {IGateway} from "../interfaces/IGateway.sol"; | ||
import {ISubnetActor} from "../interfaces/ISubnetActor.sol"; | ||
import {BottomUpCheckpoint, CrossMsg} from "../structs/Checkpoint.sol"; | ||
|
@@ -136,6 +136,12 @@ contract SubnetActorManagerFacet is ISubnetActor, SubnetActorModifiers, Reentran | |
/// @notice method that allows a validator to join the subnet | ||
/// @param publicKey The off-chain 65 byte public key that should be associated with the validator | ||
function join(bytes calldata publicKey) external payable nonReentrant notKilled { | ||
// adding this check to prevent new validators from joining | ||
// after the subnet has been bootstrapped. We will increase the | ||
// functionality in the future to support explicit permissioning. | ||
if (s.bootstrapped && s.permissioned) { | ||
revert MethodNotAllowed(); | ||
} | ||
if (msg.value == 0) { | ||
revert CollateralIsZero(); | ||
} | ||
|
@@ -180,6 +186,11 @@ contract SubnetActorManagerFacet is ISubnetActor, SubnetActorModifiers, Reentran | |
|
||
/// @notice method that allows a validator to increase its stake | ||
function stake() external payable notKilled { | ||
// disbling validator changes for permissioned subnets (at least for now | ||
// until a more complex mechanism is implemented). | ||
if (s.permissioned) { | ||
revert MethodNotAllowed(); | ||
} | ||
if (msg.value == 0) { | ||
revert CollateralIsZero(); | ||
} | ||
|
@@ -199,6 +210,11 @@ contract SubnetActorManagerFacet is ISubnetActor, SubnetActorModifiers, Reentran | |
/// @notice method that allows a validator to unstake a part of its collateral from a subnet | ||
/// @dev `leave` must be used to unstake the entire stake. | ||
function unstake(uint256 amount) external notKilled { | ||
// disbling validator changes for permissioned subnets (at least for now | ||
// until a more complex mechanism is implemented). | ||
if (s.permissioned) { | ||
revert MethodNotAllowed(); | ||
} | ||
if (amount == 0) { | ||
revert CannotReleaseZero(); | ||
} | ||
|
@@ -223,8 +239,16 @@ contract SubnetActorManagerFacet is ISubnetActor, SubnetActorModifiers, Reentran | |
/// @dev it also return the validators initial balance if the | ||
/// subnet was not yet bootstrapped. | ||
function leave() external notKilled nonReentrant { | ||
// remove bootstrap nodes added by this validator | ||
// disbling validator changes for permissioned subnets (at least for now | ||
// until a more complex mechanism is implemented). | ||
// This means that initial validators won't be able to recover | ||
// their collateral ever (worth noting in the docs if this ends | ||
// up sticking around for a while). | ||
if (s.permissioned) { | ||
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.
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. If we're limiting membership changes to reduce the changes of things going wrong, it makes sense to limit them both ways and just not have to worry about those paths. Don't see a lot of value in keeping leave as presumably you're not starting with a large validator set that you can afford to lose over time. 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.
We don´t want any validator change for now, as this is what is breaking Mycelium :)
This is a good point, fixed it |
||
revert MethodNotAllowed(); | ||
} | ||
|
||
// remove bootstrap nodes added by this validator | ||
uint256 amount = LibStaking.totalValidatorCollateral(msg.sender); | ||
if (amount == 0) { | ||
revert NotValidator(msg.sender); | ||
|
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.
Technically, it is not permissioned. Here we do not allow to join even if the validator is "permissioned". I do not know the correct term for that.
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.
static
is probably the accurate term, but not too descriptive.staticMembership
?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.
Yes,
static
sounds goodThere 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 reason why I went with
permissioned
is because this is a first stage towards this design for federated validation: https://www.notion.so/pl-strflt/Federated-validation-6290874b58904818ac4fdddb5128d01bI have no strong opinions, I can name this
static
until we have thepermissioned
feature.