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

chore: release v1.0.0 #1

Closed
wants to merge 4 commits into from
Closed
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
15 changes: 10 additions & 5 deletions bins/revme/src/cmd/statetest/merkle_trie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,19 @@ pub fn state_merkle_trie_root<'a>(
accounts: impl IntoIterator<Item = (Address, &'a PlainAccount)>,
) -> B256 {
trie_root(accounts.into_iter().map(|(address, acc)| {
(
address,
alloy_rlp::encode_fixed_size(&TrieAccount::new(acc)),
)
let t = TrieAccount::new(acc);
let s: Vec<_> = acc.storage.iter().filter(|(_k, &v)| !v.is_zero()).collect();
println!("@ {address:?}:");
for (k, v) in s {
// TODOFEE
println!(" {k:?}: {:X?}", v.to_be_bytes::<32>());
}
println!("");
(address, alloy_rlp::encode_fixed_size(&t))
}))
}

#[derive(RlpEncodable, RlpMaxEncodedLen)]
#[derive(Debug, RlpEncodable, RlpMaxEncodedLen)]
struct TrieAccount {
nonce: u64,
balance: U256,
Expand Down
197 changes: 197 additions & 0 deletions bins/revme/src/cmd/statetest/models/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
mod deserializer;
mod spec;

use deserializer::*;

pub use spec::SpecName;

use revm::{
primitives::{Address, Bytes, HashMap, B256, U256},
specification::{
eip2930::AccessList,
eip7702::{Authorization, Parity, RecoveredAuthorization, Signature},
},
};
use serde::{Deserialize, Serialize};
use std::collections::BTreeMap;

#[derive(Debug, PartialEq, Eq, Deserialize)]
pub struct TestSuite(pub BTreeMap<String, TestUnit>);

#[derive(Debug, PartialEq, Eq, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct TestUnit {
/// Test info is optional
#[serde(default, rename = "_info")]
pub info: Option<serde_json::Value>,

pub env: Env,
pub pre: HashMap<Address, AccountInfo>,
pub post: BTreeMap<SpecName, Vec<Test>>,
pub transaction: TransactionParts,
#[serde(default)]
pub out: Option<Bytes>,
}

/// State test indexed state result deserialization.
#[derive(Debug, PartialEq, Eq, Deserialize)]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
pub struct Test {
pub expect_exception: Option<String>,

/// Indexes
pub indexes: TxPartIndices,
/// Post state hash
pub hash: B256,
/// Post state
#[serde(default)]
pub post_state: HashMap<Address, AccountInfo>,

/// Logs root
pub logs: B256,

/// Tx bytes
pub txbytes: Option<Bytes>,
}

#[derive(Debug, PartialEq, Eq, Deserialize)]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
pub struct TxPartIndices {
pub data: usize,
pub gas: usize,
pub value: usize,
}

#[derive(Clone, Debug, PartialEq, Eq, Deserialize)]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
pub struct AccountInfo {
pub balance: U256,
pub code: Bytes,
#[serde(deserialize_with = "deserialize_str_as_u64")]
pub nonce: u64,
pub storage: HashMap<U256, U256>,
}

#[derive(Debug, PartialEq, Eq, Deserialize)]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
pub struct Env {
pub current_coinbase: Address,
#[serde(default)]
pub current_difficulty: U256,
pub current_gas_limit: U256,
pub current_number: U256,
pub current_timestamp: U256,
pub current_base_fee: Option<U256>,
pub previous_hash: Option<B256>,

pub current_random: Option<B256>,
pub current_beacon_root: Option<B256>,
pub current_withdrawals_root: Option<B256>,

pub parent_blob_gas_used: Option<U256>,
pub parent_excess_blob_gas: Option<U256>,
pub current_excess_blob_gas: Option<U256>,
}

#[derive(Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct TransactionParts {
pub data: Vec<Bytes>,
pub gas_limit: Vec<U256>,
pub gas_price: Option<U256>,
pub nonce: U256,
pub secret_key: B256,
/// if sender is not present we need to derive it from secret key.
#[serde(default)]
pub sender: Option<Address>,
#[serde(default, deserialize_with = "deserialize_maybe_empty")]
pub to: Option<Address>,
pub value: Vec<U256>,
pub max_fee_per_gas: Option<U256>,
pub max_priority_fee_per_gas: Option<U256>,

#[serde(default)]
pub access_lists: Vec<Option<AccessList>>,
pub authorization_list: Option<Vec<TestAuthorization>>,
#[serde(default)]
pub blob_versioned_hashes: Vec<B256>,
pub max_fee_per_blob_gas: Option<U256>,
}

#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone, Copy)]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
pub struct TestAuthorization {
chain_id: U256,
address: Address,
nonce: U256,
v: U256,
r: U256,
s: U256,
signer: Option<Address>,
}

impl TestAuthorization {
pub fn signature(&self) -> Signature {
let v = u64::try_from(self.v).unwrap_or(u64::MAX);
let parity = Parity::try_from(v).unwrap_or(Parity::Eip155(36));
Signature::from_rs_and_parity(self.r, self.s, parity).unwrap()
}

pub fn into_recovered(self) -> RecoveredAuthorization {
let authorization = Authorization {
chain_id: self.chain_id,
address: self.address,
nonce: u64::try_from(self.nonce).unwrap(),
};
let authority = self
.signature()
.recover_address_from_prehash(&authorization.signature_hash())
.ok();
RecoveredAuthorization::new_unchecked(
authorization.into_signed(self.signature()),
authority,
)
}
}

