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: invalidate proposal score when out-of-range #280

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

wa0x6e
Copy link
Contributor

@wa0x6e wa0x6e commented Jan 16, 2024

🧿 Current issues / What's wrong ?

When computing final proposal scores, some computation fail with the sql ER_WARN_DATA_OUT_OF_RANGE error.

This happens when the total scores returned by the strategies exceed the allowed size for the SQL column (decimal(64,30)). Those kind of error happen when the total score is something like 1e47

💊 Fixes / Solution

Fix #279
Fix #281
Fix SNAPSHOT-SEQUENCER-2P

In case total score is invalid, rescue the error, and return an appropriate message to show when calling /scores/proposalID.

🚧 Changes

  • In case of ER_WARN_DATA_OUT_OF_RANGE on a closed proposal, mark its score_state as invalid
  • Return {"error":"failed","message":"Invalid out of range score"} when computing fail with out-of-range score, when asked via /scores/:proposalId

🛠️ Tests

If the proposal was not closed yet, it should not set the scores_state to invalid, but call to sequencer should still return the same error message

Other

Additionally, should we update https://github.com/snapshot-labs/snapshot-strategies?tab=readme-ov-file#code to define guideline about the score value ? (max value, best practice, etc ...)

Copy link

codecov bot commented Jan 16, 2024

Codecov Report

Attention: 23 lines in your changes are missing coverage. Please review.

Files Patch % Lines
src/scores.ts 4.54% 21 Missing ⚠️
src/api.ts 0.00% 2 Missing ⚠️
Additional details and impacted files

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant