fuel_core_chain_config/
genesis.rs

1use fuel_core_storage::MerkleRoot;
2use fuel_core_types::{
3    blockchain::consensus::Genesis,
4    fuel_crypto::Hasher,
5};
6
7// TODO: Replace `anyhow` with own `Error` related to genesis.
8
9pub trait GenesisCommitment {
10    /// Calculates the merkle root of the state of the entity.
11    fn root(&self) -> anyhow::Result<MerkleRoot>;
12}
13
14impl GenesisCommitment for Genesis {
15    fn root(&self) -> anyhow::Result<MerkleRoot> {
16        let genesis_hash = *Hasher::default()
17            .chain(self.chain_config_hash)
18            .chain(self.coins_root)
19            .chain(self.contracts_root)
20            .chain(self.messages_root)
21            .chain(self.transactions_root)
22            .finalize();
23
24        Ok(genesis_hash)
25    }
26}