Skip to content

Commit

Permalink
Tilt devnet deployment for ibc generic messaging
Browse files Browse the repository at this point in the history
  • Loading branch information
nik-suri committed May 17, 2023
1 parent ce0fe7f commit e606aee
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 28 deletions.
2 changes: 1 addition & 1 deletion Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,7 @@ if ibc_relayer:
port_forwards = [
port_forward(7597, name = "HTTPDEBUG [:7597]", host = webHost),
],
resource_deps = ["wormchain", "terra2-terrad"],
resource_deps = ["wormchain-deploy", "terra2-terrad"],
labels = ["ibc-relayer"],
trigger_mode = trigger_mode,
)
Expand Down
41 changes: 20 additions & 21 deletions cosmwasm/deployment/terra2/tools/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,13 @@ import { zeroPad } from "ethers/lib/utils.js";
deterministic.
*/
const artifacts = [
"cw_wormhole.wasm",
"wormhole_ibc.wasm",
"cw_token_bridge.wasm",
"cw20_wrapped_2.wasm",
"cw20_base.wasm",
"mock_bridge_integration_2.wasm",
"shutdown_core_bridge_cosmwasm.wasm",
"shutdown_token_bridge_cosmwasm.wasm",
"global_accountant.wasm",
"wormchain_ibc_receiver.wasm",
"wormhole_ibc.wasm",
];

/* Check that the artifact folder contains all the wasm files we expect and nothing else */
Expand All @@ -50,18 +47,6 @@ if (missing_artifacts.length) {
process.exit(1);
}

const unexpected_artifacts = actual_artifacts.filter(
(a) => !artifacts.includes(a)
);
if (unexpected_artifacts.length) {
console.log(
"Error during terra deployment. The following files are not expected to be in the artifacts folder:"
);
unexpected_artifacts.forEach((file) => console.log(` - ${file}`));
console.log("Hint: you might need to modify tools/deploy.js");
process.exit(1);
}

/* Set up terra client & wallet */

const terra = new LCDClient({
Expand Down Expand Up @@ -118,6 +103,8 @@ const govChain = 1;
const govAddress =
"0000000000000000000000000000000000000000000000000000000000000004";

const wormchainIbcReceiverAddress = "0000000000000000000000000000000000000000000000000000000000000000";

async function instantiate(contract, inst_msg, label) {
var address;
await wallet
Expand Down Expand Up @@ -156,8 +143,8 @@ if (!init_guardians || init_guardians.length === 0) {
throw "failed to get initial guardians from .env file.";
}

addresses["cw_wormhole.wasm"] = await instantiate(
"cw_wormhole.wasm",
addresses["wormhole_ibc.wasm"] = await instantiate(
"wormhole_ibc.wasm",
{
gov_chain: govChain,
gov_address: Buffer.from(govAddress, "hex").toString("base64"),
Expand All @@ -173,15 +160,15 @@ addresses["cw_wormhole.wasm"] = await instantiate(
chain_id: 18,
fee_denom: "uluna",
},
"wormhole"
"wormholeIbc"
);

addresses["cw_token_bridge.wasm"] = await instantiate(
"cw_token_bridge.wasm",
{
gov_chain: govChain,
gov_address: Buffer.from(govAddress, "hex").toString("base64"),
wormhole_contract: addresses["cw_wormhole.wasm"],
wormhole_contract: addresses["wormhole_ibc.wasm"],
wrapped_asset_code_id: codeIds["cw20_wrapped_2.wasm"],
chain_id: 18,
native_denom: "uluna",
Expand Down Expand Up @@ -253,7 +240,19 @@ for (const [contract, registrations] of Object.entries(
memo: "",
})
.then((tx) => terra.tx.broadcast(tx))
.then((rs) => console.log(rs));
.then((rs) => console.log(rs))
.catch((error) => {
if (error.response) {
// Request made and server responded
console.log(error.response.data, error.response.status, error.response.headers);
} else if (error.request) {
// The request was made but no response was received
console.log(error.request);
} else {
// Something happened in setting up the request that triggered an Error
console.log('Error', error.message);
}
});
}
}

Expand Down
7 changes: 7 additions & 0 deletions devnet/ibc-relayer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ spec:
- terra-wormchain
- --debug-addr
- localhost:7597
- --src-port
- wasm.terra14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9ssrc8au
- --dst-port
- wasm.wormhole1nc5tatafv6eyq7llkr2gv50ff9e22mnf70qgjlv737ktmt4eswrq0kdhcj
- --version
- ibc-wormhole-v1
- --override
ports:
- containerPort: 7597
name: rest
Expand Down
17 changes: 15 additions & 2 deletions wormchain/contracts/tools/deploy_wormchain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
VAA,
} from "@certusone/wormhole-sdk";
import { toBinary } from "@cosmjs/cosmwasm-stargate";
import { fromBase64, toUtf8 } from "@cosmjs/encoding";
import { fromBase64, toUtf8, fromBech32 } from "@cosmjs/encoding";
import {
getWallet,
getWormchainSigningClient,
Expand Down Expand Up @@ -40,7 +40,10 @@ const readFileAsync = util.promisify(fs.readFile);
deterministic.
*/
type ContractName = string;
const artifacts: ContractName[] = ["global_accountant.wasm"];
const artifacts: ContractName[] = [
"global_accountant.wasm",
"wormchain_ibc_receiver.wasm"
];

const ARTIFACTS_PATH = "../artifacts/";
/* Check that the artifact folder contains all the wasm files we expect and nothing else */
Expand Down Expand Up @@ -205,6 +208,8 @@ async function main() {
...ZERO_FEE,
gas: "10000000",
});
console.log("contract instantiation msg: ", msg);
console.log("contract instantiation result: ", result);
const addr = JSON.parse(result.rawLog)[0]
.events.find(({ type }) => type === "instantiate")
.attributes.find(({ key }) => key === "_contract_address").value;
Expand Down Expand Up @@ -263,6 +268,14 @@ async function main() {
gas: "10000000",
});
console.log(`sent accounting chain registrations, tx: `, res.transactionHash);

const wormchainIbcReceiverInstantiateMsg = {};
addresses["wormchain_ibc_receiver.wasm"] = await instantiate(
codeIds["wormchain_ibc_receiver.wasm"],
wormchainIbcReceiverInstantiateMsg,
"wormchainIbcReceiver"
);
console.log("instantiated wormchain ibc receiver contract: ", addresses["wormchain_ibc_receiver.wasm"]);
}

try {
Expand Down
8 changes: 4 additions & 4 deletions wormchain/ts-sdk/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e606aee

Please sign in to comment.