feat: add queue system
bonustrack opened this issue · comments
Currently if Highlight receive a multiple transactions (or unit) they are ingested in parallel, here is the code that doest invoke the transaction ingest process: https://github.com/snapshot-labs/highlight/blob/main/src/highlight/highlight.ts#L39-L55. If an agent (or contract) of Highlight read a state variable it's done directly when the transaction is being process, but if an agent store a new variable in their state it's done at the end of the ingestion with the function: process.execute();
. The issue is that if there is multiple txs coming to Highlight the query to current state of the agent might be misleading because value would depend on the order of the txs. Here is a simple example:
- Image an agent with a state variable "category_count" and a function "addCategory"
- 2 persons send a transaction in the same time to add category.
- 1st and 2nd transaction will read current state var "category_count" to be
0
; and note to update it to1
- Both transaction are process, the "category_count" is
1
instead of2
.
To solve this we should have a queue system to enforce that transactions are process in series and not in parallel.