diff --git a/dan_layer/consensus/src/hotstuff/on_propose.rs b/dan_layer/consensus/src/hotstuff/on_propose.rs index facfc4967..7692740be 100644 --- a/dan_layer/consensus/src/hotstuff/on_propose.rs +++ b/dan_layer/consensus/src/hotstuff/on_propose.rs @@ -234,7 +234,15 @@ where TConsensusSpec: ConsensusSpec // prepared. We can now propose to Accept it. We also propose the decision change which everyone // should agree with if they received the same foreign LocalPrepare. TransactionPoolStage::LocalPrepared => { - let involved = local_committee_shard.count_distinct_shards(t.transaction().evidence.shards_iter()); + // For now we need to treat transactions without versions in a special case + // TODO: update the evidence after execution so all transactions are treated equally here + let db_transaction = t.get_transaction(tx)?; + let involved = if db_transaction.transaction().has_inputs_without_version() { + db_transaction.transaction().all_inputs_iter().count() + } else { + local_committee_shard.count_distinct_shards(t.transaction().evidence.shards_iter()) + }; + let involved = NonZeroU64::new(involved as u64).ok_or_else(|| { HotStuffError::InvariantError(format!( "Number of involved shards is zero for transaction {}", diff --git a/dan_layer/consensus/src/hotstuff/on_ready_to_vote_on_local_block.rs b/dan_layer/consensus/src/hotstuff/on_ready_to_vote_on_local_block.rs index 928188d98..e6111413c 100644 --- a/dan_layer/consensus/src/hotstuff/on_ready_to_vote_on_local_block.rs +++ b/dan_layer/consensus/src/hotstuff/on_ready_to_vote_on_local_block.rs @@ -630,8 +630,15 @@ where TConsensusSpec: ConsensusSpec return Ok(None); } - let distinct_shards = - local_committee_shard.count_distinct_shards(tx_rec.transaction().evidence.shards_iter()); + // For now we need to treat transactions without versions in a special case + // TODO: update the evidence after execution so all transactions are treated equally here + let executed = self.get_executed_transaction(tx, &t.id, &mut executor)?; + let transaction = executed.transaction(); + let distinct_shards = if transaction.has_inputs_without_version() { + transaction.all_inputs_iter().count() + } else { + local_committee_shard.count_distinct_shards(tx_rec.transaction().evidence.shards_iter()) + }; let distinct_shards = NonZeroU64::new(distinct_shards as u64).ok_or_else(|| { HotStuffError::InvariantError(format!( "Distinct shards is zero for transaction {} in block {}", diff --git a/dan_layer/storage/src/consensus_models/executed_transaction.rs b/dan_layer/storage/src/consensus_models/executed_transaction.rs index 2b68a5ff0..e62d6811f 100644 --- a/dan_layer/storage/src/consensus_models/executed_transaction.rs +++ b/dan_layer/storage/src/consensus_models/executed_transaction.rs @@ -144,27 +144,47 @@ impl ExecutedTransaction { } pub fn to_initial_evidence(&self) -> Evidence { + // Note that we only add evidence for inputs that have specific version numbers let mut deduped_evidence = HashMap::new(); - deduped_evidence.extend(self.transaction.inputs().iter().map(|input| { - (input.to_substate_address(), ShardEvidence { - qc_ids: IndexSet::new(), - lock: LockFlag::Write, - }) - })); - - deduped_evidence.extend(self.transaction.input_refs().iter().map(|input_ref| { - (input_ref.to_substate_address(), ShardEvidence { - qc_ids: IndexSet::new(), - lock: LockFlag::Read, - }) - })); - - deduped_evidence.extend(self.transaction.filled_inputs().iter().map(|input_ref| { - (input_ref.to_substate_address(), ShardEvidence { - qc_ids: IndexSet::new(), - lock: LockFlag::Write, - }) - })); + + deduped_evidence.extend( + self.transaction + .inputs() + .iter() + .filter(|i| i.version().is_some()) + .map(|input| { + (input.to_substate_address(), ShardEvidence { + qc_ids: IndexSet::new(), + lock: LockFlag::Write, + }) + }), + ); + + deduped_evidence.extend( + self.transaction + .input_refs() + .iter() + .filter(|i| i.version().is_some()) + .map(|input_ref| { + (input_ref.to_substate_address(), ShardEvidence { + qc_ids: IndexSet::new(), + lock: LockFlag::Read, + }) + }), + ); + + deduped_evidence.extend( + self.transaction + .filled_inputs() + .iter() + .filter(|i| i.version().is_some()) + .map(|input_ref| { + (input_ref.to_substate_address(), ShardEvidence { + qc_ids: IndexSet::new(), + lock: LockFlag::Write, + }) + }), + ); let tx_reciept_address = SubstateAddress::for_transaction_receipt(self.id().into_receipt_address()); deduped_evidence.extend(