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

Add arbi validator #19

Merged
merged 68 commits into from Dec 10, 2023
Merged

Add arbi validator #19

merged 68 commits into from Dec 10, 2023

Conversation

AlexNi245
Copy link
Contributor

No description provided.

@makoto
Copy link
Member

makoto commented Dec 5, 2023

Just a few notes on what I reviewed and tested.

The code mostly consists of two parts

  • getProvableBlock() at arb-gateway/src/ArbProofService.ts that copies the gateway service code of arb-resolver
  • getStorageValues() at arb-verifier/contracts/ArbVerifier.sol that copies the _addrWithProof code of arb-resolver
  • The contract tests on arb-verifier is identical to the tests on op-verifier. I started Nitro Test node locally and run the test against and all passed successfully.
  • I also deployed cross-chain resolver pointing to the arb verifier and gateway and it successfully resolved the ETH address of arb.evmgateway.eth

…deployment-with-corsify-and-readme-update

Update README.md
Copy link
Member

@Arachnid Arachnid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this!

arb-gateway/README.md Show resolved Hide resolved
arb-gateway/README.md Outdated Show resolved Hide resolved
arb-gateway/README.md Outdated Show resolved Hide resolved
arb-gateway/package.json Outdated Show resolved Hide resolved

return AbiCoder.defaultAbiCoder().encode(
[
'tuple(bytes32 version, bytes32 sendRoot, bytes32 blockHash,uint64 nodeIndex,bytes rlpEncodedBlock)',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'tuple(bytes32 version, bytes32 sendRoot, bytes32 blockHash,uint64 nodeIndex,bytes rlpEncodedBlock)',
'tuple(bytes32 version, bytes32 sendRoot, bytes32 blockHash, uint64 nodeIndex, bytes rlpEncodedBlock)',

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it necessary to supply both the block and its hash?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch, will be removed

const nodeIndex = await this.rollup.latestNodeCreated()

//We fetch the node created event for the node index we just retrieved.
const nodeEventFilter = await this.rollup.filters.NodeCreated(nodeIndex);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are any of these operations costly? Should we be caching the latest block?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're making two RPC calls to fetch the latest node from the L1 contract and the corresponding L2 block. Besides that, it's just event parsing. Given that the latestNodeCreated is updated roughly every hour on the mainnet, I think it could be a really good idea to cache both the Node and Block. However, there might be additional infrastructure like Redis needed to do that properly with the serverless Cloudflare worker the gateway is deployed on.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One of the RPCs is an event filter, though, which can be slow and costly. Perhaps we can at least cache the result in-process in a variable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added a simple in-memory cache that caches the values for a particular nodeIndex. It can be easily replaced by a more sophisticated cache by implementing the IBlockCache interface

arb-verifier/contracts/ArbVerifier.sol Outdated Show resolved Hide resolved
@@ -2,6 +2,7 @@
import { EVMProofHelper, type IProofService } from '@ensdomains/evm-gateway';
import { AbiCoder, Contract, EventLog, ethers, toBeHex, type AddressLike, toNumber } from 'ethers';
import rollupAbi from "./abi/rollupABI.js";
import type { IBlockCache } from './cache/IBlockCache.js';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you forgot to commit this file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes it was part of .gitignore. It is committed now

@makoto makoto merged commit 0c15039 into ensdomains:main Dec 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants