-
Notifications
You must be signed in to change notification settings - Fork 179
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
[EFM] Bug: Service Events Emitted outside System Chunk fail verification #6622
Comments
I think we will want to use service event hashes rather than indices in the EventsCollection proof.
|
Notes from conversation with @zhangchiqingGenerally onboard with design, and agrees that Option 2 is better overall. Pointed out that changing the meaning of Rough overview of additional work this would entail
|
I took a loot at option 3, which I like very much:
In my opinion, Option 3 is the best so far (if we can work it out without discovering other major complexities). |
Addressed by #6744 |
Context
In #5828, we modified the definition of Service Events to allow emission outside the context of the system chunk. This was done to simplify the smart contract code associated with emitting service events.
Bug Description
Verification Nodes make assumptions about service events during verification which no longer hold. In particular, they assume that all service events attached to an
ExecutionResult
were emitted during the system chunk.flow-go/module/chunks/chunkVerifier.go
Lines 294 to 302 in c632c51
This results in verification failing when verifying the system chunk:
ExecutionResult
Proposed Solution
VNs only process a subset of chunks. Because of that, we need to both:
Solution 1 - Add service event chunk mapping to
ExecutionResult
data structureThe simplest way to communicate which service event was emitted in which chunk is to add this to the
ExecutionResult
data structure, which is a part of the Block. We can make one of the following modifications:ExecutionResult.Chunks
- We can put aServiceEventIndices
here referencing the outerExecutionResult.ServiceEvents
ExecutionResult.ServiceEvents
- Or, we can put aChunkIndex
here referencing where the event was emittedAlthough logically simpler, this solution requires a change to the Block data model, which is used in both the networking and storage layers. Coordinating these changes in a Protocol HCU would be much more challenging and error-prone.
Solution 2 - Add service event index branch to
ChunkBody.EventsCollection
Merkle commitmentIn this solution, we re-use the existing
ChunkBody.EventsCollection
field, but extend the underlying Merkle tree to include information about service events.ChunkBody.EventsCollection
ChangesCurrently this field is the root hash of the Merkle tree formed by the ordered list of events. We propose adding a branch to the Merkle tree to include the indices of service events. This way the ExecutionResult contains a commitment to which service events are emitted in which chunk.
The diagram below shows a scenario where there an ExecutionResult has multiple service events, not all emitted in the same chunk. We are looking at one of the chunks, in which service events S2, S3 (indices 1,2) were emitted:
ChunkDataPack
ChangesThe
ChunkDataPack
needs to include enough information for Verification Nodes to:ExecutionResult.ServiceEvents
field are associated with some chunk (caution order sensitive)To accomplish this, we make the following data model changes to
ChunkDataPack
:ServiceEventIndicesProofs
) which is a list with one proof for each chunk. Each element looks like:EventsCollection
Merkle tree. This contains:ServiceEventIndices
- the concrete value of the new top-level right branch of the Merkle TreeEventsHash
(Verification Logic Changes
Verification Nodes will determine the list of expected service events for their chunk committed by the Execution Node by using the
ServiceEventIndices
field from theChunkDataPack
. They will verify that the service events they compute are equal to the expected list.Additional verification requirements:
ServiceEventIndicesProofs
ServiceEventIndicesProofs
is internally consistent and consistent withExecutionResult.ServiceEvents
.ServiceEventIndices
lists for consecutive chunks should result in exactly the list[0,1,...,n-1]
, wheren=len(ExecutionResult.ServiceEvents)
n=0
, allServiceEventIndices
are empty.Compatibility
ChunkDataPack
storage (EN)ChunkDataPack
network messages (EN/VN)ChunkDataPack
construction business logic (EN)Solution 3 - Chunk-Indexed generic service events (wip)
The
ServiceEvent.Event
field is currentlyinterface{}
-typed. Currently the concrete values added here are instances ofEpochSetup
, etc. If we replace these concrete values withChunkIndexed[ServiceEvent]
, a wrapper which includes a chunk index.This would:
Block
ServiceEvent.Event
, if the underlying type is notChunkIndexed
, we infer a ChunkIndex of 0 (all service events prior to this change)The text was updated successfully, but these errors were encountered: