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

CCIP Read implementation #41

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

pikonha
Copy link

@pikonha pikonha commented Mar 19, 2024

CCIP Read implementation

Description

This pull request adds the CCIP-Read support to the Go-ENS library. This function enables users to read data from offchain data sources that follow the EIP-3668 standard.

These additions enhance the versatility and utility of the Go-ENS library by enabling seamless interaction with contracts and providing efficient domain resolution capabilities. The implementation aligns with the library's objective of comprehensive support for Ethereum Name Service (ENS) operations.

How it works

  1. Go-ENS calls the Universal Resolver ENS' contract with the intent of forward resolving a domain such as jesse.cd.id (externally handled by Coinbase's Offchain Resolver)
  2. The Universal Resolver returns the address of the offchain resolver
  3. Go-ENS calls the addr(namehash) or resolve(labelhash, encodedArgs) function on the contract which reverts with OffchainLookup as described on the EIP-3668
  4. The client then parses the given error in order to get the following parameters:
    • sender: contract's address
    • urls: offchain API URL
    • callData: encoded function call that should be redirected to the API
    • callbackFunction: validation function that should be called with the API's response
    • extraData: encoded function call with arbitrary arguments
  5. A request to the given URL is made with sender and calldata as arguments following the Gateway Interface
  6. The callbackFunction is then called with the API's response and the extraData to validate the authenticity of the data
  7. The Offchain Resolver's callback function response is then parsed and returned by the caller
┌──────┐                                          ┌────────┐ ┌─────────────┐
│GO-ENS│                                          │Contract│ │   Gateway   │
└──┬───┘                                          └───┬────┘ └──────┬──────┘
   │                                                  │             │
   │ somefunc(...)                                    │             │
   ├─────────────────────────────────────────────────►│             │
   │                                                  │             │
   │ revert OffchainLookup(sender, urls, callData,    │             │
   │                     callbackFunction, extraData) │             │
   │◄─────────────────────────────────────────────────┤             │
   │                                                  │             │
   │ HTTP request (sender, callData)                  │             │
   ├──────────────────────────────────────────────────┼────────────►│
   │                                                  │             │
   │ Response (result)                                │             │
   │◄─────────────────────────────────────────────────┼─────────────┤
   │                                                  │             │
   │ callbackFunction(result, extraData)              │             │
   ├─────────────────────────────────────────────────►│             │
   │                                                  │             │
   │ answer                                           │             │
   │◄─────────────────────────────────────────────────┤             │
   │                                                  │             │

Related Issue

Issue #38
PR #40

Changes

  • New feature implementation
  • Bug fix
  • Code refactoring
  • Documentation update
  • Other (please specify)

Changes to Core Features:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your core changes, as applicable?
  • Have you successfully run tests with your changes locally?

Additional Notes

I'm working on the CCIP Read implementation for the other features such as reading text, multicoin addresses, and contenthash.

The Subdomain resolution PR was used as a starting point for this implementation, which enables this PR to handle both, CCIP-Read and subdomain resolution. They have been decoupled to make the review process easier.

Cheers from the Blockful team 👋🏼

@pikonha
Copy link
Author

pikonha commented Mar 26, 2024

This is now fully working:

  • resolving off-chain addresses
  • getting off-chain text

feedback on the implementation is more than welcome

@mdtanrikulu
Copy link

mdtanrikulu commented Apr 2, 2024

lgtm! works fine with real examples. only small problem is that the following test fails, probably because of some custom error change;

TestResolveEthereum > resolver_test.go:74

Expected nil, but got: &errors.errorString{s:"unregistered name"}

@pikonha
Copy link
Author

pikonha commented Apr 2, 2024

lgtm! works fine with real examples. only small problem is that the following test fails, probably because of some custom error change;

TestResolveEthereum > resolver_test.go:74

Expected nil, but got: &errors.errorString{s:"unregistered name"}

thanks for reviewing it, mate. this test is failing on the main branch as well, I'll fix it with a similar scenario.

@pikonha
Copy link
Author

pikonha commented Apr 5, 2024

lgtm! works fine with real examples. only small problem is that the following test fails, probably because of some custom error change;

TestResolveEthereum > resolver_test.go:74

Expected nil, but got: &errors.errorString{s:"unregistered name"}

the ethereum.eth test is failing because no address is assigned to this domain on mainnet as you can see in here. a similar scenario is being tested on the TestResolveResolverEth test.

image

@pikonha
Copy link
Author

pikonha commented Apr 23, 2024

any updated on this?

@mdtanrikulu
Copy link

any updated on this?

I think in that case this should be handled in the original go-ens repo. It's surely unrelated with the current PR. All good for me.

@dneilroth
Copy link

@pikonha Thanks for putting this together, was looking for an implementation just like this to help with x-chain reads for a project of mine. Anything I can do to help get it merged?

@pikonha
Copy link
Author

pikonha commented May 8, 2024

@dneilroth it's pretty much done from my end tbh, just waiting for the review and approval.

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