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

feat(protocol): introduce ForkManager to improve protocol fork management #18508

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

Conversation

dantaik
Copy link
Contributor

@dantaik dantaik commented Nov 23, 2024

Currently, the TaikoL1 protocol required each fork's codebase to contain implementations for both the current fork and the next fork within the same contract. This created unnecessary code complexity and tight coupling between fork versions.

With the new ForkManager, we can:

  • Split fork implementations into separate, focused contracts
  • Maintain cleaner separation of concerns between fork versions
  • Support multiple forks as long as their storage layouts remain compatible

This change improves code maintainability and makes the fork upgrade process more modular.

BTW, I'm aware of Diamond proxy design but I'm in favor of this ForkManager implementation for its simplicity.

@dantaik dantaik marked this pull request as ready for review November 23, 2024 07:04
@dantaik
Copy link
Contributor Author

dantaik commented Nov 23, 2024

The storage layout of ForkManager is compatible with the layout of TaikoL1.

Screenshot 2024-11-23 at 15 05 37

@dantaik dantaik enabled auto-merge (squash) November 23, 2024 07:06
Copy link

feat(protocol): introduce ForkManager to improve protocol fork management

Generated at commit: b01e6c3abe604c6c873fe7c7b4d3ea17f167a316

🚨 Report Summary

Severity Level Results
Contracts Critical
High
Medium
Low
Note
Total
3
3
0
7
42
55
Dependencies Critical
High
Medium
Low
Note
Total
0
0
0
0
0
0

For more details view the full report in OpenZeppelin Code Inspector

/// routing logic.
/// @param _selector The function selector of the call.
/// @return A boolean value indicating whether the call should be routed to the old fork.
function shouldRouteToOldFork(bytes4 _selector) internal pure virtual returns (bool) { }
Copy link
Contributor

Choose a reason for hiding this comment

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

If a function has the same selector in oldFork and newFork, how can we clarify?

/// PROXY -> FORK_MANAGER --|
/// +--> oldFork

contract ForkManager is UUPSUpgradeable, Ownable2StepUpgradeable {
Copy link
Member

Choose a reason for hiding this comment

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

Do we need an init method here for proxy deployment?

Comment on lines +20 to +23
/// PROXY -> FORK_MANAGER --|
/// +--> oldFork

contract ForkManager is UUPSUpgradeable, Ownable2StepUpgradeable {
Copy link
Contributor

Choose a reason for hiding this comment

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

An instance of this ForkManager (even behind proxy) is not really upgradeable, or at least not the 2 main variables (oldFork, newFork).
Since you placed here a constructor and not init, i suppose it is intentional from your side, but in this case we dont need the Upgradeable pattern. (Or if we do want to do that, just remove the immutability of the 2 fields).

return true;
}

function _fallback() internal virtual {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should not we restrict reentrancy ? 🤔 Not sure tho, cause propose/prove already protected.

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

Successfully merging this pull request may close these issues.

4 participants