Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/state-manager/TransactionQueue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5133,7 +5133,7 @@ class TransactionQueue {
/* prettier-ignore */ if (logFlags.verbose) this.mainLogger.debug(`factTellCorrespondingNodesFinalData: Using wrapped index ${wrappedIndex} instead of regular ${senderIndexInTxGroup}`)
}

if (configContext.p2p.factv2) senderIndex = queueEntry.transactionGroup.findIndex((node) => node.id === Self.id)
if (configContext.p2p.factv2) senderIndex = queueEntry.executionGroup.findIndex((node) => node.id === Self.id)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Overwriting senderIndex here may conflict with the earlier assignment from wrappedIndex, potentially causing inconsistency if both conditions are true. Add a check to ensure only one assignment path is taken, or clarify precedence to avoid logic errors. [possible issue, importance: 7]

Suggested change
if (configContext.p2p.factv2) senderIndex = queueEntry.executionGroup.findIndex((node) => node.id === Self.id)
if (configContext.p2p.factv2 && wrappedIndex == null) {
senderIndex = queueEntry.executionGroup.findIndex((node) => node.id === Self.id)
}


// Calculate corresponding nodes using the correct index that receivers will validate
const correspondingIndices = getCorrespondingNodes(
Expand Down Expand Up @@ -5314,6 +5314,7 @@ class TransactionQueue {
let targetEndIndex = queueEntry.transactionGroup.length // end of tx group

if (configContext.p2p.factv2) {
senderNodeIndex = queueEntry.executionGroup.findIndex((node) => node.id === senderNodeId)
targetNodeIndex = queueEntry.transactionGroup.findIndex((node) => node.id === Self.id)
targetEndIndex = targetEndIndex - 1
} else {
Comment on lines 5316 to 5320

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Assigning senderNodeIndex from executionGroup and targetNodeIndex from transactionGroup may cause mismatched indices if the groups are not aligned. Ensure both indices are derived from the same group to prevent logic errors in subsequent processing. [possible issue, importance: 8]

Suggested change
if (configContext.p2p.factv2) {
senderNodeIndex = queueEntry.executionGroup.findIndex((node) => node.id === senderNodeId)
targetNodeIndex = queueEntry.transactionGroup.findIndex((node) => node.id === Self.id)
targetEndIndex = targetEndIndex - 1
} else {
if (configContext.p2p.factv2) {
senderNodeIndex = queueEntry.executionGroup.findIndex((node) => node.id === senderNodeId)
targetNodeIndex = queueEntry.executionGroup.findIndex((node) => node.id === Self.id)
targetEndIndex = queueEntry.executionGroup.length - 1
} else {
if (queueEntry.isSenderWrappedTxGroup[senderNodeId] != null) {

Expand Down
5 changes: 4 additions & 1 deletion src/utils/fastAggregatedCorrespondingTell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ export function getCorrespondingNodes(
//this loop is at most O(k) where k is receiverGroupSize / sendGroupSize
//effectively it is constant time it is required so that a smaller
//group can send to a larger group
while (targetNumber < receiverGroupSize) {
let steps = 0
const maxSteps = v2 ? Math.ceil(receiverGroupSize / sendGroupSize) : Infinity
while (v2 ? steps < maxSteps : targetNumber < receiverGroupSize) {
//send all payload to this node
const destinationNode = wrappedIndex

Comment on lines +55 to 60

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: The destinationNode is always set to wrappedIndex, which may cause duplicate or incorrect indices if wrappedIndex is not updated properly within the loop. Ensure that wrappedIndex is updated before pushing to destinationNodes to avoid incorrect node assignments, especially when v2 is true. [possible issue, importance: 6]

New proposed code:
 let steps = 0
 const maxSteps = v2 ? Math.ceil(receiverGroupSize / sendGroupSize) : Infinity  
 while (v2 ? steps < maxSteps : targetNumber < receiverGroupSize) {
   //send all payload to this node
+  if (wrappedIndex >= transactionGroupSize) {
+    wrappedIndex = wrappedIndex - transactionGroupSize
+  }
   const destinationNode = wrappedIndex
 
   destinationNodes.push(destinationNode)

Expand All @@ -77,6 +79,7 @@ export function getCorrespondingNodes(
if (wrappedIndex >= transactionGroupSize) {
wrappedIndex = wrappedIndex - transactionGroupSize
}
steps++
if (!v2) {
//wrap to front of receiver group
if (wrappedIndex >= endTargetIndex) {
Expand Down
Loading