Skip to content

Use upgradeable proxies for tokens and collections#128

Merged
RogerPodacter merged 2 commits into
evm-backend-demofrom
rename
Oct 22, 2025
Merged

Use upgradeable proxies for tokens and collections#128
RogerPodacter merged 2 commits into
evm-backend-demofrom
rename

Conversation

@RogerPodacter

@RogerPodacter RogerPodacter commented Oct 22, 2025

Copy link
Copy Markdown
Member

Note

Replace clone-based deployments with upgradeable CREATE2 proxies for tokens and collections, update deterministic address prediction, and adjust Proxy/ProxyAdmin APIs with a new test.

  • Protocols:
    • Collections (contracts/src/CollectionsProtocolHandler.sol):
      • Replace Clones with CREATE2-deployed Proxy; initialize via upgradeToAndCall and transfer admin to Predeploys.PROXY_ADMIN.
      • Rename template constant to collectionsImplementation; events and state now reference proxy address.
      • Update predictCollectionAddress to use Create2.computeAddress with Proxy creation code.
    • Fixed-Fungible (contracts/src/FixedFungibleProtocolHandler.sol):
      • Replace Clones with CREATE2-deployed Proxy; initialize via upgradeToAndCall and transfer admin to Predeploys.PROXY_ADMIN.
      • Rename template constant to fixedFungibleImplementation; events/state now reference proxy address.
      • Update predictTokenAddressByTick to use Create2.computeAddress with Proxy creation code.
  • Infrastructure:
    • ProxyAdmin (contracts/src/L2/ProxyAdmin.sol): unify function params to address (non-payable) and remove value forwarding in upgradeAndCall.
    • Proxy library (contracts/src/libraries/Proxy.sol): remove payable from upgradeToAndCall signature.
  • Tests:
    • Add contracts/test/AddressPrediction.t.sol to assert predicted proxy addresses match deployed addresses for both handlers.

Written by Cursor Bugbot for commit 79e6dc0. This will update automatically on new commits. Configure here.

@RogerPodacter RogerPodacter requested a review from Copilot October 22, 2025 19:11

Copilot AI left a comment

Copy link
Copy Markdown

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 replaces ERC-1167 minimal proxy clones with upgradeable ERC-1967 proxies for both fungible tokens and NFT collections, enabling future contract upgrades through the ProxyAdmin governance mechanism.

Key Changes:

  • Replaces OpenZeppelin's Clones library with Create2 for deploying upgradeable proxies
  • Removes payable modifiers from proxy-related functions that don't need to accept ETH
  • Updates address prediction logic to account for proxy constructor parameters

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
contracts/test/AddressPrediction.t.sol Adds tests verifying address prediction for upgradeable proxy deployments
contracts/src/libraries/Proxy.sol Removes unnecessary payable modifier from upgradeToAndCall function
contracts/src/L2/ProxyAdmin.sol Removes payable modifiers and type qualifiers from admin functions
contracts/src/FixedFungibleProtocolHandler.sol Migrates from Clones to upgradeable Proxy pattern for token deployments
contracts/src/CollectionsProtocolHandler.sol Migrates from Clones to upgradeable Proxy pattern for collection deployments

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +143 to +144
// Deploy a Proxy via CREATE2 with this handler as temporary admin for initialization
Proxy tokenProxy = new Proxy{salt: tickKey}(address(this));

Copilot AI Oct 22, 2025

Copy link

Choose a reason for hiding this comment

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

The handler contract temporarily assumes admin privileges during initialization. If this function can be called multiple times or reentered before admin transfer, it creates a window where the handler has elevated privileges. Consider adding reentrancy protection or documenting this assumption explicitly.

Copilot uses AI. Check for mistakes.
Comment on lines +159 to +160
// Deploy ERC721 proxy with CREATE2 using collectionId as salt for deterministic address
Proxy collectionProxy = new Proxy{salt: collectionId}(address(this));

Copilot AI Oct 22, 2025

Copy link

Choose a reason for hiding this comment

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

The handler contract temporarily assumes admin privileges during initialization. If this function can be called multiple times or reentered before admin transfer, it creates a window where the handler has elevated privileges. Consider adding reentrancy protection or documenting this assumption explicitly.

Copilot uses AI. Check for mistakes.
@RogerPodacter

Copy link
Copy Markdown
Member Author

bugbot run

@cursor

cursor Bot commented Oct 22, 2025

Copy link
Copy Markdown

🚨 Bugbot couldn't run

Something went wrong. Try again by commenting "Cursor review" or "bugbot run", or contact support (requestId: serverGenReqId_38fce432-6fc5-4367-b94e-eb7a4d976b60).

{
Proxy(_proxy).upgradeToAndCall{ value: msg.value }(_implementation, _data);
) external onlyOwner {
Proxy(_proxy).upgradeToAndCall(_implementation, _data);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: Proxy Upgrades Fail to Forward ETH

The upgradeAndCall functions in ProxyAdmin and Proxy lost their payable modifier and msg.value forwarding. This prevents sending ETH to payable initialization functions during proxy upgrades, removing previously supported functionality.

Additional Locations (1)

Fix in Cursor Fix in Web

@RogerPodacter RogerPodacter merged commit e3106d2 into evm-backend-demo Oct 22, 2025
2 checks passed
@RogerPodacter RogerPodacter deleted the rename branch October 22, 2025 19:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants