Skip to content

Feat/dex fast track#324

Open
rem1niscence wants to merge 9 commits intomainfrom
feat/dex-fast-track
Open

Feat/dex fast track#324
rem1niscence wants to merge 9 commits intomainfrom
feat/dex-fast-track

Conversation

@rem1niscence
Copy link
Collaborator

@rem1niscence rem1niscence commented Mar 2, 2026

Description

This PR optimizes the DEX batch processing pipeline to achieve same-block finality. By enabling "Fast-Track" execution of remote root DEX batches and ensuring strict StateRoot consistency across the network, for nested chains, DEX transactions are now processed in the same block they are received.

Related Issues

Closes: #N/A

Changes Made

1. Same-Block DEX Finality ("Fast-Track")

  • Proposer Pre-fetch: Moved DEX batch pre-fetching to CheckMempool. The proposer now fetches the remote batch before block simulation, allowing the result to be included in the current block's StateMachine cache.
  • Certificate Results Integration: Populated results.RootDexBatch in the block proposal. This ensures all validators receive the same batch as the proposer, preventing StateRoot divergence.
  • Cache Persistence: Modified FSM.Copy() to preserve the rootDexBatch cache.

2. Deterministic & Idempotent Processing

- Monotonic Pointer: Replaced the previous "Processed Set" logic with a single LastProcessedRootDexHeight pointer in the FSM state. This ensures a batch is never executed more than once (e.g., once via Fast-Track and once via standard sync). Behavior removedi

3. Field Mapping & Logic Corrections

  • Batch Selection Fix: Corrected the logic in HandleDexBatch to properly distinguish between DexBatch (direct results from a remote chain) and RootDexBatch (mirrored sync data from the root). This resolves the 1-block delay where the root chain was previously ignoring nested chain orders.

4. Synchronization Robustness

  • Aggressive Refresh: Integrated cache refreshes into CheckMempool (every 2s) and CommitCertificate (on every block commit). This ensures all nodes have a highly synchronized view of the root chain, minimizing divergence risks.

Checklist

  • I have tested the changes locally and verified they work as intended.
  • I have appropriately titled my branch issue-#DEX-Latency.
  • I have updated documentation (via walkthrough and analysis artifacts).
  • I have included tests for the changes (existing tests verified pass).

andrewnguyen22 and others added 5 commits February 26, 2026 19:02
The Orders server handler was changed to use ordersParams/GetOrdersPaginated
returning a Page object, but Client.Orders() still sent heightAndIdRequest
and expected OrderBooks (a JSON array). This caused chain 2 to fail
certificate validation on every block, halting at height 1313702.

- Register SellOrders as a pageable type for "orders" pages
- Update Client.Orders() to send ordersRequest with committee field
  and parse the Page response back into OrderBooks
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