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<&dyn QueryTrait<N>>,
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<&dyn QueryTrait<N>>, 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<&dyn QueryTrait<N>>,
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<&dyn QueryTrait<N>>, 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.
Sourcepub fn execute_with_response<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<&dyn QueryTrait<N>>,
rng: &mut R,
) -> Result<(Transaction<N>, Response<N>)>
pub fn execute_with_response<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<&dyn QueryTrait<N>>, rng: &mut R, ) -> Result<(Transaction<N>, Response<N>)>
Returns a new execute transaction and response.
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.
This is identical to execute_authorization_with_response except that it
discards the Response.
Returns a new execute transaction and response 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, R: Rng + CryptoRng>(
&self,
state: FinalizeGlobalState,
time_since_last_block: i64,
coinbase_reward: Option<u64>,
candidate_ratifications: Vec<Ratify<N>>,
candidate_solutions: &Solutions<N>,
candidate_transactions: impl ExactSizeIterator<Item = &'a Transaction<N>>,
rng: &mut R,
) -> Result<(Ratifications<N>, Transactions<N>, Vec<N::TransactionID>, Vec<FinalizeOperation<N>>)>
pub fn speculate<'a, R: Rng + CryptoRng>( &self, state: FinalizeGlobalState, time_since_last_block: i64, coinbase_reward: Option<u64>, candidate_ratifications: Vec<Ratify<N>>, candidate_solutions: &Solutions<N>, candidate_transactions: impl ExactSizeIterator<Item = &'a Transaction<N>>, rng: &mut R, ) -> Result<(Ratifications<N>, Transactions<N>, Vec<N::TransactionID>, Vec<FinalizeOperation<N>>)>
Speculates on the given list of transactions in the VM. This function aborts all transactions that are not are well-formed or unique.
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 theratificationswill 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 theratificationslist.
Sourcepub fn check_speculate<R: Rng + CryptoRng>(
&self,
state: FinalizeGlobalState,
time_since_last_block: i64,
ratifications: &Ratifications<N>,
solutions: &Solutions<N>,
transactions: &Transactions<N>,
rng: &mut R,
) -> Result<Vec<FinalizeOperation<N>>>
pub fn check_speculate<R: Rng + CryptoRng>( &self, state: FinalizeGlobalState, time_since_last_block: i64, ratifications: &Ratifications<N>, solutions: &Solutions<N>, transactions: &Transactions<N>, rng: &mut R, ) -> Result<Vec<FinalizeOperation<N>>>
Checks the speculation on the given transactions in the VM. This function also ensure that the given transactions are well-formed and unique.
Returns the finalize operations from pre-ratify and post-ratify.
Sourcepub fn finalize(
&self,
state: FinalizeGlobalState,
ratifications: &Ratifications<N>,
solutions: &Solutions<N>,
transactions: &Transactions<N>,
) -> Result<Vec<FinalizeOperation<N>>>
pub fn finalize( &self, state: FinalizeGlobalState, ratifications: &Ratifications<N>, solutions: &Solutions<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 = 1_048_575usize
pub const MAXIMUM_CONFIRMED_TRANSACTIONS: usize = 1_048_575usize
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 const MAX_PARALLEL_DEPLOY_VERIFICATIONS: usize = 5usize
pub const MAX_PARALLEL_DEPLOY_VERIFICATIONS: usize = 5usize
The maximum number of deployments that the VM can verify in parallel.
Sourcepub const MAX_PARALLEL_EXECUTE_VERIFICATIONS: usize = 1_000usize
pub const MAX_PARALLEL_EXECUTE_VERIFICATIONS: usize = 1_000usize
The maximum number of executions to verify in parallel.
Sourcepub fn check_transactions<R: CryptoRng + Rng>(
&self,
transactions: &[(&Transaction<N>, Option<Field<N>>)],
rng: &mut R,
) -> Result<()>
pub fn check_transactions<R: CryptoRng + Rng>( &self, transactions: &[(&Transaction<N>, Option<Field<N>>)], rng: &mut R, ) -> Result<()>
Verifies the list of transactions 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 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.
Sourcepub fn partially_verified_transactions(
&self,
) -> Arc<RwLock<LruCache<(<N as Network>::TransactionID, Vec<U16<N>>), N::TransmissionChecksum>>> ⓘ
pub fn partially_verified_transactions( &self, ) -> Arc<RwLock<LruCache<(<N as Network>::TransactionID, Vec<U16<N>>), N::TransmissionChecksum>>> ⓘ
Returns the partially-verified transactions.
Sourcepub const fn restrictions(&self) -> &Restrictions<N>
pub const fn restrictions(&self) -> &Restrictions<N>
Returns the restrictions.
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 new_puzzle() -> Result<Puzzle<N>>
pub fn new_puzzle() -> Result<Puzzle<N>>
Returns a new instance of the puzzle.
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 with the default size (four validators).
Sourcepub fn genesis_beacon_with_size<R: Rng + CryptoRng>(
&self,
private_key: &PrivateKey<N>,
num_validators: usize,
rng: &mut R,
) -> Result<Block<N>>
pub fn genesis_beacon_with_size<R: Rng + CryptoRng>( &self, private_key: &PrivateKey<N>, num_validators: usize, 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>,
bonded_balances: IndexMap<Address<N>, (Address<N>, 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>, bonded_balances: IndexMap<Address<N>, (Address<N>, 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.
Trait Implementations§
Auto Trait Implementations§
impl<N, C> Freeze for VM<N, C>
impl<N, C> !RefUnwindSafe for VM<N, C>
impl<N, C> Send for VM<N, C>
impl<N, C> Sync for VM<N, C>
impl<N, C> Unpin for VM<N, C>where
C: Unpin,
N: Unpin,
<N as Environment>::Field: Unpin,
<N as Environment>::Projective: Unpin,
<N as Environment>::Scalar: Unpin,
impl<N, C> !UnwindSafe for VM<N, C>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more