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 data_types;
11mod database;
12pub mod revm;
13
14use revm_context::result::{HaltReason, Output, SuccessReason};
15use revm_primitives::Log;
16use thiserror::Error;
17
18#[derive(Debug, Error)]
19pub enum EvmExecutionError {
20    #[error("Failed to load contract EVM module: {_0}")]
21    LoadContractModule(#[source] anyhow::Error),
22    #[error("Failed to load service EVM module: {_0}")]
23    LoadServiceModule(#[source] anyhow::Error),
24    #[error("Commit error {0}")]
25    CommitError(String),
26    #[error("It is illegal to call {0} from an operation")]
27    IllegalOperationCall(String),
28    #[error("runtime error")]
29    RuntimeError(String),
30    #[error("The function {0} is being called but is missing from the bytecode API")]
31    MissingFunction(String),
32    #[error("Incorrect contract creation: {0}")]
33    IncorrectContractCreation(String),
34    #[error("The operation should contain the evm selector and so have length 4 or more")]
35    OperationIsTooShort,
36    #[error("Missing bytecode")]
37    MissingBytecode,
38    #[error("Transact error {0}")]
39    TransactError(String),
40    #[error("Impossible to create contracts in services")]
41    NoContractCreationInService,
42    #[error("Transact commit error {0}")]
43    TransactCommitError(String),
44    #[error("Precompile error: {0}")]
45    PrecompileError(String),
46    #[error("The operation was reverted with {gas_used} gas used and output {output:?}")]
47    Revert {
48        gas_used: u64,
49        output: revm_primitives::Bytes,
50    },
51    #[error("The operation was halted with {gas_used} gas used due to {reason:?}")]
52    Halt { gas_used: u64, reason: HaltReason },
53    #[error("The interpreter did not return, reason={:?}, gas_used={}, gas_refunded={}, logs={:?}, output={:?}",
54            reason, gas_used, gas_refunded, logs, output)]
55    NoReturnInterpreter {
56        reason: SuccessReason,
57        gas_used: u64,
58        gas_refunded: u64,
59        logs: Vec<Log>,
60        output: Output,
61    },
62}