Skip to content

Commit

Permalink
wallet: Accound for guesser-fee UTXOs when resyncing MS-MPs
Browse files Browse the repository at this point in the history
The function `resync_membership_proofs_from_stored_blocks` did not
account for the newly added guesser-fee UTXOs. So prior to this commit,
it constructed the wrong mutator sets.
  • Loading branch information
Sword-Smith authored and aszepieniec committed Nov 4, 2024
1 parent 70d281c commit 3132267
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
17 changes: 14 additions & 3 deletions src/models/state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1152,16 +1152,26 @@ impl GlobalState {
.get_block(apply_block_hash)
.await?
.unwrap();
let maybe_apply_block_predecessor = self
let predecessor_block = self
.chain
.archival_state()
.get_block(apply_block.kernel.header.prev_block_digest)
.await?;
let mut block_msa = match maybe_apply_block_predecessor {
let mut block_msa = match &predecessor_block {
Some(block) => block.kernel.body.mutator_set_accumulator.clone(),
None => MutatorSetAccumulator::default(),
};
let addition_records = apply_block.kernel.body.transaction_kernel.outputs.clone();
let mut addition_records = predecessor_block
.map(|x| x.guesser_fee_addition_records())
.unwrap_or_default();
addition_records.extend(
apply_block
.body()
.transaction_kernel
.outputs
.clone()
.into_iter(),
);
let removal_records = apply_block.kernel.body.transaction_kernel.inputs.clone();

// apply additions
Expand Down Expand Up @@ -1956,6 +1966,7 @@ mod global_state_tests {
let mut rng = thread_rng();
let mut alice = mock_genesis_global_state(network, 2, WalletSecret::devnet_wallet()).await;
let proving_lock = alice.proving_lock.clone();

let mut alice = alice.lock_guard_mut().await;
let alice_spending_key = alice
.wallet_state
Expand Down
1 change: 0 additions & 1 deletion src/tests/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,6 @@ pub(crate) fn invalid_block_with_transaction(
/// Returns (block, coinbase UTXO, Coinbase output randomness)
pub(crate) fn make_mock_block(
previous_block: &Block,
// target_difficulty: Option<U32s<TARGET_DIFFICULTY_U32_SIZE>>,
block_timestamp: Option<Timestamp>,
coinbase_beneficiary: generation_address::GenerationReceivingAddress,
seed: [u8; 32],
Expand Down

0 comments on commit 3132267

Please sign in to comment.