MCPcopy Create free account
hub / github.com/ChainSafe/Delorean-Protocol / block_zero

Function block_zero

fendermint/eth/api/src/conv/from_tm.rs:57–96  ·  view source on GitHub ↗

A pretend block at height 0 for some tools like The Graph which go there.

()

Source from the content-addressed store, hash-verified

55
56/// A pretend block at height 0 for some tools like The Graph which go there.
57fn block_zero() -> tendermint::Block {
58 let commit = tendermint::block::Commit {
59 height: tendermint::block::Height::try_from(0u64).unwrap(),
60 round: tendermint::block::Round::try_from(0).unwrap(),
61 block_id: tendermint::block::Id {
62 hash: tendermint::Hash::None,
63 part_set_header: tendermint::block::parts::Header::new(0, tendermint::Hash::None)
64 .unwrap(),
65 },
66 signatures: Vec::new(),
67 };
68
69 let empty_cid = fendermint_vm_message::cid(&[0u8; 0]).unwrap();
70
71 let header = tendermint::block::Header {
72 version: tendermint::block::header::Version { block: 0, app: 0 },
73 chain_id: tendermint::chain::Id::try_from("UNSPECIFIED").expect("invalid chainid"),
74 height: tendermint::block::Height::try_from(0u64).unwrap(),
75 time: tendermint::time::Time::unix_epoch(),
76 last_block_id: None,
77 last_commit_hash: None,
78 data_hash: None,
79 validators_hash: tendermint::Hash::None,
80 next_validators_hash: tendermint::Hash::None,
81 consensus_hash: tendermint::Hash::None,
82 app_hash: tendermint::AppHash::try_from(empty_cid.to_bytes()).unwrap(),
83 last_results_hash: None,
84 evidence_hash: None,
85 proposer_address: tendermint::account::Id::new([0u8; 20]),
86 };
87
88 tendermint::Block::new(
89 header,
90 Vec::new(),
91 // tendermint::evidence::Data::default(),
92 tendermint::evidence::List::default(),
93 Some(commit),
94 )
95 .unwrap()
96}
97
98pub fn is_block_zero(block: &tendermint::Block) -> bool {
99 block.header().hash() == tendermint::Hash::Sha256(*BLOCK_ZERO_HASH)

Callers

nothing calls this directly

Calls 2

cidFunction · 0.85
to_bytesMethod · 0.45

Tested by

no test coverage detected