snarkvm_synthesizer::vm

Struct VM

Source
pub struct VM<N: Network, C: ConsensusStorage<N>> { /* private fields */ }

Implementations§

Source§

impl<N: Network, C: ConsensusStorage<N>> VM<N, C>

Source

pub fn authorize<R: Rng + CryptoRng>( &self, private_key: &PrivateKey<N>, program_id: impl TryInto<ProgramID<N>>, function_name: impl TryInto<Identifier<N>>, inputs: impl IntoIterator<IntoIter = impl ExactSizeIterator<Item = impl TryInto<Value<N>>>>, rng: &mut R, ) -> Result<Authorization<N>>

Authorizes a call to the program function for the given inputs.

Source

pub fn authorize_fee_private<R: Rng + CryptoRng>( &self, private_key: &PrivateKey<N>, credits: Record<N, Plaintext<N>>, base_fee_in_microcredits: u64, priority_fee_in_microcredits: u64, deployment_or_execution_id: Field<N>, rng: &mut R, ) -> Result<Authorization<N>>

Authorizes the fee given the credits record, the fee amount (in microcredits), and the deployment or execution ID.

Source

pub fn authorize_fee_public<R: Rng + CryptoRng>( &self, private_key: &PrivateKey<N>, base_fee_in_microcredits: u64, priority_fee_in_microcredits: u64, deployment_or_execution_id: Field<N>, rng: &mut R, ) -> Result<Authorization<N>>

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>

Source

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>

Source

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.

Source

pub fn execute_authorization<R: Rng + CryptoRng>( &self, execute_authorization: Authorization<N>, fee_authorization: Option<Authorization<N>>, query: Option<Query<N, C::BlockStorage>>, rng: &mut R, ) -> Result<Transaction<N>>

Returns a new execute transaction for the given authorization.

Source

pub fn execute_fee_authorization<R: Rng + CryptoRng>( &self, authorization: Authorization<N>, query: Option<Query<N, C::BlockStorage>>, rng: &mut R, ) -> Result<Fee<N>>

Returns a new fee for the given authorization.

Source§

impl<N: Network, C: ConsensusStorage<N>> VM<N, C>

Source

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 the ratifications will not be modified.
  • If coinbase_reward = Some(coinbase_reward), then the method will append a Ratify::BlockReward(block_reward) and Ratify::PuzzleReward(puzzle_reward) to the front of the ratifications list.
Source

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.

Source

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>

Source

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>

Source

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>

Source

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

pub fn check_fee( &self, transaction: &Transaction<N>, rejected_id: Option<Field<N>>, ) -> Result<()>

Verifies the fee in the given transaction. On failure, returns an error.

Source§

impl<N: Network, C: ConsensusStorage<N>> VM<N, C>

Source

pub fn from(store: ConsensusStore<N, C>) -> Result<Self>

Initializes the VM from storage.

Source

pub fn contains_program(&self, program_id: &ProgramID<N>) -> bool

Returns true if a program with the given program ID exists.

Source

pub fn process(&self) -> Arc<RwLock<Process<N>>>

Returns the process.

Source

pub const fn puzzle(&self) -> &Puzzle<N>

Returns the puzzle.

Source

pub fn partially_verified_transactions( &self, ) -> Arc<RwLock<LruCache<N::TransactionID, N::TransmissionChecksum>>>

Returns the partially-verified transactions.

Source

pub const fn restrictions(&self) -> &Restrictions<N>

Returns the restrictions.

Source§

impl<N: Network, C: ConsensusStorage<N>> VM<N, C>

Source

pub fn finalize_store(&self) -> &FinalizeStore<N, C::FinalizeStorage>

Returns the finalize store.

Source

pub fn block_store(&self) -> &BlockStore<N, C::BlockStorage>

Returns the block store.

Source

pub fn transaction_store(&self) -> &TransactionStore<N, C::TransactionStorage>

Returns the transaction store.

Source

pub fn transition_store(&self) -> &TransitionStore<N, C::TransitionStorage>

Returns the transition store.

Source§

impl<N: Network, C: ConsensusStorage<N>> VM<N, C>

Source

pub fn new_puzzle() -> Result<Puzzle<N>>

Returns a new instance of the puzzle.

Source§

impl<N: Network, C: ConsensusStorage<N>> VM<N, C>

Source

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.

Source

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.

Source

pub fn add_next_block(&self, block: &Block<N>) -> Result<()>

Adds the given block into the VM.

Trait Implementations§

Source§

impl<N: Clone + Network, C: Clone + ConsensusStorage<N>> Clone for VM<N, C>

Source§

fn clone(&self) -> VM<N, C>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl<N, C> Freeze for VM<N, C>
where C: Freeze, <N as Environment>::Field: Freeze,

§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T