Skip to content

feat: add genesis file generator example#629

Open
TucksonDev wants to merge 47 commits into
mainfrom
add-genesis-file-generator-script
Open

feat: add genesis file generator example#629
TucksonDev wants to merge 47 commits into
mainfrom
add-genesis-file-generator-script

Conversation

@TucksonDev

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

Comment thread examples/generate-genesis-file/index.ts
@TucksonDev
TucksonDev requested a review from gzeoneth November 6, 2025 12:56

@gzeoneth gzeoneth left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

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
Copy Markdown
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
Copy Markdown
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 thread examples/generate-genesis-file/index.ts Outdated
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
Copy Markdown
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

@gzeoneth

Copy link
Copy Markdown
Member

Approved OffchainLabs/genesis-file-generator#6, can remove the tag after merging

@Jason-W123

Jason-W123 commented Feb 12, 2026

Copy link
Copy Markdown
Contributor

Updated this example to make it compatible with contract v3.2.0

spsjvc and others added 3 commits March 11, 2026 16:52
- Require GENESIS_FILE_GENERATOR_IMAGE env var and pull image
  directly instead of building from a branch
- Parse chain config from serializedChainConfig (new format
  emitted by genesis-file-generator v0.0.2+); remove deprecated
  genesisConfiguration.config path
- .env.example: rename ARB_OS_VERSION -> ARBOS_VERSION=51 to
  match genesis-file-generator env naming; bump NITRO_NODE_IMAGE
  to v3.9.9-rc.3-3a38667; add GENESIS_FILE_GENERATOR_IMAGE
  placeholder

Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>
…mple

genesis-file-generator supports additional env vars that get embedded
into the output genesis.json. Since `docker run --env-file ./.env`
forwards them automatically, the SDK example only needs to document them:

- LOAD_DEFAULT_PREDEPLOYS (default true): whether to include the default
  predeploy bundle (Safe, Multicall3, EntryPoint, etc.) in the alloc
- ENABLE_NATIVE_TOKEN_SUPPLY (default false): enables native token
  supply management in ArbOS (mint/burn via third-party bridges)
- ENABLE_TRANSACTION_FILTERING (default false): enables protocol-level
  transaction filtering for regulatory/compliance use cases

Verified end-to-end: flags propagate into arbOSInit fields or alloc
content of the generated genesis.json.

Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>
Comment thread examples/generate-genesis-file/.env.example Outdated
Co-authored-by: Alec Thomas <112640918+a-thomas-22@users.noreply.github.com>
Comment thread examples/generate-genesis-file/index.ts Fixed
Jason-W123 and others added 3 commits July 2, 2026 03:47
…cat` process'

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
….3-rc-deffec7 (NIT-5124)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.

6 participants