Skip to content

Commit 1fd360d

Browse files
committed
[gas] Fix potential data race in gas object check
1 parent cee758b commit 1fd360d

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

crates/sui-core/src/transaction_input_checker.rs

+9-6
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ use crate::authority::SuiDataStore;
55
use serde::{Deserialize, Serialize};
66
use std::collections::HashSet;
77
use std::fmt::Debug;
8+
use sui_types::base_types::ObjectRef;
89
use sui_types::messages::TransactionKind;
910
use sui_types::{
10-
base_types::{ObjectID, SequenceNumber, SuiAddress},
11+
base_types::{SequenceNumber, SuiAddress},
1112
error::{SuiError, SuiResult},
1213
fp_ensure,
1314
gas::{self, SuiGasStatus},
@@ -28,7 +29,7 @@ where
2829
{
2930
let mut gas_status = check_gas(
3031
store,
31-
transaction.gas_payment_object_ref().0,
32+
transaction.gas_payment_object_ref(),
3233
transaction.signed_data.data.gas_budget,
3334
transaction.signed_data.data.gas_price,
3435
&transaction.signed_data.data.kind,
@@ -90,7 +91,7 @@ where
9091
#[instrument(level = "trace", skip_all)]
9192
async fn check_gas<S>(
9293
store: &SuiDataStore<S>,
93-
gas_payment_id: ObjectID,
94+
gas_payment: &ObjectRef,
9495
gas_budget: u64,
9596
computation_gas_price: u64,
9697
tx_kind: &TransactionKind,
@@ -101,9 +102,11 @@ where
101102
if tx_kind.is_system_tx() {
102103
Ok(SuiGasStatus::new_unmetered())
103104
} else {
104-
let gas_object = store.get_object(&gas_payment_id)?;
105-
let gas_object = gas_object.ok_or(SuiError::ObjectNotFound {
106-
object_id: gas_payment_id,
105+
let gas_object = store.get_object_by_key(&gas_payment.0, gas_payment.1)?;
106+
let gas_object = gas_object.ok_or(SuiError::ObjectErrors {
107+
errors: vec![SuiError::ObjectNotFound {
108+
object_id: gas_payment.0,
109+
}],
107110
})?;
108111

109112
//TODO: cache this storage_gas_price in memory

0 commit comments

Comments
 (0)