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

test: add mass delegation and gas usage tests in Votes.test.js #5217

Conversation

techvoyagerX
Copy link
Contributor

Summary:
This PR adds new test cases to test/governance/utils/Votes.test.js to cover high-volume voting delegation scenarios, aiming to assess gas usage efficiency when delegating with multiple accounts. Specifically, the tests focus on mass delegations involving 100+ accounts and measure the gas consumption of these operations.

Changes:

  1. New test cases for mass voting delegation involving 100+ accounts.
  2. Gas usage tracking for mass delegation operations to evaluate efficiency.
  3. Updated logic for testing delegation behaviors under stress.

These tests help surface potential gas optimization opportunities in high-traffic delegation scenarios.

Copy link

changeset-bot bot commented Sep 20, 2024

⚠️ No Changeset found

Latest commit: 9bb1948

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

// New test: mass delegation with 100 accounts
describe('mass delegation operations', function () {
beforeEach(async function () {
this.massAccounts = this.accounts.slice(0, MASS_DELEGATION_ACCOUNTS_COUNT);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this.accounts is not that long. we would need to generate wallets differently

Comment on lines +135 to +136
const totalGas = gasCosts.reduce((a, b) => a.add(b), ethers.BigNumber.from(0));
console.log('Total gas used for mass delegation:', totalGas.toString());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't track gas usage through console.log. We have the gas reports for that

Copy link
Collaborator

@Amxx Amxx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understand why that test is needed. What it does is having many account delegate they votes to a single delegate ... and measure the gas cost

The things is that the delegation operation has a "constant" cost. Said otherwize, the cost of delegating to a particular account does not depend on the number of other users that have already delegated to this account.

The only part where gas cost in not constant, is when doing a past lookup getPastVotes. This will depend on the number of checkpoints in that account's _delegateCheckpoints. This is something we already measure.

Overall, I think this test a major issue (it assumes this.accounts contains enough accounts, which it doesn't) ... and doesn't test anything interresting.

@Amxx Amxx closed this Oct 2, 2024
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