From e079bb7d550ffb5d6b048a24da06d7b3dfaebec0 Mon Sep 17 00:00:00 2001 From: brenzi-agent <346870783+brenzi-agent@users.noreply.github.com> Date: Thu, 19 Nov 2026 14:27:42 +0000 Subject: [PATCH 01/13] BaseRegistrar: let the guardian unregister a name in its dispute period --- .../BaseRegistrarImplementation.sol | 21 +- contracts/simplex/SimplexController.sol | 27 +- contracts/simplex/SimplexNamePolicy.sol | 2 +- contracts/simplex/SimplexSponsor.sol | 11 +- test/simplex/TestApproveClaimWithSig.test.ts | 1 + test/simplex/TestDisputePeriod.test.ts | 373 ++++++++++++++++++ test/simplex/TestRecipientConsent.test.ts | 19 +- test/simplex/TestRegistrarV3.test.ts | 4 +- test/simplex/TestSimplexResolver.test.ts | 1 + test/simplex/fixtures/namesV2.ts | 14 +- 10 files changed, 447 insertions(+), 26 deletions(-) create mode 100644 test/simplex/TestDisputePeriod.test.ts diff --git a/contracts/ethregistrar/BaseRegistrarImplementation.sol b/contracts/ethregistrar/BaseRegistrarImplementation.sol index b4dff0256..1a664088b 100644 --- a/contracts/ethregistrar/BaseRegistrarImplementation.sol +++ b/contracts/ethregistrar/BaseRegistrarImplementation.sol @@ -44,6 +44,7 @@ contract BaseRegistrarImplementation is // subnames are invalidated/garbage-collectable. Optional (0 = disabled). address public subnameHook; address public namePolicy; + mapping(uint256 => uint256) public disputeUntil; // The ENS registry ENS public ens; // The namehash of the TLD this registrar owns (eg, .eth) @@ -60,9 +61,11 @@ contract BaseRegistrarImplementation is event MaxLabelLengthChanged(uint256 maxLabelLength); event SubnameHookChanged(address indexed hook); event NamePolicyChanged(address indexed namePolicy); + event NameUnregistered(uint256 indexed id); error LabelTooLong(uint256 length, uint256 max); error NamePolicyMismatch(); + error DisputePeriodOver(uint256 id); /// v2.1.3 version of _isApprovedOrOwner which calls ownerOf(tokenId) and takes grace period into consideration instead of ERC721.ownerOf(tokenId); /// https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v2.1.3/contracts/token/ERC721/ERC721.sol#L187 @@ -164,7 +167,8 @@ contract BaseRegistrarImplementation is function registerWithLabel( string calldata label, address owner, - uint256 duration + uint256 duration, + uint256 disputePeriod ) external returns (uint256) { if (maxLabelLength != 0 && bytes(label).length > maxLabelLength) revert LabelTooLong(bytes(label).length, maxLabelLength); @@ -172,6 +176,7 @@ contract BaseRegistrarImplementation is if (bytes(labelOf[id]).length == 0) { labelOf[id] = label; } + disputeUntil[id] = block.timestamp + disputePeriod; return _register(id, owner, duration); } @@ -239,6 +244,20 @@ contract BaseRegistrarImplementation is return expiries[id]; } + function unregister(uint256 id) external live onlyController { + if (block.timestamp >= disputeUntil[id]) revert DisputePeriodOver(id); + delete disputeUntil[id]; + expiries[id] = 0; + ens.setSubnodeOwner(baseNode, bytes32(id), address(0)); + if (subnameHook != address(0)) { + ISubnameHook(subnameHook).onExpiryChanged( + keccak256(abi.encodePacked(baseNode, bytes32(id))), + 0 + ); + } + emit NameUnregistered(id); + } + /// @dev Reclaim ownership of a name in ENS, if you own it in the registrar. function reclaim(uint256 id, address owner) external override live { require(_isApprovedOrOwner(msg.sender, id)); diff --git a/contracts/simplex/SimplexController.sol b/contracts/simplex/SimplexController.sol index 85d682cef..860fc07c0 100644 --- a/contracts/simplex/SimplexController.sol +++ b/contracts/simplex/SimplexController.sol @@ -47,6 +47,8 @@ contract SimplexController is uint256 public constant MIN_RENEWAL_DURATION = 365 days; uint256 public constant MAX_REGISTRATION_DURATION = MAX_REGISTRATION; uint256 public constant MAX_SPONSORED_REGISTRATION_DURATION = MAX_SPONSORED_REGISTRATION; + uint256 public constant MIN_DISPUTE_DAYS = 14; + uint256 public constant MAX_DISPUTE_DAYS = 120; // Manual reentrancy guard (see `_reentrancyStatus` + `nonReentrant`). // Implemented by hand rather than inheriting ReentrancyGuardUpgradeable so @@ -124,6 +126,7 @@ contract SimplexController is error PublicSalesClosed(); error OwnerMustBeCaller(); error NotSponsor(); + error DisputeDaysOutOfRange(uint256 disputeDays); event NameRegistered( string label, @@ -424,7 +427,7 @@ contract SimplexController is uint256 totalPrice = price.base + price.premium; if (msg.value < totalPrice) revert InsufficientValue(); - _registerCore(registration, labelhash, price); + _registerCore(registration, labelhash, price, 0); if (msg.value > totalPrice) { (bool ok, ) = payable(msg.sender).call{value: msg.value - totalPrice}(""); @@ -436,11 +439,14 @@ contract SimplexController is /// The fee would have gone to the controller and been withdrawn back /// to the same treasury, so it is removed rather than performed. function registerSponsored( - Registration calldata registration + Registration calldata registration, + uint256 disputeDays ) external onlySponsor nonReentrant { bytes32 labelhash = keccak256(bytes(registration.label)); if (registration.duration > _sponsoredHorizon(labelhash)) revert DurationTooLong(registration.duration); + if (disputeDays < MIN_DISPUTE_DAYS || disputeDays > MAX_DISPUTE_DAYS) + revert DisputeDaysOutOfRange(disputeDays); _checkSimplexGates(registration.label, false); // Zero cost in the event, and no `_rentPrice` call: nothing is paid on @@ -448,7 +454,7 @@ contract SimplexController is // and reading it would couple the sponsored flow to the ETH/USD feed, // which is the one dependency this path exists without. What was // actually consumed is in the sponsor's `RegistrarAllowanceSpent`, in attoUSD. - _registerCore(registration, labelhash, IPriceOracle.Price(0, 0)); + _registerCore(registration, labelhash, IPriceOracle.Price(0, 0), disputeDays * 1 days); } /// @dev Everything both registration paths share: availability, the @@ -456,7 +462,8 @@ contract SimplexController is function _registerCore( Registration calldata registration, bytes32 labelhash, - IPriceOracle.Price memory price + IPriceOracle.Price memory price, + uint256 disputePeriod ) private returns (uint256 expires) { if (!_available(registration.label, labelhash)) revert NameNotAvailable(registration.label); @@ -500,13 +507,15 @@ contract SimplexController is expires = base.registerWithLabel( registration.label, registration.owner, - registration.duration + registration.duration, + disputePeriod ); } else { expires = base.registerWithLabel( registration.label, address(this), - registration.duration + registration.duration, + disputePeriod ); ens.setRecord( @@ -592,6 +601,12 @@ contract SimplexController is emit NameRenewed(label, labelhash, cost, expires, referrer); } + function unregister(string calldata label) external onlyOwnerOrBeneficiary { + bytes32 labelhash = keccak256(bytes(label)); + base.unregister(uint256(labelhash)); + _retireStaleRecords(keccak256(abi.encodePacked(tldNode, labelhash))); + } + /// @notice Pays the beneficiary, never `owner()`, so revenue is independent of /// the admin key. Permissionless to call. function withdraw() public nonReentrant { diff --git a/contracts/simplex/SimplexNamePolicy.sol b/contracts/simplex/SimplexNamePolicy.sol index 132dfd43a..d3aa38a0f 100644 --- a/contracts/simplex/SimplexNamePolicy.sol +++ b/contracts/simplex/SimplexNamePolicy.sol @@ -184,7 +184,7 @@ contract SimplexNamePolicy is INamePolicy { emit ReservedNameRemoved(label); bytes32 namehash = keccak256(abi.encodePacked(_tldNode, labelhash)); - registrar.registerWithLabel(label, address(this), duration); + registrar.registerWithLabel(label, address(this), duration, 0); _retireStaleRecords(namehash); address resolver = controller.defaultResolver(); if (resolver != address(0)) diff --git a/contracts/simplex/SimplexSponsor.sol b/contracts/simplex/SimplexSponsor.sol index efd48c5b7..970608d0b 100644 --- a/contracts/simplex/SimplexSponsor.sol +++ b/contracts/simplex/SimplexSponsor.sol @@ -21,7 +21,7 @@ contract SimplexSponsor { bytes32 private constant _EIP712_VERSION = keccak256("1"); bytes32 public constant REGISTER_TYPEHASH = keccak256( - "RegisterName(string label,address owner,uint256 duration,address resolver,bytes[] data,uint256 nonce,uint256 deadline)" + "RegisterName(string label,address owner,uint256 duration,address resolver,bytes[] data,uint256 disputeDays,uint256 nonce,uint256 deadline)" ); SimplexController public immutable controller; @@ -67,22 +67,23 @@ contract SimplexSponsor { /// @notice Register with no value attached, spending the name's list price /// from the caller's allowance. /// @param sig The owner's EIP-712 `RegisterName` signature, which covers the - /// label, the duration, the resolver and `data`, not the secret or referrer. + /// label, the duration, the resolver, `data` and `disputeDays`, not the secret or referrer. /// Not checked when the owner is the caller. function registerWithCredit( IETHRegistrarController.Registration calldata registration, + uint256 disputeDays, uint256 nonce, uint256 deadline, bytes calldata sig ) external { if (registration.owner != msg.sender) - _consumeIntent(registration, nonce, deadline, sig); + _consumeIntent(registration, disputeDays, nonce, deadline, sig); IPriceOracle.Price memory usd = controller.rentPriceUSD( registration.label, registration.duration ); _spendAllowance(usd.base + usd.premium); - controller.registerSponsored(registration); + controller.registerSponsored(registration, disputeDays); } /// @notice Renew with no value attached, spending the name's list price @@ -130,6 +131,7 @@ contract SimplexSponsor { /// @dev Verify the owner's signature, then spend the nonce. function _consumeIntent( IETHRegistrarController.Registration calldata registration, + uint256 disputeDays, uint256 nonce, uint256 deadline, bytes calldata sig @@ -153,6 +155,7 @@ contract SimplexSponsor { registration.duration, registration.resolver, keccak256(abi.encodePacked(dataHashes)), + disputeDays, nonce, deadline ) diff --git a/test/simplex/TestApproveClaimWithSig.test.ts b/test/simplex/TestApproveClaimWithSig.test.ts index b30ef5b3e..a74590503 100644 --- a/test/simplex/TestApproveClaimWithSig.test.ts +++ b/test/simplex/TestApproveClaimWithSig.test.ts @@ -40,6 +40,7 @@ async function fixture() { 'alicechat', aliceAccount.address, DURATION, + 0n, ]) return { ensRegistry, baseRegistrar } } diff --git a/test/simplex/TestDisputePeriod.test.ts b/test/simplex/TestDisputePeriod.test.ts new file mode 100644 index 000000000..09fdc7a14 --- /dev/null +++ b/test/simplex/TestDisputePeriod.test.ts @@ -0,0 +1,373 @@ +import hre from 'hardhat' +import { + concat, + getAddress, + keccak256, + labelhash, + zeroAddress, + zeroHash, +} from 'viem' +import { describe, expect, it } from 'vitest' + +import { + acceptGeneralTermsForClaim, + acceptGeneralTermsForRenewal, + AMPLE_ALLOWANCE, + commitUnderGeneralTerms, + deployNamesV2, + MIN_DISPUTE_DAYS, + MIN_REGISTRATION, + node, + Reason, + registration, + signRegistration, + YEAR, + YEAR_PRICE_USD, +} from './fixtures/namesV2.js' +import { DAY } from '../fixtures/constants.js' + +const MAX_DISPUTE_DAYS = 120n +const KEY = 'simplex.contact' +const EXACT = { gas: 5_000_000n } + +const connection = await hre.network.connect() +const publicClient = await connection.viem.getPublicClient() +const testClient = await connection.viem.getTestClient() +const [ + ownerClient, + guardianClient, + registrarClient, + aliceClient, + bobClient, + carolClient, +] = await connection.viem.getWalletClients() +const owner = ownerClient.account +const guardian = guardianClient.account +const registrar = registrarClient.account +const alice = aliceClient.account +const bob = bobClient.account +const carol = carolClient.account +type Account = typeof alice + +async function fixture() { + const f = await deployNamesV2(connection, { + owner: owner.address, + beneficiary: guardian.address, + }) + await f.sponsor.write.setRegistrarAllowance( + [registrar.address, AMPLE_ALLOWANCE], + { account: guardian }, + ) + await f.controller.write.setPublicSalesOpen([true], { account: owner }) + return f +} +const load = () => connection.networkHelpers.loadFixture(fixture) +type Fixture = Awaited> + +const id = (label: string) => BigInt(labelhash(label)) + +async function timeOf(hash: `0x${string}`) { + const { blockNumber } = await publicClient.waitForTransactionReceipt({ hash }) + return (await publicClient.getBlock({ blockNumber })).timestamp +} + +const exactly = (timestamp: bigint) => + testClient.setNextBlockTimestamp({ timestamp }) + +async function sponsored( + f: Fixture, + label: string, + { + holder = alice, + days = MIN_DISPUTE_DAYS, + resolver = zeroAddress, + }: Partial<{ holder: Account; days: bigint; resolver: `0x${string}` }> = {}, +) { + const reg = registration(label, holder.address, { resolver }) + await commitUnderGeneralTerms(connection, f.controller, reg, { + account: holder, + }) + const hash = await f.sponsor.write.registerWithCredit( + await signRegistration(connection, f.sponsor, reg, { disputeDays: days }), + { account: registrar }, + ) + return (await timeOf(hash)) + days * DAY +} + +async function paid(f: Fixture, label: string, holder: Account = alice) { + const reg = registration(label, holder.address) + await commitUnderGeneralTerms(connection, f.controller, reg, { + account: holder, + }) + return timeOf( + await f.controller.write.register([reg], { + account: holder, + value: 2n * YEAR_PRICE_USD, + }), + ) +} + +const unregister = ( + f: Fixture, + label: string, + account: Account = guardian, + options = {}, +) => f.controller.write.unregister([label], { account, ...options }) + +async function withSubname(f: Fixture, label: string) { + await f.ens.write.setApprovalForAll([f.subnameRegistrar.address, true], { + account: alice, + }) + await f.subnameRegistrar.write.createSubname([node(label), 'pay'], { + account: alice, + }) + return BigInt(keccak256(concat([node(label), labelhash('pay')]))) +} + +describe('dispute period', () => { + describe('registration', () => { + it('stores the end of a sponsored registration of 14 to 120 days', async () => { + const f = await load() + for (const [label, days] of [ + ['fourteendays', MIN_DISPUTE_DAYS], + ['hundredtwenty', MAX_DISPUTE_DAYS], + ] as const) + expect(await f.baseRegistrar.read.disputeUntil([id(label)])).toBe( + await sponsored(f, label, { days }), + ) + expect(await f.controller.read.MIN_DISPUTE_DAYS()).toBe(MIN_DISPUTE_DAYS) + expect(await f.controller.read.MAX_DISPUTE_DAYS()).toBe(MAX_DISPUTE_DAYS) + }) + + it('reverts DisputeDaysOutOfRange below 14 and above 120 days', async () => { + const f = await load() + for (const [label, days] of [ + ['thirteendays', MIN_DISPUTE_DAYS - 1n], + ['zerodaysname', 0n], + ['toomanydays', MAX_DISPUTE_DAYS + 1n], + ] as const) { + const reg = registration(label, alice.address) + await commitUnderGeneralTerms(connection, f.controller, reg, { + account: alice, + }) + await expect( + f.sponsor.write.registerWithCredit( + await signRegistration(connection, f.sponsor, reg, { + disputeDays: days, + }), + { account: registrar }, + ), + ).toBeRevertedWithCustomErrorFrom(f.controller, 'DisputeDaysOutOfRange') + } + }) + + it('binds the dispute days in RegisterName', async () => { + const f = await load() + const reg = registration('signeddays', alice.address) + await commitUnderGeneralTerms(connection, f.controller, reg, { + account: alice, + }) + const [, days, nonce, deadline, sig] = await signRegistration( + connection, + f.sponsor, + reg, + { disputeDays: MAX_DISPUTE_DAYS }, + ) + await expect( + f.sponsor.write.registerWithCredit( + [reg, MIN_DISPUTE_DAYS, nonce, deadline, sig], + { account: registrar }, + ), + ).toBeRevertedWithCustomError('InvalidSignature') + await f.sponsor.write.registerWithCredit([reg, days, nonce, deadline, sig], { + account: registrar, + }) + }) + + it('gives the payable path and registerReserved no dispute period', async () => { + const f = await load() + expect(await f.baseRegistrar.read.disputeUntil([id('paidineth')])).toBe(0n) + const time = await paid(f, 'paidineth') + expect(await f.baseRegistrar.read.disputeUntil([id('paidineth')])).toBe(time) + await f.namePolicy.write.addReservedNames( + [['brandname'], Reason.Trademark], + { account: guardian }, + ) + await f.namePolicy.write.registerReserved( + ['brandname', bob.address, MIN_REGISTRATION], + { account: owner }, + ) + for (const label of ['paidineth', 'brandname']) + await expect(unregister(f, label)).toBeRevertedWithCustomErrorFrom( + f.baseRegistrar, + 'DisputePeriodOver', + ) + }) + }) + + describe('unregistration', () => { + it('is made by the guardian or the admin, before the end of the dispute period', async () => { + const f = await load() + await sponsored(f, 'byguardian') + await sponsored(f, 'byadmin') + const lastSecond = await sponsored(f, 'lastsecond') + const atEnd = await sponsored(f, 'atitsend') + for (const account of [registrar, alice, carol]) + await expect( + unregister(f, 'byguardian', account), + ).toBeRevertedWithCustomError('NotOwnerOrBeneficiary') + await unregister(f, 'byguardian', guardian) + await unregister(f, 'byadmin', owner) + await exactly(lastSecond - 1n) + await unregister(f, 'lastsecond', guardian, EXACT) + await exactly(atEnd) + await expect( + unregister(f, 'atitsend', guardian, EXACT), + ).toBeRevertedWithCustomErrorFrom(f.baseRegistrar, 'DisputePeriodOver') + for (const label of ['byguardian', 'byadmin', 'lastsecond']) + expect(await f.baseRegistrar.read.nameExpires([id(label)])).toBe(0n) + expect(await f.baseRegistrar.read.ownerOf([id('atitsend')])).toBe( + getAddress(alice.address), + ) + }) + + it('ends the registration, its records and its subnames at once', async () => { + const f = await load() + await sponsored(f, 'disputed', { resolver: f.resolver.address }) + await f.resolver.write.setText([node('disputed'), KEY, 'https://smp/alice'], { + account: alice, + }) + const sub = await withSubname(f, 'disputed') + await expect(unregister(f, 'disputed')) + .toEmitEventFrom(f.baseRegistrar, 'NameUnregistered') + .withArgs({ id: id('disputed') }) + expect(await f.baseRegistrar.read.nameExpires([id('disputed')])).toBe(0n) + expect(await f.baseRegistrar.read.disputeUntil([id('disputed')])).toBe(0n) + expect(await f.baseRegistrar.read.available([id('disputed')])).toBe(true) + expect(await f.controller.read.available(['disputed'])).toBe(true) + await expect( + f.baseRegistrar.read.ownerOf([id('disputed')]), + ).toBeRevertedWithoutReason() + expect(await f.ens.read.owner([node('disputed')])).toBe(zeroAddress) + expect(await f.resolver.read.text([node('disputed'), KEY])).toBe('') + expect(await f.subnameRegistrar.read.ownerOf([sub])).toBe(zeroAddress) + await expect( + f.resolver.write.setText([node('disputed'), KEY, 'https://smp/again'], { + account: alice, + }), + ).toBeRevertedWithoutReason() + await expect(unregister(f, 'disputed')).toBeRevertedWithCustomErrorFrom( + f.baseRegistrar, + 'DisputePeriodOver', + ) + }) + + it('refuses a claim and a renewal of an unregistered name', async () => { + const f = await load() + await sponsored(f, 'nomoreclaim') + await f.baseRegistrar.write.approve([bob.address, id('nomoreclaim')], { + account: alice, + }) + await acceptGeneralTermsForClaim( + connection, + f.baseRegistrar, + id('nomoreclaim'), + alice.address, + { account: bob }, + ) + await unregister(f, 'nomoreclaim') + await expect( + f.baseRegistrar.write.transferFrom( + [alice.address, bob.address, id('nomoreclaim')], + { account: bob }, + ), + ).toBeRevertedWithoutReason() + await acceptGeneralTermsForRenewal(connection, f.controller, 'nomoreclaim', YEAR, { + account: alice, + }) + await expect( + f.controller.write.renew(['nomoreclaim', YEAR, zeroHash], { + account: alice, + value: YEAR_PRICE_USD, + }), + ).toBeRevertedWithoutReason() + }) + + it('lets anyone register the name again at once, without the old subnames and records', async () => { + const f = await load() + await sponsored(f, 'freedname', { resolver: f.resolver.address }) + await f.resolver.write.setText([node('freedname'), KEY, 'https://smp/alice'], { + account: alice, + }) + const sub = await withSubname(f, 'freedname') + await unregister(f, 'freedname') + const time = await paid(f, 'freedname', bob) + expect(await f.baseRegistrar.read.ownerOf([id('freedname')])).toBe( + getAddress(bob.address), + ) + expect(await f.baseRegistrar.read.balanceOf([alice.address])).toBe(0n) + expect(await f.baseRegistrar.read.disputeUntil([id('freedname')])).toBe(time) + expect(await f.subnameRegistrar.read.ownerOf([sub])).toBe(zeroAddress) + expect(await f.resolver.read.text([node('freedname'), KEY])).toBe('') + }) + + it('writes a new dispute end at a sponsored registration after an unregistration', async () => { + const f = await load() + await sponsored(f, 'secondsale') + await unregister(f, 'secondsale') + const until = await sponsored(f, 'secondsale', { + holder: bob, + days: MAX_DISPUTE_DAYS, + }) + expect(await f.baseRegistrar.read.disputeUntil([id('secondsale')])).toBe(until) + }) + + it('takes the name from a recipient of a claim in the dispute period', async () => { + const f = await load() + await sponsored(f, 'soldearly') + await f.baseRegistrar.write.approve([bob.address, id('soldearly')], { + account: alice, + }) + await acceptGeneralTermsForClaim( + connection, + f.baseRegistrar, + id('soldearly'), + alice.address, + { account: bob }, + ) + await f.baseRegistrar.write.transferFrom( + [alice.address, bob.address, id('soldearly')], + { account: bob }, + ) + await unregister(f, 'soldearly') + expect(await f.baseRegistrar.read.nameExpires([id('soldearly')])).toBe(0n) + expect(await f.ens.read.owner([node('soldearly')])).toBe(zeroAddress) + }) + + it('ends a renewal made in the dispute period with the registration', async () => { + const f = await load() + await sponsored(f, 'renewedearly') + await acceptGeneralTermsForRenewal(connection, f.controller, 'renewedearly', YEAR, { + account: alice, + }) + await f.controller.write.renew(['renewedearly', YEAR, zeroHash], { + account: alice, + value: YEAR_PRICE_USD, + }) + await unregister(f, 'renewedearly') + expect(await f.baseRegistrar.read.nameExpires([id('renewedearly')])).toBe(0n) + }) + + it('is made on the registrar by a registrar controller only', async () => { + const f = await load() + await sponsored(f, 'directcall') + for (const account of [owner, guardian, alice]) + await expect( + f.baseRegistrar.write.unregister([id('directcall')], { account }), + ).toBeRevertedWithoutReason() + expect(await f.baseRegistrar.read.ownerOf([id('directcall')])).toBe( + getAddress(alice.address), + ) + }) + }) +}) diff --git a/test/simplex/TestRecipientConsent.test.ts b/test/simplex/TestRecipientConsent.test.ts index 3b9402fc7..d644623a2 100644 --- a/test/simplex/TestRecipientConsent.test.ts +++ b/test/simplex/TestRecipientConsent.test.ts @@ -17,6 +17,7 @@ import { commitUnderGeneralTerms, deployNamesV2, FAR_FUTURE, + MIN_DISPUTE_DAYS, MIN_REGISTRATION, node, registerWithCredit, @@ -87,7 +88,7 @@ describe('recipient consent', () => { expect(await sponsor.read.REGISTER_TYPEHASH()).toBe( keccak256( toHex( - 'RegisterName(string label,address owner,uint256 duration,address resolver,bytes[] data,uint256 nonce,uint256 deadline)', + 'RegisterName(string label,address owner,uint256 duration,address resolver,bytes[] data,uint256 disputeDays,uint256 nonce,uint256 deadline)', ), ), ) @@ -120,7 +121,7 @@ describe('recipient consent', () => { const reg = registration('nosigname', bob.address) await commit(controller, reg) await expect( - sponsor.write.registerWithCredit([reg, 0n, FAR_FUTURE, '0x'], { + sponsor.write.registerWithCredit([reg, MIN_DISPUTE_DAYS, 0n, FAR_FUTURE, '0x'], { account: registrar, }), ).toBeRevertedWithCustomError('InvalidSignature') @@ -139,7 +140,7 @@ describe('recipient consent', () => { const signed = registration('signedname', bob.address, { resolver: resolver.address, }) - const [, nonce, deadline, sig] = await signRegistration( + const [, disputeDays, nonce, deadline, sig] = await signRegistration( connection, sponsor, signed, @@ -162,13 +163,13 @@ describe('recipient consent', () => { for (const reg of tampered) { await commit(controller, reg) await expect( - sponsor.write.registerWithCredit([reg, nonce, deadline, sig], { + sponsor.write.registerWithCredit([reg, disputeDays, nonce, deadline, sig], { account: registrar, }), ).toBeRevertedWithCustomError('InvalidSignature') } await commit(controller, signed) - await sponsor.write.registerWithCredit([signed, nonce, deadline, sig], { + await sponsor.write.registerWithCredit([signed, disputeDays, nonce, deadline, sig], { account: registrar, }) expect( @@ -178,7 +179,7 @@ describe('recipient consent', () => { it('leaves the secret to the payer', async () => { const { controller, sponsor, baseRegistrar } = await load() - const [signed, nonce, deadline, sig] = await signRegistration( + const [signed, disputeDays, nonce, deadline, sig] = await signRegistration( connection, sponsor, registration('payername', bob.address), @@ -188,7 +189,7 @@ describe('recipient consent', () => { secret: keccak256(toHex('chosen later')), } await commit(controller, reg) - await sponsor.write.registerWithCredit([reg, nonce, deadline, sig], { + await sponsor.write.registerWithCredit([reg, disputeDays, nonce, deadline, sig], { account: registrar, }) expect( @@ -232,7 +233,7 @@ describe('recipient consent', () => { const reg = registration('directname', registrar.address) await commit(controller, reg) await expect( - controller.write.registerSponsored([reg], { account: registrar }), + controller.write.registerSponsored([reg, MIN_DISPUTE_DAYS], { account: registrar }), ).toBeRevertedWithCustomError('NotSponsor') await expect( controller.write.renewSponsored( @@ -246,7 +247,7 @@ describe('recipient consent', () => { const { controller, sponsor, baseRegistrar } = await load() const reg = registration('selfname', registrar.address) await commit(controller, reg) - await sponsor.write.registerWithCredit([reg, 0n, 0n, '0x'], { + await sponsor.write.registerWithCredit([reg, MIN_DISPUTE_DAYS, 0n, 0n, '0x'], { account: registrar, }) expect( diff --git a/test/simplex/TestRegistrarV3.test.ts b/test/simplex/TestRegistrarV3.test.ts index d06eee7e4..87ccfccc7 100644 --- a/test/simplex/TestRegistrarV3.test.ts +++ b/test/simplex/TestRegistrarV3.test.ts @@ -47,7 +47,7 @@ const registerLabel = ( baseRegistrar: any, label: string, owner: `0x${string}`, -) => baseRegistrar.write.registerWithLabel([label, owner, DURATION]) +) => baseRegistrar.write.registerWithLabel([label, owner, DURATION, 0n]) describe('BaseRegistrarImplementation v3', () => { describe('label index', () => { @@ -184,7 +184,7 @@ describe('BaseRegistrarImplementation v3', () => { const { baseRegistrar } = await loadFixture() await expect( baseRegistrar.write.registerWithLabel( - ['alice', otherAccount.address, DURATION], + ['alice', otherAccount.address, DURATION, 0n], { account: otherAccount }, ), ).rejects.toThrow() diff --git a/test/simplex/TestSimplexResolver.test.ts b/test/simplex/TestSimplexResolver.test.ts index aba38e15b..6a49429e1 100644 --- a/test/simplex/TestSimplexResolver.test.ts +++ b/test/simplex/TestSimplexResolver.test.ts @@ -53,6 +53,7 @@ async function fixture() { 'alicechat', aliceAccount.address, DURATION, + 0n, ]) return { ensRegistry, baseRegistrar, resolver } } diff --git a/test/simplex/fixtures/namesV2.ts b/test/simplex/fixtures/namesV2.ts index d52b89334..0c66e3ced 100644 --- a/test/simplex/fixtures/namesV2.ts +++ b/test/simplex/fixtures/namesV2.ts @@ -472,6 +472,7 @@ export const eip712Types = { { name: 'duration', type: 'uint256' }, { name: 'resolver', type: 'address' }, { name: 'data', type: 'bytes[]' }, + { name: 'disputeDays', type: 'uint256' }, { name: 'nonce', type: 'uint256' }, { name: 'deadline', type: 'uint256' }, ], @@ -513,6 +514,8 @@ export const eip712Types = { export const FAR_FUTURE = 4102444800n +export const MIN_DISPUTE_DAYS = 14n + /** Sign one of the intents above against `verifyingContract`. */ export async function signIntent( publicClient: any, @@ -565,8 +568,12 @@ export async function signRegistration< connection: NetworkConnection, sponsor: any, reg: R, - { signer, deadline = FAR_FUTURE }: { signer?: any; deadline?: bigint } = {}, -): Promise<[R, bigint, bigint, `0x${string}`]> { + { + signer, + deadline = FAR_FUTURE, + disputeDays = MIN_DISPUTE_DAYS, + }: { signer?: any; deadline?: bigint; disputeDays?: bigint } = {}, +): Promise<[R, bigint, bigint, bigint, `0x${string}`]> { const client = signer ?? (await connection.viem.getWalletClients()).find( @@ -586,11 +593,12 @@ export async function signRegistration< duration: reg.duration, resolver: reg.resolver, data: reg.data, + disputeDays, nonce, deadline, }, ) - return [reg, nonce, deadline, sig] + return [reg, disputeDays, nonce, deadline, sig] } /** `sponsor.registerWithCredit` for `reg`, signed by its owner. */ From 47735c050bef03c06348430d9b0bfc80c3d42b85 Mon Sep 17 00:00:00 2001 From: brenzi-agent <346870783+brenzi-agent@users.noreply.github.com> Date: Thu, 19 Nov 2026 14:29:31 +0000 Subject: [PATCH 02/13] BaseRegistrar: read the dispute end after the registration in its test --- test/simplex/TestDisputePeriod.test.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/simplex/TestDisputePeriod.test.ts b/test/simplex/TestDisputePeriod.test.ts index 09fdc7a14..598b27c0a 100644 --- a/test/simplex/TestDisputePeriod.test.ts +++ b/test/simplex/TestDisputePeriod.test.ts @@ -131,10 +131,10 @@ describe('dispute period', () => { for (const [label, days] of [ ['fourteendays', MIN_DISPUTE_DAYS], ['hundredtwenty', MAX_DISPUTE_DAYS], - ] as const) - expect(await f.baseRegistrar.read.disputeUntil([id(label)])).toBe( - await sponsored(f, label, { days }), - ) + ] as const) { + const until = await sponsored(f, label, { days }) + expect(await f.baseRegistrar.read.disputeUntil([id(label)])).toBe(until) + } expect(await f.controller.read.MIN_DISPUTE_DAYS()).toBe(MIN_DISPUTE_DAYS) expect(await f.controller.read.MAX_DISPUTE_DAYS()).toBe(MAX_DISPUTE_DAYS) }) From 3dadcf348aecf859e70b375035b48740ec03194d Mon Sep 17 00:00:00 2001 From: brenzi-agent <346870783+brenzi-agent@users.noreply.github.com> Date: Thu, 19 Nov 2026 14:55:25 +0000 Subject: [PATCH 03/13] SimplexController: refuse renewals in a dispute period, end resolution on unregister --- .../BaseRegistrarImplementation.sol | 7 +-- contracts/simplex/SimplexController.sol | 5 ++- test/ethregistrar/TestBaseRegistrar.test.ts | 10 ++--- test/simplex/TestDisputePeriod.test.ts | 43 ++++++++++++++----- test/simplex/TestLaunchLifecycle.test.ts | 2 + test/simplex/TestPublicSalesSwitch.test.ts | 2 + test/simplex/TestRegistrarAllowance.test.ts | 3 ++ .../TestSponsoredPathIndependence.test.ts | 3 ++ test/simplex/fixtures/namesV2.ts | 3 ++ 9 files changed, 59 insertions(+), 19 deletions(-) diff --git a/contracts/ethregistrar/BaseRegistrarImplementation.sol b/contracts/ethregistrar/BaseRegistrarImplementation.sol index 1a664088b..9f6d246b0 100644 --- a/contracts/ethregistrar/BaseRegistrarImplementation.sol +++ b/contracts/ethregistrar/BaseRegistrarImplementation.sol @@ -44,7 +44,6 @@ contract BaseRegistrarImplementation is // subnames are invalidated/garbage-collectable. Optional (0 = disabled). address public subnameHook; address public namePolicy; - mapping(uint256 => uint256) public disputeUntil; // The ENS registry ENS public ens; // The namehash of the TLD this registrar owns (eg, .eth) @@ -176,7 +175,7 @@ contract BaseRegistrarImplementation is if (bytes(labelOf[id]).length == 0) { labelOf[id] = label; } - disputeUntil[id] = block.timestamp + disputePeriod; + disputeUntil[id] = disputePeriod == 0 ? 0 : block.timestamp + disputePeriod; return _register(id, owner, duration); } @@ -248,7 +247,7 @@ contract BaseRegistrarImplementation is if (block.timestamp >= disputeUntil[id]) revert DisputePeriodOver(id); delete disputeUntil[id]; expiries[id] = 0; - ens.setSubnodeOwner(baseNode, bytes32(id), address(0)); + ens.setSubnodeRecord(baseNode, bytes32(id), address(0), address(0), 0); if (subnameHook != address(0)) { ISubnameHook(subnameHook).onExpiryChanged( keccak256(abi.encodePacked(baseNode, bytes32(id))), @@ -362,6 +361,8 @@ contract BaseRegistrarImplementation is /// `approve`, so a claim signature is valid for one offer and no later one. mapping(uint256 => uint256) public offers; + mapping(uint256 => uint256) public disputeUntil; + /// @dev ERC-5564 `Announcement`, verbatim in name, parameter list and /// indexing, so any indexer that knows the standard decodes ours by /// topic without special-casing. It carries the sender's ephemeral diff --git a/contracts/simplex/SimplexController.sol b/contracts/simplex/SimplexController.sol index 860fc07c0..ec08d578e 100644 --- a/contracts/simplex/SimplexController.sol +++ b/contracts/simplex/SimplexController.sol @@ -127,6 +127,7 @@ contract SimplexController is error OwnerMustBeCaller(); error NotSponsor(); error DisputeDaysOutOfRange(uint256 disputeDays); + error DisputePeriodNotOver(string name); event NameRegistered( string label, @@ -592,6 +593,8 @@ contract SimplexController is uint256 horizon ) private returns (uint256 expires) { if (duration < MIN_RENEWAL_DURATION) revert DurationTooShort(duration); + if (block.timestamp < base.disputeUntil(uint256(labelhash))) + revert DisputePeriodNotOver(label); if (INamePolicy(namePolicy).isReserved(labelhash)) revert NameReserved(label); @@ -603,8 +606,8 @@ contract SimplexController is function unregister(string calldata label) external onlyOwnerOrBeneficiary { bytes32 labelhash = keccak256(bytes(label)); - base.unregister(uint256(labelhash)); _retireStaleRecords(keccak256(abi.encodePacked(tldNode, labelhash))); + base.unregister(uint256(labelhash)); } /// @notice Pays the beneficiary, never `owner()`, so revenue is independent of diff --git a/test/ethregistrar/TestBaseRegistrar.test.ts b/test/ethregistrar/TestBaseRegistrar.test.ts index a6f3bf570..7ea2fdc18 100644 --- a/test/ethregistrar/TestBaseRegistrar.test.ts +++ b/test/ethregistrar/TestBaseRegistrar.test.ts @@ -32,7 +32,7 @@ const loadFixture = async () => connection.networkHelpers.loadFixture(fixture) async function fixtureWithRegistration() { const existing = await loadFixture() await existing.baseRegistrar.write.registerWithLabel( - ['newname', registrantAccount.address, 86400n], + ['newname', registrantAccount.address, 86400n, 0n], { account: controllerAccount, }, @@ -47,7 +47,7 @@ describe('BaseRegistrar', () => { const { ensRegistry, baseRegistrar } = await loadFixture() const hash = await baseRegistrar.write.registerWithLabel( - ['newname', registrantAccount.address, 86400n], + ['newname', registrantAccount.address, 86400n, 0n], { account: controllerAccount, }, @@ -87,7 +87,7 @@ describe('BaseRegistrar', () => { await expect( baseRegistrar.write.registerWithLabel( - ['foo', otherAccount.address, 86400n], + ['foo', otherAccount.address, 86400n, 0n], { account: otherAccount, }, @@ -110,7 +110,7 @@ describe('BaseRegistrar', () => { await expect( baseRegistrar.write.registerWithLabel( - ['newname', registrantAccount.address, 86400n], + ['newname', registrantAccount.address, 86400n, 0n], { account: controllerAccount, }, @@ -255,7 +255,7 @@ describe('BaseRegistrar', () => { ).toBeRevertedWithoutReason() await baseRegistrar.write.registerWithLabel( - ['newname', otherAccount.address, 86400n], + ['newname', otherAccount.address, 86400n, 0n], { account: controllerAccount, }, diff --git a/test/simplex/TestDisputePeriod.test.ts b/test/simplex/TestDisputePeriod.test.ts index 598b27c0a..ff602dd2a 100644 --- a/test/simplex/TestDisputePeriod.test.ts +++ b/test/simplex/TestDisputePeriod.test.ts @@ -186,9 +186,8 @@ describe('dispute period', () => { it('gives the payable path and registerReserved no dispute period', async () => { const f = await load() + await paid(f, 'paidineth') expect(await f.baseRegistrar.read.disputeUntil([id('paidineth')])).toBe(0n) - const time = await paid(f, 'paidineth') - expect(await f.baseRegistrar.read.disputeUntil([id('paidineth')])).toBe(time) await f.namePolicy.write.addReservedNames( [['brandname'], Reason.Trademark], { account: guardian }, @@ -249,8 +248,16 @@ describe('dispute period', () => { f.baseRegistrar.read.ownerOf([id('disputed')]), ).toBeRevertedWithoutReason() expect(await f.ens.read.owner([node('disputed')])).toBe(zeroAddress) + expect(await f.ens.read.resolver([node('disputed')])).toBe(zeroAddress) expect(await f.resolver.read.text([node('disputed'), KEY])).toBe('') expect(await f.subnameRegistrar.read.ownerOf([sub])).toBe(zeroAddress) + expect(await f.subnameRegistrar.read.expiryOf([node('disputed')])).toBe(0n) + await f.subnameRegistrar.write.purge([node('disputed'), [labelhash('pay')]], { + account: carol, + }) + expect( + await f.subnameRegistrar.read.childrenLength([node('disputed')]), + ).toBe(0n) await expect( f.resolver.write.setText([node('disputed'), KEY, 'https://smp/again'], { account: alice, @@ -301,12 +308,12 @@ describe('dispute period', () => { }) const sub = await withSubname(f, 'freedname') await unregister(f, 'freedname') - const time = await paid(f, 'freedname', bob) + await paid(f, 'freedname', bob) expect(await f.baseRegistrar.read.ownerOf([id('freedname')])).toBe( getAddress(bob.address), ) expect(await f.baseRegistrar.read.balanceOf([alice.address])).toBe(0n) - expect(await f.baseRegistrar.read.disputeUntil([id('freedname')])).toBe(time) + expect(await f.baseRegistrar.read.disputeUntil([id('freedname')])).toBe(0n) expect(await f.subnameRegistrar.read.ownerOf([sub])).toBe(zeroAddress) expect(await f.resolver.read.text([node('freedname'), KEY])).toBe('') }) @@ -344,18 +351,34 @@ describe('dispute period', () => { expect(await f.ens.read.owner([node('soldearly')])).toBe(zeroAddress) }) - it('ends a renewal made in the dispute period with the registration', async () => { + it('refuses a renewal on both paths until the dispute period ends', async () => { const f = await load() - await sponsored(f, 'renewedearly') - await acceptGeneralTermsForRenewal(connection, f.controller, 'renewedearly', YEAR, { + const until = await sponsored(f, 'renewlater') + await acceptGeneralTermsForRenewal(connection, f.controller, 'renewlater', YEAR, { account: alice, }) - await f.controller.write.renew(['renewedearly', YEAR, zeroHash], { + await expect( + f.sponsor.write.renewWithCredit(['renewlater', YEAR, zeroHash, alice.address], { + account: registrar, + }), + ).toBeRevertedWithCustomErrorFrom(f.controller, 'DisputePeriodNotOver') + await exactly(until - 1n) + await expect( + f.controller.write.renew(['renewlater', YEAR, zeroHash], { + account: alice, + value: YEAR_PRICE_USD, + ...EXACT, + }), + ).toBeRevertedWithCustomError('DisputePeriodNotOver') + await exactly(until) + await f.controller.write.renew(['renewlater', YEAR, zeroHash], { account: alice, value: YEAR_PRICE_USD, + ...EXACT, }) - await unregister(f, 'renewedearly') - expect(await f.baseRegistrar.read.nameExpires([id('renewedearly')])).toBe(0n) + expect(await f.baseRegistrar.read.nameExpires([id('renewlater')])).toBe( + until - MIN_DISPUTE_DAYS * DAY + MIN_REGISTRATION + YEAR, + ) }) it('is made on the registrar by a registrar controller only', async () => { diff --git a/test/simplex/TestLaunchLifecycle.test.ts b/test/simplex/TestLaunchLifecycle.test.ts index b7cb334df..67fdb3db7 100644 --- a/test/simplex/TestLaunchLifecycle.test.ts +++ b/test/simplex/TestLaunchLifecycle.test.ts @@ -23,6 +23,7 @@ import { implementationOf, type InitializeParameters, MIN_REGISTRATION, + passDisputePeriod, PRICE_BASE, PRICE_EXCEPTIONS, registerWithCredit, @@ -743,6 +744,7 @@ describe('launch lifecycle', () => { const allowanceBefore = await sponsor.read.registrarAllowance([ registrar.address, ]) + await passDisputePeriod(connection) await sponsor.write.renewWithCredit([OWNED, YEAR, zeroHash], { account: registrar, }) diff --git a/test/simplex/TestPublicSalesSwitch.test.ts b/test/simplex/TestPublicSalesSwitch.test.ts index 5ea09ba71..73263c295 100644 --- a/test/simplex/TestPublicSalesSwitch.test.ts +++ b/test/simplex/TestPublicSalesSwitch.test.ts @@ -7,6 +7,7 @@ import { commitUnderGeneralTerms, deployNamesV2, MIN_REGISTRATION, + passDisputePeriod, registerWithCredit, registration, sponsorOf, @@ -92,6 +93,7 @@ describe('public sales switch', () => { it('renewal is exempt in both forms, so a pause never costs anyone a name', async () => { const { controller, sponsor } = await load() await creditedRegister(controller, 'renewany') + await passDisputePeriod(connection) expect(await controller.read.publicSalesOpen()).toBe(false) await controller.write.renew(['renewany', YEAR, zeroHash], { diff --git a/test/simplex/TestRegistrarAllowance.test.ts b/test/simplex/TestRegistrarAllowance.test.ts index 9310bcf8d..272958323 100644 --- a/test/simplex/TestRegistrarAllowance.test.ts +++ b/test/simplex/TestRegistrarAllowance.test.ts @@ -6,6 +6,7 @@ import { AMPLE_ALLOWANCE, commitUnderGeneralTerms, deployNamesV2, + passDisputePeriod, registerWithCredit, registration, signRegistration, @@ -260,6 +261,7 @@ describe('registrar allowance', () => { { account: guardian }, ) await sponsoredRegister(controller, registration('renewable', alice.address)) + await passDisputePeriod(connection) const afterRegister = await sponsor.read.registrarAllowance([ registrar.address, ]) @@ -309,6 +311,7 @@ describe('registrar allowance', () => { { account: guardian }, ) await sponsoredRegister(controller, registration('decade', alice.address)) + await passDisputePeriod(connection) await sponsor.write.renewWithCredit(['decade', 9n * YEAR, zeroHash], { account: registrar, }) diff --git a/test/simplex/TestSponsoredPathIndependence.test.ts b/test/simplex/TestSponsoredPathIndependence.test.ts index b92d83f56..252fae64a 100644 --- a/test/simplex/TestSponsoredPathIndependence.test.ts +++ b/test/simplex/TestSponsoredPathIndependence.test.ts @@ -6,6 +6,7 @@ import { AMPLE_ALLOWANCE, commitUnderGeneralTerms, deployNamesV2, + passDisputePeriod, registerWithCredit, registration, sponsorOf, @@ -63,6 +64,7 @@ describe('the sponsored path does not depend on the price feed', () => { const tokenId = BigInt(labelhash('deadfeed')) const before = await baseRegistrar.read.nameExpires([tokenId]) + await passDisputePeriod(connection) await sponsor.write.renewWithCredit(['deadfeed', YEAR, zeroHash], { account: registrar, }) @@ -118,6 +120,7 @@ describe('the sponsored path does not depend on the price feed', () => { it('credited renewal emits a zero cost too', async () => { const { controller, sponsor } = await load() await sponsoredRegister(controller, 'renewevent') + await passDisputePeriod(connection) const hash = await sponsor.write.renewWithCredit( ['renewevent', YEAR, zeroHash], { account: registrar }, diff --git a/test/simplex/fixtures/namesV2.ts b/test/simplex/fixtures/namesV2.ts index 0c66e3ced..4ca6b2f05 100644 --- a/test/simplex/fixtures/namesV2.ts +++ b/test/simplex/fixtures/namesV2.ts @@ -516,6 +516,9 @@ export const FAR_FUTURE = 4102444800n export const MIN_DISPUTE_DAYS = 14n +export const passDisputePeriod = (connection: NetworkConnection) => + connection.networkHelpers.time.increase(MIN_DISPUTE_DAYS * DAY) + /** Sign one of the intents above against `verifyingContract`. */ export async function signIntent( publicClient: any, From 5733bba57b2110193d40364730ea307d0b76479b Mon Sep 17 00:00:00 2001 From: brenzi-agent <346870783+brenzi-agent@users.noreply.github.com> Date: Thu, 19 Nov 2026 15:01:29 +0000 Subject: [PATCH 04/13] test: registerReserved stores no dispute end --- test/simplex/TestDisputePeriod.test.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/test/simplex/TestDisputePeriod.test.ts b/test/simplex/TestDisputePeriod.test.ts index ff602dd2a..de1a7093b 100644 --- a/test/simplex/TestDisputePeriod.test.ts +++ b/test/simplex/TestDisputePeriod.test.ts @@ -196,6 +196,7 @@ describe('dispute period', () => { ['brandname', bob.address, MIN_REGISTRATION], { account: owner }, ) + expect(await f.baseRegistrar.read.disputeUntil([id('brandname')])).toBe(0n) for (const label of ['paidineth', 'brandname']) await expect(unregister(f, label)).toBeRevertedWithCustomErrorFrom( f.baseRegistrar, From 49ec5c8375309f8b3b4316dc082ed880d8faedde Mon Sep 17 00:00:00 2001 From: brenzi-agent <346870783+brenzi-agent@users.noreply.github.com> Date: Thu, 19 Nov 2026 15:25:40 +0000 Subject: [PATCH 05/13] BaseRegistrarImplementation: refuse renewals in a dispute period; SimplexController: clear the default resolver on unregister --- .../BaseRegistrarImplementation.sol | 2 + contracts/simplex/SimplexController.sol | 8 +- test/simplex/TestDisputePeriod.test.ts | 90 ++++++++++++++----- 3 files changed, 74 insertions(+), 26 deletions(-) diff --git a/contracts/ethregistrar/BaseRegistrarImplementation.sol b/contracts/ethregistrar/BaseRegistrarImplementation.sol index 9f6d246b0..d2f6dd474 100644 --- a/contracts/ethregistrar/BaseRegistrarImplementation.sol +++ b/contracts/ethregistrar/BaseRegistrarImplementation.sol @@ -65,6 +65,7 @@ contract BaseRegistrarImplementation is error LabelTooLong(uint256 length, uint256 max); error NamePolicyMismatch(); error DisputePeriodOver(uint256 id); + error DisputePeriodNotOver(uint256 id); /// v2.1.3 version of _isApprovedOrOwner which calls ownerOf(tokenId) and takes grace period into consideration instead of ERC721.ownerOf(tokenId); /// https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v2.1.3/contracts/token/ERC721/ERC721.sol#L187 @@ -227,6 +228,7 @@ contract BaseRegistrarImplementation is uint256 id, uint256 duration ) external override live onlyController returns (uint256) { + if (block.timestamp < disputeUntil[id]) revert DisputePeriodNotOver(id); require(expiries[id] + GRACE_PERIOD >= block.timestamp); // Name must be registered here or in grace period require( expiries[id] + duration + GRACE_PERIOD > duration + GRACE_PERIOD diff --git a/contracts/simplex/SimplexController.sol b/contracts/simplex/SimplexController.sol index ec08d578e..c06be4229 100644 --- a/contracts/simplex/SimplexController.sol +++ b/contracts/simplex/SimplexController.sol @@ -127,7 +127,6 @@ contract SimplexController is error OwnerMustBeCaller(); error NotSponsor(); error DisputeDaysOutOfRange(uint256 disputeDays); - error DisputePeriodNotOver(string name); event NameRegistered( string label, @@ -593,8 +592,6 @@ contract SimplexController is uint256 horizon ) private returns (uint256 expires) { if (duration < MIN_RENEWAL_DURATION) revert DurationTooShort(duration); - if (block.timestamp < base.disputeUntil(uint256(labelhash))) - revert DisputePeriodNotOver(label); if (INamePolicy(namePolicy).isReserved(labelhash)) revert NameReserved(label); @@ -606,7 +603,10 @@ contract SimplexController is function unregister(string calldata label) external onlyOwnerOrBeneficiary { bytes32 labelhash = keccak256(bytes(label)); - _retireStaleRecords(keccak256(abi.encodePacked(tldNode, labelhash))); + bytes32 node = keccak256(abi.encodePacked(tldNode, labelhash)); + _retireStaleRecords(node); + address resolver = defaultResolver; + if (resolver != address(0)) IClearableResolver(resolver).clearRecords(node); base.unregister(uint256(labelhash)); } diff --git a/test/simplex/TestDisputePeriod.test.ts b/test/simplex/TestDisputePeriod.test.ts index de1a7093b..dcf7883b3 100644 --- a/test/simplex/TestDisputePeriod.test.ts +++ b/test/simplex/TestDisputePeriod.test.ts @@ -354,32 +354,78 @@ describe('dispute period', () => { it('refuses a renewal on both paths until the dispute period ends', async () => { const f = await load() - const until = await sponsored(f, 'renewlater') - await acceptGeneralTermsForRenewal(connection, f.controller, 'renewlater', YEAR, { + const paths = { + renewpaid: () => + f.controller.write.renew(['renewpaid', YEAR, zeroHash], { + account: alice, + value: YEAR_PRICE_USD, + ...EXACT, + }), + renewcredit: () => + f.sponsor.write.renewWithCredit(['renewcredit', YEAR, zeroHash, alice.address], { + account: registrar, + ...EXACT, + }), + } + for (const [label, renew] of Object.entries(paths)) { + const until = await sponsored(f, label) + await acceptGeneralTermsForRenewal(connection, f.controller, label, YEAR, { + account: alice, + }) + await exactly(until - 1n) + await expect(renew()).toBeRevertedWithCustomErrorFrom( + f.baseRegistrar, + 'DisputePeriodNotOver', + ) + await exactly(until) + await renew() + expect(await f.baseRegistrar.read.nameExpires([id(label)])).toBe( + until - MIN_DISPUTE_DAYS * DAY + MIN_REGISTRATION + YEAR, + ) + } + }) + + it('clears the default resolver although the holder points the name elsewhere', async () => { + const f = await load() + await sponsored(f, 'repointed', { resolver: f.resolver.address }) + await f.resolver.write.setText([node('repointed'), KEY, 'https://smp/alice'], { account: alice, }) - await expect( - f.sponsor.write.renewWithCredit(['renewlater', YEAR, zeroHash, alice.address], { - account: registrar, - }), - ).toBeRevertedWithCustomErrorFrom(f.controller, 'DisputePeriodNotOver') - await exactly(until - 1n) - await expect( - f.controller.write.renew(['renewlater', YEAR, zeroHash], { - account: alice, - value: YEAR_PRICE_USD, - ...EXACT, - }), - ).toBeRevertedWithCustomError('DisputePeriodNotOver') - await exactly(until) - await f.controller.write.renew(['renewlater', YEAR, zeroHash], { + await f.ens.write.setResolver([node('repointed'), zeroAddress], { account: alice, - value: YEAR_PRICE_USD, - ...EXACT, }) - expect(await f.baseRegistrar.read.nameExpires([id('renewlater')])).toBe( - until - MIN_DISPUTE_DAYS * DAY + MIN_REGISTRATION + YEAR, - ) + await unregister(f, 'repointed') + await sponsored(f, 'repointed', { holder: bob, resolver: f.resolver.address }) + expect(await f.resolver.read.text([node('repointed'), KEY])).toBe('') + }) + + it('clears a past default resolver the name points at', async () => { + const f = await load() + await sponsored(f, 'pastdefault', { resolver: f.resolver.address }) + await f.resolver.write.setText([node('pastdefault'), KEY, 'https://smp/alice'], { + account: alice, + }) + const next = await connection.viem.deployContract('SimplexResolver', [ + f.ens.address, + f.subnameRegistrar.address, + f.controller.address, + zeroAddress, + ]) + await f.controller.write.setDefaultResolver([next.address], { account: owner }) + await unregister(f, 'pastdefault') + expect(await f.resolver.read.text([node('pastdefault'), KEY])).toBe('') + }) + + it('is made without a default resolver and after the freeze', async () => { + const f = await load() + await sponsored(f, 'nodefault') + await sponsored(f, 'afterfreeze') + await f.controller.write.setDefaultResolver([zeroAddress], { account: owner }) + await unregister(f, 'nodefault') + await f.controller.write.freeze({ account: owner }) + await unregister(f, 'afterfreeze') + for (const label of ['nodefault', 'afterfreeze']) + expect(await f.baseRegistrar.read.nameExpires([id(label)])).toBe(0n) }) it('is made on the registrar by a registrar controller only', async () => { From f1959db09440cdebebb04db7f91e9943ded53be3 Mon Sep 17 00:00:00 2001 From: brenzi-agent <346870783+brenzi-agent@users.noreply.github.com> Date: Thu, 19 Nov 2026 15:49:46 +0000 Subject: [PATCH 06/13] BaseRegistrarImplementation: bind unregister to the registration's dispute end --- .../BaseRegistrarImplementation.sol | 4 ++- contracts/simplex/SimplexController.sol | 4 +-- test/simplex/TestDisputePeriod.test.ts | 27 ++++++++++++++++--- 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/contracts/ethregistrar/BaseRegistrarImplementation.sol b/contracts/ethregistrar/BaseRegistrarImplementation.sol index d2f6dd474..962d9a2a6 100644 --- a/contracts/ethregistrar/BaseRegistrarImplementation.sol +++ b/contracts/ethregistrar/BaseRegistrarImplementation.sol @@ -66,6 +66,7 @@ contract BaseRegistrarImplementation is error NamePolicyMismatch(); error DisputePeriodOver(uint256 id); error DisputePeriodNotOver(uint256 id); + error DisputeUntilMismatch(uint256 id); /// v2.1.3 version of _isApprovedOrOwner which calls ownerOf(tokenId) and takes grace period into consideration instead of ERC721.ownerOf(tokenId); /// https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v2.1.3/contracts/token/ERC721/ERC721.sol#L187 @@ -245,7 +246,8 @@ contract BaseRegistrarImplementation is return expiries[id]; } - function unregister(uint256 id) external live onlyController { + function unregister(uint256 id, uint256 until) external live onlyController { + if (disputeUntil[id] != until) revert DisputeUntilMismatch(id); if (block.timestamp >= disputeUntil[id]) revert DisputePeriodOver(id); delete disputeUntil[id]; expiries[id] = 0; diff --git a/contracts/simplex/SimplexController.sol b/contracts/simplex/SimplexController.sol index c06be4229..c80e7fb90 100644 --- a/contracts/simplex/SimplexController.sol +++ b/contracts/simplex/SimplexController.sol @@ -601,13 +601,13 @@ contract SimplexController is emit NameRenewed(label, labelhash, cost, expires, referrer); } - function unregister(string calldata label) external onlyOwnerOrBeneficiary { + function unregister(string calldata label, uint256 until) external onlyOwnerOrBeneficiary { bytes32 labelhash = keccak256(bytes(label)); bytes32 node = keccak256(abi.encodePacked(tldNode, labelhash)); _retireStaleRecords(node); address resolver = defaultResolver; if (resolver != address(0)) IClearableResolver(resolver).clearRecords(node); - base.unregister(uint256(labelhash)); + base.unregister(uint256(labelhash), until); } /// @notice Pays the beneficiary, never `owner()`, so revenue is independent of diff --git a/test/simplex/TestDisputePeriod.test.ts b/test/simplex/TestDisputePeriod.test.ts index dcf7883b3..a641af2c0 100644 --- a/test/simplex/TestDisputePeriod.test.ts +++ b/test/simplex/TestDisputePeriod.test.ts @@ -107,12 +107,16 @@ async function paid(f: Fixture, label: string, holder: Account = alice) { ) } -const unregister = ( +const unregister = async ( f: Fixture, label: string, account: Account = guardian, options = {}, -) => f.controller.write.unregister([label], { account, ...options }) +) => + f.controller.write.unregister( + [label, await f.baseRegistrar.read.disputeUntil([id(label)])], + { account, ...options }, + ) async function withSubname(f: Fixture, label: string) { await f.ens.write.setApprovalForAll([f.subnameRegistrar.address, true], { @@ -330,6 +334,21 @@ describe('dispute period', () => { expect(await f.baseRegistrar.read.disputeUntil([id('secondsale')])).toBe(until) }) + it('refuses an unregistration prepared for an earlier registration of the name', async () => { + const f = await load() + const first = await sponsored(f, 'resold') + await unregister(f, 'resold') + const second = await sponsored(f, 'resold', { holder: bob }) + await expect( + f.controller.write.unregister(['resold', first], { account: guardian }), + ).toBeRevertedWithCustomErrorFrom(f.baseRegistrar, 'DisputeUntilMismatch') + expect(await f.baseRegistrar.read.ownerOf([id('resold')])).toBe( + getAddress(bob.address), + ) + await f.controller.write.unregister(['resold', second], { account: guardian }) + expect(await f.baseRegistrar.read.nameExpires([id('resold')])).toBe(0n) + }) + it('takes the name from a recipient of a claim in the dispute period', async () => { const f = await load() await sponsored(f, 'soldearly') @@ -430,10 +449,10 @@ describe('dispute period', () => { it('is made on the registrar by a registrar controller only', async () => { const f = await load() - await sponsored(f, 'directcall') + const until = await sponsored(f, 'directcall') for (const account of [owner, guardian, alice]) await expect( - f.baseRegistrar.write.unregister([id('directcall')], { account }), + f.baseRegistrar.write.unregister([id('directcall'), until], { account }), ).toBeRevertedWithoutReason() expect(await f.baseRegistrar.read.ownerOf([id('directcall')])).toBe( getAddress(alice.address), From e16a16e0de0cf64bab76d5ebf3266a66982e3681 Mon Sep 17 00:00:00 2001 From: brenzi-agent <346870783+brenzi-agent@users.noreply.github.com> Date: Thu, 19 Nov 2026 15:53:22 +0000 Subject: [PATCH 07/13] test: pass the dispute end to every unregistration --- test/simplex/TestDisputePeriod.test.ts | 72 +++++++++++++------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/test/simplex/TestDisputePeriod.test.ts b/test/simplex/TestDisputePeriod.test.ts index a641af2c0..3fc1d0e17 100644 --- a/test/simplex/TestDisputePeriod.test.ts +++ b/test/simplex/TestDisputePeriod.test.ts @@ -107,16 +107,13 @@ async function paid(f: Fixture, label: string, holder: Account = alice) { ) } -const unregister = async ( +const unregister = ( f: Fixture, label: string, + until: bigint, account: Account = guardian, options = {}, -) => - f.controller.write.unregister( - [label, await f.baseRegistrar.read.disputeUntil([id(label)])], - { account, ...options }, - ) +) => f.controller.write.unregister([label, until], { account, ...options }) async function withSubname(f: Fixture, label: string) { await f.ens.write.setApprovalForAll([f.subnameRegistrar.address, true], { @@ -202,7 +199,7 @@ describe('dispute period', () => { ) expect(await f.baseRegistrar.read.disputeUntil([id('brandname')])).toBe(0n) for (const label of ['paidineth', 'brandname']) - await expect(unregister(f, label)).toBeRevertedWithCustomErrorFrom( + await expect(unregister(f, label, 0n)).toBeRevertedWithCustomErrorFrom( f.baseRegistrar, 'DisputePeriodOver', ) @@ -212,21 +209,21 @@ describe('dispute period', () => { describe('unregistration', () => { it('is made by the guardian or the admin, before the end of the dispute period', async () => { const f = await load() - await sponsored(f, 'byguardian') - await sponsored(f, 'byadmin') + const byGuardian = await sponsored(f, 'byguardian') + const byAdmin = await sponsored(f, 'byadmin') const lastSecond = await sponsored(f, 'lastsecond') const atEnd = await sponsored(f, 'atitsend') for (const account of [registrar, alice, carol]) await expect( - unregister(f, 'byguardian', account), + unregister(f, 'byguardian', byGuardian, account), ).toBeRevertedWithCustomError('NotOwnerOrBeneficiary') - await unregister(f, 'byguardian', guardian) - await unregister(f, 'byadmin', owner) + await unregister(f, 'byguardian', byGuardian, guardian) + await unregister(f, 'byadmin', byAdmin, owner) await exactly(lastSecond - 1n) - await unregister(f, 'lastsecond', guardian, EXACT) + await unregister(f, 'lastsecond', lastSecond, guardian, EXACT) await exactly(atEnd) await expect( - unregister(f, 'atitsend', guardian, EXACT), + unregister(f, 'atitsend', atEnd, guardian, EXACT), ).toBeRevertedWithCustomErrorFrom(f.baseRegistrar, 'DisputePeriodOver') for (const label of ['byguardian', 'byadmin', 'lastsecond']) expect(await f.baseRegistrar.read.nameExpires([id(label)])).toBe(0n) @@ -237,12 +234,12 @@ describe('dispute period', () => { it('ends the registration, its records and its subnames at once', async () => { const f = await load() - await sponsored(f, 'disputed', { resolver: f.resolver.address }) + const until = await sponsored(f, 'disputed', { resolver: f.resolver.address }) await f.resolver.write.setText([node('disputed'), KEY, 'https://smp/alice'], { account: alice, }) const sub = await withSubname(f, 'disputed') - await expect(unregister(f, 'disputed')) + await expect(unregister(f, 'disputed', until)) .toEmitEventFrom(f.baseRegistrar, 'NameUnregistered') .withArgs({ id: id('disputed') }) expect(await f.baseRegistrar.read.nameExpires([id('disputed')])).toBe(0n) @@ -268,7 +265,11 @@ describe('dispute period', () => { account: alice, }), ).toBeRevertedWithoutReason() - await expect(unregister(f, 'disputed')).toBeRevertedWithCustomErrorFrom( + await expect(unregister(f, 'disputed', until)).toBeRevertedWithCustomErrorFrom( + f.baseRegistrar, + 'DisputeUntilMismatch', + ) + await expect(unregister(f, 'disputed', 0n)).toBeRevertedWithCustomErrorFrom( f.baseRegistrar, 'DisputePeriodOver', ) @@ -276,7 +277,7 @@ describe('dispute period', () => { it('refuses a claim and a renewal of an unregistered name', async () => { const f = await load() - await sponsored(f, 'nomoreclaim') + const until = await sponsored(f, 'nomoreclaim') await f.baseRegistrar.write.approve([bob.address, id('nomoreclaim')], { account: alice, }) @@ -287,7 +288,7 @@ describe('dispute period', () => { alice.address, { account: bob }, ) - await unregister(f, 'nomoreclaim') + await unregister(f, 'nomoreclaim', until) await expect( f.baseRegistrar.write.transferFrom( [alice.address, bob.address, id('nomoreclaim')], @@ -307,12 +308,12 @@ describe('dispute period', () => { it('lets anyone register the name again at once, without the old subnames and records', async () => { const f = await load() - await sponsored(f, 'freedname', { resolver: f.resolver.address }) + const until = await sponsored(f, 'freedname', { resolver: f.resolver.address }) await f.resolver.write.setText([node('freedname'), KEY, 'https://smp/alice'], { account: alice, }) const sub = await withSubname(f, 'freedname') - await unregister(f, 'freedname') + await unregister(f, 'freedname', until) await paid(f, 'freedname', bob) expect(await f.baseRegistrar.read.ownerOf([id('freedname')])).toBe( getAddress(bob.address), @@ -325,8 +326,7 @@ describe('dispute period', () => { it('writes a new dispute end at a sponsored registration after an unregistration', async () => { const f = await load() - await sponsored(f, 'secondsale') - await unregister(f, 'secondsale') + await unregister(f, 'secondsale', await sponsored(f, 'secondsale')) const until = await sponsored(f, 'secondsale', { holder: bob, days: MAX_DISPUTE_DAYS, @@ -337,21 +337,21 @@ describe('dispute period', () => { it('refuses an unregistration prepared for an earlier registration of the name', async () => { const f = await load() const first = await sponsored(f, 'resold') - await unregister(f, 'resold') + await unregister(f, 'resold', first) const second = await sponsored(f, 'resold', { holder: bob }) await expect( - f.controller.write.unregister(['resold', first], { account: guardian }), + unregister(f, 'resold', first), ).toBeRevertedWithCustomErrorFrom(f.baseRegistrar, 'DisputeUntilMismatch') expect(await f.baseRegistrar.read.ownerOf([id('resold')])).toBe( getAddress(bob.address), ) - await f.controller.write.unregister(['resold', second], { account: guardian }) + await unregister(f, 'resold', second) expect(await f.baseRegistrar.read.nameExpires([id('resold')])).toBe(0n) }) it('takes the name from a recipient of a claim in the dispute period', async () => { const f = await load() - await sponsored(f, 'soldearly') + const until = await sponsored(f, 'soldearly') await f.baseRegistrar.write.approve([bob.address, id('soldearly')], { account: alice, }) @@ -366,7 +366,7 @@ describe('dispute period', () => { [alice.address, bob.address, id('soldearly')], { account: bob }, ) - await unregister(f, 'soldearly') + await unregister(f, 'soldearly', until) expect(await f.baseRegistrar.read.nameExpires([id('soldearly')])).toBe(0n) expect(await f.ens.read.owner([node('soldearly')])).toBe(zeroAddress) }) @@ -406,21 +406,21 @@ describe('dispute period', () => { it('clears the default resolver although the holder points the name elsewhere', async () => { const f = await load() - await sponsored(f, 'repointed', { resolver: f.resolver.address }) + const until = await sponsored(f, 'repointed', { resolver: f.resolver.address }) await f.resolver.write.setText([node('repointed'), KEY, 'https://smp/alice'], { account: alice, }) await f.ens.write.setResolver([node('repointed'), zeroAddress], { account: alice, }) - await unregister(f, 'repointed') + await unregister(f, 'repointed', until) await sponsored(f, 'repointed', { holder: bob, resolver: f.resolver.address }) expect(await f.resolver.read.text([node('repointed'), KEY])).toBe('') }) it('clears a past default resolver the name points at', async () => { const f = await load() - await sponsored(f, 'pastdefault', { resolver: f.resolver.address }) + const until = await sponsored(f, 'pastdefault', { resolver: f.resolver.address }) await f.resolver.write.setText([node('pastdefault'), KEY, 'https://smp/alice'], { account: alice, }) @@ -431,18 +431,18 @@ describe('dispute period', () => { zeroAddress, ]) await f.controller.write.setDefaultResolver([next.address], { account: owner }) - await unregister(f, 'pastdefault') + await unregister(f, 'pastdefault', until) expect(await f.resolver.read.text([node('pastdefault'), KEY])).toBe('') }) it('is made without a default resolver and after the freeze', async () => { const f = await load() - await sponsored(f, 'nodefault') - await sponsored(f, 'afterfreeze') + const noDefault = await sponsored(f, 'nodefault') + const afterFreeze = await sponsored(f, 'afterfreeze') await f.controller.write.setDefaultResolver([zeroAddress], { account: owner }) - await unregister(f, 'nodefault') + await unregister(f, 'nodefault', noDefault) await f.controller.write.freeze({ account: owner }) - await unregister(f, 'afterfreeze') + await unregister(f, 'afterfreeze', afterFreeze) for (const label of ['nodefault', 'afterfreeze']) expect(await f.baseRegistrar.read.nameExpires([id(label)])).toBe(0n) }) From c196505b11acb60fe2d45a87499f4369dade1884 Mon Sep 17 00:00:00 2001 From: brenzi-agent <346870783+brenzi-agent@users.noreply.github.com> Date: Thu, 19 Nov 2026 16:19:51 +0000 Subject: [PATCH 08/13] BaseRegistrarImplementation: name both dispute ends in DisputeUntilMismatch; test a blocking resolver --- contracts/ethregistrar/BaseRegistrarImplementation.sol | 6 +++--- contracts/simplex/SubnameRegistrar.sol | 2 +- test/simplex/TestDisputePeriod.test.ts | 10 ++++++++++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/contracts/ethregistrar/BaseRegistrarImplementation.sol b/contracts/ethregistrar/BaseRegistrarImplementation.sol index 962d9a2a6..68b09ad1f 100644 --- a/contracts/ethregistrar/BaseRegistrarImplementation.sol +++ b/contracts/ethregistrar/BaseRegistrarImplementation.sol @@ -21,7 +21,7 @@ interface ISubnameHook { /// @dev INVARIANT (ERC721Enumerable): enumeration (`totalSupply`, /// `tokenByIndex`, `balanceOf`, `tokenOfOwnerByIndex`) is maintained on /// transfer/mint/burn, NOT on expiry — a name is only burned when it is -/// re-registered after its grace period. So enumeration includes +/// re-registered after its grace period or its unregistration. So enumeration includes /// expired-but-unburned names and can disagree with the grace-period /// `ownerOf` (which reverts once expired). Readers MUST filter by /// `nameExpires(id) > block.timestamp` to get the live set. @@ -66,7 +66,7 @@ contract BaseRegistrarImplementation is error NamePolicyMismatch(); error DisputePeriodOver(uint256 id); error DisputePeriodNotOver(uint256 id); - error DisputeUntilMismatch(uint256 id); + error DisputeUntilMismatch(uint256 named, uint256 current); /// v2.1.3 version of _isApprovedOrOwner which calls ownerOf(tokenId) and takes grace period into consideration instead of ERC721.ownerOf(tokenId); /// https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v2.1.3/contracts/token/ERC721/ERC721.sol#L187 @@ -247,7 +247,7 @@ contract BaseRegistrarImplementation is } function unregister(uint256 id, uint256 until) external live onlyController { - if (disputeUntil[id] != until) revert DisputeUntilMismatch(id); + if (disputeUntil[id] != until) revert DisputeUntilMismatch(until, disputeUntil[id]); if (block.timestamp >= disputeUntil[id]) revert DisputePeriodOver(id); delete disputeUntil[id]; expiries[id] = 0; diff --git a/contracts/simplex/SubnameRegistrar.sol b/contracts/simplex/SubnameRegistrar.sol index 76bc5cbd1..0dbb9df43 100644 --- a/contracts/simplex/SubnameRegistrar.sol +++ b/contracts/simplex/SubnameRegistrar.sol @@ -402,7 +402,7 @@ contract SubnameRegistrar is ISubnameRegistrar { } /// @notice Called by BaseRegistrar whenever 2LD `node`'s expiry moves - /// (registration or renewal), so subname authority can follow the + /// (registration, renewal or unregistration), so subname authority can follow the /// registration rather than the registry record it outlives. function onExpiryChanged(bytes32 node, uint256 expiry) external { if (msg.sender != baseRegistrar) revert NotBaseRegistrar(); diff --git a/test/simplex/TestDisputePeriod.test.ts b/test/simplex/TestDisputePeriod.test.ts index 3fc1d0e17..a1f3e80fb 100644 --- a/test/simplex/TestDisputePeriod.test.ts +++ b/test/simplex/TestDisputePeriod.test.ts @@ -418,6 +418,16 @@ describe('dispute period', () => { expect(await f.resolver.read.text([node('repointed'), KEY])).toBe('') }) + it('is not blocked by a holder who points the name at a contract that is no resolver', async () => { + const f = await load() + const until = await sponsored(f, 'blocking') + await f.ens.write.setResolver([node('blocking'), f.sponsor.address], { + account: alice, + }) + await unregister(f, 'blocking', until) + expect(await f.baseRegistrar.read.nameExpires([id('blocking')])).toBe(0n) + }) + it('clears a past default resolver the name points at', async () => { const f = await load() const until = await sponsored(f, 'pastdefault', { resolver: f.resolver.address }) From 4f06810b2c4f64020a0d6d03f8e69eed8c9c11a1 Mon Sep 17 00:00:00 2001 From: brenzi-agent <346870783+brenzi-agent@users.noreply.github.com> Date: Thu, 19 Nov 2026 16:49:34 +0000 Subject: [PATCH 09/13] test: renew up to the exact eleven-year limit after the dispute period --- test/simplex/TestRegistrarAllowance.test.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/simplex/TestRegistrarAllowance.test.ts b/test/simplex/TestRegistrarAllowance.test.ts index 272958323..f6a0648ea 100644 --- a/test/simplex/TestRegistrarAllowance.test.ts +++ b/test/simplex/TestRegistrarAllowance.test.ts @@ -6,6 +6,7 @@ import { AMPLE_ALLOWANCE, commitUnderGeneralTerms, deployNamesV2, + MIN_DISPUTE_DAYS, passDisputePeriod, registerWithCredit, registration, @@ -15,6 +16,7 @@ import { YEAR_PRICE_USD, yearPriceUSD, } from './fixtures/namesV2.js' +import { DAY } from '../fixtures/constants.js' const connection = await hre.network.connect() const publicClient = await connection.viem.getPublicClient() @@ -312,7 +314,8 @@ describe('registrar allowance', () => { ) await sponsoredRegister(controller, registration('decade', alice.address)) await passDisputePeriod(connection) - await sponsor.write.renewWithCredit(['decade', 9n * YEAR, zeroHash], { + const longest = 9n * YEAR + MIN_DISPUTE_DAYS * DAY + await sponsor.write.renewWithCredit(['decade', longest, zeroHash], { account: registrar, }) await expect( From 6cfa9ea3e200c4c0542c271acbc980ed0c7aabd2 Mon Sep 17 00:00:00 2001 From: brenzi-agent <346870783+brenzi-agent@users.noreply.github.com> Date: Thu, 19 Nov 2026 17:37:24 +0000 Subject: [PATCH 10/13] BaseRegistrarImplementation: test unregister when not live; wrap lines --- .../ethregistrar/BaseRegistrarImplementation.sol | 15 +++++++++++---- contracts/simplex/SubnameRegistrar.sol | 3 ++- test/simplex/TestDisputePeriod.test.ts | 14 ++++++++++++++ 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/contracts/ethregistrar/BaseRegistrarImplementation.sol b/contracts/ethregistrar/BaseRegistrarImplementation.sol index 68b09ad1f..c7eb16c97 100644 --- a/contracts/ethregistrar/BaseRegistrarImplementation.sol +++ b/contracts/ethregistrar/BaseRegistrarImplementation.sol @@ -21,7 +21,8 @@ interface ISubnameHook { /// @dev INVARIANT (ERC721Enumerable): enumeration (`totalSupply`, /// `tokenByIndex`, `balanceOf`, `tokenOfOwnerByIndex`) is maintained on /// transfer/mint/burn, NOT on expiry — a name is only burned when it is -/// re-registered after its grace period or its unregistration. So enumeration includes +/// re-registered after its grace period or its unregistration. +/// So enumeration includes /// expired-but-unburned names and can disagree with the grace-period /// `ownerOf` (which reverts once expired). Readers MUST filter by /// `nameExpires(id) > block.timestamp` to get the live set. @@ -177,7 +178,9 @@ contract BaseRegistrarImplementation is if (bytes(labelOf[id]).length == 0) { labelOf[id] = label; } - disputeUntil[id] = disputePeriod == 0 ? 0 : block.timestamp + disputePeriod; + disputeUntil[id] = disputePeriod == 0 + ? 0 + : block.timestamp + disputePeriod; return _register(id, owner, duration); } @@ -246,8 +249,12 @@ contract BaseRegistrarImplementation is return expiries[id]; } - function unregister(uint256 id, uint256 until) external live onlyController { - if (disputeUntil[id] != until) revert DisputeUntilMismatch(until, disputeUntil[id]); + function unregister( + uint256 id, + uint256 until + ) external live onlyController { + if (disputeUntil[id] != until) + revert DisputeUntilMismatch(until, disputeUntil[id]); if (block.timestamp >= disputeUntil[id]) revert DisputePeriodOver(id); delete disputeUntil[id]; expiries[id] = 0; diff --git a/contracts/simplex/SubnameRegistrar.sol b/contracts/simplex/SubnameRegistrar.sol index 0dbb9df43..39d9fd76e 100644 --- a/contracts/simplex/SubnameRegistrar.sol +++ b/contracts/simplex/SubnameRegistrar.sol @@ -402,7 +402,8 @@ contract SubnameRegistrar is ISubnameRegistrar { } /// @notice Called by BaseRegistrar whenever 2LD `node`'s expiry moves - /// (registration, renewal or unregistration), so subname authority can follow the + /// (registration, renewal or unregistration), so subname + /// authority can follow the /// registration rather than the registry record it outlives. function onExpiryChanged(bytes32 node, uint256 expiry) external { if (msg.sender != baseRegistrar) revert NotBaseRegistrar(); diff --git a/test/simplex/TestDisputePeriod.test.ts b/test/simplex/TestDisputePeriod.test.ts index a1f3e80fb..fbfcfb427 100644 --- a/test/simplex/TestDisputePeriod.test.ts +++ b/test/simplex/TestDisputePeriod.test.ts @@ -21,6 +21,7 @@ import { Reason, registration, signRegistration, + TLD, YEAR, YEAR_PRICE_USD, } from './fixtures/namesV2.js' @@ -457,6 +458,19 @@ describe('dispute period', () => { expect(await f.baseRegistrar.read.nameExpires([id(label)])).toBe(0n) }) + it('is refused while the registrar does not own the TLD node', async () => { + const f = await load() + const until = await sponsored(f, 'notlive') + await f.ens.write.setSubnodeOwner([zeroHash, labelhash(TLD), carol.address], { + account: owner, + }) + await f.ens.write.setApprovalForAll([f.baseRegistrar.address, true], { + account: carol, + }) + await expect(unregister(f, 'notlive', until)).toBeRevertedWithoutReason() + expect(await f.baseRegistrar.read.nameExpires([id('notlive')])).not.toBe(0n) + }) + it('is made on the registrar by a registrar controller only', async () => { const f = await load() const until = await sponsored(f, 'directcall') From f858e5e8f06f39cb499fd8bd2ea96df9788cdf2c Mon Sep 17 00:00:00 2001 From: brenzi-agent <346870783+brenzi-agent@users.noreply.github.com> Date: Thu, 19 Nov 2026 18:50:17 +0000 Subject: [PATCH 11/13] test: disputeUntil in the registrar's layout; unregister without freeze --- test/simplex/TestDisputePeriod.test.ts | 12 ++++-------- test/simplex/__snapshots__/storageLayouts.json | 3 ++- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/test/simplex/TestDisputePeriod.test.ts b/test/simplex/TestDisputePeriod.test.ts index fbfcfb427..5be4e9fa7 100644 --- a/test/simplex/TestDisputePeriod.test.ts +++ b/test/simplex/TestDisputePeriod.test.ts @@ -446,16 +446,12 @@ describe('dispute period', () => { expect(await f.resolver.read.text([node('pastdefault'), KEY])).toBe('') }) - it('is made without a default resolver and after the freeze', async () => { + it('is made without a default resolver', async () => { const f = await load() - const noDefault = await sponsored(f, 'nodefault') - const afterFreeze = await sponsored(f, 'afterfreeze') + const until = await sponsored(f, 'nodefault') await f.controller.write.setDefaultResolver([zeroAddress], { account: owner }) - await unregister(f, 'nodefault', noDefault) - await f.controller.write.freeze({ account: owner }) - await unregister(f, 'afterfreeze', afterFreeze) - for (const label of ['nodefault', 'afterfreeze']) - expect(await f.baseRegistrar.read.nameExpires([id(label)])).toBe(0n) + await unregister(f, 'nodefault', until) + expect(await f.baseRegistrar.read.nameExpires([id('nodefault')])).toBe(0n) }) it('is refused while the registrar does not own the TLD node', async () => { diff --git a/test/simplex/__snapshots__/storageLayouts.json b/test/simplex/__snapshots__/storageLayouts.json index 9ea9b4012..934dcb3be 100644 --- a/test/simplex/__snapshots__/storageLayouts.json +++ b/test/simplex/__snapshots__/storageLayouts.json @@ -34,7 +34,8 @@ "18:0+32 BaseRegistrarImplementation.baseNode bytes32", "19:0+32 BaseRegistrarImplementation.controllers mapping(address => bool)", "20:0+32 BaseRegistrarImplementation.nonces mapping(address => uint256)", - "21:0+32 BaseRegistrarImplementation.offers mapping(uint256 => uint256)" + "21:0+32 BaseRegistrarImplementation.offers mapping(uint256 => uint256)", + "22:0+32 BaseRegistrarImplementation.disputeUntil mapping(uint256 => uint256)" ], "SimplexResolver": [ "0:0+32 ResolverBase.recordVersions mapping(bytes32 => uint64)", From a262fcf605296a659894c412c7f9c4c3922d45e8 Mon Sep 17 00:00:00 2001 From: brenzi-agent <346870783+brenzi-agent@users.noreply.github.com> Date: Thu, 19 Nov 2026 23:00:13 +0000 Subject: [PATCH 12/13] docs: unregister among the registrar functions the controller calls --- docs/upgrades.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/upgrades.md b/docs/upgrades.md index fef20f3b3..c1e3fb6b6 100644 --- a/docs/upgrades.md +++ b/docs/upgrades.md @@ -220,7 +220,7 @@ declaration order, so reordering them swaps the two lists; keep them unchanged | `ENSRegistry` | `SimplexResolver` | `owner` | | `ENSRegistry` | `Root` | `setSubnodeOwner`, `setResolver` | | `ENSRegistry` | `UniversalResolver` | `resolver` | -| `BaseRegistrarImplementation` | `SimplexController` | `available`, `nameExpires`, `registerWithLabel`, `renew`, `transferFrom` | +| `BaseRegistrarImplementation` | `SimplexController` | `available`, `nameExpires`, `registerWithLabel`, `renew`, `transferFrom`, `unregister` | | `BaseRegistrarImplementation` | `SimplexNamePolicy` | `available`, `registerWithLabel`, `transferFrom` | | `SimplexController` | `SimplexNamePolicy` | `owner`, `beneficiary`, `defaultResolver`, `wasDefaultResolver`, `commitments`, `maxCommitmentAge`, `commit`; `ens` and `tldNode` in its constructor | | `SimplexController` | `SimplexSponsor` | `beneficiary`, `rentPriceUSD`, `registerSponsored`, `renewSponsored` | From 78114e879509148a154cafa6d74d189b757548a8 Mon Sep 17 00:00:00 2001 From: brenzi-agent <346870783+brenzi-agent@users.noreply.github.com> Date: Fri, 20 Nov 2026 08:43:37 +0000 Subject: [PATCH 13/13] test: dispute period renewals on the upgradeable stack --- test/simplex/TestDisputePeriod.test.ts | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/test/simplex/TestDisputePeriod.test.ts b/test/simplex/TestDisputePeriod.test.ts index 5be4e9fa7..3a8805b91 100644 --- a/test/simplex/TestDisputePeriod.test.ts +++ b/test/simplex/TestDisputePeriod.test.ts @@ -11,7 +11,6 @@ import { describe, expect, it } from 'vitest' import { acceptGeneralTermsForClaim, - acceptGeneralTermsForRenewal, AMPLE_ALLOWANCE, commitUnderGeneralTerms, deployNamesV2, @@ -296,9 +295,6 @@ describe('dispute period', () => { { account: bob }, ), ).toBeRevertedWithoutReason() - await acceptGeneralTermsForRenewal(connection, f.controller, 'nomoreclaim', YEAR, { - account: alice, - }) await expect( f.controller.write.renew(['nomoreclaim', YEAR, zeroHash], { account: alice, @@ -382,16 +378,13 @@ describe('dispute period', () => { ...EXACT, }), renewcredit: () => - f.sponsor.write.renewWithCredit(['renewcredit', YEAR, zeroHash, alice.address], { + f.sponsor.write.renewWithCredit(['renewcredit', YEAR, zeroHash], { account: registrar, ...EXACT, }), } for (const [label, renew] of Object.entries(paths)) { const until = await sponsored(f, label) - await acceptGeneralTermsForRenewal(connection, f.controller, label, YEAR, { - account: alice, - }) await exactly(until - 1n) await expect(renew()).toBeRevertedWithCustomErrorFrom( f.baseRegistrar,