Skip to content

Commit

Permalink
fix: cast overflow in 32-bits OS (#978)
Browse files Browse the repository at this point in the history
* fix: cast overflow in 32-bits OS

* Fix type conversion issues in bitwise.rs, host.rs, host_env.rs, macros.rs, and system.rs

* Fix error in as_usize_or_fail macro

* Update CI configuration and add Cross.toml

* Fix command arguments in ethereum-tests.yml

* Update Ethereum tests workflow

* Update Cross.toml with pre-build commands for i686 target
  • Loading branch information
dyxushuai authored Jan 16, 2024
1 parent 9d42562 commit 5e6546e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
- run: |
cd crates/revm
cargo check --no-default-features
check-serde:
name: check serde
runs-on: ubuntu-latest
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/ethereum-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ on:
pull_request:
branches: [main, "release/**"]


jobs:
tests-stable:
name: Ethereum Tests (Stable)
Expand All @@ -19,6 +18,7 @@ jobs:
strategy:
matrix:
profile: [ethtests, release]
target: [i686-unknown-linux-gnu, x86_64-unknown-linux-gnu]
steps:
- name: Checkout sources
uses: actions/checkout@v3
Expand All @@ -37,11 +37,13 @@ jobs:
with:
cache-on-failure: true

- name: Install cross
run: cargo install cross

- name: Run Ethereum tests
run: |
cargo run --profile ${{ matrix.profile }} -p revme -- statetest \
cross run --target ${{matrix.target}} --profile ${{ matrix.profile }} -p revme -- statetest \
ethtests/GeneralStateTests/ \
ethtests/LegacyTests/Constantinople/GeneralStateTests/ \
ethtests/EIPTests/StateTests/stEIP1153-transientStorage/ \
ethtests/EIPTests/StateTests/stEIP4844-blobtransactions/ \
ethtests/EIPTests/StateTests/stEIP5656-MCOPY/
10 changes: 10 additions & 0 deletions Cross.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[build]
pre-build = [
"apt-get update && apt-get install --assume-yes --no-install-recommends llvm-dev clang libclang-dev",
]

[target.i686-unknown-linux-gnu]
image = "ghcr.io/cross-rs/i686-unknown-linux-gnu:main"

[target.x86_64-unknown-linux-gnu]
image = "ghcr.io/cross-rs/x86_64-unknown-linux-gnu:main"
8 changes: 6 additions & 2 deletions crates/interpreter/src/instructions/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ macro_rules! as_u64_saturated {

macro_rules! as_usize_saturated {
($v:expr) => {
as_u64_saturated!($v) as usize
::core::convert::TryInto::<usize>::try_into(as_u64_saturated!($v)).unwrap_or(usize::MAX)
};
}

Expand All @@ -205,6 +205,10 @@ macro_rules! as_usize_or_fail {
$interp.instruction_result = $reason;
return;
}
x[0] as usize
let Ok(val) = ::core::convert::TryInto::<usize>::try_into(x[0]) else {
$interp.instruction_result = $reason;
return;
};
val
}};
}

0 comments on commit 5e6546e

Please sign in to comment.