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

Fix PoR #931

Merged
merged 37 commits into from
Nov 20, 2023
Merged

Fix PoR #931

merged 37 commits into from
Nov 20, 2023

Conversation

bayram98
Copy link
Contributor

@bayram98 bayram98 commented Nov 15, 2023

Description

This PR is ready to review. Mainly tried to solve the issue from previous Pr(#914).
Changes:

  • add insertAggregateData function to insert aggregatedData
  • fix the first round submission check issue
  • add POR service type
  • enable reporter to submit with in -60 sec time buffer. This would fix the issue of submitting for 3min instead of 2min.
  • use sibling's for fetcher codes. Will be changed once we make mono repo for orakl-repo. make mono repo for orakl repo #937

Next:

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist before requesting a review

  • I have performed a self-review of my code.
  • If it is a core feature, I have added thorough tests.

Deployment

  • Should publish npm package
  • Should publish Docker image

@bayram98 bayram98 linked an issue Nov 15, 2023 that may be closed by this pull request
@bayram98 bayram98 changed the title FIX PoR add webhook error messages Nov 16, 2023
@bayram98 bayram98 changed the title add webhook error messages Fix PoR Nov 16, 2023
@bayram98 bayram98 self-assigned this Nov 17, 2023
@bayram98 bayram98 marked this pull request as ready for review November 17, 2023 02:25
@bayram98 bayram98 requested a review from a team as a code owner November 17, 2023 02:25
Copy link
Collaborator

@nick-bisonai nick-bisonai left a comment

Choose a reason for hiding this comment

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

lgtm!

throw new OraklError(OraklErrorCode.FailedInsertData)
}
}

export async function insertAggregateData({
Copy link
Collaborator

Choose a reason for hiding this comment

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

I have a question.
Where is this function referenced?

Copy link
Member

Choose a reason for hiding this comment

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

@nick-bisonai Inside fetchWithAggregator

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nick-bisonai Here is the reference function.
https://github.com/Bisonai/orakl/blob/master/fetcher/src/job/job.api.ts#L69

The function is called to store the aggregated data through orakl-api.

Copy link
Member

@martinkersner martinkersner left a comment

Choose a reason for hiding this comment

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

LGTM! I left couple of minor comments. Please let me know if I did not misunderstood something :)

@bayram98
Copy link
Contributor Author

LGTM! I left couple of minor comments. Please let me know if I did not misunderstood something :)

I have fixed the issue which you mentioned. Now the PR is ready to merge, please let me know if you have a further comments.

const heartbeat = aggregator.heartbeat

if (updatedAt + heartbeat < timestamp) {
if (heartbeat >= POR_LATENCY_BUFFER && updatedAt + heartbeat - POR_LATENCY_BUFFER < now) {
Copy link
Member

Choose a reason for hiding this comment

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

@bayram98 I think this does not help us to catch the error at the beginning. It will actually hide the issue until the time when we expect the heartbeat to occur.

heartbeat >= POR_LATENCY_BUFFER might evaluate to false and if there is no deviation change, then the function shouldReport returns false and behaves as if nothing wrong happened.

If heartbeat < POR_LATENCY_BUFFER is true, then the settings is wrongly defined, and we should throw an error.

if (heartbeat < POR_LATENCY_BUFFER) {
    throw Error('Heartbeat cannot be smaller then latency buffer.')
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@martinkersner I added your suggestion to check if heartbeat and POR_LATENCY_BUFFER are set correctly or not. Please check it out.

Copy link
Member

Choose a reason for hiding this comment

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

Beautiful! Let's merge!

@bayram98 bayram98 merged commit c963b8e into master Nov 20, 2023
@bayram98 bayram98 deleted the i-929/fix/refactor-POR branch November 20, 2023 05:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix PoR
3 participants