Skip to content

Commit c55a74d

Browse files
authored
Merge pull request #1125 from openmina/more-info
Include random values in the dump file
2 parents 056deae + 5390286 commit c55a74d

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

ledger/src/proofs/transaction.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,10 +1296,22 @@ impl<F: FieldWitness> InnerCurve<F> {
12961296
let proj: GroupProjective<F::Parameters> = ark_ff::UniformRand::rand(&mut rng);
12971297
let proj: F::Projective = proj.into();
12981298

1299+
let proj2 = proj;
1300+
LATEST_RANDOM.set(Box::new(move || {
1301+
let this = Self { inner: proj2 };
1302+
format!("{:#?}", this.to_affine())
1303+
}));
1304+
12991305
Self { inner: proj }
13001306
}
13011307
}
13021308

1309+
use std::cell::RefCell;
1310+
1311+
thread_local! {
1312+
static LATEST_RANDOM: RefCell<Box<dyn Fn() -> String>> = RefCell::new(Box::new(String::new));
1313+
}
1314+
13031315
impl InnerCurve<Fp> {
13041316
// TODO: Remove this
13051317
pub fn rand() -> Self {
@@ -4013,6 +4025,7 @@ pub(super) fn create_proof<C: ProofConstants, F: FieldWitness>(
40134025
witness_aux_hash,
40144026
prev_challenges_hash,
40154027
group_map_hash,
4028+
latest_random: LATEST_RANDOM.with_borrow(|fun| (fun)()),
40164029
};
40174030

40184031
ProofError::ProvingErrorWithContext(context)
@@ -4089,6 +4102,7 @@ pub mod debug {
40894102
pub witness_aux_hash: String,
40904103
pub prev_challenges_hash: String,
40914104
pub group_map_hash: String,
4105+
pub latest_random: String,
40924106
}
40934107

40944108
// Manual implementation because String does not implement binprot traits (because unbounded)
@@ -4102,19 +4116,22 @@ pub mod debug {
41024116
witness_aux_hash,
41034117
prev_challenges_hash,
41044118
group_map_hash,
4119+
latest_random,
41054120
} = self;
41064121
let inner_error: &[u8] = inner_error.as_bytes();
41074122
let witness_primary_hash: &[u8] = witness_primary_hash.as_bytes();
41084123
let witness_aux_hash: &[u8] = witness_aux_hash.as_bytes();
41094124
let prev_challenges_hash: &[u8] = prev_challenges_hash.as_bytes();
41104125
let group_map_hash: &[u8] = group_map_hash.as_bytes();
4126+
let latest_random: &[u8] = latest_random.as_bytes();
41114127
binprot::BinProtWrite::binprot_write(&inner_error, w)?;
41124128
binprot::BinProtWrite::binprot_write(witness_primary, w)?;
41134129
binprot::BinProtWrite::binprot_write(witness_aux, w)?;
41144130
binprot::BinProtWrite::binprot_write(&witness_primary_hash, w)?;
41154131
binprot::BinProtWrite::binprot_write(&witness_aux_hash, w)?;
41164132
binprot::BinProtWrite::binprot_write(&prev_challenges_hash, w)?;
41174133
binprot::BinProtWrite::binprot_write(&group_map_hash, w)?;
4134+
binprot::BinProtWrite::binprot_write(&latest_random, w)?;
41184135
Ok(())
41194136
}
41204137
}
@@ -4132,6 +4149,7 @@ pub mod debug {
41324149
let witness_aux_hash: Vec<u8> = binprot::BinProtRead::binprot_read(r)?;
41334150
let prev_challenges_hash: Vec<u8> = binprot::BinProtRead::binprot_read(r)?;
41344151
let group_map_hash: Vec<u8> = binprot::BinProtRead::binprot_read(r)?;
4152+
let latest_random: Vec<u8> = binprot::BinProtRead::binprot_read(r)?;
41354153
Ok(Self {
41364154
inner_error: to_string(inner_error),
41374155
witness_primary,
@@ -4140,6 +4158,7 @@ pub mod debug {
41404158
witness_aux_hash: to_string(witness_aux_hash),
41414159
prev_challenges_hash: to_string(prev_challenges_hash),
41424160
group_map_hash: to_string(group_map_hash),
4161+
latest_random: to_string(latest_random),
41434162
})
41444163
}
41454164
}
@@ -4162,6 +4181,7 @@ pub mod debug {
41624181
witness_aux_hash,
41634182
prev_challenges_hash,
41644183
group_map_hash,
4184+
latest_random,
41654185
} = self;
41664186

41674187
// Print witness lengths, not the whole vectors
@@ -4173,6 +4193,7 @@ pub mod debug {
41734193
.field("witness_aux_hash", &witness_aux_hash)
41744194
.field("prev_challenges_hash", &prev_challenges_hash)
41754195
.field("group_map_hash", &group_map_hash)
4196+
.field("latest_random", &latest_random)
41764197
.finish()
41774198
}
41784199
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ fn prover_loop(
106106
let (provers, block_hash, mut input) = msg.0;
107107
let res = prove(provers, &mut input, &keypair, false);
108108
if let Err(error) = &res {
109-
openmina_core::error!(message = "Block proof failed", error = format!("{error}"));
109+
openmina_core::error!(message = "Block proof failed", error = format!("{error:?}"));
110110
if let Err(error) = dump_failed_block_proof_input(block_hash.clone(), input, error) {
111111
openmina_core::error!(
112112
message = "Failure when dumping failed block proof inputs",

0 commit comments

Comments
 (0)