-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Events Orderbook] Implement querying the orderbook at the latest blo…
…ck (#735) This PR implements querying the latest open orderbook. This is implemented by keeping a separate "confirmed" auction state, built from events that are part of confirmed blocks, and not subject to reorgs, and a "latest" auction state that is built by cloning the "confirmed" state and applying events in between the confirmed block and the latest block. The "latest" state is implemented to be discardable and rebuilt on every update so that it is not prone to errors stemming from reorgs, nor does complex logic for rolling back events need to be implemented. Unfortunately, the current implementation is slightly inefficient. I created #734 as an issue to capture a potential solution to the problem. This closes #719 ### Test Plan Run the e2e test to ensure the event based orderbook on the latest block matches the onchain queried orderbook: ``` $ yarn test-streamed-orderbook Streamed Orderbook init ==> building streamed orderbook... ==> querying onchain orderbook... ==> comparing orderbooks... ✓ should successfully apply all events and match on-chain orderbook (287940ms) 1 passing (5m) ``` * implement querying the orderbook at the latest block * comments * add unit test for copy * fix array index logic * default to system time for future blocks
- Loading branch information
Showing
4 changed files
with
194 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters