Local interchain deployment
In order to test a program locally, we use the local interchaintest suite to spin up chains.
1. Installing local-interchain
Before you can run the tests, you need to install local interchain. This is a one-time operation. NOTE: your binary will link back to the location where you install, if you remove the folder, you need to run make install
again.
git clone https://github.com/strangelove-ventures/interchaintest && cd interchaintest/local-interchain && make install
2. Running chains locally
Run one of the set-up configs we have in the e2e/chains
folder. For example, to run the neutron.json
config, run the following command from the e2e
folder:
cd e2e
local-ic start neutron --api-port 42069
This will start a local environment with a Gaia chain and a Neutron (using ICS) chain. The --api-port
will expose the API on port 42069, we are using this port in our local-ic-utils crate so let's use the same to reuse some of the utils there.
This process also writes the API endpoints of each chain to e2e/chains/configs/logs.json
. The setup script will use this file to determine which RPCs to use.
3. Optimize Contracts
From the root directory, use CosmWasm optimizer to optimize contracts. The output will be written to an artifacts
folder in the project root.
just optimize
Or
./devtools/optimize.sh
4. Generate manager config
Before deploying a program, some initial setup is required. The below script will deploy all required contracts to the chain, instantiate a registry contract, and set up polytone bridges.
cargo run -p generate_local_ic_config
The script will write all related code IDs, addresses, and RPC endpoints at deployment/configs/local/config.toml
, to be used by the program manager.
The default chain config that is used in this script is the neutron.json
config, if in step 2 you started local-ic with a different chain config, please use the same config here.
Example with neutron_juno.json
chain config:
cargo run -p generate_local_ic_config -- -c neutron_juno.json
5. Build program config
Before deploying a program, we need to build the program config.
This script will take the program you build using the Program Builder in my_program.rs
and output the program config in a JSON format in output_program/program.json
.
cargo run -p build_program
- This script is a helper to generate a program config in JSON format using our program builder in rust, a program config in JSON format can be generated in any other method.
6. Deploy a program
To deploy a program, you can use the deploy_program
script.
To run this script you need a manager config and a program config:
- Manager config is generated by
generate_local_ic_config
script for local environment atdeployment/configs/local/config.toml
- Program config can be generated using the
build_program
script or any other method atdeployment/output_program/program.json
cargo run -p deploy_program
By default it will look for the program config generated by the build_program
script in deployment/output_program/program.json
. You can pass a different path to the config with:
cargo run -p deploy_program -- -p path/to/program_config.json
7. Program Instantiated
After a program was instantiated successfully, you will see a success message in the console and the program config file path that was generated.
The name of the file will end with the program id, for example: program_1.json
.
You will be able to find this file under the deployment/results
folder.