PaimaStudios / paima-engine

Novel trustless web3/blockchain gaming engine.
MIT License
55 stars 20 forks source link

sort `eth_getLogs` calls by `logIndex` #415

Open SebastienGllmt opened 2 months ago

SebastienGllmt commented 2 months ago

Right now, the Primitive processing flow for EVM looks like this:

  1. Requests all primitives requires for a specific block range
  2. Aggregate all the primitives returned from (1), and sort them by blockNumber (this is done in the function groupCdeData)

The problem is that blocks can contain many different logs inside them! We want to ensure that Paima Engine parses events from these logs in the same order they were emitted onchain, but groupCdeData doesn't do this at the moment. Fortunately, there is a field logIndex for exactly this purpose, and we just need to integrate it