From 81744d0a81f9c0adce3617256e9a37a1e31bad5e Mon Sep 17 00:00:00 2001 From: Murad Karammaev Date: Mon, 9 Oct 2023 10:16:38 +0300 Subject: [PATCH] feat: prepare for release v0.7.0 - bump workspace_optimizer to v0.14.0 - bump Rust dependencies and organize them into workspace - set release profile at workspace Cargo.toml - bump Rust toolchain to v1.71.0 - bump protobuf codegen to v3.3.0 - prepare shell scripts for sdk v47: use broadcast mode sync --- Cargo.toml | 23 ++++++ README.md | 2 +- build_release.sh | 2 +- contracts/ibc_transfer/Cargo.toml | 29 +++----- .../neutron_interchain_queries/Cargo.toml | 37 +++------- .../src/contract.rs | 2 +- .../src/testing/tests.rs | 2 +- contracts/neutron_interchain_txs/Cargo.toml | 39 +++-------- .../neutron_interchain_txs/src/contract.rs | 2 +- packages/neutron-sdk/Cargo.toml | 43 ++++-------- packages/neutron-sdk/src/errors/error.rs | 2 +- .../src/interchain_queries/v045/testing.rs | 2 +- .../src/interchain_queries/v045/types.rs | 2 +- .../neutron-sdk/src/interchain_txs/helpers.rs | 15 ++-- rust-toolchain.toml | 2 +- scripts/test_ibc_transfer.sh | 58 +++++++++------ .../test_wasm_query.sh | 47 ++++++++----- scripts/test_interchain_txs.sh | 68 ++++++++++++------ scripts/test_kv_query.sh | 47 ++++++++----- scripts/test_tx_query.sh | 70 +++++++++++++------ thirdparty/protoc-image/Dockerfile | 2 +- 21 files changed, 275 insertions(+), 221 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 956f2a3f..2ac57ace 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,6 +2,29 @@ members = ["contracts/*", "packages/*"] [profile.release] +opt-level = 3 +debug = false rpath = false lto = true +debug-assertions = false +codegen-units = 1 +panic = 'abort' +incremental = false overflow-checks = true + +[workspace.dependencies] +cosmwasm-std = "1.4.0" +cw2 = "1.1.1" +schemars = "0.8.15" +serde = { version = "1.0.188", default-features = false } +serde-json-wasm = "1.0.0" +cw-storage-plus = "1.1.0" +cosmwasm-schema = { version = "1.4.0", default-features = false } +base64 = "0.21.4" +prost = "0.12.1" +prost-types = "0.12.1" +cosmos-sdk-proto = { version = "0.20.0", default-features = false } +bech32 = "0.9.1" +thiserror = "1.0.49" +protobuf = { version = "3.3.0" } +hex = "0.4.3" diff --git a/README.md b/README.md index 034d135b..2cff54ec 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ We provide sample contracts that either implement or consume these specification ### Environment Setup -- Rust v1.68.2+ +- Rust v1.71.0+ - `wasm32-unknown-unknown` target - Docker diff --git a/build_release.sh b/build_release.sh index 9ccfd838..1cf6a177 100755 --- a/build_release.sh +++ b/build_release.sh @@ -1,4 +1,4 @@ docker run --rm -v "$(pwd)":/code \ --mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \ --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ - cosmwasm/workspace-optimizer:0.12.13 + cosmwasm/workspace-optimizer:0.14.0 diff --git a/contracts/ibc_transfer/Cargo.toml b/contracts/ibc_transfer/Cargo.toml index 260b8f22..caae63fe 100644 --- a/contracts/ibc_transfer/Cargo.toml +++ b/contracts/ibc_transfer/Cargo.toml @@ -10,22 +10,9 @@ exclude = [ "hash.txt", ] -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [lib] crate-type = ["cdylib", "rlib"] -[profile.release] -opt-level = 3 -debug = false -rpath = false -lto = true -debug-assertions = false -codegen-units = 1 -panic = 'abort' -incremental = false -overflow-checks = true - [features] # for quicker tests, cargo test --lib # for more explicit tests, cargo test --features=backtraces @@ -33,13 +20,13 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cosmwasm-std = { version = "1.3.0", features = ["staking", "stargate"] } -cw2 = "1.1.0" -schemars = "0.8.10" -serde = { version = "1.0.149", default-features = false, features = ["derive"] } -cw-storage-plus = { version = "1.1.0", features = ["iterator"]} -neutron-sdk = { path = "../../packages/neutron-sdk", default-features = false, version = "0.6.1"} -protobuf = { version = "3.3.0", features = ["with-bytes"] } +cosmwasm-std = { workspace = true, features = ["staking", "stargate"] } +cw2 = { workspace = true } +schemars = { workspace = true } +serde = { workspace = true } +serde-json-wasm = { workspace = true } +cw-storage-plus = { workspace = true, features = ["iterator"]} +neutron-sdk = { path = "../../packages/neutron-sdk", default-features = false } [dev-dependencies] -cosmwasm-schema = { version = "1.3.0", default-features = false } \ No newline at end of file +cosmwasm-schema = { workspace = true } diff --git a/contracts/neutron_interchain_queries/Cargo.toml b/contracts/neutron_interchain_queries/Cargo.toml index a7ffc747..bf51c5bc 100644 --- a/contracts/neutron_interchain_queries/Cargo.toml +++ b/contracts/neutron_interchain_queries/Cargo.toml @@ -10,41 +10,24 @@ exclude = [ "hash.txt", ] -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [lib] crate-type = ["cdylib", "rlib"] -[profile.release] -opt-level = 3 -debug = false -rpath = false -lto = true -debug-assertions = false -codegen-units = 1 -panic = 'abort' -incremental = false -overflow-checks = true - [features] # for more explicit tests, cargo test --features=backtraces backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cosmwasm-std = { version = "1.3.0", features = ["staking"] } -cw2 = "1.1.0" -schemars = "0.8.10" -serde = { version = "1.0.149", default-features = false, features = ["derive"] } -neutron-sdk = { path = "../../packages/neutron-sdk", default-features = false, version = "0.6.1"} -base64 = "0.21.2" -cosmos-sdk-proto = { version = "0.16.0", default-features = false } -cw-storage-plus = { version = "1.1.0", features = ["iterator"]} -prost = "0.11" -serde-json-wasm = "0.5.1" +cosmwasm-std = { workspace = true } +cw2 = { workspace = true } +schemars = { workspace = true } +serde = { workspace = true } +neutron-sdk = { path = "../../packages/neutron-sdk", default-features = false } +cosmos-sdk-proto = { workspace = true } +cw-storage-plus = { workspace = true } +serde-json-wasm = { workspace = true } [dev-dependencies] -cosmwasm-schema = { version = "1.3.0", default-features = false } - - - +base64 = { workspace = true } +cosmwasm-schema = { workspace = true } diff --git a/contracts/neutron_interchain_queries/src/contract.rs b/contracts/neutron_interchain_queries/src/contract.rs index 29310739..3216ece3 100644 --- a/contracts/neutron_interchain_queries/src/contract.rs +++ b/contracts/neutron_interchain_queries/src/contract.rs @@ -1,11 +1,11 @@ use cosmos_sdk_proto::cosmos::bank::v1beta1::MsgSend; use cosmos_sdk_proto::cosmos::tx::v1beta1::{TxBody, TxRaw}; +use cosmos_sdk_proto::traits::Message; use cosmwasm_std::{ entry_point, to_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdError, StdResult, Uint128, }; use cw2::set_contract_version; -use prost::Message as ProstMessage; use crate::msg::{ Cw20BalanceResponse, ExecuteMsg, GetRecipientTxsResponse, InstantiateMsg, MigrateMsg, QueryMsg, diff --git a/contracts/neutron_interchain_queries/src/testing/tests.rs b/contracts/neutron_interchain_queries/src/testing/tests.rs index 4676271e..fdd34cf2 100644 --- a/contracts/neutron_interchain_queries/src/testing/tests.rs +++ b/contracts/neutron_interchain_queries/src/testing/tests.rs @@ -12,6 +12,7 @@ use cosmos_sdk_proto::cosmos::gov::v1beta1::{ Proposal as CosmosProposal, TallyResult as CosmosTallyResult, }; use cosmos_sdk_proto::cosmos::staking::v1beta1::Validator as CosmosValidator; +use cosmos_sdk_proto::traits::Message; use cosmos_sdk_proto::Any; use cosmwasm_std::testing::{mock_env, mock_info, MockApi, MockStorage}; use cosmwasm_std::{ @@ -36,7 +37,6 @@ use neutron_sdk::interchain_queries::v045::types::{ Balances, FeePool, GovernmentProposal, Proposal, StakingValidator, TallyResult, TotalSupply, Validator, RECIPIENT_FIELD, }; -use prost::Message as ProstMessage; use neutron_sdk::interchain_queries::v045::queries::{ BalanceResponse, DelegatorDelegationsResponse, FeePoolResponse, ProposalResponse, diff --git a/contracts/neutron_interchain_txs/Cargo.toml b/contracts/neutron_interchain_txs/Cargo.toml index 25ee2f84..afa78ea6 100644 --- a/contracts/neutron_interchain_txs/Cargo.toml +++ b/contracts/neutron_interchain_txs/Cargo.toml @@ -10,43 +10,24 @@ exclude = [ "hash.txt", ] -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [lib] crate-type = ["cdylib", "rlib"] -[profile.release] -opt-level = 3 -debug = false -rpath = false -lto = true -debug-assertions = false -codegen-units = 1 -panic = 'abort' -incremental = false -overflow-checks = true - [features] # for more explicit tests, cargo test --features=backtraces backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cosmwasm-std = { version = "1.3.0", features = ["staking"] } -cw2 = "1.1.0" -schemars = "0.8.10" -serde = { version = "1.0.149", default-features = false, features = ["derive"] } -serde-json-wasm = { version = "0.5.1" } -cw-storage-plus = { version = "1.1.0", features = ["iterator"]} -cosmos-sdk-proto = { version = "0.16.0", default-features = false } -neutron-sdk = { path = "../../packages/neutron-sdk", default-features = false, version = "0.6.1"} -base64 = "0.21.2" -protobuf = { version = "3.3.0", features = ["with-bytes"] } -prost = "0.11" -prost-types = "0.11" -bech32 = "0.9.0" -thiserror = { version = "1.0" } - +cosmwasm-std = { workspace = true } +cw2 = { workspace = true } +schemars = { workspace = true } +serde = { workspace = true } +serde-json-wasm = { workspace = true } +cw-storage-plus = { workspace = true } +cosmos-sdk-proto = { workspace = true } +neutron-sdk = { path = "../../packages/neutron-sdk", default-features = false } +prost-types = { workspace = true } [dev-dependencies] -cosmwasm-schema = { version = "1.3.0", default-features = false } +cosmwasm-schema = { workspace = true } diff --git a/contracts/neutron_interchain_txs/src/contract.rs b/contracts/neutron_interchain_txs/src/contract.rs index f9bbd2f3..71df7894 100644 --- a/contracts/neutron_interchain_txs/src/contract.rs +++ b/contracts/neutron_interchain_txs/src/contract.rs @@ -2,6 +2,7 @@ use cosmos_sdk_proto::cosmos::base::v1beta1::Coin; use cosmos_sdk_proto::cosmos::staking::v1beta1::{ MsgDelegate, MsgDelegateResponse, MsgUndelegate, MsgUndelegateResponse, }; +use cosmos_sdk_proto::traits::Message; #[cfg(not(feature = "library"))] use cosmwasm_std::entry_point; use cosmwasm_std::{ @@ -9,7 +10,6 @@ use cosmwasm_std::{ StdError, StdResult, SubMsg, }; use cw2::set_contract_version; -use prost::Message; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; diff --git a/packages/neutron-sdk/Cargo.toml b/packages/neutron-sdk/Cargo.toml index f664eb78..0cfe3b75 100644 --- a/packages/neutron-sdk/Cargo.toml +++ b/packages/neutron-sdk/Cargo.toml @@ -1,42 +1,25 @@ [package] name = "neutron-sdk" description = "Neutron CosmWasm SDK for interacting with Neutron blockchain" -version = "0.6.1" +version = "0.7.0" edition = "2021" license = "Apache-2.0" repository = "https://github.com/neutron-org/neutron-sdk" homepage = "https://neutron.org" readme = "README.md" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[profile.release] -opt-level = 3 -debug = false -rpath = false -lto = true -debug-assertions = false -codegen-units = 1 -panic = 'abort' -incremental = false -overflow-checks = true - [dependencies] -cosmwasm-std = { version = "1.3.0", features = ["staking"] } -cosmos-sdk-proto = { version = "0.16.0", default-features = false } -prost = "0.11" -serde = { version = "1.0.149", default-features = false, features = ["derive"] } -schemars = "0.8.10" -serde-json-wasm = "0.5.1" -cw-storage-plus = { version = "1.1.0", features = ["iterator"]} -base64 = "0.21.2" -bech32 = "0.9.1" -thiserror = { version = "1.0" } -serde_json = { version = "1.0.87" } -protobuf = { version = "3.3.0", features = ["with-bytes"] } -cosmwasm-schema = "1.3.0" +cosmwasm-std = { workspace = true } +cosmos-sdk-proto = { workspace = true } +serde = { workspace = true } +schemars = { workspace = true } +serde-json-wasm = { workspace = true } +bech32 = { workspace = true } +thiserror = { workspace = true } +protobuf = { workspace = true } +cosmwasm-schema = { workspace = true } [dev-dependencies] -cosmwasm-schema = { version = "1.3.0", default-features = false } -prost-types = "0.11.1" -hex = "0.4.3" +base64 = { workspace = true } +prost-types = { workspace = true } +hex = { workspace = true } diff --git a/packages/neutron-sdk/src/errors/error.rs b/packages/neutron-sdk/src/errors/error.rs index 9ffa5ce1..bb05d320 100644 --- a/packages/neutron-sdk/src/errors/error.rs +++ b/packages/neutron-sdk/src/errors/error.rs @@ -16,7 +16,7 @@ pub enum NeutronError { Bech32(#[from] bech32::Error), #[error("Prost protobuf error")] - ProstProtobuf(#[from] prost::DecodeError), + ProstProtobuf(#[from] cosmos_sdk_proto::prost::DecodeError), #[error("Serde JSON (Wasm) error")] SerdeJSONWasm(String), diff --git a/packages/neutron-sdk/src/interchain_queries/v045/testing.rs b/packages/neutron-sdk/src/interchain_queries/v045/testing.rs index c1283daf..bfcacc36 100644 --- a/packages/neutron-sdk/src/interchain_queries/v045/testing.rs +++ b/packages/neutron-sdk/src/interchain_queries/v045/testing.rs @@ -20,11 +20,11 @@ use cosmos_sdk_proto::cosmos::gov::v1beta1::{ use cosmos_sdk_proto::cosmos::staking::v1beta1::{ Commission, CommissionRates, Delegation, Description, Validator, }; +use cosmos_sdk_proto::traits::Message; use cosmwasm_std::{ to_binary, Addr, Binary, Coin as StdCoin, Decimal, Delegation as StdDelegation, Uint128, }; use hex; -use prost::Message as ProstMessage; use std::ops::Mul; use std::str::FromStr; diff --git a/packages/neutron-sdk/src/interchain_queries/v045/types.rs b/packages/neutron-sdk/src/interchain_queries/v045/types.rs index b2df2aeb..072565d0 100644 --- a/packages/neutron-sdk/src/interchain_queries/v045/types.rs +++ b/packages/neutron-sdk/src/interchain_queries/v045/types.rs @@ -9,8 +9,8 @@ use cosmos_sdk_proto::cosmos::{ gov::v1beta1::Proposal as CosmosProposal, staking::v1beta1::{Delegation, Validator as CosmosValidator}, }; +use cosmos_sdk_proto::traits::Message; use cosmwasm_std::{from_binary, Addr, Coin, Decimal, StdError, Uint128}; -use prost::Message as ProstMessage; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use std::{ops::Div, str::FromStr}; diff --git a/packages/neutron-sdk/src/interchain_txs/helpers.rs b/packages/neutron-sdk/src/interchain_txs/helpers.rs index 98220040..b222d5e5 100644 --- a/packages/neutron-sdk/src/interchain_txs/helpers.rs +++ b/packages/neutron-sdk/src/interchain_txs/helpers.rs @@ -1,21 +1,28 @@ -use cosmos_sdk_proto::cosmos::base::abci::v1beta1::{MsgData, TxMsgData}; +use cosmos_sdk_proto::{ + cosmos::base::abci::v1beta1::{MsgData, TxMsgData}, + traits::Message, +}; use cosmwasm_std::{Binary, StdError, StdResult}; -use prost::{DecodeError, Message}; /// Decodes acknowledgement into `Vec` structure pub fn decode_acknowledgement_response(data: Binary) -> StdResult> { - let msg_data: Result = TxMsgData::decode(data.as_slice()); + let msg_data: Result = TxMsgData::decode(data.as_slice()); match msg_data { Err(e) => Err(StdError::generic_err(format!( "Can't decode response: {}", e ))), + // TODO: field `.data` is deprecated. We should stop using it when we finally upgrade + // to Cosmos SDK v0.47+. + // We still use it here since current Neutron uses Cosmos SDK v0.45 which relies + // on this deprecated field. + #[allow(deprecated)] Ok(msg) => Ok(msg.data), } } /// Decodes protobuf any item into T structure -pub fn decode_message_response(item: &Vec) -> StdResult { +pub fn decode_message_response(item: &Vec) -> StdResult { let res = T::decode(item.as_slice()); match res { Err(e) => Err(StdError::generic_err(format!("Can't decode item: {}", e))), diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 864d3c41..aa464261 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel = "1.68.2" +channel = "1.71.0" diff --git a/scripts/test_ibc_transfer.sh b/scripts/test_ibc_transfer.sh index d065e029..3be2ec51 100755 --- a/scripts/test_ibc_transfer.sh +++ b/scripts/test_ibc_transfer.sh @@ -10,31 +10,43 @@ NEUTRON_DIR="${NEUTRON_DIR:-../../neutron}" HOME="$NEUTRON_DIR/data/test-1/" KEY="demowallet1" ADMIN="neutron1m9l358xunhhwds0568za49mzhvuxx9ux8xafx2" -BIN="neutrond" NODE="tcp://127.0.0.1:26657" -GAIA_BIN="gaiad" GAIA_NODE="tcp://127.0.0.1:16657" -code_id="$("$BIN" tx wasm store "$CONTRACT_PATH" \ - --from "$KEY" -y --chain-id "$CHAIN_ID" \ - --gas 50000000 --gas-prices 0.0025untrn \ - --broadcast-mode=block --keyring-backend=test \ - --output json --home "$HOME" --node "$NODE" \ - | jq -r '.logs[0].events[] | select(.type == "store_code").attributes[] | select(.key == "code_id").value')" +wait_tx() { + local txhash + local attempts + txhash="$(jq -r '.txhash' /dev/null; do + ((attempts-=1)) || { + echo "tx $txhash still not included in block" 1>&2 + exit 1 + } + sleep 0.1 + done +} + +code_id="$(neutrond tx wasm store "$CONTRACT_PATH" \ + --from "$KEY" -y --chain-id "$CHAIN_ID" \ + --gas 50000000 --gas-prices 0.0025untrn \ + --broadcast-mode=sync --keyring-backend=test \ + --output json --home "$HOME" --node "$NODE" \ + | wait_tx | jq -r '.logs[0].events[] | select(.type == "store_code").attributes[] | select(.key == "code_id").value')" echo "Code ID: $code_id" -contract_address="$("$BIN" tx wasm instantiate "$code_id" '{}' \ - --from ${KEY} --admin ${ADMIN} -y --chain-id "$CHAIN_ID" \ - --output json --broadcast-mode=block --label "init" \ - --keyring-backend=test --gas-prices 0.0025untrn \ - --home "$HOME" --node "$NODE" \ - | jq -r '.logs[0].events[] | select(.type == "instantiate").attributes[] | select(.key == "_contract_address").value')" +contract_address="$(neutrond tx wasm instantiate "$code_id" '{}' \ + --from ${KEY} --admin ${ADMIN} -y --chain-id "$CHAIN_ID" \ + --output json --broadcast-mode=sync --label "init" \ + --keyring-backend=test --gas-prices 0.0025untrn \ + --home "$HOME" --node "$NODE" \ + | wait_tx | jq -r '.logs[0].events[] | select(.type == "instantiate").attributes[] | select(.key == "_contract_address").value')" echo "Contract address: $contract_address" -tx_result="$("$BIN" tx bank send demowallet1 "$contract_address" 20000untrn \ - -y --chain-id "$CHAIN_ID" --home "$HOME" --node "$NODE" \ - --keyring-backend=test --gas-prices 0.0025untrn --output json \ - --broadcast-mode=block)" +tx_result="$(neutrond tx bank send demowallet1 "$contract_address" 20000untrn \ + -y --chain-id "$CHAIN_ID" --home "$HOME" --node "$NODE" \ + --keyring-backend=test --gas-prices 0.0025untrn --output json \ + --broadcast-mode=sync | wait_tx)" code="$(echo "$tx_result" | jq '.code')" if [[ "$code" -ne 0 ]]; then echo "Failed to send money to contract: $(echo "$tx_result" | jq '.raw_log')" && exit 1 @@ -47,10 +59,10 @@ msg='{"send":{ "denom": "untrn", "channel": "channel-0" }}' -tx_result="$("$BIN" tx wasm execute "$contract_address" "$msg" \ - --from ${KEY} -y --chain-id ${CHAIN_ID} --output json \ - --broadcast-mode=block --gas-prices 0.0025untrn --gas 1000000 \ - --keyring-backend test --home "$HOME" --node "$NODE")" +tx_result="$(neutrond tx wasm execute "$contract_address" "$msg" \ + --from ${KEY} -y --chain-id ${CHAIN_ID} --output json \ + --broadcast-mode=sync --gas-prices 0.0025untrn --gas 1000000 \ + --keyring-backend test --home "$HOME" --node "$NODE" | wait_tx)" code="$(echo "$tx_result" | jq '.code')" if [[ "$code" -ne 0 ]]; then echo "Failed to execute contract: $(echo "$tx_result" | jq '.raw_log')" && exit 1 @@ -66,7 +78,7 @@ echo " done" echo echo "cosmos17dtl0mjt3t77kpuhg2edqzjpszulwhgzuj9ljs should have 3000untrn now:" -"$GAIA_BIN" query bank balances "cosmos17dtl0mjt3t77kpuhg2edqzjpszulwhgzuj9ljs" \ +gaiad query bank balances "cosmos17dtl0mjt3t77kpuhg2edqzjpszulwhgzuj9ljs" \ --node "$GAIA_NODE" --output json | jq '.balances' echo diff --git a/scripts/test_icq_wasm_juno_testnet/test_wasm_query.sh b/scripts/test_icq_wasm_juno_testnet/test_wasm_query.sh index 7c1a29a9..e16029d2 100755 --- a/scripts/test_icq_wasm_juno_testnet/test_wasm_query.sh +++ b/scripts/test_icq_wasm_juno_testnet/test_wasm_query.sh @@ -4,7 +4,6 @@ set -euo pipefail IFS=$'\n\t' -BIN="neutrond" CONTRACT_PATH="../../artifacts/neutron_interchain_queries.wasm" CHAIN_ID_1="test-1" NEUTRON_DIR="${NEUTRON_DIR:-../../../neutron}" @@ -14,25 +13,39 @@ ADMIN="neutron1m9l358xunhhwds0568za49mzhvuxx9ux8xafx2" NODE="tcp://127.0.0.1:26657" CONNECTION_ID="connection-0" -code_id="$("$BIN" tx wasm store "$CONTRACT_PATH" \ +wait_tx() { + local txhash + local attempts + txhash="$(jq -r '.txhash' /dev/null; do + ((attempts-=1)) || { + echo "tx $txhash still not included in block" 1>&2 + exit 1 + } + sleep 0.1 + done +} + +code_id="$(neutrond tx wasm store "$CONTRACT_PATH" \ --from "$ADDRESS_1" --gas 50000000 --chain-id "$CHAIN_ID_1" \ - --broadcast-mode=block --gas-prices 0.0025untrn -y \ + --broadcast-mode=sync --gas-prices 0.0025untrn -y \ --output json --keyring-backend=test --home "$HOME_1" \ --node "$NODE" \ - | jq -r '.logs[0].events[] | select(.type == "store_code").attributes[] | select(.key == "code_id").value')" + | wait_tx | jq -r '.logs[0].events[] | select(.type == "store_code").attributes[] | select(.key == "code_id").value')" echo "Code ID: $code_id" -contract_address="$("$BIN" tx wasm instantiate "$code_id" '{}' \ - --from "$ADDRESS_1" --admin "$ADMIN" -y --chain-id "$CHAIN_ID_1" \ - --output json --broadcast-mode=block --label "init" --node "$NODE" \ - --keyring-backend=test --gas-prices 0.0025untrn --home "$HOME_1" \ - | jq -r '.logs[0].events[] | select(.type == "instantiate").attributes[] | select(.key == "_contract_address").value')" +contract_address="$(neutrond tx wasm instantiate "$code_id" '{}' \ + --from "$ADDRESS_1" --admin "$ADMIN" -y --chain-id "$CHAIN_ID_1" \ + --output json --broadcast-mode=sync --label "init" --node "$NODE" \ + --keyring-backend=test --gas-prices 0.0025untrn --home "$HOME_1" \ + | wait_tx | jq -r '.logs[0].events[] | select(.type == "instantiate").attributes[] | select(.key == "_contract_address").value')" echo "Contract address: $contract_address" -tx_result="$("$BIN" tx bank send "$ADDRESS_1" "$contract_address" 10000000untrn \ - -y --chain-id "$CHAIN_ID_1" --output json --broadcast-mode=block \ - --gas-prices 0.0025untrn --gas 300000 --keyring-backend=test \ - --home "$HOME_1" --node "$NODE")" +tx_result="$(neutrond tx bank send "$ADDRESS_1" "$contract_address" 10000000untrn \ + -y --chain-id "$CHAIN_ID_1" --output json --broadcast-mode=sync \ + --gas-prices 0.0025untrn --gas 300000 --keyring-backend=test \ + --home "$HOME_1" --node "$NODE" | wait_tx)" code="$(echo "$tx_result" | jq '.code')" if [[ "$code" -ne 0 ]]; then echo "Failed to send money to contract: $(echo "$tx_result" | jq '.raw_log')" && exit 1 @@ -45,10 +58,10 @@ msg="$(printf '{"register_cw20_balance_query":{ "cw20_contract_address": "juno1jw04ukttvcqrxwy6xsufwrehwhxl8d68d6z7gex4gxwkgta4cwcs8yufe0", "account_address": "juno1kk5eceqhcd0u65fqlzcvv52e5rjcshz704kere" }}' "$CONNECTION_ID")" -tx_result="$("$BIN" tx wasm execute "$contract_address" "$msg" \ +tx_result="$(neutrond tx wasm execute "$contract_address" "$msg" \ --from "$ADDRESS_1" -y --chain-id "$CHAIN_ID_1" --output json \ - --broadcast-mode=block --gas-prices 0.0025untrn --gas 1000000 \ - --keyring-backend=test --home "$HOME_1" --node "$NODE")" + --broadcast-mode=sync --gas-prices 0.0025untrn --gas 1000000 \ + --keyring-backend=test --home "$HOME_1" --node "$NODE" | wait_tx)" code="$(echo "$tx_result" | jq '.code')" if [[ "$code" -ne 0 ]]; then echo "Failed to register ICQ: $(echo "$tx_result" | jq '.raw_log')" && exit 1 @@ -67,4 +80,4 @@ echo " done" echo echo "KV query cw20 balance response:" query="$(printf '{"cw20_balance": {"query_id": %s}}' "$query_id")" -"$BIN" query wasm contract-state smart "$contract_address" "$query" --node "$NODE" --output json | jq +neutrond query wasm contract-state smart "$contract_address" "$query" --node "$NODE" --output json | jq diff --git a/scripts/test_interchain_txs.sh b/scripts/test_interchain_txs.sh index f30e95bd..274d217e 100755 --- a/scripts/test_interchain_txs.sh +++ b/scripts/test_interchain_txs.sh @@ -4,8 +4,6 @@ set -euo pipefail IFS=$'\n\t' -BIN="neutrond" -GAIA_BIN="gaiad" CONTRACT_PATH="../artifacts/neutron_interchain_txs.wasm" CHAIN_ID_1="test-1" CHAIN_ID_2="test-2" @@ -19,27 +17,55 @@ VALIDATOR="cosmosvaloper18hl5c9xn5dze2g50uaw0l2mr02ew57zk0auktn" NEUTRON_NODE="tcp://127.0.0.1:26657" GAIA_NODE="tcp://127.0.0.1:16657" -code_id="$("$BIN" tx wasm store "$CONTRACT_PATH" \ +wait_tx() { + local txhash + local attempts + txhash="$(jq -r '.txhash' /dev/null; do + ((attempts-=1)) || { + echo "tx $txhash still not included in block" 1>&2 + exit 1 + } + sleep 0.1 + done +} + +wait_tx_gaia() { + local txhash + local attempts + txhash="$(jq -r '.txhash' /dev/null; do + ((attempts-=1)) || { + echo "tx $txhash still not included in block" 1>&2 + exit 1 + } + sleep 0.1 + done +} + +code_id="$(neutrond tx wasm store "$CONTRACT_PATH" \ --from "$ADDRESS_1" --gas 50000000 --chain-id "$CHAIN_ID_1" \ - --broadcast-mode=block --gas-prices 0.0025untrn -y \ + --broadcast-mode=sync --gas-prices 0.0025untrn -y \ --output json --keyring-backend=test --home "$HOME_1" \ --node "$NEUTRON_NODE" \ - | jq -r '.logs[0].events[] | select(.type == "store_code").attributes[] | select(.key == "code_id").value')" + | wait_tx | jq -r '.logs[0].events[] | select(.type == "store_code").attributes[] | select(.key == "code_id").value')" echo "Code ID: $code_id" -contract_address=$("$BIN" tx wasm instantiate "$code_id" '{}' \ +contract_address=$(neutrond tx wasm instantiate "$code_id" '{}' \ --from "$ADDRESS_1" --admin "$ADMIN" -y --chain-id "$CHAIN_ID_1" \ - --output json --broadcast-mode=block --label "init" \ + --output json --broadcast-mode=sync --label "init" \ --keyring-backend=test --gas-prices 0.0025untrn --gas auto \ --gas-adjustment 1.4 --home "$HOME_1" \ --node "$NEUTRON_NODE" 2>/dev/null \ - | jq -r '.logs[0].events[] | select(.type == "instantiate").attributes[] | select(.key == "_contract_address").value') + | wait_tx | jq -r '.logs[0].events[] | select(.type == "instantiate").attributes[] | select(.key == "_contract_address").value') echo "Contract address: $contract_address" -tx_result="$("$BIN" tx bank send demowallet1 "$contract_address" 100000untrn \ - --chain-id "$CHAIN_ID_1" --home "$HOME_1" --node "$NEUTRON_NODE" \ - --keyring-backend=test -y --gas-prices 0.0025untrn \ - --broadcast-mode=block --output json)" +tx_result="$(neutrond tx bank send demowallet1 "$contract_address" 100000untrn \ + --chain-id "$CHAIN_ID_1" --home "$HOME_1" --node "$NEUTRON_NODE" \ + --keyring-backend=test -y --gas-prices 0.0025untrn \ + --broadcast-mode=sync --output json | wait_tx)" code="$(echo "$tx_result" | jq '.code')" if [[ "$code" -ne 0 ]]; then echo "Failed to send money to contract: $(echo "$tx_result" | jq '.raw_log')" && exit 1 @@ -50,10 +76,10 @@ msg='{"register":{ "connection_id": "connection-0", "interchain_account_id": "test" }}' -tx_result="$("$BIN" tx wasm execute "$contract_address" "$msg" \ +tx_result="$(neutrond tx wasm execute "$contract_address" "$msg" \ --from "$ADDRESS_1" -y --chain-id "$CHAIN_ID_1" --output json \ - --broadcast-mode=block --gas-prices 0.0025untrn --gas 1000000 \ - --keyring-backend=test --home "$HOME_1" --node "$NEUTRON_NODE")" + --broadcast-mode=sync --gas-prices 0.0025untrn --gas 1000000 \ + --keyring-backend=test --home "$HOME_1" --node "$NEUTRON_NODE" | wait_tx)" code="$(echo "$tx_result" | jq '.code')" if [[ "$code" -ne 0 ]]; then echo "Failed to register interchain account: $(echo "$tx_result" | jq '.raw_log')" && exit 1 @@ -73,9 +99,9 @@ url="http://127.0.0.1:1317/wasm/contract/$contract_address/smart/$query_b64_urle ica_address=$(curl -s "$url" | jq -r '.result.smart' | base64 -d | jq -r '.[0]') echo "ICA address: $ica_address" -tx_result=$("$GAIA_BIN" tx bank send "$ADDRESS_2" "$ica_address" 50000uatom \ - --chain-id "$CHAIN_ID_2" --broadcast-mode=block --gas-prices 0.0025uatom \ - -y --output json --keyring-backend=test --home "$HOME_2" --node "$GAIA_NODE") +tx_result=$(gaiad tx bank send "$ADDRESS_2" "$ica_address" 50000uatom \ + --chain-id "$CHAIN_ID_2" --broadcast-mode=sync --gas-prices 0.0025uatom \ + -y --output json --keyring-backend=test --home "$HOME_2" --node "$GAIA_NODE" | wait_tx_gaia) code="$(echo "$tx_result" | jq '.code')" if [[ "$code" -ne 0 ]]; then echo "Failed to send money to ICA: $(echo "$tx_result" | jq '.raw_log')" && exit 1 @@ -88,10 +114,10 @@ msg="$(printf '{"delegate":{ "amount": "2000", "denom": "uatom" }}' "$VALIDATOR")" -tx_result="$("$BIN" tx wasm execute "$contract_address" "$msg" \ +tx_result="$(neutrond tx wasm execute "$contract_address" "$msg" \ --from "$ADDRESS_1" -y --chain-id "$CHAIN_ID_1" --output json \ - --broadcast-mode=block --gas-prices 0.0025untrn --gas 1000000 \ - --keyring-backend=test --home "$HOME_1" --node "$NEUTRON_NODE")" + --broadcast-mode=sync --gas-prices 0.0025untrn --gas 1000000 \ + --keyring-backend=test --home "$HOME_1" --node "$NEUTRON_NODE" | wait_tx)" code="$(echo "$tx_result" | jq '.code')" if [[ "$code" -ne 0 ]]; then echo "Failed to execute contract: $(echo "$tx_result" | jq '.raw_log')" && exit 1 diff --git a/scripts/test_kv_query.sh b/scripts/test_kv_query.sh index 114b4ed0..5b734fff 100755 --- a/scripts/test_kv_query.sh +++ b/scripts/test_kv_query.sh @@ -4,7 +4,6 @@ set -euo pipefail IFS=$'\n\t' -BIN="neutrond" CONTRACT_PATH="../artifacts/neutron_interchain_queries.wasm" CHAIN_ID_1="test-1" NEUTRON_DIR="${NEUTRON_DIR:-../../neutron}" @@ -13,25 +12,39 @@ ADDRESS_1="neutron1m9l358xunhhwds0568za49mzhvuxx9ux8xafx2" ADMIN="neutron1m9l358xunhhwds0568za49mzhvuxx9ux8xafx2" NODE="tcp://127.0.0.1:26657" -code_id="$("$BIN" tx wasm store "$CONTRACT_PATH" \ +wait_tx() { + local txhash + local attempts + txhash="$(jq -r '.txhash' /dev/null; do + ((attempts-=1)) || { + echo "tx $txhash still not included in block" 1>&2 + exit 1 + } + sleep 0.1 + done +} + +code_id="$(neutrond tx wasm store "$CONTRACT_PATH" \ --from "$ADDRESS_1" --gas 50000000 --chain-id "$CHAIN_ID_1" \ - --broadcast-mode=block --gas-prices 0.0025untrn -y \ + --broadcast-mode=sync --gas-prices 0.0025untrn -y \ --output json --keyring-backend=test --home "$HOME_1" \ --node "$NODE" \ - | jq -r '.logs[0].events[] | select(.type == "store_code").attributes[] | select(.key == "code_id").value')" + | wait_tx | jq -r '.logs[0].events[] | select(.type == "store_code").attributes[] | select(.key == "code_id").value')" echo "Code ID: $code_id" -contract_address="$("$BIN" tx wasm instantiate "$code_id" '{}' \ - --from "$ADDRESS_1" --admin "$ADMIN" -y --chain-id "$CHAIN_ID_1" \ - --output json --broadcast-mode=block --label "init" --node "$NODE" \ - --keyring-backend=test --gas-prices 0.0025untrn --home "$HOME_1" \ - | jq -r '.logs[0].events[] | select(.type == "instantiate").attributes[] | select(.key == "_contract_address").value')" +contract_address="$(neutrond tx wasm instantiate "$code_id" '{}' \ + --from "$ADDRESS_1" --admin "$ADMIN" -y --chain-id "$CHAIN_ID_1" \ + --output json --broadcast-mode=sync --label "init" --node "$NODE" \ + --keyring-backend=test --gas-prices 0.0025untrn --home "$HOME_1" \ + | wait_tx | jq -r '.logs[0].events[] | select(.type == "instantiate").attributes[] | select(.key == "_contract_address").value')" echo "Contract address: $contract_address" -tx_result="$("$BIN" tx bank send "$ADDRESS_1" "$contract_address" 10000000untrn \ - -y --chain-id "$CHAIN_ID_1" --output json --broadcast-mode=block \ - --gas-prices 0.0025untrn --gas 300000 --keyring-backend=test \ - --home "$HOME_1" --node "$NODE")" +tx_result="$(neutrond tx bank send "$ADDRESS_1" "$contract_address" 10000000untrn \ + -y --chain-id "$CHAIN_ID_1" --output json --broadcast-mode=sync \ + --gas-prices 0.0025untrn --gas 300000 --keyring-backend=test \ + --home "$HOME_1" --node "$NODE" | wait_tx)" code="$(echo "$tx_result" | jq '.code')" if [[ "$code" -ne 0 ]]; then echo "Failed to send money to contract: $(echo "$tx_result" | jq '.raw_log')" && exit 1 @@ -43,10 +56,10 @@ msg='{"register_bank_total_supply_query":{ "denoms": ["uatom"], "update_period": 5 }}' -tx_result="$("$BIN" tx wasm execute "$contract_address" "$msg" \ +tx_result="$(neutrond tx wasm execute "$contract_address" "$msg" \ --from "$ADDRESS_1" -y --chain-id "$CHAIN_ID_1" --output json \ - --broadcast-mode=block --gas-prices 0.0025untrn --gas 1000000 \ - --keyring-backend=test --home "$HOME_1" --node "$NODE")" + --broadcast-mode=sync --gas-prices 0.0025untrn --gas 1000000 \ + --keyring-backend=test --home "$HOME_1" --node "$NODE" | wait_tx)" code="$(echo "$tx_result" | jq '.code')" if [[ "$code" -ne 0 ]]; then echo "Failed to register ICQ: $(echo "$tx_result" | jq '.raw_log')" && exit 1 @@ -65,4 +78,4 @@ echo " done" echo echo "KV query total supply response:" query="$(printf '{"bank_total_supply": {"query_id": %s}}' "$query_id")" -"$BIN" query wasm contract-state smart "$contract_address" "$query" --node "$NODE" --output json | jq +neutrond query wasm contract-state smart "$contract_address" "$query" --node "$NODE" --output json | jq diff --git a/scripts/test_tx_query.sh b/scripts/test_tx_query.sh index f87c6500..0fcb519c 100755 --- a/scripts/test_tx_query.sh +++ b/scripts/test_tx_query.sh @@ -4,8 +4,6 @@ set -euo pipefail IFS=$'\n\t' -BIN="neutrond" -GAIA_BIN="gaiad" CONTRACT_PATH="../artifacts/neutron_interchain_queries.wasm" CHAIN_ID_1="test-1" CHAIN_ID_2="test-2" @@ -19,25 +17,53 @@ VALIDATOR="cosmos1qnk2n4nlkpw9xfqntladh74w6ujtulwn7j8za9" NEUTRON_NODE="tcp://127.0.0.1:26657" GAIA_NODE="tcp://127.0.0.1:16657" -code_id="$("$BIN" tx wasm store "$CONTRACT_PATH" \ +wait_tx() { + local txhash + local attempts + txhash="$(jq -r '.txhash' /dev/null; do + ((attempts-=1)) || { + echo "tx $txhash still not included in block" 1>&2 + exit 1 + } + sleep 0.1 + done +} + +wait_tx_gaia() { + local txhash + local attempts + txhash="$(jq -r '.txhash' /dev/null; do + ((attempts-=1)) || { + echo "tx $txhash still not included in block" 1>&2 + exit 1 + } + sleep 0.1 + done +} + +code_id="$(neutrond tx wasm store "$CONTRACT_PATH" \ --from "$ADDRESS_1" --gas 50000000 --chain-id "$CHAIN_ID_1" \ - --broadcast-mode=block --gas-prices 0.0025untrn -y \ + --broadcast-mode=sync --gas-prices 0.0025untrn -y \ --output json --keyring-backend=test --home "$HOME_1" \ --node "$NEUTRON_NODE" \ - | jq -r '.logs[0].events[] | select(.type == "store_code").attributes[] | select(.key == "code_id").value')" + | wait_tx | jq -r '.logs[0].events[] | select(.type == "store_code").attributes[] | select(.key == "code_id").value')" echo "Code ID: $code_id" -contract_address="$("$BIN" tx wasm instantiate "$code_id" '{}' \ - --from "$ADDRESS_1" --admin "$ADMIN" -y --chain-id "$CHAIN_ID_1" \ - --output json --broadcast-mode=block --label "init" --keyring-backend=test \ - --gas-prices 0.0025untrn --home "$HOME_1" --node "$NEUTRON_NODE" \ - | jq -r '.logs[0].events[] | select(.type == "instantiate").attributes[] | select(.key == "_contract_address").value')" +contract_address="$(neutrond tx wasm instantiate "$code_id" '{}' \ + --from "$ADDRESS_1" --admin "$ADMIN" -y --chain-id "$CHAIN_ID_1" \ + --output json --broadcast-mode=sync --label "init" --keyring-backend=test \ + --gas-prices 0.0025untrn --home "$HOME_1" --node "$NEUTRON_NODE" \ + | wait_tx | jq -r '.logs[0].events[] | select(.type == "instantiate").attributes[] | select(.key == "_contract_address").value')" echo "Contract address: $contract_address" -tx_result="$("$BIN" tx bank send "$ADDRESS_1" "$contract_address" 10000000untrn \ - -y --chain-id "$CHAIN_ID_1" --output json --broadcast-mode=block \ - --gas-prices 0.0025untrn --gas 300000 --keyring-backend=test \ - --home "$HOME_1" --node "$NEUTRON_NODE")" +tx_result="$(neutrond tx bank send "$ADDRESS_1" "$contract_address" 10000000untrn \ + -y --chain-id "$CHAIN_ID_1" --output json --broadcast-mode=sync \ + --gas-prices 0.0025untrn --gas 300000 --keyring-backend=test \ + --home "$HOME_1" --node "$NEUTRON_NODE" | wait_tx)" code="$(echo "$tx_result" | jq '.code')" if [[ "$code" -ne 0 ]]; then echo "Failed to send money to contract: $(echo "$tx_result" | jq '.raw_log')" && exit 1 @@ -50,20 +76,20 @@ msg="$(printf '{"register_transfers_query": { "update_period": 5, "min_height": 1 }}' "$VALIDATOR")" -tx_result="$("$BIN" tx wasm execute "$contract_address" "$msg" \ +tx_result="$(neutrond tx wasm execute "$contract_address" "$msg" \ --from "$ADDRESS_1" -y --chain-id "$CHAIN_ID_1" --output json \ - --broadcast-mode=block --gas-prices 0.0025untrn --gas 1000000 \ - --keyring-backend=test --home "$HOME_1" --node "$NEUTRON_NODE")" + --broadcast-mode=sync --gas-prices 0.0025untrn --gas 1000000 \ + --keyring-backend=test --home "$HOME_1" --node "$NEUTRON_NODE" | wait_tx)" code="$(echo "$tx_result" | jq '.code')" if [[ "$code" -ne 0 ]]; then echo "Failed to register ICQ: $(echo "$tx_result" | jq '.raw_log')" && exit 1 fi echo "Registered transfers ICQ" -tx_result="$("$GAIA_BIN" tx bank send "$ADDRESS_2" "$VALIDATOR" 1000uatom \ - --gas 50000000 --gas-adjustment 1.4 --output json -y \ - --gas-prices 0.5uatom --broadcast-mode=block --chain-id "$CHAIN_ID_2" \ - --keyring-backend=test --home "$HOME_2" --node "$GAIA_NODE")" +tx_result="$(gaiad tx bank send "$ADDRESS_2" "$VALIDATOR" 1000uatom \ + --gas 50000000 --gas-adjustment 1.4 --output json -y \ + --gas-prices 0.5uatom --broadcast-mode=sync --chain-id "$CHAIN_ID_2" \ + --keyring-backend=test --home "$HOME_2" --node "$GAIA_NODE" | wait_tx_gaia)" code="$(echo "$tx_result" | jq '.code')" if [[ "$code" -ne 0 ]]; then echo "Failed to transfer funds to trigger TX ICQ: $(echo "$tx_result" | jq '.raw_log')" && exit 1 @@ -81,4 +107,4 @@ echo " done" echo echo "TX query response:" query="$(printf '{"get_recipient_txs": {"recipient": "%s"}}' "$VALIDATOR")" -"$BIN" query wasm contract-state smart "$contract_address" "$query" --node "$NEUTRON_NODE" --output json | jq +neutrond query wasm contract-state smart "$contract_address" "$query" --node "$NEUTRON_NODE" --output json | jq diff --git a/thirdparty/protoc-image/Dockerfile b/thirdparty/protoc-image/Dockerfile index dc3bd19d..683c3073 100644 --- a/thirdparty/protoc-image/Dockerfile +++ b/thirdparty/protoc-image/Dockerfile @@ -1,4 +1,4 @@ -FROM rust:1.68.2 +FROM rust:1.71.0 ENV PROTOC_VERSION 3.20.0