Skip to main content

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;
17use revm_primitives::{Address, U256};
18use thiserror::Error;
19
20/// An error that occurred while executing an EVM application.
21#[derive(Debug, Error)]
22#[allow(missing_docs)]
23pub enum EvmExecutionError {
24    #[error(transparent)]
25    AmountConversionError(#[from] AmountConversionError),
26    #[error("Failed to load contract EVM module: {_0}")]
27    LoadContractModule(#[source] anyhow::Error),
28    #[error("Failed to load service EVM module: {_0}")]
29    LoadServiceModule(#[source] anyhow::Error),
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("The function {0} is being called but is missing from the bytecode API")]
39    MissingFunction(String),
40    #[error("Incorrect contract creation: {0}")]
41    IncorrectContractCreation(String),
42    #[error("The operation should contain the evm selector and so have length 4 or more")]
43    OperationIsTooShort,
44    #[error("Contracts cannot call themselves")]
45    NoSelfCall,
46    #[error("Incorrect ApplicationId")]
47    IncorrectApplicationId,
48    #[error("Non-zero transfer precompile")]
49    NonZeroTransferPrecompile,
50    #[error("Transact error {0}")]
51    TransactError(String),
52    #[error("Impossible to create contracts in services")]
53    NoContractCreationInService,
54    #[error("Transact commit error {0}")]
55    TransactCommitError(String),
56    #[error("Precompile error: {0}")]
57    PrecompileError(String),
58    #[error("Missing account info")]
59    MissingAccountInfo,
60    #[error("The operation was reverted with {gas_used} gas used and output {output:?}")]
61    Revert {
62        gas_used: u64,
63        output: revm_primitives::Bytes,
64    },
65    #[error("The operation was halted with {gas_used} gas used due to {reason:?}")]
66    Halt { gas_used: u64, reason: HaltReason },
67}