pub struct TransactionScriptsVerifier<DL: CellDataProvider, V = DebugPrinter, M: DefaultMachineRunner = Machine> { /* private fields */ }Expand description
This struct leverages CKB VM to verify transaction inputs.
Implementations§
Source§impl<DL> TransactionScriptsVerifier<DL>
impl<DL> TransactionScriptsVerifier<DL>
Sourcepub fn new(
rtx: Arc<ResolvedTransaction>,
data_loader: DL,
consensus: Arc<Consensus>,
tx_env: Arc<TxVerifyEnv>,
) -> Self
pub fn new( rtx: Arc<ResolvedTransaction>, data_loader: DL, consensus: Arc<Consensus>, tx_env: Arc<TxVerifyEnv>, ) -> Self
Create a script verifier using default CKB syscalls and a default debug printer
Sourcepub fn new_with_debug_printer(
rtx: Arc<ResolvedTransaction>,
data_loader: DL,
consensus: Arc<Consensus>,
tx_env: Arc<TxVerifyEnv>,
debug_printer: DebugPrinter,
) -> Self
pub fn new_with_debug_printer( rtx: Arc<ResolvedTransaction>, data_loader: DL, consensus: Arc<Consensus>, tx_env: Arc<TxVerifyEnv>, debug_printer: DebugPrinter, ) -> Self
Create a script verifier using default CKB syscalls and a custom debug printer
Source§impl<DL, V, M> TransactionScriptsVerifier<DL, V, M>where
DL: CellDataProvider + HeaderProvider + ExtensionProvider + Clone,
V: Clone,
M: DefaultMachineRunner,
impl<DL, V, M> TransactionScriptsVerifier<DL, V, M>where
DL: CellDataProvider + HeaderProvider + ExtensionProvider + Clone,
V: Clone,
M: DefaultMachineRunner,
Sourcepub fn new_with_generator(
rtx: Arc<ResolvedTransaction>,
data_loader: DL,
consensus: Arc<Consensus>,
tx_env: Arc<TxVerifyEnv>,
syscall_generator: SyscallGenerator<DL, V, <M as DefaultMachineRunner>::Inner>,
syscall_context: V,
) -> TransactionScriptsVerifier<DL, V, M>
pub fn new_with_generator( rtx: Arc<ResolvedTransaction>, data_loader: DL, consensus: Arc<Consensus>, tx_env: Arc<TxVerifyEnv>, syscall_generator: SyscallGenerator<DL, V, <M as DefaultMachineRunner>::Inner>, syscall_context: V, ) -> TransactionScriptsVerifier<DL, V, M>
Creates a script verifier for the transaction.
§Params
rtx- transaction which cell out points have been resolved.data_loader- used to load cell data.consensus- consensus parameters.tx_env- environment for verifying transaction, such as committed block, etc.syscall_generator- a syscall generator for current verifiersyscall_context- context for syscall generator
Sourcepub fn extract_script(&self, script: &Script) -> Result<Bytes, ScriptError>
pub fn extract_script(&self, script: &Script) -> Result<Bytes, ScriptError>
Extracts actual script binary either in dep cells.
Sourcepub fn select_version(
&self,
script: &Script,
) -> Result<ScriptVersion, ScriptError>
pub fn select_version( &self, script: &Script, ) -> Result<ScriptVersion, ScriptError>
Returns the version of the machine based on the script and the consensus rules.
Sourcepub fn groups(&self) -> impl Iterator<Item = (&Byte32, &ScriptGroup)>
pub fn groups(&self) -> impl Iterator<Item = (&Byte32, &ScriptGroup)>
Returns all script groups.
Sourcepub fn groups_with_type(
&self,
) -> impl Iterator<Item = (ScriptGroupType, &Byte32, &ScriptGroup)>
pub fn groups_with_type( &self, ) -> impl Iterator<Item = (ScriptGroupType, &Byte32, &ScriptGroup)>
Returns all script groups with type.
Sourcepub fn find_script_group(
&self,
script_group_type: ScriptGroupType,
script_hash: &Byte32,
) -> Option<&ScriptGroup>
pub fn find_script_group( &self, script_group_type: ScriptGroupType, script_hash: &Byte32, ) -> Option<&ScriptGroup>
Finds the script group from cell deps.
Sourcepub fn verify_single(
&self,
script_group_type: ScriptGroupType,
script_hash: &Byte32,
max_cycles: Cycle,
) -> Result<Cycle, ScriptError>
pub fn verify_single( &self, script_group_type: ScriptGroupType, script_hash: &Byte32, max_cycles: Cycle, ) -> Result<Cycle, ScriptError>
Runs a single script in current transaction, while this is not useful for CKB itself, it can be very helpful when building a CKB debugger.
Sourcepub fn create_scheduler(
&self,
script_group: &ScriptGroup,
) -> Result<Scheduler<DL, V, M>, ScriptError>
pub fn create_scheduler( &self, script_group: &ScriptGroup, ) -> Result<Scheduler<DL, V, M>, ScriptError>
Create a scheduler to manage virtual machine instances.
Sourcepub fn detailed_run(
&self,
script_group: &ScriptGroup,
max_cycles: Cycle,
) -> Result<TerminatedResult, ScriptError>
pub fn detailed_run( &self, script_group: &ScriptGroup, max_cycles: Cycle, ) -> Result<TerminatedResult, ScriptError>
Runs a single program, then returns the exit code together with the entire machine to the caller for more inspections.
Source§impl<DL, V, M> TransactionScriptsVerifier<DL, V, M>where
DL: CellDataProvider + HeaderProvider + ExtensionProvider + Send + Sync + Clone + 'static,
V: Send + Clone + 'static,
M: DefaultMachineRunner + Send + 'static,
impl<DL, V, M> TransactionScriptsVerifier<DL, V, M>where
DL: CellDataProvider + HeaderProvider + ExtensionProvider + Send + Sync + Clone + 'static,
V: Send + Clone + 'static,
M: DefaultMachineRunner + Send + 'static,
Sourcepub async fn resumable_verify_with_signal(
&self,
limit_cycles: Cycle,
command_rx: &mut Receiver<ChunkCommand>,
) -> Result<Cycle, Error>
pub async fn resumable_verify_with_signal( &self, limit_cycles: Cycle, command_rx: &mut Receiver<ChunkCommand>, ) -> Result<Cycle, Error>
Performing a resumable verification on the transaction scripts with signal channel,
if Suspend comes from command_rx, the process will be hang up until Resume comes,
otherwise, it will return until the verification is completed.
Auto Trait Implementations§
impl<DL, V, M> Freeze for TransactionScriptsVerifier<DL, V, M>where
V: Freeze,
impl<DL, V, M> RefUnwindSafe for TransactionScriptsVerifier<DL, V, M>where
V: RefUnwindSafe,
DL: RefUnwindSafe,
impl<DL, V, M> Send for TransactionScriptsVerifier<DL, V, M>
impl<DL, V, M> Sync for TransactionScriptsVerifier<DL, V, M>
impl<DL, V, M> Unpin for TransactionScriptsVerifier<DL, V, M>where
V: Unpin,
impl<DL, V, M> UnsafeUnpin for TransactionScriptsVerifier<DL, V, M>where
V: UnsafeUnpin,
impl<DL, V, M> UnwindSafe for TransactionScriptsVerifier<DL, V, M>where
V: UnwindSafe,
DL: RefUnwindSafe,
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> 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