fix: invalidate proposal score when out-of-range #280
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🧿 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 like1e47
💊 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
ER_WARN_DATA_OUT_OF_RANGE
on a closed proposal, mark its score_state asinvalid
{"error":"failed","message":"Invalid out of range score"}
when computing fail with out-of-range score, when asked via/scores/:proposalId
🛠️ Tests
scores_state
topending
in the db{"error":"failed","message":"Invalid out of range score"}
scores_state
should be updated toinvalid
If the proposal was not closed yet, it should not set the
scores_state
toinvalid
, but call to sequencer should still return the same error messageOther
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 ...)