logoAcademy

Creating Genesis Block with precompileConfig

Learn how to create the genesis block with precompileConfig.

In order to create a new Blockchain from our customized EVM, we must define a Genesis block just as we did in our section earlier.

tests/precompile/genesis/sha256.json
{
  "config": {
    "chainId": 99999,
    "homesteadBlock": 0,
    "eip150Block": 0,
    "eip150Hash": "0x2086799aeebeae135c246c65021c82b4e15a2c451340993aacfd2751886514f0",
    "eip155Block": 0,
    "eip158Block": 0,
    "byzantiumBlock": 0,
    "constantinopleBlock": 0,
    "petersburgBlock": 0,
    "istanbulBlock": 0,
    "muirGlacierBlock": 0,
    "subnetEVMTimestamp": 0,
    "feeConfig": {
      "gasLimit": 20000000,
      "minBaseFee": 1000000000,
      "targetGas": 100000000,
      "baseFeeChangeDenominator": 48,
      "minBlockGasCost": 0,
      "maxBlockGasCost": 10000000,
      "targetBlockRate": 2,
      "blockGasCostStep": 500000
    },
    "sha256Config": {
      "blockTimestamp": 0
    }
  },
  "alloc": {
    "8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC": {
      "balance": "0x52B7D2DCC80CD2E4000000"
    }
  },
  "nonce": "0x0",
  "timestamp": "0x0",
  "extraData": "0x00",
  "gasLimit": "0x1312D00",
  "difficulty": "0x0",
  "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "coinbase": "0x0000000000000000000000000000000000000000",
  "number": "0x0",
  "gasUsed": "0x0",
  "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
}

The precompile config only has a single entry called blockTimestamp. This is the activation time of the precompile. Initially, we will set this 0 so that the precompile will be available from the start. Later we will see more advanced configurations.

Adding PrecompileConfig for MD5 Precompile

To incorporate the MD5 into the gensis block, we need to update the config JSON to include a key for the MD5 precompile. This key is the configKey that we specified in the module.go file of the MD5 precompile in previous section. Copy the sha256.json into a new file called MD5.json, and add the necessary key-pair value to the config.

On this page