Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into feat/eip4844
Browse files Browse the repository at this point in the history
  • Loading branch information
Wodann committed May 6, 2024
2 parents b69426c + 2147d6b commit 3168821
Show file tree
Hide file tree
Showing 47 changed files with 562 additions and 211 deletions.
5 changes: 5 additions & 0 deletions .changeset/nasty-teachers-brush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@nomicfoundation/edr": patch
---

Fixed `smock.fake` causing a panic
10 changes: 6 additions & 4 deletions .github/workflows/edr-npm-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,9 @@ jobs:
run: ls -R .
shell: bash
- name: Test bindings
run: docker run --rm -v $(pwd):/build -w /build/crates/edr_napi node:${{ matrix.node }} bash -c "wget -qO- 'https://unpkg.com/@pnpm/self-installer' | node; pnpm testNoBuild"
# Setting CI=1 is important to make PNPM install non-interactive
# https://github.com/pnpm/pnpm/issues/6615#issuecomment-1656945689
run: docker run --rm -e CI=1 -v $(pwd):/build -w /build/crates/edr_napi node:${{ matrix.node }} bash -c "wget -qO- 'https://unpkg.com/@pnpm/self-installer' | node; pnpm testNoBuild"
test-linux-x64-musl-binding:
name: Test bindings on x86_64-unknown-linux-musl - node@${{ matrix.node }}
needs:
Expand Down Expand Up @@ -255,7 +257,7 @@ jobs:
run: ls -R .
shell: bash
- name: Test bindings
run: docker run --rm -v $(pwd):/build -w /build/crates/edr_napi node:${{ matrix.node }}-alpine sh -c "wget -qO- 'https://unpkg.com/@pnpm/self-installer' | node; pnpm testNoBuild"
run: docker run --rm -e CI=1 -v $(pwd):/build -w /build/crates/edr_napi node:${{ matrix.node }}-alpine sh -c "wget -qO- 'https://unpkg.com/@pnpm/self-installer' | node; pnpm testNoBuild"
test-linux-aarch64-gnu-binding:
name: Test bindings on aarch64-unknown-linux-gnu - node@${{ matrix.node }}
needs:
Expand Down Expand Up @@ -294,7 +296,7 @@ jobs:
uses: addnab/docker-run-action@v3
with:
image: node:${{ matrix.node }}
options: "--platform linux/arm64 -v ${{ github.workspace }}:/build -w /build/crates/edr_napi"
options: "--platform linux/arm64 -v ${{ github.workspace }}:/build -w /build/crates/edr_napi -e CI=1"
run: |
wget -qO- 'https://unpkg.com/@pnpm/self-installer' | node
set -e
Expand Down Expand Up @@ -332,7 +334,7 @@ jobs:
uses: addnab/docker-run-action@v3
with:
image: node:lts-alpine
options: "--platform linux/arm64 -v ${{ github.workspace }}:/build -w /build/crates/edr_napi"
options: "--platform linux/arm64 -v ${{ github.workspace }}:/build -w /build/crates/edr_napi -e CI=1"
run: |
wget -qO- 'https://unpkg.com/@pnpm/self-installer' | node
set -e
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/hardhat-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
DO_NOT_SET_THIS_ENV_VAR____IS_HARDHAT_CI: true
FORCE_COLOR: 3
NODE_OPTIONS: --max-old-space-size=4096
run: cd hardhat-tests && pnpm test
run: cd hardhat-tests && pnpm test:ci
lint-hardhat-tests:
name: Lint Hardhat tests
runs-on: ubuntu-latest
Expand Down
22 changes: 21 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1 +1,21 @@
SEE LICENSE IN EACH PACKAGE'S LICENSE FILE
MIT License

Copyright (c) 2021 Nomic Foundation

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
30 changes: 30 additions & 0 deletions book/src/01_getting_started/05_profiling.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,35 @@
# Profiling

## Perf/DTrace

