Specification for Predicate Indexer for Limit Order Predicate
Overview
This specification outlines the requirements for a predicate indexer for a limit order predicate. The indexer will track and index events related to order creation, cancellation, and fulfillment based on the predicate's logic, tests, and scripts.
Predicate Reference
Test Suite
Testnet Scripts
Event Indexing
The indexer will be responsible for monitoring and storing the following events:
- Create Order Event: Triggered when an order is created.
- Cancel Order Event: Triggered when an order is canceled.
- Fulfill Order Event: Triggered when an order is fulfilled.
Implementation Details
- Data Collection: The indexer will listen for events emitted by the limit order predicate on the Fuel Beta 5 testnet.
- Data Storage: Relevant data from each event will be stored in a structured format, ensuring quick retrieval and query capabilities. This may include order details, transaction identifiers, timestamps, and participant addresses.
- Script Execution Tracking: For the
cancel_order
and fulfill_order
scripts, the indexer will capture the outcomes and the sequence of actions within each script execution.
- Event Parsing: Each event type will be parsed to extract and store relevant information, such as order ID, trader address, order size, price, and status changes.
- Integration with Test Suites: The indexer will be integrated with the local test suite to validate the correctness of indexed data against known outcomes.
Requirements
- Real-Time Indexing: The system should index events in real-time or near-real-time for prompt data availability.
- Scalability: The indexer should be scalable to handle an increasing number of transactions and events without significant performance degradation.
- Reliability: The system should ensure data integrity and consistency, even in cases of network or system failures.
- Query Interface: Provide an API or query interface for retrieving indexed data, supporting queries based on order ID, trader address, and order status.
Testing and Validation
- Local Test Integration: Validate the indexer against local tests for create, cancel, and fulfill orders.
- Testnet Script Results Analysis: Analyze the results of the
cancel_order
and fulfill_order
scripts executed on the testnet to ensure accurate indexing and representation of events.
Output Documentation
- Indexing Results: Document the outcomes and indexed data for both local tests and testnet script executions.
- Discrepancies and Anomalies: Any deviations from expected results should be documented and analyzed for root cause determination.
Future Considerations
- Upgrades and Maintenance: Plan for regular updates and maintenance to accommodate changes in the limit order predicate and the Fuel ecosystem.
- Expansion of Indexed Events: Consider future expansion to include additional event types as the limit order predicate evolves.
Cancel Order script output
Fulfill Order script output