Skip to content

Commit

Permalink
Update ibc-go-wasm and tendermint-wasm-client git dependencies (#411)
Browse files Browse the repository at this point in the history
* Update ibc-go-wasm and tendermint-wasm-client git dependencies

* Update Nix

* Fixing bootstrap to work with ibc-go-v8-simapp

* Proposal can go straight to voting period

* Only deposit if proposasl is still in deposit period

* Only override expedited_voting_period if it is present in genesis

* Run CI test with ibc-go-v8-wasm-simapp

* Use back Cosmos.nix main branch
  • Loading branch information
soareschen authored Aug 26, 2024
1 parent 4ee0d0f commit dd3da32
Show file tree
Hide file tree
Showing 11 changed files with 144 additions and 5,432 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/integration-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
run: |
export WASM_FILE_PATH=$(nix build .#tendermint-wasm-client --print-out-paths --no-link)/ibc_client_tendermint_cw.wasm
nix shell .#cargo-nextest .#protobuf .#gaia .#ibc-go-v7-wasm-simapp -c \
nix shell .#cargo-nextest .#protobuf .#gaia .#ibc-go-v8-wasm-simapp -c \
cargo nextest run -p hermes-cosmos-wasm-relayer \
--test-threads=2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ where
timeout_time: timeout_time.cloned(),
};

println!("built IBC transfer message: {:?}", message);

Ok(message.to_cosmos_message().into())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use core::fmt::{Debug, Display};
use core::time::Duration;

use cgp_core::error::CanRaiseError;
use cgp_core::Async;
use hermes_runtime_components::traits::runtime::HasRuntime;
use hermes_runtime_components::traits::sleep::CanSleep;
use hermes_test_components::chain::traits::proposal::poll_status::ProposalStatusPoller;
Expand All @@ -16,19 +17,22 @@ where
Chain::ProposalId: Display,
Chain::ProposalStatus: Eq + Debug,
{
async fn poll_proposal_status(
async fn poll_proposal_status<M>(
chain: &Chain,
proposal_id: &Chain::ProposalId,
expected_status: &Chain::ProposalStatus,
) -> Result<(), Chain::Error> {
status_matcher: &M,
) -> Result<Chain::ProposalStatus, Chain::Error>
where
M: Fn(&Chain::ProposalStatus) -> bool + Async,
{
let runtime = chain.runtime();

for _ in 0..40 {
let status_result = chain.query_proposal_status(proposal_id).await;

match &status_result {
Ok(status) if status == expected_status => {
return Ok(());
match status_result {
Ok(status) if status_matcher(&status) => {
return Ok(status);
}
_ => {
runtime.sleep(Duration::from_millis(500)).await;
Expand All @@ -37,8 +41,8 @@ where
}

Err(Chain::raise_error(format!(
"Governance proposal {} was not in status {:?}",
proposal_id, expected_status
"Governance proposal {} was not in expected status",
proposal_id
)))
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#[derive(Debug, PartialEq, Eq)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ProposalStatus {
DepositPeriod,
VotingPeriod,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ use crate::chain::traits::proposal::types::proposal_status::HasProposalStatusTyp
#[derive_component(ProposalStatusPollerComponent, ProposalStatusPoller<Chain>)]
#[async_trait]
pub trait CanPollProposalStatus: HasProposalIdType + HasProposalStatusType + HasErrorType {
async fn poll_proposal_status(
async fn poll_proposal_status<M>(
&self,
proposal_id: &Self::ProposalId,
expected_status: &Self::ProposalStatus,
) -> Result<(), Self::Error>;
status_matcher: &M,
) -> Result<Self::ProposalStatus, Self::Error>
where
M: Fn(&Self::ProposalStatus) -> bool + Async;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use alloc::collections::BTreeMap;
use core::fmt::Debug;
use core::marker::PhantomData;
use core::time::Duration;

Expand Down Expand Up @@ -60,6 +61,7 @@ where
ChainDriver:
HasChain<Chain = Chain> + HasWalletAt<ValidatorWallet, 0> + HasDenomAt<StakingDenom, 0>,
InBuilder: ChainDriverBuilder<Bootstrap>,
Chain::Event: Debug,
{
async fn build_chain_driver(
bootstrap: &Bootstrap,
Expand Down Expand Up @@ -90,7 +92,7 @@ where
"Wasm Client",
bootstrap.governance_proposal_authority(),
&Amount {
quantity: 20000,
quantity: 1000000,
denom: staking_denom.clone(),
},
)
Expand All @@ -99,15 +101,17 @@ where

bootstrap.runtime().sleep(Duration::from_secs(3)).await;

chain
.poll_proposal_status(&proposal_id, &ProposalStatus::DepositPeriod)
let status = chain
.poll_proposal_status(&proposal_id, &|status| {
status == &ProposalStatus::DepositPeriod || status == &ProposalStatus::VotingPeriod
})
.await
.map_err(Bootstrap::raise_error)?;

{
if status == ProposalStatus::DepositPeriod {
let deposit_message = chain.build_deposit_proposal_message(
&proposal_id,
&Amount::new(100000000, staking_denom.clone()),
&Amount::new(1000000000, staking_denom.clone()),
);

chain
Expand All @@ -120,7 +124,9 @@ where
}

chain
.poll_proposal_status(&proposal_id, &ProposalStatus::VotingPeriod)
.poll_proposal_status(&proposal_id, &|status| {
status == &ProposalStatus::VotingPeriod
})
.await
.map_err(Bootstrap::raise_error)?;

Expand All @@ -134,7 +140,7 @@ where
}

chain
.poll_proposal_status(&proposal_id, &ProposalStatus::Passed)
.poll_proposal_status(&proposal_id, &|status| status == &ProposalStatus::Passed)
.await
.map_err(Bootstrap::raise_error)?;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,26 @@ where
bootstrap: &Bootstrap,
config: &mut Value,
) -> Result<(), Bootstrap::Error> {
let max_deposit_period = config
let gov_params = config
.get_mut("app_state")
.and_then(|app_state| app_state.get_mut("gov"))
.and_then(|gov| gov.get_mut("params"))
.and_then(|deposit_params| deposit_params.as_object_mut())
.and_then(|gov_params| gov_params.as_object_mut())
.ok_or_else(|| {
Bootstrap::raise_error(
"Failed to retrieve `deposit_params` in genesis configuration",
)
Bootstrap::raise_error("Failed to retrieve `gov.params` in genesis configuration")
})?;

max_deposit_period
.insert(
"max_deposit_period".to_owned(),
Value::String("10s".to_owned()),
)
.ok_or_else(|| {
Bootstrap::raise_error(
"Failed to update `max_deposit_period` in genesis configuration",
)
})?;
gov_params.insert(
"max_deposit_period".to_owned(),
Value::String("6s".to_owned()),
);

if gov_params.contains_key("expedited_voting_period") {
gov_params.insert(
"expedited_voting_period".to_owned(),
Value::String("5s".to_owned()),
);
}

let voting_period = config
.get_mut("app_state")
Expand All @@ -49,29 +48,27 @@ where
)
})?;

voting_period
.insert(
"voting_period".to_owned(),
serde_json::Value::String("10s".to_owned()),
)
.ok_or_else(|| {
Bootstrap::raise_error("Failed to update `voting_period` in genesis configuration")
})?;
voting_period.insert(
"voting_period".to_owned(),
serde_json::Value::String("10s".to_owned()),
);

let allowed_clients = config
let client_genesis_params = config
.get_mut("app_state")
.and_then(|app_state| app_state.get_mut("ibc"))
.and_then(|ibc| ibc.get_mut("client_genesis"))
.and_then(|client_genesis| client_genesis.get_mut("params"))
.and_then(|params| params.get_mut("allowed_clients"))
.and_then(|allowed_clients| allowed_clients.as_array_mut())
.and_then(|client_genesis_params| client_genesis_params.as_object_mut())
.ok_or_else(|| {
Bootstrap::raise_error(
"Failed to retrieve `allowed_clients` in genesis configuration",
"Failed to retrieve `client_genesis.params` in genesis configuration",
)
})?;

allowed_clients.push(Value::String("08-wasm".to_string()));
client_genesis_params.insert(
"allowed_clients".to_owned(),
Value::Array(vec![Value::String("08-wasm".to_owned())]),
);

InModifier::modify_genesis_config(bootstrap, config)?;

Expand Down
Loading

0 comments on commit dd3da32

Please sign in to comment.