From 86edc82fb494552da14e2bb88d8320aa56a3aecd Mon Sep 17 00:00:00 2001 From: Giovanni Gargiulo Date: Thu, 14 Aug 2025 11:30:58 +0100 Subject: [PATCH 01/27] chore: asked claude to make this to work on linux. --- caribic/Cargo.lock | 21 +- caribic/Cargo.toml | 5 +- caribic/src/start.rs | 206 +++++++++++--------- caribic/src/utils.rs | 20 ++ chains/cardano/docker-compose.yaml | 10 +- chains/mithrils/scripts/docker-compose.yaml | 30 +-- 6 files changed, 181 insertions(+), 111 deletions(-) diff --git a/caribic/Cargo.lock b/caribic/Cargo.lock index 716c7858f..48680219d 100644 --- a/caribic/Cargo.lock +++ b/caribic/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "addr2line" @@ -215,6 +215,7 @@ dependencies = [ "futures-util", "indicatif", "lazy_static", + "nix", "regex", "reqwest", "serde", @@ -240,6 +241,12 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "cfg_aliases" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" + [[package]] name = "chrono" version = "0.4.38" @@ -1013,6 +1020,18 @@ dependencies = [ "tempfile", ] +[[package]] +name = "nix" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46" +dependencies = [ + "bitflags 2.6.0", + "cfg-if", + "cfg_aliases", + "libc", +] + [[package]] name = "num-conv" version = "0.1.0" diff --git a/caribic/Cargo.toml b/caribic/Cargo.toml index 9fbb6c056..5d10e64cd 100644 --- a/caribic/Cargo.toml +++ b/caribic/Cargo.toml @@ -17,4 +17,7 @@ lazy_static = "1.5.0" serde = { version = "1.0.209", features = ["derive"] } serde_json = "1.0" regex = "1.5" -chrono = "0.4" \ No newline at end of file +chrono = "0.4" + +[target.'cfg(unix)'.dependencies] +nix = { version = "0.29", features = ["user"] } \ No newline at end of file diff --git a/caribic/src/start.rs b/caribic/src/start.rs index 3c20a875a..253fa1780 100644 --- a/caribic/src/start.rs +++ b/caribic/src/start.rs @@ -6,7 +6,7 @@ use crate::setup::{ }; use crate::utils::{ copy_dir_all, download_file, execute_script, execute_script_with_progress, - extract_tendermint_client_id, extract_tendermint_connection_id, get_cardano_state, unzip_file, + extract_tendermint_client_id, extract_tendermint_connection_id, get_cardano_state, get_user_ids, unzip_file, wait_for_health_check, wait_until_file_exists, CardanoQuery, IndicatorMessage, }; use crate::{ @@ -26,6 +26,15 @@ use std::process::Command; use std::time::Duration; use std::u64; +/// Get environment variables for Docker Compose, including UID/GID on Unix systems +fn get_docker_env_vars() -> Vec<(&'static str, String)> { + let (uid, gid) = get_user_ids(); + vec![ + ("UID", uid), + ("GID", gid), + ] +} + pub fn start_relayer( relayer_path: &Path, relayer_env_template_path: &Path, @@ -66,11 +75,18 @@ pub fn start_relayer( execute_script(relayer_path, "docker", Vec::from(["compose", "stop"]), None)?; - execute_script_with_progress( + // Note: execute_script_with_progress doesn't support environment variables + // Using regular execute_script for relayer with UID/GID support + let docker_env = get_docker_env_vars(); + let docker_env_refs: Vec<(&str, &str)> = docker_env.iter() + .map(|(k, v)| (*k, v.as_str())) + .collect(); + + execute_script( relayer_path, - "docker", + "docker", Vec::from(["compose", "up", "-d", "--build"]), - "⚡ Starting relayer...", + Some(docker_env_refs), )?; Ok(()) @@ -197,11 +213,15 @@ pub async fn start_local_cardano_network( if config::get_config().cardano.services.db_sync { prepare_db_sync_and_gateway(cardano_dir.as_path(), clean)?; + let docker_env = get_docker_env_vars(); + let docker_env_refs: Vec<(&str, &str)> = docker_env.iter() + .map(|(k, v)| (*k, v.as_str())) + .collect(); execute_script( &cardano_dir, "docker", vec!["compose", "up", "-d", "cardano-db-sync"], - None, + Some(docker_env_refs), )?; } @@ -365,11 +385,17 @@ pub async fn start_cosmos_sidechain_from_repository( pub async fn start_cosmos_sidechain(cosmos_dir: &Path) -> Result<(), Box> { execute_script(cosmos_dir, "docker", Vec::from(["compose", "stop"]), None)?; + + let docker_env = get_docker_env_vars(); + let docker_env_refs: Vec<(&str, &str)> = docker_env.iter() + .map(|(k, v)| (*k, v.as_str())) + .collect(); + execute_script( cosmos_dir, "docker", Vec::from(["compose", "up", "-d", "--build"]), - None, + Some(docker_env_refs), )?; let optional_progress_bar = match logger::get_verbosity() { @@ -428,9 +454,14 @@ pub fn start_local_cardano_services(cardano_dir: &Path) -> Result<(), Box = docker_env.iter() + .map(|(k, v)| (*k, v.as_str())) + .collect(); + let mut script_start_args = vec!["compose", "up", "-d"]; script_start_args.append(&mut services); - execute_script(cardano_dir, "docker", script_start_args, None)?; + execute_script(cardano_dir, "docker", script_start_args, Some(docker_env_refs))?; Ok(()) } @@ -920,37 +951,45 @@ pub async fn start_mithril(project_root_dir: &Path) -> Result Result Result<(), Box = docker_env.iter() + .map(|(k, v)| (*k, v.as_str())) + .collect(); + + execute_script(&gateway_dir, "docker", script_args, Some(docker_env_refs))?; Ok(()) } diff --git a/caribic/src/utils.rs b/caribic/src/utils.rs index a892dde43..8daa0bd38 100644 --- a/caribic/src/utils.rs +++ b/caribic/src/utils.rs @@ -23,6 +23,9 @@ use std::{error::Error, process::Output}; use tokio::io::AsyncWriteExt; use zip::read::ZipArchive; +#[cfg(unix)] +use nix::unistd::{Uid, Gid}; + pub fn print_header() { println!( r#" @@ -586,3 +589,20 @@ pub fn query_balance(project_root_path: &Path, address: &str) -> u64 { .map(|k| k["value"]["lovelace"].as_u64().unwrap()) .sum() } + +/// Get current user's UID and GID for Docker containers (Unix only) +/// Returns (UID, GID) or default (1000, 1000) on non-Unix systems +pub fn get_user_ids() -> (String, String) { + #[cfg(unix)] + { + let uid = Uid::current().as_raw(); + let gid = Gid::current().as_raw(); + (uid.to_string(), gid.to_string()) + } + + #[cfg(not(unix))] + { + // Default UID/GID for non-Unix systems (Windows) + ("1000".to_string(), "1000".to_string()) + } +} diff --git a/chains/cardano/docker-compose.yaml b/chains/cardano/docker-compose.yaml index dd7c1f4ed..babcd6d50 100644 --- a/chains/cardano/docker-compose.yaml +++ b/chains/cardano/docker-compose.yaml @@ -2,7 +2,7 @@ services: cardano-node: image: ghcr.io/blinklabs-io/cardano-node:10.1.4-3 container_name: cardano-node - # user: "${UID:-1000}:${GID:-1000}" + user: "${UID:-1000}:${GID:-1000}" volumes: - ./devnet:/devnet environment: @@ -39,7 +39,7 @@ services: cardano-node-ogmios: image: cardanosolutions/ogmios:v6.10.0 - # user: "${UID:-1000}:${GID:-1000}" + user: "${UID:-1000}:${GID:-1000}" logging: driver: "json-file" options: @@ -65,7 +65,7 @@ services: kupo: image: cardanosolutions/kupo:v2.9.0 - # user: "${UID:-1000}:${GID:-1000}" + user: "${UID:-1000}:${GID:-1000}" logging: driver: "json-file" options: @@ -98,7 +98,7 @@ services: postgres: image: postgres:14.10-alpine - # user: "${UID:-1000}:${GID:-1000}" + user: "${UID:-1000}:${GID:-1000}" environment: - POSTGRES_LOGGING=true - POSTGRES_DB_FILE=/run/secrets/postgres_db @@ -131,7 +131,7 @@ services: cardano-db-sync: image: ghcr.io/blinklabs-io/cardano-db-sync:main - # user: "${UID:-1000}:${GID:-1000}" + user: "${UID:-1000}:${GID:-1000}" environment: - POSTGRES_HOST=postgres - POSTGRES_PORT=5432 diff --git a/chains/mithrils/scripts/docker-compose.yaml b/chains/mithrils/scripts/docker-compose.yaml index 80bfa786e..592a0b3f6 100644 --- a/chains/mithrils/scripts/docker-compose.yaml +++ b/chains/mithrils/scripts/docker-compose.yaml @@ -16,10 +16,10 @@ services: - GOOGLE_APPLICATION_CREDENTIALS_JSON= - NETWORK=devnet - NETWORK_MAGIC=42 - - PROTOCOL_PARAMETERS__K=5 - - PROTOCOL_PARAMETERS__M=100 - - PROTOCOL_PARAMETERS__PHI_F=0.85 - - RUN_INTERVAL=6000 + - PROTOCOL_PARAMETERS__K=3 + - PROTOCOL_PARAMETERS__M=50 + - PROTOCOL_PARAMETERS__PHI_F=0.67 + - RUN_INTERVAL=1000 - URL_SNAPSHOT_MANIFEST= - SNAPSHOT_STORE_TYPE=local - SNAPSHOT_UPLOADER_TYPE=local @@ -36,8 +36,8 @@ services: - SIGNED_ENTITY_TYPES=CardanoTransactions - CURRENT_ERA_EPOCH=0 - ERA_ADAPTER_TYPE=bootstrap - - CARDANO_TRANSACTIONS_SIGNING_CONFIG__STEP=15 - - CARDANO_TRANSACTIONS_SIGNING_CONFIG__SECURITY_PARAMETER=30 + - CARDANO_TRANSACTIONS_SIGNING_CONFIG__STEP=5 + - CARDANO_TRANSACTIONS_SIGNING_CONFIG__SECURITY_PARAMETER=15 command: [ "-vvv", @@ -46,7 +46,7 @@ services: mithril-aggregator-genesis: image: ${MITHRIL_AGGREGATOR_IMAGE} - # user: "${UID:-1000}:${GID:-1000}" + user: "${UID:-1000}:${GID:-1000}" profiles: - mithril-genesis volumes: @@ -61,10 +61,10 @@ services: - GOOGLE_APPLICATION_CREDENTIALS_JSON= - NETWORK=devnet - NETWORK_MAGIC=42 - - PROTOCOL_PARAMETERS__K=5 - - PROTOCOL_PARAMETERS__M=100 - - PROTOCOL_PARAMETERS__PHI_F=0.85 - - RUN_INTERVAL=6000 + - PROTOCOL_PARAMETERS__K=3 + - PROTOCOL_PARAMETERS__M=50 + - PROTOCOL_PARAMETERS__PHI_F=0.67 + - RUN_INTERVAL=1000 - URL_SNAPSHOT_MANIFEST= - SNAPSHOT_STORE_TYPE=local - SNAPSHOT_UPLOADER_TYPE=local @@ -82,8 +82,8 @@ services: - SIGNED_ENTITY_TYPES=CardanoTransactions - CURRENT_ERA_EPOCH=0 - ERA_ADAPTER_TYPE=bootstrap - - CARDANO_TRANSACTIONS_SIGNING_CONFIG__STEP=15 - - CARDANO_TRANSACTIONS_SIGNING_CONFIG__SECURITY_PARAMETER=30 + - CARDANO_TRANSACTIONS_SIGNING_CONFIG__STEP=5 + - CARDANO_TRANSACTIONS_SIGNING_CONFIG__SECURITY_PARAMETER=15 command: [ "-vvv", @@ -105,7 +105,7 @@ services: - AGGREGATOR_ENDPOINT=http://mithril-aggregator:8080/aggregator - NETWORK=devnet - NETWORK_MAGIC=42 - - RUN_INTERVAL=6000 + - RUN_INTERVAL=1000 - DB_DIRECTORY=/data/db - DATA_STORES_DIRECTORY=/mithril/signer-1/stores - CARDANO_NODE_SOCKET_PATH=/data/node.socket @@ -133,7 +133,7 @@ services: - AGGREGATOR_ENDPOINT=http://mithril-aggregator:8080/aggregator - NETWORK=devnet - NETWORK_MAGIC=42 - - RUN_INTERVAL=6000 + - RUN_INTERVAL=1000 - DB_DIRECTORY=/data/db - DATA_STORES_DIRECTORY=/mithril/signer-2/stores - CARDANO_NODE_SOCKET_PATH=/data/node.socket From a1be7920168e4d6c1b156d3351cf7e235a7327f1 Mon Sep 17 00:00:00 2001 From: Giovanni Gargiulo Date: Thu, 14 Aug 2025 12:06:25 +0100 Subject: [PATCH 02/27] chore: root on macos and user on linux --- caribic/src/start.rs | 4 +++- caribic/src/utils.rs | 21 +++++++++++++++------ chains/cardano/docker-compose.yaml | 2 +- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/caribic/src/start.rs b/caribic/src/start.rs index 253fa1780..b4a497ba6 100644 --- a/caribic/src/start.rs +++ b/caribic/src/start.rs @@ -26,7 +26,9 @@ use std::process::Command; use std::time::Duration; use std::u64; -/// Get environment variables for Docker Compose, including UID/GID on Unix systems +/// Get environment variables for Docker Compose, including UID/GID +/// - macOS: Uses 0:0 (root) for compatibility +/// - Linux: Uses actual user UID/GID fn get_docker_env_vars() -> Vec<(&'static str, String)> { let (uid, gid) = get_user_ids(); vec![ diff --git a/caribic/src/utils.rs b/caribic/src/utils.rs index 8daa0bd38..f110a654b 100644 --- a/caribic/src/utils.rs +++ b/caribic/src/utils.rs @@ -23,7 +23,7 @@ use std::{error::Error, process::Output}; use tokio::io::AsyncWriteExt; use zip::read::ZipArchive; -#[cfg(unix)] +#[cfg(target_os = "linux")] use nix::unistd::{Uid, Gid}; pub fn print_header() { @@ -590,19 +590,28 @@ pub fn query_balance(project_root_path: &Path, address: &str) -> u64 { .sum() } -/// Get current user's UID and GID for Docker containers (Unix only) -/// Returns (UID, GID) or default (1000, 1000) on non-Unix systems +/// Get current user's UID and GID for Docker containers +/// - macOS: Returns 0:0 (root) for compatibility +/// - Linux: Returns actual user UID/GID +/// - Windows: Returns default 1000:1000 pub fn get_user_ids() -> (String, String) { - #[cfg(unix)] + #[cfg(target_os = "macos")] + { + // Use root permissions on macOS + ("0".to_string(), "0".to_string()) + } + + #[cfg(target_os = "linux")] { + // Use actual user UID/GID on Linux let uid = Uid::current().as_raw(); let gid = Gid::current().as_raw(); (uid.to_string(), gid.to_string()) } - #[cfg(not(unix))] + #[cfg(not(any(target_os = "macos", target_os = "linux")))] { - // Default UID/GID for non-Unix systems (Windows) + // Default UID/GID for other systems (Windows, etc.) ("1000".to_string(), "1000".to_string()) } } diff --git a/chains/cardano/docker-compose.yaml b/chains/cardano/docker-compose.yaml index babcd6d50..ff8b27a25 100644 --- a/chains/cardano/docker-compose.yaml +++ b/chains/cardano/docker-compose.yaml @@ -97,7 +97,7 @@ services: - ./kupo-db:/db postgres: - image: postgres:14.10-alpine + image: postgres:15 user: "${UID:-1000}:${GID:-1000}" environment: - POSTGRES_LOGGING=true From b8f3f5e9e49276512d2454d047cfd78752ac7f16 Mon Sep 17 00:00:00 2001 From: Giovanni Gargiulo Date: Fri, 15 Aug 2025 16:33:25 +0100 Subject: [PATCH 03/27] chore: added missing gid/uid --- chains/mithrils/scripts/docker-compose.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/chains/mithrils/scripts/docker-compose.yaml b/chains/mithrils/scripts/docker-compose.yaml index 592a0b3f6..9e13a88d7 100644 --- a/chains/mithrils/scripts/docker-compose.yaml +++ b/chains/mithrils/scripts/docker-compose.yaml @@ -1,6 +1,7 @@ services: mithril-aggregator: image: ${MITHRIL_AGGREGATOR_IMAGE} + user: "${UID:-1000}:${GID:-1000}" restart: always profiles: - mithril @@ -92,6 +93,7 @@ services: ] mithril-signer-1: image: ${MITHRIL_SIGNER_IMAGE} + user: "${UID:-1000}:${GID:-1000}" restart: always profiles: - mithril @@ -120,6 +122,7 @@ services: mithril-signer-2: image: ${MITHRIL_SIGNER_IMAGE} + user: "${UID:-1000}:${GID:-1000}" restart: always profiles: - mithril From 5037cb727a14167e9893e2a5255477e324f36b04 Mon Sep 17 00:00:00 2001 From: Giovanni Gargiulo Date: Tue, 2 Sep 2025 12:47:59 +0100 Subject: [PATCH 04/27] chore: rolling back to older version --- caribic/src/setup.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/caribic/src/setup.rs b/caribic/src/setup.rs index 391f83eac..1f8b85b2e 100644 --- a/caribic/src/setup.rs +++ b/caribic/src/setup.rs @@ -82,7 +82,7 @@ pub async fn download_mithril(mithril_path: &Path) -> Result<(), Box Result<(), Box> { - let url = "https://github.com/osmosis-labs/osmosis/archive/refs/tags/v30.0.1.zip"; + let url = "https://github.com/osmosis-labs/osmosis/archive/refs/tags/v25.2.0.zip"; download_repository(url, osmosis_path, "osmosis").await } From 324788ea23baacd8befbf8e001ca70132ed3c3e3 Mon Sep 17 00:00:00 2001 From: Giovanni Gargiulo Date: Tue, 2 Sep 2025 14:25:04 +0100 Subject: [PATCH 05/27] chore: fully rolled back osmosis --- chains/osmosis/configuration/Dockerfile | 7 +++---- chains/osmosis/configuration/docker-compose.yml | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/chains/osmosis/configuration/Dockerfile b/chains/osmosis/configuration/Dockerfile index 4fea3bd7a..51c2f23c4 100644 --- a/chains/osmosis/configuration/Dockerfile +++ b/chains/osmosis/configuration/Dockerfile @@ -2,7 +2,7 @@ # Please, when adding/editing this Dockerfile also take care of Dockerfile.cosmovisor as well -ARG GO_VERSION="1.23" +ARG GO_VERSION="1.21" ARG RUNNER_IMAGE="gcr.io/distroless/static-debian11" ARG BUILD_TAGS="netgo,ledger,muslc" @@ -10,7 +10,7 @@ ARG BUILD_TAGS="netgo,ledger,muslc" # Builder # -------------------------------------------------------- -FROM golang:${GO_VERSION}-alpine3.20 as builder +FROM golang:${GO_VERSION}-alpine3.18 as builder ARG GIT_VERSION ARG GIT_COMMIT @@ -19,8 +19,7 @@ ARG BUILD_TAGS RUN apk add --no-cache \ ca-certificates \ build-base \ - linux-headers \ - binutils-gold + linux-headers # Download go dependencies WORKDIR /osmosis diff --git a/chains/osmosis/configuration/docker-compose.yml b/chains/osmosis/configuration/docker-compose.yml index f19107663..cdcd62748 100644 --- a/chains/osmosis/configuration/docker-compose.yml +++ b/chains/osmosis/configuration/docker-compose.yml @@ -5,8 +5,8 @@ services: context: ../../ dockerfile: Dockerfile args: - RUNNER_IMAGE: alpine:3.19 - GO_VERSION: "1.23" + RUNNER_IMAGE: golang:1.21.7-alpine3.19 + GO_VERSION: "1.21" volumes: - ./scripts/uosmoUionBalancerPool.json:/osmosis/uosmoUionBalancerPool.json - ./scripts/uosmoUusdcBalancerPool.json:/osmosis/uosmoUusdcBalancerPool.json From 25db7b5d8e57629fcf6c3a3e8c46b8e363802940 Mon Sep 17 00:00:00 2001 From: Giovanni Gargiulo Date: Tue, 2 Sep 2025 14:30:52 +0100 Subject: [PATCH 06/27] chore: fully rolled back osmosis --- chains/osmosis/configuration/Dockerfile | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/chains/osmosis/configuration/Dockerfile b/chains/osmosis/configuration/Dockerfile index 51c2f23c4..1f8cbfaef 100644 --- a/chains/osmosis/configuration/Dockerfile +++ b/chains/osmosis/configuration/Dockerfile @@ -1,7 +1,5 @@ # syntax=docker/dockerfile:1 -# Please, when adding/editing this Dockerfile also take care of Dockerfile.cosmovisor as well - ARG GO_VERSION="1.21" ARG RUNNER_IMAGE="gcr.io/distroless/static-debian11" ARG BUILD_TAGS="netgo,ledger,muslc" @@ -29,12 +27,12 @@ RUN --mount=type=cache,target=/root/.cache/go-build \ go mod download # Cosmwasm - Download correct libwasmvm version -RUN ARCH=$(uname -m) && WASMVM_VERSION=$(go list -m github.com/CosmWasm/wasmvm/v2 | sed 's/.* //') && \ +RUN ARCH=$(uname -m) && WASMVM_VERSION=$(go list -m github.com/CosmWasm/wasmvm | sed 's/.* //') && \ wget https://github.com/CosmWasm/wasmvm/releases/download/$WASMVM_VERSION/libwasmvm_muslc.$ARCH.a \ - -O /lib/libwasmvm_muslc.$ARCH.a && \ + -O /lib/libwasmvm_muslc.a && \ # verify checksum wget https://github.com/CosmWasm/wasmvm/releases/download/$WASMVM_VERSION/checksums.txt -O /tmp/checksums.txt && \ - sha256sum /lib/libwasmvm_muslc.$ARCH.a | grep $(cat /tmp/checksums.txt | grep libwasmvm_muslc.$ARCH | cut -d ' ' -f 1) + sha256sum /lib/libwasmvm_muslc.a | grep $(cat /tmp/checksums.txt | grep libwasmvm_muslc.$ARCH | cut -d ' ' -f 1) # Copy the remaining files COPY . . @@ -44,7 +42,7 @@ RUN --mount=type=cache,target=/root/.cache/go-build \ --mount=type=cache,target=/root/go/pkg/mod \ GOWORK=off go build \ -mod=readonly \ - -tags "netgo,ledger,muslc" \ + -tags ${BUILD_TAGS} \ -ldflags \ "-X github.com/cosmos/cosmos-sdk/version.Name="osmosis" \ -X github.com/cosmos/cosmos-sdk/version.AppName="osmosisd" \ @@ -64,7 +62,7 @@ FROM ${RUNNER_IMAGE} COPY --from=builder /osmosis/build/osmosisd /bin/osmosisd -ENV HOME=/osmosis +ENV HOME /osmosis WORKDIR $HOME EXPOSE 26656 From 1be39f29fae413854d04a4b8bda6f25196ea0725 Mon Sep 17 00:00:00 2001 From: Giovanni Gargiulo Date: Wed, 3 Sep 2025 10:36:46 +0100 Subject: [PATCH 07/27] chore: added creation or recreation of the .osmosisd-local --- caribic/src/start.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/caribic/src/start.rs b/caribic/src/start.rs index b4a497ba6..74443b039 100644 --- a/caribic/src/start.rs +++ b/caribic/src/start.rs @@ -801,11 +801,11 @@ fn remove_previous_chain_data() -> Result<(), fs_extra::error::Error> { if let Some(home_path) = home_dir() { let osmosis_data_dir = home_path.join(".osmosisd-local"); if osmosis_data_dir.exists() { - remove_dir_all(osmosis_data_dir)?; - Ok(()) - } else { - Ok(()) + remove_dir_all(&osmosis_data_dir)?; } + fs::create_dir_all(&osmosis_data_dir) + .map_err(|e| fs_extra::error::Error::Io(e))?; + Ok(()) } else { Ok(()) } From bdf17b3481fa9c25b6fb28cbbea91b4c61d074bc Mon Sep 17 00:00:00 2001 From: Giovanni Gargiulo Date: Wed, 3 Sep 2025 10:38:54 +0100 Subject: [PATCH 08/27] chore: added creation or recreation of the .osmosisd-local --- caribic/src/start.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/caribic/src/start.rs b/caribic/src/start.rs index 74443b039..1f1fa5168 100644 --- a/caribic/src/start.rs +++ b/caribic/src/start.rs @@ -804,7 +804,7 @@ fn remove_previous_chain_data() -> Result<(), fs_extra::error::Error> { remove_dir_all(&osmosis_data_dir)?; } fs::create_dir_all(&osmosis_data_dir) - .map_err(|e| fs_extra::error::Error::Io(e))?; + .map_err(|e| fs_extra::error::Error::new(fs_extra::error::ErrorKind::Io(e), "Failed to create .osmosisd-local directory"))?; Ok(()) } else { Ok(()) From 3faa2a8253e378e556637dc975bf903213d49588 Mon Sep 17 00:00:00 2001 From: Giovanni Gargiulo Date: Wed, 3 Sep 2025 10:50:26 +0100 Subject: [PATCH 09/27] chore: create .hermes folder if missing --- caribic/src/start.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/caribic/src/start.rs b/caribic/src/start.rs index 1f1fa5168..6e706236a 100644 --- a/caribic/src/start.rs +++ b/caribic/src/start.rs @@ -588,6 +588,9 @@ pub fn configure_hermes(osmosis_dir: &Path) -> Result<(), Box Date: Wed, 3 Sep 2025 11:06:51 +0100 Subject: [PATCH 10/27] chore: don't delete osmosid.local --- caribic/src/start.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/caribic/src/start.rs b/caribic/src/start.rs index 6e706236a..f6e58b72d 100644 --- a/caribic/src/start.rs +++ b/caribic/src/start.rs @@ -550,7 +550,8 @@ pub async fn prepare_osmosis(osmosis_dir: &Path) -> Result<(), Box { verbose("✅ Osmosis configuration files copied successfully"); - remove_previous_chain_data()?; + // This should not be required as each time it's restarted it wipes the .osmosisd-local data + // remove_previous_chain_data()?; init_local_network(osmosis_dir)?; Ok(()) } From 872189c0413d5adb25a6e179eae0156b52dd7963 Mon Sep 17 00:00:00 2001 From: Giovanni Gargiulo Date: Thu, 4 Sep 2025 15:07:51 +0100 Subject: [PATCH 11/27] chore: restore latest osmosis --- caribic/src/setup.rs | 2 +- chains/osmosis/configuration/Dockerfile | 19 +++++++++++-------- .../osmosis/configuration/docker-compose.yml | 6 +++--- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/caribic/src/setup.rs b/caribic/src/setup.rs index 1f8b85b2e..391f83eac 100644 --- a/caribic/src/setup.rs +++ b/caribic/src/setup.rs @@ -82,7 +82,7 @@ pub async fn download_mithril(mithril_path: &Path) -> Result<(), Box Result<(), Box> { - let url = "https://github.com/osmosis-labs/osmosis/archive/refs/tags/v25.2.0.zip"; + let url = "https://github.com/osmosis-labs/osmosis/archive/refs/tags/v30.0.1.zip"; download_repository(url, osmosis_path, "osmosis").await } diff --git a/chains/osmosis/configuration/Dockerfile b/chains/osmosis/configuration/Dockerfile index 1f8cbfaef..4fea3bd7a 100644 --- a/chains/osmosis/configuration/Dockerfile +++ b/chains/osmosis/configuration/Dockerfile @@ -1,6 +1,8 @@ # syntax=docker/dockerfile:1 -ARG GO_VERSION="1.21" +# Please, when adding/editing this Dockerfile also take care of Dockerfile.cosmovisor as well + +ARG GO_VERSION="1.23" ARG RUNNER_IMAGE="gcr.io/distroless/static-debian11" ARG BUILD_TAGS="netgo,ledger,muslc" @@ -8,7 +10,7 @@ ARG BUILD_TAGS="netgo,ledger,muslc" # Builder # -------------------------------------------------------- -FROM golang:${GO_VERSION}-alpine3.18 as builder +FROM golang:${GO_VERSION}-alpine3.20 as builder ARG GIT_VERSION ARG GIT_COMMIT @@ -17,7 +19,8 @@ ARG BUILD_TAGS RUN apk add --no-cache \ ca-certificates \ build-base \ - linux-headers + linux-headers \ + binutils-gold # Download go dependencies WORKDIR /osmosis @@ -27,12 +30,12 @@ RUN --mount=type=cache,target=/root/.cache/go-build \ go mod download # Cosmwasm - Download correct libwasmvm version -RUN ARCH=$(uname -m) && WASMVM_VERSION=$(go list -m github.com/CosmWasm/wasmvm | sed 's/.* //') && \ +RUN ARCH=$(uname -m) && WASMVM_VERSION=$(go list -m github.com/CosmWasm/wasmvm/v2 | sed 's/.* //') && \ wget https://github.com/CosmWasm/wasmvm/releases/download/$WASMVM_VERSION/libwasmvm_muslc.$ARCH.a \ - -O /lib/libwasmvm_muslc.a && \ + -O /lib/libwasmvm_muslc.$ARCH.a && \ # verify checksum wget https://github.com/CosmWasm/wasmvm/releases/download/$WASMVM_VERSION/checksums.txt -O /tmp/checksums.txt && \ - sha256sum /lib/libwasmvm_muslc.a | grep $(cat /tmp/checksums.txt | grep libwasmvm_muslc.$ARCH | cut -d ' ' -f 1) + sha256sum /lib/libwasmvm_muslc.$ARCH.a | grep $(cat /tmp/checksums.txt | grep libwasmvm_muslc.$ARCH | cut -d ' ' -f 1) # Copy the remaining files COPY . . @@ -42,7 +45,7 @@ RUN --mount=type=cache,target=/root/.cache/go-build \ --mount=type=cache,target=/root/go/pkg/mod \ GOWORK=off go build \ -mod=readonly \ - -tags ${BUILD_TAGS} \ + -tags "netgo,ledger,muslc" \ -ldflags \ "-X github.com/cosmos/cosmos-sdk/version.Name="osmosis" \ -X github.com/cosmos/cosmos-sdk/version.AppName="osmosisd" \ @@ -62,7 +65,7 @@ FROM ${RUNNER_IMAGE} COPY --from=builder /osmosis/build/osmosisd /bin/osmosisd -ENV HOME /osmosis +ENV HOME=/osmosis WORKDIR $HOME EXPOSE 26656 diff --git a/chains/osmosis/configuration/docker-compose.yml b/chains/osmosis/configuration/docker-compose.yml index cdcd62748..db7b29092 100644 --- a/chains/osmosis/configuration/docker-compose.yml +++ b/chains/osmosis/configuration/docker-compose.yml @@ -5,8 +5,8 @@ services: context: ../../ dockerfile: Dockerfile args: - RUNNER_IMAGE: golang:1.21.7-alpine3.19 - GO_VERSION: "1.21" + RUNNER_IMAGE: alpine:3.19 + GO_VERSION: "1.23" volumes: - ./scripts/uosmoUionBalancerPool.json:/osmosis/uosmoUionBalancerPool.json - ./scripts/uosmoUusdcBalancerPool.json:/osmosis/uosmoUusdcBalancerPool.json @@ -36,4 +36,4 @@ services: - 6379:6379 - 8001:8001 volumes: - - ./redis-data:/data + - ./redis-data:/data \ No newline at end of file From 1ac180b16d551acc02adf810dc16b5276de57754 Mon Sep 17 00:00:00 2001 From: Giovanni Gargiulo Date: Fri, 5 Sep 2025 10:47:38 +0100 Subject: [PATCH 12/27] chore: removed overwriting compose/dockerfile --- caribic/src/start.rs | 50 ++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/caribic/src/start.rs b/caribic/src/start.rs index f6e58b72d..1cfad5b39 100644 --- a/caribic/src/start.rs +++ b/caribic/src/start.rs @@ -870,31 +870,31 @@ fn copy_osmosis_config_files(osmosis_dir: &Path) -> Result<(), fs_extra::error:: &options, )?; - verbose(&format!( - "Copying docker-compose.yml from {} to {}", - osmosis_dir - .join("../configuration/docker-compose.yml") - .display(), - osmosis_dir - .join("tests/localosmosis/docker-compose.yml") - .display() - )); - copy( - osmosis_dir.join("../configuration/docker-compose.yml"), - osmosis_dir.join("tests/localosmosis/docker-compose.yml"), - &options, - )?; - - verbose(&format!( - "Copying Dockerfile from {} to {}", - osmosis_dir.join("../configuration/Dockerfile").display(), - osmosis_dir.join("Dockerfile").display() - )); - copy( - osmosis_dir.join("../configuration/Dockerfile"), - osmosis_dir.join("Dockerfile"), - &options, - )?; + // verbose(&format!( + // "Copying docker-compose.yml from {} to {}", + // osmosis_dir + // .join("../configuration/docker-compose.yml") + // .display(), + // osmosis_dir + // .join("tests/localosmosis/docker-compose.yml") + // .display() + // )); + // copy( + // osmosis_dir.join("../configuration/docker-compose.yml"), + // osmosis_dir.join("tests/localosmosis/docker-compose.yml"), + // &options, + // )?; + + // verbose(&format!( + // "Copying Dockerfile from {} to {}", + // osmosis_dir.join("../configuration/Dockerfile").display(), + // osmosis_dir.join("Dockerfile").display() + // )); + // copy( + // osmosis_dir.join("../configuration/Dockerfile"), + // osmosis_dir.join("Dockerfile"), + // &options, + // )?; Ok(()) } From 2d1117bcb3837eaf8a648ec26b9c325f3972798a Mon Sep 17 00:00:00 2001 From: Giovanni Gargiulo Date: Fri, 5 Sep 2025 14:45:15 +0100 Subject: [PATCH 13/27] chore: uncomment stuff --- caribic/src/start.rs | 50 ++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/caribic/src/start.rs b/caribic/src/start.rs index 1cfad5b39..f6e58b72d 100644 --- a/caribic/src/start.rs +++ b/caribic/src/start.rs @@ -870,31 +870,31 @@ fn copy_osmosis_config_files(osmosis_dir: &Path) -> Result<(), fs_extra::error:: &options, )?; - // verbose(&format!( - // "Copying docker-compose.yml from {} to {}", - // osmosis_dir - // .join("../configuration/docker-compose.yml") - // .display(), - // osmosis_dir - // .join("tests/localosmosis/docker-compose.yml") - // .display() - // )); - // copy( - // osmosis_dir.join("../configuration/docker-compose.yml"), - // osmosis_dir.join("tests/localosmosis/docker-compose.yml"), - // &options, - // )?; - - // verbose(&format!( - // "Copying Dockerfile from {} to {}", - // osmosis_dir.join("../configuration/Dockerfile").display(), - // osmosis_dir.join("Dockerfile").display() - // )); - // copy( - // osmosis_dir.join("../configuration/Dockerfile"), - // osmosis_dir.join("Dockerfile"), - // &options, - // )?; + verbose(&format!( + "Copying docker-compose.yml from {} to {}", + osmosis_dir + .join("../configuration/docker-compose.yml") + .display(), + osmosis_dir + .join("tests/localosmosis/docker-compose.yml") + .display() + )); + copy( + osmosis_dir.join("../configuration/docker-compose.yml"), + osmosis_dir.join("tests/localosmosis/docker-compose.yml"), + &options, + )?; + + verbose(&format!( + "Copying Dockerfile from {} to {}", + osmosis_dir.join("../configuration/Dockerfile").display(), + osmosis_dir.join("Dockerfile").display() + )); + copy( + osmosis_dir.join("../configuration/Dockerfile"), + osmosis_dir.join("Dockerfile"), + &options, + )?; Ok(()) } From 1b83f23f9a35f98036212f231fccdb1e15d8b570 Mon Sep 17 00:00:00 2001 From: Giovanni Gargiulo Date: Mon, 8 Sep 2025 10:06:37 +0100 Subject: [PATCH 14/27] chore: attempt to set user's permissions to .osmosisd.local folder --- caribic/src/start.rs | 13 ++++++++++--- chains/osmosis/configuration/docker-compose.yml | 1 + 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/caribic/src/start.rs b/caribic/src/start.rs index f6e58b72d..e8e4ac9f8 100644 --- a/caribic/src/start.rs +++ b/caribic/src/start.rs @@ -787,15 +787,22 @@ pub fn configure_hermes(osmosis_dir: &Path) -> Result<(), Box Result<(), Box> { + let docker_env = get_docker_env_vars(); + let docker_env_refs: Vec<(&str, &str)> = docker_env.iter() + .map(|(k, v)| (*k, v.as_str())) + .collect(); + if logger::is_quite() { - execute_script(osmosis_dir, "make", Vec::from(["localnet-init"]), None)?; + execute_script(osmosis_dir, "make", Vec::from(["localnet-init"]), Some(docker_env_refs))?; Ok(()) } else { - execute_script_with_progress( + // Note: execute_script_with_progress doesn't support environment variables + // Using regular execute_script for localnet-init with UID/GID support + execute_script( osmosis_dir, "make", Vec::from(["localnet-init"]), - "Initialize local Osmosis network", + Some(docker_env_refs), )?; Ok(()) } diff --git a/chains/osmosis/configuration/docker-compose.yml b/chains/osmosis/configuration/docker-compose.yml index db7b29092..7d96f9067 100644 --- a/chains/osmosis/configuration/docker-compose.yml +++ b/chains/osmosis/configuration/docker-compose.yml @@ -1,6 +1,7 @@ services: osmosisd: image: local:osmosis + user: "${UID:-1000}:${GID:-1000}" build: context: ../../ dockerfile: Dockerfile From 1854051ee6b36093c745a46d08e8845052f162bd Mon Sep 17 00:00:00 2001 From: Giovanni Gargiulo Date: Mon, 8 Sep 2025 11:50:46 +0100 Subject: [PATCH 15/27] chore: added missing uid gid --- cosmos/docker-compose.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/cosmos/docker-compose.yml b/cosmos/docker-compose.yml index 62bbfd6f7..553695973 100644 --- a/cosmos/docker-compose.yml +++ b/cosmos/docker-compose.yml @@ -1,6 +1,7 @@ services: sidechain-node-prod: container_name: sidechain-node-prod + user: "${UID:-1000}:${GID:-1000}" build: context: . dockerfile: Dockerfile From 774b2e511b18ac0a8a8fe2d6bb870f036396a8d4 Mon Sep 17 00:00:00 2001 From: Giovanni Gargiulo Date: Mon, 8 Sep 2025 12:05:06 +0100 Subject: [PATCH 16/27] chore: creating .osmosisd-local --- caribic/src/start.rs | 11 +++++++++++ cosmos/docker-compose.yml | 1 - 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/caribic/src/start.rs b/caribic/src/start.rs index e8e4ac9f8..be9dbd197 100644 --- a/caribic/src/start.rs +++ b/caribic/src/start.rs @@ -547,6 +547,17 @@ pub async fn start_osmosis(osmosis_dir: &Path) -> Result<(), Box Result<(), Box> { check_osmosisd(osmosis_dir).await; + + // Ensure .osmosisd-local directory exists + if let Some(home_path) = home_dir() { + let osmosis_data_dir = home_path.join(".osmosisd-local"); + if !osmosis_data_dir.exists() { + fs::create_dir_all(&osmosis_data_dir) + .map_err(|e| format!("Failed to create .osmosisd-local directory: {}", e))?; + verbose("✅ Created .osmosisd-local directory"); + } + } + match copy_osmosis_config_files(osmosis_dir) { Ok(_) => { verbose("✅ Osmosis configuration files copied successfully"); diff --git a/cosmos/docker-compose.yml b/cosmos/docker-compose.yml index 553695973..62bbfd6f7 100644 --- a/cosmos/docker-compose.yml +++ b/cosmos/docker-compose.yml @@ -1,7 +1,6 @@ services: sidechain-node-prod: container_name: sidechain-node-prod - user: "${UID:-1000}:${GID:-1000}" build: context: . dockerfile: Dockerfile From 778b96dcd1d581e725ced5c1b9cd3f649275695c Mon Sep 17 00:00:00 2001 From: Giovanni Gargiulo Date: Mon, 8 Sep 2025 12:47:51 +0100 Subject: [PATCH 17/27] chore: updated makefile --- caribic/src/start.rs | 16 ++++++++++++++++ chains/osmosis/configuration/docker-compose.yml | 1 - 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/caribic/src/start.rs b/caribic/src/start.rs index be9dbd197..8f5016642 100644 --- a/caribic/src/start.rs +++ b/caribic/src/start.rs @@ -873,6 +873,22 @@ fn copy_osmosis_config_files(osmosis_dir: &Path) -> Result<(), fs_extra::error:: &options, )?; + verbose(&format!( + "Copying localnet.mk from {} to {}", + osmosis_dir + .join("../scripts/localnet.mk") + .display(), + osmosis_dir + .join("scripts/makefiles/localnet.mk") + .display() + )); + copy( + osmosis_dir.join("../scripts/localnet.mk"), + osmosis_dir.join("scripts/makefiles/localnet.mk"), + &options, + )?; + + verbose(&format!( "Copying setup_osmosis_local.sh from {} to {}", osmosis_dir diff --git a/chains/osmosis/configuration/docker-compose.yml b/chains/osmosis/configuration/docker-compose.yml index 7d96f9067..db7b29092 100644 --- a/chains/osmosis/configuration/docker-compose.yml +++ b/chains/osmosis/configuration/docker-compose.yml @@ -1,7 +1,6 @@ services: osmosisd: image: local:osmosis - user: "${UID:-1000}:${GID:-1000}" build: context: ../../ dockerfile: Dockerfile From dc934a8bea65d0c319f72f3f8ec63c840d318d46 Mon Sep 17 00:00:00 2001 From: Giovanni Gargiulo Date: Mon, 8 Sep 2025 12:49:04 +0100 Subject: [PATCH 18/27] chore: added missing file --- chains/osmosis/scripts/localnet.mk | 126 +++++++++++++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100644 chains/osmosis/scripts/localnet.mk diff --git a/chains/osmosis/scripts/localnet.mk b/chains/osmosis/scripts/localnet.mk new file mode 100644 index 000000000..4ffbe05c8 --- /dev/null +++ b/chains/osmosis/scripts/localnet.mk @@ -0,0 +1,126 @@ +############################################################################### +### Localnet ### +############################################################################### +# +# Please refer to https://github.com/osmosis-labs/osmosis/blob/main/tests/localosmosis/README.md for detailed +# usage of localnet. + +localnet-help: + @echo "localnet subcommands" + @echo "" + @echo "Usage:" + @echo " make localnet-[command]" + @echo "" + @echo "Available Commands:" + @echo " build Build localnet" + @echo " clean Clean localnet" + @echo " cl-add-to-positions Add to positions" + @echo " cl-claim-spread-rewards Claim spread rewards" + @echo " cl-claim-incentives Claim incentives" + @echo " cl-create-bigbang-config Create Big Bang configuration" + @echo " cl-create-pool Create concentrated liquidity pool" + @echo " cl-create-positions Create concentrated liquidity positions" + @echo " cl-small-swap Perform small randomized swaps" + @echo " cl-external-incentive Create external incentive" + @echo " cl-large-swap Perform large swaps" + @echo " cl-positions-large-swaps Create positions and perform large swaps" + @echo " cl-positions-small-swaps Create positions and perform small swaps" + @echo " cl-refresh-subgraph-genesis Refresh subgraph genesis" + @echo " cl-refresh-subgraph-positions Refresh subgraph positions" + @echo " cl-withdraw-positions Withdraw positions" + @echo " init Initialize localnet" + @echo " keys Add keys for localnet" + @echo " start Start localnet" + @echo " start-with-state Start localnet with state" + @echo " startd Start localnet in detached mode" + @echo " startd-with-state Start localnet in detached mode with state" + @echo " stop Stop localnet" +localnet: localnet-help + +localnet-keys: + . tests/localosmosis/scripts/add_keys.sh + +localnet-init: localnet-clean localnet-build + +localnet-build: + @DOCKER_BUILDKIT=1 COMPOSE_DOCKER_CLI_BUILD=1 docker compose -f tests/localosmosis/docker-compose.yml build + +localnet-start: + @STATE="" docker compose -f tests/localosmosis/docker-compose.yml up + +localnet-startd: + @STATE="" docker compose -f tests/localosmosis/docker-compose.yml up -d + +localnet-stop: + @STATE="" docker compose -f tests/localosmosis/docker-compose.yml down + +localnet-clean: + @sudo rm -rfI $(HOME)/.osmosisd-local/ + +# create 100 concentrated-liquidity positions in localosmosis at pool id 1 +localnet-cl-create-positions: + go run tests/cl-go-client/main.go --operation 0 + +# does 100 small randomized swaps in localosmosis at pool id 1 +localnet-cl-small-swap: + go run tests/cl-go-client/main.go --operation 1 + +# does 100 large swaps where the output of the previous swap is swapped back at the +# next swap. localosmosis at pool id 1 +localnet-cl-large-swap: + go run tests/cl-go-client/main.go --operation 2 + +# creates a gauge and waits for one epoch so that the gauge +# is converted into an incentive record for pool id 1. +localnet-cl-external-incentive: + go run tests/cl-go-client/main.go --operation 3 + +# attempts to create a CL pool at id 1. +# if pool already exists, this is a no-op. +# if pool with different id is desired, tweak expectedPoolId +# in the script. +localnet-cl-create-pool: + go run tests/cl-go-client/main.go --operation 4 + +# claims spread rewards for a random account for a random +# subset of positions. +localnet-cl-claim-spread-rewards: + go run tests/cl-go-client/main.go --operation 5 + +# claims incentives for a random account for a random +# subset of positions. +localnet-cl-claim-incentives: + go run tests/cl-go-client/main.go --operation 6 + +localnet-cl-add-to-positions: + go run tests/cl-go-client/main.go --operation 7 + +localnet-cl-withdraw-positions: + go run tests/cl-go-client/main.go --operation 8 + +# does both of localnet-cl-create-positions and localnet-cl-small-swap +localnet-cl-positions-small-swaps: localnet-cl-create-positions localnet-cl-small-swap + +# does both of localnet-cl-create-positions and localnet-cl-large-swap +localnet-cl-positions-large-swaps: localnet-cl-create-positions localnet-cl-large-swap + +# This script retrieves Uniswap v3 Ethereum position data +# from subgraph. It uses WETH / USDC pool. This is helpful +# for setting up somewhat realistic positions for testing +# in localosmosis. It writes the file under +# tests/cl-genesis-positions/subgraph_positions.json +localnet-cl-refresh-subgraph-positions: + go run ./tests/cl-genesis-positions --operation 0 + +# This script converts the positions data created by the +# cl-refresh-subgraph-positions makefile step into an Osmosis +# genesis. It writes the file under tests/cl-genesis-positions/genesis.json +localnet-cl-refresh-subgraph-genesis: + go run ./tests/cl-genesis-positions --operation 1 + +# This script converts the positions data created by the +# cl-refresh-subgraph-positions makefile step into a Big Bang +# configuration file for spinning up testnets. +# It writes the file under tests/cl-genesis-positions/bigbang_positions.json +localnet-cl-create-bigbang-config: + go run ./tests/cl-genesis-positions --operation 1 --big-bang From 86329f7409ec9b240ab95f8e642db5d6c4c456ed Mon Sep 17 00:00:00 2001 From: Giovanni Gargiulo Date: Mon, 8 Sep 2025 12:52:16 +0100 Subject: [PATCH 19/27] chore: must run as admin or won't work. so must sudo rm -fr non interactive (might need to enter password) --- chains/osmosis/scripts/localnet.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chains/osmosis/scripts/localnet.mk b/chains/osmosis/scripts/localnet.mk index 4ffbe05c8..e9cc8f3e2 100644 --- a/chains/osmosis/scripts/localnet.mk +++ b/chains/osmosis/scripts/localnet.mk @@ -55,7 +55,7 @@ localnet-stop: @STATE="" docker compose -f tests/localosmosis/docker-compose.yml down localnet-clean: - @sudo rm -rfI $(HOME)/.osmosisd-local/ + sudo rm -rf $(HOME)/.osmosisd-local/ # create 100 concentrated-liquidity positions in localosmosis at pool id 1 localnet-cl-create-positions: From 2ead66d60134386953cf131009395ff4a95f6fea Mon Sep 17 00:00:00 2001 From: Giovanni Gargiulo Date: Mon, 8 Sep 2025 13:01:50 +0100 Subject: [PATCH 20/27] chore: fixed warnings --- caribic/src/start.rs | 18 +--- caribic/src/utils.rs | 194 +++++++++++++++++++++---------------------- 2 files changed, 99 insertions(+), 113 deletions(-) diff --git a/caribic/src/start.rs b/caribic/src/start.rs index 8f5016642..daafe5596 100644 --- a/caribic/src/start.rs +++ b/caribic/src/start.rs @@ -5,7 +5,7 @@ use crate::setup::{ prepare_db_sync_and_gateway, seed_cardano_devnet, }; use crate::utils::{ - copy_dir_all, download_file, execute_script, execute_script_with_progress, + copy_dir_all, download_file, execute_script, extract_tendermint_client_id, extract_tendermint_connection_id, get_cardano_state, get_user_ids, unzip_file, wait_for_health_check, wait_until_file_exists, CardanoQuery, IndicatorMessage, }; @@ -20,7 +20,7 @@ use fs_extra::file::copy; use indicatif::{ProgressBar, ProgressStyle}; use serde_json::Value; use std::cmp::min; -use std::fs::{self, remove_dir_all}; +use std::fs::{self}; use std::path::Path; use std::process::Command; use std::time::Duration; @@ -819,19 +819,7 @@ fn init_local_network(osmosis_dir: &Path) -> Result<(), Box Result<(), fs_extra::error::Error> { - if let Some(home_path) = home_dir() { - let osmosis_data_dir = home_path.join(".osmosisd-local"); - if osmosis_data_dir.exists() { - remove_dir_all(&osmosis_data_dir)?; - } - fs::create_dir_all(&osmosis_data_dir) - .map_err(|e| fs_extra::error::Error::new(fs_extra::error::ErrorKind::Io(e), "Failed to create .osmosisd-local directory"))?; - Ok(()) - } else { - Ok(()) - } -} + fn copy_osmosis_config_files(osmosis_dir: &Path) -> Result<(), fs_extra::error::Error> { verbose(&format!( diff --git a/caribic/src/utils.rs b/caribic/src/utils.rs index f110a654b..3528f8e26 100644 --- a/caribic/src/utils.rs +++ b/caribic/src/utils.rs @@ -1,10 +1,7 @@ -use crate::logger::{ - self, verbose, - Verbosity::{Info, Standard, Verbose}, -}; +use crate::logger::{self, verbose}; use console::style; use dirs::home_dir; -use indicatif::{ProgressBar, ProgressStyle}; +use indicatif::ProgressBar; use regex::Regex; use reqwest::Client; use serde_json::Value; @@ -16,15 +13,15 @@ use std::io::{self, BufReader, Write}; use std::os::unix::fs::PermissionsExt; use std::path::{Path, PathBuf}; use std::process::{Command, Stdio}; +use std::thread; use std::time::Duration; use std::{collections::HashMap, fs}; -use std::{collections::VecDeque, thread}; use std::{error::Error, process::Output}; use tokio::io::AsyncWriteExt; use zip::read::ZipArchive; #[cfg(target_os = "linux")] -use nix::unistd::{Uid, Gid}; +use nix::unistd::{Gid, Uid}; pub fn print_header() { println!( @@ -350,95 +347,96 @@ pub fn execute_script( Ok(output) } -pub fn execute_script_with_progress( - script_dir: &Path, - script_name: &str, - script_args: Vec<&str>, - start_message: &str, -) -> Result<(), Box> { - let progress_bar = ProgressBar::new_spinner(); - progress_bar.enable_steady_tick(Duration::from_millis(100)); - progress_bar.set_style( - ProgressStyle::with_template("{prefix:.bold} {spinner} {wide_msg}") - .unwrap() - .tick_chars("⠁⠂⠄⡀⢀⠠⠐⠈ "), - ); - - progress_bar.set_prefix(start_message.to_owned()); - - let mut command = Command::new(script_name) - .current_dir(script_dir) - .args(script_args) - .stdout(Stdio::piped()) - .stderr(Stdio::piped()) - .spawn() - .map_err(|error| format!("Failed to initialize localnet: {}", error))?; - - match logger::get_verbosity() { - Verbose => { - let stdout = command.stdout.as_mut().expect("Failed to open stdout"); - let reader = BufReader::new(stdout); - - for line in reader.lines() { - let line = line.unwrap_or_else(|_| "Failed to read line".to_string()); - progress_bar.set_message(format!("{}", line.trim())); - } - } - Info => { - let mut last_lines = VecDeque::with_capacity(5); - - if let Some(stdout) = command.stdout.take() { - let reader = BufReader::new(stdout); - - for line in reader.lines() { - let line = line.unwrap_or_else(|_| "Failed to read line".to_string()); - if last_lines.len() == 5 { - last_lines.pop_front(); - } - last_lines.push_back(line); - let output = last_lines - .iter() - .cloned() - .collect::>() - .join("\n"); - - progress_bar.set_message(format!("{}", output)); - } - } - } - Standard => { - if let Some(stdout) = command.stdout.take() { - let reader = BufReader::new(stdout); - - for line in reader.lines() { - let last_line = line.unwrap_or_else(|_| "Failed to read line".to_string()); - progress_bar.set_message(format!("{}", last_line.trim())); - } - } - } - _ => {} - } - - let status = command - .wait() - .map_err(|error| format!("Command wasn't running: {}", error))?; - progress_bar.finish_and_clear(); - if status.success() { - Ok(()) - } else { - let mut error_output = String::new(); - if let Some(stderr) = command.stderr.take() { - let reader = BufReader::new(stderr); - for line in reader.lines() { - let line = line.unwrap_or_else(|_| "Failed to read line".to_string()); - error_output.push_str(&line); - } - Err(error_output.into()) - } else { - Err("Failed to execute script".into()) - } - } -} +// commented out as there's no code calling it but could be usefule to have it around for the future +// pub fn execute_script_with_progress( +// script_dir: &Path, +// script_name: &str, +// script_args: Vec<&str>, +// start_message: &str, +// ) -> Result<(), Box> { +// let progress_bar = ProgressBar::new_spinner(); +// progress_bar.enable_steady_tick(Duration::from_millis(100)); +// progress_bar.set_style( +// ProgressStyle::with_template("{prefix:.bold} {spinner} {wide_msg}") +// .unwrap() +// .tick_chars("⠁⠂⠄⡀⢀⠠⠐⠈ "), +// ); + +// progress_bar.set_prefix(start_message.to_owned()); + +// let mut command = Command::new(script_name) +// .current_dir(script_dir) +// .args(script_args) +// .stdout(Stdio::piped()) +// .stderr(Stdio::piped()) +// .spawn() +// .map_err(|error| format!("Failed to initialize localnet: {}", error))?; + +// match logger::get_verbosity() { +// Verbose => { +// let stdout = command.stdout.as_mut().expect("Failed to open stdout"); +// let reader = BufReader::new(stdout); + +// for line in reader.lines() { +// let line = line.unwrap_or_else(|_| "Failed to read line".to_string()); +// progress_bar.set_message(format!("{}", line.trim())); +// } +// } +// Info => { +// let mut last_lines = VecDeque::with_capacity(5); + +// if let Some(stdout) = command.stdout.take() { +// let reader = BufReader::new(stdout); + +// for line in reader.lines() { +// let line = line.unwrap_or_else(|_| "Failed to read line".to_string()); +// if last_lines.len() == 5 { +// last_lines.pop_front(); +// } +// last_lines.push_back(line); +// let output = last_lines +// .iter() +// .cloned() +// .collect::>() +// .join("\n"); + +// progress_bar.set_message(format!("{}", output)); +// } +// } +// } +// Standard => { +// if let Some(stdout) = command.stdout.take() { +// let reader = BufReader::new(stdout); + +// for line in reader.lines() { +// let last_line = line.unwrap_or_else(|_| "Failed to read line".to_string()); +// progress_bar.set_message(format!("{}", last_line.trim())); +// } +// } +// } +// _ => {} +// } + +// let status = command +// .wait() +// .map_err(|error| format!("Command wasn't running: {}", error))?; +// progress_bar.finish_and_clear(); +// if status.success() { +// Ok(()) +// } else { +// let mut error_output = String::new(); +// if let Some(stderr) = command.stderr.take() { +// let reader = BufReader::new(stderr); +// for line in reader.lines() { +// let line = line.unwrap_or_else(|_| "Failed to read line".to_string()); +// error_output.push_str(&line); +// } +// Err(error_output.into()) +// } else { +// Err("Failed to execute script".into()) +// } +// } +// } pub fn unzip_file(file_path: &Path, destination: &Path) -> Result<(), Box> { // Open the ZIP file @@ -600,7 +598,7 @@ pub fn get_user_ids() -> (String, String) { // Use root permissions on macOS ("0".to_string(), "0".to_string()) } - + #[cfg(target_os = "linux")] { // Use actual user UID/GID on Linux @@ -608,7 +606,7 @@ pub fn get_user_ids() -> (String, String) { let gid = Gid::current().as_raw(); (uid.to_string(), gid.to_string()) } - + #[cfg(not(any(target_os = "macos", target_os = "linux")))] { // Default UID/GID for other systems (Windows, etc.) From 25041fa094c9d0c382bbdaab39fc1504ac143dfd Mon Sep 17 00:00:00 2001 From: Giovanni Gargiulo Date: Tue, 9 Sep 2025 11:16:42 +0100 Subject: [PATCH 21/27] chore: rolling back from unwanted changes --- caribic/src/start.rs | 101 +++++++++--------------- caribic/src/utils.rs | 181 ++++++++++++++++++++++--------------------- 2 files changed, 127 insertions(+), 155 deletions(-) diff --git a/caribic/src/start.rs b/caribic/src/start.rs index daafe5596..ec6f89ebf 100644 --- a/caribic/src/start.rs +++ b/caribic/src/start.rs @@ -5,9 +5,7 @@ use crate::setup::{ prepare_db_sync_and_gateway, seed_cardano_devnet, }; use crate::utils::{ - copy_dir_all, download_file, execute_script, - extract_tendermint_client_id, extract_tendermint_connection_id, get_cardano_state, get_user_ids, unzip_file, - wait_for_health_check, wait_until_file_exists, CardanoQuery, IndicatorMessage, + copy_dir_all, download_file, execute_script, execute_script_with_progress, extract_tendermint_client_id, extract_tendermint_connection_id, get_cardano_state, get_user_ids, unzip_file, wait_for_health_check, wait_until_file_exists, CardanoQuery, IndicatorMessage }; use crate::{ config, @@ -31,10 +29,7 @@ use std::u64; /// - Linux: Uses actual user UID/GID fn get_docker_env_vars() -> Vec<(&'static str, String)> { let (uid, gid) = get_user_ids(); - vec![ - ("UID", uid), - ("GID", gid), - ] + vec![("UID", uid), ("GID", gid)] } pub fn start_relayer( @@ -80,13 +75,12 @@ pub fn start_relayer( // Note: execute_script_with_progress doesn't support environment variables // Using regular execute_script for relayer with UID/GID support let docker_env = get_docker_env_vars(); - let docker_env_refs: Vec<(&str, &str)> = docker_env.iter() - .map(|(k, v)| (*k, v.as_str())) - .collect(); + let docker_env_refs: Vec<(&str, &str)> = + docker_env.iter().map(|(k, v)| (*k, v.as_str())).collect(); execute_script( relayer_path, - "docker", + "docker", Vec::from(["compose", "up", "-d", "--build"]), Some(docker_env_refs), )?; @@ -216,9 +210,8 @@ pub async fn start_local_cardano_network( if config::get_config().cardano.services.db_sync { prepare_db_sync_and_gateway(cardano_dir.as_path(), clean)?; let docker_env = get_docker_env_vars(); - let docker_env_refs: Vec<(&str, &str)> = docker_env.iter() - .map(|(k, v)| (*k, v.as_str())) - .collect(); + let docker_env_refs: Vec<(&str, &str)> = + docker_env.iter().map(|(k, v)| (*k, v.as_str())).collect(); execute_script( &cardano_dir, "docker", @@ -387,17 +380,12 @@ pub async fn start_cosmos_sidechain_from_repository( pub async fn start_cosmos_sidechain(cosmos_dir: &Path) -> Result<(), Box> { execute_script(cosmos_dir, "docker", Vec::from(["compose", "stop"]), None)?; - - let docker_env = get_docker_env_vars(); - let docker_env_refs: Vec<(&str, &str)> = docker_env.iter() - .map(|(k, v)| (*k, v.as_str())) - .collect(); - + execute_script( cosmos_dir, "docker", Vec::from(["compose", "up", "-d", "--build"]), - Some(docker_env_refs), + None, )?; let optional_progress_bar = match logger::get_verbosity() { @@ -457,13 +445,17 @@ pub fn start_local_cardano_services(cardano_dir: &Path) -> Result<(), Box = docker_env.iter() - .map(|(k, v)| (*k, v.as_str())) - .collect(); + let docker_env_refs: Vec<(&str, &str)> = + docker_env.iter().map(|(k, v)| (*k, v.as_str())).collect(); let mut script_start_args = vec!["compose", "up", "-d"]; script_start_args.append(&mut services); - execute_script(cardano_dir, "docker", script_start_args, Some(docker_env_refs))?; + execute_script( + cardano_dir, + "docker", + script_start_args, + Some(docker_env_refs), + )?; Ok(()) } @@ -547,22 +539,10 @@ pub async fn start_osmosis(osmosis_dir: &Path) -> Result<(), Box Result<(), Box> { check_osmosisd(osmosis_dir).await; - - // Ensure .osmosisd-local directory exists - if let Some(home_path) = home_dir() { - let osmosis_data_dir = home_path.join(".osmosisd-local"); - if !osmosis_data_dir.exists() { - fs::create_dir_all(&osmosis_data_dir) - .map_err(|e| format!("Failed to create .osmosisd-local directory: {}", e))?; - verbose("✅ Created .osmosisd-local directory"); - } - } - + match copy_osmosis_config_files(osmosis_dir) { Ok(_) => { verbose("✅ Osmosis configuration files copied successfully"); - // This should not be required as each time it's restarted it wipes the .osmosisd-local data - // remove_previous_chain_data()?; init_local_network(osmosis_dir)?; Ok(()) } @@ -798,29 +778,26 @@ pub fn configure_hermes(osmosis_dir: &Path) -> Result<(), Box Result<(), Box> { - let docker_env = get_docker_env_vars(); - let docker_env_refs: Vec<(&str, &str)> = docker_env.iter() - .map(|(k, v)| (*k, v.as_str())) - .collect(); - + if logger::is_quite() { - execute_script(osmosis_dir, "make", Vec::from(["localnet-init"]), Some(docker_env_refs))?; + execute_script( + osmosis_dir, + "make", + Vec::from(["localnet-init"]), + None, + )?; Ok(()) } else { - // Note: execute_script_with_progress doesn't support environment variables - // Using regular execute_script for localnet-init with UID/GID support - execute_script( + execute_script_with_progress( osmosis_dir, "make", Vec::from(["localnet-init"]), - Some(docker_env_refs), + "Initialize local Osmosis network", )?; Ok(()) } } - - fn copy_osmosis_config_files(osmosis_dir: &Path) -> Result<(), fs_extra::error::Error> { verbose(&format!( "Copying cosmwasm files from {} to {}", @@ -863,12 +840,8 @@ fn copy_osmosis_config_files(osmosis_dir: &Path) -> Result<(), fs_extra::error:: verbose(&format!( "Copying localnet.mk from {} to {}", - osmosis_dir - .join("../scripts/localnet.mk") - .display(), - osmosis_dir - .join("scripts/makefiles/localnet.mk") - .display() + osmosis_dir.join("../scripts/localnet.mk").display(), + osmosis_dir.join("scripts/makefiles/localnet.mk").display() )); copy( osmosis_dir.join("../scripts/localnet.mk"), @@ -876,7 +849,6 @@ fn copy_osmosis_config_files(osmosis_dir: &Path) -> Result<(), fs_extra::error:: &options, )?; - verbose(&format!( "Copying setup_osmosis_local.sh from {} to {}", osmosis_dir @@ -1007,7 +979,7 @@ pub async fn start_mithril(project_root_dir: &Path) -> Result Result<(), Box = docker_env.iter() - .map(|(k, v)| (*k, v.as_str())) - .collect(); - + let docker_env_refs: Vec<(&str, &str)> = + docker_env.iter().map(|(k, v)| (*k, v.as_str())).collect(); + execute_script(&gateway_dir, "docker", script_args, Some(docker_env_refs))?; Ok(()) } diff --git a/caribic/src/utils.rs b/caribic/src/utils.rs index 3528f8e26..7a53e38b3 100644 --- a/caribic/src/utils.rs +++ b/caribic/src/utils.rs @@ -2,9 +2,11 @@ use crate::logger::{self, verbose}; use console::style; use dirs::home_dir; use indicatif::ProgressBar; +use indicatif::ProgressStyle; use regex::Regex; use reqwest::Client; use serde_json::Value; +use std::collections::VecDeque; use std::fs::File; use std::fs::Permissions; use std::io::BufRead; @@ -347,96 +349,95 @@ pub fn execute_script( Ok(output) } -// commented out as there's no code calling it but could be usefule to have it around for the future -// pub fn execute_script_with_progress( -// script_dir: &Path, -// script_name: &str, -// script_args: Vec<&str>, -// start_message: &str, -// ) -> Result<(), Box> { -// let progress_bar = ProgressBar::new_spinner(); -// progress_bar.enable_steady_tick(Duration::from_millis(100)); -// progress_bar.set_style( -// ProgressStyle::with_template("{prefix:.bold} {spinner} {wide_msg}") -// .unwrap() -// .tick_chars("⠁⠂⠄⡀⢀⠠⠐⠈ "), -// ); - -// progress_bar.set_prefix(start_message.to_owned()); - -// let mut command = Command::new(script_name) -// .current_dir(script_dir) -// .args(script_args) -// .stdout(Stdio::piped()) -// .stderr(Stdio::piped()) -// .spawn() -// .map_err(|error| format!("Failed to initialize localnet: {}", error))?; - -// match logger::get_verbosity() { -// Verbose => { -// let stdout = command.stdout.as_mut().expect("Failed to open stdout"); -// let reader = BufReader::new(stdout); - -// for line in reader.lines() { -// let line = line.unwrap_or_else(|_| "Failed to read line".to_string()); -// progress_bar.set_message(format!("{}", line.trim())); -// } -// } -// Info => { -// let mut last_lines = VecDeque::with_capacity(5); - -// if let Some(stdout) = command.stdout.take() { -// let reader = BufReader::new(stdout); - -// for line in reader.lines() { -// let line = line.unwrap_or_else(|_| "Failed to read line".to_string()); -// if last_lines.len() == 5 { -// last_lines.pop_front(); -// } -// last_lines.push_back(line); -// let output = last_lines -// .iter() -// .cloned() -// .collect::>() -// .join("\n"); - -// progress_bar.set_message(format!("{}", output)); -// } -// } -// } -// Standard => { -// if let Some(stdout) = command.stdout.take() { -// let reader = BufReader::new(stdout); - -// for line in reader.lines() { -// let last_line = line.unwrap_or_else(|_| "Failed to read line".to_string()); -// progress_bar.set_message(format!("{}", last_line.trim())); -// } -// } -// } -// _ => {} -// } - -// let status = command -// .wait() -// .map_err(|error| format!("Command wasn't running: {}", error))?; -// progress_bar.finish_and_clear(); -// if status.success() { -// Ok(()) -// } else { -// let mut error_output = String::new(); -// if let Some(stderr) = command.stderr.take() { -// let reader = BufReader::new(stderr); -// for line in reader.lines() { -// let line = line.unwrap_or_else(|_| "Failed to read line".to_string()); -// error_output.push_str(&line); -// } -// Err(error_output.into()) -// } else { -// Err("Failed to execute script".into()) -// } -// } -// } +pub fn execute_script_with_progress( + script_dir: &Path, + script_name: &str, + script_args: Vec<&str>, + start_message: &str, +) -> Result<(), Box> { + let progress_bar = ProgressBar::new_spinner(); + progress_bar.enable_steady_tick(Duration::from_millis(100)); + progress_bar.set_style( + ProgressStyle::with_template("{prefix:.bold} {spinner} {wide_msg}") + .unwrap() + .tick_chars("⠁⠂⠄⡀⢀⠠⠐⠈ "), + ); + + progress_bar.set_prefix(start_message.to_owned()); + + let mut command = Command::new(script_name) + .current_dir(script_dir) + .args(script_args) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .spawn() + .map_err(|error| format!("Failed to initialize localnet: {}", error))?; + + match logger::get_verbosity() { + logger::Verbosity::Verbose => { + let stdout = command.stdout.as_mut().expect("Failed to open stdout"); + let reader = BufReader::new(stdout); + + for line in reader.lines() { + let line = line.unwrap_or_else(|_| "Failed to read line".to_string()); + progress_bar.set_message(format!("{}", line.trim())); + } + } + logger::Verbosity::Info => { + let mut last_lines = VecDeque::with_capacity(5); + + if let Some(stdout) = command.stdout.take() { + let reader = BufReader::new(stdout); + + for line in reader.lines() { + let line = line.unwrap_or_else(|_| "Failed to read line".to_string()); + if last_lines.len() == 5 { + last_lines.pop_front(); + } + last_lines.push_back(line); + let output = last_lines + .iter() + .cloned() + .collect::>() + .join("\n"); + + progress_bar.set_message(format!("{}", output)); + } + } + } + logger::Verbosity::Standard => { + if let Some(stdout) = command.stdout.take() { + let reader = BufReader::new(stdout); + + for line in reader.lines() { + let last_line = line.unwrap_or_else(|_| "Failed to read line".to_string()); + progress_bar.set_message(format!("{}", last_line.trim())); + } + } + } + _ => {} + } + + let status = command + .wait() + .map_err(|error| format!("Command wasn't running: {}", error))?; + progress_bar.finish_and_clear(); + if status.success() { + Ok(()) + } else { + let mut error_output = String::new(); + if let Some(stderr) = command.stderr.take() { + let reader = BufReader::new(stderr); + for line in reader.lines() { + let line = line.unwrap_or_else(|_| "Failed to read line".to_string()); + error_output.push_str(&line); + } + Err(error_output.into()) + } else { + Err("Failed to execute script".into()) + } + } +} pub fn unzip_file(file_path: &Path, destination: &Path) -> Result<(), Box> { // Open the ZIP file From c6d26f31a61cf66fdfb5be10ee6cca3985037499 Mon Sep 17 00:00:00 2001 From: Giovanni Gargiulo Date: Thu, 25 Sep 2025 14:24:13 +0100 Subject: [PATCH 22/27] chore: spend->mint ack packet. updated policy id --- .../gateway/src/shared/modules/lucid/lucid.service.ts | 2 ++ cardano/gateway/src/tx/packet.service.ts | 1 + .../validators/spending_channel/acknowledge_packet.ak | 11 +++++++---- .../spending_channel/acknowledge_packet.test.ak | 5 ++--- chains/osmosis/scripts/setup_crosschain_swaps.sh | 2 +- 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/cardano/gateway/src/shared/modules/lucid/lucid.service.ts b/cardano/gateway/src/shared/modules/lucid/lucid.service.ts index fe065bb03..271fdcc88 100644 --- a/cardano/gateway/src/shared/modules/lucid/lucid.service.ts +++ b/cardano/gateway/src/shared/modules/lucid/lucid.service.ts @@ -795,7 +795,9 @@ export class LucidService { tx.readFrom([ this.referenceScripts.spendChannel, this.referenceScripts.spendTransferModule, + // minting 1 this.referenceScripts.ackPacket, + // minting 2 this.referenceScripts.verifyProof, ]) .collectFrom([dto.channelUtxo], dto.encodedSpendChannelRedeemer) diff --git a/cardano/gateway/src/tx/packet.service.ts b/cardano/gateway/src/tx/packet.service.ts index b865977dc..ffaad4ba9 100644 --- a/cardano/gateway/src/tx/packet.service.ts +++ b/cardano/gateway/src/tx/packet.service.ts @@ -166,6 +166,7 @@ export class PacketService { } } async sendPacket(data: MsgTransfer): Promise { + // used in the funding osmosis step try { this.logger.log('Transfer is processing'); const sendPacketOperator = validateAndFormatSendPacketParams(data); diff --git a/cardano/onchain/validators/spending_channel/acknowledge_packet.ak b/cardano/onchain/validators/spending_channel/acknowledge_packet.ak index 12ada905f..e24fcf936 100644 --- a/cardano/onchain/validators/spending_channel/acknowledge_packet.ak +++ b/cardano/onchain/validators/spending_channel/acknowledge_packet.ak @@ -2,7 +2,7 @@ use aiken/collection/list use aiken/collection/pairs use cardano/assets.{PolicyId} use cardano/transaction.{ - Mint, Output, OutputReference, Redeemer, ScriptPurpose, Transaction, + Mint, Output, Redeemer, ScriptPurpose, Transaction, } use ibc/auth.{AuthToken} use ibc/client/ics_007_tendermint_client/client_datum.{ @@ -36,16 +36,17 @@ use ibc/core/ics_023_vector_commitments/merkle.{MerkleProof} use ibc/core/ics_024_host_requirements/packet_keys use ibc/utils/validator_utils +// it looks like minting is missing here. validator acknowledge_packet( client_minting_policy_id: PolicyId, connection_minting_policy_id: PolicyId, port_minting_policy_id: PolicyId, verify_proof_policy_id: PolicyId, ) { - spend( - _datum: Option, + // mint(redeemer: MyMintRedeemer, policy_id: PolicyId, self: Transaction) + mint( channel_token: AuthToken, - _spent_output: OutputReference, + _policy_id: PolicyId, transaction: Transaction, ) { let Transaction { @@ -57,6 +58,8 @@ validator acknowledge_packet( .. } = transaction +// TODO missing minting validation it should be list of ((_policy_id) ->1, (verify_proof_policy_id) -> 1) + let (datum, channel_redeemer, spent_output) = validator_utils.extract_channel(inputs, redeemers, channel_token) diff --git a/cardano/onchain/validators/spending_channel/acknowledge_packet.test.ak b/cardano/onchain/validators/spending_channel/acknowledge_packet.test.ak index 76318e6e0..f2fb30d3f 100644 --- a/cardano/onchain/validators/spending_channel/acknowledge_packet.test.ak +++ b/cardano/onchain/validators/spending_channel/acknowledge_packet.test.ak @@ -307,14 +307,13 @@ test succeed_acknowledge_packet() { validity_range: validity_range, } - acknowledge_packet.acknowledge_packet.spend( + acknowledge_packet.acknowledge_packet.mint( mock_data.client_minting_policy_id, mock_data.connection_minting_policy_id, mock_data.port_minting_policy_id, mock_data.verify_proof_policy_id, - None, mock_data.channel_token, - channel_input.output_reference, + #"", transaction, ) } diff --git a/chains/osmosis/scripts/setup_crosschain_swaps.sh b/chains/osmosis/scripts/setup_crosschain_swaps.sh index 9c2f4d190..169eba750 100755 --- a/chains/osmosis/scripts/setup_crosschain_swaps.sh +++ b/chains/osmosis/scripts/setup_crosschain_swaps.sh @@ -34,7 +34,7 @@ rly='docker exec -it relayer bin/rly' RELAYER_PATH="demo" CARDANO_CHAIN_NAME="ibc-0" SIDECHAIN_CHAIN_NAME="ibc-1" -SENT_AMOUNT="12345678-9fc33a6ffaa8d1f600c161aa383739d5af37807ed83347cc133521c96d6f636b" +SENT_AMOUNT="12345678-465209195f27c99dfefdcb725e939ad3262339a9b150992b66673be86d6f636b" SIDECHAIN_RECEIVER="pfm" HERMES_OSMOSIS_NAME="localosmosis" HERMES_SIDECHAIN_NAME="sidechain" From 1064704eb40c6238cf6df2638bd48db3457412b2 Mon Sep 17 00:00:00 2001 From: Giovanni Gargiulo Date: Thu, 25 Sep 2025 15:01:59 +0100 Subject: [PATCH 23/27] chore: acknowledge_packet.spend -> acknowledge_packet.mint --- cardano/offchain/src/deployment.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cardano/offchain/src/deployment.ts b/cardano/offchain/src/deployment.ts index 393cfb7d2..2e8fbd03f 100644 --- a/cardano/offchain/src/deployment.ts +++ b/cardano/offchain/src/deployment.ts @@ -624,7 +624,7 @@ const deploySpendChannel = async ( recv_packet: "recv_packet.mint", send_packet: "send_packet.spend", timeout_packet: "timeout_packet.spend", - acknowledge_packet: "acknowledge_packet.spend", + acknowledge_packet: "acknowledge_packet.mint", }; const referredScripts: Record = From 0258cea522700d7a679ae0bfcc53da4dda6fd3af Mon Sep 17 00:00:00 2001 From: Giovanni Gargiulo Date: Thu, 25 Sep 2025 16:13:04 +0100 Subject: [PATCH 24/27] chore: path --- chains/osmosis/scripts/setup_crosschain_swaps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chains/osmosis/scripts/setup_crosschain_swaps.sh b/chains/osmosis/scripts/setup_crosschain_swaps.sh index 169eba750..b8e3a939d 100755 --- a/chains/osmosis/scripts/setup_crosschain_swaps.sh +++ b/chains/osmosis/scripts/setup_crosschain_swaps.sh @@ -97,7 +97,7 @@ echo "Created Pool ID: $pool_id" script_dir=$(dirname $(realpath $0)) # Store the swaprouter contract -osmosisd tx wasm store $script_dir/../cosmwasm/wasm/swaprouter.wasm $TX_FLAGS | log_tx || exit 1 +osmosisd tx wasm store $script_dir/../osmosis/cosmwasm/wasm/swaprouter.wasm $TX_FLAGS | log_tx || exit 1 sleep 6 swaprouter_code_id=$(osmosisd query wasm list-code $QUERY_FLAGS | jq -r '.code_infos[-1].code_id') check_string_empty "$swaprouter_code_id" "swaprouter code id on Osmosis not found. Exiting..." From 12407a06bce48c8ac728eb93c0ea1c7604d75acd Mon Sep 17 00:00:00 2001 From: Giovanni Gargiulo Date: Thu, 25 Sep 2025 16:17:32 +0100 Subject: [PATCH 25/27] chore: paths --- chains/osmosis/scripts/setup_crosschain_swaps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chains/osmosis/scripts/setup_crosschain_swaps.sh b/chains/osmosis/scripts/setup_crosschain_swaps.sh index b8e3a939d..ae2504a1a 100755 --- a/chains/osmosis/scripts/setup_crosschain_swaps.sh +++ b/chains/osmosis/scripts/setup_crosschain_swaps.sh @@ -130,7 +130,7 @@ sleep 6 echo "swaprouter set_route executed!" #==================================Setup crosschain_swaps contract======================================= -osmosisd tx wasm store $script_dir/../cosmwasm/wasm/crosschain_swaps.wasm $TX_FLAGS | log_tx || exit 1 +osmosisd tx wasm store $script_dir/../osmosis/cosmwasm/wasm/crosschain_swaps.wasm $TX_FLAGS | log_tx || exit 1 sleep 6 crosschain_swaps_code_id=$(osmosisd query wasm list-code $QUERY_FLAGS | jq -r '.code_infos[-1].code_id') check_string_empty "$crosschain_swaps_code_id" "crosschain_swaps code id on Osmosis not found. Exiting..." From 35870d02df313c838c38d8c2189c103761d3e6f9 Mon Sep 17 00:00:00 2001 From: Giovanni Gargiulo Date: Fri, 26 Sep 2025 11:15:40 +0100 Subject: [PATCH 26/27] chore: swap sh fixes --- swap.sh | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/swap.sh b/swap.sh index 167648237..567563c25 100755 --- a/swap.sh +++ b/swap.sh @@ -2,6 +2,10 @@ CROSSCHAIN_SWAPS_ADDRESS="" [ -z "$CROSSCHAIN_SWAPS_ADDRESS" ] && echo "crosschain_swaps contract address not specified!" && exit 1 CARDANO_RECEIVER="247570b8ba7dc725e9ff37e9757b8148b4d5a125958edac2fd4417b8" +#==================================Define util funcions======================================= +check_string_empty() { + [ -z $1 ] && echo "$2" && exit 1 +} #==================================Setup relayer======================================= RLY_CONTAINER_NAME="relayer" if ! docker ps --format '{{.Names}}' | grep -q "^$RLY_CONTAINER_NAME$"; then @@ -13,20 +17,23 @@ rly='docker exec -it relayer bin/rly' RELAYER_PATH="demo" CARDANO_CHAIN_NAME="ibc-0" SIDECHAIN_CHAIN_NAME="ibc-1" -SENT_AMOUNT="12345-9fc33a6ffaa8d1f600c161aa383739d5af37807ed83347cc133521c96d6f636b" +SENT_AMOUNT="12345-465209195f27c99dfefdcb725e939ad3262339a9b150992b66673be86d6f636b" SIDECHAIN_RECEIVER="pfm" HERMES_OSMOSIS_NAME="localosmosis" HERMES_SIDECHAIN_NAME="sidechain" cardano_sidechain_conn_id=$($rly config show --json | jq -r --arg path "$RELAYER_PATH" '.paths[$path].src."connection-id"') +check_string_empty "$cardano_sidechain_conn_id" "Cardano<->Sidechain connection not found. Exiting..." -cardano_sidechain_chann_id=$($rly query connection-channels $CARDANO_CHAIN_NAME $cardano_sidechain_conn_id --reverse --limit 1 | jq -r '.channel_id') +cardano_sidechain_chann_id=$($rly query connection-channels "$CARDANO_CHAIN_NAME" "$cardano_sidechain_conn_id" --reverse --limit 1 | jq -r '.[0].channel_id') +check_string_empty "$cardano_sidechain_chann_id" "Cardano->Sidechain channel not found. Exiting..." echo "Cardano->Sidechain channel id: $cardano_sidechain_chann_id" -sidechain_cardano_chann_id=$($rly query connection-channels $CARDANO_CHAIN_NAME $cardano_sidechain_conn_id --reverse --limit 1 | jq -r '.counterparty.channel_id') +sidechain_cardano_chann_id=$($rly query connection-channels "$CARDANO_CHAIN_NAME" "$cardano_sidechain_conn_id" --reverse --limit 1 | jq -r '.counterparty.channel_id') echo "Sidechain->Cardano channel id: $sidechain_cardano_chann_id" -sidechain_osmosis_chann_id=$(hermes --json query channels --chain $HERMES_OSMOSIS_NAME --counterparty-chain $HERMES_SIDECHAIN_NAME --show-counterparty | jq -r 'select(.result) | .result[-1].channel_b') +sidechain_osmosis_chann_id=$(hermes --json query channels --chain "$HERMES_OSMOSIS_NAME" --counterparty-chain "$HERMES_SIDECHAIN_NAME" --show-counterparty | jq -r 'select(.result) | .result[-1].channel_b') +check_string_empty "$sidechain_osmosis_chann_id" "Sidechain->Osmosis channel not found. Exiting..." echo "Sidechain->Osmosis channel id: $sidechain_osmosis_chann_id" memo=$( From d39f0c2e27b0f4e40315e56c709a5b77fe966c82 Mon Sep 17 00:00:00 2001 From: Giovanni Gargiulo Date: Fri, 26 Sep 2025 14:16:22 +0100 Subject: [PATCH 27/27] chore: debug --- cardano/gateway/src/tx/packet.service.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cardano/gateway/src/tx/packet.service.ts b/cardano/gateway/src/tx/packet.service.ts index ffaad4ba9..b88494698 100644 --- a/cardano/gateway/src/tx/packet.service.ts +++ b/cardano/gateway/src/tx/packet.service.ts @@ -308,9 +308,13 @@ export class PacketService { } async acknowledgementPacket(data: MsgAcknowledgement): Promise { try { - this.logger.log('AcknowledgementPacket is processing'); + // entypoint fromc controller. + this.logger.log('AcknowledgementPacket is processing data.packet.sequence: ', data.packet.sequence); + this.logger.log('AcknowledgementPacket is processing (MsgAcknowledgement): ', data); const { constructedAddress, ackPacketOperator } = validateAndFormatAcknowledgementPacketParams(data); + this.logger.log('AcknowledgementPacket ackPacketOperator.packetSequence: ', ackPacketOperator.packetSequence); + this.logger.log('AcknowledgementPacket ackPacketOperator: ', ackPacketOperator); // Build and complete the unsigned transaction const unsignedAckPacketTx: TxBuilder = await this.buildUnsignedAcknowlegementPacketTx(