From d2a9fb63b8aed593b8eb982b8f11e31ea91bed37 Mon Sep 17 00:00:00 2001 From: Andrew Schran Date: Fri, 1 Nov 2024 14:08:07 -0400 Subject: [PATCH] Bug fix for `test_simulated_load_shared_object_congestion_control` (#20139) ## Description Prevents the test from erroneously picking up current protocol config setting for separate randomness congestion control budget. ## Test plan Is a test fix --- ## Release notes Check each box that your changes affect. If none of the boxes relate to your changes, release notes aren't required. For each box you select, include information after the relevant heading that describes the impact of your changes that a user might notice and any actions they must take to implement updates. - [ ] Protocol: - [ ] Nodes (Validators and Full nodes): - [ ] Indexer: - [ ] JSON-RPC: - [ ] GraphQL: - [ ] CLI: - [ ] Rust SDK: - [ ] REST API: --- crates/sui-benchmark/tests/simtest.rs | 3 +++ .../shared_object_congestion_tracker.rs | 22 +++++++++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/crates/sui-benchmark/tests/simtest.rs b/crates/sui-benchmark/tests/simtest.rs index 3c0e9cacccc4b..88e4c5f7a3091 100644 --- a/crates/sui-benchmark/tests/simtest.rs +++ b/crates/sui-benchmark/tests/simtest.rs @@ -547,6 +547,9 @@ mod test { config.max_accumulated_txn_cost_per_object_in_mysticeti_commit() / 10, ), ); + } else { + config + .disable_max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit_for_testing(); } config }); diff --git a/crates/sui-core/src/authority/shared_object_congestion_tracker.rs b/crates/sui-core/src/authority/shared_object_congestion_tracker.rs index 82250fe4e37e9..fa1fa9013cf1f 100644 --- a/crates/sui-core/src/authority/shared_object_congestion_tracker.rs +++ b/crates/sui-core/src/authority/shared_object_congestion_tracker.rs @@ -12,6 +12,7 @@ use sui_types::base_types::{ObjectID, TransactionDigest}; use sui_types::error::SuiResult; use sui_types::executable_transaction::VerifiedExecutableTransaction; use sui_types::transaction::{Argument, SharedInputObject, TransactionDataAPI}; +use tracing::debug; // SharedObjectCongestionTracker stores the accumulated cost of executing transactions on an object, for // all transactions in a consensus commit. @@ -44,6 +45,8 @@ impl SharedObjectCongestionTracker { gas_budget_based_txn_cost_absolute_cap_commit_count: Option, max_txn_cost_overage_per_object_in_commit: u64, ) -> Self { + let object_execution_cost: HashMap = + initial_object_debts.into_iter().collect(); let max_accumulated_txn_cost_per_object_in_commit = if mode == PerObjectCongestionControlMode::None { 0 @@ -52,14 +55,25 @@ impl SharedObjectCongestionTracker { "max_accumulated_txn_cost_per_object_in_commit must be set if mode is not None", ) }; + let gas_budget_based_txn_cost_absolute_cap = + gas_budget_based_txn_cost_absolute_cap_commit_count + .map(|m| m * max_accumulated_txn_cost_per_object_in_commit); + debug!( + "created SharedObjectCongestionTracker with + {} initial object debts, + mode: {mode:?}, + max_accumulated_txn_cost_per_object_in_commit: {max_accumulated_txn_cost_per_object_in_commit:?}, + gas_budget_based_txn_cost_cap_factor: {gas_budget_based_txn_cost_cap_factor:?}, + gas_budget_based_txn_cost_absolute_cap: {gas_budget_based_txn_cost_absolute_cap:?}, + max_txn_cost_overage_per_object_in_commit: {max_txn_cost_overage_per_object_in_commit:?}", + object_execution_cost.len(), + ); Self { - object_execution_cost: initial_object_debts.into_iter().collect(), + object_execution_cost, mode, max_accumulated_txn_cost_per_object_in_commit, gas_budget_based_txn_cost_cap_factor, - gas_budget_based_txn_cost_absolute_cap: - gas_budget_based_txn_cost_absolute_cap_commit_count - .map(|m| m * max_accumulated_txn_cost_per_object_in_commit), + gas_budget_based_txn_cost_absolute_cap, max_txn_cost_overage_per_object_in_commit, } }