-
Notifications
You must be signed in to change notification settings - Fork 71
feat: add genesis file generator example #629
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
base: main
Are you sure you want to change the base?
Conversation
…m/OffchainLabs/arbitrum-orbit-sdk into add-genesis-file-generator-script
| 1. Install dependencies | ||
|
|
||
| ```bash | ||
| yarn install |
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.
need to also yarn install in project root and yarn build for sdk dist
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.
Added further instructions in 00d933a
gzeoneth
left a comment
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.
LGTM
| const genesisAssertionState = { | ||
| globalState: { | ||
| bytes32Vals: [genesisBlockHash as `0x${string}`, sendRootHash as `0x${string}`] as [ | ||
| `0x${string}`, | ||
| `0x${string}`, | ||
| ], | ||
| // Set inbox position to 1 | ||
| u64Vals: [1n, 0n] as [bigint, bigint], | ||
| }, | ||
| machineStatus: 0, // Running | ||
| endHistoryRoot: toHex(0, { size: 32 }), | ||
| }; |
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.
prepareGenesisAssertionState(params: { genesisBlockHash: Hex, sendRootHash: Hex }): GenesisAssertionState| const genesisHashesStr = genesisHashes.toString(); | ||
| const genesisBlockHash = genesisHashesStr.split(',')[0].split(':')[1].trim(); | ||
| const sendRootHash = genesisHashesStr.split(',')[1].split(':')[1].trim(); |
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.
if we don't end up creating a function that wraps the call to run the docker container, we might do something like this:
parseGenesisHashes(hashes: Hex)| const genesisHashes = execSync( | ||
| `docker run -v $(pwd):/data/genesisDir --entrypoint genesis-generator ${nitroNodeImage} --genesis-json-file /data/genesisDir/genesis.json --initial-l1-base-fee ${l1BaseFee}`, | ||
| ); |
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.
if we want to wrap a docker run command
prepareGenesisHashes(params: {
genesis,
nitroNodeImageTag,
initialParentBaseFee
})| execSync( | ||
| `docker build -t genesis-file-generator https://github.com/OffchainLabs/genesis-file-generator.git`, | ||
| ); | ||
|
|
||
| // Generate genesis file | ||
| console.log(`Generate genesis file...`); | ||
| execSync(`docker run --env-file ./.env genesis-file-generator > genesis.json`); |
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.
if we want to wrap a docker run command
prepareGenesis(chainConfig: ChainConfig): Genesis
This PR adds an example script to generate a genesis.json file and obtain the genesis information, making use of the genesis-file-generator script.