Skip to content
Open
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
86edc82
chore: asked claude to make this to work on linux.
nemo83 Aug 14, 2025
a1be792
chore: root on macos and user on linux
nemo83 Aug 14, 2025
b8f3f5e
chore: added missing gid/uid
nemo83 Aug 15, 2025
5037cb7
chore: rolling back to older version
nemo83 Sep 2, 2025
324788e
chore: fully rolled back osmosis
nemo83 Sep 2, 2025
25db7b5
chore: fully rolled back osmosis
nemo83 Sep 2, 2025
1be39f2
chore: added creation or recreation of the .osmosisd-local
nemo83 Sep 3, 2025
bdf17b3
chore: added creation or recreation of the .osmosisd-local
nemo83 Sep 3, 2025
3faa2a8
chore: create .hermes folder if missing
nemo83 Sep 3, 2025
d87c4be
chore: don't delete osmosid.local
nemo83 Sep 3, 2025
872189c
chore: restore latest osmosis
nemo83 Sep 4, 2025
1ac180b
chore: removed overwriting compose/dockerfile
nemo83 Sep 5, 2025
2d1117b
chore: uncomment stuff
nemo83 Sep 5, 2025
1b83f23
chore: attempt to set user's permissions to .osmosisd.local folder
nemo83 Sep 8, 2025
1854051
chore: added missing uid gid
nemo83 Sep 8, 2025
774b2e5
chore: creating .osmosisd-local
nemo83 Sep 8, 2025
778b96d
chore: updated makefile
nemo83 Sep 8, 2025
dc934a8
chore: added missing file
nemo83 Sep 8, 2025
86329f7
chore: must run as admin or won't work. so must sudo rm -fr non inter…
nemo83 Sep 8, 2025
2ead66d
chore: fixed warnings
nemo83 Sep 8, 2025
25041fa
chore: rolling back from unwanted changes
nemo83 Sep 9, 2025
c6d26f3
chore: spend->mint ack packet. updated policy id
nemo83 Sep 25, 2025
1064704
chore: acknowledge_packet.spend -> acknowledge_packet.mint
nemo83 Sep 25, 2025
0258cea
chore: path
nemo83 Sep 25, 2025
12407a0
chore: paths
nemo83 Sep 25, 2025
35870d0
chore: swap sh fixes
nemo83 Sep 26, 2025
d39f0c2
chore: debug
nemo83 Sep 26, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion caribic/Cargo.lock

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

5 changes: 4 additions & 1 deletion caribic/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
chrono = "0.4"

[target.'cfg(unix)'.dependencies]
nix = { version = "0.29", features = ["user"] }
222 changes: 128 additions & 94 deletions caribic/src/start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand All @@ -26,6 +26,17 @@ 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,
Expand Down Expand Up @@ -66,11 +77,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(())
Expand Down Expand Up @@ -197,11 +215,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),
)?;
}

