-
Notifications
You must be signed in to change notification settings - Fork 0
Feat/ethereal hypercore executors #15
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
Open
tHeMaskedMan981
wants to merge
2
commits into
main
Choose a base branch
from
feat/ethereal-hypercore-executors
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| { | ||
| "RFQVaultExecutor": "0x97caCa78AC2a94c67643d07843F85AFAa44a3ea5" | ||
| "RFQVaultExecutor": "0x97caCa78AC2a94c67643d07843F85AFAa44a3ea5", | ||
| "CctpClaimExecutor": "0x424a31a57f7c63918ecaa2fac38016a8af5a6ec2" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| { | ||
| "RFQVaultExecutor": "0x97caCa78AC2a94c67643d07843F85AFAa44a3ea5", | ||
| "CctpClaimExecutor": "0x424a31a57f7c63918ecaa2fac38016a8af5a6ec2" | ||
| "CctpClaimExecutor": "0x424a31a57f7c63918ecaa2fac38016a8af5a6ec2", | ||
| "HypercoreDepositExecutor": "0x20dfbf72767129c9305d7b34d67770815a793fb8" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,275 @@ | ||
| /** | ||
| * Deployment script for EtherealExecutor via CreateX CREATE3. | ||
| * | ||
| * Deploy on Ethereal only — the sole destination chain USDe deposits into ExchangeGateway. | ||
| * | ||
| * Usage: | ||
| * npx hardhat run scripts/deploy/deployEtherealExecutor.ts --network ethereal | ||
| * | ||
| * Required env vars: | ||
| * DEPLOYER_PRIVATE_KEY — deployer wallet private key | ||
| * | ||
| * Optional env vars: | ||
| * OWNER_ADDRESS — EtherealExecutor owner/EXECUTOR_ROLE holder; defaults to DEFAULT_OWNER_ADDRESS or deployer | ||
| * RESCUE_ADDRESS — RESCUE_ROLE holder; defaults to the resolved owner address | ||
| */ | ||
|
|
||
| import hre, { ethers } from 'hardhat'; | ||
| import { | ||
| CREATE_X_FACTORY, | ||
| Create3ABI, | ||
| ETHEREAL_EXECUTOR_CREATE3_SALT, | ||
| ETHEREAL_EXECUTOR_CREATE3_SALT_TEXT, | ||
| CALLDATA_EXECUTOR_EXPECTED_ADDRESS, | ||
| decodeCreate3DeploymentFromTxReceipt, | ||
| hasContractBytecode, | ||
| } from './create3'; | ||
| import { findDeploymentRegistryRow } from './deploymentRegistry'; | ||
| import { writeEtherealExecutorAddress } from './etherealExecutorAddresses'; | ||
| import { ETHEREAL_EXECUTOR_CHAIN_CONFIG } from './etherealExecutorConfig'; | ||
|
|
||
| const DEFAULT_OWNER_ADDRESS = '0x0E1B5AB67aF1c99F8c7Ebc71f41f75D4D6211e53'; | ||
|
|
||
| const ADDR_HEX_RE = /^0x[a-fA-F0-9]{40}$/; | ||
|
|
||
| function resolveOwnerAddress(deployerAddress: string): string { | ||
| const envOwner = process.env.OWNER_ADDRESS?.trim(); | ||
| if (envOwner && ADDR_HEX_RE.test(envOwner)) { | ||
| return envOwner; | ||
| } | ||
|
|
||
| if (DEFAULT_OWNER_ADDRESS && ADDR_HEX_RE.test(DEFAULT_OWNER_ADDRESS)) { | ||
| return DEFAULT_OWNER_ADDRESS; | ||
| } | ||
|
|
||
| return deployerAddress; | ||
| } | ||
|
|
||
| function resolveRescueAddress(ownerAddress: string): string { | ||
| const envRescue = process.env.RESCUE_ADDRESS?.trim(); | ||
| if (envRescue && ADDR_HEX_RE.test(envRescue)) { | ||
| return envRescue; | ||
| } | ||
|
|
||
| return ownerAddress; | ||
| } | ||
|
|
||
| function resolveCalldataExecutorAddress(chainId: number): string { | ||
| const row = findDeploymentRegistryRow(chainId); | ||
| const registryAddress = row?.calldataExecutorAddress?.trim(); | ||
| if (registryAddress && ADDR_HEX_RE.test(registryAddress)) { | ||
| return registryAddress; | ||
| } | ||
|
|
||
| return CALLDATA_EXECUTOR_EXPECTED_ADDRESS; | ||
| } | ||
|
|
||
| async function getEtherealExecutorInitcode(params: { | ||
| owner: string; | ||
| rescueAddress: string; | ||
| calldataExecutor: string; | ||
| exchangeGateway: string; | ||
| depositToken: string; | ||
| }): Promise<string> { | ||
| const factory = await ethers.getContractFactory('EtherealExecutor'); | ||
| const deployTransaction = await factory.getDeployTransaction( | ||
| params.owner, | ||
| params.rescueAddress, | ||
| params.calldataExecutor, | ||
| params.exchangeGateway, | ||
| params.depositToken, | ||
| ); | ||
|
|
||
| if (!deployTransaction.data) { | ||
| throw new Error('EtherealExecutor deploy transaction data is empty'); | ||
| } | ||
|
|
||
| return deployTransaction.data; | ||
| } | ||
|
|
||
| async function assertEtherealExecutorDeployment(params: { | ||
| address: string; | ||
| owner: string; | ||
| calldataExecutor: string; | ||
| exchangeGateway: string; | ||
| depositToken: string; | ||
| }): Promise<void> { | ||
| const contract = new ethers.Contract( | ||
| params.address, | ||
| [ | ||
| 'function owner() view returns (address)', | ||
| 'function CALLDATA_EXECUTOR() view returns (address)', | ||
| 'function exchangeGateway() view returns (address)', | ||
| 'function DEPOSIT_TOKEN() view returns (address)', | ||
| ], | ||
| ethers.provider, | ||
| ); | ||
|
|
||
| const [owner, calldataExecutor, exchangeGateway, depositToken] = await Promise.all([ | ||
| contract.owner() as Promise<string>, | ||
| contract.CALLDATA_EXECUTOR() as Promise<string>, | ||
| contract.exchangeGateway() as Promise<string>, | ||
| contract.DEPOSIT_TOKEN() as Promise<string>, | ||
| ]); | ||
|
|
||
| if (owner.toLowerCase() !== params.owner.toLowerCase()) { | ||
| throw new Error(`EtherealExecutor owner mismatch: expected ${params.owner}, got ${owner}`); | ||
| } | ||
|
|
||
| if (calldataExecutor.toLowerCase() !== params.calldataExecutor.toLowerCase()) { | ||
| throw new Error( | ||
| `EtherealExecutor CALLDATA_EXECUTOR mismatch: expected ${params.calldataExecutor}, got ${calldataExecutor}`, | ||
| ); | ||
| } | ||
|
|
||
| if (exchangeGateway.toLowerCase() !== params.exchangeGateway.toLowerCase()) { | ||
| throw new Error( | ||
| `EtherealExecutor exchangeGateway mismatch: expected ${params.exchangeGateway}, got ${exchangeGateway}`, | ||
| ); | ||
| } | ||
|
|
||
| if (depositToken.toLowerCase() !== params.depositToken.toLowerCase()) { | ||
| throw new Error( | ||
| `EtherealExecutor DEPOSIT_TOKEN mismatch: expected ${params.depositToken}, got ${depositToken}`, | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| function printBackendConfigSnippet(chainId: number, address: string): void { | ||
| console.log('\n=== bungee-backend config snippet ==='); | ||
| console.log( | ||
| 'Update executorAddress in bungee-backend/src/modules/bungee-auto/constants.ts (ETHEREAL_DEPOSIT_CONFIG):', | ||
| ); | ||
| console.log(` [${chainId}]: '${address}',`); | ||
| } | ||
|
|
||
| async function persistEtherealExecutorAddress(params: { | ||
| network: string; | ||
| chainId: number; | ||
| address: string; | ||
| }): Promise<void> { | ||
| const filePath = await writeEtherealExecutorAddress(params.network, params.address); | ||
| console.log('Deployment JSON:', filePath); | ||
| printBackendConfigSnippet(params.chainId, params.address); | ||
| } | ||
|
|
||
| async function main() { | ||
| const [deployer] = await ethers.getSigners(); | ||
| const networkName = hre.network.name; | ||
| const chainId = Number((await ethers.provider.getNetwork()).chainId); | ||
|
|
||
| const chainConfig = ETHEREAL_EXECUTOR_CHAIN_CONFIG[chainId]; | ||
| if (!chainConfig) { | ||
| throw new Error(`Chain ${chainId} is not configured for EtherealExecutor deployment`); | ||
| } | ||
|
|
||
| console.log('Deployer: ', deployer.address); | ||
| console.log('Network: ', networkName); | ||
| console.log('Chain ID: ', chainId); | ||
| console.log('CREATE3 salt: ', ETHEREAL_EXECUTOR_CREATE3_SALT_TEXT); | ||
| console.log(''); | ||
|
|
||
| const owner = resolveOwnerAddress(deployer.address); | ||
| const rescueAddress = resolveRescueAddress(owner); | ||
| const calldataExecutor = resolveCalldataExecutorAddress(chainId); | ||
| const { exchangeGateway, depositToken } = chainConfig; | ||
|
|
||
| console.log('Owner: ', owner); | ||
| console.log('RescueAddress: ', rescueAddress); | ||
| console.log('CalldataExecutor: ', calldataExecutor); | ||
| console.log('ExchangeGateway: ', exchangeGateway); | ||
| console.log('DepositToken: ', depositToken); | ||
| console.log(''); | ||
|
|
||
| const initcode = await getEtherealExecutorInitcode({ | ||
| owner, | ||
| rescueAddress, | ||
| calldataExecutor, | ||
| exchangeGateway, | ||
| depositToken, | ||
| }); | ||
|
|
||
| const create3Factory = new ethers.Contract(CREATE_X_FACTORY, Create3ABI, deployer); | ||
|
|
||
| const expectedAddress = (await create3Factory.deployCreate3.staticCall( | ||
| ETHEREAL_EXECUTOR_CREATE3_SALT, | ||
| initcode, | ||
| )) as string; | ||
|
|
||
| console.log('Expected address:', expectedAddress); | ||
|
|
||
| const existingBytecode = await ethers.provider.getCode(expectedAddress); | ||
| if (hasContractBytecode(existingBytecode)) { | ||
| console.log(`EtherealExecutor already deployed at ${expectedAddress}`); | ||
| await assertEtherealExecutorDeployment({ | ||
| address: expectedAddress, | ||
| owner, | ||
| calldataExecutor, | ||
| exchangeGateway, | ||
| depositToken, | ||
| }); | ||
| await persistEtherealExecutorAddress({ | ||
| network: networkName, | ||
| chainId, | ||
| address: expectedAddress, | ||
| }); | ||
| return; | ||
| } | ||
|
|
||
| console.log('Deploying EtherealExecutor via CREATE3...'); | ||
| const create3Deployment = await create3Factory.deployCreate3( | ||
| ETHEREAL_EXECUTOR_CREATE3_SALT, | ||
| initcode, | ||
| ); | ||
| console.log('CREATE3 deployment tx:', create3Deployment.hash); | ||
|
|
||
| const receipt = await create3Deployment.wait(); | ||
| const executorAddress = decodeCreate3DeploymentFromTxReceipt({ receipt }); | ||
| if (!executorAddress) { | ||
| throw new Error('EtherealExecutor address not found in CREATE3 deployment receipt'); | ||
| } | ||
|
|
||
| if (executorAddress.toLowerCase() !== expectedAddress.toLowerCase()) { | ||
| throw new Error( | ||
| `Deployed address ${executorAddress} does not match staticCall ${expectedAddress}`, | ||
| ); | ||
| } | ||
|
|
||
| await assertEtherealExecutorDeployment({ | ||
| address: executorAddress, | ||
| owner, | ||
| calldataExecutor, | ||
| exchangeGateway, | ||
| depositToken, | ||
| }); | ||
|
|
||
| console.log('\n=== Deployment Summary ==='); | ||
| console.log(`EtherealExecutor (${networkName}): ${executorAddress}`); | ||
| await persistEtherealExecutorAddress({ | ||
| network: networkName, | ||
| chainId, | ||
| address: executorAddress, | ||
| }); | ||
|
|
||
| if (chainId !== 31337) { | ||
| await new Promise((resolve) => setTimeout(resolve, 5000)); | ||
|
|
||
| try { | ||
| await hre.run('verify:verify', { | ||
| address: executorAddress, | ||
| constructorArguments: [owner, rescueAddress, calldataExecutor, exchangeGateway, depositToken], | ||
| }); | ||
| console.log('Contract verified on block explorer'); | ||
| } catch (err) { | ||
| console.warn( | ||
| 'Contract verification failed (deployment succeeded):', | ||
| err instanceof Error ? err.message : err, | ||
| ); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| main().catch((err) => { | ||
| console.error(err); | ||
| process.exit(1); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🌐 Web query:
Circle CCTP MessageTransmitter contract address on Arc mainnet chain 5042💡 Result:
The Circle CCTP MessageTransmitterV2 contract address on the Arc mainnet (Chain ID 5042) is 0xE737e5cEBEEBa77EFE34D4aa090756590b1CE275 [1][2]. This address is documented in the official Arc documentation for its cross-chain interoperability infrastructure [1][2]. Users integrating with CCTP on the Arc network should utilize this contract address for message transmission and receiving operations [2].
Citations:
🏁 Script executed:
Repository: SocketDotTech/openrouter
Length of output: 50380
🏁 Script executed:
Repository: SocketDotTech/openrouter
Length of output: 6013
🏁 Script executed:
Repository: SocketDotTech/openrouter
Length of output: 15960
🏁 Script executed:
Repository: SocketDotTech/openrouter
Length of output: 7580
🏁 Script executed:
Repository: SocketDotTech/openrouter
Length of output: 5648
🏁 Script executed:
Repository: SocketDotTech/openrouter
Length of output: 10277
Use Arc’s chain-specific CCTP transmitter address.
CctpClaimExecutoronly does raw 6-decimal USDC balance accounting, so the USDC wrapper at0x3600000000000000000000000000000000000000is fine. The real issue isCCTP_MESSAGE_TRANSMITTER: Arc mainnet uses0xE737e5cEBEEBa77EFE34D4aa090756590b1CE275, so this entry should not reuse the global constant.🤖 Prompt for AI Agents