Skip to content

CCIP Cross-Chain Name Service (CCNS) is a cross-chain domain name service system that allows users to register and manage unique domain names on different chains. The project leverages Chainlink's Cross-Chain Interoperability Protocol (CCIP) to enable cross-chain communication

License

Notifications You must be signed in to change notification settings

meitedaf/ccip-cross-chain-name-service

 
 

Repository files navigation

Cross Chain Name Service Project

Original Repository:
smartcontractkit/ccip-cross-chain-name-service

Forked Repository Reason:
I forked this repository to implement tests for the Cross Chain Name Service project using the CCIPLocalSimulator.

Issue Encountered:
While using CCIPLocalSimulator for testing, I encountered the following issue, referenced in GitHub issue #17. The primary challenge is that even after resolving the Unauthorized() error, an AlreadyTaken() error would occur. This happens because CCIPLocalSimulator simulates cross-chain behavior on the same blockchain, which leads to duplicate calls when attempting to register a name.

Modifications & Testing Process

To overcome this, I made the following modifications:

  1. Installing Foundry in the Hardhat Project:

    npm install --save-dev @nomicfoundation/hardhat-foundry
  2. Changes to the CrossChainNameServiceLookup Contract:

    • I updated the onlyCrossChainNameService modifier to hardcode the address of ccnsRegister. This ensures that ccnsRegister is authorized to call the register() function.
    • Updated Modifier:
      modifier onlyCrossChainNameService() {
          if (msg.sender != s_crossChainNameService && msg.sender != 0xF62849F9A0B5Bf2913b396098F7c7019b51A820a) {
              revert Unauthorized();
          }
          _;
      }
  3. Changes to the CrossChainNameServiceRegister Contract:

    • I removed the last line from the register() function:
      i_lookup.register(_name, msg.sender);
    • Reasoning: This avoids the duplication of registration calls on the source chain, which would otherwise result in an AlreadyTaken error when attempting to register the same name twice. The registration on the source chain now only happens via cross-chain messages to avoid conflicts.
  4. Testing Contract:

    • I created a test contract CrossChainNameServiceTest to verify the implementation of cross-chain name registration using the modified contracts and the CCIPLocalSimulator.

Summary

The modified approach ensures that name registration is completed only via cross-chain messages, without redundant calls on the source chain. This prevents the AlreadyTaken error and allows the CCIPLocalSimulator to simulate cross-chain behavior more effectively, even though it operates on the same blockchain for testing purposes.

About

CCIP Cross-Chain Name Service (CCNS) is a cross-chain domain name service system that allows users to register and manage unique domain names on different chains. The project leverages Chainlink's Cross-Chain Interoperability Protocol (CCIP) to enable cross-chain communication

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 97.2%
  • Solidity 2.8%