Skip to content

Commit

Permalink
Merge pull request #25 from neutron-org/revert-24-feat/contract-manag…
Browse files Browse the repository at this point in the history
…er-resubmit

Revert "feat: contract manager resubmit #ntrn-84"
  • Loading branch information
pr0n00gler authored Aug 29, 2023
2 parents 685e8b0 + 60f6469 commit f24a13a
Show file tree
Hide file tree
Showing 21 changed files with 204 additions and 310 deletions.
38 changes: 9 additions & 29 deletions Cargo.lock

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

17 changes: 3 additions & 14 deletions artifacts/checksums.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,11 @@
3a4c512a4ca6a26f80e8d351b101103248d6ddb51caf8eb1c96db3613feedf5f client_updater-aarch64.wasm
c0190cf28da64b4058da71a9083c187d45f84ee7b9db11a0830025ecb0a687dc client_updater.wasm
ee36fe3b2c7b73bdaf00f92019adbbb7e0459cabf00b797336df16ca3cfd908d echo-aarch64.wasm
4ee0b1e8a1c39e7a440f236778e76935f29506f354b6a59712d267181da77678 echo.wasm
d72e2f3bd0e3cc7e38fe716144220e699023fd8013e52360dac2d3a01b2edad6 ibc_transfer-aarch64.wasm
cf4b2b555032cffa472b98122dee6d6c8f53d07be31c2565d651b4941584f4f1 ibc_transfer.wasm
72274baaf57f04f86ae5af938ac30d824953a28b1f9e8956910ed50f85335641 msg_receiver-aarch64.wasm
fec7d4b6280569bd4ca428d1f5b52702a3378533f50362e1c3f1c848c4e91303 ibc_transfer.wasm
af52c56fb25355afa04d86c7d9e867f9db9295a455fb8a89f9cfdbd6374dd1ff msg_receiver.wasm
15a5c15af41227b8861e92a89830d9c76fba368c2be252709bd9868ce5f9a171 neutron_interchain_queries-aarch64.wasm
05e49fb2d0295c9a9e27a0077da856126f8285c2e949cb1f927f08fa8a867c8e neutron_interchain_queries.wasm
955075ca5b473e1a987d5384cd4e3d6aa730f412edc3049b6527239549319fec neutron_interchain_txs-aarch64.wasm
696362a84c5f8ef42eec10ea9ece3e77251b6de971e05aaa338ae1a1bb21f157 neutron_interchain_txs.wasm
08e912518f6f87119833a863b7562f52d043d80d78e0539c3f3cd50b1cfd4ac5 neutron_price_feed_mock-aarch64.wasm
19d3ea0f4f0a24d202edbd2a7989dcffa61ba3d6754ff382cbd89d4ecd034a67 neutron_interchain_txs.wasm
344ec19c522cc5e6135a77a181345f02a0f65ef19ad919d5236dc16f53d33e76 neutron_price_feed_mock.wasm
6e1a337b1f905cd6b4b5414beb64f67a16de525ad9618ebc5d917246dac4c131 neutron_validators_test-aarch64.wasm
4678704ef3ffd9f1240b719991dc629623929fa75499fd6ed9f76eda4c8a556a neutron_validators_test.wasm
c68ec42808159b006580e6868a7e8de0abfaa52a9a6ebaf90c25ffbf711aee33 reflect-aarch64.wasm
c24970beb5a08bfc73dc422e63207342343802a329f28d527b4accaaf66209f8 reflect.wasm
d18b852f6c0c57b51e577825f454e82f233b26f86d441d264654c7a58f42f5dc stargate_querier-aarch64.wasm
d2ee71886a22631993bbe9f5add6878601897e2f11a31eb7a83296c6eb57eafa stargate_querier.wasm
9bc16491e14afe7f8b0aded8aaa01bbfa0d7b05394e14b0b10ac5e361bc4fa07 tokenfactory-aarch64.wasm
e3ab89e1d88381142c6a970daafceda3cb3fde6f8222e450834045d1f7c9f971 stargate_querier.wasm
a9ee139212dca756adbde1e86723154b1fd79dc96cbc7e4885a851d8c978e946 tokenfactory.wasm
10 changes: 5 additions & 5 deletions artifacts/checksums_intermediate.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
d89ba235e130977d1f79ac4d7f9252f6f6bed3002dfc1d08227ba138acec70b1 target/wasm32-unknown-unknown/release/client_updater.wasm
a67c60c5853497b890d67dd2bfed1caf0984a03af01ec67c877e63688970814e target/wasm32-unknown-unknown/release/echo.wasm
b388b89207c69e9e243f5acf64b761e1cf1116adcc2d79e4eb59bf8cb6c9b99a target/wasm32-unknown-unknown/release/ibc_transfer.wasm
f1ec0aa2f9c84a8b0d63d877fb6dcaf2d25c30023740f3ef53072496124c7dce target/wasm32-unknown-unknown/release/msg_receiver.wasm
bebad52462ca1ddc557ae7ea3fc09aab0a11dd86497027a473f885bbe0c91d6c target/wasm32-unknown-unknown/release/ibc_transfer.wasm
b09e4f513e19e78b5ea08e10d26dc4d61056a4c6f534e783039f32494c39021b target/wasm32-unknown-unknown/release/neutron_interchain_queries.wasm
78b1e6a83b5adc768345716f9eac1bbcc1c4676046d18efaa27d8a8d6c470cb7 target/wasm32-unknown-unknown/release/neutron_interchain_txs.wasm
43c926644f096ba26d356c34f0f409b94b793d8398b1845e5fe03ffee7400e0c target/wasm32-unknown-unknown/release/neutron_interchain_txs.wasm
e947d71ddeb4f6e61d756b48981bedae6973e0b25a9d873c3bba5e9878079d8b target/wasm32-unknown-unknown/release/neutron_price_feed_mock.wasm
8893279611c69a5ca55628f0476e943ca60b8900cb0ae17fefc2f38c4e472215 target/wasm32-unknown-unknown/release/neutron_validators_test.wasm
b260fdda36208b9017f0f142821fa3bb47f3d3dea86901d687cf3d3da00946e0 target/wasm32-unknown-unknown/release/reflect.wasm
46d5d18cf293f37cca582c669de1364635e9c69eaed629f9d5dfe4b6db1b352e target/wasm32-unknown-unknown/release/stargate_querier.wasm
fc80abbf059bafa21b25162af22ddb963a1ea1c6ab4dd671855adb3e1f8a8a84 target/wasm32-unknown-unknown/release/tokenfactory.wasm
d89ba235e130977d1f79ac4d7f9252f6f6bed3002dfc1d08227ba138acec70b1 target/wasm32-unknown-unknown/release/client_updater.wasm
f1ec0aa2f9c84a8b0d63d877fb6dcaf2d25c30023740f3ef53072496124c7dce target/wasm32-unknown-unknown/release/msg_receiver.wasm
0cd5cb6ac3532b558fffa62d501936ccbe748cddf465746ad639ac3a166066ce target/wasm32-unknown-unknown/release/stargate_querier.wasm
Binary file modified artifacts/ibc_transfer.wasm
Binary file not shown.
Binary file modified artifacts/neutron_interchain_txs.wasm
Binary file not shown.
2 changes: 1 addition & 1 deletion contracts/ibc_transfer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ schemars = "0.8.10"
serde = { version = "1.0.180", default-features = false, features = ["derive"] }
serde-json-wasm = { version = "0.5.1" }
cw-storage-plus = { version = "1.1.0", features = ["iterator"]}
neutron-sdk = { package = "neutron-sdk", git = "https://github.com/neutron-org/neutron-sdk", rev = "bb2188561a30d0a7fb293ff05f73907724eb2020" }
neutron-sdk = { package = "neutron-sdk", version = "0.6.1" }
protobuf = { version = "3.2.0", features = ["with-bytes"] }

