revm_handler_interface/post_execution.rs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
pub trait PostExecutionHandler {
type Context;
type Error;
type ExecResult;
type Output;
/// Calculate final refund
fn refund(
&self,
context: &mut Self::Context,
exec_result: &mut Self::ExecResult,
eip7702_refund: i64,
);
/// Reimburse the caller with balance it didn't spent.
fn reimburse_caller(
&self,
context: &mut Self::Context,
exec_result: &mut Self::ExecResult,
) -> Result<(), Self::Error>;
/// Reward beneficiary with transaction rewards.
fn reward_beneficiary(
&self,
context: &mut Self::Context,
exec_result: &mut Self::ExecResult,
) -> Result<(), Self::Error>;
/// Main return handle, takes state from journal and transforms internal result to [`PostExecutionHandler::Output`].
fn output(
&self,
context: &mut Self::Context,
result: Self::ExecResult,
) -> Result<Self::Output, Self::Error>;
/// Called when execution ends.
///
/// End handle in comparison to output handle will be called every time after execution.
/// While [`PostExecutionHandler::output`] will be omitted in case of the error.
fn end(
&self,
_context: &mut Self::Context,
end_output: Result<Self::Output, Self::Error>,
) -> Result<Self::Output, Self::Error> {
end_output
}
/// Clean handler. This handle is called every time regardless
/// of the result of the transaction.
fn clear(&self, context: &mut Self::Context);
}