#[cfg(test)]
mod tests {
use super::*;
use serde_json::Error;

#[test]
pub fn serialize_u256() -> Result<(), Error> {
let json = r#"{"_item":"0x10"}"#;

#[derive(Deserialize, Debug)]
pub struct Test {
_item: Option<U256>,
}

let out: Test = serde_json::from_str(json)?;
println!("out:{out:?}");
Ok(())
}

#[test]
pub fn deserialize_minimal_transaction_parts() -> Result<(), Error> {
let json = r#"{"data":[],"gasLimit":[],"nonce":"0x0","secretKey":"0x0000000000000000000000000000000000000000000000000000000000000000","to":"","value":[]}"#;

let _: TransactionParts = serde_json::from_str(json)?;
Ok(())
}

#[test]
pub fn serialize_b160() -> Result<(), Error> {
let json = r#"{"_item":"0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"}"#;

#[derive(Deserialize, Debug)]
pub struct Test {
_item: Address,
}

let out: Test = serde_json::from_str(json)?;
println!("out:{out:?}");
Ok(())
}
}
8 changes: 8 additions & 0 deletions bins/revme/src/cmd/statetest/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ fn check_evm_execution(
spec: SpecId,
print_json_outcome: bool,
) -> Result<(), TestErrorKind> {
// for acc in evm.context.evm.db.cache.trie_account() {
// println!("# {:?} [{:?}]", acc, acc.1.storage.len());
// }
let logs_root = log_rlp_hash(exec_result.as_ref().map(|r| r.logs()).unwrap_or_default());
let state_root = state_merkle_trie_root(db.cache.trie_account());

Expand Down Expand Up @@ -264,6 +267,10 @@ pub fn execute_test_suite(
})?;

for (name, unit) in suite.0 {
if name != "tests/prague/eip7702_set_code_tx/test_set_code_txs.py::test_contract_creating_set_code_transaction[fork_Prague-state_test]" {
// continue;
}

// Create database and insert cache
let mut cache_state = database::CacheState::new(false);
for (address, info) in unit.pre {
Expand Down Expand Up @@ -429,6 +436,7 @@ pub fn execute_test_suite(

let timer = Instant::now();
let res = evm.exec_commit();
println!("RES: {res:?}\n");
*elapsed.lock().unwrap() += timer.elapsed();

let spec = cfg.spec();
Expand Down
83 changes: 83 additions & 0 deletions crates/bytecode/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [1.0.0](https://github.com/mrLSD/revm/releases/tag/revm-bytecode-v1.0.0) - 2024-12-27

### Added

- *(database)* implement order-independent equality for Reverts (#1827)
- Restucturing Part7 Handler and Context rework (#1865)
- restructuring Part6 transaction crate (#1814)
- Merge validation/analyzis with Bytecode (#1793)
- restructure Part2 database crate (#1784)
- project restructuring Part1 (#1776)
- *(examples)* generate block traces (#895)
- implement EIP-4844 (#668)
- *(Shanghai)* All EIPs: push0, warm coinbase, limit/measure initcode (#376)
- Migrate `primitive_types::U256` to `ruint::Uint<256, 4>` (#239)
- Introduce ByteCode format, Update Readme (#156)

### Fixed

- fix typos ([#620](https://github.com/mrLSD/revm/pull/620))

### Other

- fix comments and docs into more sensible (#1920)
- *(crates/bytecode)* fix some comments (#1851)
- some no_std cleanup (#1834)
- fix `constants` module typo (#1801)
- Bump new logo (#1735)
- *(README)* add rbuilder to used-by (#1585)
- added simular to used-by (#1521)
- add Trin to used by list (#1393)
- Fix typo in readme ([#1185](https://github.com/mrLSD/revm/pull/1185))
- Add Hardhat to the "Used by" list ([#1164](https://github.com/mrLSD/revm/pull/1164))
- Add VERBS to used by list ([#1141](https://github.com/mrLSD/revm/pull/1141))
- license date and revm docs (#1080)
- *(docs)* Update the benchmark docs to point to revm package (#906)
- *(docs)* Update top-level benchmark docs (#894)
- clang requirement (#784)
- Readme Updates (#756)
- Logo (#743)
- book workflow ([#537](https://github.com/mrLSD/revm/pull/537))
- add example to revm crate ([#468](https://github.com/mrLSD/revm/pull/468))
- Update README.md ([#424](https://github.com/mrLSD/revm/pull/424))
- add no_std to primitives ([#366](https://github.com/mrLSD/revm/pull/366))
- revm-precompiles to revm-precompile
- Bump v20, changelog ([#350](https://github.com/mrLSD/revm/pull/350))
- typos (#232)
- Add support for old forks. ([#191](https://github.com/mrLSD/revm/pull/191))
- revm bump 1.8. update libs. snailtracer rename ([#159](https://github.com/mrLSD/revm/pull/159))
- typo fixes
- fix readme typo
- Big Refactor. Machine to Interpreter. refactor instructions. call/create struct ([#52](https://github.com/mrLSD/revm/pull/52))
- readme. debuger update
- Bump revm v0.3.0. README updated
- readme
- Add time elapsed for tests
- readme updated
- Include Basefee into cost calc. readme change
- Initialize precompile accounts
- Status update. Taking a break
- Merkle calc. Tweaks and debugging for eip158
- Replace aurora bn lib with parity's. All Bn128Add/Mul/Pair tests passes
- TEMP
- one tab removed
- readme
- README Example simplified
- Gas calculation for Call/Create. Example Added
- readme usage
- README changes
- Static gas cost added
- Subroutine changelogs and reverts
- Readme postulates
- Spelling
- Restructure project
- First iteration. Machine is looking okay
Loading