Skip to content

Conversation

@TucksonDev
Copy link
Contributor

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.

@TucksonDev TucksonDev changed the title Add genesis file generator example feat: add genesis file generator example Oct 21, 2025
1. Install dependencies

```bash
yarn install
Copy link
Member

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

Copy link
Contributor Author

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

@TucksonDev TucksonDev requested a review from gzeoneth November 6, 2025 12:56
Copy link
Member

@gzeoneth gzeoneth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment on lines +165 to +176
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 }),
};
Copy link
Member

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

Comment on lines +97 to +99
const genesisHashesStr = genesisHashes.toString();
const genesisBlockHash = genesisHashesStr.split(',')[0].split(':')[1].trim();
const sendRootHash = genesisHashesStr.split(',')[1].split(':')[1].trim();
Copy link
Member

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)

Comment on lines +90 to +92
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}`,
);
Copy link
Member

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
})

Comment on lines 78 to 84
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`);
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants