Conversation
Add storage decoupling architecture to enable upgrading PostageStamp logic without migrating funds or batch data. This introduces a separation between immutable storage and upgradeable logic contracts. Key components: - PostageStampStorage: Immutable contract holding all data and BZZ tokens - PostageStampV2: Upgradeable logic contract implementing all operations - IPostageStampStorage: Interface defining storage operations Benefits: - Zero-migration upgrades (no token or data movement needed) - Reduced risk and complexity for future upgrades - Swarm nodes only need to update contract address - Storage contract remains trusted and immutable Documentation: - SWIP proposal with full specification and rationale - Complete implementation guide for deployment and migration - Example deployment and migration scripts Files added: - src/interface/IPostageStampStorage.sol - src/PostageStampStorage.sol - src/PostageStampV2.sol - deploy/PostageStampV2.deploy.ts - scripts/migration/migrateToStorageDecoupling.ts - SWIP-storage-decoupling.md - docs/STORAGE_DECOUPLING_GUIDE.md - STORAGE_DECOUPLING_README.md This is a preparation for future upgrades and provides a one-time migration path from the existing monolithic PostageStamp contract.
Remove version numbers (V2, V3, etc.) from contract names in favor of git tag-based versioning. This provides cleaner contract naming where the logic contract is always named PostageStamp, with versions tracked via git tags. Changes: - Renamed PostageStampV2.sol to PostageStamp.sol - Renamed old PostageStamp.sol to PostageStampLegacy.sol - Renamed deploy/PostageStampV2.deploy.ts to deploy/PostageStamp.deploy.ts - Updated all documentation to reflect git tag-based versioning - Updated SWIP to explain versioning approach - Updated migration script references - Updated deployment script to reference correct contract names Versioning strategy: - Logic contract is always named PostageStamp - Versions tracked via git tags (v2.0.0, v2.1.0, etc.) - When upgrading: checkout new tag, deploy, update storage pointer - No version numbers in contract or file names
…ture - Update local deployment script to deploy PostageStampStorage + PostageStamp - Use fully qualified contract name to resolve PostageStamp ambiguity - Update mintAndApprove to approve tokens for PostageStampStorage - Fix token balance checks to use storage contract instead of logic contract - Add copyBatch function to PostageStamp for testing/migration with specific IDs - Skip legacy copyBatch tests (not relevant to new architecture) All tests passing: 145 passing, 13 pending (legacy tests)
- Add minimumValidityBlocks property to networkConfigItem interface - Configure values for all networks based on their block times - Fixes deployment script error in CI/CD
…cess BREAKING CHANGE: PostageStampStorage no longer has mutable logic contract pointer ## Architecture Changes ### Before: - Storage had mutable `logicContract` address - Required admin to call `updateLogicContract()` to upgrade - Created trust issues and admin dependency ### After: - Storage uses role-based access control (WRITER_ROLE) - Logic contracts are granted WRITER_ROLE to modify storage - Storage is truly immutable - no mutable state - Logic contracts point to storage (immutable reference) ## Upgrade Process (New): 1. Deploy new PostageStamp logic pointing to same storage address 2. Admin grants WRITER_ROLE to new logic contract 3. Update Bee nodes to use new logic contract address 4. (Optional) Revoke WRITER_ROLE from old logic contract ## Benefits: - True immutability - no mutable pointers in storage - Multiple logic versions can coexist (for gradual rollout) - Bee node versions are hinged to specific logic contract addresses - No need for admin intervention in contracts during upgrades - Reduces trust requirements ## Changes: - Remove `logicContract` state variable from PostageStampStorage - Remove `updateLogicContract()` function - Replace `onlyLogicContract` modifier with WRITER_ROLE checks - Update deployment to grant WRITER_ROLE instead of setting logic address - Storage constructor now only takes (bzzToken, admin) All tests passing: 145 passing, 13 pending
- Rename _admin to _multisig in constructor for clarity - Add detailed documentation on role management workflow - Add isWriter() and isAdmin() helper functions - Document the exact multisig calls needed for upgrades: - grantRole(WRITER_ROLE, newPostageStamp) to add new logic - revokeRole(WRITER_ROLE, oldPostageStamp) to remove old logic The multisig is set once in constructor and can manage WRITER_ROLE forever.
- Add architecture diagram showing multiple logic versions - Document WRITER_ROLE based access control - Explain Bee node versioning model - Document multisig operations for granting/revoking roles - Update deployment and migration instructions - Add FAQ section addressing common questions - Remove outdated references to updateLogicContract()
ROUND_LENGTH Parameter Change VerificationContext
Goal: Maintain identical wall-clock timing across networks.
Checklist for Reviewers1. Round CalculationFiles: Same number of rounds per day on both networks:
2. Phase DurationsFile:
All phases have identical wall-clock duration. 3. Staking Wait Period (2 Rounds)File:
Same minimum staking wait time before participating. 4. Freeze PenaltiesFile: Freeze duration in blocks converted to time:
Freeze penalties result in same wall-clock duration. 5. Last Block PreventionFile: Still prevents commits on last block of commit phase (works with any ROUND_LENGTH value). Configuration Values
Verification formula:
Files Modified
|
|
If we go with this #310 then this is obsolete |
PostageStamp Storage Decoupling Architecture
Overview
Separates PostageStamp into two contracts:
How It Works
Key Points
WRITER_ROLE(OpenZeppelin AccessControl) - multisig grants this to logic contractsBenefits
Upgrade Process
storage.grantRole(WRITER_ROLE, newLogicAddress)