Struct risc0_steel::CallBuilder
source · pub struct CallBuilder<S, E> { /* private fields */ }
Expand description
A builder for calling an Ethereum contract.
Once configured, call with CallBuilder::call.
Implementations§
source§impl<S, N, P, H, C> CallBuilder<S, &mut EvmEnv<ProofDb<ProviderDb<N, P>>, H, HostCommit<C>>>
impl<S, N, P, H, C> CallBuilder<S, &mut EvmEnv<ProofDb<ProviderDb<N, P>>, H, HostCommit<C>>>
sourcepub async fn prefetch_access_list(self, access_list: AccessList) -> Result<Self>
Available on crate feature host
only.
pub async fn prefetch_access_list(self, access_list: AccessList) -> Result<Self>
host
only.Fetches all the EIP-1186 storage proofs from the access_list
. This can help to
drastically reduce the number of RPC calls required during execution, as
eth_getStorageAt
calls are then only required for storage accesses not included in the
list. This does not set the access list as part of the transaction (as specified in
EIP-2930), and thus can only be specified during preflight on the host.
§Usage
This method is typically used when you have a pre-computed access list and want to
optimize preflight time. For automatic access list generation, consider using
CallBuilder::call_with_prefetch which combines this method with
eth_createAccessList
RPC.
§Example
let mut contract = Contract::preflight(contract_address, &mut env);
let result =
contract.call_builder(&call).prefetch_access_list(access_list).await?.call().await?;
sourcepub async fn call(self) -> Result<S::Return>
Available on crate feature host
only.
pub async fn call(self) -> Result<S::Return>
host
only.Executes the call using an EvmEnv constructed with Contract::preflight.
This uses [tokio::task::spawn_blocking] to run the blocking revm execution.
sourcepub async fn call_with_prefetch(self) -> Result<S::Return>
Available on crate feature host
only.
pub async fn call_with_prefetch(self) -> Result<S::Return>
host
only.Automatically prefetches the access list before executing the call using an EvmEnv constructed with Contract::preflight.
As the number of SLOAD
operations in a call grows, the preflight time
with Steel can become quite long due to the large number of RPC calls needed for
individual storage queries. This method uses eth_createAccessList
to greatly
reduce the number of RPC calls and improve pre-flight time.
§How it works
This method is equivalent to calling CallBuilder::prefetch_access_list with the
EIP-2930 access list as returned by the corresponding eth_createAccessList
RPC, followed by CallBuilder::call. The access list contains all storage slots
that would be accessed during the execution of the call, allowing them to be
fetched in a single RPC call.
§Trade-offs
- On certain node software, the underlying
eth_createAccessList
RPC actually checks to see if there are enough funds for the gas cost (in most cases, this can be fixed by using CallBuilder::from to set the caller to the deposit contract, e.g.0x00000000219ab540356cBB839Cbe05303d7705Fa
on mainnet. However, this is rather arbitrary and ugly). - This
eth_createAccessList
RPC is not available on all node software versions or chains.
§Example
let mut contract = Contract::preflight(contract_address, &mut env);
// This will automatically fetch the access list and execute the call
let result = contract.call_builder(&call).call_with_prefetch().await?;
source§impl<S, E> CallBuilder<S, E>
impl<S, E> CallBuilder<S, E>
source§impl<S, H> CallBuilder<S, &EvmEnv<StateDb, H, Commitment>>where
S: SolCall,
H: EvmBlockHeader,
impl<S, H> CallBuilder<S, &EvmEnv<StateDb, H, Commitment>>where
S: SolCall,
H: EvmBlockHeader,
sourcepub fn try_call(self) -> Result<S::Return, String>
pub fn try_call(self) -> Result<S::Return, String>
Executes the call and returns an error if the call fails.
In general, it’s recommended to use CallBuilder::call unless explicit error handling is required.
sourcepub fn call(self) -> S::Return
pub fn call(self) -> S::Return
Executes the call and panics on failure.
A convenience wrapper for CallBuilder::try_call, panicking if the call fails. Useful when success is expected.
Trait Implementations§
source§impl<S: Clone, E: Clone> Clone for CallBuilder<S, E>
impl<S: Clone, E: Clone> Clone for CallBuilder<S, E>
source§fn clone(&self) -> CallBuilder<S, E>
fn clone(&self) -> CallBuilder<S, E>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl<S, E> Freeze for CallBuilder<S, E>where
E: Freeze,
impl<S, E> RefUnwindSafe for CallBuilder<S, E>where
E: RefUnwindSafe,
S: RefUnwindSafe,
impl<S, E> Send for CallBuilder<S, E>
impl<S, E> Sync for CallBuilder<S, E>
impl<S, E> Unpin for CallBuilder<S, E>
impl<S, E> UnwindSafe for CallBuilder<S, E>where
E: UnwindSafe,
S: 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,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§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>
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§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> 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.