fix: Add upgrade safety hardening and comprehensive tests#89
Merged
hudsonhrh merged 2 commits intohudsonhrh/event-ordering-fixfrom Feb 9, 2026
Merged
Conversation
…rade safety tests
- Added _disableInitializers() constructor to 8 contracts with no constructor (Executor, ParticipationToken, TaskManager, QuickJoin, EducationHub, PaymentManager, UniversalAccountRegistry, ImplementationRegistry) preventing re-initialization attacks on implementation contracts
- Replaced weak constructor() initializer {} pattern in 4 contracts (HybridVoting, DirectDemocracyVoting, OrgRegistry, OrgDeployer) with _disableInitializers() for stronger initialization guards
- Added implementation validation to PoaManager.upgradeBeacon() and addContractType() to reject EOA addresses
- Added implementation validation to PaymasterHub._authorizeUpgrade() to prevent UUPS upgrades to invalid addresses
- Removed misleading __gap[50] from PaymasterHub (unnecessary with ERC-7201 namespaced storage)
- Fixed 8 test files to use BeaconProxy pattern instead of direct initialization of implementation contracts
- Created UpgradeSafety.t.sol with 24 comprehensive tests covering re-initialization prevention, upgrade authorization, storage preservation, and SwitchableBeacon mode-switching safety
- Created UpgradeEdgeCases.t.sol with 10 production-scenario tests covering full upgrade chains, multi-tenant isolation, mode cycling, sequential upgrades, and ownership transfer flows
- All 696 tests pass with zero failures
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Tests were directly calling initialize() on implementation contracts, which now revert due to _disableInitializers(). Wrapped all test setups in UpgradeableBeacon + BeaconProxy before calling initialize(). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Added complete upgrade safety hardening for all 17 upgradeable contracts and comprehensive test suite covering 34+ scenarios.
Key changes:
_disableInitializers()protection preventing re-initialization attacksBefore launch checks: Storage layout validation on upgrades, multi-org beacon isolation, mode-switching state consistency, ownership transfer flows.
🤖 Generated with Claude Code