-
Notifications
You must be signed in to change notification settings - Fork 860
feat(cli): add TokenBridge SetPauserAddresses and Sui ContractUpgrade… #4955
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
Open
douglasgalico
wants to merge
4
commits into
wormhole-foundation:main
Choose a base branch
from
wormholelabs-xyz:feat/worm-cli-tb-governance
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
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 |
|---|---|---|
|
|
@@ -7,17 +7,22 @@ import { | |
| import { Payload, impossible } from "../../vaa"; | ||
| import { | ||
| assertSuccess, | ||
| buildTokenBridgePackage, | ||
| executeTransactionBlock, | ||
| getOriginalPackageId, | ||
| getPackageId, | ||
| getProvider, | ||
| getPublishedPackageId, | ||
| getSigner, | ||
| getUpgradeCapObjectId, | ||
| migrateTokenBridge, | ||
| normalizeSuiAddress, | ||
| registerChain, | ||
| setMaxGasBudgetDevnet, | ||
| setPauserAddresses, | ||
| SUI_CLOCK_OBJECT_ID, | ||
| upgradeTokenBridge, | ||
| waitForNewPackage, | ||
| } from "./utils"; | ||
| import { SuiGrpcClient } from "@mysten/sui/grpc"; | ||
| import { | ||
|
|
@@ -204,8 +209,64 @@ export const submit = async ( | |
|
|
||
| break; | ||
| } | ||
| case "ContractUpgrade": | ||
| throw new Error("ContractUpgrade not supported on Sui"); | ||
| case "ContractUpgrade": { | ||
| console.log("Upgrading contract"); | ||
| // On Sui the VAA authorizes a build digest, and the upgrade | ||
| // transaction itself carries the compiled bytecode — build the | ||
| // package locally and refuse to submit if it doesn't reproduce the | ||
| // authorized digest (the chain would reject it anyway). | ||
| const { modules, dependencies, digest } = | ||
| buildTokenBridgePackage(network); | ||
| const authorized = payload.address.replace(/^0x/, ""); | ||
| if (digest.toString("hex") !== authorized) { | ||
| throw new Error( | ||
| `local build digest ${digest.toString( | ||
| "hex" | ||
| )} does not match the digest authorized by the VAA (${authorized}); ` + | ||
| "rebuild from the proposal's commit with the proposal's sui CLI version" | ||
| ); | ||
| } | ||
| const oldPackage = await getPackageId( | ||
| client, | ||
| tokenBridgeStateObjectId | ||
| ); | ||
| const tx = await upgradeTokenBridge( | ||
| client, | ||
| network, | ||
| vaa, | ||
| coreBridgeStateObjectId, | ||
| tokenBridgeStateObjectId, | ||
| modules, | ||
| dependencies | ||
| ); | ||
| setMaxGasBudgetDevnet(network, tx); | ||
| const res = await executeTransactionBlock(signer, tx); | ||
| console.log(JSON.stringify(res)); | ||
| assertSuccess(res, "Upgrade failed."); | ||
|
|
||
| // The upgrade only publishes the new package; it becomes active | ||
| // once migrate flips the version on the state object. | ||
| const newPackage = await waitForNewPackage( | ||
| client, | ||
| tokenBridgeStateObjectId, | ||
| oldPackage | ||
| ); | ||
| console.log(`New package: ${newPackage}`); | ||
|
|
||
| console.log("Migrating"); | ||
| const migrateTx = await migrateTokenBridge( | ||
| client, | ||
| network, | ||
| vaa, | ||
| coreBridgeStateObjectId, | ||
| tokenBridgeStateObjectId | ||
| ); | ||
| setMaxGasBudgetDevnet(network, migrateTx); | ||
| const migrateRes = await executeTransactionBlock(signer, migrateTx); | ||
| console.log(JSON.stringify(migrateRes)); | ||
| assertSuccess(migrateRes, "Migrate failed."); | ||
| break; | ||
| } | ||
| case "RecoverChainId": | ||
| throw new Error("RecoverChainId not supported on Sui"); | ||
| case "RegisterChain": { | ||
|
|
@@ -222,6 +283,20 @@ export const submit = async ( | |
| console.log(JSON.stringify(res)); | ||
| break; | ||
| } | ||
| case "SetPauserAddresses": { | ||
| console.log("Setting pauser addresses"); | ||
| const tx = await setPauserAddresses( | ||
| client, | ||
| network, | ||
| vaa, | ||
| coreBridgeStateObjectId, | ||
| tokenBridgeStateObjectId | ||
| ); | ||
| setMaxGasBudgetDevnet(network, tx); | ||
| const res = await executeTransactionBlock(signer, tx); | ||
| console.log(JSON.stringify(res)); | ||
| break; | ||
|
Comment on lines
+288
to
+298
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to assert whether or not the transaction actually succeeded here? |
||
| } | ||
| case "Transfer": | ||
| throw new Error("Transfer not supported on Sui"); | ||
| case "TransferWithPayload": | ||
|
|
||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ty for fixing the builds! Verified the hash matches the claimed version