1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
//! FuelVM implementation

#![cfg_attr(not(feature = "std"), no_std)]
#![warn(missing_docs)]
#![deny(unsafe_code)]
#![deny(unused_must_use)]
#![deny(unused_crate_dependencies)]
#![deny(
    clippy::arithmetic_side_effects,
    clippy::cast_sign_loss,
    clippy::cast_possible_truncation,
    clippy::cast_possible_wrap,
    clippy::string_slice
)]

#[doc(hidden)] // Needed by some of the exported macros
pub extern crate alloc;

extern crate core;
#[cfg(feature = "std")]
extern crate libm as _; // Not needed with stdlib
#[cfg(test)]
use criterion as _;

pub mod backtrace;
pub mod call;
pub mod checked_transaction;
pub mod constraints;
pub mod consts;
pub mod context;
mod convert;
pub mod crypto;
pub mod error;
pub mod interpreter;
pub mod memory_client;
pub mod pool;
pub mod predicate;
pub mod state;
pub mod storage;
pub mod transactor;
pub mod util;

#[cfg(feature = "profile-any")]
pub mod profiler;

#[cfg(test)]
mod tests;

#[cfg(not(feature = "profile-any"))]
/// Placeholder
pub mod profiler {
    use crate::constraints::InstructionLocation;

    /// Placeholder profiler.
    #[derive(Default, Debug, Clone)]
    pub struct Profiler;

    impl Profiler {
        /// Set the current coverage location.
        pub fn set_coverage(&mut self, _location: InstructionLocation) {}

        /// Add gas to the current coverage location.
        pub fn add_gas(&mut self, _location: InstructionLocation, _gas_use: u64) {}
    }
}

// Fully re-export fuel dependencies
#[doc(no_inline)]
pub use fuel_asm;
#[doc(no_inline)]
pub use fuel_crypto;
#[doc(no_inline)]
pub use fuel_merkle;
#[doc(no_inline)]
pub use fuel_storage;
#[doc(no_inline)]
pub use fuel_tx;
#[doc(no_inline)]
pub use fuel_types;

pub mod prelude {
    //! Required implementations for full functionality
    #[doc(no_inline)]
    pub use fuel_asm::{
        GMArgs,
        GTFArgs,
        Instruction,
        Opcode,
        PanicReason,
        RegId,
    };
    #[doc(no_inline)]
    pub use fuel_crypto::{
        Hasher,
        Message,
        PublicKey,
        SecretKey,
        Signature,
    };
    #[doc(no_inline)]
    pub use fuel_storage::{
        MerkleRoot,
        MerkleRootStorage,
        StorageAsMut,
        StorageAsRef,
        StorageInspect,
        StorageMutate,
    };
    #[doc(no_inline)]
    pub use fuel_tx::*;
    #[doc(no_inline)]
    pub use fuel_types::{
        Address,
        AssetId,
        Bytes32,
        Bytes4,
        Bytes64,
        Bytes8,
        ContractId,
        Immediate06,
        Immediate12,
        Immediate18,
        Immediate24,
        RegisterId,
        Salt,
        Word,
    };

    pub use crate::{
        backtrace::Backtrace,
        call::{
            Call,
            CallFrame,
        },
        context::Context,
        error::{
            Bug,
            BugVariant,
            InterpreterError,
            RuntimeError,
        },
        interpreter::{
            ExecutableTransaction,
            Interpreter,
            Memory,
            MemoryInstance,
            MemoryRange,
        },
        memory_client::MemoryClient,
        pool::VmMemoryPool,
        predicate::RuntimePredicate,
        state::{
            Debugger,
            ProgramState,
            StateTransition,
            StateTransitionRef,
        },
        storage::{
            InterpreterStorage,
            MemoryStorage,
            PredicateStorage,
        },
        transactor::Transactor,
    };

    pub use crate::state::{
        Breakpoint,
        DebugEval,
    };

    #[cfg(any(test, feature = "test-helpers"))]
    pub use crate::util::test_helpers::TestBuilder;

    #[cfg(any(test, feature = "test-helpers"))]
    pub use crate::checked_transaction::{
        builder::TransactionBuilderExt,
        IntoChecked,
    };

    #[cfg(all(
        feature = "profile-gas",
        feature = "std",
        any(test, feature = "test-helpers")
    ))]
    pub use crate::util::gas_profiling::GasProfiler;

    pub use crate::profiler::Profiler;
    #[cfg(feature = "profile-any")]
    pub use crate::profiler::{
        CoverageProfilingData,
        GasProfilingData,
        InstructionLocation,
        PerLocationIter,
        PerLocationKeys,
        PerLocationValues,
        ProfileReceiver,
        ProfilingData,
        StderrReceiver,
    };
}