Skip to content

Commit 13117ec

Browse files
authored
[1.3.2] Support zeus deploy verify for multisig steps. (#31)
* save * revert print
1 parent a8d9608 commit 13117ec

File tree

5 files changed

+45
-6
lines changed

5 files changed

+45
-6
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11

22
**[Current]**
3+
1.3.2:
4+
- `zeus deploy verify` now allows checking the correctness of the most recent submitted gnosis transaction.
5+
36
1.3.1:
47
- Adds `ZEUS_DEPLOY_FROM_VERSION` and `ZEUS_DEPLOY_TO_VERSION`, automatically injected to scripts, upgrades, and all tasks run via `zeus run`.
58

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@layr-labs/zeus",
3-
"version": "1.3.1",
3+
"version": "1.3.2",
44
"description": "web3 deployer / metadata manager",
55
"main": "src/index.ts",
66
"scripts": {

src/commands/deploy/cmd/verify.ts

+40-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { pickStrategy, rpcUrl } from "../../prompts";
99
import { getActiveDeploy } from "./utils";
1010
import * as AllChains from "viem/chains";
1111
import { canonicalPaths } from "../../../metadata/paths";
12-
import { TForgeRequest } from "../../../signing/strategy";
12+
import { TForgeRequest, TGnosisRequest } from "../../../signing/strategy";
1313
import { ForgeSolidityMetadata, TDeployedContractsManifest } from "../../../metadata/schema";
1414
import { createPublicClient, hexToBytes, http, toHex } from "viem";
1515
import { join } from "path";
@@ -254,6 +254,7 @@ async function handler(_user: TState, args: {env: string}) {
254254
console.log(chalk.green('OK'));
255255
} else {
256256
console.log(chalk.red(`FAILURE`));
257+
throw new Error(`Deployed contracts did not match local copy.`)
257258
}
258259

259260
try {
@@ -271,6 +272,44 @@ async function handler(_user: TState, args: {env: string}) {
271272
console.error(e)
272273
}
273274
}
275+
276+
if (deploy._.segments[deploy._.segmentId].type === 'multisig') {
277+
// allow verifying the multisig txn hash.
278+
console.log(chalk.bold(`This deploy has a multisig step ongoing. You can check that the provided gnosisTransactionHash matches what was submitted`))
279+
280+
const strategyId = await pickStrategy([
281+
{id: 'gnosis.api.eoa', description: 'Gnosis / Private Key'},
282+
{id: 'gnosis.api.ledger', description: 'Gnosis / Ledger'},
283+
{id: 'cancel', description: 'Cancel'}
284+
], "How would you like to supply the signer used for simulation?");
285+
286+
if (strategyId !== 'cancel') {
287+
const strategy = await (async () => {
288+
const all = await import('../../../signing/strategies/strategies');
289+
const strategy = all.all.find(s => new s(deploy, metatxn, {nonInteractive: false, defaultArgs: {}}).id === strategyId);
290+
if (!strategy) {
291+
throw new Error(`Unknown strategy`);
292+
}
293+
return new strategy(deploy, metatxn, {nonInteractive: false, defaultArgs: {rpcUrl: customRpcUrl, etherscanApiKey: false}});
294+
})();
295+
const script = join(deploy._.upgradePath, deploy._.segments[deploy._.segmentId].filename);
296+
const request = await strategy.prepare(script, deploy._);
297+
const gnosisTxnHash = (request as TGnosisRequest).safeTxHash;
298+
299+
const multisigRun = await metatxn.getJSONFile<TGnosisRequest>(canonicalPaths.multisigRun({deployEnv: deploy._.env, deployName: deploy._.name, segmentId: deploy._.segmentId}))
300+
const proposedTxHash = multisigRun._.safeTxHash;
301+
302+
if (proposedTxHash === gnosisTxnHash) {
303+
console.log(`${chalk.green('✔')} ${script} (${gnosisTxnHash})`);
304+
} else {
305+
console.error(`${chalk.red('x')} ${script} (local=${gnosisTxnHash},reported=${proposedTxHash})`);
306+
throw new Error(`Multisig transaction did not match (local=${gnosisTxnHash},reported=${proposedTxHash})`);
307+
}
308+
} else {
309+
console.log(chalk.italic(`skipping gnosis verification`))
310+
}
311+
}
312+
274313
} catch (e) {
275314
console.error(`Failed to verify contracts.`);
276315
console.error(e);

src/signing/strategies/gnosis/api/gnosisApi.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export abstract class GnosisApiStrategy extends GnosisSigningStrategy {
3737
}
3838
}
3939

40-
console.log(`Multisig transactions to execute: `)
40+
console.log(chalk.italic(`Upgrade script produced the following transactions: `))
4141
console.table(JSON.stringify(multisigExecuteRequests, null, 2));
4242

4343
const protocolKitOwner1 = await Safe.init({
@@ -57,7 +57,6 @@ export abstract class GnosisApiStrategy extends GnosisSigningStrategy {
5757
),
5858
})
5959

60-
console.log(`Forming transaction...`);
6160
const hash = await protocolKitOwner1.getTransactionHash(txn)
6261

6362
return {

src/signing/strategies/gnosis/gnosis.ts

-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ export abstract class GnosisSigningStrategy extends Strategy {
3131
throw new Error(`Failed to read deployed script address.`);
3232
}
3333

34-
console.log(`\nFiltering for transactions originating from Multisig(${_multisig})\n\n`);
35-
3634
return output.traces.filter(trace => {
3735
return trace[0] === "Execution"
3836
}).map(

0 commit comments

Comments
 (0)