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: Failed Ack Handling #582

Merged
merged 11 commits into from
Oct 26, 2024
104 changes: 23 additions & 81 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 contracts/data-storage/andromeda-counter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ cosmwasm-schema = { workspace = true }
cw-storage-plus = { workspace = true }
cw-utils = { workspace = true }
cw20 = { workspace = true }
cw-orch = "=0.23.0"
cw-orch = "=0.24.1"

andromeda-std = { workspace = true, features = ["rates"] }
andromeda-data-storage = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion contracts/finance/andromeda-splitter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ cosmwasm-std = { workspace = true }
cosmwasm-schema = { workspace = true }
cw-storage-plus = { workspace = true }
cw-utils = { workspace = true }
cw-orch = "=0.23.0"
cw-orch = "=0.24.1"

andromeda-std = { workspace = true }
andromeda-finance = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion contracts/fungible-tokens/andromeda-ics20/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ cw-controllers = "=1.1.2"
schemars = "0.8.21"
serde = "1.0.203"
thiserror = "1.0.61"
cw-orch = "=0.23.0"
cw-orch = "=0.24.1"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Inconsistent cw-orch Dependency Versions Detected

The cw-orch dependency is not updated to version =0.24.1 in the following Cargo.toml files:

  • contracts/app/andromeda-app-contract/Cargo.toml
  • contracts/data-storage/andromeda-boolean/Cargo.toml
  • contracts/data-storage/andromeda-primitive/Cargo.toml
  • contracts/data-storage/andromeda-string-storage/Cargo.toml
  • contracts/ecosystem/andromeda-vault/Cargo.toml
  • contracts/finance/andromeda-conditional-splitter/Cargo.toml
  • contracts/finance/andromeda-cross-chain-swap/Cargo.toml
  • contracts/finance/andromeda-rate-limiting-withdrawals/Cargo.toml
  • contracts/finance/andromeda-set-amount-splitter/Cargo.toml
  • contracts/finance/andromeda-timelock/Cargo.toml
  • contracts/finance/andromeda-validator-staking/Cargo.toml
  • contracts/finance/andromeda-vesting/Cargo.toml
  • contracts/finance/andromeda-weighted-distribution-splitter/Cargo.toml
  • contracts/fungible-tokens/andromeda-cw20/Cargo.toml
  • contracts/fungible-tokens/andromeda-cw20-exchange/Cargo.toml
  • contracts/fungible-tokens/andromeda-cw20-staking/Cargo.toml
  • contracts/fungible-tokens/andromeda-lockdrop/Cargo.toml
  • contracts/fungible-tokens/andromeda-merkle-airdrop/Cargo.toml
  • contracts/modules/andromeda-address-list/Cargo.toml
  • contracts/modules/andromeda-curve/Cargo.toml
  • contracts/modules/andromeda-date-time/Cargo.toml
  • contracts/modules/andromeda-rates/Cargo.toml
  • contracts/modules/andromeda-shunting/Cargo.toml
  • contracts/non-fungible-tokens/andromeda-auction/Cargo.toml
  • contracts/non-fungible-tokens/andromeda-crowdfund/Cargo.toml
  • contracts/non-fungible-tokens/andromeda-cw721/Cargo.toml
  • contracts/non-fungible-tokens/andromeda-marketplace/Cargo.toml
  • contracts/os/andromeda-ibc-registry/Cargo.toml
  • ibc-tests/Cargo.toml
  • packages/andromeda-app/Cargo.toml
  • packages/andromeda-data-storage/Cargo.toml
  • packages/andromeda-ecosystem/Cargo.toml
  • packages/andromeda-finance/Cargo.toml
  • packages/andromeda-fungible-tokens/Cargo.toml
  • packages/andromeda-modules/Cargo.toml
  • packages/andromeda-non-fungible-tokens/Cargo.toml
  • packages/andromeda-testing/Cargo.toml
  • packages/andromeda-testing-e2e/Cargo.toml
  • packages/std/Cargo.toml
  • packages/std/macros/Cargo.toml
  • tests-integration/Cargo.toml