Expand Down Expand Up @@ -365,11 +387,17 @@ pub async fn start_cosmos_sidechain_from_repository(

pub async fn start_cosmos_sidechain(cosmos_dir: &Path) -> Result<(), Box<dyn std::error::Error>> {
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() {
Expand Down Expand Up @@ -428,9 +456,14 @@ pub fn start_local_cardano_services(cardano_dir: &Path) -> Result<(), Box<dyn st
script_stop_args.append(&mut services.clone());
execute_script(cardano_dir, "docker", script_stop_args, 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();

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(())
}

Expand Down Expand Up @@ -517,7 +550,8 @@ pub async fn prepare_osmosis(osmosis_dir: &Path) -> Result<(), Box<dyn std::erro
match copy_osmosis_config_files(osmosis_dir) {
Ok(_) => {
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()?;
Copy link
Collaborator Author

@nemo83 nemo83 Sep 3, 2025

Choose a reason for hiding this comment

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

@fabianbormann this cleanup doesn't seem to be necessary. You can check the README.md in the localosmosis folder.

Can you remember any other reasons why this might be required?

make localnet-init

The command:

- Builds a local docker image with the latest changes
- Cleans the `$HOME/.osmosisd-local` folder

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah ok makes sense. It's just a re-write of the bash script. I assume we can just remove it ;)

init_local_network(osmosis_dir)?;
Ok(())
}
Expand Down Expand Up @@ -555,6 +589,9 @@ pub fn configure_hermes(osmosis_dir: &Path) -> Result<(), Box<dyn std::error::Er
let script_dir = osmosis_dir.join("scripts");
if let Some(home_path) = home_dir() {
let hermes_dir = home_path.join(".hermes");
if !hermes_dir.exists() {
fs::create_dir_all(&hermes_dir)?;
}
let options = fs_extra::file::CopyOptions::new().overwrite(true);
verbose(&format!(
"Copying Hermes configuration files from {} to {}",
Expand Down Expand Up @@ -768,11 +805,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::new(fs_extra::error::ErrorKind::Io(e), "Failed to create .osmosisd-local directory"))?;
Ok(())
} else {
Ok(())
}
Expand Down Expand Up @@ -920,37 +957,45 @@ pub async fn start_mithril(project_root_dir: &Path) -> Result<u64, Box<dyn std::
),
&optional_progress_bar,
);
let docker_env = get_docker_env_vars();
let mut mithril_env = vec![
(
"MITHRIL_AGGREGATOR_IMAGE",
mithril_config.aggregator_image.as_str(),
),
("MITHRIL_CLIENT_IMAGE", mithril_config.client_image.as_str()),
("MITHRIL_SIGNER_IMAGE", mithril_config.signer_image.as_str()),
(
"CARDANO_NODE_VERSION",
mithril_config.cardano_node_version.as_str(),
),
(
"CHAIN_OBSERVER_TYPE",
mithril_config.chain_observer_type.as_str(),
),
("CARDANO_NODE_DIR", mithril_config.cardano_node_dir.as_str()),
("MITHRIL_DATA_DIR", mithril_data_dir.to_str().unwrap()),
(
"GENESIS_VERIFICATION_KEY",
mithril_config.genesis_verification_key.as_str(),
),
(
"GENESIS_SECRET_KEY",
mithril_config.genesis_secret_key.as_str(),
),
("MITHRIL_SIGNER_IMAGE", mithril_config.signer_image.as_str()),
];

// Add UID/GID to environment
for (key, value) in &docker_env {
mithril_env.push((key, value.as_str()));
}

execute_script(
&mithril_script_dir,
"docker",
vec!["compose", "rm", "-f"],
Some(vec![
(
"MITHRIL_AGGREGATOR_IMAGE",
mithril_config.aggregator_image.as_str(),
),
("MITHRIL_CLIENT_IMAGE", mithril_config.client_image.as_str()),
("MITHRIL_SIGNER_IMAGE", mithril_config.signer_image.as_str()),
(
"CARDANO_NODE_VERSION",
mithril_config.cardano_node_version.as_str(),
),
(
"CHAIN_OBSERVER_TYPE",
mithril_config.chain_observer_type.as_str(),
),
("CARDANO_NODE_DIR", mithril_config.cardano_node_dir.as_str()),
("MITHRIL_DATA_DIR", mithril_data_dir.to_str().unwrap()),
(
"GENESIS_VERIFICATION_KEY",
mithril_config.genesis_verification_key.as_str(),
),
(
"GENESIS_SECRET_KEY",
mithril_config.genesis_secret_key.as_str(),
),
("MITHRIL_SIGNER_IMAGE", mithril_config.signer_image.as_str()),
]),
Some(mithril_env.clone()),
)
.map_err(|error| format!("Failed to bring down mithril services: {}", error))?;

Expand All @@ -976,33 +1021,7 @@ pub async fn start_mithril(project_root_dir: &Path) -> Result<u64, Box<dyn std::
"-d",
"--no-build",
],
Some(vec![
(
"MITHRIL_AGGREGATOR_IMAGE",
mithril_config.aggregator_image.as_str(),
),
("MITHRIL_CLIENT_IMAGE", mithril_config.client_image.as_str()),
("MITHRIL_SIGNER_IMAGE", mithril_config.signer_image.as_str()),
(
"CARDANO_NODE_VERSION",
mithril_config.cardano_node_version.as_str(),
),
(
"CHAIN_OBSERVER_TYPE",
mithril_config.chain_observer_type.as_str(),
),
("CARDANO_NODE_DIR", mithril_config.cardano_node_dir.as_str()),
("MITHRIL_DATA_DIR", mithril_data_dir.to_str().unwrap()),
(
"GENESIS_VERIFICATION_KEY",
mithril_config.genesis_verification_key.as_str(),
),
(
"GENESIS_SECRET_KEY",
mithril_config.genesis_secret_key.as_str(),
),
("MITHRIL_SIGNER_IMAGE", mithril_config.signer_image.as_str()),
]),
Some(mithril_env.clone()),
)
.map_err(|error| {
format!(
Expand Down Expand Up @@ -1081,6 +1100,41 @@ pub fn wait_and_start_mithril_genesis(

let mithril_config = config::get_config().mithril;

// Reuse the same environment variables with UID/GID
let docker_env = get_docker_env_vars();
let mut mithril_genesis_env = vec![
(
"MITHRIL_AGGREGATOR_IMAGE",
mithril_config.aggregator_image.as_str(),
),
("MITHRIL_CLIENT_IMAGE", mithril_config.client_image.as_str()),
("MITHRIL_SIGNER_IMAGE", mithril_config.signer_image.as_str()),
(
"CARDANO_NODE_VERSION",
mithril_config.cardano_node_version.as_str(),
),
(
"CHAIN_OBSERVER_TYPE",
mithril_config.chain_observer_type.as_str(),
),
("CARDANO_NODE_DIR", mithril_config.cardano_node_dir.as_str()),
("MITHRIL_DATA_DIR", mithril_data_dir.to_str().unwrap()),
(
"GENESIS_VERIFICATION_KEY",
mithril_config.genesis_verification_key.as_str(),
),
(
"GENESIS_SECRET_KEY",
mithril_config.genesis_secret_key.as_str(),
),
("MITHRIL_SIGNER_IMAGE", mithril_config.signer_image.as_str()),
];

// Add UID/GID to environment
for (key, value) in &docker_env {
mithril_genesis_env.push((key, value.as_str()));
}

execute_script(
&mithril_script_dir,
"docker",
Expand All @@ -1094,33 +1148,7 @@ pub fn wait_and_start_mithril_genesis(
"--rm",
"mithril-aggregator-genesis",
],
Some(vec![
(
"MITHRIL_AGGREGATOR_IMAGE",
mithril_config.aggregator_image.as_str(),
),
("MITHRIL_CLIENT_IMAGE", mithril_config.client_image.as_str()),
("MITHRIL_SIGNER_IMAGE", mithril_config.signer_image.as_str()),
(
"CARDANO_NODE_VERSION",
mithril_config.cardano_node_version.as_str(),
),
(
"CHAIN_OBSERVER_TYPE",
mithril_config.chain_observer_type.as_str(),
),
("CARDANO_NODE_DIR", mithril_config.cardano_node_dir.as_str()),
("MITHRIL_DATA_DIR", mithril_data_dir.to_str().unwrap()),
(
"GENESIS_VERIFICATION_KEY",
mithril_config.genesis_verification_key.as_str(),
),
(
"GENESIS_SECRET_KEY",
mithril_config.genesis_secret_key.as_str(),
),
("MITHRIL_SIGNER_IMAGE", mithril_config.signer_image.as_str()),
]),
Some(mithril_genesis_env),
)?;

current_slot = get_cardano_state(project_root_dir, CardanoQuery::Slot)?;
Expand Down Expand Up @@ -1179,6 +1207,12 @@ pub fn start_gateway(gateway_dir: &Path, clean: bool) -> Result<(), Box<dyn std:
script_args.push("--build");
}
execute_script(&gateway_dir, "docker", Vec::from(["compose", "stop"]), None)?;
execute_script(&gateway_dir, "docker", script_args, 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(&gateway_dir, "docker", script_args, Some(docker_env_refs))?;
Ok(())
}
Loading