Skip to content

Add integrate spark-rewards #338

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

Merged
merged 12 commits into from
Oct 13, 2024
Merged

Add integrate spark-rewards #338

merged 12 commits into from
Oct 13, 2024

Conversation

juliangruber
Copy link
Member

@juliangruber juliangruber commented Aug 30, 2024

Copy link
Member

@bajtos bajtos left a comment

Choose a reason for hiding this comment

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

See the comment below.

GitHub also shows a bunch of TypeScript errors. Did you run the npm test?

@juliangruber
Copy link
Member Author

See the comment below.

GitHub also shows a bunch of TypeScript errors. Did you run the npm test?

This is a draft and I hadn't requested a review yet :) Also see the commit title

@juliangruber juliangruber requested a review from bajtos October 2, 2024 11:59
@juliangruber juliangruber marked this pull request as ready for review October 2, 2024 11:59
Copy link
Member

@bajtos bajtos left a comment

Choose a reason for hiding this comment

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

Great work!

I have a few comments to discuss, PTAL below.

// Bypass NonceManager as we need to cancel transactions with the same nonce
signer: wallet
})
const submitScores = async (participants, values) => {
Copy link
Member

Choose a reason for hiding this comment

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

Can you please move this function to lib? I'd like to keep bin files as high-level glue connecting bits imported from lib.

Is it worth adding a test for it? (E.g. using a mocked fetch.)

Copy link
Member Author

Choose a reason for hiding this comment

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

I've refactored the function, I think adding tests is lower priority due to the simplicity of the function, therefore I added a comment about adding tests in the future instead

Copy link
Member

Choose a reason for hiding this comment

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

I've refactored the function,

Thank you!

I think adding tests is lower priority due to the simplicity of the function, therefore I added a comment about adding tests in the future instead

I am curious - have you ever run this code, or will we execute it for the first time in production?

We did the latter recently (#363, landed on Sept 24th) and there was a bug we did not discover & fix until the next day (#368).

Please watch the production after landing this PR until the first round is evaluated & scores are submitted to ensure the code works as intended.

test/evaluate.js Outdated
Comment on lines 58 to 61
const submitScoresCalls = []
const submitScores = async (participantAddresses, scores) => {
submitScoresCalls.push({ participantAddresses, scores })
}
Copy link
Member

Choose a reason for hiding this comment

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

Can you preserve the name setScoresCall to reduce the code churn?

I am surprised we don't need to include the roundIndex when submitting scores. Could the lack of roundIndex make debugging more difficult for us?

How do you feel about keeping the setScores signature in the interfaces, i.e. modify submitScores to require (roundIndex, participantAddresses, scores), even if the actual implementation calling spark-rewards does not use the round index?

Since it's something used by the previous version, I think we may need to have it again in the future. I know it's just a speculation violating YAGNI principle, so 🤷🏻 What I like most is that if we preserve the signature then there will be much fewer changes in the existing tests.

Copy link
Member Author

Choose a reason for hiding this comment

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

Can you preserve the name setScoresCall to reduce the code churn?

This would mean we have a function submitScores that pushes into setScoresCalls. That doesn't make sense. It's only coherent if we also rename submitScores to setScores everywhere. I'm ok with that, wdyt?

I am surprised we don't need to include the roundIndex when submitting scores. Could the lack of roundIndex make debugging more difficult for us?

spark-rewards has no notion of rounds. What would we need the round index for?

How do you feel about keeping the setScores signature in the interfaces, i.e. modify submitScores to require (roundIndex, participantAddresses, scores), even if the actual implementation calling spark-rewards does not use the round index?

We don't need that right now so I'm against it and think we shouldn't spend time discussing it. If you feel strongly I'll just change it.

Copy link
Member

Choose a reason for hiding this comment

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

Can you preserve the name setScoresCall to reduce the code churn?

This would mean we have a function submitScores that pushes into setScoresCalls. That doesn't make sense. It's only coherent if we also rename submitScores to setScores everywhere. I'm ok with that, wdyt?

rename submitScores to setScores everywhere sounds good to me 👍🏻

I am surprised we don't need to include the roundIndex when submitting scores. Could the lack of roundIndex make debugging more difficult for us?

spark-rewards has no notion of rounds. What would we need the round index for?

For troubleshooting - e.g. to detect a duplicate submission of scores for the same round, or a round with no scores submitted.

It also allows us to implement idempotency in spark-rewards: we can add pRetry to spark-evaluate and drop duplicate scores for the same round on the spark-rewards side.

How do you feel about keeping the setScores signature in the interfaces, i.e. modify submitScores to require (roundIndex, participantAddresses, scores), even if the actual implementation calling spark-rewards does not use the round index?

We don't need that right now so I'm against it and think we shouldn't spend time discussing it. If you feel strongly I'll just change it.

Ack!

Copy link
Member Author

Choose a reason for hiding this comment

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

rename submitScores to setScores everywhere sounds good to me 👍🏻

Done!

For troubleshooting - e.g. to detect a duplicate submission of scores for the same round, or a round with no scores submitted.

It also allows us to implement idempotency in spark-rewards: we can add pRetry to spark-evaluate and drop duplicate scores for the same round on the spark-rewards side.

I opened a new issue for this, I don't see it as release blocking: CheckerNetwork/spark-rewards#15

@bajtos
Copy link
Member

bajtos commented Oct 4, 2024

@juliangruber could you please remind me what's the plan for paying out rewards tracked by spark-rewards and how are we going to handle the migration - what are the next steps after landing this PR up to the first payout of rewards?

@juliangruber
Copy link
Member Author

@juliangruber could you please remind me what's the plan for paying out rewards tracked by spark-rewards

Docs for reference: https://spacemeridian.notion.site/Meridian-Off-chain-scheduled-rewards-f9480ef009464ecfaf02a4f752cc4d70#6b1b57295e3046a395085473027d8942

The steps are:

  1. GET /scores on spark-rewards
  2. addBalances() on the IE
  3. POST /paid on spark-rewards

We should write a CLI for this, as doing this manually is brittle. I'll do that next.

and how are we going to handle the migration - what are the next steps after landing this PR up to the first payout of rewards?

We don't need to migrate anything, as calling releaseRewards() on the IE will release rewards both from before and after merging this PR. I will take care of updating the docs.

@juliangruber juliangruber requested a review from bajtos October 4, 2024 11:01
@bajtos
Copy link
Member

bajtos commented Oct 7, 2024

@juliangruber could you please remind me what's the plan for paying out rewards tracked by spark-rewards

Docs for reference: https://spacemeridian.notion.site/Meridian-Off-chain-scheduled-rewards-f9480ef009464ecfaf02a4f752cc4d70#6b1b57295e3046a395085473027d8942

The steps are:

  1. GET /scores on spark-rewards
  2. addBalances() on the IE
  3. POST /paid on spark-rewards

We should write a CLI for this, as doing this manually is brittle. I'll do that next.

and how are we going to handle the migration - what are the next steps after landing this PR up to the first payout of rewards?

We don't need to migrate anything, as calling releaseRewards() on the IE will release rewards both from before and after merging this PR. I will take care of updating the docs.

Perfect!

Do we need to make any changes inside Station Core and/or Station Desktop to let the chart in the Station Desktop UI to show the correct amount of scheduled rewards? This amount can be a combination of scheduled rewards tracked by the smart contract and by spark-rewards.

Copy link
Member

@bajtos bajtos left a comment

Choose a reason for hiding this comment

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

The new version is good enough 👍🏻

Please take a look at #338 (comment) before landing.

EDIT

Also please consider the impact on Station Desktop UI before landing, see #338 (comment).

@juliangruber juliangruber marked this pull request as draft October 7, 2024 13:38
@juliangruber
Copy link
Member Author

juliangruber commented Oct 7, 2024

Converted to draft as these projects should have spark-rewards integrated first:

  • core
  • spark-stats
  • telegraf

@juliangruber

This comment was marked as outdated.

@juliangruber juliangruber marked this pull request as ready for review October 13, 2024 08:59
@juliangruber juliangruber merged commit 5da35f5 into main Oct 13, 2024
6 checks passed
@juliangruber juliangruber deleted the add/spark-rewards branch October 13, 2024 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Error: failed to lookup Eth Txn 0xff4599c1cb901...
2 participants