Skip to content

refactor(StakeVault): Remove obsolete trust stake manager logic #237

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

3esmit
Copy link
Contributor

@3esmit 3esmit commented Aug 2, 2025

Description

Fixes #234
Replaces #235

This PR simply removes the logic of requring to trust the stake manager on every upgrade.

The reason for this is because there is no advantage or risk for funds if the stake manager upgraded. The leave function operates regardless of the stake manager being upgraded, and is a escape hatch for the case something bad happens during the upgrade.
There is no need for checking if the upgrade happened or not because the user still needs to wait the stake lock period, so leave also works as a unstake function.

Checklist

Ensure you completed all of the steps below before submitting your pull request:

  • Added natspec comments?
  • Ran pnpm adorno?
  • Ran pnpm verify?

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR removes the obsolete trust stake manager logic from the StakeVault contract. The logic previously required users to explicitly trust the stake manager on every upgrade, but this has been determined to be unnecessary since the leave function provides an adequate escape hatch regardless of stake manager upgrade status.

Key changes:

  • Removed trust-based access control for stake manager operations
  • Simplified the leave function to work without trust checks
  • Cleaned up related test cases and error definitions

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/StakeVault.sol Removed trust stake manager logic, error definitions, and access control modifiers
test/StakeVault.test.sol Removed tests for trust-based restrictions and updated leave function test
test/RewardsStreamerMP.t.sol Removed comprehensive trust manager upgrade test scenarios
.gas-snapshot Updated gas consumption measurements reflecting the simplified code
.gas-report Updated detailed gas usage reports for modified functions

Comment on lines +262 to 265
function updateLockUntil(uint256 _lockUntil) external {
if (msg.sender != address(stakeManager)) {
revert StakeVault__NotAuthorized();
}
Copy link
Preview

Copilot AI Aug 2, 2025

Choose a reason for hiding this comment

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

The updateLockUntil function removes the onlyTrustedStakeManager modifier but still has access control logic inside. This creates an inconsistency where the function is publicly callable but has internal authorization checks. Consider adding a proper access control modifier or make the access control more explicit in the function signature.

Suggested change
function updateLockUntil(uint256 _lockUntil) external {
if (msg.sender != address(stakeManager)) {
revert StakeVault__NotAuthorized();
}
function updateLockUntil(uint256 _lockUntil) external onlyTrustedStakeManager {

Copilot uses AI. Check for mistakes.

Comment on lines +165 to 168
// We have to `try/catch` here in case the upgrade was bad and `leave()`
// either doesn't exist on the new stake manager or reverts for some reason.
// If it was a benign upgrade, it will cause the stake manager to properly update
// If it was a good upgrade, it will cause the stake manager to properly update
// its internal accounting before we move the funds out.
Copy link
Preview

Copilot AI Aug 2, 2025

Choose a reason for hiding this comment

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

[nitpick] The comment has been updated from 'malicious' to 'bad' but the explanation is incomplete. The comment should clarify what constitutes a 'bad' upgrade and why the try/catch is necessary for proper error handling.

Copilot uses AI. Check for mistakes.

@github-project-automation github-project-automation bot moved this from Needs Review to Ready to Merge in Tasks - Smart Contracts Aug 4, 2025
@0x-r4bbit
Copy link
Collaborator

This doesn't pass certora atm.

Pls fix that first - otherwise, good changes!

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

Successfully merging this pull request may close these issues.

Remove or refactor zombie trustStakeManager logic in StakeVault.sol
2 participants