Skip to content

Commit

Permalink
feat: add WasmModuleRoot verification (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason-W123 authored Jan 18, 2024
1 parent a199539 commit e294c2b
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
22 changes: 22 additions & 0 deletions examples/verify-rollup/src/lib/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
export const WASMModuleRoots = [
'0xbb9d58e9527566138b682f3a207c0976d5359837f6e330f4017434cca983ff41', // consensus-v1-rc1
'0x9d68e40c47e3b87a8a7e6368cc52915720a6484bb2f47ceabad7e573e3a11232', // consensus-v2.1
'0x53c288a0ca7100c0f2db8ab19508763a51c7fd1be125d376d940a65378acaee7', // consensus-v3
'0x588762be2f364be15d323df2aa60ffff60f2b14103b34823b6f7319acd1ae7a3', // consensus-v3.1
'0xcfba6a883c50a1b4475ab909600fa88fc9cceed9e3ff6f43dccd2d27f6bd57cf', // consensus-v3.2
'0xa24ccdb052d92c5847e8ea3ce722442358db4b00985a9ee737c4e601b6ed9876', // consensus-v4
'0x1e09e6d9e35b93f33ed22b2bc8dc10bbcf63fdde5e8a1fb8cc1bcd1a52f14bd0', // consensus-v5
'0x3848eff5e0356faf1fc9cafecb789584c5e7f4f8f817694d842ada96613d8bab', // consensus-v6
'0x53dd4b9a3d807a8cbb4d58fbfc6a0857c3846d46956848cae0a1cc7eca2bb5a8', // consensus-v7
'0x2b20e1490d1b06299b222f3239b0ae07e750d8f3b4dedd19f500a815c1548bbc', // consensus-v7.1
'0xd1842bfbe047322b3f3b3635b5fe62eb611557784d17ac1d2b1ce9c170af6544', // consensus-v9
'0x6b94a7fc388fd8ef3def759297828dc311761e88d8179c7ee8d3887dc554f3c3', // consensus-v10
'0xda4e3ad5e7feacb817c21c8d0220da7650fe9051ece68a3f0b1c5d38bbb27b21', // consensus-v10.1
'0x0754e09320c381566cc0449904c377a52bd34a6b9404432e80afd573b67f7b17', // consensus-v10.2
'0xf559b6d4fa869472dabce70fe1c15221bdda837533dfd891916836975b434dec', // consensus-v10.3
'0xf4389b835497a910d7ba3ebfb77aa93da985634f3c052de1290360635be40c4a', // consensus-v11
];

export const currentMainnetWasmModuleRootIndex = WASMModuleRoots.indexOf(
'0x6b94a7fc388fd8ef3def759297828dc311761e88d8179c7ee8d3887dc554f3c3',
);
32 changes: 32 additions & 0 deletions examples/verify-rollup/src/partial-handlers/rollup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
} from '../lib/utils';
import { zeroAddress } from 'viem';
import { SequencerInbox__factory } from '@arbitrum/sdk/dist/lib/abi/factories/SequencerInbox__factory';
import { currentMainnetWasmModuleRootIndex, WASMModuleRoots } from '../lib/constants';

// Constants
const minConfirmPeriodBlocks = 45818;
Expand Down Expand Up @@ -467,5 +468,36 @@ export const rollupHandler = async (
}
console.log('');

//
// STF verification
//

// get the wasmModuleRoot of the given orbit chain
const moduleRoot = (await orbitHandler.readContract(
'parent',
rollupAddress,
[...RollupCore__factory.abi, ...Ownable__factory.abi] as Abi,
'wasmModuleRoot',
)) as `0x${string}`;

const index = WASMModuleRoots.indexOf(moduleRoot);

// check if this wasmModuleRoot belongs to one of mainnet version
if (0 <= index) {
console.log('The state transition function is standard version');
// check if the rollups' arbos version is latest or not
if (index < currentMainnetWasmModuleRootIndex) {
warningMessages.push(
`Arbos version is old, Rollup wasmModuleRoot is ${moduleRoot}. Latest standard wasmModuleRoot is ${WASMModuleRoots[currentMainnetWasmModuleRootIndex]}.`,
);
}
} else {
console.log('The state transition function is not standard version');
warningMessages.push(
`The node is using a customized state transition function, the wasmModule root is ${moduleRoot}`,
);
}
console.log('');

return warningMessages;
};

0 comments on commit e294c2b

Please sign in to comment.