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

refactor: connection router picks up gateway-api #277

Merged
merged 2 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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: 4 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions contracts/connection-router/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ optimize = """docker run --rm -v "$(pwd)":/code \
axelar-wasm-std = { workspace = true }
axelar-wasm-std-derive = { workspace = true }
connection-router-api = { workspace = true }
gateway-api = { workspace = true }
cosmwasm-schema = { workspace = true }
cosmwasm-std = { workspace = true }
cosmwasm-storage = { workspace = true }
Expand Down
8 changes: 4 additions & 4 deletions contracts/connection-router/src/contract/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use std::vec;

use axelar_wasm_std::flagset::FlagSet;
use connection_router_api::error::Error;
use connection_router_api::msg::ExecuteMsg;
use connection_router_api::{ChainEndpoint, ChainName, Gateway, GatewayDirection, Message};
use cosmwasm_std::{to_binary, Addr, DepsMut, MessageInfo, Response, StdResult, WasmMsg};
use error_stack::report;
Expand Down Expand Up @@ -175,9 +174,10 @@ where

Ok(WasmMsg::Execute {
contract_addr: gateway.to_string(),
// TODO: this happens to work because the router and the gateways have the same definition of RouteMessages
msg: to_binary(&ExecuteMsg::RouteMessages(msgs.cloned().collect()))
.expect("must serialize message"),
msg: to_binary(&gateway_api::msg::ExecuteMsg::RouteMessages(
msgs.cloned().collect(),
))
.expect("must serialize message"),
funds: vec![],
})
})
Expand Down
1 change: 1 addition & 0 deletions contracts/gateway/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ cosmwasm-std = { workspace = true }
cosmwasm-storage = { workspace = true }
cw-storage-plus = { workspace = true }
error-stack = { workspace = true }
gateway-api = { workspace = true}
itertools = { workspace = true }
mockall = "0.11.3"
report = { workspace = true }
Expand Down
3 changes: 2 additions & 1 deletion contracts/gateway/src/bin/schema.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use cosmwasm_schema::write_api;
use gateway_api::msg::{ExecuteMsg, QueryMsg};

use gateway::msg::{ExecuteMsg, InstantiateMsg, QueryMsg};
use gateway::msg::InstantiateMsg;

fn main() {
write_api! {
Expand Down
6 changes: 4 additions & 2 deletions contracts/gateway/src/contract.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#[cfg(not(feature = "library"))]
use cosmwasm_std::entry_point;
use cosmwasm_std::{Binary, Deps, DepsMut, Env, MessageInfo, Response};
use gateway_api::msg::{ExecuteMsg, QueryMsg};
use std::fmt::Debug;

use crate::msg::{ExecuteMsg, InstantiateMsg, QueryMsg};
use crate::msg::InstantiateMsg;

mod execute;
mod query;
Expand Down Expand Up @@ -58,9 +59,10 @@ mod internal {
use connection_router_api::client::Router;
use cosmwasm_std::{to_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response};
use error_stack::{Result, ResultExt};
use gateway_api::msg::{ExecuteMsg, QueryMsg};

use crate::contract::Error;
use crate::msg::{ExecuteMsg, InstantiateMsg, QueryMsg};
use crate::msg::InstantiateMsg;
use crate::state::Config;
use crate::{contract, state};

Expand Down
19 changes: 1 addition & 18 deletions contracts/gateway/src/msg.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,7 @@
use connection_router_api::{CrossChainId, Message};
use cosmwasm_schema::{cw_serde, QueryResponses};
use cosmwasm_schema::cw_serde;

#[cw_serde]
pub struct InstantiateMsg {
pub verifier_address: String,
pub router_address: String,
}

#[cw_serde]
pub enum ExecuteMsg {
// Permissionless
VerifyMessages(Vec<Message>),

// Permissionless
RouteMessages(Vec<Message>),
}

#[cw_serde]
#[derive(QueryResponses)]
pub enum QueryMsg {
#[returns(Vec<Message>)]
GetMessages { message_ids: Vec<CrossChainId> },
}
3 changes: 2 additions & 1 deletion contracts/gateway/tests/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ use cosmwasm_std::{
from_binary, to_binary, Addr, ContractResult, DepsMut, QuerierResult, WasmQuery,
};
use gateway::contract::*;
use gateway::msg::{ExecuteMsg, InstantiateMsg, QueryMsg};
use gateway::msg::InstantiateMsg;
use gateway_api::msg::{ExecuteMsg, QueryMsg};
use itertools::Itertools;
use serde::Serialize;

Expand Down
1 change: 1 addition & 0 deletions contracts/multisig-prover/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ either = "1.8.1"
error-stack = { workspace = true }
ethabi = { version = "18.0.0", default-features = false, features = [] }
gateway = { workspace = true }
gateway-api = { workspace = true }
hex = { version = "0.4.3", default-features = false, features = [] }
itertools = "0.11.0"
k256 = { version = "0.13.1", features = ["ecdsa"] }
Expand Down
2 changes: 1 addition & 1 deletion contracts/multisig-prover/src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ fn get_messages(
) -> Result<Vec<Message>, ContractError> {
let length = message_ids.len();

let query = gateway::msg::QueryMsg::GetMessages { message_ids };
let query = gateway_api::msg::QueryMsg::GetMessages { message_ids };
let messages: Vec<Message> = querier.query(&QueryRequest::Wasm(WasmQuery::Smart {
contract_addr: gateway.into(),
msg: to_binary(&query)?,
Expand Down
3 changes: 2 additions & 1 deletion contracts/multisig-prover/src/test/mocks/gateway.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use cosmwasm_std::{
to_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdError, StdResult,
};
use gateway::msg::{ExecuteMsg, InstantiateMsg, QueryMsg};
use gateway::msg::InstantiateMsg;
use gateway_api::msg::{ExecuteMsg, QueryMsg};

use crate::test::test_data;

Expand Down
1 change: 1 addition & 0 deletions integration-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ cw-multi-test = "0.15.1"
cw-storage-plus = { workspace = true }
error-stack = { workspace = true }
gateway = { workspace = true }
gateway-api = { workspace = true }
itertools = { workspace = true }
k256 = { version = "0.13.1", features = ["ecdsa"] }
mockall = "0.11.3"
Expand Down
6 changes: 3 additions & 3 deletions integration-tests/tests/test_utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
let response = app.execute_contract(
Addr::unchecked("relayer"),
gateway_address.clone(),
&gateway::msg::ExecuteMsg::VerifyMessages(msgs.to_vec()),
&gateway_api::msg::ExecuteMsg::VerifyMessages(msgs.to_vec()),
&[],
);
assert!(response.is_ok());
Expand All @@ -66,7 +66,7 @@
let response = app.execute_contract(
Addr::unchecked("relayer"),
gateway_address.clone(),
&gateway::msg::ExecuteMsg::RouteMessages(msgs.to_vec()),
&gateway_api::msg::ExecuteMsg::RouteMessages(msgs.to_vec()),
&[],
);

Expand Down Expand Up @@ -94,7 +94,7 @@
}
}

pub fn vote_true_for_worker_set(

Check warning on line 97 in integration-tests/tests/test_utils/mod.rs

View workflow job for this annotation

GitHub Actions / Test Suite

function `vote_true_for_worker_set` is never used
app: &mut App,
voting_verifier_address: &Addr,
workers: &Vec<Worker>,
Expand Down Expand Up @@ -221,7 +221,7 @@
) -> Vec<Message> {
let query_response = app.wrap().query_wasm_smart(
gateway_address,
&gateway::msg::QueryMsg::GetMessages {
&gateway_api::msg::QueryMsg::GetMessages {
message_ids: message_ids.to_owned(),
},
);
Expand All @@ -244,7 +244,7 @@
query_response.unwrap()
}

pub fn get_worker_set(app: &mut App, multisig_prover_address: &Addr) -> WorkerSet {

Check warning on line 247 in integration-tests/tests/test_utils/mod.rs

View workflow job for this annotation

GitHub Actions / Test Suite

function `get_worker_set` is never used
let query_response = app.wrap().query_wasm_smart(
multisig_prover_address,
&multisig_prover::msg::QueryMsg::GetWorkerSet,
Expand Down Expand Up @@ -459,7 +459,7 @@
}
}

pub fn deregister_workers(

Check warning on line 462 in integration-tests/tests/test_utils/mod.rs

View workflow job for this annotation

GitHub Actions / Test Suite

function `deregister_workers` is never used
app: &mut App,
service_registry: Addr,
governance_addr: Addr,
Expand Down Expand Up @@ -493,7 +493,7 @@
}
}

pub fn update_worker_set(app: &mut App, relayer_addr: Addr, multisig_prover: Addr) -> AppResponse {

Check warning on line 496 in integration-tests/tests/test_utils/mod.rs

View workflow job for this annotation

GitHub Actions / Test Suite

function `update_worker_set` is never used
let response = app.execute_contract(
relayer_addr.clone(),
multisig_prover.clone(),
Expand All @@ -506,7 +506,7 @@
response.unwrap()
}

pub fn confirm_worker_set(app: &mut App, relayer_addr: Addr, multisig_prover: Addr) {

Check warning on line 509 in integration-tests/tests/test_utils/mod.rs

View workflow job for this annotation

GitHub Actions / Test Suite

function `confirm_worker_set` is never used
let response = app.execute_contract(
relayer_addr.clone(),
multisig_prover.clone(),
Expand All @@ -516,7 +516,7 @@
assert!(response.is_ok());
}

fn get_worker_set_poll_id_and_expiry(response: AppResponse) -> (PollId, PollExpiryBlock) {

Check warning on line 519 in integration-tests/tests/test_utils/mod.rs

View workflow job for this annotation

GitHub Actions / Test Suite

function `get_worker_set_poll_id_and_expiry` is never used
let poll_id = get_event_attribute(&response.events, "wasm-worker_set_poll_started", "poll_id")
.map(|attr| serde_json::from_str(&attr.value).unwrap())
.expect("couldn't get poll_id");
Expand All @@ -530,7 +530,7 @@
(poll_id, expiry)
}

pub fn create_worker_set_poll(

Check warning on line 533 in integration-tests/tests/test_utils/mod.rs

View workflow job for this annotation

GitHub Actions / Test Suite

function `create_worker_set_poll` is never used
app: &mut App,
relayer_addr: Addr,
voting_verifier: Addr,
Expand All @@ -550,7 +550,7 @@
get_worker_set_poll_id_and_expiry(response.unwrap())
}

pub fn workers_to_worker_set(protocol: &mut Protocol, workers: &Vec<Worker>) -> WorkerSet {

Check warning on line 553 in integration-tests/tests/test_utils/mod.rs

View workflow job for this annotation

GitHub Actions / Test Suite

function `workers_to_worker_set` is never used
// get public keys
let mut pub_keys = vec![];
for worker in workers {
Expand Down Expand Up @@ -580,7 +580,7 @@
)
}

pub fn create_new_workers_vec(

Check warning on line 583 in integration-tests/tests/test_utils/mod.rs

View workflow job for this annotation

GitHub Actions / Test Suite

function `create_new_workers_vec` is never used
chains: Vec<ChainName>,
worker_details: Vec<(String, u32)>,
) -> Vec<Worker> {
Expand All @@ -594,7 +594,7 @@
.collect()
}

pub fn update_registry_and_construct_proof(

Check warning on line 597 in integration-tests/tests/test_utils/mod.rs

View workflow job for this annotation

GitHub Actions / Test Suite

function `update_registry_and_construct_proof` is never used
protocol: &mut Protocol,
new_workers: &Vec<Worker>,
workers_to_remove: &Vec<Worker>,
Expand Down
11 changes: 9 additions & 2 deletions packages/gateway-api/src/msg.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use connection_router_api::Message;
use cosmwasm_schema::cw_serde;
use connection_router_api::{CrossChainId, Message};
use cosmwasm_schema::{cw_serde, QueryResponses};

#[cw_serde]
pub enum ExecuteMsg {
Expand All @@ -13,3 +13,10 @@
/// they have to be verified first.
RouteMessages(Vec<Message>),
}

#[cw_serde]
#[derive(QueryResponses)]
pub enum QueryMsg {

Check warning on line 19 in packages/gateway-api/src/msg.rs

View check run for this annotation

Codecov / codecov/patch

packages/gateway-api/src/msg.rs#L18-L19

Added lines #L18 - L19 were not covered by tests
#[returns(Vec<Message>)]
GetMessages { message_ids: Vec<CrossChainId> },
}
Loading