Struct snarkvm_synthesizer::vm::VM
source · pub struct VM<N: Network, C: ConsensusStorage<N>> { /* private fields */ }
Implementations§
source§impl<N: Network, C: ConsensusStorage<N>> VM<N, C>
impl<N: Network, C: ConsensusStorage<N>> VM<N, C>
Authorizes a call to the program function for the given inputs.
Authorizes the fee given the credits record, the fee amount (in microcredits), and the deployment or execution ID.
Authorizes the fee given the the fee amount (in microcredits) and the deployment or execution ID.
source§impl<N: Network, C: ConsensusStorage<N>> VM<N, C>
impl<N: Network, C: ConsensusStorage<N>> VM<N, C>
sourcepub fn deploy<R: Rng + CryptoRng>(
&self,
private_key: &PrivateKey<N>,
program: &Program<N>,
fee_record: Option<Record<N, Plaintext<N>>>,
priority_fee_in_microcredits: u64,
query: Option<Query<N, C::BlockStorage>>,
rng: &mut R
) -> Result<Transaction<N>>
pub fn deploy<R: Rng + CryptoRng>( &self, private_key: &PrivateKey<N>, program: &Program<N>, fee_record: Option<Record<N, Plaintext<N>>>, priority_fee_in_microcredits: u64, query: Option<Query<N, C::BlockStorage>>, rng: &mut R ) -> Result<Transaction<N>>
Returns a new deploy transaction.
If a fee_record
is provided, then a private fee will be included in the transaction;
otherwise, a public fee will be included in the transaction.
The priority_fee_in_microcredits
is an additional fee on top of the deployment fee.
source§impl<N: Network, C: ConsensusStorage<N>> VM<N, C>
impl<N: Network, C: ConsensusStorage<N>> VM<N, C>
sourcepub fn execute<R: Rng + CryptoRng>(
&self,
private_key: &PrivateKey<N>,
(program_id, function_name): (impl TryInto<ProgramID<N>>, impl TryInto<Identifier<N>>),
inputs: impl ExactSizeIterator<Item = impl TryInto<Value<N>>>,
fee_record: Option<Record<N, Plaintext<N>>>,
priority_fee_in_microcredits: u64,
query: Option<Query<N, C::BlockStorage>>,
rng: &mut R
) -> Result<Transaction<N>>
pub fn execute<R: Rng + CryptoRng>( &self, private_key: &PrivateKey<N>, (program_id, function_name): (impl TryInto<ProgramID<N>>, impl TryInto<Identifier<N>>), inputs: impl ExactSizeIterator<Item = impl TryInto<Value<N>>>, fee_record: Option<Record<N, Plaintext<N>>>, priority_fee_in_microcredits: u64, query: Option<Query<N, C::BlockStorage>>, rng: &mut R ) -> Result<Transaction<N>>
Returns a new execute transaction.
If a fee_record
is provided, then a private fee will be included in the transaction;
otherwise, a public fee will be included in the transaction.
The priority_fee_in_microcredits
is an additional fee on top of the execution fee.
Returns a new execute transaction for the given authorization.
Returns a new fee for the given authorization.
source§impl<N: Network, C: ConsensusStorage<N>> VM<N, C>
impl<N: Network, C: ConsensusStorage<N>> VM<N, C>
sourcepub fn speculate<'a>(
&self,
state: FinalizeGlobalState,
coinbase_reward: Option<u64>,
candidate_ratifications: Vec<Ratify<N>>,
candidate_solutions: Option<&CoinbaseSolution<N>>,
candidate_transactions: impl ExactSizeIterator<Item = &'a Transaction<N>>
) -> Result<(Ratifications<N>, Transactions<N>, Vec<N::TransactionID>, Vec<FinalizeOperation<N>>)>
pub fn speculate<'a>( &self, state: FinalizeGlobalState, coinbase_reward: Option<u64>, candidate_ratifications: Vec<Ratify<N>>, candidate_solutions: Option<&CoinbaseSolution<N>>, candidate_transactions: impl ExactSizeIterator<Item = &'a Transaction<N>> ) -> Result<(Ratifications<N>, Transactions<N>, Vec<N::TransactionID>, Vec<FinalizeOperation<N>>)>
Speculates on the given list of transactions in the VM.
Returns the confirmed transactions, aborted transaction IDs, and finalize operations from pre-ratify and post-ratify.
Note: This method is used to create a new block (including the genesis block).
- If
coinbase_reward = None
, then theratifications
will not be modified. - If
coinbase_reward = Some(coinbase_reward)
, then the method will append aRatify::BlockReward(block_reward)
andRatify::PuzzleReward(puzzle_reward)
to the front of theratifications
list.
sourcepub fn check_speculate(
&self,
state: FinalizeGlobalState,
ratifications: &Ratifications<N>,
solutions: Option<&CoinbaseSolution<N>>,
transactions: &Transactions<N>
) -> Result<Vec<FinalizeOperation<N>>>
pub fn check_speculate( &self, state: FinalizeGlobalState, ratifications: &Ratifications<N>, solutions: Option<&CoinbaseSolution<N>>, transactions: &Transactions<N> ) -> Result<Vec<FinalizeOperation<N>>>
Checks the speculation on the given transactions in the VM.
Returns the finalize operations from pre-ratify and post-ratify.
sourcepub fn finalize(
&self,
state: FinalizeGlobalState,
ratifications: &Ratifications<N>,
solutions: Option<&CoinbaseSolution<N>>,
transactions: &Transactions<N>
) -> Result<Vec<FinalizeOperation<N>>>
pub fn finalize( &self, state: FinalizeGlobalState, ratifications: &Ratifications<N>, solutions: Option<&CoinbaseSolution<N>>, transactions: &Transactions<N> ) -> Result<Vec<FinalizeOperation<N>>>
Finalizes the given transactions into the VM.
Returns the finalize operations from pre-ratify and post-ratify.
source§impl<N: Network, C: ConsensusStorage<N>> VM<N, C>
impl<N: Network, C: ConsensusStorage<N>> VM<N, C>
sourcepub const MAXIMUM_CONFIRMED_TRANSACTIONS: usize = 65_536usize
pub const MAXIMUM_CONFIRMED_TRANSACTIONS: usize = 65_536usize
The maximum number of confirmed transactions allowed in a block.
source§impl<N: Network, C: ConsensusStorage<N>> VM<N, C>
impl<N: Network, C: ConsensusStorage<N>> VM<N, C>
sourcepub fn check_transaction<R: CryptoRng + Rng>(
&self,
transaction: &Transaction<N>,
rejected_id: Option<Field<N>>,
rng: &mut R
) -> Result<()>
pub fn check_transaction<R: CryptoRng + Rng>( &self, transaction: &Transaction<N>, rejected_id: Option<Field<N>>, rng: &mut R ) -> Result<()>
Verifies the transaction in the VM. On failure, returns an error.
source§impl<N: Network, C: ConsensusStorage<N>> VM<N, C>
impl<N: Network, C: ConsensusStorage<N>> VM<N, C>
sourcepub fn from(store: ConsensusStore<N, C>) -> Result<Self>
pub fn from(store: ConsensusStore<N, C>) -> Result<Self>
Initializes the VM from storage.
sourcepub fn contains_program(&self, program_id: &ProgramID<N>) -> bool
pub fn contains_program(&self, program_id: &ProgramID<N>) -> bool
Returns true
if a program with the given program ID exists.
source§impl<N: Network, C: ConsensusStorage<N>> VM<N, C>
impl<N: Network, C: ConsensusStorage<N>> VM<N, C>
sourcepub fn finalize_store(&self) -> &FinalizeStore<N, C::FinalizeStorage>
pub fn finalize_store(&self) -> &FinalizeStore<N, C::FinalizeStorage>
Returns the finalize store.
sourcepub fn block_store(&self) -> &BlockStore<N, C::BlockStorage>
pub fn block_store(&self) -> &BlockStore<N, C::BlockStorage>
Returns the block store.
sourcepub fn transaction_store(&self) -> &TransactionStore<N, C::TransactionStorage>
pub fn transaction_store(&self) -> &TransactionStore<N, C::TransactionStorage>
Returns the transaction store.
sourcepub fn transition_store(&self) -> &TransitionStore<N, C::TransitionStorage>
pub fn transition_store(&self) -> &TransitionStore<N, C::TransitionStorage>
Returns the transition store.
source§impl<N: Network, C: ConsensusStorage<N>> VM<N, C>
impl<N: Network, C: ConsensusStorage<N>> VM<N, C>
sourcepub fn genesis_beacon<R: Rng + CryptoRng>(
&self,
private_key: &PrivateKey<N>,
rng: &mut R
) -> Result<Block<N>>
pub fn genesis_beacon<R: Rng + CryptoRng>( &self, private_key: &PrivateKey<N>, rng: &mut R ) -> Result<Block<N>>
Returns a new genesis block for a beacon chain.
sourcepub fn genesis_quorum<R: Rng + CryptoRng>(
&self,
private_key: &PrivateKey<N>,
committee: Committee<N>,
public_balances: IndexMap<Address<N>, u64>,
rng: &mut R
) -> Result<Block<N>>
pub fn genesis_quorum<R: Rng + CryptoRng>( &self, private_key: &PrivateKey<N>, committee: Committee<N>, public_balances: IndexMap<Address<N>, u64>, rng: &mut R ) -> Result<Block<N>>
Returns a new genesis block for a quorum chain.
sourcepub fn add_next_block(&self, block: &Block<N>) -> Result<()>
pub fn add_next_block(&self, block: &Block<N>) -> Result<()>
Adds the given block into the VM.