-
Notifications
You must be signed in to change notification settings - Fork 2
feat: Make FilBeamOperator contract upgradeable #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Chaitu-Tatipamula
wants to merge
4
commits into
filbeam:main
from
Chaitu-Tatipamula:feat/uups-upgradeable
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
2cc6318
feat: make FilBeamOperator upgradeable with UUPS proxy pattern
Chaitu-Tatipamula d7434fc
refactor: address PR review feedback - immutable variables and docume…
Chaitu-Tatipamula 924665d
docs: address PR review feedback on documentation and contract versio…
Chaitu-Tatipamula 6ca1cc9
docs: add missing flags to upgrade script command
Chaitu-Tatipamula File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| // SPDX-License-Identifier: UNLICENSED | ||
| pragma solidity ^0.8.13; | ||
|
|
||
| import "forge-std/Script.sol"; | ||
| import "../src/FilBeamOperator.sol"; | ||
|
|
||
| /** | ||
| * @title UpgradeFilBeamOperator | ||
| * @dev Upgrades an existing FilBeamOperator proxy to a new implementation | ||
| * | ||
| * This script deploys a new implementation contract and upgrades the proxy | ||
| * State is preserved in the proxy - only the implementation logic changes. | ||
| * | ||
| * Note: To preserve existing rates, query them from the current proxy: | ||
| * cast call $FILBEAM_OPERATOR_PROXY_ADDRESS "cdnRatePerByte()" --rpc-url $RPC_URL | ||
| * cast call $FILBEAM_OPERATOR_PROXY_ADDRESS "cacheMissRatePerByte()" --rpc-url $RPC_URL | ||
| * | ||
| * Required Environment Variables: | ||
| * - PRIVATE_KEY: Owner's private key (must be contract owner) | ||
| * - FILBEAM_OPERATOR_PROXY_ADDRESS: Address of the existing proxy contract | ||
| * - FWSS_ADDRESS: Address of the FWSS contract | ||
| * - FWSS_STATE_VIEW_ADDRESS: Address of the FWSS State View contract | ||
| * - PAYMENTS_ADDRESS: Address of the Payments contract | ||
| * - CDN_RATE_PER_BYTE: CDN rate per byte in USDFC smallest units | ||
| * - CACHE_MISS_RATE_PER_BYTE: Cache miss rate per byte in USDFC smallest units | ||
| * | ||
| * Example usage: | ||
| * PRIVATE_KEY=0x... FILBEAM_OPERATOR_PROXY_ADDRESS=0x... FWSS_ADDRESS=0x... FWSS_STATE_VIEW_ADDRESS=0x... PAYMENTS_ADDRESS=0x... CDN_RATE_PER_BYTE=100 CACHE_MISS_RATE_PER_BYTE=200 forge script script/UpgradeFilBeamOperator.s.sol --broadcast | ||
| */ | ||
| contract UpgradeFilBeamOperator is Script { | ||
| function run() public { | ||
| uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); | ||
| address deployer = vm.addr(deployerPrivateKey); | ||
| // The address of existing proxy contract | ||
| address filBeamOperatorProxyAddress = vm.envAddress("FILBEAM_OPERATOR_PROXY_ADDRESS"); | ||
| address fwssAddress = vm.envAddress("FWSS_ADDRESS"); | ||
| address fwssStateViewAddress = vm.envAddress("FWSS_STATE_VIEW_ADDRESS"); | ||
| address paymentsAddress = vm.envAddress("PAYMENTS_ADDRESS"); | ||
| uint256 cdnRatePerByte = vm.envUint("CDN_RATE_PER_BYTE"); | ||
| uint256 cacheMissRatePerByte = vm.envUint("CACHE_MISS_RATE_PER_BYTE"); | ||
|
|
||
| vm.startBroadcast(deployerPrivateKey); | ||
|
|
||
| // Step 1: Deploy new implementation contract | ||
| FilBeamOperator newImplementation = new FilBeamOperator( | ||
| fwssAddress, fwssStateViewAddress, paymentsAddress, cdnRatePerByte, cacheMissRatePerByte | ||
| ); | ||
|
|
||
| // Step 2: Upgrade the proxy to point to the new implementation | ||
| FilBeamOperator proxy = FilBeamOperator(filBeamOperatorProxyAddress); | ||
| proxy.upgradeToAndCall(address(newImplementation), ""); | ||
|
|
||
| vm.stopBroadcast(); | ||
|
|
||
| // Step 3: Verify the upgrade | ||
| FilBeamOperator filBeam = FilBeamOperator(filBeamOperatorProxyAddress); | ||
| console2.log("=== FilBeamOperator Upgrade Complete ==="); | ||
| console2.log("Proxy Address:", filBeamOperatorProxyAddress); | ||
| console2.log("New Implementation Address:", address(newImplementation)); | ||
| console2.log("Contract Version:", filBeam.version()); | ||
| } | ||
| } |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.