🔗 Analysis chain

Dependency version update looks good.

The cw-orch dependency has been updated from version 0.23.0 to 0.24.1. This change is consistent with updates made across multiple packages in the project, as mentioned in the AI-generated summary.

To ensure consistency across the project, let's verify this update in other packages:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify cw-orch version consistency across packages

# Test: Check cw-orch version in all Cargo.toml files
rg -U 'cw-orch.*=.*0\.24\.1' '**/Cargo.toml'

Length of output: 100


Script:

#!/bin/bash
# Description: Locate all Cargo.toml files and verify cw-orch version

# Find all Cargo.toml files
fd Cargo.toml > cargo_files.txt

# Check cw-orch version in each Cargo.toml
while IFS= read -r file; do
  echo "Checking $file"
  grep 'cw-orch\s*=\s*"\=0\.24\.1"' "$file"
done < cargo_files.txt

Length of output: 11382


Script:

#!/bin/bash
# Description: List all Cargo.toml files that do not have cw-orch version "=0.24.1"

# Find all Cargo.toml files
fd Cargo.toml > cargo_files.txt

# List files without cw-orch = "=0.24.1"
while IFS= read -r file; do
  if ! grep -q 'cw-orch\s*=\s*"\=0\.24\.1"' "$file"; then
    echo "$file"
  fi
done < cargo_files.txt

Length of output: 9643


andromeda-std = { workspace = true, features = ["rates"]}
andromeda-fungible-tokens = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion contracts/os/andromeda-adodb/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ cw-storage-plus = { workspace = true }
andromeda-std = { workspace = true }
semver = { workspace = true }
cw-asset = { workspace = true }
cw-orch = "=0.23.0"
cw-orch = "=0.24.1"

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
cw-multi-test = { workspace = true, optional = true }
2 changes: 1 addition & 1 deletion contracts/os/andromeda-economics/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ andromeda-std = { workspace = true }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
cw-multi-test = { workspace = true, optional = true }
cw-orch = "=0.23.0"
cw-orch = "=0.24.1"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Inconsistent cw-orch Dependency Versions Detected.

Only 2 out of 49 Cargo.toml files are using cw-orch = "0.24.1". Please update the following files to ensure consistency across the project:

  • tests-integration/Cargo.toml
  • contracts/os/andromeda-economics/Cargo.toml
🔗 Analysis chain

Dependency update looks good, but let's verify consistency.

The update of cw-orch from version 0.23.0 to 0.24.1 is in line with the changes observed in other packages. This update likely brings improvements or fixes that benefit the project.

To ensure this update is intentional and consistent across the project, please run the following script:

This script will help us confirm that the version update has been applied consistently across all relevant Cargo.toml files in the project.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify cw-orch version consistency across all Cargo.toml files

# Test: Check for any Cargo.toml files that don't use cw-orch version 0.24.1
# Expect: No output if all files are consistent
rg -U 'cw-orch.*=.*(?!0\.24\.1)' $(fd Cargo.toml)

# Test: Count occurrences of cw-orch version 0.24.1
# Expect: A number equal to the total number of Cargo.toml files that use cw-orch
echo "Number of Cargo.toml files using cw-orch 0.24.1:"
rg -c 'cw-orch.*=.*0\.24\.1' $(fd Cargo.toml) | awk -F: '{sum += $2} END {print sum}'

Length of output: 5169


Script:

#!/bin/bash
# Description: Verify cw-orch version consistency across all Cargo.toml files

# Test: Check for any Cargo.toml files that don't use cw-orch version 0.24.1
# Using --pcre2 to enable look-around in regex
rg --pcre2 -U 'cw-orch\s*=\s*"(?!0\.24\.1)' $(fd Cargo.toml)

