-
Notifications
You must be signed in to change notification settings - Fork 4
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
Conversation
There was a problem hiding this 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
?
This is a draft and I hadn't requested a review yet :) Also see the commit title |
8c897a6
to
5ae4356
Compare
There was a problem hiding this 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.
bin/spark-evaluate.js
Outdated
// Bypass NonceManager as we need to cancel transactions with the same nonce | ||
signer: wallet | ||
}) | ||
const submitScores = async (participants, values) => { |
There was a problem hiding this comment.
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
.)
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
const submitScoresCalls = [] | ||
const submitScores = async (participantAddresses, scores) => { | ||
submitScoresCalls.push({ participantAddresses, scores }) | ||
} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 intosetScoresCalls
. That doesn't make sense. It's only coherent if we also renamesubmitScores
tosetScores
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!
There was a problem hiding this comment.
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
@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? |
Docs for reference: https://spacemeridian.notion.site/Meridian-Off-chain-scheduled-rewards-f9480ef009464ecfaf02a4f752cc4d70#6b1b57295e3046a395085473027d8942 The steps are:
We should write a CLI for this, as doing this manually is brittle. I'll do that next.
We don't need to migrate anything, as calling |
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. |
There was a problem hiding this 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).
Converted to draft as these projects should have
|
CheckerNetwork/roadmap#161
Closes #364