Skip to content

Commit

Permalink
nit
Browse files Browse the repository at this point in the history
  • Loading branch information
wacban committed Dec 18, 2024
1 parent 4eea6ad commit 752e804
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 23 deletions.
23 changes: 1 addition & 22 deletions chain/chain/src/stateless_validation/chunk_validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use crate::types::{
};
use crate::validate::validate_chunk_with_chunk_extra_and_receipts_root;
use crate::{Chain, ChainStore, ChainStoreAccess};
use itertools::Itertools;
use lru::LruCache;
use near_async::futures::AsyncComputationSpawnerExt;
use near_chain_primitives::Error;
Expand All @@ -37,7 +36,6 @@ use near_primitives::types::{AccountId, ProtocolVersion, ShardId, ShardIndex};
use near_primitives::utils::compression::CompressedData;
use near_store::trie::ops::resharding::RetainMode;
use near_store::{PartialStorage, Trie};
use node_runtime::bootstrap_congestion_info;
use std::collections::HashMap;
use std::num::NonZeroUsize;
use std::sync::{Arc, Mutex};
Expand Down Expand Up @@ -723,6 +721,7 @@ pub fn validate_chunk_state_witness(
let new_root = trie.retain_split_shard(&boundary_account, retain_mode)?;

if let Some(congestion_info) = chunk_extra.congestion_info_mut() {
tracing::info!("BOOM doing congestion info");
// Get the congestion info based on the parent shard.
let epoch_id = epoch_manager.get_epoch_id(&block_hash)?;
let parent_shard_layout = epoch_manager.get_shard_layout(&epoch_id)?;
Expand All @@ -743,26 +742,6 @@ pub fn validate_chunk_state_witness(
child_shard_uid,
congestion_info,
)?;

let config = runtime_adapter.get_runtime_config(protocol_version)?;
let new_shard_id = child_shard_uid.shard_id();
*congestion_info = bootstrap_congestion_info(&trie, &config, new_shard_id)?;

// Please note the usage of the child shard layout here.
let next_epoch_id = epoch_manager.get_next_epoch_id(&block_hash)?;
let next_shard_layout = epoch_manager.get_shard_layout(&next_epoch_id)?;
let all_shards = next_shard_layout.shard_ids().collect_vec();
let own_shard = new_shard_id;
let own_shard_index = next_shard_layout
.get_shard_index(own_shard)?
.try_into()
.expect("ShardIndex must fit in u64");

// Use simplified congestion seed. The proper one should be
// block height + shard index, however the block heigh is not
// easily available in all required places.
let congestion_seed = own_shard_index;
congestion_info.finalize_allowed_shard(own_shard, &all_shards, congestion_seed);
}

(child_shard_uid, new_root)
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/src/test_loop/tests/resharding_v3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -968,7 +968,7 @@ fn test_resharding_v3_split_parent_buffered_receipts_base(base_shard_layout_vers
let account_in_right_child: AccountId = "account6".parse().unwrap();
let params = TestReshardingParametersBuilder::default()
.base_shard_layout_version(base_shard_layout_version)
.allow_negative_refcount()
.allow_negative_refcount(true)
.deploy_test_contract(receiver_account.clone())
.limit_outgoing_gas(true)
.add_loop_action(call_burn_gas_contract(
Expand Down

0 comments on commit 752e804

Please sign in to comment.