-
Notifications
You must be signed in to change notification settings - Fork 15
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: check for duplicate vote in verify #194
base: master
Are you sure you want to change the base?
Conversation
const votes = await db.queryAsync( | ||
'SELECT created FROM votes WHERE voter = ? AND proposal = ? AND space = ? ORDER BY created DESC LIMIT 1', | ||
[body.address, msg.payload.proposal, msg.space] | ||
); | ||
|
||
// Reject vote with later timestamp | ||
if (votes[0]?.created > msgTs) { | ||
return Promise.reject('already voted at later time'); | ||
} |
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.
It is already checked in action right https://github.com/snapshot-labs/snapshot-sequencer/blob/use-alias-schema/src/writer/vote.ts#L148 ? maybe we should remove that if we already check it in verify
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 think the check inside action
is to there in case some other threads/container are processing the same exact request, and is still needed, since we can't guarantee that the check inside verify
is valid.
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.
mm better to handle parallel requests in requestDeduplicator, because this can cause duplicate query and code, meaning additional time to vote for users 🙈
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.
We should move all inside verify
, after implementing requestDeduplicator #202
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.
mmm better to install deduplication first
Superseded by #216 , should still move the check from |
If a vote already exist, we check that the new vote is more recent that the existing one before inserting, in the vote's
action
function.We should also do the same in the
verify
function, to avoid a call to get voting power.This kind of error is currently the slowest one: