espresso-sequencer icon indicating copy to clipboard operation
espresso-sequencer copied to clipboard

2879 extend staketable contract to override voting methods

Open alysiahuggins opened this issue 6 months ago • 0 comments

Closes #2879

This PR:

  • modifies StakeTable to integrate with OpenZeppelin's VotesUpgradeable for on-chain governance
  • adds _getVotingUnits override 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 delegate and undelegate logic 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, inheritance
  • contracts/test/StakeTable.t.sol: tests for voting behavior under VotesUpgradeable.
  • _delegateStake and _undelegateStake internal functions
  • the override of _getVotingUnits and delegate() to ensure compatibility with OpenZeppelin governance.

How to test this PR:

  • forge test --match-contract StakeTableVotes

alysiahuggins avatar Apr 02 '25 22:04 alysiahuggins