unc_primitives/runtime/
apply_state.rs

1use crate::runtime::migration_data::{MigrationData, MigrationFlags};
2use crate::{
3    hash::CryptoHash,
4    types::{Balance, BlockHeight, EpochHeight, EpochId, Gas},
5    version::ProtocolVersion,
6};
7use std::sync::Arc;
8use unc_parameters::RuntimeConfig;
9use unc_vm_runner::logic::CompiledContractCache;
10
11#[derive(Debug)]
12pub struct ApplyState {
13    /// Currently building block height.
14    pub block_height: BlockHeight,
15    /// Prev block hash
16    pub prev_block_hash: CryptoHash,
17    /// Current block hash
18    pub block_hash: CryptoHash,
19    /// Current epoch id
20    pub epoch_id: EpochId,
21    /// Current epoch height
22    pub epoch_height: EpochHeight,
23    /// Price for the gas.
24    pub gas_price: Balance,
25    /// The current block timestamp (number of non-leap-nanoseconds since January 1, 1970 0:00:00 UTC).
26    pub block_timestamp: u64,
27    /// Gas limit for a given chunk.
28    /// If None is given, assumes there is no gas limit.
29    pub gas_limit: Option<Gas>,
30    /// Current random seed (from current block vrf output).
31    pub random_seed: CryptoHash,
32    /// Current Protocol version when we apply the state transition
33    pub current_protocol_version: ProtocolVersion,
34    /// The Runtime config to use for the current transition.
35    pub config: Arc<RuntimeConfig>,
36    /// Cache for compiled contracts.
37    pub cache: Option<Box<dyn CompiledContractCache>>,
38    /// Whether the chunk being applied is new.
39    pub is_new_chunk: bool,
40    /// Data for migrations that may need to be applied at the start of an epoch when protocol
41    /// version changes
42    pub migration_data: Arc<MigrationData>,
43    /// Flags for migrations indicating whether they can be applied at this block
44    pub migration_flags: MigrationFlags,
45}