-
Notifications
You must be signed in to change notification settings - Fork 11.9k
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
test: add mass delegation and gas usage tests in Votes.test.js #5217
Conversation
|
// 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); |
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.
this.accounts is not that long. we would need to generate wallets differently
const totalGas = gasCosts.reduce((a, b) => a.add(b), ethers.BigNumber.from(0)); | ||
console.log('Total gas used for mass delegation:', totalGas.toString()); |
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 don't track gas usage through console.log. We have the gas reports for that
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'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.
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:
These tests help surface potential gas optimization opportunities in high-traffic delegation scenarios.