diff --git a/README.md b/README.md index ef7793f..2487fcd 100644 --- a/README.md +++ b/README.md @@ -4,14 +4,15 @@ [Registry.sol](src/Registry.sol) - [x] Reduce `MIN_COLLATERAL` to 0.1 ETH. It needs to be non-zero to incentivize people to slash bad registrations. -- [ ] Rename `proxyKey` to `commitmentKey`. -- [ ] ~~Optimistically accept an `OperatorCommitment` hash. It can be proven as fraudulent by generating the merkle tree in the fraud proof.~~ -- [ ] Make the unregistration delay parameterizable by the proposer but requires it to be at least `TWO_EPOCHS`. +- [X] Rename `proxyKey` to `commitmentKey`. +- [X] ~~Optimistically accept an `OperatorCommitment` hash. It can be proven as fraudulent by generating the merkle tree in the fraud proof.~~ +- [X] Make the unregistration delay parameterizable by the proposer but requires it to be at least `TWO_EPOCHS`. - [ ] Spec out the `Registration` message signed by a Validator BLS key. - [ ] Make sure no one can overwrite an `OperatorCommitment` - [ ] Save the `Operator.collateral` as GWEI. - [ ] Diagram the registration process -- [ ] Add field to `Operator` struct to signal if they are a gateway (open for discussion). +- [ ] Add field to `Operator` struct to signal if they are a gateway (open for discussion). + [BytecodeSlasher.sol](src/BytecodeSlasher.sol) @@ -55,4 +56,5 @@ struct RegistrationMessage { // Arbitrary metadata to be included in the delegation (we should include the OperatorCommitment) bytes metadata; } -``` \ No newline at end of file +``` + diff --git a/src/Registry.sol b/src/Registry.sol index 47f638e..e00c72c 100644 --- a/src/Registry.sol +++ b/src/Registry.sol @@ -18,6 +18,7 @@ contract Registry { uint72 collateral; // todo save as GWEI uint32 registeredAt; uint32 unregisteredAt; + uint32 unregistrationDelay; // anything else? } @@ -30,7 +31,7 @@ contract Registry { // Constants uint256 constant MIN_COLLATERAL = 0.1 ether; - uint256 constant TWO_EPOCHS = 64; // parameterize when you join + uint256 constant TWO_EPOCHS = 64; // Errors error InsufficientCollateral(); @@ -41,6 +42,8 @@ contract Registry { error NoCollateralToClaim(); error FraudProofMerklePathInvalid(); error FraudProofChallengeInvalid(); + error UnregistrationDelayTooShort(); + // Events event OperatorRegistered(bytes32 operatorCommitment, uint32 registeredAt); event OperatorUnregistered( @@ -52,6 +55,7 @@ contract Registry { function register( Registration[] calldata registrations, bytes32 commitmentKey, + uint32 unregistrationDelay, uint256 height ) external payable { // check collateral @@ -59,6 +63,10 @@ contract Registry { revert InsufficientCollateral(); } + if (unregistrationDelay < TWO_EPOCHS) { + revert UnregistrationDelayTooShort(); + } + // operatorCommitment hash = merklize registrations bytes32 operatorCommitment = createCommitment( registrations, @@ -72,6 +80,7 @@ contract Registry { commitmentKey: commitmentKey, collateral: uint72(msg.value), // todo save as GWEI registeredAt: uint32(block.number), + unregistrationDelay: unregistrationDelay, unregisteredAt: 0 }); @@ -181,7 +190,7 @@ contract Registry { } // Check that enough time has passed - if (block.number < operator.unregisteredAt + TWO_EPOCHS) { + if (block.number < operator.unregisteredAt + operator.unregistrationDelay) { revert UnregistrationDelayNotMet(); }