pub enum BrilligOpcode<F> {
Show 19 variants
BinaryFieldOp {
destination: MemoryAddress,
op: BinaryFieldOp,
lhs: MemoryAddress,
rhs: MemoryAddress,
},
BinaryIntOp {
destination: MemoryAddress,
op: BinaryIntOp,
bit_size: IntegerBitSize,
lhs: MemoryAddress,
rhs: MemoryAddress,
},
Not {
destination: MemoryAddress,
source: MemoryAddress,
bit_size: IntegerBitSize,
},
Cast {
destination: MemoryAddress,
source: MemoryAddress,
bit_size: BitSize,
},
JumpIf {
condition: MemoryAddress,
location: Label,
},
Jump {
location: Label,
},
CalldataCopy {
destination_address: MemoryAddress,
size_address: MemoryAddress,
offset_address: MemoryAddress,
},
Call {
location: Label,
},
Const {
destination: MemoryAddress,
bit_size: BitSize,
value: F,
},
IndirectConst {
destination_pointer: MemoryAddress,
bit_size: BitSize,
value: F,
},
Return,
ForeignCall {
function: String,
destinations: Vec<ValueOrArray>,
destination_value_types: Vec<HeapValueType>,
inputs: Vec<ValueOrArray>,
input_value_types: Vec<HeapValueType>,
},
Mov {
destination: MemoryAddress,
source: MemoryAddress,
},
ConditionalMov {
destination: MemoryAddress,
source_a: MemoryAddress,
source_b: MemoryAddress,
condition: MemoryAddress,
},
Load {
destination: MemoryAddress,
source_pointer: MemoryAddress,
},
Store {
destination_pointer: MemoryAddress,
source: MemoryAddress,
},
BlackBox(BlackBoxOp),
Trap {
revert_data: HeapVector,
},
Stop {
return_data: HeapVector,
},
}Variants§
BinaryFieldOp
Takes the fields in addresses lhs and rhs,
performs the specified binary operation,
and stores the value in the destination address.
BinaryIntOp
Takes the bit_size size integers in addresses lhs and rhs,
performs the specified binary operation,
and stores the value in the destination address.
Fields
destination: MemoryAddressop: BinaryIntOpbit_size: IntegerBitSizelhs: MemoryAddressrhs: MemoryAddressNot
Takes the value from the source address, inverts it,
and stores the value in the destination address.
Cast
Takes the value from the source address,
casts it into the type indicated by bit_size,
and stores the value in the destination address.
JumpIf
Sets the program counter to the value of location
if the value at condition is non-zero.
Jump
Sets the program counter to the value of location.
CalldataCopy
Copies calldata after the offset_address with length indicated by size_address
to the specified destination_address.
Call
Pushes the current program counter to the call stack as to set a return location.
Sets the program counter to the value of location.
We don’t support dynamic jumps or calls; see https://github.com/ethereum/aleth/issues/3404 for reasoning.
Const
Stores a constant value with a bit_size in the destination address.
IndirectConst
Reads the address from destination_pointer, then stores a constant value with a bit_size at that address.
Return
Pops the top element from the call stack, which represents the return location, and sets the program counter to that value. This operation is used to return from a function call.
ForeignCall
Used to get data from an outside source.
Also referred to as an Oracle, intended for things like state tree reads; it shouldn’t be confused with e.g. blockchain price oracles.
Fields
function: StringInterpreted by caller context, ie. this will have different meanings depending on who the caller is.
destinations: Vec<ValueOrArray>Destination addresses (may be single values or memory pointers).
Output vectors are passed as a ValueOrArray::MemoryAddress. Since their size is not known up front, we cannot allocate space for them on the heap. Instead, the VM is expected to write their data after the current free memory pointer, and store the heap address into the destination.
destination_value_types: Vec<HeapValueType>Destination value types.
inputs: Vec<ValueOrArray>Input addresses (may be single values or memory pointers).
input_value_types: Vec<HeapValueType>Input value types (for heap allocated structures indicates how to retrieve the elements).
Mov
Moves the content in the source address to the destination address.
ConditionalMov
If the value at condition is non-zero, moves the content in the source_a
address to the destination address, otherwise moves the content from the
source_b address instead.
destination = condition > 0 ? source_a : source_b
Fields
destination: MemoryAddresssource_a: MemoryAddresssource_b: MemoryAddresscondition: MemoryAddressLoad
Reads the source_pointer to obtain a memory address, then retrieves the data
stored at that address and writes it to the destination address.
Store
Reads the destination_pointer to obtain a memory address, then stores the value
from the source address at that location.
BlackBox(BlackBoxOp)
Native functions in the VM. These are equivalent to the black box functions in ACIR.
Trap
Used to denote execution failure, halting the VM and returning data specified by a dynamically-sized vector.
Fields
revert_data: HeapVectorStop
Halts execution and returns data specified by a dynamically-sized vector.
Fields
return_data: HeapVectorTrait Implementations§
Source§impl<F: Clone> Clone for BrilligOpcode<F>
impl<F: Clone> Clone for BrilligOpcode<F>
Source§fn clone(&self) -> BrilligOpcode<F>
fn clone(&self) -> BrilligOpcode<F>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<F: Debug> Debug for BrilligOpcode<F>
impl<F: Debug> Debug for BrilligOpcode<F>
Source§impl<'de, F> Deserialize<'de> for BrilligOpcode<F>where
F: Deserialize<'de>,
impl<'de, F> Deserialize<'de> for BrilligOpcode<F>where
F: Deserialize<'de>,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl<F: Display> Display for BrilligOpcode<F>
impl<F: Display> Display for BrilligOpcode<F>
Source§impl<F: Hash> Hash for BrilligOpcode<F>
impl<F: Hash> Hash for BrilligOpcode<F>
Source§impl<F: PartialEq> PartialEq for BrilligOpcode<F>
impl<F: PartialEq> PartialEq for BrilligOpcode<F>
Source§impl<F> Serialize for BrilligOpcode<F>where
F: Serialize,
impl<F> Serialize for BrilligOpcode<F>where
F: Serialize,
impl<F: Eq> Eq for BrilligOpcode<F>
impl<F> StructuralPartialEq for BrilligOpcode<F>
Auto Trait Implementations§
impl<F> Freeze for BrilligOpcode<F>where
F: Freeze,
impl<F> RefUnwindSafe for BrilligOpcode<F>where
F: RefUnwindSafe,
impl<F> Send for BrilligOpcode<F>where
F: Send,
impl<F> Sync for BrilligOpcode<F>where
F: Sync,
impl<F> Unpin for BrilligOpcode<F>where
F: Unpin,
impl<F> UnwindSafe for BrilligOpcode<F>where
F: UnwindSafe,
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,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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