Skip to content

Commit

Permalink
Npm (#39)
Browse files Browse the repository at this point in the history
* Make testResolver work

* Update bun.lockb

* Add coinType

* Make text record work

* Add hardhat-storage-layout

* Use the real Resolver contracts

* Add contenthash

* Add comment

* Update README

* Change the license to ENS labs

* Remove console.log

* Add an explanation

* typo

* Remove L1Verifier.sol

* Remove L1Verifier.sol

* Rename test

* Add hardhat-deploy

* Add deployment script

* Remove deployment addresses

* Apply suggestions from code review

Add indentation

Co-authored-by: Nick Johnson <[email protected]>

* Add immutable and constants

* Remove getStatic

* Fix the wrong constants

* Update bun.lockb

* Remove contracts-bedrock

* Update bun.lockb

* Add bun

* Remove package-lock.json

* update bun.lockb

* Use BrowserProvider

* Revert to use fork

* Put immutable and constant together

* Use bytes20 instead

* Apply suggestions from code review

Co-authored-by: Nick Johnson <[email protected]>

* Remove gasLimit and gas

* Add test for the empty record

* Remove remote

* Remove RECORD_VERSIONS_REF constant

* Copy crosschain resolver to crosschain reverse resolver

* Rename the function name

* Add crosschain reverse registrar

* Update README.md

* Replace OwnedResolver with DelegatableResolverFactory

* replace target with targets

* Add isAuthorised

* Add test for setTarget

* Modify deployment code

* Remove getTarget and add TargetSet event

* WIP: Adding NameWrapper into test

* Use L2ReverseRegistrar

* Revert L1Resolver.sol and update L1ReverseResolver.sol storage slot location

* Update storage slot info

* Enable ccip read on name

* Add clearRecords and fixed typo

* Fix failing test temporarily

* Update ens-contracts

* Update bun

* Commit bun

* Update ens-contracts on crosschain-reverse-resolver

* Recreate bun.lockb

* Crosschain resolver with reverse registrar with deploy script (#18)

* Update deploy scripts

* Remove console.log

* Remove blank space from the file

* Add deployment script

* Update deployment readme

* Add getname

* Add setname

* Add setup script

* Add getaddr

* Add approve

* Fix wildcard for subname

* Update bun

* Deploy l2 reverse registrar to base goerli

* Add base deployment

* Added instruction on subname registrar

* Added instruction on how to register names

* Add support interface (#21)

* Add support interface

* Use ens-contracts IExtendedResolver

* Add support interface to reverse registrar

* Change test name

* Update L1 deployment contract address for base and OP

* Remove offset from getTarget

* Inherit Interfaces

* Inherit interfaces for ReverseResolver

* Add ERC165 signature

* Add metadata (#22)

* Add Metadata service

* Add MetadataChanged event, change setTarget argument and TargetSet event

* Update bun.lockb

* Update bun.lockb

* Remove comment

* remove id function and get rid of node from TargetSet

* Update comment, link to ENSIP16 and add variable name on the return argument of metadata function

* Fix failing tests

* Remove resolver name from metadata

* Update comment and move MetadataChanged

* Remove id

* Arb deployment (#23)

* Add support interface

* Use ens-contracts IExtendedResolver

* Add support interface to reverse registrar

* Change test name

* Update L1 deployment contract address for base and OP

* Add arbitrum deployment script and deployed contract info

* Update README

* Add IERC165

* Remove DelegatableResolverRegistrar

* Add Sepolia verifier contracts and gateway deployment details (#26)

* Add OP sepolia gateway info

* Add deployed addresses for base

* Add arbitrum sepolia deployment address

* Remove console.log

* Update comment

* Add environment on wrangler.toml

* Add .wrangler to gitignore

* Sepolia resolvers (#27)

* Add crosschain resolver details

* Updated @ensdomains/ens-contracts ensdomains/ens-contracts#feature/crosschain-resolver-with-reverse-registrar to the latest commit

* Change slot

* Add ReverseRegistrar deployment details

* Update reverse registrar deployed addresses

* Add Op sepolia reverse registrar deployment info

* Added L1Resolver contract deployment details

* Remove comment out

* Add bun.lockb

* Update bun.lockb

* Change ens- ontracts to point to l2-deployment branch

* Fix failing test

* Update bun.lockb

* Add L2ReverseRegistrar to deps.sol on crosschain-resolver (was throwing error)

* Fix failing test

* Remove unused subheader

* Redeploy base l1 resolver

* Update README.md

* Added Base Reverse Resolver contract address

* Add Arbitrum Reverse Resolver deployement

* Redeploy ArbL1ReverseResolver with correct L2 Resolver Address

* Redeploy l2 contracts with official reverse record namespace (cointype.reverse)

* Sepolia resolvers with analytics (#30)

* WIP

* Fix errors

* Ignore favicon

* Update bun.lockb

* Fix lint error

* Update gateway url

* Add console.log

* Changed endpoint

* Update apiEndpoint

* Add sender and calldata to props

* Move Tracker to evm-gateway

* Revert "Move Tracker to evm-gateway"

This reverts commit 5d3ba37.

* WIP

* Downgrade to 4.20231121.0

* Bump it to the latest

* Add type

* Replace tracker with @ensdomains/server-analytics

* Pass custom apiEndpoint and props

* Add GATEWAY_DOMAIN and ENDPOINT_URL

* Point to correct branch

* Fix CORS problem

* Add gateway log tracker to OP

* Fix lint error

* Update readme

* Default reverse resolver (#33)

* Change ens-contracts to use default-reverse-resolver

* Add suport for DefaultReverseResolver

* Add hexToAddress to extract address

* Add faulback to name function

* Add fallback for text

* Use imported IDefaultReverseResolver

* Update bun.lockb and README

* Update comment

* Move DefaultReverseResolver

* Add DefaultReverseResolver

* Update bun.lockb

* Add support for resolve on DefaultReverseResolver

* Deployed new contracts

* Add setdefaultname

* Update README.md

* Update README.md

* Remove console.log

* Point to default-reverse-resolver-2

* Reswitch to default-reverse-resolver

* Update bun.ockb

* Add whitespace

* Check if invalid address

* Override .text

* Fix  TypeError: ambiguous function error

* Re-point to default-reverse-resolver

* Added wait

* Update storage location after removing Owner

* Added wait on crosschain resolver

* Use L2ReverseRevolver and fix broken test

* Update ens-contracts branch

* Eip 5559 support (#34)

* Add IResolverSetter

* Simplify metadata function

* Fix failing tests

* Add test for EIP 5559

* Added wait

* Rename from IResolverSetter to IAddrSetter

* Add resolveDeferral

* Store chainId directly

* Rename from resolveDeferral to setAddr

* Remove crosschain-resolver and crosschain-reverse-resolver

* Add .yalc to .gitignore

* v0.1.0-beta.1

* Pushed all versions to 0.1.0-beta.2

* Add repo info and bump to beta.3

* Add links to arb related repos

* Remove old deployment info

* Revert removed scripts

* Recreate bun.lockb

* Remove console.log and tidy up props

* Fix linting error

* Fix linting error

* remove log result util (#40)

* remove log result util

* bump server-analytics version, update types and functions

* bypass frozen-lockfile flag for deps update

* bypass frozen-lockfile flag for deps update

* lint

* revert frozen-lockfile flag

* keep  rozen-lockfile disabled

* lint

* Rename sepoliaforbase to sepoliaForBase

* Update op-gateway/README.md

Co-authored-by: Nick Johnson <[email protected]>

* move propsDecoder (#41)

* move propsDecoder

* Add Request as type

* Update workers-types

* Fix lint error

* v0.1.0-beta.4

* v0.1.0-beta.4

* v0.1.0-beta.4

* Bump the version to beta.4

---------

Co-authored-by: Nick Johnson <[email protected]>
Co-authored-by: tate <[email protected]>
Co-authored-by: Muhammed Tanrıkulu <[email protected]>
  • Loading branch information
4 people authored Apr 26, 2024
1 parent 81639ce commit 588d6b5
Show file tree
Hide file tree
Showing 51 changed files with 401 additions and 983 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
node-version: ${{ matrix.node }}

- name: Install Dependencies
run: bun install --frozen-lockfile --ignore-scripts
run: bun install --ignore-scripts

- name: Build
run: bun run build
Expand All @@ -44,7 +44,7 @@ jobs:
bun-version: 1.0.7

- name: Install Dependencies
run: bun install --frozen-lockfile --ignore-scripts
run: bun install --ignore-scripts

- name: Build
run: bun run build
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ _cjs
op-verifier/deployments/opDevnetL1
op-verifier/deployments/opDevnetL2
artifacts
deployments
cache
.env
typechain-types
.wrangler
.yalc
30 changes: 29 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,32 @@ 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.

### [arb-gateway](/arb-gateway/)
An instantiation of `evm-gateway` that targets Optimism. Combined with `arb-verifier`, makes it possible for L1 contracts to fetch contract state data from Arbitrum.

### [arb-verifier](/arb-verifier/)
A complete Solidity library that facilitates sending CCIP-Read requests for Arbitrum 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
```
14 changes: 8 additions & 6 deletions arb-gateway/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ bun run dev

```
cd arb-gateway
npm install -g bun wrangler
wrangler login
wrangler secret put L1_PROVIDER_URL
wrangler secret put L2_PROVIDER_URL
wrangler secret put L2_ROLLUP
bun run deploy
npm install -g wrangler
wrngler login
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
5 changes: 3 additions & 2 deletions 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",
"@ensdomains/evm-gateway": "^0.1.0",
"@cloudflare/workers-types": "^4.20240423.0",
"@ensdomains/evm-gateway": "0.1.0-beta.4",
"@ensdomains/server-analytics": "0.0.1-alpha.5",
"@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"

}
}
32 changes: 26 additions & 6 deletions arb-gateway/src/worker.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,32 @@
import { Request as CFWRequest } from '@cloudflare/workers-types';
import { Server } from '@ensdomains/ccip-read-cf-worker';
import type { Router } from '@ensdomains/evm-gateway';
import { propsDecoder, 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;
}

let app: Router;
async function fetch(request: Request, env: Env) {

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,
});

// 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 +35,10 @@ 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 });
const gateway = new EVMGateway(
new ArbProofService(
l1Provider,
Expand All @@ -37,7 +52,12 @@ async function fetch(request: Request, env: Env) {
gateway.add(server);
app = server.makeApp('/');
}
return app.handle(request);

const props = propsDecoder(request);
await tracker.trackEvent(request, 'request', { props }, true);
return app
.handle(request)
.then(tracker.logResult.bind(null, propsDecoder, 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 = "bun run 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
2 changes: 1 addition & 1 deletion arb-verifier/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
},
"dependencies": {
"@arbitrum/nitro-contracts": "^1.1.0",
"@ensdomains/evm-verifier": "^0.1.0",
"@ensdomains/evm-verifier": "0.1.0-beta.4",
"dotenv": "^16.3.1"
}
}
6 changes: 3 additions & 3 deletions arb-verifier/test/testArbVerifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ 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
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.
12 changes: 0 additions & 12 deletions crosschain-resolver/.gitignore

This file was deleted.

21 changes: 0 additions & 21 deletions crosschain-resolver/LICENSE

This file was deleted.

Loading

0 comments on commit 588d6b5

Please sign in to comment.