Skip to content

Commit

Permalink
[fix] ci (#4)
Browse files Browse the repository at this point in the history
* fix ci

* update branch

* fix clippy,test,docs

* fix clippy

* fix clippy
  • Loading branch information
lightsing authored May 10, 2024
1 parent e1e8f7a commit 1d44eb0
Show file tree
Hide file tree
Showing 15 changed files with 75 additions and 20 deletions.
13 changes: 7 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ concurrency:

on:
push:
branches: [main, "release/**"]
branches: [ main, "release/**", "scroll-evm-executor/**" ]
pull_request:
branches: [main, "release/**"]
branches: [ main, "release/**", "scroll-evm-executor/**" ]

env:
CARGO_TERM_COLOR: always
Expand All @@ -21,8 +21,8 @@ jobs:
strategy:
fail-fast: false
matrix:
rust: ["stable", "beta", "nightly"]
flags: ["--no-default-features", "", "--all-features"]
rust: [ "stable", "beta", "nightly" ]
flags: [ "--no-default-features", "", "--features=\"all, scroll\"", "--features=\"all, optimism\"" ]
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
Expand Down Expand Up @@ -79,9 +79,10 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- run: cargo clippy --workspace --all-targets --all-features
- run: cargo clippy --workspace --all-targets --features all,scroll
env:
RUSTFLAGS: -Dwarnings
- run: cargo clippy --workspace --all-targets --features all,optimism

docs:
name: docs
Expand All @@ -92,7 +93,7 @@ jobs:
- uses: dtolnay/rust-toolchain@stable
with:
components: rust-docs
- run: cargo doc --workspace --all-features --no-deps --document-private-items
- run: cargo doc --workspace --features all,scroll --no-deps --document-private-items
env:
RUSTDOCFLAGS: "--cfg docsrs -D warnings"

Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/ethereum-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ concurrency:

on:
push:
branches: [main, "release/**"]
branches: [ main, "release/**", "scroll-evm-executor/**" ]
pull_request:
branches: [main, "release/**"]
branches: [ main, "release/**", "scroll-evm-executor/**" ]

jobs:
tests-stable:
Expand All @@ -17,8 +17,8 @@ jobs:
timeout-minutes: 30
strategy:
matrix:
profile: [ethtests, release]
target: [i686-unknown-linux-gnu, x86_64-unknown-linux-gnu]
profile: [ ethtests, release ]
target: [ i686-unknown-linux-gnu, x86_64-unknown-linux-gnu ]
steps:
- name: Checkout sources
uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion bins/revme/src/cmd/statetest/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ pub fn execute_test_suite(
.build();
let mut evm = Evm::builder()
.with_db(&mut state)
.modify_env(|e| *e = env.clone())
.modify_env(|e| e.clone_from(&env))
.with_spec_id(spec_id)
.build();

Expand Down
9 changes: 9 additions & 0 deletions crates/interpreter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,12 @@ optional_eip3607 = ["revm-primitives/optional_eip3607"]
optional_gas_refund = ["revm-primitives/optional_gas_refund"]
optional_no_base_fee = ["revm-primitives/optional_no_base_fee"]
optional_beneficiary_reward = ["revm-primitives/optional_beneficiary_reward"]

all = [
"std",
"serde",
"arbitrary",
"asm-keccak",
"portable",
"dev",
]
4 changes: 3 additions & 1 deletion crates/interpreter/src/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,9 @@ impl Interpreter {
let out_offset = call_outcome.memory_start();
let out_len = call_outcome.memory_length();

self.return_data_buffer = call_outcome.output().to_owned();
call_outcome
.output()
.clone_into(&mut self.return_data_buffer);
let target_len = min(out_len, self.return_data_buffer.len());

match call_outcome.instruction_result() {
Expand Down
8 changes: 8 additions & 0 deletions crates/precompile/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ portable = ["revm-primitives/portable", "c-kzg?/portable"]
# In Linux it passes. If you don't require to build wasm on win/mac, it is safe to use it and it is enabled by default.
secp256k1 = ["dep:secp256k1"]

all = [
"std",
"asm-keccak",
"c-kzg",
"portable",
"secp256k1",
]

[[bench]]
name = "bench"
path = "benches/bench.rs"
Expand Down
9 changes: 9 additions & 0 deletions crates/primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,12 @@ optional_beneficiary_reward = []

# See comments in `revm-precompile`
c-kzg = ["dep:c-kzg", "dep:once_cell", "dep:derive_more"]

all = [
"std",
"serde",
"arbitrary",
"asm-keccak",
"portable",
"dev",
]
13 changes: 10 additions & 3 deletions crates/primitives/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,15 +220,16 @@ impl Default for AccountInfo {
}

impl PartialEq for AccountInfo {
#[allow(clippy::let_and_return)]
fn eq(&self, other: &Self) -> bool {
let eq = self.balance == other.balance
&& self.nonce == other.nonce
&& self.code_hash == other.code_hash;

#[cfg(all(debug_assertions, feature = "scroll"))]
if eq {
assert_eq!(self.keccak_code_hash, other.keccak_code_hash);
}

eq
}
}
Expand Down Expand Up @@ -329,7 +330,7 @@ impl AccountInfo {

#[cfg(test)]
mod tests {
use crate::{Account, KECCAK_EMPTY, U256};
use crate::{Account, U256};

#[test]
fn account_is_empty_balance() {
Expand Down Expand Up @@ -366,7 +367,13 @@ mod tests {
account.info.code_hash = [0; 32].into();
assert!(account.is_empty());

account.info.code_hash = KECCAK_EMPTY;
cfg_if::cfg_if! {
if #[cfg(feature = "scroll")] {
account.info.code_hash = crate::POSEIDON_EMPTY;
} else {
account.info.code_hash = crate::KECCAK_EMPTY;
}
}
assert!(account.is_empty());
}

Expand Down
13 changes: 13 additions & 0 deletions crates/revm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,19 @@ optional_beneficiary_reward = ["revm-interpreter/optional_beneficiary_reward"]
secp256k1 = ["revm-precompile/secp256k1"]
c-kzg = ["revm-precompile/c-kzg"]

all = [
"std",
"serde",
"serde-json",
"arbitrary",
"asm-keccak",
"portable",
"ethersdb",
"dev",
"revm-interpreter/all",
"revm-precompile/all",
]

[[example]]
name = "fork_ref_transact"
path = "../../examples/fork_ref_transact.rs"
Expand Down
6 changes: 6 additions & 0 deletions crates/revm/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,10 @@ mod test {
let code = Bytecode::new_raw([0xEF, 0x00].into());
#[cfg(feature = "scroll")]
let poseidon_code_hash = code.poseidon_hash_slow();
#[cfg(feature = "scroll")]
let keccak_code_hash = code.keccak_hash_slow();
#[cfg(not(feature = "scroll"))]
let keccak_code_hash = code.hash_slow();
let to_addr = address!("ffffffffffffffffffffffffffffffffffffffff");

// initialize the custom context and make sure it's zero
Expand Down Expand Up @@ -551,7 +554,10 @@ mod test {
let code = Bytecode::new_raw([0xEF, 0x00].into());
#[cfg(feature = "scroll")]
let poseidon_code_hash = code.poseidon_hash_slow();
#[cfg(feature = "scroll")]
let keccak_code_hash = code.keccak_hash_slow();
#[cfg(not(feature = "scroll"))]
let keccak_code_hash = code.hash_slow();
let to_addr = address!("ffffffffffffffffffffffffffffffffffffffff");

let mut evm = Evm::builder()
Expand Down
2 changes: 1 addition & 1 deletion crates/revm/src/context/evm_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ mod tests {
nonce: 0,
balance: bal,
#[cfg(not(feature = "scroll"))]
code_hash: by.clone().keccak_hash_slow(),
code_hash: by.clone().hash_slow(),
#[cfg(feature = "scroll")]
code_hash: by.clone().poseidon_hash_slow(),
#[cfg(feature = "scroll")]
Expand Down
2 changes: 1 addition & 1 deletion crates/revm/src/db/in_memory_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ mod tests {
let serialized = serde_json::to_string(&init_state).unwrap();
let deserialized: CacheDB<EmptyDB> = serde_json::from_str(&serialized).unwrap();

assert!(deserialized.accounts.get(&account).is_some());
assert!(deserialized.accounts.contains_key(&account));
assert_eq!(
deserialized.accounts.get(&account).unwrap().info.nonce,
nonce
Expand Down
2 changes: 1 addition & 1 deletion crates/revm/src/db/states/transition_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl TransitionAccount {
/// Update new values of transition. Don't override old values.
/// Both account info and old storages need to be left intact.
pub fn update(&mut self, other: Self) {
self.info = other.info.clone();
self.info.clone_from(&other.info);
self.status = other.status;

// if transition is from some to destroyed drop the storage.
Expand Down
2 changes: 1 addition & 1 deletion crates/revm/src/inspector/eip3155.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ impl<DB: Database> Inspector<DB> for TracerEip3155 {

fn step(&mut self, interp: &mut Interpreter, context: &mut EvmContext<DB>) {
self.gas_inspector.step(interp, context);
self.stack = interp.stack.data().clone();
self.stack.clone_from(interp.stack.data());
self.memory = if self.include_memory {
Some(hex::encode_prefixed(interp.shared_memory.context_memory()))
} else {
Expand Down
2 changes: 1 addition & 1 deletion crates/revm/src/scroll/l1block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl L1BlockInfo {
}))
}

/// Calculate the gas cost of a transaction based on L1 block data posted on L2, depending on the [SpecId] passed.
/// Calculate the gas cost of a transaction based on L1 block data posted on L2.
pub fn calculate_tx_l1_cost(&self, input: &[u8]) -> U256 {
let tx_l1_gas = self.data_gas(input);
tx_l1_gas
Expand Down

0 comments on commit 1d44eb0

Please sign in to comment.