Skip to content

Commit

Permalink
rewrite geth_utils with go.work (#875)
Browse files Browse the repository at this point in the history
* Remove assembly in geth-utils (privacy-scaling-explorations#1553)

Remove geth-utils and examples.

New feature (non-breaking change which adds functionality)

- Assembly was introduced in #91 to build examples to use geth-util. It
was not used elsewhere in the codebase.
- The examples are removed as we currently don't use geth-util like the
way the examples show. (Note that the examples also fail to run now. The
transactions in the examples would fail because the trace config
defaults to a 0 block gas limit. It runs after adding a block gas
limit.)
- I found those examples unused when reviewing how we use the tracing
API. It is much easier to review the tracing code after removing the
Assembly.
- The Readme mentioned a TODO CLI, which we never built. I think it
might be interesting to create a good first issue for people to extend
testool(https://github.com/privacy-scaling-explorations/zkevm-circuits/blob/690b2f143a94b7474f0c99493a99b0f2c53d93b8/testool/README.md#L38)
for it.

* rewrite geth_utils with go.work

* fix make doc

---------

Co-authored-by: Chih Cheng Liang <chihchengliang@gmail.com>
  • Loading branch information
lispc and ChihChengLiang authored Sep 2, 2023
1 parent 13aaee3 commit 47236ff
Show file tree
Hide file tree
Showing 18 changed files with 215 additions and 920 deletions.
13 changes: 0 additions & 13 deletions geth-utils/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,6 @@

The module `gethutil` tried to provide identical output from APIs `debug_trace*` of latest `geth` as test vectors for [`zkevm-circuits`](https://github.com/privacy-scaling-explorations/zkevm-circuits).

## Usage

<!-- ### CLI Usage -->
<!-- TODO: Implement a CLI to consume bytecode and output logs -->

### Library Usage

For [`./example/mstore_mload.go`](./example/mstore_mload.go) as an example, it defines bytecode directly by builder `asm`, then write the logs produced by `TraceTx` to stdout. To reproduce the logs, run:

```bash
go run ./example/mstore_mload.go > ./mstore_mload.json
```

### Debugging

The execution traces returned by geth omit some information like execution
Expand Down
25 changes: 7 additions & 18 deletions geth-utils/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,16 @@ fn main() {
// Build
let mut build = gobuild::Build::new();
let target_files = if cfg!(feature = "scroll") {
vec![
"./l2geth/asm.go",
"./l2geth/trace.go",
"./l2geth/util.go",
"./l2geth/lib.go",
]
vec!["./l2geth/trace.go", "./l2geth/lib.go"]
} else {
vec!["./lib/lib.go"]
vec!["./l1geth/trace.go", "./l1geth/lib.go"]
};

// Replace to a custom go-ethereum for scroll.
#[cfg(feature = "scroll")]
build.modfile("./l2geth/go.mod");

if let Err(e) = build.files(target_files).try_compile(lib_name) {
// The error type is private so have to check the error string
if format!("{e}").starts_with("Failed to find tool.") {
fail(
" Failed to find Go. Please install Go 1.16 or later \
" Failed to find Go. Please install Go 1.18 or later \
following the instructions at https://golang.org/doc/install.
On linux it is also likely available as a package."
.to_string(),
Expand All @@ -41,19 +32,17 @@ fn main() {
// Files the lib depends on that should recompile the lib
let dep_files = if cfg!(feature = "scroll") {
vec![
"./l2geth/asm.go",
"./l2geth/trace.go",
"./l2geth/util.go",
"./l2geth/lib.go",
"./l2geth/go.mod",
"./l2geth/go.sum",
]
} else {
vec![
"./gethutil/asm.go",
"./gethutil/trace.go",
"./gethutil/util.go",
"./go.mod",
"./l1geth/trace.go",
"./l1geth/lib.go",
"./l1geth/go.mod",
"./l1geth/go.sum",
]
};

Expand Down
31 changes: 0 additions & 31 deletions geth-utils/example/add_sub.go

This file was deleted.

31 changes: 0 additions & 31 deletions geth-utils/example/msize.go

This file was deleted.

31 changes: 0 additions & 31 deletions geth-utils/example/mstore_mload.go

This file was deleted.

31 changes: 0 additions & 31 deletions geth-utils/example/sstore_sload.go

This file was deleted.

Loading

0 comments on commit 47236ff

Please sign in to comment.