Skip to content

Implement sequence-race detection and XDR decoding optimization - #42

Merged
BigDella merged 1 commit into
Parcel-Protocol:mainfrom
sanmipaul:add-sequence-race-detection-and-xdr-optimization
Sep 24, 2026
Merged

BigDella merged 1 commit into
Parcel-Protocol:mainfrom
sanmipaul:add-sequence-race-detection-and-xdr-optimization

Conversation

@sanmipaul

@sanmipaul sanmipaul commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Comprehensive implementation of issues #32 (XDR decoding performance) and #33 (sequence-number race detection).

Issue #33: Detect and warn about sequence-number races

Problem: Read-only tools reporting sequence numbers can show stale values if the account submits another transaction in between.

Solution:

  • Added timestamps/ledger info to every sequence-number display
  • Implemented refresh action in sequence-inspector with state tracking
  • Added consistent advisory copy across all features displaying sequences
  • Created comprehensive documentation explaining staleness risk

Features updated:

  • ✅ sequence-inspector (with manual refresh button)
  • ✅ xdr-inspector (advisory for encoded sequence)
  • ✅ preconditions-explainer (advisory for envelope sequence)
  • ✅ fee-bump-inspector (advisory for inner transaction sequence)

Issue #32: Profile and optimize XDR decoding performance

Problem: Large transactions (100+ operations) could block the main thread during decoding.

Solution:

  • Created benchmark suite measuring 100-operation transaction decoding
  • Implemented optimized decoding path with Web Worker support
  • Threshold-based approach: synchronous for small envelopes (<2KB), worker for larger
  • Graceful fallback: falls back to sync if worker initialization fails or times out

Implementation:

  • xdrInspector.optimized.ts - Smart routing between sync/worker paths
  • xdrInspector.worker.ts - Web Worker for off-main-thread decoding
  • xdrInspector.benchmark.ts - Performance test suite with frame-budget validation

Acceptance Criteria (Both Issues)

Issue #32:

  • ✅ Documented benchmark for 100-operation and large-ScVal fixtures
  • ✅ Decoding moves off-thread if threshold exceeded
  • ✅ Small transactions not penalized by worker overhead
  • ✅ Errors from off-thread decoding surface same way

Issue #33:

  • ✅ Every sequence display labeled with ledger/time retrieved
  • ✅ Manual refresh available for decoding-preview features
  • ✅ Advisory copy consistent across all slices
  • ✅ Documentation explaining freshness limitations

Test Plan

  • Manual: Inspect a sequence number, verify timestamp/ledger shown
  • Manual: Click refresh button, verify re-fetch with new timestamp
  • Manual: Paste 100-op XDR in xdr-inspector, verify no main-thread blocking
  • Manual: Review advisory copy across sequence-inspector, xdr-inspector, preconditions-explainer, fee-bump-inspector
  • Run: npm run test -- xdrInspector.benchmark to verify performance targets

Documentation

Added two new docs:

  • docs/SEQUENCE_FRESHNESS.md - Complete guide to sequence staleness and user best practices
  • docs/XDR_DECODING_PERFORMANCE.md - Architecture and optimization strategy

closes #27
closes #29
closes #32
closes #33

Parcel-Protocol#32, Parcel-Protocol#33)

Issue Parcel-Protocol#33: Detect and warn about sequence-number races
- Add timestamps/ledger info to every sequence-number display
- Implement refresh action in sequence-inspector with state tracking
- Add consistent advisory copy across all features displaying sequences
- Features updated: sequence-inspector, xdr-inspector, preconditions-explainer, fee-bump-inspector
- Add comprehensive docs explaining staleness risk and user best practices

Issue Parcel-Protocol#32: Profile and optimize XDR decoding performance
- Create benchmark suite for 100-operation transaction decoding
- Add performance test with 16ms frame-budget target
- Implement optimized decoding with Web Worker support for large payloads
- Add fallback-to-sync for worker initialization failure and timeouts
- Threshold-based approach: sync for <2KB envelopes, worker for larger
- Add detailed performance documentation with architecture notes

Acceptance criteria met:
- [x] Documented benchmark exists for 100-op and large-ScVal fixtures
- [x] Throttle-exceeded: decoding moves off-thread with proper fallback
- [x] Small transactions not penalized by worker overhead
- [x] Errors from off-thread decoding surface same way
- [x] Every sequence display labeled with ledger/time retrieved
- [x] Manual refresh available for decoding-preview features
- [x] Advisory copy consistent across slices
- [x] Docs explain why freshness cannot be guaranteed
@drips-wave

drips-wave Bot commented Sep 24, 2026

Copy link
Copy Markdown

@sanmipaul Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@BigDella
BigDella merged commit 3e39d21 into Parcel-Protocol:main Sep 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment