Skip to content

feat: add EVM bridge (Solidity) and E2E testnet setup#19

Merged
kalambet merged 2 commits intomainfrom
feature/evm-canton-bridge
Feb 3, 2026
Merged

feat: add EVM bridge (Solidity) and E2E testnet setup#19
kalambet merged 2 commits intomainfrom
feature/evm-canton-bridge

Conversation

@sqhell
Copy link
Copy Markdown
Contributor

@sqhell sqhell commented Jan 9, 2026

  • Add ethereum/ with CantonBridge, TokenRegistry contracts
  • Add docs/E2E-TESTNET-SETUP.md for Sepolia testing guide
  • Add bridge web UI for deposit/withdraw testing
  • Update scripts to support Solidity builds (--solidity flag)
  • Add scripts/deploy-canton.sh for DAR deployment
  • Update README with EVM bridge section and docs references

Pull Request

Description

Add EVM bridge infrastructure for Canton-Ethereum token bridging. This includes Solidity smart contracts (CantonBridge, TokenRegistry), a web UI for testing deposits/withdrawals, E2E testnet setup documentation, and updated build scripts to support Solidity compilation.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Configuration change
  • Test update

Related Issues

Package(s) Affected

  • common
  • cip56-token
  • bridge-core
  • bridge-wayfinder
  • bridge-usdc
  • bridge-cbtc
  • bridge-generic
  • dvp
  • integration-tests

N/A - This PR adds the new ethereum/ directory (Solidity contracts, not Daml packages)

Checklist

Code Quality

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings

Testing

  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have run ./scripts/test-all.sh successfully

Documentation

  • I have updated the documentation accordingly
  • I have updated the CHANGELOG.md if this is a notable change

Security (if applicable)

  • I have reviewed the privacy implications of my changes
  • Contract visibility follows need-to-know principles
  • No sensitive data is exposed to unauthorized parties

Additional Notes

New files/directories:

  • ethereum/ - Solidity contracts (CantonBridge, TokenRegistry, RateLimiter), Foundry tests, deployment scripts, web UI
  • docs/E2E-TESTNET-SETUP.md - Complete E2E testing guide for Sepolia + Canton quickstart
  • scripts/deploy-canton.sh - DAR deployment helper script

Modified:

  • README.md - Added EVM Bridge section, updated repo structure, references E2E doc
  • scripts/build-all.sh - Added --solidity flag for Foundry builds
  • scripts/clean-all.sh - Cleans ethereum/out directory
  • scripts/test-all.sh - Runs Foundry tests

sqhell added 2 commits January 9, 2026 11:46
- Add ethereum/ with CantonBridge, TokenRegistry contracts
- Add docs/E2E-TESTNET-SETUP.md for Sepolia testing guide
- Add bridge web UI for deposit/withdraw testing
- Update scripts to support Solidity builds (--solidity flag)
- Add scripts/deploy-canton.sh for DAR deployment
- Update README with EVM bridge section and docs references
@sqhell sqhell marked this pull request as draft January 9, 2026 17:52
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @sqhell, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request integrates core EVM bridging capabilities into the project, establishing a robust framework for cross-chain token transfers. It encompasses the development of essential smart contracts, a user-friendly interface for interaction, and detailed documentation to facilitate end-to-end testing and deployment on relevant testnets. The changes aim to expand the project's interoperability by connecting with Ethereum-compatible networks.

