Function makeGenesis

Build a Genesis block from the provided data

immutable(Block) makeGenesis (
  Transaction[] txs,
  Enrollment[] enrolls,
  agora.crypto.Schnorr.Signature delegate(geod24.bitblob.BitBlob!(64L)) sigcb
);

This function is intended to be used when the hard-coded genesis block needs to be replaced, e.g. when the parameters are changed or a new network is created. It shouldn't be used in non-test code.

Example

Check the Coinnet Genesis Block enrollments (prints replacement enrollments if needed for agora.consensus.data.genesis.Test.d) This will not be used for the final Coinnet GenesisBlock which will use unknown key secrets. But can be useful for now.

import agora.consensus.data.genesis.Test;
import agora.utils.Test;

import std.algorithm;
import std.array;
import std.conv;

auto sorted_enrollments = checkGenesisEnrollments(GenesisBlock, [ WK.Keys.NODE2, WK.Keys.NODE3, WK.Keys.NODE4,
    WK.Keys.NODE5, WK.Keys.NODE6, WK.Keys.NODE7 ]);

// For unit tests we want the index of the nodes to match the order of the enrollments
assert(genesis_validator_keys.map!(k => k.address).array == sorted_enrollments.map!(e => e.key).array);

checkGenesisTransactions(GenesisBlock);
assert(GenesisBlock.isGenesisBlockInvalidReason() == null);

Example

Check the Test Genesis Block enrollments (prints replacement enrollments if needed for agora.consensus.data.genesis.Coinnet.d)

import agora.consensus.data.genesis.Coinnet;

setHashMagic(1);
checkGenesisEnrollments(GenesisBlock, genesis_validator_keys);
checkGenesisTransactions(GenesisBlock);
setHashMagic(0);