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>

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>( &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 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( &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.

source

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>

source

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>

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§

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 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>, 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> !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,

§

impl<N, C> !UnwindSafe for VM<N, C>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. 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 Twhere 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.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

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

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.
§

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

§

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