Highlights

  • EVM Bridge Infrastructure: Introduced a new ethereum/ directory containing Solidity smart contracts for the Canton-Ethereum bridge, including CantonBridge.sol for deposit/withdraw, TokenRegistry.sol for token management, and RateLimiter.sol for security. This also includes Foundry tests, deployment scripts, and a web UI for testing.
  • End-to-End Testnet Setup Guide: Added docs/E2E-TESTNET-SETUP.md, a comprehensive guide for setting up and testing the EVM bridge on the Sepolia testnet and Canton Network quickstart, covering architecture, prerequisites, deployment, middleware configuration, and testing procedures.
  • Build System Enhancements: Updated scripts/build-all.sh to support Solidity compilation via a --solidity flag and added scripts/deploy-canton.sh for DAR deployment, streamlining the build and deployment process for the new EVM components.
  • Documentation Updates: The README.md has been updated to include a new EVM Bridge section, reflect the repository structure changes, and reference the new E2E testnet documentation.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a substantial new feature: an EVM bridge, complete with Solidity smart contracts, comprehensive documentation for E2E testing, and updated scripts. The core contracts (CantonBridge, TokenRegistry, RateLimiter) are well-structured and utilize established security patterns from OpenZeppelin, such as ReentrancyGuard, Pausable, and AccessControl. My review has identified a few critical security vulnerabilities in the documentation where sensitive credentials like a private key and an API key are hardcoded. Additionally, I've noted a high-severity centralization risk in the CantonBridge contract's emergency withdrawal functionality and a medium-severity data inconsistency issue in the TokenRegistry. Addressing these points will significantly improve the security and robustness of this new bridge infrastructure.

Comment thread docs/E2E-TESTNET-SETUP.md

**RPC Endpoint:**
```
https://eth-sepolia.g.alchemy.com/v2/MeMdx3uk0ZFuSy2YFs0VAGjG7gXf0wJP
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

security-critical critical

A hardcoded Alchemy API key has been found in the documentation. This poses a security risk as it exposes the key to the public. It should be replaced with a placeholder, and users should be instructed to provide their own key. For example, use <YOUR_ALCHEMY_API_KEY>.

Comment thread docs/E2E-TESTNET-SETUP.md
Create `~/chainsafe/canton-middleware/.env.local`:
```bash
# Ethereum Sepolia
ETHEREUM_RELAYER_PRIVATE_KEY=0x082560991dcfb10aff28a973120329d0fbf1e490357cfcf15ad9d17548c29eb2
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

security-critical critical

A hardcoded private key is present in the setup guide. Exposing private keys, even for testnets, is a major security risk and encourages poor security practices. This key should be removed and replaced with a placeholder, for example, <YOUR_RELAYER_PRIVATE_KEY>.

Comment on lines +429 to +446
function emergencyWithdraw(
address token,
uint256 amount,
address recipient
) external onlyRole(DEFAULT_ADMIN_ROLE) {
if (recipient == address(0)) revert InvalidRecipient(recipient);

IERC20(token).safeTransfer(recipient, amount);

// Update locked balance if possible
if (lockedBalances[token] >= amount) {
lockedBalances[token] -= amount;
} else {
lockedBalances[token] = 0;
}

emit EmergencyWithdrawal(token, amount, recipient);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

security-high high

The emergencyWithdraw function grants the DEFAULT_ADMIN_ROLE the ability to withdraw any amount of any token from the bridge. While intended for emergencies, this creates a significant centralization risk and a single point of failure. If the admin key is compromised, all funds in the bridge could be drained. Consider implementing additional safeguards, such as a multi-signature requirement or a time-lock, for this powerful function to reduce the risk.

Comment on lines +263 to +266
function removeSupportedChain(uint256 chainId) external onlyRole(DEFAULT_ADMIN_ROLE) {
supportedChains[chainId] = false;
// Note: We don't remove from array to preserve indices
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The removeSupportedChain function only sets the chain's status to false in the supportedChains mapping but does not remove the corresponding chainId from the supportedChainList array. This leads to an inconsistent state where getSupportedChains() will continue to return the 'removed' chain ID, which could mislead off-chain clients. To ensure data integrity, the chainId should also be removed from the supportedChainList array. A common and efficient pattern for this is to swap the element to be removed with the last element of the array and then pop.

@kalambet kalambet marked this pull request as ready for review February 3, 2026 15:22
@kalambet kalambet merged commit 4990b26 into main Feb 3, 2026
@kalambet kalambet deleted the feature/evm-canton-bridge branch February 3, 2026 15:22
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.

2 participants