Skip to content
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

feat: icq MaxKvQueryKeysCount and MaxTransactionsFilters gov gated #NTRN-364 #60

Merged
merged 8 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
inputs:
toolchain:
description: 'Default Rust Toolchain'
default: "1.73.0"
default: "1.78.0"
required: true
type: string
target:
Expand All @@ -31,7 +31,7 @@ on:
type: string

env:
TOOLCHAIN: ${{ inputs.toolchain || '1.73.0' }}
TOOLCHAIN: ${{ inputs.toolchain || '1.78.0' }}
TARGET: ${{ inputs.target || 'wasm32-unknown-unknown' }}
REF: ${{ github.event_name == 'push' && github.ref || inputs.branch || 'main' }}
ID: ${{ inputs.id || 'scheduled' }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
fetch-depth: 1
- uses: actions-rs/toolchain@v1
with:
toolchain: 1.73.0
toolchain: 1.78.0
components: clippy
profile: minimal
override: true
Expand All @@ -31,7 +31,7 @@ jobs:
fetch-depth: 1
- uses: actions-rs/toolchain@v1
with:
toolchain: 1.73.0
toolchain: 1.78.0
components: rustfmt
profile: minimal
override: true
Expand All @@ -49,7 +49,7 @@ jobs:
fetch-depth: 1
- uses: actions-rs/toolchain@v1
with:
toolchain: 1.73.0
toolchain: 1.78.0
profile: minimal
- run: cargo fetch --verbose
- run: cargo build
Expand Down
4 changes: 2 additions & 2 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ incremental = false
overflow-checks = true

[workspace.dependencies]
neutron-sdk = { package = "neutron-sdk", git = "https://github.com/neutron-org/neutron-sdk", branch = "main" }
neutron-sdk = { package = "neutron-sdk", git = "https://github.com/neutron-org/neutron-sdk", branch = "feat/icq-params-gov-gated" }
prost = "0.12.4"
prost-types = "0.12.4"
cosmos-sdk-proto = { version = "0.20.0", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ compile:
--mount type=volume,source="$(notdir $(CURDIR))_cache",target=/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
--platform linux/amd64 \
cosmwasm/workspace-optimizer:0.15.0
cosmwasm/workspace-optimizer:0.16.0

check_contracts:
@cargo install cosmwasm-check --version 2.0.4 --locked
Expand Down
9 changes: 6 additions & 3 deletions contracts/neutron_interchain_queries/schema/execute_msg.json
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@
"type": "object",
"required": [
"connection_id",
"recipient",
"recipients",
"update_period"
],
"properties": {
Expand All @@ -239,8 +239,11 @@
"format": "uint64",
"minimum": 0.0
},
"recipient": {
"type": "string"
"recipients": {
"type": "array",
"items": {
"type": "string"
}
},
"update_period": {
"type": "integer",
Expand Down
33 changes: 27 additions & 6 deletions contracts/neutron_interchain_queries/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ use neutron_sdk::interchain_queries::get_registered_query;
use neutron_sdk::interchain_queries::types::{
QueryPayload, TransactionFilterItem, TransactionFilterOp, TransactionFilterValue,
};
use neutron_sdk::interchain_queries::v045::types::HEIGHT_FIELD;
use neutron_sdk::interchain_queries::v047::queries::{
query_balance, query_bank_total, query_delegations, query_distribution_fee_pool,
query_government_proposal_votes, query_government_proposals, query_staking_validators,
Expand All @@ -45,7 +46,7 @@ use neutron_sdk::interchain_queries::v047::register_queries::{
new_register_delegator_delegations_query_msg,
new_register_delegator_unbonding_delegations_query_msg,
new_register_distribution_fee_pool_query_msg, new_register_gov_proposals_query_msg,
new_register_staking_validators_query_msg, new_register_transfers_query_msg,
new_register_staking_validators_query_msg,
};
use neutron_sdk::interchain_queries::v047::register_queries::{
new_register_gov_proposals_voters_votes_query_msg,
Expand Down Expand Up @@ -144,10 +145,10 @@ pub fn execute(
} => register_validators_signing_infos_query(connection_id, validators, update_period),
ExecuteMsg::RegisterTransfersQuery {
connection_id,
recipient,
recipients,
update_period,
min_height,
} => register_transfers_query(connection_id, recipient, update_period, min_height),
} => register_transfers_query(connection_id, recipients, update_period, min_height),
ExecuteMsg::UpdateInterchainQuery {
query_id,
new_keys,
Expand Down Expand Up @@ -284,12 +285,32 @@ pub fn register_validators_signing_infos_query(

pub fn register_transfers_query(
connection_id: String,
recipient: String,
recipients: Vec<String>,
update_period: u64,
min_height: Option<u64>,
) -> NeutronResult<Response<NeutronMsg>> {
let msg =
new_register_transfers_query_msg(connection_id, recipient, update_period, min_height)?;
let mut query_data: Vec<TransactionFilterItem> = recipients
.into_iter()
.map(|r| TransactionFilterItem {
field: RECIPIENT_FIELD.to_string(),
op: TransactionFilterOp::Eq,
value: TransactionFilterValue::String(r),
})
.collect();

if let Some(min_height) = min_height {
query_data.push(TransactionFilterItem {
field: HEIGHT_FIELD.to_string(),
op: TransactionFilterOp::Gte,
value: TransactionFilterValue::Int(min_height),
})
}

let msg = NeutronMsg::register_interchain_query(
QueryPayload::TX(query_data),
connection_id,
update_period,
)?;

Ok(Response::new().add_message(msg))
}
Expand Down
2 changes: 1 addition & 1 deletion contracts/neutron_interchain_queries/src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub enum ExecuteMsg {
RegisterTransfersQuery {
connection_id: String,
update_period: u64,
recipient: String,
recipients: Vec<String>,
min_height: Option<u64>,
},
RegisterDelegatorDelegationsQuery {
Expand Down
4 changes: 2 additions & 2 deletions contracts/neutron_interchain_queries/src/testing/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1000,7 +1000,7 @@ fn test_sudo_tx_query_result_callback() {
let msg = ExecuteMsg::RegisterTransfersQuery {
connection_id: "connection".to_string(),
update_period: 1u64,
recipient: watched_addr.clone(),
recipients: vec![watched_addr.clone()],
min_height: None,
};
execute(
Expand Down Expand Up @@ -1104,7 +1104,7 @@ fn test_sudo_tx_query_result_min_height_callback() {
let msg = ExecuteMsg::RegisterTransfersQuery {
connection_id: "connection".to_string(),
update_period: 1u64,
recipient: watched_addr.clone(),
recipients: vec![watched_addr.clone()],
min_height: Some(100000),
};
execute(
Expand Down
4 changes: 2 additions & 2 deletions contracts/neutron_interchain_txs/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ fn execute_undelegate(
amount: amount.to_string(),
}),
};
let mut buf = Vec::new();
let mut buf = Vec::with_capacity(delegate_msg.encoded_len());
buf.reserve(delegate_msg.encoded_len());

if let Err(e) = delegate_msg.encode(&mut buf) {
Expand Down Expand Up @@ -403,7 +403,7 @@ fn do_delegate(
amount: info.amount.to_string(),
}),
};
let mut buf = Vec::new();
let mut buf = Vec::with_capacity(delegate_msg.encoded_len());
buf.reserve(delegate_msg.encoded_len());

if let Err(e) = delegate_msg.encode(&mut buf) {
Expand Down
2 changes: 1 addition & 1 deletion contracts/neutron_validator_test/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ fn execute_undelegate(
amount: amount.to_string(),
}),
};
let mut buf = Vec::new();
let mut buf = Vec::with_capacity(delegate_msg.encoded_len());
buf.reserve(delegate_msg.encoded_len());

if let Err(e) = delegate_msg.encode(&mut buf) {
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[toolchain]
channel = "1.73.0"
channel = "1.78.0"
Loading