Add upgradeability pattern to project#86
Conversation
There was a problem hiding this comment.
Pull request overview
Adds optional Transparent Proxy upgradeability across the confidential token suite by refactoring the existing contracts into upgradeable “core” base contracts, adding proxy-friendly wrappers + deployment scripts, and introducing tests that validate initialization, access control, and upgrade behavior.
Changes:
- Introduces
*Corebase contracts (upgradeable-friendly) and newcontracts/upgradeable/*proxy-deployable entrypoints withinitialize()+ locked implementations. - Adds Hardhat Upgrades integration plus new upgradeable deployment scripts and proxy-admin ownership transfer/check helper.
- Adds upgradeability-focused test coverage for proxy initialization, admin ownership, restricted calls, EIP-712 domain separator behavior, and storage persistence across upgrades; reorganizes generated docs accordingly.
Reviewed changes
Copilot reviewed 50 out of 51 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| yarn.lock | Adds OZ upgradeable packages + upgrades plugin and new dev deps to lockfile. |
| package.json | Adds OZ upgrades plugin and additional dev dependencies. |
| hardhat.config.ts | Enables Hardhat upgrades plugin; configures Hardhat network settings for deployments/tests. |
| scripts/test_deploy.sh | Exercises both non-upgradeable and upgradeable deployment scripts. |
| PLAN.md | Adds an AI-agent audit plan document for this repository. |
| migrations/upgradeableOwnership.ts | Implements ProxyAdmin ownership transfer + AccessManager admin-role checks post-deploy. |
| migrations/deployMintableUpgradeable.ts | Deploys Mintable token behind a proxy and validates ownership/roles. |
| migrations/deployWrapperUpgradeable.ts | Deploys Wrapper behind a proxy and validates ownership/roles. |
| migrations/deployMintable.ts | Exports address storage + verification helpers for reuse. |
| migrations/deployWrapper.ts | Exports address storage + verification helpers for reuse. |
| test/MintableConfidentialTokenUpgradeable.ts | Adds proxy/upgrade tests for the mintable confidential token. |
| test/ConfidentialWrapperUpgradeable.ts | Adds proxy/upgrade tests for the confidential wrapper. |
| contracts/core/ConfidentialTokenCore.sol | New upgradeable-friendly base token implementation (init pattern + shared logic). |
| contracts/core/MintableConfidentialTokenCore.sol | New base mint/burn extension built atop ConfidentialTokenCore. |
| contracts/core/ConfidentialWrapperCore.sol | New base wrapper implementation with async wrap/unwrap flows. |
| contracts/upgradeable/ConfidentialTokenUpgradeable.sol | New proxy entrypoint with initialize() + disabled initializers in ctor. |
| contracts/upgradeable/MintableConfidentialTokenUpgradeable.sol | New proxy entrypoint for mintable token. |
| contracts/upgradeable/ConfidentialWrapperUpgradeable.sol | New proxy entrypoint for wrapper. |
| contracts/ConfidentialToken.sol | Refactors non-proxy deployment to reuse ConfidentialTokenCore initialization path. |
| contracts/MintableConfidentialToken.sol | Refactors non-proxy mintable token to reuse MintableConfidentialTokenCore. |
| contracts/ConfidentialWrapper.sol | Refactors non-proxy wrapper to reuse ConfidentialWrapperCore. |
| contracts/eip3009/EIP3009Upgradeable.sol | Migrates EIP-3009 base to upgradeable OZ primitives + adds init hook. |
| contracts/eip3009/ConfidentialEIP3009Upgradeable.sol | Migrates confidential EIP-3009 extension to upgradeable base + adds init hook. |
| contracts/interfaces/IConfidentialTokenUpgradeable.sol | Adds initializer interface for proxy deployments. |
| contracts/interfaces/IMintableConfidentialTokenUpgradeable.sol | Adds initializer interface for proxy deployments. |
| contracts/interfaces/IConfidentialWrapperUpgradeable.sol | Adds initializer interface for proxy deployments. |
| docs/upgradeable/ConfidentialTokenUpgradeable.md | Adds generated docs for upgradeable token entrypoint. |
| docs/upgradeable/MintableConfidentialTokenUpgradeable.md | Adds generated docs for upgradeable mintable entrypoint. |
| docs/upgradeable/ConfidentialWrapperUpgradeable.md | Adds generated docs for upgradeable wrapper entrypoint. |
| docs/interfaces/IConfidentialTokenUpgradeable.md | Adds generated docs for upgradeable initializer interface. |
| docs/interfaces/IMintableConfidentialTokenUpgradeable.md | Adds generated docs for upgradeable initializer interface. |
| docs/interfaces/IConfidentialWrapperUpgradeable.md | Adds generated docs for upgradeable initializer interface. |
| docs/eip3009/EIP3009Upgradeable.md | Renames/updates generated docs to match upgradeable contract naming/init. |
| docs/eip3009/ConfidentialEIP3009Upgradeable.md | Renames/updates generated docs to match upgradeable contract naming/init. |
| docs/core/ConfidentialTokenCore.md | Adds generated docs for new core base contract. |
| docs/core/MintableConfidentialTokenCore.md | Adds generated docs for new core base contract. |
| docs/core/ConfidentialWrapperCore.md | Adds generated docs for new core base contract. |
| docs/ConfidentialToken.md | Removes large sections (likely moved to docs/core/*). |
| docs/ConfidentialWrapper.md | Removes large sections (likely moved to docs/core/*). |
| docs/MintableConfidentialToken.md | Removes mint/burn docs (likely moved to docs/core/*). |
| docs/types.md | Deletes generated docs (now redundant/moved). |
| docs/Precompiled.md | Deletes generated docs (now redundant/moved). |
| docs/lib/IERC20Internal.md | Deletes generated docs (now redundant/moved). |
| docs/lib/EIP712Domain.md | Deletes generated docs (now redundant/moved). |
| docs/lib/EIP712.md | Deletes generated docs (now redundant/moved). |
| docs/lib/EIP3009.md | Deletes generated docs (now redundant/moved). |
| docs/lib/EIP2612.md | Deletes generated docs (now redundant/moved). |
| docs/lib/ECRecover.md | Deletes generated docs (now redundant/moved). |
| docs/interfaces/IMintableConfidentialToken.md | Deletes generated docs (superseded by core/upgradeable splits). |
| docs/interfaces/bite/IBiteSupplicant.md | Deletes generated docs (now redundant/moved). |
| ] | ||
| }, | ||
| networks: { | ||
| hardhat: { | ||
| allowUnlimitedContractSize: true, | ||
| }, | ||
| custom: { |
There was a problem hiding this comment.
Not ideal but currently necessary. On SKALE chains this limit is bigger I think so no big issues. Alternatives & improvements are welcome - reducing optimizer runs is not enough
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #86 +/- ##
===========================================
- Coverage 97.84% 96.50% -1.34%
===========================================
Files 7 13 +6
Lines 417 458 +41
Branches 95 104 +9
===========================================
+ Hits 408 442 +34
- Misses 9 16 +7 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Fixes #80