From 7e9e716a29c077a91dcc2769c904d695f1f8570a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20Chuda=C5=9B?= Date: Thu, 12 Dec 2024 14:19:21 +0100 Subject: [PATCH] fmt --- core/store/src/adapter/trie_store.rs | 6 ++-- .../src/test_loop/tests/resharding_v3.rs | 36 +++++++++---------- nearcore/src/cold_storage.rs | 3 +- vlog | 2 -- 4 files changed, 24 insertions(+), 23 deletions(-) delete mode 100644 vlog diff --git a/core/store/src/adapter/trie_store.rs b/core/store/src/adapter/trie_store.rs index 3950c7eda06..41eb0bd5a7f 100644 --- a/core/store/src/adapter/trie_store.rs +++ b/core/store/src/adapter/trie_store.rs @@ -173,12 +173,14 @@ impl<'a> TrieStoreUpdateAdapter<'a> { } } -/// Get the `ShardUId` mapping for child_shard_uid. +/// Get the `ShardUId` mapping for child_shard_uid. If the mapping does not exist, map the shard to itself. /// Used by Resharding V3 for State mapping. pub fn get_shard_uid_mapping(store: &Store, child_shard_uid: ShardUId) -> ShardUId { store .get_ser::(DBCol::StateShardUIdMapping, &child_shard_uid.to_bytes()) - .expect(&format!("get_shard_uid_mapping() failed for child_shard_uid = {}", child_shard_uid)) + .unwrap_or_else(|_| { + panic!("get_shard_uid_mapping() failed for child_shard_uid = {}", child_shard_uid) + }) .unwrap_or(child_shard_uid) } diff --git a/integration-tests/src/test_loop/tests/resharding_v3.rs b/integration-tests/src/test_loop/tests/resharding_v3.rs index 8bb0d0df916..0db73baf8ab 100644 --- a/integration-tests/src/test_loop/tests/resharding_v3.rs +++ b/integration-tests/src/test_loop/tests/resharding_v3.rs @@ -7,9 +7,7 @@ use near_client::Query; use near_o11y::testonly::init_test_logger; use near_primitives::epoch_manager::EpochConfigStore; use near_primitives::shard_layout::{account_id_to_shard_uid, ShardLayout}; -use near_primitives::types::{ - AccountId, BlockHeightDelta, BlockId, BlockReference, Gas, ShardId, -}; +use near_primitives::types::{AccountId, BlockHeightDelta, BlockId, BlockReference, Gas, ShardId}; use near_primitives::version::{ProtocolFeature, PROTOCOL_VERSION}; use near_store::ShardUId; use std::collections::{BTreeMap, HashMap, HashSet}; @@ -17,12 +15,16 @@ use std::sync::Arc; use crate::test_loop::builder::TestLoopBuilder; use crate::test_loop::env::{TestData, TestLoopEnv}; -use crate::test_loop::utils::sharding::{next_block_has_new_shard_layout, print_and_assert_shard_accounts}; -use crate::test_loop::utils::transactions::{ - create_account, delete_account, get_shared_block_hash, get_smallest_height_head, run_tx, store_and_submit_tx, -}; use crate::test_loop::utils::receipts::{ - check_receipts_presence_after_resharding_block, check_receipts_presence_at_resharding_block, ReceiptKind, + check_receipts_presence_after_resharding_block, check_receipts_presence_at_resharding_block, + ReceiptKind, +}; +use crate::test_loop::utils::sharding::{ + next_block_has_new_shard_layout, print_and_assert_shard_accounts, +}; +use crate::test_loop::utils::transactions::{ + create_account, delete_account, get_shared_block_hash, get_smallest_height_head, run_tx, + store_and_submit_tx, }; use crate::test_loop::utils::trie_sanity::{ check_state_shard_uid_mapping_after_resharding, TrieSanityCheck, @@ -220,8 +222,6 @@ impl TestReshardingParameters { fn fork_before_resharding_block(double_signing: bool) -> LoopActionFn { use near_client::client_actor::AdvProduceBlockHeightSelection; - use crate::test_loop::utils::sharding::next_block_has_new_shard_layout; - let done = Cell::new(false); Box::new( move |_: &[TestData], @@ -944,14 +944,14 @@ fn test_resharding_v3_outgoing_receipts_towards_splitted_shard() { let account_1_in_stable_shard: AccountId = "account1".parse().unwrap(); let account_2_in_stable_shard: AccountId = "account2".parse().unwrap(); let rpc_id = params.rpc_clients[0].clone(); - let params = params - .deploy_test_contract(receiver_account.clone()) - .add_loop_action(call_burn_gas_contract( + let params = params.deploy_test_contract(receiver_account.clone()).add_loop_action( + call_burn_gas_contract( vec![account_1_in_stable_shard, account_2_in_stable_shard], vec![receiver_account], 5 * TGAS, rpc_id, - )); + ), + ); test_resharding_v3_base(params); } @@ -963,14 +963,14 @@ fn test_resharding_v3_outgoing_receipts_from_splitted_shard() { let account_in_left_child: AccountId = "account4".parse().unwrap(); let account_in_right_child: AccountId = "account6".parse().unwrap(); let rpc_id = params.rpc_clients[0].clone(); - let params = params - .deploy_test_contract(receiver_account.clone()) - .add_loop_action(call_burn_gas_contract( + let params = params.deploy_test_contract(receiver_account.clone()).add_loop_action( + call_burn_gas_contract( vec![account_in_left_child, account_in_right_child], vec![receiver_account], 5 * TGAS, rpc_id, - )); + ), + ); test_resharding_v3_base(params); } diff --git a/nearcore/src/cold_storage.rs b/nearcore/src/cold_storage.rs index 812e7373901..a868ce8184b 100644 --- a/nearcore/src/cold_storage.rs +++ b/nearcore/src/cold_storage.rs @@ -124,7 +124,8 @@ fn cold_store_copy( } // Here it should be sufficient to just read from hot storage. // Because BlockHeight is never garbage collectable and is not even copied to cold. - let next_height_block_hash = hot_store.get_ser::(DBCol::BlockHeight, &next_height.to_le_bytes())?; + let next_height_block_hash = + hot_store.get_ser::(DBCol::BlockHeight, &next_height.to_le_bytes())?; if let Some(next_height_block_hash) = next_height_block_hash { break next_height_block_hash; } diff --git a/vlog b/vlog deleted file mode 100644 index d12fa15c2a0..00000000000 --- a/vlog +++ /dev/null @@ -1,2 +0,0 @@ - -running 1 test