Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 78 additions & 44 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,65 +10,99 @@ on:
pull_request:
branches: [main, "release/**"]

env:
CARGO_TERM_COLOR: always

jobs:
tests-stable:
name: Tests (Stable)
test:
name: test ${{ matrix.rust }} ${{ matrix.flags }}
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
rust: ["stable", "beta", "nightly"]
flags: ["--no-default-features", "", "--all-features"]
steps:
- name: Checkout sources
uses: actions/checkout@v3

- name: Install toolchain
uses: dtolnay/rust-toolchain@stable
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@master
with:
targets: riscv32imac-unknown-none-elf

toolchain: ${{ matrix.rust }}
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- run: cargo test --workspace ${{ matrix.flags }}

- name: cargo test
run: cargo test --workspace

- name: cargo test all features
run: cargo test --workspace --all-features

- name: cargo check no_std
run: cargo check --target riscv32imac-unknown-none-elf --no-default-features

lint:
name: Lint
test-no-std:
name: test no_std
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout sources
uses: actions/checkout@v3

- name: Install toolchain
uses: dtolnay/rust-toolchain@nightly
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy

- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true

- name: cargo fmt
run: cargo +nightly fmt --all -- --check

- name: cargo clippy
run: cargo +nightly clippy --workspace --all-features -- -D warnings
targets: riscv32imac-unknown-none-elf
- run: cargo check --target riscv32imac-unknown-none-elf --no-default-features

- name: cargo check no-default-features
run: |
check-no-default-features:
name: check no-default-features
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v3
- run: |
cd crates/revm
cargo check --no-default-features
- name: cargo check serde
run: |

check-serde:
name: check serde
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v3
- run: |
cd crates/revm
cargo check --no-default-features --features serde
- name: cargo check std
run: |

check-std:
name: check std
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v3
- run: |
cd crates/revm
cargo check --no-default-features --features std

clippy:
name: clippy
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@clippy
- run: cargo +nightly clippy --workspace --all-targets --all-features
env:
RUSTFLAGS: -Dwarnings

docs:
name: docs
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@nightly
with:
components: rust-docs
- run: cargo doc --workspace --all-features --no-deps --document-private-items
env:
RUSTDOCFLAGS: "--cfg docsrs -D warnings"

fmt:
name: fmt
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt
- run: cargo +nightly fmt --all --check
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ resolver = "2"
members = ["bins/*", "crates/*"]
default-members = ["crates/revm"]

[workspace.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]

[profile.release]
lto = true
codegen-units = 1
Expand Down
4 changes: 4 additions & 0 deletions crates/interpreter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ repository = "https://github.com/bluealloy/revm"
version = "1.3.0"
readme = "../../README.md"

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]

[dependencies]
revm-primitives = { path = "../primitives", version = "1.3.0", default-features = false }

Expand Down
2 changes: 1 addition & 1 deletion crates/interpreter/src/interpreter/shared_memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub struct SharedMemory {
checkpoints: Vec<usize>,
/// Invariant: equals `self.checkpoints.last()`
last_checkpoint: usize,
/// Memory limit. See [`crate::CfgEnv`].
/// Memory limit. See [`CfgEnv`](revm_primitives::CfgEnv).
#[cfg(feature = "memory_limit")]
memory_limit: u64,
}
Expand Down
1 change: 1 addition & 0 deletions crates/interpreter/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! # revm-interpreter
//!
//! REVM Interpreter.
#![warn(rustdoc::all)]
#![warn(unreachable_pub, unused_crate_dependencies)]
#![deny(unused_must_use, rust_2018_idioms)]
#![cfg_attr(not(feature = "std"), no_std)]
Expand Down
4 changes: 4 additions & 0 deletions crates/precompile/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ name = "revm-precompile"
repository = "https://github.com/bluealloy/revm"
version = "2.2.0"

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]

[dependencies]
revm-primitives = { path = "../primitives", version = "1.3.0", default-features = false }
bn = { package = "substrate-bn", version = "0.6", default-features = false }
Expand Down
8 changes: 4 additions & 4 deletions crates/precompile/src/blake2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub const FUN: PrecompileWithAddress = PrecompileWithAddress(
Precompile::Standard(run as StandardPrecompileFn),
);

