-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: calls to revm with database in typescript (#3182)
Co-authored-by: Franco Victorio <victorio.franco@gmail.com>
- Loading branch information
Showing
65 changed files
with
7,917 additions
and
1,349 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[alias] | ||
gen-execution-api = "run --bin tools -- gen-execution-api" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
*.sol linguist-language=Solidity | ||
# prevent github actions to checkout files with crlf line endings | ||
* -text | ||
* text=auto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
name: rethnet CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- $default-branch | ||
- "rethnet/main" | ||
paths: | ||
- "config/**" | ||
- "crates/**" | ||
- "Cargo.toml" | ||
- "rust-toolchain" | ||
pull_request: | ||
branches: ["**"] | ||
paths: | ||
- "config/**" | ||
- "crates/**" | ||
- "Cargo.toml" | ||
- "rust-toolchain" | ||
|
||
env: | ||
RUSTFLAGS: -Dwarnings | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
check: | ||
name: Check | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Install Rust (stable) | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
profile: minimal | ||
override: true | ||
|
||
- uses: Swatinem/rust-cache@v1 | ||
|
||
- name: Cargo check | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
command: check | ||
args: --all-targets | ||
|
||
test-js: | ||
name: Test Node.js | ||
runs-on: ${{ matrix.os }} | ||
needs: check | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: ["ubuntu-latest", "windows-latest", "macOS-latest"] | ||
include: | ||
- RUSTFLAGS: "-Dwarnings" | ||
- os: "windows-latest" | ||
RUSTFLAGS: "-Dwarnings -Ctarget-feature=+crt-static" | ||
defaults: | ||
run: | ||
working-directory: crates/rethnet_evm_napi | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: actions/setup-node@v2 | ||
with: | ||
node-version: 14 | ||
cache: yarn | ||
|
||
- name: Install node dependencies | ||
run: yarn --frozen-lockfile | ||
|
||
- name: Install Rust (stable) | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
profile: minimal | ||
override: true | ||
components: rustfmt | ||
|
||
- uses: Swatinem/rust-cache@v1 | ||
|
||
- name: Build | ||
run: yarn build | ||
|
||
- name: Test | ||
run: yarn test | ||
|
||
test-rs: | ||
name: Test Rust | ||
runs-on: ${{ matrix.os }} | ||
needs: check | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: ["ubuntu-latest", "windows-latest", "macOS-latest"] | ||
include: | ||
- RUSTFLAGS: "-Dwarnings" | ||
- os: "windows-latest" | ||
RUSTFLAGS: "-Dwarnings -Ctarget-feature=+crt-static" | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Install Rust (stable) | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
profile: minimal | ||
override: true | ||
components: rustfmt | ||
|
||
- uses: Swatinem/rust-cache@v1 | ||
|
||
- name: Doctests | ||
uses: actions-rs/cargo@v1 | ||
env: | ||
RUSTFLAGS: ${{ matrix.RUSTFLAGS }} | ||
with: | ||
command: test | ||
args: --doc --all-features | ||
|
||
- name: Install latest nextest release | ||
uses: taiki-e/install-action@nextest | ||
|
||
- name: Test with latest nextest release | ||
uses: actions-rs/cargo@v1 | ||
env: | ||
RUSTFLAGS: ${{ matrix.RUSTFLAGS }} | ||
CARGO_INCREMENTAL: ${{ matrix.CARGO_INCREMENTAL }} | ||
with: | ||
command: nextest | ||
args: run --all-features |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[workspace] | ||
members = [ | ||
"crates/*", | ||
] | ||
resolver = "2" | ||
|
||
[profile.dev] | ||
rpath = true | ||
|
||
[profile.release] | ||
rpath = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Rethnet | ||
|
||
[licence-badge]: https://img.shields.io/badge/license-MIT%20OR%20Apache--2.0-blue | ||
[license]: COPYRIGHT | ||
|
||
**Rethnet** is a debugging runtime for the Ethereum Virtual Machine (or EVM). It can be consumed as a Rust or as a Node.js native module. | ||
|
||
## Building from Source | ||
|
||
Make sure you have the following dependencies installed on your machine: | ||
|
||
- [Rust](https://www.rust-lang.org/tools/install) | ||
|
||
Rethnet is part of the [Hardhat monorepo](https://github.com/NomicFoundation/hardhat). Clone the source code using ssh: | ||
|
||
```bash | ||
git clone git@github.com:NomicFoundation/hardhat.git | ||
``` | ||
|
||
or https: | ||
|
||
```bash | ||
git clone https://github.com/NomicFoundation/hardhat.git | ||
``` | ||
|
||
Use `cargo` to build a release version: | ||
|
||
```bash | ||
cd hardhat | ||
cargo build --release | ||
``` | ||
|
||
## Building a Node.js native module | ||
|
||
Make sure you have the following dependencies installed on your machine: | ||
|
||
- [node.js](https://nodejs.org) | ||
|
||
Use `npm` (or `yarn`) to build a release version: | ||
|
||
```bash | ||
cd crates/rethnet_evm_napi | ||
npm run build | ||
# yarn build | ||
``` | ||
|
||
## Contributing | ||
|
||
Rethnet is still under development by [Nomic Foundation](https://github.com/NomicFoundation/). As such, progress is being merged with the `rethnet/main` branch until its first release. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[package] | ||
name = "eth_execution_api" | ||
version = "1.0.0-beta.1" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
derive_builder = { version = "0.11.2", default-features = false } | ||
serde = { version = "1.0.145", default-features = false, features = ["derive"] } | ||
serde_json = { version = "1.0.85", default-features = false, features = ["alloc"] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
pub fn add(left: usize, right: usize) -> usize { | ||
left + right | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
|
||
#[test] | ||
fn it_works() { | ||
let result = add(2, 2); | ||
assert_eq!(result, 4); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[package] | ||
name = "rethnet" | ||
version = "0.1.0-dev" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
anyhow = "1.0.65" | ||
clap = { version = "3.2.22", default-features = false, features = ["std", "derive"] } | ||
pretty_env_logger = { version = "0.4.0", default-features = false } | ||
|
||
[dev-dependencies.cargo-husky] | ||
version = "1.5.0" | ||
default-features = false | ||
features = ["precommit-hook", "run-cargo-test", "run-cargo-fmt", "run-cargo-clippy", "run-for-all"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
use std::ffi::OsString; | ||
|
||
use clap::{Parser, Subcommand}; | ||
|
||
#[derive(Parser)] | ||
#[clap(author, version, about, long_about = None)] | ||
struct Args { | ||
#[clap(subcommand)] | ||
command: Command, | ||
} | ||
|
||
#[derive(Subcommand)] | ||
#[allow(clippy::large_enum_variant)] | ||
enum Command { | ||
Start, | ||
} | ||
|
||
#[derive(Copy, Debug, Clone, PartialEq, Eq)] | ||
pub enum ExitStatus { | ||
Success, | ||
Error, | ||
} | ||
|
||
impl From<bool> for ExitStatus { | ||
fn from(value: bool) -> Self { | ||
if value { | ||
ExitStatus::Success | ||
} else { | ||
ExitStatus::Error | ||
} | ||
} | ||
} | ||
|
||
pub fn run_with_args<T, I>(args: I) -> Result<ExitStatus, anyhow::Error> | ||
where | ||
I: IntoIterator<Item = T>, | ||
T: Into<OsString> + Clone, | ||
{ | ||
let args = Args::parse_from(args); | ||
match args.command { | ||
Command::Start => { | ||
println!("Hello, world!"); | ||
Ok(ExitStatus::Success) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
use rethnet::{run_with_args, ExitStatus}; | ||
|
||
/// Main entry point for the `rethnet` executable. | ||
fn main() -> anyhow::Result<()> { | ||
pretty_env_logger::try_init()?; | ||
|
||
let status = run_with_args(std::env::args_os()).unwrap(); | ||
match status { | ||
ExitStatus::Success => (), | ||
ExitStatus::Error => std::process::exit(1), | ||
} | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[package] | ||
name = "rethnet_evm" | ||
version = "0.1.0-dev" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
anyhow = { version = "1.0.64", default-features = false, features = ["std"] } | ||
bytes = { version = "1.2.1", default-features = false } | ||
hashbrown = { version = "0.12.3", default-features = false, features = ["serde"] } | ||
log = { version = "0.4.17", default-features = false } | ||
primitive-types = { version = "0.11.1", default-features = false, features = ["impl-serde"] } | ||
revm = { git = "https://github.com/bluealloy/revm/", version = "2.1.0", default-features = false, features = ["dev", "k256", "with-serde"] } | ||
sha3 = { version = "0.10.4", default-features = false } | ||
tokio = { version = "1.21.2", default-features = false, features = ["sync"] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub mod layered_db; |
Oops, something went wrong.