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

feat: Fetch epoch info from the RewardDistribution contract #3

Merged
merged 10 commits into from
Jan 5, 2022

Conversation

nduchak
Copy link
Contributor

@nduchak nduchak commented Dec 2, 2021

No description provided.

@nduchak nduchak marked this pull request as ready for review December 8, 2021 09:51
@nduchak nduchak force-pushed the feat/multy-chain-volume-tracker branch from 7f61d09 to 34aabe6 Compare December 8, 2021 15:57
@nduchak nduchak changed the title feat: multy chain feat: multy chain and epoch listening Dec 8, 2021
Copy link
Contributor

@ColonelJ ColonelJ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Part of the information for each epoch is stored on chain, including the number of epochs and calc timestamps and send blocknumber/timestamps for each epoch. Some of this info is required (calc timestamp), and anyway it might be better for the full node if you search for the event only on the individual blocks where they occur rather than a large range of blocks. Somehow there needs to be a check that you got the events for all the epochs you expect. Also the CurrentEpoch in StakingSettings can probably be set based on the number of epochs read from the SC and increased when there is a new distribution event. If something goes wrong with getting epoch info, the service should probably be crashed with process.exit so we can know about it...

decodedLog.args.epoch.toString(),
{
endBlockNumber: blockNumber,
calcTimeStamp: 1,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The calcTimeStamp is stored on chain and needs to be retrieved for each epoch.

@shresthagrawal
Copy link
Contributor

I agree with Jason's comments! You can follow the following sequence:

  1. Fetch the currentEpoch
  2. For each epoch index before the currentEpoch
    1. Fetch the epochHistory[i] to get sendBlockNumber, and calcTimestamp
    2. Use sendBlockNumber to fetch for exact event
    3. Set the all the info about the epoch
    • If anything in this level fails log an error, retry n times and finally throw an error
  • if you get any error simply catch, log and process.exit

add retries for epoch info retrieving
Copy link
Contributor

@ColonelJ ColonelJ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You still need to update CurrentEpoch in StakingSettings.

@shresthagrawal shresthagrawal changed the title feat: multy chain and epoch listening feat: Fetch epoch info from the RewardDistribution contract Jan 4, 2022
@shresthagrawal shresthagrawal merged commit ba6cc5e into master Jan 5, 2022
@shresthagrawal shresthagrawal deleted the feat/multy-chain-volume-tracker branch January 5, 2022 05:52
mwamedacen added a commit that referenced this pull request Mar 28, 2022
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

Successfully merging this pull request may close these issues.

3 participants