Skip to content

Conversation

wa0x6e
Copy link
Contributor

@wa0x6e wa0x6e commented Oct 6, 2023

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:

Screenshot 2023-10-06 at 06 55 55

@wa0x6e wa0x6e requested a review from ChaituVR October 6, 2023 16:54
Comment on lines +52 to +60
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');
}
Copy link
Member

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

Copy link
Contributor Author

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.

Copy link
Member

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 🙈

Copy link
Contributor Author

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

Copy link
Member

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

@wa0x6e
Copy link
Contributor Author

wa0x6e commented Oct 24, 2023

Superseded by #216 , should still move the check from action to verify

@wa0x6e wa0x6e closed this Aug 21, 2025
Copy link

codecov bot commented Aug 21, 2025

Codecov Report

❌ Patch coverage is 0% with 11 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/writer/vote.ts 0.00% 11 Missing ⚠️

📢 Thoughts on this report? Let us know!

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

Successfully merging this pull request may close these issues.

2 participants