Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove minification of chain config since it is now done in the genes…
…is-file-generator tool
  • Loading branch information
TucksonDev committed Nov 21, 2025
commit 62b9af4880f5ef20d850b5c52334e674c2bc5dfc
27 changes: 1 addition & 26 deletions examples/generate-genesis-file/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,28 +56,6 @@ async function askQuestion(question: string): Promise<string> {
);
}

function cleanChainConfigInFile(genesisFilePath: string) {
// Read the genesis file
const genesisFileContents = fs.readFileSync(genesisFilePath, { encoding: 'utf8' });
const genesisConfig = JSON.parse(genesisFileContents);

// Minify the `config` property
const chainConfigMinified = JSON.stringify(genesisConfig.config);

// Put a placeholder in its place so we can pretty-print the rest
const PLACEHOLDER = '__CONFIG_MINIFIED__';
genesisConfig.config = PLACEHOLDER;

// Create the final JSON contents
let genesisFileFinalContents = JSON.stringify(genesisConfig, null, 2);

// Replace the placeholder string (with quotes) by the minified config
genesisFileFinalContents = genesisFileFinalContents.replace(`"${PLACEHOLDER}"`, chainConfigMinified);

// Write result back to file
fs.writeFileSync(genesisFilePath, genesisFileFinalContents + '\n', { encoding: 'utf8' });
}

async function main() {
// Step 0 - Check if there's a genesis.json file present in the directory
let generateGenesisFile = true;
Expand All @@ -98,17 +76,14 @@ async function main() {
// Build genesis file generator container from Github
console.log(`Build genesis file generator container...`);
execSync(
`docker build -t genesis-file-generator https://github.com/OffchainLabs/genesis-file-generator.git#clean-chain-config`,
`docker build -t genesis-file-generator https://github.com/OffchainLabs/genesis-file-generator.git#minify-chain-config`,
);

// Generate genesis file
console.log(`Generate genesis file...`);
execSync(`docker run --env-file ./.env genesis-file-generator > genesis.json`);
}

// Remove the extra newlines and whitespaces from the chainConfig in the genesis file
cleanChainConfigInFile('genesis.json');

// Step 2 - Obtain genesis block hash and sendRoot hash
console.log(`Obtain genesis block hash and sendRoot hash...`);
console.log(`Using image "${nitroNodeImage}" and L1 base fee "${l1BaseFee}".`);
Expand Down
Loading