# Test: Count occurrences of cw-orch version 0.24.1
echo "Number of Cargo.toml files using cw-orch 0.24.1:"
rg -c 'cw-orch\s*=\s*"0\.24\.1"' $(fd Cargo.toml) | awk -F: '{sum += $2} END {print sum}'

# Test: Count total number of Cargo.toml files
echo "Total number of Cargo.toml files:"
fd Cargo.toml | wc -l

Length of output: 5552

joemonem marked this conversation as resolved.
Show resolved Hide resolved

[dev-dependencies]
# andromeda-testing = { workspace = true, optional = true }
2 changes: 1 addition & 1 deletion contracts/os/andromeda-kernel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ andromeda-std = { workspace = true }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
cw-multi-test = { workspace = true, optional = true }
cw-orch = "=0.23.0"
cw-orch = "=0.24.1"

[dev-dependencies]
# andromeda-testing = { workspace = true, optional = true }
35 changes: 25 additions & 10 deletions contracts/os/andromeda-kernel/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ use cosmwasm_std::{
};

use crate::ibc::{IBCLifecycleComplete, SudoMsg};
use crate::reply::{on_reply_create_ado, on_reply_ibc_hooks_packet_send, on_reply_ibc_transfer};
use crate::reply::{
on_reply_create_ado, on_reply_ibc_hooks_packet_send, on_reply_ibc_transfer,
on_reply_refund_ibc_transfer_with_msg,
};
use crate::state::CURR_CHAIN;
use crate::{execute, query, sudo};

Expand Down Expand Up @@ -44,13 +47,24 @@ pub fn instantiate(
}

#[cfg_attr(not(feature = "library"), entry_point)]
pub fn reply(deps: DepsMut, env: Env, msg: Reply) -> Result<Response, ContractError> {
pub fn reply(mut deps: DepsMut, env: Env, msg: Reply) -> Result<Response, ContractError> {
if msg.result.is_err() {
return Err(ContractError::Std(StdError::generic_err(format!(
"{}:{}",
msg.id,
msg.result.unwrap_err()
))));
match ReplyId::from_repr(msg.id) {
Some(ReplyId::IBCTransferWithMsg) => {
return on_reply_refund_ibc_transfer_with_msg(
deps.branch(),
env.clone(),
msg.clone(),
);
Comment on lines +54 to +58
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Avoid Unnecessary Cloning of env and msg

In the call to on_reply_refund_ibc_transfer_with_msg, consider passing references to env and msg instead of cloning them to improve performance and reduce overhead.

Apply this diff to avoid cloning:

 return on_reply_refund_ibc_transfer_with_msg(
     deps.branch(),
-    env.clone(),
-    msg.clone(),
+    &env,
+    &msg,
 );

Ensure that the function on_reply_refund_ibc_transfer_with_msg is updated to accept references to Env and Reply accordingly.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
return on_reply_refund_ibc_transfer_with_msg(
deps.branch(),
env.clone(),
msg.clone(),
);
return on_reply_refund_ibc_transfer_with_msg(
deps.branch(),
&env,
&msg,
);

}
_ => {
return Err(ContractError::Std(StdError::generic_err(format!(
"{}:{}",
msg.id,
msg.result.unwrap_err()
))))
}
}
}

match ReplyId::from_repr(msg.id) {
Expand Down Expand Up @@ -83,9 +97,10 @@ pub fn execute(
packet,
),
ExecuteMsg::Send { message } => execute::send(execute_env, message),
ExecuteMsg::TriggerRelay { packet_sequence } => {
execute::trigger_relay(execute_env, packet_sequence)
}
ExecuteMsg::TriggerRelay {
packet_sequence,
packet_ack_msg,
} => execute::trigger_relay(execute_env, packet_sequence, packet_ack_msg),
ExecuteMsg::UpsertKeyAddress { key, value } => {
execute::upsert_key_address(execute_env, key, value)
}
Expand Down
Loading
Loading