Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract object loading from transaction input checking #14579

Merged
merged 14 commits into from
Nov 8, 2023
Prev Previous commit
Next Next commit
PR comments
  • Loading branch information
mystenmark committed Nov 8, 2023
commit 8bcfd04394430316a54c56bc761874d1f03e7a45
10 changes: 5 additions & 5 deletions crates/sui-core/src/authority.rs
Original file line number Diff line number Diff line change
Expand Up @@ -955,10 +955,14 @@ impl AuthorityState {
expected_effects_digest: Option<TransactionEffectsDigest>,
epoch_store: &Arc<AuthorityPerEpochStore>,
) -> SuiResult<(TransactionEffects, Option<ExecutionError>)> {
let _scope = monitored_scope("Execution::try_execute_immediately");
let _metrics_guard = self.metrics.internal_execution_latency.start_timer();
debug!("execute_certificate_internal");

let tx_digest = certificate.digest();
let input_objects = {
let _scope = monitored_scope("Execution::load_input_objects");
let input_objects = &certificate.data().intent_message().value.input_objects()?;
let input_objects = &certificate.data().transaction_data().input_objects()?;
if certificate.data().transaction_data().is_end_of_epoch_tx() {
self.input_loader
.read_objects_for_synchronous_execution(
Expand All @@ -979,10 +983,6 @@ impl AuthorityState {
}
};

let _scope = monitored_scope("Execution::try_execute_immediately");
let _metrics_guard = self.metrics.internal_execution_latency.start_timer();
debug!("execute_certificate_internal");

// This acquires a lock on the tx digest to prevent multiple concurrent executions of the
// same tx. While we don't need this for safety (tx sequencing is ultimately atomic), it is
// very common to receive the same tx multiple times simultaneously due to gossip, so we
Expand Down
6 changes: 6 additions & 0 deletions crates/sui-core/src/transaction_input_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use sui_types::{
ReceivingObjectReadResult, ReceivingObjectReadResultKind, ReceivingObjects,
},
};
use tracing::instrument;

pub(crate) struct TransactionInputLoader {
store: Arc<AuthorityStore>,
Expand All @@ -32,6 +33,7 @@ impl TransactionInputLoader {
/// Read the inputs for a transaction that the validator was asked to sign.
/// tx_digest is provided so that the inputs can be cached with the tx_digest and returned with
mystenmark marked this conversation as resolved.
Show resolved Hide resolved
/// a single hash map lookup when notify_read_objects_for_execution is called later.
#[instrument(level = "trace", skip_all)]
pub async fn read_objects_for_signing(
&self,
_tx_digest: &TransactionDigest,
Expand Down Expand Up @@ -148,6 +150,7 @@ impl TransactionInputLoader {
/// Reads input objects assuming a synchronous context such as the end of epoch transaction.
/// By "synchronous" we mean that it is safe to read the latest version of all shared objects,
/// as opposed to relying on the shared input version assignment.
#[instrument(level = "trace", skip_all)]
pub async fn read_objects_for_synchronous_execution(
&self,
tx_digest: &TransactionDigest,
Expand All @@ -165,6 +168,7 @@ impl TransactionInputLoader {
}

/// Read input objects for a dry run execution.
#[instrument(level = "trace", skip_all)]
pub async fn read_objects_for_dry_run_exec(
&self,
tx_digest: &TransactionDigest,
Expand All @@ -182,6 +186,7 @@ impl TransactionInputLoader {
}

/// Read input objects for dev inspect
#[instrument(level = "trace", skip_all)]
pub async fn read_objects_for_dev_inspect(
&self,
input_object_kinds: &[InputObjectKind],
Expand Down Expand Up @@ -209,6 +214,7 @@ impl TransactionInputLoader {
/// can be stored as a group with the transaction_digest as the key, allowing the lookup to
/// proceed with only a single hash map lookup. (additional lookups may be necessary for shared
mystenmark marked this conversation as resolved.
Show resolved Hide resolved
/// inputs, since the versions are not known at signing time).
#[instrument(level = "trace", skip_all)]
pub async fn read_objects_for_execution(
&self,
shared_lock_store: &dyn GetSharedLocks,
mystenmark marked this conversation as resolved.
Show resolved Hide resolved
Expand Down