-
Notifications
You must be signed in to change notification settings - Fork 51
Add UpgradeableRegistrarController #123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
c307e78
Add upgradeable RegistrarController, make it EIP-7201 compliant'
stevieraykatz a578e14
Add interface to new ENS contract, add support for setting primary to…
stevieraykatz 5dfed4a
Add initializer for reverse resolver contract
stevieraykatz 43a53a7
Add shim for migration period
stevieraykatz fc735bf
Add tests for Shim
stevieraykatz 7a0d049
lint
stevieraykatz 8151302
Testing start
stevieraykatz 1fc8be7
chore: forge fmt
abdulla-cb 15ebd14
chore: typos
abdulla-cb d256095
forge install: openzeppelin-contracts-upgradeable
abdulla-cb 5214bc2
feat: use v5.0.0 of openzeppelin-contracts-upgradeable
abdulla-cb 34a313a
feat: update tests to use OpenZeppelin Upgradeable
abdulla-cb 78e3f28
chore: fix typo
abdulla-cb 5e64d7d
Update interface to ENS reverse resolver
stevieraykatz 5f78d9f
Remove launch logic
stevieraykatz d747ca0
remove shim from this branch
stevieraykatz c2bc49f
Add support for new cointypes array in reverse set
stevieraykatz 48feaf1
Add cointypes to test helper
stevieraykatz 6211b51
Remove test for removed method
stevieraykatz 0e17adf
Merge branch 'main' into upgradeable-registrar
stevieraykatz 148cb2c
attempt to fix ci
stevieraykatz eb85c2e
Cleanup test mocks
stevieraykatz 50a2c3f
Remove launch logic, cleanup test base
stevieraykatz 438d626
Fix missing refs from rename
stevieraykatz 91ce6d5
Remove reference to unused test var
stevieraykatz 2b85da9
fix _getExpiry
stevieraykatz e35b156
Fix Register test to use a duration
stevieraykatz 752aeb3
lint
stevieraykatz 3de1f8f
fix natspec
stevieraykatz cadfc45
Fixes to natspec and typos per comments on PR #95
stevieraykatz cdd4326
Add registrar controller switch-over integration test
stevieraykatz 4317ccc
chore: cleanup logging, formatting
stevieraykatz 6b124db
feat: add grace period renewal test
stevieraykatz c1a274a
chore: typos and gas
stevieraykatz 44be9dc
Merge branch 'main' into upgradeable-registrar
stevieraykatz 9d91fa3
Fix ext link ref to branch with updated code
stevieraykatz 3e0a849
add interface for new reverse registrar
stevieraykatz 465e843
lint interface
stevieraykatz 0102186
refactor reverse registration to leverage updated reverse registrar v2
stevieraykatz e48a19d
finish refactor to IReverseRegistrarV2
stevieraykatz b5a815c
Fix tests to account for new reverse registrar v2
stevieraykatz cce8e36
lint
stevieraykatz 51dc6e9
Nits from PR comments
stevieraykatz d8cb250
cleanup tests based on renamings
stevieraykatz 5a956e9
update submodules, pin solady version
stevieraykatz a3eb0c8
Revert "update submodules, pin solady version"
stevieraykatz 73afd8b
Natspec and cleanup from PR
stevieraykatz ad21ff6
Reorder modifiers
stevieraykatz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule openzeppelin-contracts-upgradeable
added at
fa5253
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.23; | ||
|
||
/// @title Interface for ReverseRegistrarV2 | ||
interface IReverseRegistrarV2 { | ||
/// @notice Transfers ownership of the base-specific reverse ENS record for `msg.sender` to the provided `owner`. | ||
stevieraykatz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
/// | ||
/// @param owner The address to set as the owner of the reverse record in ENS. | ||
/// | ||
/// @return The ENS node hash of the Base network-specific reverse record. | ||
function claim(address owner) external returns (bytes32); | ||
|
||
/// @notice Sets the reverse record `name` for `addr`. | ||
/// | ||
/// @param addr The name records will be set for this address. | ||
/// @param signatureExpiry The timestamp expiration of the signature. | ||
/// @param name The name that will be stored for `addr`. | ||
/// @param cointypes The array of networks-as-cointypes used in replayable reverse sets. | ||
/// @param signature The signature bytes. | ||
function setNameForAddrWithSignature( | ||
Comment on lines
+19
to
+20
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. nit, missing |
||
address addr, | ||
uint256 signatureExpiry, | ||
string calldata name, | ||
uint256[] memory cointypes, | ||
stevieraykatz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
bytes memory signature | ||
) external returns (bytes32); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
119 changes: 119 additions & 0 deletions
119
test/Integration/SwitchToUpgradeableRegistrarController.t.sol
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
//SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.23; | ||
|
||
import {Test} from "forge-std/Test.sol"; | ||
import {console} from "forge-std/console.sol"; | ||
|
||
import {IntegrationTestBase} from "./IntegrationTestBase.t.sol"; | ||
import {MockL2ReverseRegistrar} from "test/mocks/MockL2ReverseRegistrar.sol"; | ||
import {MockReverseRegistrarV2} from "test/mocks/MockReverseRegistrarV2.sol"; | ||
|
||
import {ExponentialPremiumPriceOracle} from "src/L2/ExponentialPremiumPriceOracle.sol"; | ||
import {IPriceOracle} from "src/L2/interface/IPriceOracle.sol"; | ||
import {UpgradeableRegistrarController} from "src/L2/UpgradeableRegistrarController.sol"; | ||
import {TransparentUpgradeableProxy} from | ||
"openzeppelin-contracts/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; | ||
|
||
import {BASE_ETH_NODE, GRACE_PERIOD} from "src/util/Constants.sol"; | ||
|
||
contract SwitchToUpgradeableRegistrarController is IntegrationTestBase { | ||
UpgradeableRegistrarController public controllerImpl; | ||
UpgradeableRegistrarController public controller; | ||
TransparentUpgradeableProxy public proxy; | ||
MockL2ReverseRegistrar public l2ReverseRegistrar; | ||
MockReverseRegistrarV2 public reverseRegistrarv2; | ||
|
||
address admin; | ||
uint256 duration = 365.25 days; | ||
|
||
uint256 constant UPGRADE_TIMESTAMP = 1746057600; // May 1 2025 | ||
|
||
function setUp() public override { | ||
super.setUp(); | ||
_registerAlice(); | ||
|
||
vm.warp(UPGRADE_TIMESTAMP); | ||
|
||
admin = makeAddr("admin"); | ||
|
||
l2ReverseRegistrar = new MockL2ReverseRegistrar(); | ||
reverseRegistrarv2 = new MockReverseRegistrarV2(); | ||
|
||
exponentialPremiumPriceOracle = new ExponentialPremiumPriceOracle( | ||
_getBasePrices(), EXPIRY_AUCTION_START_PRICE, EXPIRY_AUCTION_DURATION_DAYS | ||
); | ||
|
||
bytes memory controllerInitData = abi.encodeWithSelector( | ||
UpgradeableRegistrarController.initialize.selector, | ||
baseRegistrar, | ||
exponentialPremiumPriceOracle, | ||
reverseRegistrarv2, | ||
owner, | ||
BASE_ETH_NODE, | ||
".base.eth", | ||
payments, | ||
address(registrarController), | ||
address(l2ReverseRegistrar) | ||
); | ||
|
||
controllerImpl = new UpgradeableRegistrarController(); | ||
proxy = new TransparentUpgradeableProxy(address(controllerImpl), admin, controllerInitData); | ||
controller = UpgradeableRegistrarController(address(proxy)); | ||
|
||
_postDeployConfig(); | ||
} | ||
|
||
function _postDeployConfig() internal { | ||
vm.startPrank(owner); | ||
baseRegistrar.addController(address(proxy)); | ||
reverseRegistrar.setControllerApproval(address(proxy), true); | ||
defaultL2Resolver.setRegistrarController(address(proxy)); | ||
vm.stopPrank(); | ||
} | ||
|
||
function test_canRegisterANewName() public { | ||
string memory name = "new-name"; | ||
uint256[] memory coinTypes = new uint256[](1); | ||
coinTypes[0] = 0x80000000 | 0x00002105; | ||
|
||
uint256 registerPrice = controller.registerPrice(name, duration); | ||
uint256 expectedPrice = _getBasePrices()[4] * duration; | ||
vm.assertEq(registerPrice, expectedPrice); | ||
|
||
UpgradeableRegistrarController.RegisterRequest memory request = UpgradeableRegistrarController.RegisterRequest({ | ||
name: name, | ||
owner: alice, | ||
duration: duration, | ||
resolver: address(defaultL2Resolver), | ||
data: new bytes[](0), | ||
reverseRecord: true, | ||
coinTypes: coinTypes, | ||
signatureExpiry: block.timestamp, | ||
signature: "" | ||
}); | ||
|
||
vm.deal(alice, 1 ether); | ||
vm.prank(alice); | ||
controller.register{value: registerPrice}(request); | ||
} | ||
|
||
function test_canRenewExistingName() public { | ||
string memory name = "alice"; | ||
|
||
IPriceOracle.Price memory prices = controller.rentPrice(name, duration); | ||
|
||
vm.deal(alice, 1 ether); | ||
vm.prank(alice); | ||
controller.renew{value: prices.base}(name, duration); | ||
} | ||
|
||
function test_canRenewNameInGracePeriod() public { | ||
string memory name = "alice"; | ||
|
||
IPriceOracle.Price memory prices = controller.rentPrice(name, duration); | ||
|
||
vm.deal(alice, 1 ether); | ||
vm.warp(LAUNCH_TIME + duration + GRACE_PERIOD - 1); | ||
controller.renew{value: prices.base}(name, duration); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.23; | ||
|
||
import {UpgradeableRegistrarControllerBase} from "./UpgradeableRegistrarControllerBase.t.sol"; | ||
|
||
contract Available is UpgradeableRegistrarControllerBase { | ||
function test_returnsFalse_whenNotAvailableOnBase() public { | ||
base.setAvailable(uint256(nameLabel), false); | ||
assertFalse(controller.available(name)); | ||
} | ||
|
||
function test_returnsFalse_whenInvalidLength() public { | ||
base.setAvailable(uint256(shortNameLabel), true); | ||
assertFalse(controller.available(shortName)); | ||
} | ||
|
||
function test_returnsTrue_whenValidAndAvailable() public { | ||
base.setAvailable(uint256(nameLabel), true); | ||
assertTrue(controller.available(name)); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.