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

PoR Off-Chain #914

Merged
merged 21 commits into from
Nov 15, 2023
Merged

PoR Off-Chain #914

merged 21 commits into from
Nov 15, 2023

Conversation

bayram98
Copy link
Contributor

@bayram98 bayram98 commented Nov 13, 2023

Description

This PR is ready to review. Main changes with this PR is to make a separate directory to POR, where it will be running upon request.

How to run PoR

  1. Define env variables with new addition POR_AGGREGATOR_HASH
  2. Build: yarn build
  3. Run por: yarn start:por

Changes:

  • new env variable POR_AGGREGATOR_HASH
  • new directory for PoR, includes fetching and reporting of data.

Fixes # (issue)

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 self-assigned this Nov 13, 2023
@bayram98 bayram98 linked an issue Nov 13, 2023 that may be closed by this pull request
@bayram98 bayram98 requested review from martinkersner and a user November 15, 2023 02:43
@bayram98 bayram98 marked this pull request as ready for review November 15, 2023 03:00
@bayram98 bayram98 requested a review from a team as a code owner November 15, 2023 03:00
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 comments, but they are more recommendation and we can fix it in next PR. It is usually related to reuse of implementation from other files so we do not copy & paste code.

BTW I notice, you store data only in data table. It would be better to store it also in aggregate table which is then used for visualizations.

core/src/por/api.ts Show resolved Hide resolved
core/src/por/api.ts Show resolved Hide resolved
}

async function fetchData(feed) {
const rawDatum = await (await axios.get(feed.url)).data
Copy link
Member

Choose a reason for hiding this comment

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

We should make try-catch block here.

@@ -0,0 +1,71 @@
import { PorError, PorErrorCode } from './errors'

export const DATA_FEED_REDUCER_MAPPING = {
Copy link
Member

Choose a reason for hiding this comment

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

Can't we just import the reducer, rather than copy it?

Copy link
Collaborator

@nick-bisonai nick-bisonai Nov 15, 2023

Choose a reason for hiding this comment

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

would it be okay to import reducer.ts from ./src/worker/reducer.ts? thought por can't refer from worker folder

@@ -8,7 +8,6 @@ export class FetcherError extends Error {
}

export enum FetcherErrorCode {
IncompleteDataFeed,
Copy link
Member

Choose a reason for hiding this comment

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

Is this update somehow related to the PoR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is from fetcher. I realized that we did not used it anywhere tried to clean-up.

Copy link
Member

Choose a reason for hiding this comment

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

Okay! Good good!

Copy link
Collaborator

Choose a reason for hiding this comment

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

it would be appreciated if you could make a separate PR for refactoring from next time :)

@@ -0,0 +1,6 @@
export interface IData {
Copy link
Member

Choose a reason for hiding this comment

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

If possible, it would be also good if we can reuse the implementation from other files. We don't have to do it now, but we should at least make an issue for it.

core/src/por/reporter.ts Show resolved Hide resolved
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

LGTM

@bayram98
Copy link
Contributor Author

@martinkersner @nick-bisonai I will merge the PR now, and will make a new PR for the recommend changes.

@bayram98 bayram98 merged commit edbde75 into master Nov 15, 2023
1 check passed
@bayram98 bayram98 deleted the i-913/feat/script-for-PoR branch November 15, 2023 04:18
@bayram98 bayram98 mentioned this pull request Nov 15, 2023
@bayram98 bayram98 restored the i-913/feat/script-for-PoR branch November 15, 2023 08:10
@martinkersner martinkersner changed the title PoR PoR Off-Chain Nov 16, 2023
@bayram98 bayram98 mentioned this pull request Nov 17, 2023
8 tasks
@bayram98 bayram98 deleted the i-913/feat/script-for-PoR branch November 22, 2023 04:49
@bayram98 bayram98 mentioned this pull request Nov 28, 2023
8 tasks
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.

Implement single script for PoR
3 participants