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

Feature/crosschain resolver with reverse registrar #20

Open
wants to merge 77 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
0971ed6
Make testResolver work
makoto Oct 20, 2023
383f29a
Update bun.lockb
makoto Oct 20, 2023
88dc259
Add coinType
makoto Oct 23, 2023
8a58674
Make text record work
makoto Oct 23, 2023
8cb5256
Add hardhat-storage-layout
makoto Oct 23, 2023
641e15b
Use the real Resolver contracts
makoto Oct 23, 2023
914c66e
Add contenthash
makoto Oct 23, 2023
9a1a74d
Add comment
makoto Oct 23, 2023
9a386ea
Update README
makoto Oct 23, 2023
db89d14
Change the license to ENS labs
makoto Oct 23, 2023
805b218
Remove console.log
makoto Oct 23, 2023
757d787
Add an explanation
makoto Oct 23, 2023
93ef4b7
typo
makoto Oct 23, 2023
b3141e5
Remove L1Verifier.sol
makoto Oct 23, 2023
80292c4
Remove L1Verifier.sol
makoto Oct 23, 2023
0a227de
Rename test
makoto Oct 23, 2023
7f086ce
Add hardhat-deploy
makoto Oct 23, 2023
749ccd0
Add deployment script
makoto Oct 23, 2023
6c9f241
Remove deployment addresses
makoto Oct 23, 2023
4871812
Merge branch 'crosschain-resolver' into crosschain-resolver-deployment
makoto Oct 23, 2023
50d48b6
Apply suggestions from code review
makoto Oct 25, 2023
84dd082
Add immutable and constants
makoto Oct 25, 2023
40be600
Remove getStatic
makoto Oct 25, 2023
415392b
Fix the wrong constants
makoto Oct 25, 2023
7987695
Merge branch 'main' into crosschain-resolver
makoto Oct 25, 2023
507bfb4
Update bun.lockb
makoto Oct 25, 2023
0ee53c8
Remove contracts-bedrock
makoto Oct 25, 2023
574297d
Update bun.lockb
makoto Oct 25, 2023
3e49356
Add bun
makoto Oct 25, 2023
98adc6e
Remove package-lock.json
makoto Oct 26, 2023
a4044bd
update bun.lockb
TateB Oct 26, 2023
780b416
Merge branch 'revert-test-script' into crosschain-resolver
makoto Oct 27, 2023
9ffd059
Use BrowserProvider
makoto Oct 27, 2023
73f286f
Revert to use fork
makoto Oct 27, 2023
c713107
Put immutable and constant together
makoto Oct 27, 2023
fc128af
Use bytes20 instead
makoto Oct 27, 2023
f013347
Apply suggestions from code review
makoto Oct 27, 2023
f9a056e
Remove gasLimit and gas
makoto Oct 27, 2023
8974854
Merge branch 'crosschain-resolver' of https://github.com/ensdomains/e…
makoto Oct 27, 2023
d84a766
Add test for the empty record
makoto Oct 27, 2023
e0ea493
Remove remote
makoto Oct 27, 2023
e20e6c3
Remove RECORD_VERSIONS_REF constant
makoto Oct 30, 2023
74bb4cc
Copy crosschain resolver to crosschain reverse resolver
makoto Oct 30, 2023
b8c56d0
Rename the function name
makoto Oct 30, 2023
553696e
Add crosschain reverse registrar
makoto Oct 30, 2023
4443f88
Update README.md
makoto Oct 30, 2023
541d5f5
Replace OwnedResolver with DelegatableResolverFactory
makoto Nov 1, 2023
3a50148
replace target with targets
makoto Nov 2, 2023
2fd26ac
Add isAuthorised
makoto Nov 2, 2023
3e83644
Add test for setTarget
makoto Nov 2, 2023
59a5424
Modify deployment code
makoto Nov 2, 2023
4859c62
Remove getTarget and add TargetSet event
makoto Nov 2, 2023
8a00bae
WIP: Adding NameWrapper into test
makoto Nov 2, 2023
c1490e1
Use L2ReverseRegistrar
makoto Nov 6, 2023
912d1e8
Revert L1Resolver.sol and update L1ReverseResolver.sol storage slot l…
makoto Nov 6, 2023
b635152
Update storage slot info
makoto Nov 6, 2023
131c836
Enable ccip read on name
makoto Nov 6, 2023
377e2f4
Add clearRecords and fixed typo
makoto Nov 6, 2023
0cd293c
Fix failing test temporarily
makoto Nov 6, 2023
9d8a668
Resolve conflicts
makoto Nov 6, 2023
77c04ea
Update ens-contracts
makoto Nov 6, 2023
b48c4ef
Merge branch 'bug/zeroref' into feature/crosschain-resolver-with-reve…
makoto Nov 7, 2023
35b91ee
Resolve conflicts
makoto Nov 10, 2023
7fad46a
Update bun
makoto Nov 10, 2023
5ef2612
Resolve conflicts
makoto Nov 10, 2023
4de68ed
Resolve conflicts
makoto Nov 10, 2023
8240df8
Commit bun
makoto Nov 10, 2023
6e725f6
Update ens-contracts on crosschain-reverse-resolver
makoto Nov 10, 2023
e142a7b
Recreate bun.lockb
makoto Nov 10, 2023
c52f671
Crosschain resolver with reverse registrar with deploy script (#18)
makoto Nov 27, 2023
9be5192
Add support interface (#21)
makoto Nov 30, 2023
d173654
Add metadata (#22)
makoto Dec 6, 2023
acabddc
Resolve conflicts and update bun
makoto Dec 10, 2023
3027453
Arb deployment (#23)
makoto Dec 20, 2023
587de25
Add Sepolia verifier contracts and gateway deployment details (#26)
makoto Jan 4, 2024
b868b70
Add .wrangler to gitignore
makoto Jan 25, 2024
2af9e7b
Sepolia resolvers (#27)
makoto Apr 11, 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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ _cjs
op-verifier/deployments/opDevnetL1
op-verifier/deployments/opDevnetL2
artifacts
deployments
cache
.env
typechain-types
.wrangler
25 changes: 24 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,27 @@ This repository also contains the end-to-end tests for the entire stack.
An instantiation of `evm-gateway` that targets Optimism. Combined with `op-verifier`, makes it possible for L1 contracts to fetch contract state data from Optimism.

### [op-verifier](/op-verifier/)
A complete Solidity library that facilitates sending CCIP-Read requests for Optimism state, and verifying the responses.
A complete Solidity library that facilitates sending CCIP-Read requests for Optimism state, and verifying the responses.


## How to setup locally

```
gh repo clone ensdomains/evmgateway
bun install # `@ensdomains/@ensdomains` not found error will be thrown
bun run workspace evm-gateway build
bun install
bun run test
```

## Troubleshooting

### Error HH12: Trying to use a non-local installation of Hardhat, which is not supported.

`yarn test` spawns `hardhat test` in the forked process. When `hardhat` command is installed under the node_modules of under each workspace, it complains that it's using locally installed hardhat. Remove hardhat from local node_modules and make sure it's only installed under the root `node_modules`

```
rm -rf *-*/node_modules/hardhat
rm bun.lockb
bun install
```
9 changes: 5 additions & 4 deletions arb-gateway/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ cd arb-gateway
npm install -g wrangler
wrngler login

wrangler secret put L1_PROVIDER_URL
wrangler secret put L2_PROVIDER_URL
wrangler secret put L2_ROLLUP
yarn deploy
wrangler secret put L1_PROVIDER_URL --env sepolia
wrangler secret put L2_PROVIDER_URL --env sepolia
wrangler secret put L2_ROLLUP --env sepolia
wrangler secret put ENDPOINT_URL --env sepolia
yarn deploy --env sepolia
```

## How to test
Expand Down
3 changes: 2 additions & 1 deletion arb-gateway/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,15 @@
},
"dependencies": {
"@chainlink/ccip-read-server": "^0.2.1",
"@cloudflare/workers-types": "^4.20240117.0",
"@ensdomains/evm-gateway": "^0.1.0",
"@ensdomains/server-analytics": "0.0.1-alpha.2",
"@ethereumjs/block": "^5.0.0",
"@nomicfoundation/ethereumjs-block": "^5.0.2",
"commander": "^11.0.0",
"ethers": "^6.7.1"
},
"devDependencies": {
"@commander-js/extra-typings": "^11.0.0"

}
}
79 changes: 73 additions & 6 deletions arb-gateway/src/worker.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,49 @@
import { Request as CFWRequest } from '@cloudflare/workers-types';
import { Server } from '@ensdomains/ccip-read-cf-worker';
import type { Router } from '@ensdomains/evm-gateway';
import { InMemoryBlockCache } from './blockCache/InMemoryBlockCache.js';
import { Tracker } from '@ensdomains/server-analytics';
interface Env {
L1_PROVIDER_URL: string;
L2_PROVIDER_URL: string;
L2_ROLLUP: string;
GATEWAY_DOMAIN: string;
ENDPOINT_URL: string;
}
interface LogResult {
(request: CFWRequest, result: Response): Promise<Response>;
}

let app: Router, logResult: LogResult;

const decodeUrl = (url: string) => {
const trackingData = url.match(
/\/0x[a-fA-F0-9]{40}\/0x[a-fA-F0-9]{1,}\.json/
);
if (trackingData) {
return {
sender: trackingData[0].slice(1, 42),
calldata: trackingData[0].slice(44).replace('.json', ''),
};
} else {
return {};
}
};

async function fetch(request: CFWRequest, env: Env) {
// Set PROVIDER_URL under .dev.vars locally. Set the key as secret remotely with `wrangler secret put WORKER_PROVIDER_URL`
const {
L1_PROVIDER_URL,
L2_PROVIDER_URL,
L2_ROLLUP,
GATEWAY_DOMAIN,
ENDPOINT_URL,
} = env;
const tracker = new Tracker(GATEWAY_DOMAIN, {
apiEndpoint: ENDPOINT_URL,
enableLogging: true,
});

let app: Router;
async function fetch(request: Request, env: Env) {
// Loading libraries dynamically as a temp work around.
// Otherwise, deployment thorws "Error: Script startup exceeded CPU time limit." error
if (!app) {
Expand All @@ -17,13 +52,37 @@ async function fetch(request: Request, env: Env) {
const EVMGateway = (await import('@ensdomains/evm-gateway')).EVMGateway;
const ArbProofService = (await import('./ArbProofService.js'))
.ArbProofService;
// Set PROVIDER_URL under .dev.vars locally. Set the key as secret remotely with `wrangler secret put WORKER_PROVIDER_URL`
const { L1_PROVIDER_URL, L2_PROVIDER_URL, L2_ROLLUP } = env;

const l1Provider = new ethers.JsonRpcProvider(L1_PROVIDER_URL);
const l2Provider = new ethers.JsonRpcProvider(L2_PROVIDER_URL);

console.log({ L1_PROVIDER_URL, L2_PROVIDER_URL });
logResult = async (
request: CFWRequest,
result: Response
): Promise<Response> => {
if (request.url.match(/favicon/)) {
return result;
}
if (!result.body) {
return result;
}
const [streamForLog, streamForResult] = result.body.tee();
const logResultData = (
await new Response(streamForLog).json()
).data.substring(0, 200);
const props = decodeUrl(request.url);
await tracker.trackEvent(
request,
'result',
{ props: { ...props, result: logResultData } },
true
);
const myHeaders = new Headers();
myHeaders.set('Access-Control-Allow-Origin', '*');
myHeaders.set('Access-Control-Allow-Methods', 'GET,HEAD,POST,OPTIONS');
myHeaders.set('Access-Control-Max-Age', '86400');
return new Response(streamForResult, { ...result, headers: myHeaders });
};
const gateway = new EVMGateway(
new ArbProofService(
l1Provider,
Expand All @@ -37,7 +96,15 @@ async function fetch(request: Request, env: Env) {
gateway.add(server);
app = server.makeApp('/');
}
return app.handle(request);

const props = decodeUrl(request.url);
await tracker.trackEvent(
request,
'request',
{ props: { ...props, ...{} } },
true
);
return app.handle(request).then(logResult.bind(null, request));
}

export default {
Expand Down
8 changes: 6 additions & 2 deletions arb-gateway/wrangler.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@ name = "arb-gateway-worker"
account_id = "15dcc9085cb794bb4f29d3e8177ac880"
main = "./src/worker.ts"
node_compat = true
compatibility_date = "2023-10-13"
compatibility_date = "2024-01-25"


[dev]
port = 8080

[build]
command = "yarn build"

[vars]
[env.sepolia]
name = "arb-sepolia-gateway-worker"
[env.sepolia.vars]
GATEWAY_DOMAIN="arb-sepolia-gateway-worker.ens-cf.workers.dev"
32 changes: 29 additions & 3 deletions arb-verifier/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,43 @@ bun run test

## Deployments

### L2
### Goerli

#### L2

- TestL2.sol = [0xAdef74372444e716C0473dEe1F9Cb3108EFa3818](https://goerli.arbiscan.io/address/0xAdef74372444e716C0473dEe1F9Cb3108EFa3818#code)

### L1
#### L1

- ArbVerifier = [0x9E46DeE08Ad370bEFa7858c0E9a6c87f2D7E57A1](https://goerli.etherscan.io/address/0x9E46DeE08Ad370bEFa7858c0E9a6c87f2D7E57A1#code)

- TestL1.sol = [0x0d6c6B70cd561EB59e6818D832197fFad60840AB](https://goerli.etherscan.io/address/0x0d6c6B70cd561EB59e6818D832197fFad60840AB#code)

### Gateway server
#### Gateway server

- https://arb-gateway-worker.ens-cf.workers.dev


### Sepolia

#### L2

- TestL2.sol = [0x162A433068F51e18b7d13932F27e66a3f99E6890](https://api-sepolia.arbiscan.io/address/0x162A433068F51e18b7d13932F27e66a3f99E6890#code)

#### L1

- ArbVerifier = [0x6820E47CED34D6F275c6d26C3876D48B2c1fdf27](https://sepolia.etherscan.io/address/0x6820E47CED34D6F275c6d26C3876D48B2c1fdf27#code)
- TestL1.sol = [0x50200c7Ccb1abD927184396547ea8dD1A18CAA3A](https://sepolia.etherscan.io/address/0x50200c7Ccb1abD927184396547ea8dD1A18CAA3A#code)

deploying "ArbVerifier" (tx: 0x61ae88749f911f1e09d7c073f34a13bb843c71fafaf93a1266423798bd3aadc6)...: deployed at 0x6820E47CED34D6F275c6d26C3876D48B2c1fdf27 with 3872186 gas
deploying "TestL1" (tx: 0x0a7b6b74357d20f33cb89df12da3db34b5cd3c764403888420108ca13f0126fa)...: deployed at 0x50200c7Ccb1abD927184396547ea8dD1A18CAA3A with 2411152 gas

#### Gateway url

- https://arb-sepolia-gateway-worker.ens-cf.workers.dev

## Testing gateway

```
TARGET_ADDRESS=$TEST_L1_ADDRESS PROVIDER_URL=$L1_PROVIDER_URL npx hardhat run ../l1-verifier/scripts/remote.ts --network sepolia
```
6 changes: 6 additions & 0 deletions arb-verifier/arguments.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = [
[
'https://arb-sepolia-gateway-worker.ens-cf.workers.dev/{sender}/{data}.json'
],
'0xd80810638dbDF9081b72C1B33c65375e807281C8'
];
2 changes: 2 additions & 0 deletions arb-verifier/deploy_l1/00_arb_verifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import 'dotenv/config';
const GATEWAY_URLS = {
arbDevnetL1: 'http://localhost:8089/{sender}/{data}.json',
goerli: 'https://arb-gateway-worker.ens-cf.workers.dev/{sender}/{data}.json',
sepolia: 'https://arb-sepolia-gateway-worker.ens-cf.workers.dev/{sender}/{data}.json',
};

const ROLLUP_ADDRESSES = {
goerli: '0x45e5cAea8768F42B385A366D3551Ad1e0cbFAb17',
sepolia: '0xd80810638dbDF9081b72C1B33c65375e807281C8',
};

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
Expand Down
27 changes: 26 additions & 1 deletion arb-verifier/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,26 +38,51 @@ const config: HardhatUserConfig = {
l2: 'arbitrumGoerli',
},
},
sepolia: {
url: L1_PROVIDER_URL,
accounts: [DEPLOYER_PRIVATE_KEY],
deploy: ['deploy_l1/'],
chainId:11155111,
companionNetworks: {
l2: 'arbitrumSepolia',
},
},
arbitrumGoerli: {
url: 'https://rpc.goerli.arbitrum.gateway.fm',
accounts: [DEPLOYER_PRIVATE_KEY],
deploy: ['deploy_l2/'],
},
arbitrumSepolia: {
chainId: 421614,
url: 'https://sepolia-rollup.arbitrum.io/rpc',
accounts: [DEPLOYER_PRIVATE_KEY],
deploy: [ "deploy_l2/" ],
},
},
etherscan: {
apiKey: {
goerli: L1_ETHERSCAN_API_KEY,
sepolia: L1_ETHERSCAN_API_KEY,
arbitrumGoerli: L2_ETHERSCAN_API_KEY,
arbitrumSepolia: L2_ETHERSCAN_API_KEY,
},
customChains: [
{
network: 'arbitrumGoerli',
chainId: 421613,
urls: {
apiURL: 'https://api-goerli.arbiscan.io/api',
browserURL: 'https://api-goerli.arbiscan.io.io',
browserURL: 'https://api-goerli.arbiscan.io',
},
},
{
network: "arbitrumSepolia",
chainId: 421614,
urls: {
apiURL: "https://api-sepolia.arbiscan.io/api",
browserURL: "https://api-sepolia.arbiscan.io"
}
}
],
},
namedAccounts: {
Expand Down
8 changes: 5 additions & 3 deletions arb-verifier/test/testArbVerifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,14 @@ describe('ArbVerifier', () => {
const rollupAddress = process.env.ROLLUP_ADDRESS;
// When testing against Goerli, replace with this address
// const rollupAddress = '0x45e5cAea8768F42B385A366D3551Ad1e0cbFAb17';

const chainId = hre.network.config.chainId
console.log(hre.network.config)
console.log({chainId})
const gateway = await makeArbGateway(
(hre.network.config as any).url,
(hre.network.config as any).url,
(hre.config.networks[hre.network.companionNetworks.l2] as any).url,
rollupAddress,
5,
chainId,
);
const server = new Server()
gateway.add(server)
Expand Down
Binary file modified bun.lockb
Binary file not shown.
3 changes: 1 addition & 2 deletions crosschain-resolver/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
node_modules
.env
.env*
coverage
coverage.json
typechain
Expand All @@ -8,5 +8,4 @@ typechain-types
# Hardhat files
cache
artifacts
deployments

Loading
Loading