Skip to content

Commit

Permalink
Merge branch 'master' into feature/subdomain-registrar
Browse files Browse the repository at this point in the history
  • Loading branch information
makoto committed Dec 18, 2023
2 parents 47c98cd + 0b6f79e commit 134d776
Show file tree
Hide file tree
Showing 18 changed files with 978 additions and 41 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: CI

on:
push:
branches: [master]
pull_request:

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Use Node.js 16
uses: actions/setup-node@v3
with:
node-version: 16
cache: 'yarn'

- run: yarn install --frozen-lockfile

- name: Run test
run: yarn test

deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Use Node.js 16
uses: actions/setup-node@v3
with:
node-version: 16
cache: 'yarn'

- run: yarn install --frozen-lockfile

- name: Run deploy
run: yarn test:deploy
env:
BATCH_GATEWAY_URLS: '["https://universal-offchain-unwrapper.ens-cf.workers.dev/"]'
20 changes: 0 additions & 20 deletions .travis.yml

This file was deleted.

1 change: 1 addition & 0 deletions contracts/dnsregistrar/DNSClaimChecker.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ library DNSClaimChecker {
!iter.done();
iter.next()
) {
if (iter.name().compareNames(buf.buf) != 0) continue;
bool found;
address addr;
(addr, found) = parseRR(data, iter.rdataOffset, iter.nextOffset);
Expand Down
2 changes: 1 addition & 1 deletion contracts/ethregistrar/IBaseRegistrar.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ interface IBaseRegistrar is IERC721 {
// Returns the expiration timestamp of the specified label hash.
function nameExpires(uint256 id) external view returns (uint256);

// Returns true iff the specified name is available for registration.
// Returns true if the specified name is available for registration.
function available(uint256 id) external view returns (bool);

/**
Expand Down
63 changes: 63 additions & 0 deletions contracts/ethregistrar/StaticBulkRenewal.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
//SPDX-License-Identifier: MIT
pragma solidity ~0.8.17;

import "./ETHRegistrarController.sol";
import "./IBulkRenewal.sol";
import "./IPriceOracle.sol";

import "@openzeppelin/contracts/utils/introspection/IERC165.sol";

contract StaticBulkRenewal is IBulkRenewal {
ETHRegistrarController controller;

constructor(ETHRegistrarController _controller) {
controller = _controller;
}

function rentPrice(
string[] calldata names,
uint256 duration
) external view override returns (uint256 total) {
uint256 length = names.length;
for (uint256 i = 0; i < length; ) {
IPriceOracle.Price memory price = controller.rentPrice(
names[i],
duration
);
unchecked {
++i;
total += (price.base + price.premium);
}
}
}

function renewAll(
string[] calldata names,
uint256 duration
) external payable override {
uint256 length = names.length;
uint256 total;
for (uint256 i = 0; i < length; ) {
IPriceOracle.Price memory price = controller.rentPrice(
names[i],
duration
);
uint256 totalPrice = price.base + price.premium;
controller.renew{value: totalPrice}(names[i], duration);
unchecked {
++i;
total += totalPrice;
}
}
// Send any excess funds back
payable(msg.sender).transfer(address(this).balance);
}

function supportsInterface(
bytes4 interfaceID
) external pure returns (bool) {
return
interfaceID == type(IERC165).interfaceId ||
interfaceID == type(IBulkRenewal).interfaceId;
}
}
8 changes: 6 additions & 2 deletions contracts/wrapper/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ Expiry can be extended using the following functions:

`renew()` indirectly extends the expiry of a .eth name by renewing the name inside the .eth registrar.

`extendExpiry()` extends the expiry of any name. It can only be called by the owner of the name or the owner of the parent name. When called by the owner of the name, the `CAN_EXTEND_EXPIRY` fuse must have already been burned by the parent.
`extendExpiry()` extends the expiry of any name. It can only be called by the owner of the name, an approved address or the owner of the parent name. When called by the owner of the name, the `CAN_EXTEND_EXPIRY` fuse must have already been burned by the parent. An approved address can be set by calling `approve()`.

## Fuses

Expand Down Expand Up @@ -178,6 +178,10 @@ If this fuse is burned, the TTL cannot be changed. Calls to setTTL, setRecord, a

If this fuse is burned, new subdomains cannot be created. Calls to setSubnodeOwner and setSubnodeRecord will fail if they reference a name that does not already exist.

#### CANNOT_APPROVE = 64

If this fuse is burned, `approve()` cannot be called on this name anymore and so the current approved address cannot be changed until expiry.

#### PARENT_CANNOT_CONTROL = 65536

If this fuse is burned, existing subdomains cannot be replaced by the parent name and the parent can no longer burn other fuses on this child. Calls to setSubnodeOwner and setSubnodeRecord will fail if they reference a name that already exists. Attempting to burn fuses in setChildFuses will also fail. This fuse can only be burnt by the parent of a node.
Expand Down Expand Up @@ -316,7 +320,7 @@ Cannot be called if `CANNOT_BURN_FUSES` has been burned.
**Start State**: Wrapped | Emancipated | Locked
**End State**: Wrapped | Emancipated | Locked

`extendExpiry()` can only be called by the owner of a name or the owner of the parent name. When called by the owner of the name, the `CAN_EXTEND_EXPIRY` fuse must have already been burned by the parent.
`extendExpiry()` can only be called by the owner of a name, the owner of the parent name or an approved address (known as a renewal manager). When called by the owner of the name, the `CAN_EXTEND_EXPIRY` fuse must have already been burned by the parent. The approved address can be set by calling `approve

The expiry can only be extended, not reduced. And the max expiry is automatically set to the expiry of the parent node.

Expand Down
14 changes: 9 additions & 5 deletions deploy/dnsregistrar/20_set_tlds.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import packet from 'dns-packet'
import { ethers } from 'hardhat'
import { DeployFunction } from 'hardhat-deploy/types'
import { HardhatRuntimeEnvironment } from 'hardhat/types'
Expand All @@ -6,6 +7,7 @@ const tld_map = {
mainnet: ['xyz'],
ropsten: ['xyz'],
localhost: ['xyz'],
hardhat: ['xyz'],
goerli: [
'exposed',
'target',
Expand Down Expand Up @@ -1224,6 +1226,10 @@ const tld_map = {
const ZERO_HASH =
'0x0000000000000000000000000000000000000000000000000000000000000000'

function encodeName(name: string) {
return '0x' + packet.name.encode(name).toString('hex')
}

async function setTLDs(
owner: string,
registry: any,
Expand All @@ -1241,8 +1247,7 @@ async function setTLDs(
) {
console.log(`Transferring .${tld} to new DNS registrar`)
transactions.push(
await registrar.enableNode(tld, {
from: owner,
await registrar.enableNode(encodeName(tld), {
gasLimit: 10000000,
}),
)
Expand All @@ -1254,11 +1259,10 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { getNamedAccounts, network } = hre
const { owner } = await getNamedAccounts()

const registrar = await ethers.getContract('DNSRegistrar')
const signer = await ethers.getSigner(owner)

let transactions: any[] = []
const root = await ethers.getContract('Root', signer)
const registrar = await ethers.getContract('DNSRegistrar', signer)
const registry = await ethers.getContract('ENSRegistry', signer)
transactions = await setTLDs(
owner,
Expand All @@ -1276,6 +1280,6 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
}

func.tags = ['dnsregistrar']
func.dependencies = ['registry', 'root', 'dnssec-oracle']
func.dependencies = ['registry', 'dnssec-oracle']

export default func
12 changes: 7 additions & 5 deletions deploy/ethregistrar/02_deploy_legacy_eth_registrar_controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,13 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
)
await tx3.wait()

console.log('Running unwrapped name registrations...')
await run('register-unwrapped-names', {
deletePreviousDeployments: false,
resetMemory: false,
})
if (process.env.npm_package_name !== '@ensdomains/ens-contracts') {
console.log('Running unwrapped name registrations...')
await run('register-unwrapped-names', {
deletePreviousDeployments: false,
resetMemory: false,
})
}

return true
}
Expand Down
5 changes: 3 additions & 2 deletions deploy/ethregistrar/04_deploy_bulk_renewal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { deployer } = await getNamedAccounts()

const registry = await ethers.getContract('ENSRegistry')
const controller = await ethers.getContract('ETHRegistrarController')

const bulkRenewal = await deploy('BulkRenewal', {
const bulkRenewal = await deploy('StaticBulkRenewal', {
from: deployer,
args: [registry.address],
args: [controller.address],
log: true,
})

Expand Down
12 changes: 7 additions & 5 deletions deploy/registry/00_deploy_registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
console.log(`Setting owner of root node to owner (tx: ${rootTx.hash})`)
await rootTx.wait()

console.log('Running legacy registry scripts...')
await run('legacy-registry-names', {
deletePreviousDeployments: false,
resetMemory: false,
})
if (process.env.npm_package_name !== '@ensdomains/ens-contracts') {
console.log('Running legacy registry scripts...')
await run('legacy-registry-names', {
deletePreviousDeployments: false,
resetMemory: false,
})
}

const revertRootTx = await legacyRegistry
.connect(await ethers.getSigner(owner))
Expand Down
1 change: 1 addition & 0 deletions deploy/wrapper/01_deploy_name_wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ func.dependencies = [
'BaseRegistrarImplementation',
'StaticMetadataService',
'registry',
'ReverseRegistrar',
]

export default func
130 changes: 130 additions & 0 deletions deployments/goerli/StaticBulkRenewal.json

Large diffs are not rendered by default.

158 changes: 158 additions & 0 deletions deployments/goerli/solcInputs/ad37cc3cd3f1925923b5003f9803ae69.json

Large diffs are not rendered by default.

130 changes: 130 additions & 0 deletions deployments/mainnet/StaticBulkRenewal.json

Large diffs are not rendered by default.

158 changes: 158 additions & 0 deletions deployments/mainnet/solcInputs/ad37cc3cd3f1925923b5003f9803ae69.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"name": "@ensdomains/ens-contracts",
"version": "0.0.20",
"version": "0.0.21",
"description": "ENS contracts",
"scripts": {
"test": "hardhat test",
"test:local": "hardhat --network localhost test",
"test:deploy": "hardhat --network hardhat deploy",
"lint": "hardhat check",
"build": "rm -rf ./build/deploy ./build/hardhat.config.js && hardhat compile && tsc",
"format": "prettier --write .",
Expand Down
Loading

0 comments on commit 134d776

Please sign in to comment.