Skip to main content

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 causal_admission;
12pub(crate) mod execution_scheduler_impl;
13pub(crate) mod funds_withdraw_scheduler;
14mod overload_tracker;
15pub(crate) mod settlement_scheduler;
16pub(crate) use settlement_scheduler::{SettlementBatchInfo, SettlementScheduler};
17
18// TODO: Cleanup this struct.
19#[derive(Clone, Debug)]
20pub struct PendingCertificateStats {
21    // The time this certificate enters execution scheduler.
22    #[allow(unused)]
23    pub enqueue_time: Instant,
24    // The time this certificate becomes ready for execution.
25    pub ready_time: Option<Instant>,
26}
27
28#[derive(Debug)]
29pub struct PendingCertificate {
30    // Certified transaction to be executed.
31    pub certificate: VerifiedExecutableTransaction,
32    // Environment in which the transaction will be executed.
33    pub execution_env: ExecutionEnv,
34    // Stores stats about this transaction.
35    pub stats: PendingCertificateStats,
36    pub executing_guard: Option<ExecutingGuard>,
37}
38
39#[derive(Debug)]
40pub struct ExecutingGuard {
41    num_executing_certificates: IntGauge,
42}
43
44impl ExecutingGuard {
45    pub fn new(num_executing_certificates: IntGauge) -> Self {
46        num_executing_certificates.inc();
47        Self {
48            num_executing_certificates,
49        }
50    }
51}
52
53impl Drop for ExecutingGuard {
54    fn drop(&mut self) {
55        self.num_executing_certificates.dec();
56    }
57}