Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
staffik committed Dec 12, 2024
1 parent 893ea1a commit 7e9e716
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 23 deletions.
6 changes: 4 additions & 2 deletions core/store/src/adapter/trie_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<ShardUId>(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)
}

Expand Down
36 changes: 18 additions & 18 deletions integration-tests/src/test_loop/tests/resharding_v3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,24 @@ 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};
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,
Expand Down Expand Up @@ -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],
Expand Down Expand Up @@ -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);
}

Expand All @@ -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);
}

Expand Down
3 changes: 2 additions & 1 deletion nearcore/src/cold_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<CryptoHash>(DBCol::BlockHeight, &next_height.to_le_bytes())?;
let next_height_block_hash =
hot_store.get_ser::<CryptoHash>(DBCol::BlockHeight, &next_height.to_le_bytes())?;
if let Some(next_height_block_hash) = next_height_block_hash {
break next_height_block_hash;
}
Expand Down
2 changes: 0 additions & 2 deletions vlog

This file was deleted.

0 comments on commit 7e9e716

Please sign in to comment.