/// reference: https://eips.ethereum.org/EIPS/eip-152
/// reference: <https://eips.ethereum.org/EIPS/eip-152>
/// input format:
/// [4 bytes for rounds][64 bytes for h][128 bytes for m][8 bytes for t_0][8 bytes for t_1][1 byte for f]
fn run(input: &[u8], gas_limit: u64) -> PrecompileResult {
Expand Down Expand Up @@ -55,7 +55,7 @@ fn run(input: &[u8], gas_limit: u64) -> PrecompileResult {
}

mod algo {
/// SIGMA from spec: https://datatracker.ietf.org/doc/html/rfc7693#section-2.7
/// SIGMA from spec: <https://datatracker.ietf.org/doc/html/rfc7693#section-2.7>
const SIGMA: [[usize; 16]; 10] = [
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
[14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3],
Expand All @@ -69,7 +69,7 @@ mod algo {
[10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0],
];

/// got IV from: https://en.wikipedia.org/wiki/BLAKE_(hash_function)
/// got IV from: <https://en.wikipedia.org/wiki/BLAKE_(hash_function)>
const IV: [u64; 8] = [
0x6a09e667f3bcc908,
0xbb67ae8584caa73b,
Expand All @@ -83,7 +83,7 @@ mod algo {

#[inline(always)]
#[allow(clippy::many_single_char_names)]
/// G function: https://tools.ietf.org/html/rfc7693#section-3.1
/// G function: <https://tools.ietf.org/html/rfc7693#section-3.1>
fn g(v: &mut [u64], a: usize, b: usize, c: usize, d: usize, x: u64, y: u64) {
v[a] = v[a].wrapping_add(v[b]).wrapping_add(x);
v[d] = (v[d] ^ v[a]).rotate_right(32);
Expand Down
12 changes: 6 additions & 6 deletions crates/precompile/src/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ pub const RIPEMD160: PrecompileWithAddress = PrecompileWithAddress(
Precompile::Standard(ripemd160_run as StandardPrecompileFn),
);

/// See: https://ethereum.github.io/yellowpaper/paper.pdf
/// See: https://docs.soliditylang.org/en/develop/units-and-global-variables.html#mathematical-and-cryptographic-functions
/// See: https://etherscan.io/address/0000000000000000000000000000000000000002
/// See: <https://ethereum.github.io/yellowpaper/paper.pdf>
/// See: <https://docs.soliditylang.org/en/develop/units-and-global-variables.html#mathematical-and-cryptographic-functions>
/// See: <https://etherscan.io/address/0000000000000000000000000000000000000002>
fn sha256_run(input: &[u8], gas_limit: u64) -> PrecompileResult {
let cost = calc_linear_cost_u32(input.len(), 60, 12);
if cost > gas_limit {
Expand All @@ -24,9 +24,9 @@ fn sha256_run(input: &[u8], gas_limit: u64) -> PrecompileResult {
}
}

/// See: https://ethereum.github.io/yellowpaper/paper.pdf
/// See: https://docs.soliditylang.org/en/develop/units-and-global-variables.html#mathematical-and-cryptographic-functions
/// See: https://etherscan.io/address/0000000000000000000000000000000000000003
/// See: <https://ethereum.github.io/yellowpaper/paper.pdf>
/// See: <https://docs.soliditylang.org/en/develop/units-and-global-variables.html#mathematical-and-cryptographic-functions>
/// See: <https://etherscan.io/address/0000000000000000000000000000000000000003>
fn ripemd160_run(input: &[u8], gas_limit: u64) -> PrecompileResult {
let gas_used = calc_linear_cost_u32(input.len(), 600, 120);
if gas_used > gas_limit {
Expand Down
4 changes: 2 additions & 2 deletions crates/precompile/src/identity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ const IDENTITY_PER_WORD: u64 = 3;

/// Takes the input bytes, copies them, and returns it as the output.
///
/// See: https://ethereum.github.io/yellowpaper/paper.pdf
/// See: https://etherscan.io/address/0000000000000000000000000000000000000004
/// See: <https://ethereum.github.io/yellowpaper/paper.pdf>
/// See: <https://etherscan.io/address/0000000000000000000000000000000000000004>
fn identity_run(input: &[u8], gas_limit: u64) -> PrecompileResult {
let gas_used = calc_linear_cost_u32(input.len(), IDENTITY_BASE, IDENTITY_PER_WORD);
if gas_used > gas_limit {
Expand Down
1 change: 1 addition & 0 deletions crates/precompile/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! # revm-precompile
//!
//! Implementations of EVM precompiled contracts.
#![warn(rustdoc::all)]
#![warn(unused_crate_dependencies)]
#![deny(unused_must_use, rust_2018_idioms)]
#![cfg_attr(not(feature = "std"), no_std)]
Expand Down
4 changes: 2 additions & 2 deletions crates/precompile/src/modexp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ pub const BERLIN: PrecompileWithAddress = PrecompileWithAddress(
Precompile::Standard(berlin_run as StandardPrecompileFn),
);

/// See: https://eips.ethereum.org/EIPS/eip-198
/// See: https://etherscan.io/address/0000000000000000000000000000000000000005
/// See: <https://eips.ethereum.org/EIPS/eip-198>
/// See: <https://etherscan.io/address/0000000000000000000000000000000000000005>
fn byzantium_run(input: &[u8], gas_limit: u64) -> PrecompileResult {
run_inner(input, gas_limit, 0, |a, b, c, d| {
byzantium_gas_calc(a, b, c, d)
Expand Down
4 changes: 4 additions & 0 deletions crates/primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ readme = "../../README.md"
# Don't need to run build script outside of this repo
exclude = ["build.rs", "src/kzg/*.txt"]

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]

[dependencies]
alloy-primitives = { version = "0.5", default-features = false, features = [
"rlp",
Expand Down
2 changes: 1 addition & 1 deletion crates/primitives/src/db/components/block_hash.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! BlockHash database component from [`crate::db::Database`]
//! it is used inside [crate::db::DatabaseComponents`]
//! it is used inside [`crate::db::DatabaseComponents`]
use crate::{B256, U256};
use alloc::sync::Arc;
Expand Down
2 changes: 1 addition & 1 deletion crates/primitives/src/db/components/state.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! State database component from [`crate::db::Database`]
//! it is used inside [crate::db::DatabaseComponents`]
//! it is used inside [`crate::db::DatabaseComponents`]

use crate::{AccountInfo, Address, Bytecode, B256, U256};
use alloc::sync::Arc;
Expand Down
1 change: 1 addition & 0 deletions crates/primitives/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! # revm-primitives
//!
//! EVM primitive types.
#![warn(rustdoc::all)]
#![warn(unreachable_pub, unused_crate_dependencies)]
#![deny(unused_must_use, rust_2018_idioms)]
#![cfg_attr(not(feature = "std"), no_std)]
Expand Down
4 changes: 4 additions & 0 deletions crates/revm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ repository = "https://github.com/bluealloy/revm"
version = "3.5.0"
readme = "../../README.md"

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]

[dependencies]
revm-interpreter = { path = "../interpreter", version = "1.3.0", default-features = false }
revm-precompile = { path = "../precompile", version = "2.2.0", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion crates/revm/src/evm_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ impl<'a, DB: Database> EvmContext<'a, DB> {
.ok()
}

/// Storage change of storage slot, before storing `sload`` will be called for that slot.
/// Storage change of storage slot, before storing `sload` will be called for that slot.
pub fn sstore(
&mut self,
address: Address,
Expand Down
2 changes: 1 addition & 1 deletion crates/revm/src/journaled_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ impl JournaledState {

/// Load account from database to JournaledState.
///
/// Return boolean pair where first is `is_cold`` second bool `is_exists`.
/// Return boolean pair where first is `is_cold` second bool `is_exists`.
#[inline]
pub fn load_account_exist<DB: Database>(
&mut self,
Expand Down
4 changes: 3 additions & 1 deletion crates/revm/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#![warn(unreachable_pub)]
#![doc = include_str!("../../../README.md")]
#![warn(rustdoc::all, unreachable_pub)]
#![allow(rustdoc::bare_urls)]
#![cfg_attr(not(test), warn(unused_crate_dependencies))]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
#![deny(unused_must_use, rust_2018_idioms)]
Expand Down