Skip to content

Comments

feat: Implement Executor Service for asynchronous transaction processing#14

Open
toruguera wants to merge 1 commit intochore/update-bundle-endpoint-mempoolfrom
feat/mempool-slots-execution-service
Open

feat: Implement Executor Service for asynchronous transaction processing#14
toruguera wants to merge 1 commit intochore/update-bundle-endpoint-mempoolfrom
feat/mempool-slots-execution-service

Conversation

@toruguera
Copy link

Implement Executor Service for asynchronous transaction processing

Summary

Implements the Executor Service that processes slots from the Mempool queue, aggregates bundles into transactions, and submits them to the Stellar network asynchronously.

Changes

New Executor Service

  • executor.service.ts: Pure function buildTransactionFromSlot() that:

    • Aggregates all bundles from a slot into a single transaction
    • Calculates total fee (sum of all bundle fees)
    • Creates a single fee operation
    • Adds all operations from all bundles
  • executor.process.ts: Executor class with:

    • Automatic execution loop at configurable intervals
    • Slot processing from Mempool queue
    • Transaction building and submission to Stellar network
    • Database persistence (Transaction and BundleTransaction records)
    • Error handling with bundle status rollback to PENDING on failure
  • executor.types.ts: Types for transaction building and execution results

  • executor.errors.ts: Specific error classes for executor failures

Features

  • Processes slots from Mempool queue automatically
  • Groups multiple bundles into single transactions for efficiency
  • Handles OPEX UTXO management
  • Creates transaction records with UNVERIFIED status
  • Links bundles to transactions via BundleTransaction junction table
  • Robust error handling with automatic retry capability

Files Created

  • src/core/service/executor/executor.types.ts
  • src/core/service/executor/executor.errors.ts
  • src/core/service/executor/executor.service.ts
  • src/core/service/executor/executor.process.ts

@toruguera toruguera requested a review from fazzatti January 12, 2026 14:09
@toruguera toruguera self-assigned this Jan 12, 2026
Comment on lines +88 to +96
for (const bundleId of bundleIds) {
await bundleTransactionRepository.create({
transactionId: txHash,
bundleId: bundleId,
createdAt: new Date(),
createdBy: accountId,
});
}
}

Choose a reason for hiding this comment

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

Should this be a promise all?

LOG.info("Executor started", { intervalMs: EXECUTOR_CONFIG.INTERVAL_MS });

// Execute immediately, then on interval
this.executeNext();
Copy link

@willemneal willemneal Jan 21, 2026

Choose a reason for hiding this comment

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

Should this be awaited?

Comment on lines +59 to +79
for (const bundle of bundles) {
// Add deposit operations
bundle.operations.deposit.forEach((op) => {
txBuilder.addOperation(op);
});

// Add create operations
bundle.operations.create.forEach((op) => {
txBuilder.addOperation(op);
});

// Add spend operations
bundle.operations.spend.forEach((op) => {
txBuilder.addOperation(op);
});

// Add withdraw operations
bundle.operations.withdraw.forEach((op) => {
txBuilder.addOperation(op);
});
}

Choose a reason for hiding this comment

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

Since there are a max of 100 operations. And there is already 1 fee, then there is a max of 24 bundles?

24 * 4 + 1 = 97 operations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants