circlefin/evm-cctp-contracts
关于
Official repository for all EVM-compatible smart contracts used by the Cross-Chain Transfer Protocol
开发工具实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- 正在收集历史
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文evm-cctp-contracts
Prerequisites
Install dependencies
- Run
git submodule update --init --recursiveto update/download all libraries. - Run
yarn installto install any additional dependencies.
VSCode IDE Setup
- Install solidity extension https://marketplace.visualstudio.com/items?itemName=juanblanco.solidity
- Navigate to a .sol file
- Right-click, select
Solidity: Change global compiler version (Remote)

- Select 0.7.6

- Install solhint extension https://marketplace.visualstudio.com/items?itemName=idrabenia.solidity-solhint
Install Foundry
Install Foundry CLI (forge 0.2.0) from official website.
- To install a specific version, see here.
Testing
Unit tests
Run forge test to run test using installed forge cli or make test to run tests in docker container.
Run unit tests with debug logs
Log level is controlled by the -v flag. For example, forge test -vv displays console.log() statements from within contracts. Highest verbosity is -vvvvv. More info: https://book.getfoundry.sh/forge/tests.html#logs-and-traces. Contracts that use console.log() must import lib/forge-std/src/console.sol.
Integration tests
Run make anvil-test to setup anvil test node in docker container and run integration tests. There is an example in anvil/ folder
Linting
Run yarn lint to lint all .sol files in the src and test directories.
Static analysis
Run make analyze-{message-transmitter | message-transmitter-v2 | token-messenger-minter} to set up Mythril dependency and run Mythril on all source files. If Mythril dependency has been installed, alternatively run myth -v4 analyze $FILE_PATH --solc-json mythril.config.json --solv 0.7.6 to run static analysis on a .sol file at the given $FILE_PATH. Please note that this can take several minutes.
Continuous Integration using Github Actions
We use Github actions to run linter and all the tests. The workflow configuration can be found in .github/workflows/ci.yml
Manual Triggering of the Olympix CI Workflow for Security Alerts
You can manually trigger the Olympix.ai Code Scanning workflow using the workflow_dispatch feature of GitHub Actions.
- Click on the
Actionstab. - In the left sidebar, select
Olympix Scan. - Select the branch & click on the
Run workflowbutton.
Alternative Installations
Docker + Foundry
Use Docker to run Foundry commands. Run make build to build Foundry docker image. Then run docker run --rm foundry "<COMMAND>" to run any forge, anvil or cast commands. There are some pre defined commands available in Makefile for testing and deploying contract on anvil. More info on Docker and Foundry here.
ℹ️ Note
- Some machines (including those with M1 chips) may be unable to build the docker image locally. This is a known issue.
Deployment
V1
The contracts are deployed using Forge Scripts. The script is located in scripts/v1/deploy.s.sol. Follow the below steps to deploy the contracts:
Add the below environment variables to your env file
MESSAGE_TRANSMITTER_DEPLOYER_KEYTOKEN_MESSENGER_DEPLOYER_KEYTOKEN_MINTER_DEPLOYER_KEYTOKEN_CONTROLLER_DEPLOYER_KEYATTESTER_ADDRESSUSDC_CONTRACT_ADDRESSREMOTE_USDC_CONTRACT_ADDRESSMESSAGE_TRANSMITTER_PAUSER_ADDRESSTOKEN_MINTER_PAUSER_ADDRESSMESSAGE_TRANSMITTER_RESCUER_ADDRESSTOKEN_MESSENGER_RESCUER_ADDRESSTOKEN_MINTER_RESCUER_ADDRESSTOKEN_CONTROLLER_ADDRESSDOMAINREMOTE_DOMAINBURN_LIMIT_PER_MESSAGE
In addition, to link the remote bridge, one of two steps needs to be followed:
- Add the
REMOTE_TOKEN_MESSENGER_DEPLOYERaddress to your env file and run scripts/precomputeRemoteMessengerAddress.py with argument--REMOTE_RPC_URLfor the remote chain, which will automatically add theREMOTE_TOKEN_MESSENGER_ADDRESSto the .env file - Manually add the
REMOTE_TOKEN_MESSENGER_ADDRESSto your .env file.
Run
make simulate-deploy RPC_URL=<RPC_URL> SENDER=<SENDER>to perform a dry run. Note: Use address from one of the private keys (used for deploying) above assender. It is used to deploy the shared libraries that contracts useRun
make deploy RPC_URL=<RPC_URL> SENDER=<SENDER>to deploy the contracts
V2
Create2Factory
Deploy Create2Factory first if not yet deployed.
- Add the environment variable
CREATE2_FACTORY_OWNER(address) to your env file. - Run
make simulate-deploy-create2-factory RPC_URL=<RPC_URL> SENDER=<SENDER> CREATE2_FACTORY_OWNER_KEY=<PRIVATE_KEY>to perform a dry run. - Run
make deploy-create2-factory RPC_URL=<RPC_URL> SENDER=<SENDER> CREATE2_FACTORY_OWNER_KEY=<PRIVATE_KEY>
to deploy the Create2Factory.
V2 Implementation Contracts
Deploy the implementation contracts.
Add the following env variables
CREATE2_FACTORY_CONTRACT_ADDRESSTOKEN_MINTER_V2_OWNER_KEYTOKEN_CONTROLLER_ADDRESSDOMAINMESSAGE_BODY_VERSIONVERSION
Run
make simulate-deploy-implementations-v2 RPC_URL=<RPC_URL> SENDER=<SENDER> CREATE2_FACTORY_OWNER_KEY=<CREATE2_FACTORY_OWNER_KEY>to perform a dry run.Run
make deploy-implementations-v2 RPC_URL=<RPC_URL> SENDER=<SENDER> CREATE2_FACTORY_OWNER_KEY=<CREATE2_FACTORY_OWNER_KEY>
to deploy MessageTransmitterV2, TokenMinterV2, and TokenMessengerV2.
V2 Proxies
The proxies are deployed via CREATE2 through Create2Factory. The scripts assumes the remote chains are EVM compatible and predicts that remote contracts will be deployed at the same addresses. Follow the below steps to deploy the contracts:
Replace the environment variables in your env file with the following:
Note:
REMOTE_DOMAINS,REMOTE_USDC_CONTRACT_ADDRESSES, andREMOTE_TOKEN_MESSENGER_V2_ADDRESSESmust all correspond 1:1:1 in order.USDC_CONTRACT_ADDRESSTOKEN_CONTROLLER_ADDRESSREMOTE_DOMAINSREMOTE_USDC_CONTRACT_ADDRESSESREMOTE_TOKEN_MESSENGER_V2_ADDRESSESCREATE2_FACTORY_CONTRACT_ADDRESSMESSAGE_TRANSMITTER_V2_OWNER_ADDRESSMESSAGE_TRANSMITTER_V2_PAUSER_ADDRESSMESSAGE_TRANSMITTER_V2_RESCUER_ADDRESSMESSAGE_TRANSMITTER_V2_ATTESTER_MANAGER_ADDRESSMESSAGE_TRANSMITTER_V2_ATTESTER_1_ADDRESSMESSAGE_TRANSMITTER_V2_ATTESTER_2_ADDRESSMESSAGE_TRANSMITTER_V2_PROXY_ADMIN_ADDRESSTOKEN_MINTER_V2_PAUSER_ADDRESSTOKEN_MINTER_V2_RESCUER_ADDRESSTOKEN_MESSENGER_V2_OWNER_ADDRESSTOKEN_MESSENGER_V2_RESCUER_ADDRESSTOKEN_MESSENGER_V2_FEE_RECIPIENT_ADDRESSTOKEN_MESSENGER_V2_DENYLISTER_ADDRESSTOKEN_MESSENGER_V2_PROXY_ADMIN_ADDRESSTOKEN_MESSENGER_V2_MIN_FEE_CONTROLLER_ADDRESSTOKEN_MESSENGER_V2_MIN_FEEDOMAINBURN_LIMIT_PER_MESSAGETOKEN_CONTROLLER_KEYTOKEN_MINTER_V2_OWNER_KEY
Run
make simulate-deploy-proxies-v2 RPC_URL=<RPC_URL> SENDER=<SENDER> CREATE2_FACTORY_OWNER_KEY=<CREATE2_FACTORY_OWNER_KEY>to perform a dry run.Run
make deploy-proxies-v2 RPC_URL=<RPC_URL> SENDER=<SENDER> CREATE2_FACTORY_OWNER_KEY=<CREATE2_FACTORY_OWNER_KEY>to deploy the contractsONLY perform steps 5-7 for additional remote resources NOT already configured above.
Replace the environment variables in your env file with the following. We'll just add one remote resource (e.g. adding remote token messenger and remote usdc contract addresses) at a time, so just pick any and then repeat these steps. This will need to be repeated for each remote chain:
TOKEN_MESSENGER_V2_OWNER_KEYTOKEN_CONTROLLER_KEYTOKEN_MESSENGER_V2_CONTRACT_ADDRESSTOKEN_MINTER_V2_CONTRACT_ADDRESSUSDC_CONTRACT_ADDRESSREMOTE_USDC_CONTRACT_ADDRESSREMOTE_DOMAIN
Run
make simulate-setup-remote-resources-v2 RPC_URL=<RPC_URL> SENDER=<SENDER>to perform a dry run of adding remote resources.Run
make setup-remote-resources-v2 RPC_URL=<RPC_URL> SENDER=<SENDER>to setup the remote resources.
[Remaining steps are only for mainnet]
Replace the environment variables in your env file with:
MESSAGE_TRANSMITTER_V2_CONTRACT_ADDRESSTOKEN_MESSENGER_V2_CONTRACT_ADDRESSTOKEN_MINTER_V2_CONTRACT_ADDRESSMESSAGE_TRANSMITTER_V2_OWNER_KEYTOKEN_MESSENGER_V2_OWNER_KEYTOKEN_MINTER_V2_OWNER_KEYMESSAGE_TRANSMITTER_V2_NEW_OWNER_ADDRESSTOKEN_MESSENGER_V2_NEW_OWNER_ADDRESSTOKEN_MINTER_V2_NEW_OWNER_ADDRESSNEW_TOKEN_CONTROLLER_ADDRESS
Run
make simulate-rotate-keys-v2 RPC_URL=<RPC_URL> SENDER=<SENDER>to perform a dry run of rotating the keys.Run
make rotate-keys-v2 RPC_URL=<RPC_URL> SENDER=<SENDER>to rotate keys.
AddressUtilsExternal
Use Create2Factory to deploy the helper library to a deterministic address for easy integration.
Set the following env variables:
CREATE2_FACTORY_CONTRACT_ADDRESS
Run
make simulate-deploy-address-utils-external RPC_URL=<RPC_URL> SENDER=<SENDER> CREATE2_FACTORY_OWNER_KEY=<CREATE2_FACTORY_OWNER_KEY>to perform a dry run.Run
make deploy-address-utils-external RPC_URL=<RPC_URL> SENDER=<SENDER> CREATE2_FACTORY_OWNER_KEY=<CREATE2_FACTORY_OWNER_KEY>to deploy.
Predicting Create2 Deployment Addresses
The PredictCreate2Deployments.s.sol script can help compute expected deployment addresses for various contracts. You can run it like so:
Predicting MessageTransmitterV2 Implementation:
forge script scripts/v2/PredictCreate2Deployments.s.sol --sig "messageTransmitterV2Impl(address,uint32,uint32)" <create2FactoryAddress> <domain> <message version>Predicting TokenMessengerV2 Implementation:
forge script scripts/v2/PredictCreate2Deployments.s.sol --sig "tokenMessengerV2Impl(address,uint32)" <create2FactoryAddress> <messageBodyVersion>Predicting MessageTransmitterV2 Proxy:
forge script scripts/v2/PredictCreate2Deployments.s.sol --sig "messageTransmitterV2Proxy(address)" <create2FactoryAddress>Predicting TokenMessengerV2 Proxy:
forge script scripts/v2/PredictCreate2Deployments.s.sol --sig "tokenMessengerV2Proxy(address)" <create2FactoryAddress>Predicting TokenMinter:
forge script scripts/v2/PredictCreate2Deployments.s.sol --sig "tokenMinterV2(address)" <create2FactoryAddress>Predicting AddressUtilsExternal:
forge script scripts/v2/PredictCreate2Deployments.s.sol --sig "addressUtilsExternal(address)
License
For license information, see LICENSE and additional notices stored in NOTICES.
探索相关项目
加载中…