espresso-sequencer
espresso-sequencer copied to clipboard
2879 extend staketable contract to override voting methods
Closes #2879
This PR:
- modifies
StakeTableto integrate with OpenZeppelin'sVotesUpgradeablefor on-chain governance - adds
_getVotingUnitsoverride to reflect voting power based on staking delegation - adds validation to prevent invalid delegation scenarios (e.g., validator delegating to self, or delegating to different validators)
- updates
delegateandundelegatelogic to allow delegating all tokens or a specific amount, and properly handles partial and full undelegations
This PR does not:
- implement fuzz testing, marked as TODO
- override checkpoints and numCheckpoints logic, marked as TODO
- also need to get better at describing staking, delegating in the comments
Key places to review:
contracts/src/StakeTable.sol: core changes to logic, inheritancecontracts/test/StakeTable.t.sol: tests for voting behavior under VotesUpgradeable._delegateStakeand_undelegateStakeinternal functions- the override of
_getVotingUnitsanddelegate()to ensure compatibility with OpenZeppelin governance.
How to test this PR:
forge test --match-contract StakeTableVotes