├── .github
├── CODEOWNERS
├── ISSUE_TEMPLATE
│ ├── config.yml
│ ├── BUG-FORM.yml
│ └── FEATURE-FORM.yml
├── PULL_REQUEST_TEMPLATE.md
└── workflows
│ └── ci.yml
├── crates
├── op-evm
│ ├── README.md
│ ├── Cargo.toml
│ └── src
│ │ └── block
│ │ ├── receipt_builder.rs
│ │ └── canyon.rs
└── evm
│ ├── src
│ ├── rpc
│ │ ├── mod.rs
│ │ ├── transaction.rs
│ │ └── fees.rs
│ ├── op
│ │ ├── mod.rs
│ │ ├── rpc.rs
│ │ ├── env.rs
│ │ ├── spec_id.rs
│ │ └── tx.rs
│ ├── lib.rs
│ ├── block
│ │ ├── state_hook.rs
│ │ ├── state.rs
│ │ ├── system_calls
│ │ │ ├── eip2935.rs
│ │ │ ├── eip4788.rs
│ │ │ ├── eip7002.rs
│ │ │ ├── eip7251.rs
│ │ │ └── mod.rs
│ │ ├── state_changes.rs
│ │ ├── calc.rs
│ │ └── error.rs
│ ├── eth
│ │ ├── spec.rs
│ │ ├── receipt_builder.rs
│ │ ├── dao_fork.rs
│ │ ├── spec_id.rs
│ │ ├── env.rs
│ │ ├── block.rs
│ │ └── mod.rs
│ ├── call.rs
│ ├── either.rs
│ ├── error.rs
│ ├── env.rs
│ ├── tracing.rs
│ ├── overrides.rs
│ └── evm.rs
│ ├── README.md
│ └── Cargo.toml
├── .gitignore
├── .config
├── nextest.toml
└── zepter.yaml
├── scripts
├── changelog.sh
└── check_no_std.sh
├── rustfmt.toml
├── release.toml
├── README.md
├── LICENSE-MIT
├── deny.toml
├── cliff.toml
├── Cargo.toml
└── LICENSE-APACHE
/.github/CODEOWNERS:
--------------------------------------------------------------------------------
1 | * @mattsse @klkvr
2 |
--------------------------------------------------------------------------------
/crates/op-evm/README.md:
--------------------------------------------------------------------------------
1 | # alloy-evm
2 |
3 | OP EVM implementation.
4 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /target
2 | /Cargo.lock
3 | .vscode
4 | .idea
5 | .env
6 | .DS_Store
7 |
--------------------------------------------------------------------------------
/.config/nextest.toml:
--------------------------------------------------------------------------------
1 | [profile.default]
2 | retries = { backoff = "exponential", count = 2, delay = "2s", jitter = true }
3 | slow-timeout = { period = "30s", terminate-after = 4 }
4 |
--------------------------------------------------------------------------------
/crates/evm/src/rpc/mod.rs:
--------------------------------------------------------------------------------
1 | //! RPC-related traits and implementations.
2 |
3 | mod fees;
4 | mod transaction;
5 |
6 | pub use fees::{CallFees, CallFeesError};
7 | pub use transaction::{EthTxEnvError, TryIntoTxEnv};
8 |
--------------------------------------------------------------------------------
/crates/evm/src/op/mod.rs:
--------------------------------------------------------------------------------
1 | //! Optimism EVM implementation.
2 |
3 | mod env;
4 | #[cfg(feature = "rpc")]
5 | mod rpc;
6 | mod spec_id;
7 | mod tx;
8 |
9 | pub use spec_id::{spec, spec_by_timestamp_after_bedrock};
10 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/config.yml:
--------------------------------------------------------------------------------
1 | blank_issues_enabled: true
2 | contact_links:
3 | - name: Support
4 | url: https://t.me/ethers_rs
5 | about: This issue tracker is only for bugs and feature requests. Support is available on Telegram!
6 |
--------------------------------------------------------------------------------
/scripts/changelog.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | set -e -o pipefail
3 |
4 | root=$(dirname "$(dirname "$0")")
5 | cmd=(git cliff --workdir "$root" --output "$root/CHANGELOG.md" "$@")
6 |
7 | if [ "$DRY_RUN" = "true" ]; then
8 | echo "skipping due to dry run: ${cmd[*]}" >&2
9 | exit 0
10 | else
11 | "${cmd[@]}"
12 | fi
--------------------------------------------------------------------------------
/crates/evm/README.md:
--------------------------------------------------------------------------------
1 | # alloy-evm
2 |
3 | EVM interface.
4 |
5 | This crate contains constants, types, and functions for interacting with the Ethereum Virtual Machine (EVM).
6 | It is compatible with the types from the [alloy](https://crates.io/crates/alloy) ecosystem and comes with batteries included for [revm](https://crates.io/crates/revm)
7 |
8 |
--------------------------------------------------------------------------------
/rustfmt.toml:
--------------------------------------------------------------------------------
1 | reorder_imports = true
2 | use_field_init_shorthand = true
3 | use_small_heuristics = "Max"
4 |
5 | # Nightly
6 | max_width = 100
7 | comment_width = 100
8 | imports_granularity = "Crate"
9 | wrap_comments = true
10 | format_code_in_doc_comments = true
11 | doc_comment_code_block_width = 100
12 | format_macro_matchers = true
13 |
--------------------------------------------------------------------------------
/scripts/check_no_std.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | set -eo pipefail
3 |
4 | no_std_packages=(
5 | alloy-evm
6 | alloy-op-evm
7 | )
8 |
9 | for package in "${no_std_packages[@]}"; do
10 | cmd="cargo +stable build -p $package --target riscv32imac-unknown-none-elf --no-default-features"
11 | if [ -n "$CI" ]; then
12 | echo "::group::$cmd"
13 | else
14 | printf "\n%s:\n %s\n" "$package" "$cmd"
15 | fi
16 |
17 | $cmd
18 |
19 | if [ -n "$CI" ]; then
20 | echo "::endgroup::"
21 | fi
22 | done
23 |
--------------------------------------------------------------------------------
/release.toml:
--------------------------------------------------------------------------------
1 | # Configuration file for [`cargo-release`](https://github.com/crate-ci/cargo-release)
2 | # See: https://github.com/crate-ci/cargo-release/blob/master/docs/reference.md
3 |
4 | allow-branch = ["main"]
5 | sign-commit = true
6 | sign-tag = true
7 | shared-version = true
8 | pre-release-commit-message = "chore: release {{version}}"
9 | tag-prefix = "" # tag only once instead of per every crate
10 | pre-release-hook = ["sh", "-c", "$WORKSPACE_ROOT/scripts/changelog.sh --tag {{version}}"]
11 | owners = ["github:alloy-rs:core"]
12 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/BUG-FORM.yml:
--------------------------------------------------------------------------------
1 | name: Bug report
2 | description: File a bug report
3 | labels: ["bug"]
4 | title: "[Bug] "
5 | body:
6 | - type: markdown
7 | attributes:
8 | value: |
9 | Please ensure that the bug has not already been filed in the issue tracker.
10 |
11 | Thanks for taking the time to report this bug!
12 | - type: input
13 | attributes:
14 | label: What version of Alloy are you on?
15 | placeholder: "Run `cargo tree | grep alloy` and paste the output here"
16 | - type: textarea
17 | attributes:
18 | label: Describe the bug
19 | description: Please include code snippets as well if relevant.
20 | validations:
21 | required: true
22 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/FEATURE-FORM.yml:
--------------------------------------------------------------------------------
1 | name: Feature request
2 | description: Suggest a feature
3 | labels: ["enhancement"]
4 | title: "[Feature] "
5 | body:
6 | - type: markdown
7 | attributes:
8 | value: |
9 | Please ensure that the feature has not already been requested in the issue tracker.
10 | - type: textarea
11 | attributes:
12 | label: Describe the feature you would like
13 | description:
14 | Please also describe your goals for the feature. What problems it solves, how it would be
15 | used, etc.
16 | validations:
17 | required: true
18 | - type: textarea
19 | attributes:
20 | label: Additional context
21 | description: Add any other context to the feature (like screenshots, resources)
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # :construction: This repository is a work in progress.
2 |
3 | # Alloy-EVM
4 |
5 | ## Overview
6 |
7 | `alloy-evm` is an abstraction layer on top of [revm](https://github.com/bluealloy/revm) providing common implementations of EVMs. Currently, alloy-evm is only used in Reth but is designed to be consumed by any project that needs to execute/trace transactions or blocks on EVM compatible chains.
8 |
9 | `alloy-evm` is compatible with no_std and riscv targets.
10 |
11 | #### License
12 |
13 |
14 | Licensed under either of Apache License, Version
15 | 2.0 or MIT license at your option.
16 |
17 |
18 |
19 |
20 |
21 | Unless you explicitly state otherwise, any contribution intentionally submitted
22 | for inclusion in these crates by you, as defined in the Apache-2.0 license,
23 | shall be dual licensed as above, without any additional terms or conditions.
24 |
25 |
--------------------------------------------------------------------------------
/.github/PULL_REQUEST_TEMPLATE.md:
--------------------------------------------------------------------------------
1 |
12 |
13 |
14 |
15 | ## Motivation
16 |
17 |
22 |
23 | ## Solution
24 |
25 |
29 |
30 | ## PR Checklist
31 |
32 | - [ ] Added Tests
33 | - [ ] Added Documentation
34 | - [ ] Breaking changes
35 |
--------------------------------------------------------------------------------
/LICENSE-MIT:
--------------------------------------------------------------------------------
1 | Permission is hereby granted, free of charge, to any
2 | person obtaining a copy of this software and associated
3 | documentation files (the "Software"), to deal in the
4 | Software without restriction, including without
5 | limitation the rights to use, copy, modify, merge,
6 | publish, distribute, sublicense, and/or sell copies of
7 | the Software, and to permit persons to whom the Software
8 | is furnished to do so, subject to the following
9 | conditions:
10 |
11 | The above copyright notice and this permission notice
12 | shall be included in all copies or substantial portions
13 | of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
16 | ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
17 | TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
18 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
19 | SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
22 | IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23 | DEALINGS IN THE SOFTWARE.
24 |
--------------------------------------------------------------------------------
/crates/evm/src/lib.rs:
--------------------------------------------------------------------------------
1 | #![doc = include_str!("../README.md")]
2 | #![doc(
3 | html_logo_url = "https://raw.githubusercontent.com/alloy-rs/core/main/assets/alloy.jpg",
4 | html_favicon_url = "https://raw.githubusercontent.com/alloy-rs/core/main/assets/favicon.ico"
5 | )]
6 | #![cfg_attr(not(test), warn(unused_crate_dependencies))]
7 | #![cfg_attr(docsrs, feature(doc_cfg))]
8 | #![cfg_attr(not(feature = "std"), no_std)]
9 |
10 | extern crate alloc;
11 |
12 | pub mod block;
13 | pub mod evm;
14 | pub use evm::{Database, Evm, EvmFactory};
15 | pub mod eth;
16 | pub use eth::{EthEvm, EthEvmFactory};
17 | pub mod env;
18 | pub use env::EvmEnv;
19 | pub mod error;
20 | pub use error::*;
21 | pub mod tx;
22 | pub use tx::*;
23 | pub mod traits;
24 | pub use traits::*;
25 | #[cfg(feature = "call-util")]
26 | pub mod call;
27 | #[cfg(feature = "op")]
28 | pub mod op;
29 | #[cfg(feature = "overrides")]
30 | pub mod overrides;
31 | pub mod precompiles;
32 | #[cfg(feature = "rpc")]
33 | pub mod rpc;
34 | pub mod tracing;
35 |
36 | mod either;
37 |
38 | // re-export revm and op-revm
39 | #[cfg(feature = "op")]
40 | pub use op_revm;
41 | pub use revm;
42 |
43 | pub use eth::spec_id::{spec, spec_by_timestamp_and_block_number};
44 |
--------------------------------------------------------------------------------
/crates/op-evm/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "alloy-op-evm"
3 | description = "OP EVM implementation"
4 |
5 | version.workspace = true
6 | edition.workspace = true
7 | rust-version.workspace = true
8 | authors.workspace = true
9 | license.workspace = true
10 | homepage.workspace = true
11 | repository.workspace = true
12 |
13 | [lints]
14 | workspace = true
15 |
16 | [dependencies]
17 | alloy-evm = { workspace = true, features = ["op"] }
18 |
19 | alloy-eips.workspace = true
20 | alloy-consensus.workspace = true
21 | alloy-primitives.workspace = true
22 |
23 | alloy-op-hardforks.workspace = true
24 | op-alloy.workspace = true
25 |
26 | revm.workspace = true
27 | op-revm.workspace = true
28 |
29 | thiserror.workspace = true
30 |
31 | auto_impl.workspace = true
32 |
33 | [dev-dependencies]
34 | alloy-hardforks.workspace = true
35 | test-case.workspace = true
36 |
37 | [features]
38 | default = ["std"]
39 | std = [
40 | "alloy-primitives/std",
41 | "revm/std",
42 | "alloy-evm/std",
43 | "op-revm/std",
44 | "alloy-consensus/std",
45 | "alloy-eips/std",
46 | "op-alloy/std",
47 | "thiserror/std"
48 | ]
49 | gmp = ["alloy-evm/gmp"]
50 | asm-keccak = ["alloy-evm/asm-keccak", "alloy-primitives/asm-keccak", "revm/asm-keccak"]
--------------------------------------------------------------------------------
/deny.toml:
--------------------------------------------------------------------------------
1 | [advisories]
2 | version = 2
3 | yanked = "warn"
4 | ignore = [
5 | # https://rustsec.org/advisories/RUSTSEC-2024-0437, trezor-client dependency, no fix available yet
6 | "RUSTSEC-2024-0437",
7 | # https://rustsec.org/advisories/RUSTSEC-2024-0436
8 | "RUSTSEC-2024-0436",
9 | ]
10 |
11 | [bans]
12 | multiple-versions = "warn"
13 | wildcards = "deny"
14 | highlight = "all"
15 |
16 | [licenses]
17 | version = 2
18 | confidence-threshold = 0.8
19 |
20 | allow = [
21 | "MIT",
22 | "Apache-2.0",
23 | "Apache-2.0 WITH LLVM-exception",
24 | "BSD-2-Clause",
25 | "BSD-3-Clause",
26 | "Unicode-3.0",
27 | "Unlicense",
28 | "Zlib",
29 | "CC0-1.0",
30 | ]
31 |
32 | exceptions = [
33 | # gmp feature (optional, LGPL-licensed)
34 | { allow = ["LGPL-3.0-or-later"], crate = "rug" },
35 | { allow = ["LGPL-3.0-or-later"], crate = "gmp-mpfr-sys" },
36 | ]
37 |
38 | [[licenses.clarify]]
39 | name = "ring"
40 | expression = "LicenseRef-ring"
41 | license-files = [{ path = "LICENSE", hash = 0xbd0eed23 }]
42 |
43 | [[licenses.clarify]]
44 | name = "webpki"
45 | expression = "LicenseRef-webpki"
46 | license-files = [{ path = "LICENSE", hash = 0x001c7e6c }]
47 |
48 | [sources]
49 | unknown-registry = "deny"
50 | unknown-git = "deny"
51 | allow-git = [
52 | "https://github.com/bluealloy/revm",
53 | "https://github.com/alloy-rs/hardforks",
54 | ]
55 |
--------------------------------------------------------------------------------
/.config/zepter.yaml:
--------------------------------------------------------------------------------
1 | version:
2 | format: 1
3 | # Minimum zepter version that is expected to work. This is just for printing a nice error
4 | # message when someone tries to use an older version.
5 | binary: 0.13.2
6 |
7 | # The examples in the following comments assume crate `A` to have a dependency on crate `B`.
8 | workflows:
9 | check:
10 | - [
11 | "lint",
12 | # Check that `A` activates the features of `B`.
13 | "propagate-feature",
14 | # These are the features to check:
15 | "--features=std",
16 | # Do not try to add a new section into `[features]` of `A` only because `B` expose that feature. There are edge-cases where this is still needed, but we can add them manually.
17 | "--left-side-feature-missing=ignore",
18 | # Ignore the case that `A` it outside of the workspace. Otherwise it will report errors in external dependencies that we have no influence on.
19 | "--left-side-outside-workspace=ignore",
20 | # limit to the workspace
21 | "--show-path",
22 | "--quiet",
23 | ]
24 | default:
25 | # Running `zepter` with no subcommand will check & fix.
26 | - [$check.0, "--fix"]
27 |
28 | # Will be displayed when any workflow fails:
29 | help:
30 | text: |
31 | Alloy uses the Zepter CLI to detect abnormalities in Cargo features, e.g. missing propagation.
32 |
33 | It looks like one more checks failed; please check the console output.
34 |
35 | You can try to automatically address them by installing zepter (`cargo install zepter --locked`) and simply running `zepter` in the workspace root.
36 | links:
37 | - "https://github.com/ggwpez/zepter"
38 |
--------------------------------------------------------------------------------
/crates/evm/src/block/state_hook.rs:
--------------------------------------------------------------------------------
1 | use revm::state::EvmState;
2 |
3 | /// A hook that is called after each state change.
4 | pub trait OnStateHook: Send + 'static {
5 | /// Invoked with the source of the change and the state after each system call.
6 | fn on_state(&mut self, source: StateChangeSource, state: &EvmState);
7 | }
8 |
9 | /// Source of the state change
10 | #[derive(Debug, Clone, Copy)]
11 | pub enum StateChangeSource {
12 | /// Transaction with its index
13 | Transaction(usize),
14 | /// Pre-block state transition
15 | PreBlock(StateChangePreBlockSource),
16 | /// Post-block state transition
17 | PostBlock(StateChangePostBlockSource),
18 | }
19 |
20 | /// Source of the pre-block state change
21 | #[derive(Debug, Clone, Copy)]
22 | pub enum StateChangePreBlockSource {
23 | /// EIP-2935 blockhashes contract
24 | BlockHashesContract,
25 | /// EIP-4788 beacon root contract
26 | BeaconRootContract,
27 | /// EIP-7002 withdrawal requests contract
28 | WithdrawalRequestsContract,
29 | }
30 |
31 | /// Source of the post-block state change
32 | #[derive(Debug, Clone, Copy)]
33 | pub enum StateChangePostBlockSource {
34 | /// Balance increments from block rewards and withdrawals
35 | BalanceIncrements,
36 | /// EIP-7002 withdrawal requests contract
37 | WithdrawalRequestsContract,
38 | /// EIP-7251 consolidation requests contract
39 | ConsolidationRequestsContract,
40 | }
41 |
42 | impl OnStateHook for F
43 | where
44 | F: FnMut(StateChangeSource, &EvmState) + Send + 'static,
45 | {
46 | fn on_state(&mut self, source: StateChangeSource, state: &EvmState) {
47 | self(source, state)
48 | }
49 | }
50 |
51 | /// An [`OnStateHook`] that does nothing.
52 | #[derive(Default, Debug, Clone)]
53 | #[non_exhaustive]
54 | pub struct NoopHook;
55 |
56 | impl OnStateHook for NoopHook {
57 | fn on_state(&mut self, _source: StateChangeSource, _state: &EvmState) {}
58 | }
59 |
--------------------------------------------------------------------------------
/crates/evm/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "alloy-evm"
3 | description = "EVM abstraction for Alloy"
4 |
5 | version.workspace = true
6 | edition.workspace = true
7 | rust-version.workspace = true
8 | authors.workspace = true
9 | license.workspace = true
10 | homepage.workspace = true
11 | repository.workspace = true
12 |
13 | [lints]
14 | workspace = true
15 |
16 | [dependencies]
17 | alloy-consensus = { workspace = true, features = ["k256"] }
18 | alloy-primitives.workspace = true
19 | alloy-sol-types.workspace = true
20 | alloy-eips.workspace = true
21 | alloy-hardforks.workspace = true
22 | alloy-op-hardforks = { workspace = true, optional = true }
23 | alloy-rpc-types-eth = { workspace = true, optional = true }
24 | alloy-rpc-types-engine = { workspace = true, optional = true }
25 |
26 | revm.workspace = true
27 | op-revm = { workspace = true, optional = true }
28 | op-alloy = { workspace = true, optional = true }
29 |
30 | auto_impl.workspace = true
31 | derive_more.workspace = true
32 | thiserror.workspace = true
33 |
34 | [dev-dependencies]
35 | alloy-primitives = { workspace = true, features = ["serde"] }
36 | serde_json.workspace = true
37 | test-case.workspace = true
38 |
39 | [features]
40 | default = ["std"]
41 | secp256k1 = [
42 | "std",
43 | "alloy-consensus/secp256k1",
44 | ]
45 | std = [
46 | "alloy-primitives/std",
47 | "revm/std",
48 | "alloy-consensus/std",
49 | "alloy-eips/std",
50 | "alloy-sol-types/std",
51 | "derive_more/std",
52 | "op-revm?/std",
53 | "thiserror/std",
54 | "op-alloy?/std",
55 | "alloy-rpc-types-eth?/std",
56 | "alloy-rpc-types-engine?/std"
57 | ]
58 | gmp = [
59 | "revm/gmp",
60 | ]
61 | op = ["op-revm", "op-alloy", "alloy-op-hardforks"]
62 | overrides = ["dep:alloy-rpc-types-eth"]
63 | call-util = ["overrides"]
64 | engine = ["dep:alloy-rpc-types-engine", "op-alloy?/rpc-types-engine"]
65 | asm-keccak = ["alloy-primitives/asm-keccak", "revm/asm-keccak"]
66 | rpc = ["dep:alloy-rpc-types-eth", "op-alloy?/rpc-types"]
67 |
--------------------------------------------------------------------------------
/crates/evm/src/block/state.rs:
--------------------------------------------------------------------------------
1 | //! State database abstraction.
2 |
3 | use alloy_primitives::Address;
4 | use revm::database::State;
5 |
6 | /// A type which has the state of the blockchain.
7 | ///
8 | /// This trait encapsulates some of the functionality found in [`State`]
9 | pub trait StateDB: revm::Database {
10 | /// State clear EIP-161 is enabled in Spurious Dragon hardfork.
11 | fn set_state_clear_flag(&mut self, has_state_clear: bool);
12 |
13 | /// Iterates over received balances and increment all account balances.
14 | ///
15 | /// **Note**: If account is not found inside cache state it will be loaded from database.
16 | ///
17 | /// Update will create transitions for all accounts that are updated.
18 | ///
19 | /// If using this to implement withdrawals, zero balances must be filtered out before calling
20 | /// this function.
21 | fn increment_balances(
22 | &mut self,
23 | balances: impl IntoIterator- ,
24 | ) -> Result<(), Self::Error>;
25 | }
26 |
27 | /// auto_impl unable to reconcile return associated type from supertrait
28 | impl StateDB for &mut T {
29 | fn set_state_clear_flag(&mut self, has_state_clear: bool) {
30 | StateDB::set_state_clear_flag(*self, has_state_clear);
31 | }
32 |
33 | fn increment_balances(
34 | &mut self,
35 | balances: impl IntoIterator
- ,
36 | ) -> Result<(), Self::Error> {
37 | StateDB::increment_balances(*self, balances)
38 | }
39 | }
40 |
41 | impl StateDB for State {
42 | fn set_state_clear_flag(&mut self, has_state_clear: bool) {
43 | self.cache.set_state_clear_flag(has_state_clear);
44 | }
45 |
46 | fn increment_balances(
47 | &mut self,
48 | balances: impl IntoIterator
- ,
49 | ) -> Result<(), Self::Error> {
50 | Self::increment_balances(self, balances)
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/crates/evm/src/block/system_calls/eip2935.rs:
--------------------------------------------------------------------------------
1 | //! [EIP-2935](https://eips.ethereum.org/EIPS/eip-2935) system call implementation.
2 |
3 | use crate::{
4 | block::{BlockExecutionError, BlockValidationError},
5 | Evm,
6 | };
7 | use alloc::string::ToString;
8 | use alloy_eips::eip2935::HISTORY_STORAGE_ADDRESS;
9 | use alloy_hardforks::EthereumHardforks;
10 | use alloy_primitives::B256;
11 | use revm::{context::Block, context_interface::result::ResultAndState};
12 |
13 | /// Applies the pre-block call to the [EIP-2935] blockhashes contract, using the given block,
14 | /// chain specification, and EVM.
15 | ///
16 | /// If Prague is not activated, or the block is the genesis block, then this is a no-op, and no
17 | /// state changes are made.
18 | ///
19 | /// Note: this does not commit the state changes to the database, it only transacts the call.
20 | ///
21 | /// Returns `None` if Prague is not active or the block is the genesis block, otherwise returns the
22 | /// result of the call.
23 | ///
24 | /// [EIP-2935]: https://eips.ethereum.org/EIPS/eip-2935
25 | #[inline]
26 | pub(crate) fn transact_blockhashes_contract_call(
27 | spec: impl EthereumHardforks,
28 | parent_block_hash: B256,
29 | evm: &mut impl Evm,
30 | ) -> Result