forbole / flowJuno

Creative Commons Zero v1.0 Universal
2 stars 1 forks source link

Get exact epoch end time #10

Closed HarleyAppleChoi closed 2 years ago

HarleyAppleChoi commented 2 years ago

Feature description

Since epoch end at approximately 12:00 pm PT on Tuesday (7:00 pm UTC). There are possibilities that the epoch not end on time due to some accident or upgrade. The variance in epoch length to be less than 2 hours for a 1-week epoch (~1%). Therefore, there should be some additional operation to monitor the epoch changes.

Implementation proposal

This explains how epoch changes. The system should monitor the transaction about flowEpoch.endEpoch() in real time

HarleyAppleChoi commented 2 years ago

May look at payreward() to listen to the reward emmitted events

HarleyAppleChoi commented 2 years ago

Do an additional operation to monitor if the last ~100 blocks have EpochTotalRewardsPaid event emitted. If yes, do the node operator/delegator balance scan. @kwunyeung do you think it is a good idea?

kwunyeung commented 2 years ago

Is it possible to track the reward payout transaction?

HarleyAppleChoi commented 2 years ago

@kwunyeung Yes There are Events emitted when having reward payout transactions:

We can scan NewEpoch event emitted in the last ~50 blocks like every ~1 minute. Once that is emitted, do the balance scan. Is that good?

HarleyAppleChoi commented 2 years ago

Or we can do it for every block parsed. If NewEpoch event is in the block, do the balance scan. I think that is not good especially when flowjuno is parsing old blocks. It will scan so many time when parsing old block, but that is at the same epoch.

kwunyeung commented 2 years ago

@HarleyAppleChoi what do you mean

but that is at the same epoch

for the old blocks?

HarleyAppleChoi commented 2 years ago

Scanning latest validators and delegators status. If the trigger is just finding event message at block parsing event instead of fetching event at latest blocks, the latest status may get scan so many times when parsing old block.

kwunyeung commented 2 years ago

Do you know which epoch would it be when you see the event in previous blocks?

HarleyAppleChoi commented 2 years ago

@kwunyeung Yes but the gRPC endpoints for Flow are unstable when executing scripts from old states See here. Even we find an end epoch event on some block, we cannot require the state on that epoch yet

kwunyeung commented 2 years ago

I see. For the old state, I think we can copy those data from some existing public data, e.g, another explorer.

HarleyAppleChoi commented 2 years ago

Flowscan seems don't have historical data for validators but only

kwunyeung commented 2 years ago

Let’s ping the FLOW team and see how they can be retrieved.