-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ensure that L1 Events received from the relayer are in a deterministic order #1772
Comments
This was referenced Mar 25, 2024
MitchTurner
added a commit
that referenced
this issue
Mar 28, 2024
closes #1772 *** Had to modify `MockDB` to also maintain order. This code only works if the Relayer DB maintains order. In production it is stored as a `Mappable` with value being `[Event]`: ``` impl Mappable for EventsHistory { /// The key is the height of the DA. type Key = Self::OwnedKey; type OwnedKey = DaBlockHeight; /// The value is an events happened at the height. type Value = [Event]; type OwnedValue = Vec<Event>; } ``` So it should be good. This approach is flakier than having the relayer reader in the executor ensure the order, but it could add a lot of extra execution cost to the executor code if we put the sorting on that side. We are already making assumptions about what the writing code is doing though. For example, if an event is missing from L1, correct order doesn't matter. So why not add more assumptions :P *** We require that all `Logs`include the `log_index` so we can sort them. So I added a test `relayer__if_a_log_does_not_include_index_then_event_not_included` to check the sad path. **I'm not positive this is the behavior we want.** It is erroring in the `sort_events_by_log_index` method but I'm not exactly sure where that bubbles up to: `start_and_await` still returns an `Ok(Starting)` not an `Ok(StoppedWithError)`. That might be a bug in our `Service` code, or might be meant to be used differently. Not sure. So I just check that the `Log` isn't included in the test... ~I had to modify `MockMiddleware` to only let you take the batch once. Before it would error and then just try again and call the same value over and over and never exited. Making some assumptions there too.~ --------- Co-authored-by: Green Baneling <[email protected]>
crypto523
added a commit
to crypto523/fuel-core
that referenced
this issue
Oct 7, 2024
closes FuelLabs/fuel-core#1772 *** Had to modify `MockDB` to also maintain order. This code only works if the Relayer DB maintains order. In production it is stored as a `Mappable` with value being `[Event]`: ``` impl Mappable for EventsHistory { /// The key is the height of the DA. type Key = Self::OwnedKey; type OwnedKey = DaBlockHeight; /// The value is an events happened at the height. type Value = [Event]; type OwnedValue = Vec<Event>; } ``` So it should be good. This approach is flakier than having the relayer reader in the executor ensure the order, but it could add a lot of extra execution cost to the executor code if we put the sorting on that side. We are already making assumptions about what the writing code is doing though. For example, if an event is missing from L1, correct order doesn't matter. So why not add more assumptions :P *** We require that all `Logs`include the `log_index` so we can sort them. So I added a test `relayer__if_a_log_does_not_include_index_then_event_not_included` to check the sad path. **I'm not positive this is the behavior we want.** It is erroring in the `sort_events_by_log_index` method but I'm not exactly sure where that bubbles up to: `start_and_await` still returns an `Ok(Starting)` not an `Ok(StoppedWithError)`. That might be a bug in our `Service` code, or might be meant to be used differently. Not sure. So I just check that the `Log` isn't included in the test... ~I had to modify `MockMiddleware` to only let you take the batch once. Before it would error and then just try again and call the same value over and over and never exited. Making some assumptions there too.~ --------- Co-authored-by: Green Baneling <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We are now writing the merkle root of all the events received via the relayer to the header of each block. It is important that the order of those events is the same for all nodes verifying blocks so that the merkle root is the same.
Related to #1769
The text was updated successfully, but these errors were encountered: