@@ -7,6 +7,7 @@ use chrono::prelude::{DateTime, Utc};
7
7
use chrono:: Duration ;
8
8
use log:: { debug, info} ;
9
9
10
+ use near_primitives:: block:: genesis_chunks;
10
11
use near_primitives:: hash:: { hash, CryptoHash } ;
11
12
use near_primitives:: merkle:: { merklize, verify_path} ;
12
13
use near_primitives:: receipt:: Receipt ;
@@ -185,11 +186,15 @@ impl Chain {
185
186
186
187
// Get runtime initial state and create genesis block out of it.
187
188
let ( state_store_update, state_roots) = runtime_adapter. genesis_state ( ) ;
188
- let genesis = Block :: genesis (
189
+ let genesis_chunks = genesis_chunks (
189
190
state_roots. clone ( ) ,
190
- chain_genesis. time ,
191
191
runtime_adapter. num_shards ( ) ,
192
192
chain_genesis. gas_limit ,
193
+ ) ;
194
+ let genesis = Block :: genesis (
195
+ genesis_chunks. iter ( ) . map ( |chunk| chunk. header . clone ( ) ) . collect ( ) ,
196
+ chain_genesis. time ,
197
+ chain_genesis. gas_limit ,
193
198
chain_genesis. gas_price ,
194
199
chain_genesis. total_supply ,
195
200
) ;
@@ -227,6 +232,9 @@ impl Chain {
227
232
}
228
233
Err ( err) => match err. kind ( ) {
229
234
ErrorKind :: DBNotFoundErr ( _) => {
235
+ for chunk in genesis_chunks {
236
+ store_update. save_chunk ( & chunk. chunk_hash , chunk. clone ( ) ) ;
237
+ }
230
238
runtime_adapter. add_validator_proposals (
231
239
CryptoHash :: default ( ) ,
232
240
genesis. hash ( ) ,
@@ -247,7 +255,15 @@ impl Chain {
247
255
store_update. save_chunk_extra (
248
256
& genesis. hash ( ) ,
249
257
chunk_header. inner . shard_id ,
250
- ChunkExtra :: new ( state_root, vec ! [ ] , 0 , chain_genesis. gas_limit , 0 , 0 , 0 ) ,
258
+ ChunkExtra :: new (
259
+ state_root,
260
+ vec ! [ ] ,
261
+ 0 ,
262
+ chain_genesis. gas_limit ,
263
+ 0 ,
264
+ 0 ,
265
+ 0 ,
266
+ ) ,
251
267
) ;
252
268
}
253
269
@@ -1652,11 +1668,14 @@ impl<'a> ChainUpdate<'a> {
1652
1668
self . chain_store_update . get_chunk_clone_from_header ( & chunk_header) ?;
1653
1669
1654
1670
let any_transaction_is_invalid = chunk. transactions . iter ( ) . any ( |t| {
1655
- self . chain_store_update . get_chain_store ( ) . check_blocks_on_same_chain (
1656
- & block. header ,
1657
- & t. transaction . block_hash ,
1658
- self . transaction_validity_period ,
1659
- ) . is_err ( )
1671
+ self . chain_store_update
1672
+ . get_chain_store ( )
1673
+ . check_blocks_on_same_chain (
1674
+ & block. header ,
1675
+ & t. transaction . block_hash ,
1676
+ self . transaction_validity_period ,
1677
+ )
1678
+ . is_err ( )
1660
1679
} ) ;
1661
1680
if any_transaction_is_invalid {
1662
1681
debug ! ( target: "chain" , "Invalid transactions in the chunk: {:?}" , chunk. transactions) ;
@@ -1693,7 +1712,7 @@ impl<'a> ChainUpdate<'a> {
1693
1712
gas_limit,
1694
1713
apply_result. total_rent_paid ,
1695
1714
apply_result. total_validator_reward ,
1696
- apply_result. total_balance_burnt
1715
+ apply_result. total_balance_burnt ,
1697
1716
) ,
1698
1717
) ;
1699
1718
// Save resulting receipts.
@@ -2200,7 +2219,7 @@ impl<'a> ChainUpdate<'a> {
2200
2219
gas_limit,
2201
2220
apply_result. total_rent_paid ,
2202
2221
apply_result. total_validator_reward ,
2203
- apply_result. total_balance_burnt
2222
+ apply_result. total_balance_burnt ,
2204
2223
) ;
2205
2224
self . chain_store_update . save_chunk_extra ( & block_header. hash , shard_id, chunk_extra) ;
2206
2225
0 commit comments