sui_core/execution_scheduler/
mod.rs

1// Copyright (c) Mysten Labs, Inc.
2// SPDX-License-Identifier: Apache-2.0
3
4use crate::authority::ExecutionEnv;
5pub use execution_scheduler_impl::ExecutionScheduler;
6pub use funds_withdraw_scheduler::FundsWithdrawSchedulerType;
7use prometheus::IntGauge;
8use sui_types::executable_transaction::VerifiedExecutableTransaction;
9use tokio::time::Instant;
10
11pub(crate) mod execution_scheduler_impl;
12pub(crate) mod funds_withdraw_scheduler;
13mod overload_tracker;
14pub(crate) mod settlement_scheduler;
15pub(crate) use settlement_scheduler::{SettlementBatchInfo, SettlementScheduler};
16
17// TODO: Cleanup this struct.
18#[derive(Clone, Debug)]
19pub struct PendingCertificateStats {
20    // The time this certificate enters execution scheduler.
21    #[allow(unused)]
22    pub enqueue_time: Instant,
23    // The time this certificate becomes ready for execution.
24    pub ready_time: Option<Instant>,
25}
26
27#[derive(Debug)]
28pub struct PendingCertificate {
29    // Certified transaction to be executed.
30    pub certificate: VerifiedExecutableTransaction,
31    // Environment in which the transaction will be executed.
32    pub execution_env: ExecutionEnv,
33    // Stores stats about this transaction.
34    pub stats: PendingCertificateStats,
35    pub executing_guard: Option<ExecutingGuard>,
36}
37
38#[derive(Debug)]
39pub struct ExecutingGuard {
40    num_executing_certificates: IntGauge,
41}
42
43impl ExecutingGuard {
44    pub fn new(num_executing_certificates: IntGauge) -> Self {
45        num_executing_certificates.inc();
46        Self {
47            num_executing_certificates,
48        }
49    }
50}
51
52impl Drop for ExecutingGuard {
53    fn drop(&mut self) {
54        self.num_executing_certificates.dec();
55    }
56}