Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ jobs:
with:
node-version: "22"
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@8789b3e21e6c11b2697f5eb56eddae542f746c10 # v1.7.0
uses: foundry-rs/foundry-toolchain@908c540300062bd5a7e473851cdb4282204cee09 # v1.9.1

Copy link
Copy Markdown
Contributor

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

- run: cd ethereum && make test-push0 && make test

ethereum-upgrade:
Expand All @@ -94,7 +94,7 @@ jobs:
with:
node-version: "22"
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@8789b3e21e6c11b2697f5eb56eddae542f746c10 # v1.7.0
uses: foundry-rs/foundry-toolchain@908c540300062bd5a7e473851cdb4282204cee09 # v1.9.1
- run: cd clients/js && make install
- run: cd ethereum && make test-upgrade

Expand Down
3 changes: 3 additions & 0 deletions clients/js/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ worm generate [command]
Commands:
worm generate registration Generate registration VAA
worm generate upgrade Generate contract upgrade VAA
worm generate set-pauser-addresses Generate a token bridge
SetPauserAddresses VAA (whitepaper
0003)
worm generate attestation Generate a token attestation VAA
worm generate recover-chain-id Generate a recover chain ID VAA
worm generate Sets the default delivery provider
Expand Down
2 changes: 2 additions & 0 deletions clients/js/src/algorand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ export async function execute_algorand(
case "AttestMeta":
console.log("Creating wrapped token");
break;
case "SetPauserAddresses":
throw new Error("SetPauserAddresses not supported on algorand");
case "TransferWithPayload":
throw Error("Can't complete payload 3 transfer from CLI");
default:
Expand Down
2 changes: 2 additions & 0 deletions clients/js/src/aptos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ export async function execute_aptos(
);
break;
}
case "SetPauserAddresses":
throw new Error("SetPauserAddresses not supported on aptos");
case "TransferWithPayload":
throw Error("Can't complete payload 3 transfer from CLI");
default:
Expand Down
2 changes: 2 additions & 0 deletions clients/js/src/chains/sei/submit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ export const submit = async (
case "AttestMeta":
console.log("Creating wrapped token");
break;
case "SetPauserAddresses":
throw new Error("SetPauserAddresses not supported on sei");
case "TransferWithPayload":
throw Error("Can't complete payload 3 transfer from CLI");
default:
Expand Down
79 changes: 77 additions & 2 deletions clients/js/src/chains/sui/submit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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": {
Expand All @@ -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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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":
Expand Down
Loading
Loading