Skip to content

Commit

Permalink
feat(lockinginfo): update setSequencerOwner process flow
Browse files Browse the repository at this point in the history
  • Loading branch information
ericlee42 committed Aug 27, 2024
1 parent 0648f43 commit 876694d
Show file tree
Hide file tree
Showing 6 changed files with 223 additions and 46 deletions.
16 changes: 12 additions & 4 deletions contracts/SequencerInfo.sol
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,23 @@ contract SequencerInfo is OwnableUpgradeable, ISequencerInfo {
* @dev setSequencerOwner update sequencer owner
* @param _seqId The sequencerId
* @param _owner the new owner
* @notice whitelisting is still required for the new owner
*/
function setSequencerOwner(
uint256 _seqId,
address _owner
) external whitelistRequired {
function setSequencerOwner(uint256 _seqId, address _owner) external {
if (_owner == address(0)) {
revert NullAddress();
}

// the new owner should be whitelisted
if (!whitelist[_owner]) {
revert NotWhitelisted();
}

// the new owner doesn't have any sequencer nodes
if (seqOwners[_owner] != 0) {
revert OwnedSequencer();
}

Sequencer storage seq = sequencers[_seqId];
if (seq.status != Status.Active) {
revert SeqNotActive();
Expand Down
4 changes: 2 additions & 2 deletions deployments/sepolia/LockingPool.json

Large diffs are not rendered by default.

84 changes: 44 additions & 40 deletions deployments/sepolia/LockingPool_Implementation.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

37 changes: 37 additions & 0 deletions ts-src/test/LockingManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,43 @@ describe("locking", async () => {
);
});

it("setSequencerOwner", async () => {
const { lockingInfo, lockingPool, whitelised, unwhitelist } = await loadFixture(fixture);

const [wallet0, wallet1, wallet2] = whitelised;
const [wallet3] = unwhitelist;
const minLock = 1n;
await lockingInfo.setMinLock(minLock);

expect(
await lockingPool.signerUpdateThrottle(),
"default signerUpdateThrottle",
).to.be.eq(1);

const wallet0Pubkey = trimPubKeyPrefix(wallet0.signingKey.publicKey);
const wallet1Pubkey = trimPubKeyPrefix(wallet1.signingKey.publicKey);

// seq1
await lockingPool.connect(wallet0).lockFor(wallet0, minLock, wallet0Pubkey);
// seq2
await lockingPool.connect(wallet1).lockFor(wallet1, minLock, wallet1Pubkey);

await expect(lockingPool.connect(wallet0).setSequencerOwner(1, ethers.ZeroAddress)).revertedWithCustomError(lockingPool, "NullAddress")
await expect(lockingPool.connect(wallet0).setSequencerOwner(1, wallet3)).revertedWithCustomError(lockingPool, "NotWhitelisted")
await expect(lockingPool.connect(wallet0).setSequencerOwner(1, wallet1)).revertedWithCustomError(lockingPool, "OwnedSequencer")
await expect(lockingPool.connect(wallet1).setSequencerOwner(1, wallet2)).revertedWithCustomError(lockingPool, "NotSeqOwner")

await lockingPool.setWhitelist(wallet0, false)
expect(await lockingPool.connect(wallet0).setSequencerOwner(1, wallet2)).emit(lockingPool, "SequencerOwnerChanged").withArgs(1n, wallet2.address)

const { owner } =
await lockingPool.sequencers(1);
expect(owner).eq(wallet2.address);

expect(await lockingPool.seqOwners(wallet2.address)).eq(1)
expect(await lockingPool.seqOwners(wallet0.address)).eq(0)
});

it("relock/withoutReward", async () => {
const { lockingInfo, lockingPool, whitelised, unwhitelist } =
await loadFixture(fixture);
Expand Down

0 comments on commit 876694d

Please sign in to comment.