Skip to content
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

Shifted Oracle frame in case of missed epoch #419

Open
avsetsin opened this issue Dec 29, 2023 · 1 comment
Open

Shifted Oracle frame in case of missed epoch #419

avsetsin opened this issue Dec 29, 2023 · 1 comment

Comments

@avsetsin
Copy link
Contributor

Issue

In a rare scenario, when at least a whole epoch containing a report ref slot is missed, the Oracle reports data for a narrower frame.

The method get_reference_blockstamp is used in the Oracle to fetch a slot and block that will be used for report collection. The method finds the nearest non-missed slot and uses it to collect data. This solution assumes that the state does not change without a block. However, there is a scenario in which the state of validators is changed for a missed slot. This scenario comes up during epoch transition, where the state is updated even if a first slot in epoch is missed during the state_transition execution in the first non-missed slot.

Example

Let's consider an example:

[ ] - missed slot
[o] - slot with block

        epoch start      ref slot   
        v                v
... [o][ ][ ] ... [ ][ ][ ][o] ...
    31 32 33  ... 61 62 63 64   - slot numbers
    10 -  -       -  -  -  11   - block numbers

In the example, an epoch including ref slot of an Oracle report is missed. According to the current implementation, the Oracle will collect report on slot 31 (block 10), while the state for slot 32 will be different from the state for slot 31. The state for slot 32 will be changed in the chain of method calls state_transition -> process_slots -> process_epoch when the next block is included in the chain at slot 64 (block 11), which is outside the epoch and after the ref slot.

Specification: https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#beacon-chain-state-transition-function

Impact

Since the Oracle collects a snapshot of the state, rather than the difference between reports, the subsequent Oracle report will take into account all changes during the period not covered by the previous report, but the boundary of the report frames will be shifted by the number of missed epochs:

   |<------------->|<--------------->| actual frames
   |<-------------->|<-------------->| expected frames
---|----------------|----------------|----------------> time
   ^               ^^                ^
   ref slot        missed epochs     ref slot
@ujenjt
Copy link
Member

ujenjt commented Dec 29, 2023

Thanks for describing the case, I think there is low chance that this situation would take place in wild. Looks like the only impact is shifting of frames and no accuracy lost. Would be very nice to fix in one of future oracle updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants