Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions Cargo.lock

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

8 changes: 7 additions & 1 deletion cli/src/commands/node/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ use openmina_node_native::{tracing, NodeBuilder};
/// Openmina node
#[derive(Debug, clap::Args)]
pub struct Node {
#[arg(long, short = 'd', default_value = "~/.openmina", env)]
#[arg(
long,
short = 'd',
default_value = "~/.openmina",
env = "OPENMINA_HOME"
)]
pub work_dir: String,

/// Peer secret key
Expand Down Expand Up @@ -196,6 +201,7 @@ impl Node {
}

let work_dir = shellexpand::full(&self.work_dir).unwrap().into_owned();
openmina_core::set_work_dir(work_dir.clone().into());

node_builder
.http_server(self.port)
Expand Down
21 changes: 21 additions & 0 deletions core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,27 @@ pub use network::NetworkConfig;
mod chain_id;
pub use chain_id::*;

mod work_dir {
use once_cell::sync::OnceCell;
use std::path::PathBuf;

static HOME_DIR: OnceCell<PathBuf> = OnceCell::new();

pub fn set_work_dir(dir: PathBuf) {
HOME_DIR.set(dir).expect("Work dir can only be set once");
}

pub fn get_work_dir() -> PathBuf {
HOME_DIR.get().expect("Work dir is not set").clone()
}

pub fn get_debug_dir() -> PathBuf {
get_work_dir().join("debug")
}
}

pub use work_dir::{get_debug_dir, get_work_dir, set_work_dir};

pub fn preshared_key(chain_id: &ChainId) -> [u8; 32] {
use multihash::Hasher;
let mut hasher = Blake2b256::default();
Expand Down
7 changes: 6 additions & 1 deletion ledger/src/proofs/verification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,12 @@ fn dump_zkapp_verification(
vec
};

let filename = generate_new_filename("/tmp/verify_zapp", "binprot", &bin)?;
let debug_dir = openmina_core::get_debug_dir();
let filename = debug_dir
.join(generate_new_filename("verify_zapp", "binprot", &bin)?)
.to_string_lossy()
.to_string();
std::fs::create_dir_all(&debug_dir)?;

let mut file = std::fs::File::create(filename)?;
file.write_all(&bin)?;
Expand Down
1 change: 1 addition & 0 deletions node/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ ledger = { workspace = true }
sha3 = "0.10.8"

node = { path = "../../node", features = ["replay"] }
openmina-core = { path = "../../core" }

[target.'cfg(target_family = "wasm")'.dependencies]
redux = { workspace = true }
Expand Down
7 changes: 6 additions & 1 deletion node/common/src/service/block_producer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,13 @@ fn dump_failed_block_proof_input(
block_hash: StateHash,
input: Box<ProverExtendBlockchainInputStableV2>,
) -> std::io::Result<()> {
let filename = format!("/tmp/failed_block_proof_input_{block_hash}.binprot");
let debug_dir = openmina_core::get_debug_dir();
let filename = debug_dir
.join(format!("failed_block_proof_input_{block_hash}.binprot"))
.to_string_lossy()
.to_string();
println!("Dumping failed block proof to {filename}");
std::fs::create_dir_all(&debug_dir)?;
let mut file = std::fs::File::create(&filename)?;
input.binprot_write(&mut file)?;
file.sync_all()?;
Expand Down
22 changes: 17 additions & 5 deletions node/src/ledger/ledger_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1222,17 +1222,22 @@ fn dump_reconstruct_to_file(
states: needed_blocks.clone(),
};

const FILENAME: &str = "/tmp/failed_reconstruct_ctx.binprot";
let debug_dir = openmina_core::get_debug_dir();
let filename = debug_dir
.join("failed_reconstruct_ctx.binprot")
.to_string_lossy()
.to_string();
std::fs::create_dir_all(&debug_dir)?;

use mina_p2p_messages::binprot::BinProtWrite;
let mut file = std::fs::File::create(FILENAME)?;
let mut file = std::fs::File::create(&filename)?;
reconstruct_context.binprot_write(&mut file)?;
file.sync_all()?;

openmina_core::info!(
openmina_core::log::system_time();
kind = "LedgerService::dump - Failed reconstruct",
summary = format!("Reconstruction saved to: {FILENAME:?}")
summary = format!("Reconstruction saved to: {filename:?}")
);

Ok(())
Expand Down Expand Up @@ -1277,9 +1282,16 @@ fn dump_application_to_file(
blocks: vec![(*block.block).clone()],
};

use mina_p2p_messages::binprot::BinProtWrite;
let filename = format!("/tmp/failed_application_ctx_{}.binprot", block_height);
let debug_dir = openmina_core::get_debug_dir();
let filename = debug_dir
.join(format!("failed_application_ctx_{}.binprot", block_height))
.to_string_lossy()
.to_string();
std::fs::create_dir_all(&debug_dir)?;

let mut file = std::fs::File::create(&filename)?;

use mina_p2p_messages::binprot::BinProtWrite;
apply_context.binprot_write(&mut file)?;
file.sync_all()?;

Expand Down
1 change: 0 additions & 1 deletion p2p/src/network/pubsub/p2p_network_pubsub_reducer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ impl P2pNetworkPubsubState {
if err.to_string().contains("buffer underflow") && state.buffer.is_empty() {
state.buffer = data.to_vec();
}
dbg!(err);
}
}

Expand Down
Loading