Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions .github/workflows/cross-chain-e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# name: Cross-Chain E2E

# on:
# push:
# branches: [main]
# paths:
# - "contracts/**"
# - "proof_circuits/**"
# - "scripts/**"
# - ".github/workflows/cross-chain-e2e.yml"
# pull_request:
# paths:
# - "contracts/**"
# - "proof_circuits/**"
# - "scripts/**"
# - ".github/workflows/cross-chain-e2e.yml"
# workflow_dispatch:

# env:
# CARGO_TERM_COLOR: always

# jobs:
# cross-chain-e2e:
# name: Cross-Chain E2E Test
# runs-on: ubuntu-latest
# timeout-minutes: 30

# steps:
# - uses: actions/checkout@v4
# with:
# submodules: recursive

# - uses: dtolnay/rust-toolchain@stable

# - name: Install wasm32v1-none target
# run: rustup target add wasm32v1-none

# - name: Install Foundry
# uses: foundry-rs/foundry-toolchain@v1

# - name: Install Stellar CLI
# run: |
# curl -Ls https://github.com/stellar/stellar-cli/releases/download/v23.3.0/stellar-cli-23.3.0-x86_64-unknown-linux-gnu.tar.gz -o /tmp/stellar-cli.tar.gz
# mkdir -p "$HOME/.local/bin"
# tar -xzf /tmp/stellar-cli.tar.gz -C "$HOME/.local/bin" stellar
# chmod +x "$HOME/.local/bin/stellar"
# echo "$HOME/.local/bin" >> "$GITHUB_PATH"

# - name: Install pnpm
# uses: pnpm/action-setup@v4

# - name: Install Node.js
# uses: actions/setup-node@v4
# with:
# node-version: "18"
# cache: "pnpm"

# - name: Install Node dependencies
# run: pnpm install --frozen-lockfile

# - name: Cache cargo directories
# uses: actions/cache@v4
# with:
# path: |
# ~/.cargo/registry
# ~/.cargo/git
# contracts/stellar/target
# key: ${{ runner.os }}-cargo-e2e-${{ hashFiles('contracts/stellar/Cargo.lock') }}

# - name: Run cross-chain E2E test
# run: bash scripts/run_cross_chain_e2e.sh
Comment thread
JoE11-y marked this conversation as resolved.
50 changes: 30 additions & 20 deletions contracts/evm/js-scripts/deploy/core/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,20 @@ import {
ORDER_PORTAL_ABI,
} from "./utils";

/**
* Left-pad an EVM address to bytes32 for cross-chain parity.
*/
function addrToBytes32(addr: string): string {
return ethers.zeroPadValue(ethers.getAddress(addr), 32);
}

/**
* Compare a bytes32 returned from chain with an EVM address (case-insensitive).
*/
function b32EqAddr(b32: string, addr: string): boolean {
return b32.toLowerCase() === addrToBytes32(addr).toLowerCase();
}

