Skip to content
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

Bug/flake test #311

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
76768cc
fix offchain-resolver resolution over offchain dns
mdtanrikulu Nov 15, 2023
9ef4bcb
update tests, add universal + dns resolver test
mdtanrikulu Dec 6, 2023
84ecab8
fix test flow
mdtanrikulu Dec 6, 2023
74de256
Merge pull request #296 from ensdomains/mdt/fix-testflow
jefflau Dec 18, 2023
822e4e6
Remove log
jefflau Dec 18, 2023
06d956c
Merge pull request #298 from ensdomains/mdt/fix-testflow
jefflau Dec 18, 2023
67bf365
Merge pull request #291 from ensdomains/mdt/offchain-resolver-fix
mdtanrikulu Dec 18, 2023
4e73ef9
Redeploy DNSRegistrar to Sepolia
jefflau Jan 3, 2024
8b76224
convert bn to string
mdtanrikulu Jan 11, 2024
fcc06ca
revert bn to string
mdtanrikulu Jan 11, 2024
1a88d61
try different action runner image
mdtanrikulu Jan 13, 2024
656160a
try mac runner
mdtanrikulu Jan 13, 2024
2015531
revert runner os, try different node version
mdtanrikulu Jan 13, 2024
bde22f8
revert node version, add tmate
mdtanrikulu Jan 14, 2024
831e1cf
revert tmate
mdtanrikulu Jan 14, 2024
53f64de
Deploy to mainnet
Arachnid Jan 16, 2024
7d091bd
New DNSRegistrar deployment with correct previous version address
Arachnid Jan 17, 2024
03b4775
Use owner instead of isOwner
Arachnid Jan 17, 2024
3d2f538
Use explicit public suffix list
Arachnid Jan 17, 2024
0d99f42
Remove accidentally added contract
Arachnid Jan 17, 2024
160919f
New deployment
Arachnid Jan 17, 2024
e5391f7
Merge pull request #310 from ensdomains/feature/public-suffixes
Arachnid Jan 17, 2024
3ba9573
Commit to test CI flakiness
Arachnid Jan 17, 2024
d623978
Merge remote-tracking branch 'origin/staging' into bug/flake-test
Arachnid Jan 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
148 changes: 85 additions & 63 deletions contracts/dnsregistrar/OffchainDNSResolver.sol
Original file line number Diff line number Diff line change
Expand Up @@ -61,23 +61,36 @@ contract OffchainDNSResolver is IExtendedResolver, IERC165 {
bytes calldata name,
bytes calldata data
) external view returns (bytes memory) {
return
callWithOffchainLookupPropagation(
msg.sender,
name,
data,
abi.encodeCall(IExtendedResolver.resolve, (name, data))
);
revertWithDefaultOffchainLookup(name, data);
}

