From 5dd2effda8fa0c1d5b9e4bd7bcb2654b75dd0687 Mon Sep 17 00:00:00 2001 From: Michael Benfield Date: Tue, 12 Mar 2024 11:05:05 -0700 Subject: [PATCH] exit_early --- include/hostio.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/hostio.h b/include/hostio.h index da62df5..cfe7059 100644 --- a/include/hostio.h +++ b/include/hostio.h @@ -305,6 +305,18 @@ VM_HOOK(read_return_data) size_t read_return_data(uint8_t * dest, size_t offset, */ VM_HOOK(write_result) void write_result(const uint8_t * data, size_t len); +/** +* Exits program execution early with the given status code. +* If `0`, the program returns successfully with any data supplied by `write_result`. +* Otherwise, the program reverts and treats any `write_result` data as revert data. +* +* The semantics are equivalent to that of the EVM's [`Return`] and [`Revert`] opcodes. +* +* [`Return`]: https://www.evm.codes/#f3 +* [`Revert`]: https://www.evm.codes/#fd +*/ +VM_HOOK(exit_early) void exit_early(uint32_t status); + /** * Returns the length of the last EVM call or deployment return result, or `0` if neither have * happened during the program's execution. The semantics are equivalent to that of the EVM's