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

SHARD-946 - Fix: By default use main program to handle global txs #93

Merged
merged 1 commit into from
Oct 24, 2024
Merged
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
4 changes: 4 additions & 0 deletions src/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ export interface Config {
workerProcessesDebugLog: boolean // To enable debug logs for worker processes managed by the main process
restrictFirstNodeSelectionByPublicKey: boolean // The flag to pick the first node that matches the PUBLIC_KEY specified in the firstNodeInfo
firstNodePublicKey: string // The public key of the first node to be selected
disableOffloadReceipt: boolean // To disable offloading of receipts globally
disableOffloadReceiptForGlobalModification: boolean // To disable offloading of receipts for global modifications receipts
}

let config: Config = {
Expand Down Expand Up @@ -188,6 +190,8 @@ let config: Config = {
workerProcessesDebugLog: false,
restrictFirstNodeSelectionByPublicKey: false,
firstNodePublicKey: '',
disableOffloadReceipt: false,
disableOffloadReceiptForGlobalModification: true,
}
// Override default config params from config file, env vars, and cli args
export async function overrideDefaultConfig(file: string): Promise<void> {
Expand Down
20 changes: 20 additions & 0 deletions src/primary-process/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,26 @@ export const offloadReceipt = async (
receivedReceiptCount++ // Increment the counter for each receipt received
receiptLoadTraker++ // Increment the receipt load tracker
let verificationResult: ReceiptVerificationResult

// Check if offloading is disabled globally or for global modifications
if (
config.disableOffloadReceipt ||
(config.disableOffloadReceiptForGlobalModification && receipt.globalModification)
) {
mainProcessReceiptTracker++
if (config.workerProcessesDebugLog) console.log('Verifying on the main program', txId, timestamp)
verificationResult = await verifyArchiverReceipt(receipt, requiredSignatures)
arhamj marked this conversation as resolved.
Show resolved Hide resolved
mainProcessReceiptTracker--
verifiedReceiptCount++
if (verificationResult.success) {
successReceiptCount++
} else {
failureReceiptCount++
}
return verificationResult
}

// Existing logic for offloading
if (workers.length === 0 && mainProcessReceiptTracker > config.receiptLoadTrakerLimit) {
// If there are extra workers available, put them to the workers list
if (extraWorkers.size > 0) {
Expand Down
Loading