/**
* Generic function to call a contract function
* Used by specialized scenarios for custom contract interactions
Expand Down Expand Up @@ -103,14 +117,13 @@ export async function linkChains(
const chain1Info = await adManager1.chains(chain2Config.chainId);
if (
chain1Info.supported &&
chain1Info.orderPortal.toLowerCase() ===
chain2Contracts.orderPortal!.toLowerCase()
b32EqAddr(chain1Info.orderPortal, chain2Contracts.orderPortal!)
) {
console.log(" ✓ Already configured");
} else {
const tx1 = await adManager1.setChain(
chain2Config.chainId,
chain2Contracts.orderPortal!,
addrToBytes32(chain2Contracts.orderPortal!),
true
);
console.log(` Tx: ${tx1.hash}`);
Expand Down Expand Up @@ -141,14 +154,13 @@ export async function linkChains(

if (
chain1OrderPortalInfo.supported &&
chain1OrderPortalInfo.adManager.toLowerCase() ===
chain2Contracts.adManager!.toLowerCase()
b32EqAddr(chain1OrderPortalInfo.adManager, chain2Contracts.adManager!)
) {
console.log(" ✓ Already configured");
} else {
const tx2 = await orderPortal1.setChain(
chain2Config.chainId,
chain2Contracts.adManager!,
addrToBytes32(chain2Contracts.adManager!),
true
);
console.log(` Tx: ${tx2.hash}`);
Expand Down Expand Up @@ -177,14 +189,13 @@ export async function linkChains(
const chain2Info = await adManager2.chains(chain1Config.chainId);
if (
chain2Info.supported &&
chain2Info.orderPortal.toLowerCase() ===
chain1Contracts.orderPortal!.toLowerCase()
b32EqAddr(chain2Info.orderPortal, chain1Contracts.orderPortal!)
) {
console.log(" ✓ Already configured");
} else {
const tx3 = await adManager2.setChain(
chain1Config.chainId,
chain1Contracts.orderPortal!,
addrToBytes32(chain1Contracts.orderPortal!),
true
);
console.log(` Tx: ${tx3.hash}`);
Expand Down Expand Up @@ -214,14 +225,13 @@ export async function linkChains(
);
if (
chain2OrderPortalInfo.supported &&
chain2OrderPortalInfo.adManager.toLowerCase() ===
chain1Contracts.adManager!.toLowerCase()
b32EqAddr(chain2OrderPortalInfo.adManager, chain1Contracts.adManager!)
) {
console.log(" ✓ Already configured");
} else {
const tx4 = await orderPortal2.setChain(
chain1Config.chainId,
chain1Contracts.adManager!,
addrToBytes32(chain1Contracts.adManager!),
true
);
console.log(` Tx: ${tx4.hash}`);
Expand Down Expand Up @@ -328,12 +338,12 @@ export async function configureTokenRoutes(
chain2Config.chainId
);

if (existingRoute1.toLowerCase() === routeToken2.toLowerCase()) {
if (b32EqAddr(existingRoute1, routeToken2)) {
console.log(" ✓ Already configured");
} else {
const tx1 = await adManager1.setTokenRoute(
routeToken1, // adToken on chain1
routeToken2, // orderToken on chain2
addrToBytes32(routeToken2), // orderToken on chain2 as bytes32
chain2Config.chainId // orderChainId
);
console.log(` Tx: ${tx1.hash}`);
Expand All @@ -349,13 +359,13 @@ export async function configureTokenRoutes(
chain1Config.chainId
);

if (existingRoute2.toLowerCase() === routeToken1.toLowerCase()) {
if (b32EqAddr(existingRoute2, routeToken1)) {
console.log(" ✓ Already configured");
} else {
const tx2 = await orderPortal2.setTokenRoute(
routeToken2, // orderToken on chain2
chain1Config.chainId, // adChainId
routeToken1 // adToken on chain1
addrToBytes32(routeToken1) // adToken on chain1 as bytes32
);
console.log(` Tx: ${tx2.hash}`);
await waitForTransaction(tx2);
Expand All @@ -370,12 +380,12 @@ export async function configureTokenRoutes(
chain1Config.chainId
);

if (existingRoute3.toLowerCase() === routeToken1.toLowerCase()) {
if (b32EqAddr(existingRoute3, routeToken1)) {
console.log(" ✓ Already configured");
} else {
const tx3 = await adManager2.setTokenRoute(
routeToken2, // adToken on chain2
routeToken1, // orderToken on chain1
addrToBytes32(routeToken1), // orderToken on chain1 as bytes32
chain1Config.chainId // orderChainId
);
console.log(` Tx: ${tx3.hash}`);
Expand All @@ -391,13 +401,13 @@ export async function configureTokenRoutes(
chain2Config.chainId
);

if (existingRoute4.toLowerCase() === routeToken2.toLowerCase()) {
if (b32EqAddr(existingRoute4, routeToken2)) {
console.log(" ✓ Already configured");
} else {
const tx4 = await orderPortal1.setTokenRoute(
routeToken1, // orderToken on chain1
chain2Config.chainId, // adChainId
routeToken2 // adToken on chain2
addrToBytes32(routeToken2) // adToken on chain2 as bytes32
);
console.log(` Tx: ${tx4.hash}`);
await waitForTransaction(tx4);
Expand Down
16 changes: 8 additions & 8 deletions contracts/evm/js-scripts/deploy/core/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@ export const MERKLE_MANAGER_ABI = [
];

export const AD_MANAGER_ABI = [
"function setChain(uint256 orderChainId, address orderPortal, bool supported) external",
"function setTokenRoute(address adToken, address orderToken, uint256 orderChainId) external",
"function chains(uint256) external view returns (bool supported, address orderPortal)",
"function tokenRoute(address, uint256) external view returns (address)",
"function setChain(uint256 orderChainId, bytes32 orderPortal, bool supported) external",
"function setTokenRoute(address adToken, bytes32 orderToken, uint256 orderChainId) external",
"function chains(uint256) external view returns (bool supported, bytes32 orderPortal)",
"function tokenRoute(address, uint256) external view returns (bytes32)",
"function i_merkleManager() external view returns (address)",
"function i_verifier() external view returns (address)",
];

export const ORDER_PORTAL_ABI = [
"function setChain(uint256 adChainId, address adManager, bool supported) external",
"function setTokenRoute(address orderToken, uint256 adChainId, address adToken) external",
"function chains(uint256) external view returns (bool supported, address adManager)",
"function tokenRoute(address, uint256) external view returns (address)",
"function setChain(uint256 adChainId, bytes32 adManager, bool supported) external",
"function setTokenRoute(address orderToken, uint256 adChainId, bytes32 adToken) external",
"function chains(uint256) external view returns (bool supported, bytes32 adManager)",
"function tokenRoute(address, uint256) external view returns (bytes32)",
"function i_merkleManager() external view returns (address)",
"function i_verifier() external view returns (address)",
];
Expand Down
16 changes: 8 additions & 8 deletions contracts/evm/js-scripts/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ export const domain = {
// ----------------------------
export const orderTypes: Record<string, { name: string; type: string }[]> = {
Order: [
{ name: "orderChainToken", type: "address" },
{ name: "adChainToken", type: "address" },
{ name: "orderChainToken", type: "bytes32" },
{ name: "adChainToken", type: "bytes32" },
{ name: "amount", type: "uint256" },
{ name: "bridger", type: "address" },
{ name: "bridger", type: "bytes32" },
{ name: "orderChainId", type: "uint256" },
{ name: "orderPortal", type: "address" },
{ name: "orderRecipient", type: "address" },
{ name: "orderPortal", type: "bytes32" },
{ name: "orderRecipient", type: "bytes32" },
{ name: "adChainId", type: "uint256" },
{ name: "adManager", type: "address" },
{ name: "adManager", type: "bytes32" },
{ name: "adId", type: "string" },
{ name: "adCreator", type: "address" },
{ name: "adRecipient", type: "address" },
{ name: "adCreator", type: "bytes32" },
{ name: "adRecipient", type: "bytes32" },
{ name: "salt", type: "uint256" },
],
};
Expand Down
Loading
Loading