@@ -188,6 +188,22 @@ impl BlockData {
188
188
}
189
189
}
190
190
191
+ pub fn make_genesis_block_from_any_ledger_info ( ledger_info : & LedgerInfo ) -> Self {
192
+ let ancestor = ledger_info. commit_info ( ) . to_owned ( ) ;
193
+
194
+ // Genesis carries a placeholder quorum certificate to its parent id with LedgerInfo
195
+ // carrying information about version from the last LedgerInfo of previous epoch.
196
+ let genesis_quorum_cert = QuorumCert :: new (
197
+ VoteData :: new ( ancestor. clone ( ) , ancestor. clone ( ) ) ,
198
+ LedgerInfoWithSignatures :: new (
199
+ LedgerInfo :: new ( ancestor, HashValue :: zero ( ) ) ,
200
+ AggregateSignature :: empty ( ) ,
201
+ ) ,
202
+ ) ;
203
+
204
+ BlockData :: new_starting_block ( ledger_info. timestamp_usecs ( ) , genesis_quorum_cert)
205
+ }
206
+
191
207
pub fn new_genesis_from_ledger_info ( ledger_info : & LedgerInfo ) -> Self {
192
208
assert ! ( ledger_info. ends_epoch( ) ) ;
193
209
let ancestor = BlockInfo :: new (
@@ -246,9 +262,22 @@ impl BlockData {
246
262
247
263
#[ allow( unexpected_cfgs) ]
248
264
pub fn new_genesis ( timestamp_usecs : u64 , quorum_cert : QuorumCert ) -> Self {
265
+ assume ! ( quorum_cert. certified_block( ) . epoch( ) < u64 :: MAX ) ; // unlikely to be false in this universe
266
+ let genesis_epoch = quorum_cert. certified_block ( ) . epoch ( ) + 1 ;
267
+ Self {
268
+ epoch : genesis_epoch,
269
+ round : 0 ,
270
+ timestamp_usecs,
271
+ quorum_cert,
272
+ block_type : BlockType :: Genesis ,
273
+ }
274
+ }
275
+
276
+ #[ allow( unexpected_cfgs) ]
277
+ pub fn new_starting_block ( timestamp_usecs : u64 , quorum_cert : QuorumCert ) -> Self {
249
278
assume ! ( quorum_cert. certified_block( ) . epoch( ) < u64 :: MAX ) ; // unlikely to be false in this universe
250
279
Self {
251
- epoch : quorum_cert. certified_block ( ) . epoch ( ) + 1 ,
280
+ epoch : quorum_cert. certified_block ( ) . epoch ( ) ,
252
281
round : 0 ,
253
282
timestamp_usecs,
254
283
quorum_cert,
0 commit comments