Skip to content

Fix/sequencer#81

Merged
glitch003 merged 23 commits intomainfrom
fix/sequencer
Sep 15, 2025
Merged

Fix/sequencer#81
glitch003 merged 23 commits intomainfrom
fix/sequencer

Conversation

@glitch003
Copy link
Contributor

@glitch003 glitch003 commented Sep 15, 2025

  • Optimistic nonce calculation
  • Auto retries with backoff if it fails
  • Periodically refresh the nonce from chain or during failure
  • Sequencer actually works

@glitch003 glitch003 requested a review from Copilot September 15, 2025 21:25
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements optimistic nonce management to prevent nonce collisions when handling concurrent requests, particularly for PKP minting and payee delegation operations. The changes replace the existing sequencer-based approach with a more efficient system that assigns unique nonces optimistically.

  • Replaces the existing Sequencer-based transaction handling with a new OptimisticNonceManager
  • Adds comprehensive load testing for concurrent transaction scenarios
  • Modifies rate limiting to skip test API keys for testing purposes

Reviewed Changes

Copilot reviewed 11 out of 13 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
lib/optimisticNonceManager.ts New optimistic nonce management system for handling concurrent transactions
lib/walletSequencer.ts Wallet-specific sequencer management (appears unused in favor of optimistic approach)
lib/sequencer.ts Enhanced existing sequencer with optimistic nonce handling and error recovery
routes/auth/mintAndFetch.ts Refactored to use optimistic nonce management instead of sequencer
routes/delegate/user.ts Updated to return transaction hash and use optimistic nonce management
lit.ts Modified PKP minting and payee delegation to use optimistic nonce management
routes/middlewares/limiter.ts Added configuration options and test API key bypass
tests/routes/delegate/addPayee.test.ts New load test for concurrent payee addition
tests/routes/auth/mintAndFetch.test.ts New load test for concurrent PKP minting
test-addpayee.sh Shell script for running addPayee concurrency tests
package.json Added test scripts and axios dependency
Comments suppressed due to low confidence (1)

lit.ts:1

  • The function has removed all capacity token logic (lines that were checking for existing tokens, minting new ones, etc.) without explanation. This appears to be a significant behavioral change that should be documented or the removed logic should be preserved if still needed.
import { ethers, utils } from "ethers";

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@glitch003 glitch003 requested a review from Copilot September 15, 2025 21:44
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 14 out of 16 changed files in this pull request and generated 4 comments.

Comments suppressed due to low confidence (1)

tests/routes/delegate/addPayee.test.ts:1

  • The function generateAuthMethod is creating auth method data but this is inconsistent with the test context. This appears to be for PKP minting, not for adding payees. The function should generate unique payee addresses instead.
import { describe, it, expect, beforeAll } from "@jest/globals";

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +173 to +183
tx.wait().then(() => {
nonceManager.markTransactionComplete(nonce, true);
if (!isTestEnvironment) {
console.log(`[TransactionRetry] Transaction ${tx.hash} confirmed`);
}
}).catch((error) => {
if (!isTestEnvironment) {
console.error(`[TransactionRetry] Transaction ${tx.hash} failed to confirm:`, error);
}
nonceManager.markTransactionComplete(nonce, false);
});
Copy link

Copilot AI Sep 15, 2025

Choose a reason for hiding this comment

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

The background confirmation tracking with tx.wait() creates unhandled promise rejections if the transaction fails after the function returns. Consider using a more robust background task management approach or at least add .catch() to prevent unhandled rejections from propagating.

Copilot uses AI. Check for mistakes.
@glitch003 glitch003 merged commit bffdce1 into main Sep 15, 2025
3 checks passed
@glitch003 glitch003 deleted the fix/sequencer branch September 15, 2025 22:44
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