[dev-dependencies]
Expand Down
44 changes: 2 additions & 42 deletions contracts/ibc_transfer/schema/execute_msg.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,28 +82,6 @@
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"resubmit_failure"
],
"properties": {
"resubmit_failure": {
"type": "object",
"required": [
"failure_id"
],
"properties": {
"failure_id": {
"type": "integer",
"format": "uint64",
"minimum": 0.0
}
}
}
},
"additionalProperties": false
},
{
"description": "Used only in integration tests framework to simulate failures. After executing this message, contract will fail, all of this happening in sudo callback handler.",
"type": "object",
Expand All @@ -112,15 +90,7 @@
],
"properties": {
"integration_tests_set_sudo_failure_mock": {
"type": "object",
"required": [
"state"
],
"properties": {
"state": {
"$ref": "#/definitions/IntegrationTestsSudoFailureMock"
}
}
"type": "object"
}
},
"additionalProperties": false
Expand All @@ -138,15 +108,5 @@
},
"additionalProperties": false
}
],
"definitions": {
"IntegrationTestsSudoFailureMock": {
"type": "string",
"enum": [
"enabled",
"enabled_infinite_loop",
"disabled"
]
}
}
]
}
70 changes: 13 additions & 57 deletions contracts/ibc_transfer/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ use serde::{Deserialize, Serialize};

