Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Updated beforeStateAccounts → beforeStates as per the new receipt structure #79

Merged
merged 1 commit into from
Sep 10, 2024
Merged
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
4 changes: 2 additions & 2 deletions src/Data/Collector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
0,
5 * config.RECEIPT_CONFIRMATIONS
)
const isReceiptEqual = (receipt1: any, receipt2: any): boolean => {

Check warning on line 103 in src/Data/Collector.ts

View workflow job for this annotation

GitHub Actions / ci / QA merge checks

Unexpected any. Specify a different type

Check warning on line 103 in src/Data/Collector.ts

View workflow job for this annotation

GitHub Actions / ci / QA merge checks

Unexpected any. Specify a different type

Check warning on line 103 in src/Data/Collector.ts

View workflow job for this annotation

GitHub Actions / ci / QA merge checks

Unexpected any. Specify a different type

Check warning on line 103 in src/Data/Collector.ts

View workflow job for this annotation

GitHub Actions / ci / QA merge checks

Unexpected any. Specify a different type
if (!receipt1 || !receipt2) return false
const r1 = Utils.deepCopy(receipt1)
const r2 = Utils.deepCopy(receipt2)
Expand All @@ -125,7 +125,7 @@
true
)
if (config.VERBOSE) Logger.mainLogger.debug('robustQuery', receipt.tx.txId, robustQuery)
if (!robustQuery || !robustQuery.value || !(robustQuery.value as any).receipt) {

Check warning on line 128 in src/Data/Collector.ts

View workflow job for this annotation

GitHub Actions / ci / QA merge checks

Unexpected any. Specify a different type

Check warning on line 128 in src/Data/Collector.ts

View workflow job for this annotation

GitHub Actions / ci / QA merge checks

Unexpected any. Specify a different type
Logger.mainLogger.error(
`❌ 'null' response from all nodes in receipt-validation for txId: ${receipt.tx.txId} , ${receipt.cycle}, ${receipt.tx.timestamp}
}`
Expand All @@ -135,7 +135,7 @@
return result
}

const robustQueryReceipt = (robustQuery.value as any).receipt as Receipt.SignedReceipt

Check warning on line 138 in src/Data/Collector.ts

View workflow job for this annotation

GitHub Actions / ci / QA merge checks

Unexpected any. Specify a different type

Check warning on line 138 in src/Data/Collector.ts

View workflow job for this annotation

GitHub Actions / ci / QA merge checks

Unexpected any. Specify a different type

if (robustQuery.count < minConfirmations) {
// Wait for 500ms and try fetching the receipt from the nodes that did not respond in the robustQuery
Expand All @@ -158,7 +158,7 @@
}
const node = nodesToQuery[0]
nodesToQuery.splice(0, 1)
const receiptResult: any = await queryReceipt(node)

Check warning on line 161 in src/Data/Collector.ts

View workflow job for this annotation

GitHub Actions / ci / QA merge checks

Unexpected any. Specify a different type

Check warning on line 161 in src/Data/Collector.ts

View workflow job for this annotation

GitHub Actions / ci / QA merge checks

Unexpected any. Specify a different type
if (!receiptResult || !receiptResult.receipt) continue
if (isReceiptEqual(robustQueryReceipt, receiptResult.receipt)) {
requiredConfirmations--
Expand Down Expand Up @@ -870,6 +870,8 @@
// timestamp: tx.timestamp,
// })
const { afterStates, cycle, tx, appReceiptData, signedReceipt } = receipt
receipt.beforeStates = config.storeReceiptBeforeStates ? receipt.beforeStates : []

const sortedVoteOffsets = (signedReceipt.voteOffsets ?? []).sort()
const medianOffset = sortedVoteOffsets[Math.floor(sortedVoteOffsets.length / 2)] ?? 0
const applyTimestamp = tx.timestamp + medianOffset * 1000
Expand All @@ -882,7 +884,6 @@
receiptId: tx.txId,
timestamp: tx.timestamp,
applyTimestamp,
beforeStateAccounts: config.storeReceiptBeforeStates ? receipt.beforeStateAccounts : [],
})
if (config.dataLogWrite && ReceiptLogWriter)
ReceiptLogWriter.writeToLog(
Expand All @@ -891,7 +892,6 @@
receiptId: tx.txId,
timestamp: tx.timestamp,
applyTimestamp,
beforeStateAccounts: config.storeReceiptBeforeStates ? receipt.beforeStateAccounts : [],
})}\n`
)
txDataList.push({ txId, timestamp })
Expand Down
Loading