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

Feat: EIP-7702 implementation #56

Open
wants to merge 31 commits into
base: feat/prague-hard-fork
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
3c4c1c1
Added Prague hard fork config
mrLSD Aug 7, 2024
226d7eb
EIP-7702 basic implementation, CI and tests changes
mrLSD Aug 27, 2024
956f879
Merge branch 'feat/prague-hard-fork' into feat/eip-7702
mrLSD Aug 27, 2024
9394615
Refactored Authorization. Added verifacations for Authorization behavior
mrLSD Sep 3, 2024
8392ed3
Delegation execution and refund gas cost calculation and configs
mrLSD Sep 5, 2024
61436c2
Extend EIP-7702 gas calculation
mrLSD Sep 7, 2024
7a9042a
Added authority code detection
mrLSD Sep 10, 2024
cfe8f97
Added state function for authority code
mrLSD Sep 11, 2024
b3b20af
Merge branch 'master' of github.com:aurora-is-near/sputnikvm into fea…
mrLSD Sep 11, 2024
c93995a
Caching for authority
mrLSD Sep 11, 2024
92e98c7
Merge branch 'feat/prague-hard-fork' of github.com:aurora-is-near/spu…
mrLSD Sep 11, 2024
350a3cf
Merge branch 'feat/prague-hard-fork' of github.com:aurora-is-near/spu…
mrLSD Sep 11, 2024
de9d0db
AUthority warm gas cost calculation
mrLSD Sep 12, 2024
49f6fef
Redactore IsPrecompile
mrLSD Sep 12, 2024
d021461
Update EVM configs
mrLSD Sep 12, 2024
d58aaf0
jsontests: added validation for EIP-7702
mrLSD Sep 16, 2024
e5f3085
Fix issies for AUthority validation and Shared state afte tests running
mrLSD Sep 18, 2024
7a66dd0
Refactore warm address logic for EIP-2929
mrLSD Sep 18, 2024
05b6444
Fix is-empty-code condition related to EIP-3607
mrLSD Sep 19, 2024
63fcdd9
Fixed Authority signature tests, Added Warm basic Caller, added CI fi…
mrLSD Sep 19, 2024
8f9334f
Refactore get_authority_target and loop detection
mrLSD Sep 20, 2024
108e9b8
Fix clippy
mrLSD Sep 20, 2024
a10a583
Remove type: IsPrecompileResult
mrLSD Sep 23, 2024
7795ae8
Merge branch 'feat/refactore-is-precompile' into feat/eip-7702
mrLSD Sep 23, 2024
a296920
Tests pass for EIP-7702 and fixes. Added Prague precompiles
mrLSD Sep 25, 2024
b287143
Fix Prague empty Create Contract issue
mrLSD Sep 25, 2024
cbdcc80
Clean up
mrLSD Sep 25, 2024
a870e25
PR prreview proposals changes
mrLSD Oct 7, 2024
f0d9742
Remove auth_list from CREATE
mrLSD Oct 7, 2024
e85303d
Refactore gas cost for create
mrLSD Oct 9, 2024
1e0cb99
Merge branch 'feat/prague-hard-fork' into feat/eip-7702
mrLSD Oct 15, 2024
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
16 changes: 13 additions & 3 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,21 @@ 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-3%40v1.5.0/fixtures_pectra-devnet-3.tar.gz
mkdir ethereum-spec-tests
tar -xzf fixtures_pectra-devnet-3.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/
# Temporally disable as EOFv1 not implemented
# ethtests/EIPTests/StateTests/

- name: Run Ethereum vm tests
run: |
Expand Down Expand Up @@ -134,8 +143,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
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
2 changes: 1 addition & 1 deletion core/src/stack.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::prelude::*;
use crate::prelude::Vec;
use crate::utils::USIZE_MAX;
use crate::ExitError;
use primitive_types::{H256, U256};
Expand Down
5 changes: 3 additions & 2 deletions evm-tests/ethjson/src/spec/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ pub enum ForkSpec {
Paris,
/// Shanghai (#17,034,870, 2023-04-12)
Shanghai,
/// Cancun (2024-03-13)
/// Cancun (28,750,000, 2024-03-13)
Cancun,
/// Prague-Electra—aka Pectra
/// Prague (future)
Prague,
}

Expand Down Expand Up @@ -118,6 +118,7 @@ impl TryFrom<String> for ForkSpec {
"paris" => Self::Paris,
"shanghai" => Self::Shanghai,
"cancun" => Self::Cancun,
"prague" => Self::Prague,
other => return Err(format!("Unknown hard fork spec {other}")),
};
Ok(res)
Expand Down
27 changes: 27 additions & 0 deletions evm-tests/ethjson/src/test_helpers/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ pub struct MultiTransaction {
pub blob_versioned_hashes: Vec<U256>,
/// EIP-4844
pub max_fee_per_blob_gas: Option<Uint>,

/// EIP-7702
#[serde(default)]
pub authorization_list: AuthorizationList,
}

impl MultiTransaction {
Expand Down Expand Up @@ -109,6 +113,7 @@ impl MultiTransaction {
v: Default::default(),
secret: self.secret,
access_list,
authorization_list: self.authorization_list.clone(),
}
}
}
Expand All @@ -127,6 +132,28 @@ pub struct AccessListTuple {
pub storage_keys: Vec<H256>,
}

/// EIP-7702 Authorization List
pub type AuthorizationList = Vec<AuthorizationItem>;
/// EIP-7702 Authorization item
#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AuthorizationItem {
/// Chain ID
pub chain_id: Uint,
/// Address to access
pub address: Address,
/// Keys (slots) to access at that address
pub nonce: Uint,
/// r signature
pub r: Uint,
/// s signature
pub s: Uint,
/// Parity
pub v: Uint,
/// Signer address
pub signer: Option<Address>,
}

/// State test indexes deserialization.
#[derive(Debug, PartialEq, Eq, Deserialize)]
pub struct PostStateIndexes {
Expand Down
4 changes: 4 additions & 0 deletions evm-tests/ethjson/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

//! Transaction deserialization.

use crate::test_helpers::state::AuthorizationList;
use crate::{
bytes::Bytes,
hash::{Address, H256},
Expand All @@ -33,6 +34,9 @@ pub struct Transaction {
/// Transaction access list (see EIP-2930).
#[serde(default)]
pub access_list: Vec<(Address, Vec<H256>)>,
/// Transaction authorization list (see EIP-7702`s).
#[serde(default)]
pub authorization_list: AuthorizationList,
/// Gas limit.
pub gas_limit: Uint,
/// To.
Expand Down
2 changes: 1 addition & 1 deletion evm-tests/jsontests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ rlp = "0.5"
sha3 = "0.10"
parity-bytes = "0.1"
env_logger = "0.11"
lazy_static = "1.4.0"
hex-literal = "0.4"

[features]
enable-slow-tests = []
1 change: 0 additions & 1 deletion evm-tests/jsontests/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,6 @@ fn run_test_for_file(
);
}
let file = File::open(file_name).expect("Open file failed");

let reader = BufReader::new(file);
let test_suite = serde_json::from_reader::<_, HashMap<String, statetests::Test>>(reader)
.expect("Parse test cases failed");
Expand Down
Loading
Loading