use crate::state::{
read_reply_payload, read_sudo_payload, save_reply_payload, save_sudo_payload, IBC_FEE,
IBC_SUDO_ID_RANGE_END, IBC_SUDO_ID_RANGE_START, TEST_COUNTER_ITEM,
IBC_SUDO_ID_RANGE_END, IBC_SUDO_ID_RANGE_START,
};

use crate::{
integration_tests_mock_handlers::{set_sudo_failure_mock, unset_sudo_failure_mock},
state::{IntegrationTestsSudoFailureMock, INTEGRATION_TESTS_SUDO_FAILURE_MOCK},
state::{IntegrationTestsSudoMock, INTEGRATION_TESTS_SUDO_MOCK},
};

// Default timeout for IbcTransfer is 10000000 blocks
Expand Down Expand Up @@ -58,15 +58,10 @@ pub enum ExecuteMsg {
timeout_fee: u128,
denom: String,
},
ResubmitFailure {
failure_id: u64,
},
/// Used only in integration tests framework to simulate failures.
/// After executing this message, contract will fail, all of this happening
/// in sudo callback handler.
IntegrationTestsSetSudoFailureMock {
state: IntegrationTestsSudoFailureMock,
},
IntegrationTestsSetSudoFailureMock {},
/// Used only in integration tests framework to simulate failures.
/// After executing this message, contract will revert back to normal behaviour.
IntegrationTestsUnsetSudoFailureMock {},
Expand Down Expand Up @@ -99,15 +94,10 @@ pub fn execute(
timeout_fee,
denom,
} => execute_set_fees(deps, recv_fee, ack_fee, timeout_fee, denom),

ExecuteMsg::ResubmitFailure { failure_id } => execute_resubmit_failure(deps, failure_id),

// Used only in integration tests framework to simulate failures.
// After executing this message, contract fail, all of this happening
// in sudo callback handler.
ExecuteMsg::IntegrationTestsSetSudoFailureMock { state } => {
set_sudo_failure_mock(deps, state)
}
ExecuteMsg::IntegrationTestsSetSudoFailureMock {} => set_sudo_failure_mock(deps),
ExecuteMsg::IntegrationTestsUnsetSudoFailureMock {} => unset_sudo_failure_mock(deps),
}
}
Expand Down Expand Up @@ -268,52 +258,18 @@ fn execute_send(
Ok(Response::default().add_submessages(vec![submsg1, submsg2]))
}

fn execute_resubmit_failure(_: DepsMut, failure_id: u64) -> StdResult<Response<NeutronMsg>> {
let msg = NeutronMsg::submit_resubmit_failure(failure_id);
Ok(Response::default().add_message(msg))
}

