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 inputs;
13pub mod revm;
14
15use linera_base::data_types::AmountConversionError;
16use revm_context::result::{HaltReason, Output, SuccessReason};
17use revm_primitives::{Address, Log, U256};
18use thiserror::Error;
19
20#[derive(Debug, Error)]
21pub enum EvmExecutionError {
22    #[error(transparent)]
23    AmountConversionError(#[from] AmountConversionError),
24    #[error("Failed to load contract EVM module: {_0}")]
25    LoadContractModule(#[source] anyhow::Error),
26    #[error("Failed to load service EVM module: {_0}")]
27    LoadServiceModule(#[source] anyhow::Error),
28    #[error("Commit error {0}")]
29    CommitError(String),
30    #[error("It is illegal to call {0} from an operation")]
31    IllegalOperationCall(String),
32    #[error("runtime error")]
33    RuntimeError(String),
34    #[error("The balances are incoherent for address {0}, balances {1}, {2}")]
35    IncoherentBalances(Address, U256, U256),
36    #[error("Unknown signer")]
37    UnknownSigner,
38    #[error("No delegate call")]
39    NoDelegateCall,
40    #[error("No transfer in services")]
41    NoTransferInServices,
42    #[error("No transfer in Wasm application call")]
43    NoTransferInRuntimeCall,
44    #[error("The function {0} is being called but is missing from the bytecode API")]
45    MissingFunction(String),
46    #[error("Incorrect contract creation: {0}")]
47    IncorrectContractCreation(String),
48    #[error("The operation should contain the evm selector and so have length 4 or more")]
49    OperationIsTooShort,
50    #[error("Missing bytecode")]
51    MissingBytecode,
52    #[error("Contracts cannot call themselves")]
53    NoSelfCall,
54    #[error("Transact error {0}")]
55    TransactError(String),
56    #[error("Impossible to create contracts in services")]
57    NoContractCreationInService,
58    #[error("Transact commit error {0}")]
59    TransactCommitError(String),
60    #[error("Precompile error: {0}")]
61    PrecompileError(String),
62    #[error("The operation was reverted with {gas_used} gas used and output {output:?}")]
63    Revert {
64        gas_used: u64,
65        output: revm_primitives::Bytes,
66    },
67    #[error("The operation was halted with {gas_used} gas used due to {reason:?}")]
68    Halt { gas_used: u64, reason: HaltReason },
69    #[error("The interpreter did not return, reason={:?}, gas_used={}, gas_refunded={}, logs={:?}, output={:?}",
70            reason, gas_used, gas_refunded, logs, output)]
71    NoReturnInterpreter {
72        reason: SuccessReason,
73        gas_used: u64,
74        gas_refunded: u64,
75        logs: Vec<Log>,
76        output: Output,
77    },
78}