linera_execution/evm/
mod.rs

1// Copyright (c) Zefchain Labs, Inc.
2// SPDX-License-Identifier: Apache-2.0
3
4//! Support for user applications compiled for the EVM
5//!
6//! We are using Revm for implementing it.
7
8#![cfg(with_revm)]
9
10mod database;
11pub mod revm;
12
13use revm_context::result::{HaltReason, Output, SuccessReason};
14use revm_primitives::Log;
15use thiserror::Error;
16
17#[derive(Debug, Error)]
18pub enum EvmExecutionError {
19    #[error("Failed to load contract EVM module: {_0}")]
20    LoadContractModule(#[source] anyhow::Error),
21    #[error("Failed to load service EVM module: {_0}")]
22    LoadServiceModule(#[source] anyhow::Error),
23    #[error("Commit error {0}")]
24    CommitError(String),
25    #[error("It is illegal to call {0} from an operation")]
26    IllegalOperationCall(String),
27    #[error("The function {0} is being called but is missing from the bytecode API")]
28    MissingFunction(String),
29    #[error("Incorrect contract creation: {0}")]
30    IncorrectContractCreation(String),
31    #[error("The operation should contain the evm selector and so have length 4 or more")]
32    OperationIsTooShort,
33    #[error("Transact error {0}")]
34    TransactError(String),
35    #[error("Transact commit error {0}")]
36    TransactCommitError(String),
37    #[error("Precompile error: {0}")]
38    PrecompileError(String),
39    #[error("The operation was reverted with {gas_used} gas used and output {output:?}")]
40    Revert {
41        gas_used: u64,
42        output: revm_primitives::Bytes,
43    },
44    #[error("The operation was halted with {gas_used} gas used due to {reason:?}")]
45    Halt { gas_used: u64, reason: HaltReason },
46    #[error("The interpreter did not return, reason={:?}, gas_used={}, gas_refunded={}, logs={:?}, output={:?}",
47            reason, gas_used, gas_refunded, logs, output)]
48    NoReturnInterpreter {
49        reason: SuccessReason,
50        gas_used: u64,
51        gas_refunded: u64,
52        logs: Vec<Log>,
53        output: Output,
54    },
55}