Skip to content

Commit

Permalink
fix(ledger_service): assert the loaded top hash and computed merkle r…
Browse files Browse the repository at this point in the history
…oot are the same
  • Loading branch information
tizoc committed Mar 22, 2024
1 parent c17170c commit 8186e0f
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions node/src/ledger/ledger_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,11 @@ impl LedgerCtx {
mask.get_or_create_account(account_id, account).unwrap();
}

let top_hash = top_hash.unwrap_or_else(|| {
v2::LedgerHash::from(v2::MinaBaseLedgerHash0StableV1(mask.merkle_root().into()))
});
let top_hash = top_hash.unwrap_or_else(|| v2::LedgerHash::from_fp(mask.merkle_root()));
// Forcing this computation is needed so that the ledger contains node hashes
let computed_merkle_root = v2::LedgerHash::from_fp(mask.merkle_root());

// Needed so that the ledger contains node hashes
let _force_hashes_computation = mask.merkle_root();
assert_eq!(top_hash, computed_merkle_root);

self.snarked_ledgers.insert(top_hash, mask);
}
Expand Down

0 comments on commit 8186e0f

Please sign in to comment.