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..b88494698 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); @@ -307,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( 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 = 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/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..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, execute_script_with_progress, - extract_tendermint_client_id, extract_tendermint_connection_id, get_cardano_state, 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, @@ -20,12 +18,20 @@ 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; use std::u64; +/// 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![("UID", uid), ("GID", gid)] +} + pub fn start_relayer( relayer_path: &Path, relayer_env_template_path: &Path, @@ -66,11 +72,17 @@ 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", Vec::from(["compose", "up", "-d", "--build"]), - "⚡ Starting relayer...", + Some(docker_env_refs), )?; Ok(()) @@ -197,11 +209,14 @@ 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,6 +380,7 @@ 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)?; + execute_script( cosmos_dir, "docker", @@ -428,9 +444,18 @@ 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(()) } @@ -514,10 +539,10 @@ pub async fn start_osmosis(osmosis_dir: &Path) -> Result<(), Box Result<(), Box> { check_osmosisd(osmosis_dir).await; + match copy_osmosis_config_files(osmosis_dir) { Ok(_) => { verbose("✅ Osmosis configuration files copied successfully"); - remove_previous_chain_data()?; init_local_network(osmosis_dir)?; Ok(()) } @@ -555,6 +580,9 @@ pub fn configure_hermes(osmosis_dir: &Path) -> Result<(), Box Result<(), Box Result<(), Box> { + if logger::is_quite() { - execute_script(osmosis_dir, "make", Vec::from(["localnet-init"]), None)?; + execute_script( + osmosis_dir, + "make", + Vec::from(["localnet-init"]), + None, + )?; Ok(()) } else { execute_script_with_progress( @@ -764,20 +798,6 @@ 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)?; - Ok(()) - } else { - Ok(()) - } - } else { - Ok(()) - } -} - fn copy_osmosis_config_files(osmosis_dir: &Path) -> Result<(), fs_extra::error::Error> { verbose(&format!( "Copying cosmwasm files from {} to {}", @@ -818,6 +838,17 @@ 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 @@ -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..7a53e38b3 100644 --- a/caribic/src/utils.rs +++ b/caribic/src/utils.rs @@ -1,13 +1,12 @@ -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 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; @@ -16,13 +15,16 @@ 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::{Gid, Uid}; + pub fn print_header() { println!( r#" @@ -372,7 +374,7 @@ pub fn execute_script_with_progress( .map_err(|error| format!("Failed to initialize localnet: {}", error))?; match logger::get_verbosity() { - Verbose => { + logger::Verbosity::Verbose => { let stdout = command.stdout.as_mut().expect("Failed to open stdout"); let reader = BufReader::new(stdout); @@ -381,7 +383,7 @@ pub fn execute_script_with_progress( progress_bar.set_message(format!("{}", line.trim())); } } - Info => { + logger::Verbosity::Info => { let mut last_lines = VecDeque::with_capacity(5); if let Some(stdout) = command.stdout.take() { @@ -403,7 +405,7 @@ pub fn execute_script_with_progress( } } } - Standard => { + logger::Verbosity::Standard => { if let Some(stdout) = command.stdout.take() { let reader = BufReader::new(stdout); @@ -586,3 +588,29 @@ 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 +/// - 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(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(any(target_os = "macos", target_os = "linux")))] + { + // 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 dd7c1f4ed..ff8b27a25 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: @@ -97,8 +97,8 @@ services: - ./kupo-db:/db postgres: - image: postgres:14.10-alpine - # user: "${UID:-1000}:${GID:-1000}" + image: postgres:15 + 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..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 @@ -16,10 +17,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 +37,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 +47,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 +62,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 +83,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", @@ -92,6 +93,7 @@ services: ] mithril-signer-1: image: ${MITHRIL_SIGNER_IMAGE} + user: "${UID:-1000}:${GID:-1000}" restart: always profiles: - mithril @@ -105,7 +107,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 @@ -120,6 +122,7 @@ services: mithril-signer-2: image: ${MITHRIL_SIGNER_IMAGE} + user: "${UID:-1000}:${GID:-1000}" restart: always profiles: - mithril @@ -133,7 +136,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 diff --git a/chains/osmosis/configuration/docker-compose.yml b/chains/osmosis/configuration/docker-compose.yml index f19107663..db7b29092 100644 --- a/chains/osmosis/configuration/docker-compose.yml +++ b/chains/osmosis/configuration/docker-compose.yml @@ -36,4 +36,4 @@ services: - 6379:6379 - 8001:8001 volumes: - - ./redis-data:/data + - ./redis-data:/data \ No newline at end of file diff --git a/chains/osmosis/scripts/localnet.mk b/chains/osmosis/scripts/localnet.mk new file mode 100644 index 000000000..e9cc8f3e2 --- /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 -rf $(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 diff --git a/chains/osmosis/scripts/setup_crosschain_swaps.sh b/chains/osmosis/scripts/setup_crosschain_swaps.sh index 9c2f4d190..ae2504a1a 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" @@ -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..." @@ -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..." 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=$(