Skip to content

Commit 15a9e9c

Browse files
authored
Merge pull request #674 from openmina/develop
Merge `develop` to `main`
2 parents 3c83225 + 841ce85 commit 15a9e9c

File tree

8 files changed

+59
-9
lines changed

8 files changed

+59
-9
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cli/src/commands/node/mod.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@ use openmina_node_native::{tracing, NodeBuilder};
1616
/// Openmina node
1717
#[derive(Debug, clap::Args)]
1818
pub struct Node {
19-
#[arg(long, short = 'd', default_value = "~/.openmina", env)]
19+
#[arg(
20+
long,
21+
short = 'd',
22+
default_value = "~/.openmina",
23+
env = "OPENMINA_HOME"
24+
)]
2025
pub work_dir: String,
2126

2227
/// Peer secret key
@@ -196,6 +201,7 @@ impl Node {
196201
}
197202

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

200206
node_builder
201207
.http_server(self.port)

core/src/lib.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,27 @@ pub use network::NetworkConfig;
2323
mod chain_id;
2424
pub use chain_id::*;
2525

26+
mod work_dir {
27+
use once_cell::sync::OnceCell;
28+
use std::path::PathBuf;
29+
30+
static HOME_DIR: OnceCell<PathBuf> = OnceCell::new();
31+
32+
pub fn set_work_dir(dir: PathBuf) {
33+
HOME_DIR.set(dir).expect("Work dir can only be set once");
34+
}
35+
36+
pub fn get_work_dir() -> PathBuf {
37+
HOME_DIR.get().expect("Work dir is not set").clone()
38+
}
39+
40+
pub fn get_debug_dir() -> PathBuf {
41+
get_work_dir().join("debug")
42+
}
43+
}
44+
45+
pub use work_dir::{get_debug_dir, get_work_dir, set_work_dir};
46+
2647
pub fn preshared_key(chain_id: &ChainId) -> [u8; 32] {
2748
use multihash::Hasher;
2849
let mut hasher = Blake2b256::default();

ledger/src/proofs/verification.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -769,7 +769,12 @@ fn dump_zkapp_verification(
769769
vec
770770
};
771771

772-
let filename = generate_new_filename("/tmp/verify_zapp", "binprot", &bin)?;
772+
let debug_dir = openmina_core::get_debug_dir();
773+
let filename = debug_dir
774+
.join(generate_new_filename("verify_zapp", "binprot", &bin)?)
775+
.to_string_lossy()
776+
.to_string();
777+
std::fs::create_dir_all(&debug_dir)?;
773778

774779
let mut file = std::fs::File::create(filename)?;
775780
file.write_all(&bin)?;

node/common/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ ledger = { workspace = true }
2020
sha3 = "0.10.8"
2121

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

2425
[target.'cfg(target_family = "wasm")'.dependencies]
2526
redux = { workspace = true }

node/common/src/service/block_producer/mod.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,13 @@ fn dump_failed_block_proof_input(
116116
block_hash: StateHash,
117117
input: Box<ProverExtendBlockchainInputStableV2>,
118118
) -> std::io::Result<()> {
119-
let filename = format!("/tmp/failed_block_proof_input_{block_hash}.binprot");
119+
let debug_dir = openmina_core::get_debug_dir();
120+
let filename = debug_dir
121+
.join(format!("failed_block_proof_input_{block_hash}.binprot"))
122+
.to_string_lossy()
123+
.to_string();
120124
println!("Dumping failed block proof to {filename}");
125+
std::fs::create_dir_all(&debug_dir)?;
121126
let mut file = std::fs::File::create(&filename)?;
122127
input.binprot_write(&mut file)?;
123128
file.sync_all()?;

node/src/ledger/ledger_service.rs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,17 +1222,22 @@ fn dump_reconstruct_to_file(
12221222
states: needed_blocks.clone(),
12231223
};
12241224

1225-
const FILENAME: &str = "/tmp/failed_reconstruct_ctx.binprot";
1225+
let debug_dir = openmina_core::get_debug_dir();
1226+
let filename = debug_dir
1227+
.join("failed_reconstruct_ctx.binprot")
1228+
.to_string_lossy()
1229+
.to_string();
1230+
std::fs::create_dir_all(&debug_dir)?;
12261231

12271232
use mina_p2p_messages::binprot::BinProtWrite;
1228-
let mut file = std::fs::File::create(FILENAME)?;
1233+
let mut file = std::fs::File::create(&filename)?;
12291234
reconstruct_context.binprot_write(&mut file)?;
12301235
file.sync_all()?;
12311236

12321237
openmina_core::info!(
12331238
openmina_core::log::system_time();
12341239
kind = "LedgerService::dump - Failed reconstruct",
1235-
summary = format!("Reconstruction saved to: {FILENAME:?}")
1240+
summary = format!("Reconstruction saved to: {filename:?}")
12361241
);
12371242

12381243
Ok(())
@@ -1277,9 +1282,16 @@ fn dump_application_to_file(
12771282
blocks: vec![(*block.block).clone()],
12781283
};
12791284

1280-
use mina_p2p_messages::binprot::BinProtWrite;
1281-
let filename = format!("/tmp/failed_application_ctx_{}.binprot", block_height);
1285+
let debug_dir = openmina_core::get_debug_dir();
1286+
let filename = debug_dir
1287+
.join(format!("failed_application_ctx_{}.binprot", block_height))
1288+
.to_string_lossy()
1289+
.to_string();
1290+
std::fs::create_dir_all(&debug_dir)?;
1291+
12821292
let mut file = std::fs::File::create(&filename)?;
1293+
1294+
use mina_p2p_messages::binprot::BinProtWrite;
12831295
apply_context.binprot_write(&mut file)?;
12841296
file.sync_all()?;
12851297

p2p/src/network/pubsub/p2p_network_pubsub_reducer.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ impl P2pNetworkPubsubState {
104104
if err.to_string().contains("buffer underflow") && state.buffer.is_empty() {
105105
state.buffer = data.to_vec();
106106
}
107-
dbg!(err);
108107
}
109108
}
110109

0 commit comments

Comments
 (0)