function resolveCallback(
bytes calldata response,
bytes calldata extraData
) external view returns (bytes memory) {
(bytes memory name, bytes memory query) = abi.decode(
(bytes memory name, bytes memory query, bytes4 selector) = abi.decode(
extraData,
(bytes, bytes)
(bytes, bytes, bytes4)
);

if (selector != bytes4(0)) {
(bytes memory targetData, address targetResolver) = abi.decode(
query,
(bytes, address)
);
return
callWithOffchainLookupPropagation(
targetResolver,
name,
query,
abi.encodeWithSelector(
selector,
response,
abi.encode(targetData, address(this))
)
);
}

DNSSEC.RRSetWithSignature[] memory rrsets = abi.decode(
response,
(DNSSEC.RRSetWithSignature[])
Expand Down Expand Up @@ -251,64 +264,73 @@ contract OffchainDNSResolver is IExtendedResolver, IERC165 {
bytes memory innerdata,
bytes memory data
) internal view returns (bytes memory) {
if (target.isContract()) {
bool result = LowLevelCallUtils.functionStaticCall(
address(target),
data
);
uint256 size = LowLevelCallUtils.returnDataSize();
if (result) {
bytes memory returnData = LowLevelCallUtils.readReturnData(
0,
size
if (!target.isContract()) {
revertWithDefaultOffchainLookup(name, innerdata);
}

bool result = LowLevelCallUtils.functionStaticCall(
address(target),
data
);
uint256 size = LowLevelCallUtils.returnDataSize();
if (result) {
bytes memory returnData = LowLevelCallUtils.readReturnData(0, size);
return abi.decode(returnData, (bytes));
}
// Failure
if (size >= 4) {
bytes memory errorId = LowLevelCallUtils.readReturnData(0, 4);
if (bytes4(errorId) == OffchainLookup.selector) {
// Offchain lookup. Decode the revert message and create our own that nests it.
bytes memory revertData = LowLevelCallUtils.readReturnData(
4,
size - 4
);
return abi.decode(returnData, (bytes));
handleOffchainLookupError(revertData, target, name);
}
// Failure
if (size >= 4) {
bytes memory errorId = LowLevelCallUtils.readReturnData(0, 4);
if (bytes4(errorId) == OffchainLookup.selector) {
// Offchain lookup. Decode the revert message and create our own that nests it.
bytes memory revertData = LowLevelCallUtils.readReturnData(
4,
size - 4
);
(
address sender,
string[] memory urls,
bytes memory callData,
bytes4 innerCallbackFunction,
bytes memory extraData
) = abi.decode(
revertData,
(address, string[], bytes, bytes4, bytes)
);
}
LowLevelCallUtils.propagateRevert();
}

if (sender != target) {
revert InvalidOperation();
}
function revertWithDefaultOffchainLookup(
bytes memory name,
bytes memory data
) internal view {
string[] memory urls = new string[](1);
urls[0] = gatewayURL;

revert OffchainLookup(
address(this),
urls,
callData,
OffchainDNSResolver.resolveCallback.selector,
abi.encode(sender, innerCallbackFunction, extraData)
);
}
}
LowLevelCallUtils.propagateRevert();
} else {
string[] memory urls = new string[](1);
urls[0] = gatewayURL;

revert OffchainLookup(
address(this),
urls,
abi.encodeCall(IDNSGateway.resolve, (name, TYPE_TXT)),
OffchainDNSResolver.resolveCallback.selector,
abi.encode(name, innerdata)
);
revert OffchainLookup(
address(this),
urls,
abi.encodeCall(IDNSGateway.resolve, (name, TYPE_TXT)),
OffchainDNSResolver.resolveCallback.selector,
abi.encode(name, data, bytes4(0))
);
}

function handleOffchainLookupError(
bytes memory returnData,
address target,
bytes memory name
) internal view {
(
address sender,
string[] memory urls,
bytes memory callData,
bytes4 innerCallbackFunction,
bytes memory extraData
) = abi.decode(returnData, (address, string[], bytes, bytes4, bytes));

if (sender != target) {
revert InvalidOperation();
}

revert OffchainLookup(
address(this),
urls,
callData,
OffchainDNSResolver.resolveCallback.selector,
abi.encode(name, extraData, innerCallbackFunction)
);
}
}
3 changes: 3 additions & 0 deletions contracts/dnsregistrar/SimplePublicSuffixList.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ import "./PublicSuffixList.sol";
contract SimplePublicSuffixList is PublicSuffixList, Ownable {
mapping(bytes => bool) suffixes;

event SuffixAdded(bytes suffix);

function addPublicSuffixes(bytes[] memory names) public onlyOwner {
for (uint256 i = 0; i < names.length; i++) {
suffixes[names[i]] = true;
emit SuffixAdded(names[i]);
}
}

Expand Down
49 changes: 49 additions & 0 deletions deploy/dnsregistrar/05_deploy_public_suffix_list.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { ethers } from 'hardhat'
import packet from 'dns-packet'
import { DeployFunction } from 'hardhat-deploy/types'
import { HardhatRuntimeEnvironment } from 'hardhat/types'

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

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { getNamedAccounts, deployments } = hre
const { deploy } = deployments
const { deployer, owner } = await getNamedAccounts()

await deploy('SimplePublicSuffixList', {
from: deployer,
args: [],
log: true,
})
const publicSuffixList = await ethers.getContract('SimplePublicSuffixList')

const suffixList = await (
await fetch('https://publicsuffix.org/list/public_suffix_list.dat')
).text()
let suffixes = suffixList
.split('\n')
.filter((suffix) => !suffix.startsWith('//') && suffix.trim() != '')
// Right now we're only going to support top-level, non-idna suffixes
suffixes = suffixes.filter((suffix) => suffix.match(/^[a-z0-9]+$/))
const txes = []
for (let i = 0; i < suffixes.length; i += 100) {
const batch = suffixes.slice(i, i + 100).map((suffix) => encodeName(suffix))
txes.push(await publicSuffixList.addPublicSuffixes(batch))
}
console.log(
`Waiting on ${txes.length} suffix-setting transactions to complete...`,
)
await Promise.all(txes.map((tx) => tx.wait()))

if (owner !== undefined && owner !== deployer) {
console.log('Transferring ownership to owner account')
await publicSuffixList.transferOwnership(owner)
}
}

func.tags = ['SimplePublicSuffixList']
func.dependencies = []

export default func
25 changes: 15 additions & 10 deletions deploy/dnsregistrar/10_deploy_dnsregistrar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const oldregistrar = await hre.deployments.getOrNull('DNSRegistrar')
const root = await ethers.getContract('Root')

const publicSuffixList = await deploy('TLDPublicSuffixList', {
from: deployer,
args: [],
log: true,
})
const publicSuffixList = await ethers.getContract('SimplePublicSuffixList')

const tx = await deploy('DNSRegistrar', {
from: deployer,
Expand All @@ -32,11 +28,20 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
})
console.log(`Deployed DNSRegistrar to ${tx.address}`)

const tx2 = await root
.connect(await ethers.getSigner(owner))
.setController(tx.address, true)
console.log(`Set DNSRegistrar as controller of Root (${tx2.hash})`)
await tx2.wait()
if (
owner !== undefined &&
(await root.owner()).toLowerCase() === owner.toLowerCase()
) {
const tx2 = await root
.connect(await ethers.getSigner(owner))
.setController(tx.address, true)
console.log(`Set DNSRegistrar as controller of Root (${tx2.hash})`)
await tx2.wait()
} else {
console.log(
`${owner} is not the owner of the root; you will need to call setController('${tx.address}', true) manually`,
)
}
}

func.tags = ['DNSRegistrar']
Expand Down
2 changes: 1 addition & 1 deletion deploy/dnsregistrar/20_set_tlds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1284,7 +1284,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
}
}

func.tags = ['DNSRegistrar']
func.tags = ['registrar-tlds']
func.dependencies = ['registry', 'dnssec-oracle']
func.runAtTheEnd = true

Expand Down
3 changes: 0 additions & 3 deletions deploy/registry/00_deploy_registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,11 @@ const ZERO_HASH =
'0x0000000000000000000000000000000000000000000000000000000000000000'

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
console.log('starting')
const { getNamedAccounts, deployments, network } = hre
const { deploy, run } = deployments
const { deployer, owner } = await getNamedAccounts()

if (network.tags.legacy) {
console.log(deployer)
console.log(owner)
const contract = await deploy('LegacyENSRegistry', {
from: owner,
args: [],
Expand Down
1 change: 0 additions & 1 deletion deploy/resolvers/00_deploy_extended_dns_resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
})
}

func.id = 'extended-dns-resolver'
func.tags = ['resolvers', 'ExtendedDNSResolver']

export default func
3 changes: 2 additions & 1 deletion deployments/mainnet/.migrations.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"ens": 1626404011,
"root": 1580387832
"root": 1580387832,
"setupRoot": 1580387832
}
Loading
Loading