Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PRAGUE hard fork implementation #67

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
17 changes: 14 additions & 3 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,22 @@ jobs:
submodules: recursive
fetch-depth: 1

- name: Download Ethereum spec tests fixtures
run: |
wget https://github.com/ethereum/execution-spec-tests/releases/download/pectra-devnet-5%40v1.2.0/fixtures_pectra-devnet-5.tar.gz
mkdir ethereum-spec-tests
tar -xzf fixtures_pectra-devnet-5.tar.gz -C ethereum-spec-tests
tree ethereum-spec-tests/fixtures/state_tests/prague/eip7702_set_code_tx

- name: Run Ethereum state tests
run: |
cargo run -r -p evm-jsontests -F enable-slow-tests -- state -f \
ethtests/GeneralStateTests/ \
ethtests/LegacyTests/Cancun/GeneralStateTests/ \
ethtests/EIPTests/StateTests/
ethereum-spec-tests/fixtures/state_tests/prague/eip7702_set_code_tx/ \
ethereum-spec-tests/fixtures/state_tests/prague/eip7623_increase_calldata_cost/
# Temporally disable as EOFv1 not implemented
# ethtests/EIPTests/StateTests/

- name: Run Ethereum vm tests
run: |
Expand Down Expand Up @@ -135,8 +145,9 @@ jobs:
export PATH="$PATH:$HOME/.cargo/bin"
cargo run -r -p evm-jsontests -F enable-slow-tests -- state -f \
ethtests/GeneralStateTests/ \
ethtests/LegacyTests/Cancun/GeneralStateTests/ \
ethtests/EIPTests/StateTests/
ethtests/LegacyTests/Cancun/GeneralStateTests/
# Temporally disable as EOFv1 not implemented
# ethtests/EIPTests/StateTests/
cargo run -r -p evm-jsontests -F enable-slow-tests -- vm -f \
ethtests/LegacyTests/Constantinople/VMTests/vmArithmeticTest \
ethtests/LegacyTests/Constantinople/VMTests/vmBitwiseLogicOperation \
Expand Down
10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ keywords.workspace = true
edition.workspace = true

[workspace.dependencies]
evm = { version = "0.46.2", path = "." }
evm-core = { version = "0.46.2", path = "core", default-features = false }
evm-gasometer = { version = "0.46.2", path = "gasometer", default-features = false }
evm-runtime = { version = "0.46.2", path = "runtime", default-features = false }
evm = { version = "0.46.3", path = "." }
evm-core = { version = "0.46.3", path = "core", default-features = false }
evm-gasometer = { version = "0.46.3", path = "gasometer", default-features = false }
evm-runtime = { version = "0.46.3", path = "runtime", default-features = false }
primitive-types = { version = "0.13", default-features = false }
auto_impl = "1.0"
sha3 = { version = "0.10", default-features = false }
Expand Down Expand Up @@ -84,7 +84,7 @@ create-fixed = []
print-debug = ["evm-gasometer/print-debug"]

[workspace.package]
version = "0.46.2"
version = "0.46.3"
license = "Apache-2.0"
authors = ["Aurora Labs <[email protected]>", "Wei Tang <[email protected]>", "Parity Technologies <[email protected]>"]
description = "Portable Ethereum Virtual Machine implementation written in pure Rust."
Expand Down
1 change: 1 addition & 0 deletions benches/loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ fn run_loop_contract() {
// hex::decode("0f14a4060000000000000000000000000000000000000000000000000000000000002ee0").unwrap(),
u64::MAX,
Vec::new(),
Vec::new(),
);
}

Expand Down
19 changes: 12 additions & 7 deletions core/src/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@ use core::cmp::min;
use core::ops::{BitAnd, Not};
use primitive_types::{H256, U256};

/// A sequencial memory. It uses Rust's `Vec` for internal
/// A sequential memory. It uses Rust's `Vec` for internal
/// representation.
#[derive(Clone, Debug)]
pub struct Memory {
/// Memory data
data: Vec<u8>,
/// Memory effective length, that changed after resize operations.
effective_len: usize,
/// Memory limit
limit: usize,
}

Expand Down Expand Up @@ -59,7 +62,7 @@ impl Memory {
/// with 32 bytes as the step. If the length is zero, this function does nothing.
///
/// # Errors
/// Return `ExitError`
/// Return `ExitError::InvalidRange` if `offset + len` is overflow.
pub fn resize_offset(&mut self, offset: usize, len: usize) -> Result<(), ExitError> {
if len == 0 {
return Ok(());
Expand All @@ -73,7 +76,7 @@ impl Memory {
/// Resize the memory, making it cover to `end`, with 32 bytes as the step.
///
/// # Errors
/// Return `ExitError`
/// Return `ExitError::InvalidRange` if `end` value is overflow in `next_multiple_of_32` call.
pub fn resize_end(&mut self, end: usize) -> Result<(), ExitError> {
if end > self.effective_len {
let new_end = next_multiple_of_32(end).ok_or(ExitError::InvalidRange)?;
Expand Down Expand Up @@ -105,7 +108,7 @@ impl Memory {
ret
}

/// Get `H256` from a specific offset in memory.
/// Get `H256` value from a specific offset in memory.
#[must_use]
pub fn get_h256(&self, offset: usize) -> H256 {
let mut ret = [0; 32];
Expand All @@ -127,7 +130,7 @@ impl Memory {
/// untrusted.
///
/// # Errors
/// Return `ExitFatal`
/// Return `ExitFatal::NotSupported` if `offset + target_size` is out of memory limit or overflow.
pub fn set(
&mut self,
offset: usize,
Expand Down Expand Up @@ -166,7 +169,9 @@ impl Memory {
/// `copy_within` uses `memmove` to avoid `DoS` attacks.
///
/// # Errors
/// Return `ExitFatal`
/// Return `ExitFatal::Other`:
/// - `OverflowOnCopy` if `offset + length` is overflow
/// - `OutOfGasOnCopy` if `offst_length` out of memory limit
pub fn copy(
&mut self,
src_offset: usize,
Expand Down Expand Up @@ -200,7 +205,7 @@ impl Memory {
/// Copy `data` into the memory, of given `len`.
///
/// # Errors
/// Return `ExitFatal`
/// Return `ExitFatal::NotSupported` if `set()` call return out of memory limit.
pub fn copy_large(
&mut self,
memory_offset: usize,
Expand Down
Loading
Loading