- Integrated Zod validation schemas across various API routes to ensure input integrity and improve error handling. - Updated `mapping-service`, `orchestrator`, `packet-service`, and `webhook-service` to utilize validation middleware for request parameters and bodies. - Improved error handling in webhook management, packet generation, and compliance routes to provide clearer feedback on request failures. - Added new validation schemas for various endpoints, enhancing overall API robustness and maintainability. - Updated dependencies in `package.json` to include the new validation library.
2.8 KiB
2.8 KiB
Upgrade Procedure for eMoneyToken
Overview
eMoneyToken uses the UUPS (Universal Upgradeable Proxy Standard) upgradeable proxy pattern. This document outlines the procedure for safely upgrading token implementations.
Prerequisites
-
OpenZeppelin Upgrades Core tools installed:
npm install --save-dev @openzeppelin/upgrades-core -
Storage layout validation script (see
tools/validate-storage-layout.sh)
Pre-Upgrade Checklist
- Review all changes to storage variables
- Ensure no storage variables are removed or reordered
- Verify new storage variables are appended only
- Run storage layout validation
- Test upgrade on testnet
- Get multisig approval for upgrade
Storage Layout Validation
Using OpenZeppelin Upgrades Core
-
Extract storage layout from current implementation:
forge build npx @openzeppelin/upgrades-core validate-storage-layout \ --contract-name eMoneyToken \ --reference artifacts/build-info/*.json \ --new artifacts/build-info/*.json -
Compare layouts:
tools/validate-storage-layout.sh
Manual Validation
Storage variables in eMoneyToken (in order):
_decimals(uint8)_inForceTransfer(bool)_inClawback(bool)- Inherited from ERC20Upgradeable
- Inherited from AccessControlUpgradeable
- Inherited from UUPSUpgradeable
- Inherited from ReentrancyGuardUpgradeable
CRITICAL: Never remove or reorder existing storage variables. Only append new ones.
Upgrade Steps
-
Deploy New Implementation:
forge script script/Upgrade.s.sol:UpgradeScript --rpc-url $RPC_URL --broadcast -
Verify Implementation:
forge verify-contract <NEW_IMPL_ADDRESS> eMoneyToken --chain-id 138 -
Authorize Upgrade (via multisig):
eMoneyToken(tokenAddress).upgradeToAndCall(newImplementationAddress, ""); -
Verify Upgrade:
forge script script/VerifyUpgrade.s.sol:VerifyUpgrade --rpc-url $RPC_URL
Post-Upgrade Verification
- Token balances unchanged
- Transfer functionality works
- Policy checks still enforced
- Lien enforcement still works
- Compliance checks still work
- Events emit correctly
- All roles still functional
Emergency Rollback
If issues are discovered post-upgrade:
- Deploy previous implementation
- Authorize upgrade back to previous version
- Investigate and fix issues
- Re-attempt upgrade with fixes
Storage Layout Validation Script
See tools/validate-storage-layout.sh for automated validation.