pub struct CircuitInputStateRef<'a> {
pub sdb: &'a mut StateDB,
pub code_db: &'a mut CodeDB,
pub block: &'a mut Block,
pub block_ctx: &'a mut BlockContext,
pub chunk_ctx: &'a mut ChunkContext,
pub tx: &'a mut Transaction,
pub tx_ctx: &'a mut TransactionContext,
pub max_rws: Option<usize>,
}
Expand description
Reference to the internal state of the CircuitInputBuilder in a particular
ExecStep
.
Fields§
§sdb: &'a mut StateDB
StateDB
code_db: &'a mut CodeDB
CodeDB
block: &'a mut Block
Block
block_ctx: &'a mut BlockContext
Block Context
chunk_ctx: &'a mut ChunkContext
Chunk Context
tx: &'a mut Transaction
Transaction
tx_ctx: &'a mut TransactionContext
Transaction Context
max_rws: Option<usize>
Max rw number limit
Implementations§
source§impl<'a> CircuitInputStateRef<'a>
impl<'a> CircuitInputStateRef<'a>
sourcepub fn new_step(&self, geth_step: &GethExecStep) -> Result<ExecStep, Error>
pub fn new_step(&self, geth_step: &GethExecStep) -> Result<ExecStep, Error>
Create a new step from a GethExecStep
sourcepub fn new_invalid_tx_step(&self) -> ExecStep
pub fn new_invalid_tx_step(&self) -> ExecStep
Create a new InvalidTx step
sourcepub fn new_begin_tx_step(&self) -> ExecStep
pub fn new_begin_tx_step(&self) -> ExecStep
Create a new BeginTx step
sourcepub fn new_end_tx_step(&self) -> ExecStep
pub fn new_end_tx_step(&self) -> ExecStep
Create a new EndTx step
sourcepub fn push_op<T: Op>(
&mut self,
step: &mut ExecStep,
rw: RW,
op: T
) -> Result<(), Error>
pub fn push_op<T: Op>( &mut self, step: &mut ExecStep, rw: RW, op: T ) -> Result<(), Error>
Push an Operation
into the
OperationContainer
with the
next RWCounter
and then adds a
reference to the stored operation (OperationRef
) inside the
bus-mapping instance of the current ExecStep
. Then increase the
block_ctx RWCounter
by one.
sourcepub fn check_rw_num_limit(&self) -> Result<(), Error>
pub fn check_rw_num_limit(&self) -> Result<(), Error>
Check whether rws will overflow circuit limit.
sourcepub fn call_context_read(
&mut self,
step: &mut ExecStep,
call_id: usize,
field: CallContextField,
value: Word
) -> Result<(), Error>
pub fn call_context_read( &mut self, step: &mut ExecStep, call_id: usize, field: CallContextField, value: Word ) -> Result<(), Error>
Push a read type CallContextOp
into the
OperationContainer
with
the next RWCounter
and then adds a
reference to the stored operation (OperationRef
) inside the
bus-mapping instance of the current ExecStep
. Then increase the
block_ctx RWCounter
by one.
sourcepub fn call_context_write(
&mut self,
step: &mut ExecStep,
call_id: usize,
field: CallContextField,
value: Word
) -> Result<(), Error>
pub fn call_context_write( &mut self, step: &mut ExecStep, call_id: usize, field: CallContextField, value: Word ) -> Result<(), Error>
Push a write type CallContextOp
into the
OperationContainer
with
the next RWCounter
and then adds a
reference to the stored operation (OperationRef
) inside the
bus-mapping instance of the current ExecStep
. Then increase the
block_ctx RWCounter
by one.
sourcepub fn push_op_reversible<T: Op>(
&mut self,
step: &mut ExecStep,
op: T
) -> Result<(), Error>
pub fn push_op_reversible<T: Op>( &mut self, step: &mut ExecStep, op: T ) -> Result<(), Error>
Push an Operation
with reversible to be true into the
OperationContainer
with the
next RWCounter
and then adds a
reference to the stored operation
(OperationRef
) inside the
bus-mapping instance of the current ExecStep
. Then increase the
block_ctx RWCounter
by one.
This method should be used in Opcode::gen_associated_ops
instead of
push_op
when the operation is RW::WRITE
and it can be reverted (for
example, a write StorageOp
).
sourcepub fn memory_read(
&mut self,
step: &mut ExecStep,
address: MemoryAddress
) -> Result<u8, Error>
pub fn memory_read( &mut self, step: &mut ExecStep, address: MemoryAddress ) -> Result<u8, Error>
Push a read type MemoryOp
into the
OperationContainer
with the
next RWCounter
and call_id
, and then
adds a reference to the stored operation (OperationRef
) inside
the bus-mapping instance of the current ExecStep
. Then increase
the block_ctx
RWCounter
by one.
sourcepub fn memory_read_caller(
&mut self,
step: &mut ExecStep,
address: MemoryAddress
) -> Result<u8, Error>
pub fn memory_read_caller( &mut self, step: &mut ExecStep, address: MemoryAddress ) -> Result<u8, Error>
Almost the same as above memory_read, but read from the caller’s context instead.
sourcepub fn memory_write(
&mut self,
step: &mut ExecStep,
address: MemoryAddress,
value: u8
) -> Result<u8, Error>
pub fn memory_write( &mut self, step: &mut ExecStep, address: MemoryAddress, value: u8 ) -> Result<u8, Error>
Push a write type MemoryOp
into the
OperationContainer
with the
next RWCounter
and call_id
, and then
adds a reference to the stored operation (OperationRef
) inside
the bus-mapping instance of the current ExecStep
. Then increase
the block_ctx
RWCounter
by one.
sourcepub fn memory_write_caller(
&mut self,
step: &mut ExecStep,
address: MemoryAddress,
value: u8
) -> Result<u8, Error>
pub fn memory_write_caller( &mut self, step: &mut ExecStep, address: MemoryAddress, value: u8 ) -> Result<u8, Error>
Almost the same as above memory_write, but write to the caller’s context instead.
sourcepub fn stack_write(
&mut self,
step: &mut ExecStep,
address: StackAddress,
value: Word
) -> Result<(), Error>
pub fn stack_write( &mut self, step: &mut ExecStep, address: StackAddress, value: Word ) -> Result<(), Error>
Push a write type StackOp
into the
OperationContainer
with the
next RWCounter
and call_id
, and then
adds a reference to the stored operation (OperationRef
) inside
the bus-mapping instance of the current ExecStep
. Then increase
the block_ctx
RWCounter
by one.
sourcepub fn stack_read(
&mut self,
step: &mut ExecStep,
address: StackAddress,
value: Word
) -> Result<(), Error>
pub fn stack_read( &mut self, step: &mut ExecStep, address: StackAddress, value: Word ) -> Result<(), Error>
Push a read type StackOp
into the
OperationContainer
with the
next RWCounter
and call_id
, and then
adds a reference to the stored operation (OperationRef
) inside
the bus-mapping instance of the current ExecStep
. Then increase
the block_ctx
RWCounter
by one.
sourcepub fn account_read(
&mut self,
step: &mut ExecStep,
address: Address,
field: AccountField,
value: Word
) -> Result<(), Error>
pub fn account_read( &mut self, step: &mut ExecStep, address: Address, field: AccountField, value: Word ) -> Result<(), Error>
Push a read type AccountOp
into the
OperationContainer
with the
next RWCounter
, and then
adds a reference to the stored operation (OperationRef
) inside
the bus-mapping instance of the current ExecStep
. Then increase
the block_ctx
RWCounter
by one.
sourcepub fn account_write(
&mut self,
step: &mut ExecStep,
address: Address,
field: AccountField,
value: Word,
value_prev: Word,
reversible: bool
) -> Result<(), Error>
pub fn account_write( &mut self, step: &mut ExecStep, address: Address, field: AccountField, value: Word, value_prev: Word, reversible: bool ) -> Result<(), Error>
Push a write type AccountOp
into the
OperationContainer
with the
next RWCounter
, and then
adds a reference to the stored operation (OperationRef
) inside
the bus-mapping instance of the current ExecStep
. Then increase
the block_ctx
RWCounter
by one.
sourcepub fn tx_log_write(
&mut self,
step: &mut ExecStep,
tx_id: usize,
log_id: usize,
field: TxLogField,
index: usize,
value: Word
) -> Result<(), Error>
pub fn tx_log_write( &mut self, step: &mut ExecStep, tx_id: usize, log_id: usize, field: TxLogField, index: usize, value: Word ) -> Result<(), Error>
Push a write type TxLogOp
into the
OperationContainer
with the
next RWCounter
, and then
adds a reference to the stored operation (OperationRef
) inside
the bus-mapping instance of the current ExecStep
. Then increase
the block_ctx
RWCounter
by one.
sourcepub fn tx_receipt_read(
&mut self,
step: &mut ExecStep,
tx_id: usize,
field: TxReceiptField,
value: u64
) -> Result<(), Error>
pub fn tx_receipt_read( &mut self, step: &mut ExecStep, tx_id: usize, field: TxReceiptField, value: u64 ) -> Result<(), Error>
Push a read type TxReceiptOp
into the
OperationContainer
with the
next RWCounter
, and then
adds a reference to the stored operation (OperationRef
) inside
the bus-mapping instance of the current ExecStep
. Then increase
the block_ctx
RWCounter
by one.
sourcepub fn tx_receipt_write(
&mut self,
step: &mut ExecStep,
tx_id: usize,
field: TxReceiptField,
value: u64
) -> Result<(), Error>
pub fn tx_receipt_write( &mut self, step: &mut ExecStep, tx_id: usize, field: TxReceiptField, value: u64 ) -> Result<(), Error>
Push a write type TxReceiptOp
into the
OperationContainer
with the
next RWCounter
, and then
adds a reference to the stored operation (OperationRef
) inside
the bus-mapping instance of the current ExecStep
. Then increase
the block_ctx
RWCounter
by one.
sourcepub fn tx_accesslist_account_write(
&mut self,
step: &mut ExecStep,
tx_id: usize,
address: Address,
is_warm: bool,
is_warm_prev: bool
) -> Result<(), Error>
pub fn tx_accesslist_account_write( &mut self, step: &mut ExecStep, tx_id: usize, address: Address, is_warm: bool, is_warm_prev: bool ) -> Result<(), Error>
Push a write type TxAccessListAccountOp
into the
OperationContainer
with the
next RWCounter
, and then
adds a reference to the stored operation (OperationRef
) inside
the bus-mapping instance of the current ExecStep
. Then increase
the block_ctx
RWCounter
by one.
sourcepub fn tx_access_list_write(
&mut self,
step: &mut ExecStep,
address: Address
) -> Result<(), Error>
pub fn tx_access_list_write( &mut self, step: &mut ExecStep, address: Address ) -> Result<(), Error>
Add address to access list for the current transaction.
sourcepub fn transfer(
&mut self,
step: &mut ExecStep,
sender: Address,
receiver: Address,
receiver_exists: bool,
is_create: bool,
value: Word,
fee: Option<Word>
) -> Result<(), Error>
pub fn transfer( &mut self, step: &mut ExecStep, sender: Address, receiver: Address, receiver_exists: bool, is_create: bool, value: Word, fee: Option<Word> ) -> Result<(), Error>
sourcepub fn transfer_to(
&mut self,
step: &mut ExecStep,
receiver: Address,
receiver_exists: bool,
is_create: bool,
value: Word,
reversible: bool
) -> Result<(), Error>
pub fn transfer_to( &mut self, step: &mut ExecStep, receiver: Address, receiver_exists: bool, is_create: bool, value: Word, reversible: bool ) -> Result<(), Error>
Transfer to an address. Create an account if it is not existed before.
sourcepub fn code(&self, code_hash: H256) -> Result<Vec<u8>, Error>
pub fn code(&self, code_hash: H256) -> Result<Vec<u8>, Error>
Fetch and return code for the given code hash from the code DB.
sourcepub fn caller_mut(&mut self) -> Result<&mut Call, Error>
pub fn caller_mut(&mut self) -> Result<&mut Call, Error>
Mutable reference to the current call’s caller Call
sourcepub fn caller_ctx(&self) -> Result<&CallContext, Error>
pub fn caller_ctx(&self) -> Result<&CallContext, Error>
Reference to the current CallContext
sourcepub fn call_ctx(&self) -> Result<&CallContext, Error>
pub fn call_ctx(&self) -> Result<&CallContext, Error>
Reference to the current CallContext
sourcepub fn call_ctx_mut(&mut self) -> Result<&mut CallContext, Error>
pub fn call_ctx_mut(&mut self) -> Result<&mut CallContext, Error>
Mutable reference to the call CallContext
sourcepub fn caller_ctx_mut(&mut self) -> Result<&mut CallContext, Error>
pub fn caller_ctx_mut(&mut self) -> Result<&mut CallContext, Error>
Mutable reference to the caller CallContext
sourcepub fn push_call(&mut self, call: Call)
pub fn push_call(&mut self, call: Call)
Push a new Call
into the Transaction
, and add its index and
CallContext
in the call_stack
of the TransactionContext
sourcepub fn is_precompiled(&self, address: &Address) -> bool
pub fn is_precompiled(&self, address: &Address) -> bool
Check if address is a precompiled or not.
sourcepub fn parse_call(&mut self, step: &GethExecStep) -> Result<Call, Error>
pub fn parse_call(&mut self, step: &GethExecStep) -> Result<Call, Error>
Parse Call
from a CALL/CREATE* step.
sourcepub fn handle_reversion(&mut self, current_exec_steps: &mut [&mut ExecStep])
pub fn handle_reversion(&mut self, current_exec_steps: &mut [&mut ExecStep])
Handle a reversion group
sourcepub fn handle_return(
&mut self,
current_exec_steps: &mut [&mut ExecStep],
geth_steps: &[GethExecStep],
need_restore: bool
) -> Result<(), Error>
pub fn handle_return( &mut self, current_exec_steps: &mut [&mut ExecStep], geth_steps: &[GethExecStep], need_restore: bool ) -> Result<(), Error>
Handle a restore and a return step caused by any opcode that causes a return to the previous call context.
sourcepub fn handle_restore_context(
&mut self,
exec_step: &mut ExecStep,
steps: &[GethExecStep]
) -> Result<(), Error>
pub fn handle_restore_context( &mut self, exec_step: &mut ExecStep, steps: &[GethExecStep] ) -> Result<(), Error>
Bus mapping for the RestoreContextGadget as used in RETURN.
sourcepub fn push_copy(&mut self, step: &mut ExecStep, event: CopyEvent)
pub fn push_copy(&mut self, step: &mut ExecStep, event: CopyEvent)
Push a copy event to the state.
sourcepub fn push_exponentiation(&mut self, event: ExpEvent)
pub fn push_exponentiation(&mut self, event: ExpEvent)
Push a exponentiation event to the state.
sourcepub fn push_precompile_event(&mut self, event: PrecompileEvent)
pub fn push_precompile_event(&mut self, event: PrecompileEvent)
Push an event representing auxiliary data for a precompile call to the state.
Auto Trait Implementations§
impl<'a> RefUnwindSafe for CircuitInputStateRef<'a>
impl<'a> Send for CircuitInputStateRef<'a>
impl<'a> Sync for CircuitInputStateRef<'a>
impl<'a> Unpin for CircuitInputStateRef<'a>
impl<'a> !UnwindSafe for CircuitInputStateRef<'a>
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
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.