diff --git a/crates/sui-core/src/authority.rs b/crates/sui-core/src/authority.rs index f5d648a9a7d51..5b5c7d23fdd67 100644 --- a/crates/sui-core/src/authority.rs +++ b/crates/sui-core/src/authority.rs @@ -2234,13 +2234,6 @@ impl AuthorityState { .expect("Cannot insert genesis object") } - pub async fn insert_genesis_objects_bulk_unsafe(&self, objects: &[&Object]) { - self.database - .bulk_object_insert(objects) - .await - .expect("Cannot bulk insert genesis objects") - } - /// Make an information response for a transaction pub async fn make_transaction_info( &self, diff --git a/crates/sui-core/src/authority/authority_store.rs b/crates/sui-core/src/authority/authority_store.rs index 487c04beca421..e13fba0f3acf3 100644 --- a/crates/sui-core/src/authority/authority_store.rs +++ b/crates/sui-core/src/authority/authority_store.rs @@ -496,7 +496,7 @@ impl AuthorityStore { /// Insert an object directly into the store, and also update relevant tables /// NOTE: does not handle transaction lock. /// This is used to insert genesis objects - pub async fn insert_object_direct(&self, object_ref: ObjectRef, object: &Object) -> SuiResult { + async fn insert_object_direct(&self, object_ref: ObjectRef, object: &Object) -> SuiResult { let mut write_batch = self.perpetual_tables.objects.batch(); // Insert object @@ -532,10 +532,8 @@ impl AuthorityStore { Ok(()) } - /// This function is used by the bench.rs script, and should not be used in other contexts - /// In particular it does not check the old locks before inserting new ones, so the objects - /// must be new. - pub async fn bulk_object_insert(&self, objects: &[&Object]) -> SuiResult<()> { + /// This function should only be used for initializing genesis and should remain private. + async fn bulk_object_insert(&self, objects: &[&Object]) -> SuiResult<()> { let mut batch = self.perpetual_tables.objects.batch(); let ref_and_objects: Vec<_> = objects .iter() diff --git a/crates/sui-core/src/unit_tests/pay_sui_tests.rs b/crates/sui-core/src/unit_tests/pay_sui_tests.rs index d1b80ee596262..5bc16880480d2 100644 --- a/crates/sui-core/src/unit_tests/pay_sui_tests.rs +++ b/crates/sui-core/src/unit_tests/pay_sui_tests.rs @@ -1,7 +1,9 @@ // Copyright (c) Mysten Labs, Inc. // SPDX-License-Identifier: Apache-2.0 -use crate::authority::authority_tests::{init_state, send_and_confirm_transaction}; +use crate::authority::authority_tests::{ + init_state, init_state_with_committee, send_and_confirm_transaction, +}; use crate::authority::AuthorityState; use futures::future::join_all; use std::collections::HashMap; @@ -458,15 +460,32 @@ async fn execute_pay_all_sui( sender_key: AccountKeyPair, gas_budget: u64, ) -> PaySuiTransactionExecutionResult { - let authority_state = init_state().await; - authority_state - .insert_genesis_objects_bulk_unsafe(&input_coin_objects) - .await; - - let input_coins: Vec = input_coin_objects - .iter() - .map(|obj| obj.compute_object_reference()) - .collect(); + let dir = tempfile::TempDir::new().unwrap(); + let network_config = sui_config::builder::ConfigBuilder::new(&dir) + .with_objects( + input_coin_objects + .clone() + .into_iter() + .map(ToOwned::to_owned) + .collect(), + ) + .build(); + let genesis = network_config.genesis; + let keypair = network_config.validator_configs[0].protocol_key_pair(); + + let authority_state = init_state_with_committee(&genesis, keypair).await; + + let mut input_coins = Vec::new(); + for coin in input_coin_objects { + let id = coin.id(); + let object_ref = genesis + .objects() + .iter() + .find(|o| o.id() == id) + .unwrap() + .compute_object_reference(); + input_coins.push(object_ref); + } let gas_object_ref = input_coins[0]; let kind = TransactionKind::Single(SingleTransactionKind::PayAllSui(PayAllSui {