Skip to content

Commit ab81e5c

Browse files
committed
cleanup(congestion) - removed local congestion control
1 parent a95c83e commit ab81e5c

File tree

1 file changed

+2
-47
lines changed

1 file changed

+2
-47
lines changed

Diff for: chain/chain/src/runtime/mod.rs

+2-47
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use near_chain_configs::{GenesisConfig, MIN_GC_NUM_EPOCHS_TO_KEEP, ProtocolConfi
1111
use near_crypto::PublicKey;
1212
use near_epoch_manager::shard_assignment::account_id_to_shard_id;
1313
use near_epoch_manager::{EpochManagerAdapter, EpochManagerHandle};
14-
use near_parameters::{ActionCosts, ExtCosts, RuntimeConfig, RuntimeConfigStore};
14+
use near_parameters::{ExtCosts, RuntimeConfig, RuntimeConfigStore};
1515
use near_pool::types::TransactionGroupIterator;
1616
use near_primitives::account::{AccessKey, Account};
1717
use near_primitives::apply::ApplyChunkReason;
@@ -20,13 +20,12 @@ use near_primitives::congestion_info::{
2020
};
2121
use near_primitives::errors::{InvalidTxError, RuntimeError, StorageError};
2222
use near_primitives::hash::{CryptoHash, hash};
23-
use near_primitives::receipt::{DelayedReceiptIndices, Receipt};
23+
use near_primitives::receipt::Receipt;
2424
use near_primitives::runtime::migration_data::{MigrationData, MigrationFlags};
2525
use near_primitives::sandbox::state_patch::SandboxStatePatch;
2626
use near_primitives::shard_layout::{ShardLayout, ShardUId};
2727
use near_primitives::state_part::PartId;
2828
use near_primitives::transaction::{SignedTransaction, ValidatedTransaction};
29-
use near_primitives::trie_key::TrieKey;
3029
use near_primitives::types::{
3130
AccountId, Balance, BlockHeight, EpochHeight, EpochId, EpochInfoProvider, Gas, MerkleHash,
3231
ShardId, StateChangeCause, StateRoot, StateRootNode,
@@ -662,18 +661,6 @@ impl RuntimeAdapter for NightshadeRuntime {
662661
};
663662
let mut num_checked_transactions = 0;
664663

665-
// To avoid limiting the throughput of the network, we want to include enough receipts to
666-
// saturate the capacity of the chunk even in case when all of these receipts end up using
667-
// the smallest possible amount of gas, which is at least the cost of execution of action
668-
// receipt.
669-
// Currently, the min execution cost is ~100 GGas and the chunk capacity is 1 PGas, giving
670-
// a bound of at most 10000 receipts processed in a chunk.
671-
let delayed_receipts_indices: DelayedReceiptIndices =
672-
near_store::get(&state_update, &TrieKey::DelayedReceiptIndices)?.unwrap_or_default();
673-
let min_fee = runtime_config.fees.fee(ActionCosts::new_action_receipt).exec_fee();
674-
let new_receipt_count_limit =
675-
get_new_receipt_count_limit(min_fee, gas_limit, delayed_receipts_indices);
676-
677664
let size_limit: u64 = calculate_transactions_size_limit(
678665
protocol_version,
679666
&runtime_config,
@@ -695,17 +682,6 @@ impl RuntimeAdapter for NightshadeRuntime {
695682
result.limited_by = Some(PrepareTransactionsLimit::Size);
696683
break;
697684
}
698-
if !ProtocolFeature::CongestionControl.enabled(protocol_version) {
699-
// Local Congestion Control.
700-
// Keep this for the upgrade phase, afterwards it can be
701-
// removed. It does not need to be kept because it does not
702-
// affect replayability.
703-
// TODO(congestion_control): remove at release CongestionControl + 1 or later
704-
if result.transactions.len() >= new_receipt_count_limit {
705-
result.limited_by = Some(PrepareTransactionsLimit::ReceiptCount);
706-
break;
707-
}
708-
}
709685

710686
if let Some(time_limit) = &time_limit {
711687
if start_time.elapsed() >= *time_limit {
@@ -1285,27 +1261,6 @@ impl RuntimeAdapter for NightshadeRuntime {
12851261
}
12861262
}
12871263

1288-
/// Get the limit on the number of new receipts imposed by the local congestion control.
1289-
fn get_new_receipt_count_limit(
1290-
min_fee: u64,
1291-
gas_limit: u64,
1292-
delayed_receipts_indices: DelayedReceiptIndices,
1293-
) -> usize {
1294-
if min_fee == 0 {
1295-
return usize::MAX;
1296-
}
1297-
// Round up to include at least one receipt.
1298-
let max_processed_receipts_in_chunk = (gas_limit + min_fee - 1) / min_fee;
1299-
// Allow at most 2 chunks worth of delayed receipts. This way under congestion,
1300-
// after processing a single chunk, we will still have at least 1 chunk worth of
1301-
// delayed receipts, ensuring the high throughput even if the next chunk producer
1302-
// does not include any receipts.
1303-
// This buffer size is a trade-off between the max queue size and system efficiency
1304-
// under congestion.
1305-
let delayed_receipt_count_limit = max_processed_receipts_in_chunk * 2;
1306-
delayed_receipt_count_limit.saturating_sub(delayed_receipts_indices.len()) as usize
1307-
}
1308-
13091264
/// How much gas of the next chunk we want to spend on converting new
13101265
/// transactions to receipts.
13111266
fn chunk_tx_gas_limit(

0 commit comments

Comments
 (0)