Skip to content

Commit

Permalink
Add unregistrationDelay as a parameter at registration
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonVranek committed Nov 7, 2024
1 parent 8f97f05 commit 881ee56
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -55,4 +56,5 @@ struct RegistrationMessage {
// Arbitrary metadata to be included in the delegation (we should include the OperatorCommitment)
bytes metadata;
}
```
```

13 changes: 11 additions & 2 deletions src/Registry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ contract Registry {
uint72 collateral; // todo save as GWEI
uint32 registeredAt;
uint32 unregisteredAt;
uint32 unregistrationDelay;
// anything else?
}

Expand All @@ -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();
Expand All @@ -41,6 +42,8 @@ contract Registry {
error NoCollateralToClaim();
error FraudProofMerklePathInvalid();
error FraudProofChallengeInvalid();
error UnregistrationDelayTooShort();

// Events
event OperatorRegistered(bytes32 operatorCommitment, uint32 registeredAt);
event OperatorUnregistered(
Expand All @@ -52,13 +55,18 @@ contract Registry {
function register(
Registration[] calldata registrations,
bytes32 commitmentKey,
uint32 unregistrationDelay,
uint256 height
) external payable {
// check collateral
if (msg.value < MIN_COLLATERAL) {
revert InsufficientCollateral();
}

if (unregistrationDelay < TWO_EPOCHS) {
revert UnregistrationDelayTooShort();
}

// operatorCommitment hash = merklize registrations
bytes32 operatorCommitment = createCommitment(
registrations,
Expand All @@ -72,6 +80,7 @@ contract Registry {
commitmentKey: commitmentKey,
collateral: uint72(msg.value), // todo save as GWEI
registeredAt: uint32(block.number),
unregistrationDelay: unregistrationDelay,
unregisteredAt: 0
});

Expand Down Expand Up @@ -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();
}

Expand Down

0 comments on commit 881ee56

Please sign in to comment.