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