// Err result returned from the `sudo()` handler will result in the `Failure` object stored in the chain state.
// It can be resubmitted later using `NeutronMsg::ResubmitFailure { failure_id }` message.
#[allow(unreachable_code)]
#[entry_point]
pub fn sudo(deps: DepsMut, _env: Env, msg: TransferSudoMsg) -> StdResult<Response> {
match INTEGRATION_TESTS_SUDO_FAILURE_MOCK.may_load(deps.storage)? {
Some(IntegrationTestsSudoFailureMock::Enabled) => {
// Used only in integration tests framework to simulate failures.
deps.api
.debug("WASMDEBUG: sudo: mocked failure on the handler");

return Err(StdError::generic_err(
"Integrations test mock error".to_string(),
));
}
Some(IntegrationTestsSudoFailureMock::EnabledInfiniteLoop) => {
// Used only in integration tests framework to simulate failures.
deps.api
.debug("WASMDEBUG: sudo: mocked infinite loop failure on the handler");

if let TransferSudoMsg::Response { request, data: _ } = msg {
deps.api.debug(
format!(
"WASMDEBUG: infinite loop failure response; sequence_id = {:?}",
&request.sequence.unwrap_or_default().to_string()
)
.as_str(),
);
}

let mut counter: u64 = 0;
while counter < 18_446_744_073_709_551_615u64 {
counter = counter.checked_add(1).unwrap_or_default();
TEST_COUNTER_ITEM.save(deps.storage, &counter)?;
}
deps.api.debug("WASMDEBUG: after infinite loop");
TEST_COUNTER_ITEM.save(deps.storage, &counter)?;
if let Some(IntegrationTestsSudoMock::Enabled {}) =
INTEGRATION_TESTS_SUDO_MOCK.may_load(deps.storage)?
{
// Used only in integration tests framework to simulate failures.
deps.api
.debug("WASMDEBUG: sudo: mocked failure on the handler");

return Ok(Response::default());
}
_ => {}
return Err(StdError::GenericErr {
msg: "Integrations test mock error".to_string(),
});
}

match msg {
Expand Down
12 changes: 4 additions & 8 deletions contracts/ibc_transfer/src/integration_tests_mock_handlers.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
use crate::state::{IntegrationTestsSudoFailureMock, INTEGRATION_TESTS_SUDO_FAILURE_MOCK};
use crate::state::{IntegrationTestsSudoMock, INTEGRATION_TESTS_SUDO_MOCK};
use cosmwasm_std::{DepsMut, Response, StdResult};
use neutron_sdk::bindings::msg::NeutronMsg;

pub fn set_sudo_failure_mock(
deps: DepsMut,
state: IntegrationTestsSudoFailureMock,
) -> StdResult<Response<NeutronMsg>> {
INTEGRATION_TESTS_SUDO_FAILURE_MOCK.save(deps.storage, &state)?;
pub fn set_sudo_failure_mock(deps: DepsMut) -> StdResult<Response<NeutronMsg>> {
INTEGRATION_TESTS_SUDO_MOCK.save(deps.storage, &IntegrationTestsSudoMock::Enabled)?;
Ok(Response::default())
}

pub fn unset_sudo_failure_mock(deps: DepsMut) -> StdResult<Response<NeutronMsg>> {
INTEGRATION_TESTS_SUDO_FAILURE_MOCK
.save(deps.storage, &IntegrationTestsSudoFailureMock::Disabled)?;
INTEGRATION_TESTS_SUDO_MOCK.save(deps.storage, &IntegrationTestsSudoMock::Disabled)?;
Ok(Response::default())
}
9 changes: 2 additions & 7 deletions contracts/ibc_transfer/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,11 @@ pub fn read_sudo_payload(
}

/// Used only in integration tests framework to simulate failures.
pub const INTEGRATION_TESTS_SUDO_FAILURE_MOCK: Item<IntegrationTestsSudoFailureMock> =
pub const INTEGRATION_TESTS_SUDO_MOCK: Item<IntegrationTestsSudoMock> =
Item::new("integration_tests_sudo_mock");

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum IntegrationTestsSudoFailureMock {
pub enum IntegrationTestsSudoMock {
Enabled,
EnabledInfiniteLoop,
Disabled,
}

// just to do something in infinite loop
pub const TEST_COUNTER_ITEM: Item<u64> = Item::new("test_counter");
2 changes: 1 addition & 1 deletion contracts/neutron_interchain_txs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ serde = { version = "1.0.180", 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 = { package = "neutron-sdk", git = "https://github.com/neutron-org/neutron-sdk", rev = "bb2188561a30d0a7fb293ff05f73907724eb2020" }
neutron-sdk = { package = "neutron-sdk", version = "0.6.1" }
base64 = "0.21.2"
protobuf = { version = "3.2.0", features = ["with-bytes"] }
prost = "0.11"
Expand Down
Loading

0 comments on commit f24a13a

Please sign in to comment.