The [cargo-flamegraph](https://github.com/flamegraph-rs/flamegraph) tool can be used to collect performance profiling data using [perf](https://en.wikipedia.org/wiki/Perf_(Linux)) on Linux and [DTrace](https://en.wikipedia.org/wiki/DTrace) on MacOS/Windows and then visualize it as a flamegraph.
This only works when executing `edr` from Rust, so it's mostly used to profile the [scenarios](../02_development/01_tools.md#scenarios) in the repository.

## Instructions

Install the `cargo-flamegraph` tool by running:

```bash
cargo install flamegraph
```

(If you're on Linux, check the [readme](https://github.com/flamegraph-rs/flamegraph?tab=readme-ov-file#installation) for distro specific instructions.)

Then create the flamegraph from the repo root, for example for the `seaport` scenario with:

```bash
CARGO_PROFILE_RELEASE_DEBUG=true cargo flamegraph -o flamegraph_seaport.svg --root --release -- scenario crates/tools/scenarios/neptune-mutual-blue-protocol_8db6480.jsonl.gz
```

The flamegraph will be saved to `flamegraph_seaport.svg`.

## Event Tracing

It's possible to profile the execution of `edr` by collecting [execution traces](https://docs.rs/tracing/latest/tracing/) and then turning them into flamegraphs.
This has the advantage that the contents of the flamegraph can be filtered on the tracing level, and it works when EDR is ran from JS.

### Instructions

```bash
pnpm build:tracing
```
Expand Down
1 change: 1 addition & 0 deletions crates/edr_defaults/LICENSE
1 change: 1 addition & 0 deletions crates/edr_eth/LICENSE
4 changes: 2 additions & 2 deletions crates/edr_eth/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
//! transaction related data
mod fake_signature;
mod kind;
/// Types for transaction gossip (aka pooled transactions)
pub mod pooled;
mod request;
mod signed;
mod r#type;

pub use revm_primitives::alloy_primitives::TxKind;
use revm_primitives::B256;

pub use self::{kind::TransactionKind, r#type::TransactionType, request::*, signed::*};
pub use self::{r#type::TransactionType, request::*, signed::*};
use crate::{access_list::AccessListItem, Address, Bytes, U256};

pub trait Transaction {
Expand Down
67 changes: 0 additions & 67 deletions crates/edr_eth/src/transaction/kind.rs

This file was deleted.

10 changes: 5 additions & 5 deletions crates/edr_eth/src/transaction/pooled.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ mod tests {
use super::*;
use crate::{
signature::Signature,
transaction::{Eip4844SignedTransaction, TransactionKind},
transaction::{Eip4844SignedTransaction, TxKind},
Address, Bytes, B256, U256,
};

Expand Down Expand Up @@ -217,7 +217,7 @@ mod tests {
nonce: 0,
gas_price: U256::from(1),
gas_limit: 2,
kind: TransactionKind::Call(Address::default()),
kind: TxKind::Call(Address::default()),
value: U256::from(3),
input: Bytes::from(vec![1, 2]),
signature: Signature {
Expand All @@ -232,7 +232,7 @@ mod tests {
nonce: 0,
gas_price: U256::from(1),
gas_limit: 2,
kind: TransactionKind::Create,
kind: TxKind::Create,
value: U256::from(3),
input: Bytes::from(vec![1, 2]),
signature: Signature {
Expand All @@ -248,7 +248,7 @@ mod tests {
nonce: 0,
gas_price: U256::from(1),
gas_limit: 2,
kind: TransactionKind::Call(Address::random()),
kind: TxKind::Call(Address::random()),
value: U256::from(3),
input: Bytes::from(vec![1, 2]),
odd_y_parity: true,
Expand All @@ -264,7 +264,7 @@ mod tests {
max_priority_fee_per_gas: U256::from(1),
max_fee_per_gas: U256::from(2),
gas_limit: 3,
kind: TransactionKind::Create,
kind: TxKind::Create,
value: U256::from(4),
input: Bytes::from(vec![1, 2]),
access_list: vec![].into(),
Expand Down
10 changes: 4 additions & 6 deletions crates/edr_eth/src/transaction/request/eip155.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ use revm_primitives::keccak256;

use crate::{
signature::{Signature, SignatureError},
transaction::{
fake_signature::make_fake_signature, kind::TransactionKind, signed::Eip155SignedTransaction,
},
transaction::{fake_signature::make_fake_signature, signed::Eip155SignedTransaction, TxKind},
Address, Bytes, B256, U256,
};

Expand All @@ -18,7 +16,7 @@ pub struct Eip155TransactionRequest {
pub nonce: u64,
pub gas_price: U256,
pub gas_limit: u64,
pub kind: TransactionKind,
pub kind: TxKind,
pub value: U256,
pub input: Bytes,
pub chain_id: u64,
Expand Down Expand Up @@ -142,7 +140,7 @@ mod tests {
nonce: 1,
gas_price: U256::from(2),
gas_limit: 3,
kind: TransactionKind::Call(to),
kind: TxKind::Call(to),
value: U256::from(4),
input: Bytes::from(input),
chain_id: 1,
Expand Down Expand Up @@ -182,7 +180,7 @@ mod tests {
nonce: 0,
gas_price: U256::from(678_912),
gas_limit: 30_000,
kind: TransactionKind::Call("0xb5bc06d4548a3ac17d72b372ae1e416bf65b8ead".parse()?),
kind: TxKind::Call("0xb5bc06d4548a3ac17d72b372ae1e416bf65b8ead".parse()?),
value: U256::from(1),
input: Bytes::default(),
chain_id: 123,
Expand Down
13 changes: 5 additions & 8 deletions crates/edr_eth/src/transaction/request/eip1559.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ use revm_primitives::keccak256;
use crate::{
access_list::AccessListItem,
signature::{Signature, SignatureError},
transaction::{
fake_signature::make_fake_signature, kind::TransactionKind,
signed::Eip1559SignedTransaction,
},
transaction::{fake_signature::make_fake_signature, signed::Eip1559SignedTransaction, TxKind},
utils::envelop_bytes,
Address, Bytes, B256, U256,
};
Expand All @@ -23,7 +20,7 @@ pub struct Eip1559TransactionRequest {
pub max_priority_fee_per_gas: U256,
pub max_fee_per_gas: U256,
pub gas_limit: u64,
pub kind: TransactionKind,
pub kind: TxKind,
pub value: U256,
pub input: Bytes,
pub access_list: Vec<AccessListItem>,
Expand Down Expand Up @@ -114,7 +111,7 @@ pub(crate) mod tests {
max_priority_fee_per_gas: U256::from(2),
max_fee_per_gas: U256::from(5),
gas_limit: 3,
kind: TransactionKind::Call(to),
kind: TxKind::Call(to),
value: U256::from(4),
input: Bytes::from(input),
access_list: vec![AccessListItem {
Expand Down Expand Up @@ -150,7 +147,7 @@ pub(crate) mod tests {
max_priority_fee_per_gas: U256::ZERO,
max_fee_per_gas: U256::ZERO,
gas_limit: 0,
kind: TransactionKind::Create,
kind: TxKind::Create,
value: U256::ZERO,
input: Bytes::new(),
access_list: vec![],
Expand Down Expand Up @@ -182,7 +179,7 @@ pub(crate) mod tests {
max_priority_fee_per_gas: U256::from(2),
max_fee_per_gas: U256::from(12),
gas_limit: 30_000,
kind: TransactionKind::Call("0xb5bc06d4548a3ac17d72b372ae1e416bf65b8ead".parse()?),
kind: TxKind::Call("0xb5bc06d4548a3ac17d72b372ae1e416bf65b8ead".parse()?),
value: U256::from(1),
input: Bytes::default(),
access_list: vec![],
Expand Down
11 changes: 4 additions & 7 deletions crates/edr_eth/src/transaction/request/eip2930.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ use revm_primitives::keccak256;
use crate::{
access_list::AccessListItem,
signature::{Signature, SignatureError},
transaction::{
fake_signature::make_fake_signature, kind::TransactionKind,
signed::Eip2930SignedTransaction,
},
transaction::{fake_signature::make_fake_signature, signed::Eip2930SignedTransaction, TxKind},
utils::envelop_bytes,
Address, Bytes, B256, U256,
};
Expand All @@ -22,7 +19,7 @@ pub struct Eip2930TransactionRequest {
pub nonce: u64,
pub gas_price: U256,
pub gas_limit: u64,
pub kind: TransactionKind,
pub kind: TxKind,
pub value: U256,
pub input: Bytes,
pub access_list: Vec<AccessListItem>,
Expand Down Expand Up @@ -111,7 +108,7 @@ mod tests {
nonce: 1,
gas_price: U256::from(2),
gas_limit: 3,
kind: TransactionKind::Call(to),
kind: TxKind::Call(to),
value: U256::from(4),
input: Bytes::from(input),
access_list: vec![AccessListItem {
Expand Down Expand Up @@ -157,7 +154,7 @@ mod tests {
nonce: 0,
gas_price: U256::from(1),
gas_limit: 30_000,
kind: TransactionKind::Call("0xb5bc06d4548a3ac17d72b372ae1e416bf65b8ead".parse()?),
kind: TxKind::Call("0xb5bc06d4548a3ac17d72b372ae1e416bf65b8ead".parse()?),
value: U256::from(1),
input: Bytes::default(),
access_list: vec![AccessListItem {
Expand Down
Loading

0 comments on commit 3168821

Please sign in to comment.