pub struct CircuitInputBuilder<C: CircuitsParams> {
pub sdb: StateDB,
pub code_db: CodeDB,
pub block: Block,
pub chunks: Vec<Chunk>,
pub block_ctx: BlockContext,
pub chunk_ctx: ChunkContext,
pub circuits_params: C,
pub feature_config: FeatureConfig,
}
Expand description
Builder to generate a complete circuit input from data gathered from a geth
instance. This structure is the centre of the crate and is intended to be
the only entry point to it. The CircuitInputBuilder
works in several
steps:
- Take a [
eth_types::Block
] to build the circuit input associated with the block. 2. For each [eth_types::Transaction
] in the block, take theeth_types::GethExecTrace
to build the circuit input associated with each transaction, and the bus-mapping operations associated with each [eth_types::GethExecStep
] in theeth_types::GethExecTrace
. 3. IfRw
s generated during Transactions exceed themax_rws
threshold, separate witness into multiple chunks.
The generated bus-mapping operations are:
StackOp
s,
MemoryOp
s and
StorageOp
, which correspond to each
OpcodeId
s used in each ExecTrace
step so that
the State Proof witnesses are already generated on a structured manner and
ready to be added into the State circuit.
Fields§
§sdb: StateDB
StateDB key-value DB
code_db: CodeDB
Map of account codes by code hash
block: Block
Block
chunks: Vec<Chunk>
Chunk
block_ctx: BlockContext
Block Context
chunk_ctx: ChunkContext
Chunk Context
circuits_params: C
Circuits Setup Parameters before chunking
feature_config: FeatureConfig
Feature config
Implementations§
source§impl<'a, C: CircuitsParams> CircuitInputBuilder<C>
impl<'a, C: CircuitsParams> CircuitInputBuilder<C>
sourcepub fn new(
sdb: StateDB,
code_db: CodeDB,
block: Block,
params: C,
feature_config: FeatureConfig
) -> Self
pub fn new( sdb: StateDB, code_db: CodeDB, block: Block, params: C, feature_config: FeatureConfig ) -> Self
Create a new CircuitInputBuilder from the given eth_block
and
constants
.
sourcepub fn set_total_chunk(&mut self, total_chunks: usize)
pub fn set_total_chunk(&mut self, total_chunks: usize)
Set the total number of chunks for existing CircuitInputBuilder, API for chunking the existing tests then run with a specific chunk
sourcepub fn state_ref(
&'a mut self,
tx: &'a mut Transaction,
tx_ctx: &'a mut TransactionContext
) -> CircuitInputStateRef<'_>
pub fn state_ref( &'a mut self, tx: &'a mut Transaction, tx_ctx: &'a mut TransactionContext ) -> CircuitInputStateRef<'_>
Obtain a mutable reference to the state that the CircuitInputBuilder
maintains, contextualized to a particular transaction and a
particular execution step in that transaction.
sourcepub fn new_tx(
&mut self,
id: u64,
eth_tx: &Transaction,
is_success: bool
) -> Result<Transaction, Error>
pub fn new_tx( &mut self, id: u64, eth_tx: &Transaction, is_success: bool ) -> Result<Transaction, Error>
Create a new Transaction from a [eth_types::Transaction
].
sourcepub fn set_value_ops_call_context_rwc_eor(&mut self)
pub fn set_value_ops_call_context_rwc_eor(&mut self)
Iterate over all generated CallContext RwCounterEndOfReversion
operations and set the correct value. This is required because when we
generate the RwCounterEndOfReversion operation in
gen_associated_ops
we don’t know yet which value it will take,
so we put a placeholder; so we do it here after the values are known.
sourcepub fn commit_chunk_ctx(
&mut self,
to_next: bool,
next_tx_index: usize,
next_copy_index: usize,
last_call: Option<Call>
)
pub fn commit_chunk_ctx( &mut self, to_next: bool, next_tx_index: usize, next_copy_index: usize, last_call: Option<Call> )
Set the end status of a chunk including the current globle rwc and commit the current chunk context, proceed to the next chunk if needed
sourcepub fn get_chunk_mut(&mut self, i: usize) -> &mut Chunk
pub fn get_chunk_mut(&mut self, i: usize) -> &mut Chunk
Get the i-th mutable chunk
sourcepub fn cur_chunk_mut(&mut self) -> &mut Chunk
pub fn cur_chunk_mut(&mut self) -> &mut Chunk
Get a mutable reference of current chunk
sourcepub fn prev_chunk(&self) -> Option<Chunk>
pub fn prev_chunk(&self) -> Option<Chunk>
Get the previous chunk
source§impl CircuitInputBuilder<FixedCParams>
impl CircuitInputBuilder<FixedCParams>
sourcepub fn begin_handle_block(
&mut self,
eth_block: &Block<Transaction>,
geth_traces: &[GethExecTrace]
) -> Result<(Option<ExecStep>, Option<Call>), Error>
pub fn begin_handle_block( &mut self, eth_block: &Block<Transaction>, geth_traces: &[GethExecTrace] ) -> Result<(Option<ExecStep>, Option<Call>), Error>
First part of handle_block, only called by fixed Builder
sourcepub fn handle_block(
self,
eth_block: &Block<Transaction>,
geth_traces: &[GethExecTrace]
) -> Result<CircuitInputBuilder<FixedCParams>, Error>
pub fn handle_block( self, eth_block: &Block<Transaction>, geth_traces: &[GethExecTrace] ) -> Result<CircuitInputBuilder<FixedCParams>, Error>
Handle a block by handling each transaction to generate all the associated operations.
source§impl<C: CircuitsParams> CircuitInputBuilder<C>
impl<C: CircuitsParams> CircuitInputBuilder<C>
sourcepub fn last_exec_step_rws_reserved(&self) -> usize
pub fn last_exec_step_rws_reserved(&self) -> usize
return the rw row reserved for end_block/end_chunk
source§impl CircuitInputBuilder<DynamicCParams>
impl CircuitInputBuilder<DynamicCParams>
sourcepub fn handle_block(
self,
eth_block: &Block<Transaction>,
geth_traces: &[GethExecTrace]
) -> Result<CircuitInputBuilder<FixedCParams>, Error>
pub fn handle_block( self, eth_block: &Block<Transaction>, geth_traces: &[GethExecTrace] ) -> Result<CircuitInputBuilder<FixedCParams>, Error>
Handle a block by handling each transaction to generate all the
associated operations. Dry run the block to determined the target
FixedCParams
from to total number of chunks.
Trait Implementations§
source§impl<C: Clone + CircuitsParams> Clone for CircuitInputBuilder<C>
impl<C: Clone + CircuitsParams> Clone for CircuitInputBuilder<C>
source§fn clone(&self) -> CircuitInputBuilder<C>
fn clone(&self) -> CircuitInputBuilder<C>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl<C> RefUnwindSafe for CircuitInputBuilder<C>where
C: RefUnwindSafe,
impl<C> Send for CircuitInputBuilder<C>where
C: Send,
impl<C> Sync for CircuitInputBuilder<C>where
C: Sync,
impl<C> Unpin for CircuitInputBuilder<C>where
C: Unpin,
impl<C> UnwindSafe for CircuitInputBuilder<C>where
C: 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
§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.