Skip to content

Commit 88349c6

Browse files
feat: add mux tracer for native call tracer and native prestate tracers (#615)
* hack to use native tracers * update * fix * add prestate * fix marshal * format * draft * move * separate `MuxTracer` * fix * update miner/worker.go * update api * rename * remove * bump go version * bump golangci * goimports lint * fix tests * minor * clean up * fix tests * sync error handling * bump go version in Dockerfiles * bump version * lint: disable `goconst` & `goimports` * bump version again * add comments --------- Co-authored-by: lightsing <light.tsing@gmail.com>
1 parent fc06826 commit 88349c6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+908
-472
lines changed

.github/workflows/l2geth_ci.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- name: Install Go
2121
uses: actions/setup-go@v2
2222
with:
23-
go-version: 1.18.x
23+
go-version: 1.20.x
2424
- name: Checkout code
2525
uses: actions/checkout@v2
2626
- name: Build
@@ -33,7 +33,7 @@ jobs:
3333
- name: Install Go
3434
uses: actions/setup-go@v2
3535
with:
36-
go-version: 1.19.x
36+
go-version: 1.20.x
3737
- name: Install rust
3838
uses: actions-rs/toolchain@v1
3939
with:
@@ -55,7 +55,7 @@ jobs:
5555
- name: Install Go
5656
uses: actions/setup-go@v2
5757
with:
58-
go-version: 1.18.x
58+
go-version: 1.20.x
5959
- name: Checkout code
6060
uses: actions/checkout@v2
6161
- name: Lint
@@ -69,7 +69,7 @@ jobs:
6969
- name: Install Go
7070
uses: actions/setup-go@v2
7171
with:
72-
go-version: 1.18.x
72+
go-version: 1.20.x
7373
- name: Install goimports
7474
run: go install golang.org/x/tools/cmd/goimports@latest
7575
- name: Checkout code
@@ -89,7 +89,7 @@ jobs:
8989
- name: Install Go
9090
uses: actions/setup-go@v2
9191
with:
92-
go-version: 1.18.x
92+
go-version: 1.20.x
9393
- name: Checkout code
9494
uses: actions/checkout@v2
9595
- name: Test

.golangci.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ linters:
1313
disable-all: true
1414
enable:
1515
- deadcode
16-
- goconst
17-
- goimports
16+
# - goconst
17+
# - goimports
1818
- gosimple
1919
- govet
2020
- ineffassign

Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ARG VERSION=""
44
ARG BUILDNUM=""
55

66
# Build libzkp dependency
7-
FROM scrolltech/go-rust-builder:go-1.19-rust-nightly-2022-12-10 as chef
7+
FROM scrolltech/go-rust-builder:go-1.20-rust-nightly-2022-12-10 as chef
88
WORKDIR app
99

1010
FROM chef as planner
@@ -21,7 +21,7 @@ RUN cargo build --release
2121
RUN find ./ | grep libzktrie.so | xargs -I{} cp {} /app/target/release/
2222

2323
# Build Geth in a stock Go builder container
24-
FROM scrolltech/go-rust-builder:go-1.19-rust-nightly-2022-12-10 as builder
24+
FROM scrolltech/go-rust-builder:go-1.20-rust-nightly-2022-12-10 as builder
2525

2626
ADD . /go-ethereum
2727
COPY --from=zkp-builder /app/target/release/libzkp.so /usr/local/lib/

Dockerfile.alltools

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ARG VERSION=""
44
ARG BUILDNUM=""
55

66
# Build Geth in a stock Go builder container
7-
FROM golang:1.19-alpine as builder
7+
FROM golang:1.20-alpine as builder
88

99
RUN apk add --no-cache gcc musl-dev linux-headers git
1010

Dockerfile.mockccc

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ARG VERSION=""
44
ARG BUILDNUM=""
55

66
# Build Geth in a stock Go builder container
7-
FROM scrolltech/go-rust-builder:go-1.19-rust-nightly-2022-12-10 as builder
7+
FROM scrolltech/go-rust-builder:go-1.20-rust-nightly-2022-12-10 as builder
88

99
ADD . /go-ethereum
1010
RUN cd /go-ethereum && env GO111MODULE=on go run build/ci.go install ./cmd/geth

Dockerfile.mockccc.alpine

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ARG VERSION=""
44
ARG BUILDNUM=""
55

66
# Build Geth in a stock Go builder container
7-
FROM golang:1.18-alpine as builder
7+
FROM golang:1.20-alpine as builder
88

99
RUN apk add --no-cache gcc musl-dev linux-headers git
1010

accounts/abi/bind/backends/simulated.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ type SimulatedBackend struct {
7979
func NewSimulatedBackendWithDatabase(database ethdb.Database, alloc core.GenesisAlloc, gasLimit uint64) *SimulatedBackend {
8080
genesis := core.Genesis{Config: params.AllEthashProtocolChanges, GasLimit: gasLimit, Alloc: alloc}
8181
genesis.MustCommit(database)
82-
blockchain, _ := core.NewBlockChain(database, nil, genesis.Config, ethash.NewFaker(), vm.Config{}, nil, nil, false)
82+
blockchain, _ := core.NewBlockChain(database, nil, genesis.Config, ethash.NewFaker(), vm.Config{}, nil, nil)
8383

8484
backend := &SimulatedBackend{
8585
database: database,

build/checksums.txt

+27-21
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,30 @@ c4b2349a8d11350ca038b8c57f3cc58dc0b31284bcbed4f7fca39aeed28b4a51 go1.17.2.linux
1515
fa6da0b829a66f5fab7e4e312fd6aa1b2d8f045c7ecee83b3d00f6fe5306759a go1.17.2.windows-amd64.zip
1616
00575c85dc7a129ba892685a456b27a3f3670f71c8bfde1c5ad151f771d55df7 go1.17.2.windows-arm64.zip
1717

18-
658078aaaf7608693f37c4cf1380b2af418ab8b2d23fdb33e7e2d4339328590e golangci-lint-1.46.2-darwin-amd64.tar.gz
19-
81f9b4afd62ec5e612ef8bc3b1d612a88b56ff289874831845cdad394427385f golangci-lint-1.46.2-darwin-arm64.tar.gz
20-
943486e703e62ec55ecd90caeb22bcd39f8cc3962a93eec18c06b7bae12cb46f golangci-lint-1.46.2-freebsd-386.tar.gz
21-
a75dd9ba7e08e8315c411697171db5375c0f6a1ece9e6fbeb9e9a4386822e17d golangci-lint-1.46.2-freebsd-amd64.tar.gz
22-
83eedca1af72e8be055a1235177eb1b33524fbf08bec5730df2e6c3efade2b23 golangci-lint-1.46.2-freebsd-armv6.tar.gz
23-
513d276c490de6f82baa01f9346d8d78b385f2ae97608f42f05d1f0f1314cd54 golangci-lint-1.46.2-freebsd-armv7.tar.gz
24-
461a60016d516c69d406dc3e2d4957b722dbe684b7085dfac4802d0f84409e27 golangci-lint-1.46.2-linux-386.tar.gz
25-
242cd4f2d6ac0556e315192e8555784d13da5d1874e51304711570769c4f2b9b golangci-lint-1.46.2-linux-amd64.tar.gz
26-
ff5448ada2b3982581984d64b0dec614dba0a3ea4cab2d6a343c77927fc89f7e golangci-lint-1.46.2-linux-arm64.tar.gz
27-
177f5210ef04aee282bfbc6ec519d36af5fb7d2b2c8d3f4ea5e59fdba71b0a27 golangci-lint-1.46.2-linux-armv6.tar.gz
28-
10dd512a36ee978a1009edbca3ba3af410f0fda8df4d85f0e4793a24213870cc golangci-lint-1.46.2-linux-armv7.tar.gz
29-
67779fa517c688c9db1090c3c456117d95c6b92979c623fe8cce8fb84251f21e golangci-lint-1.46.2-linux-mips64.tar.gz
30-
c085f0f57bdccbb2c902a41b72ce210a3dfff16ca856789374745ab52004b6ee golangci-lint-1.46.2-linux-mips64le.tar.gz
31-
abecef6421499248e58ed75d2938bc12b4b1f98b057f25060680b77bb51a881e golangci-lint-1.46.2-linux-ppc64le.tar.gz
32-
134843a8f5c5c182c11979ea75f5866945d54757b2a04f3e5e04a0cf4fbf3a39 golangci-lint-1.46.2-linux-riscv64.tar.gz
33-
9fe21a9476567aafe7a2e1a926b9641a39f920d4c0ea8eda9d968bc6136337f9 golangci-lint-1.46.2-linux-s390x.tar.gz
34-
b48a421ec12a43f8fc8f977b9cf7d4a1ea1c4b97f803a238de7d3ce4ab23a84b golangci-lint-1.46.2-windows-386.zip
35-
604acc1378a566abb0eac799362f3a37b7fcb5fa2268aeb2d5d954c829367301 golangci-lint-1.46.2-windows-amd64.zip
36-
927def10db073da9687594072e6a3d9c891f67fa897105a2cfd715e018e7386c golangci-lint-1.46.2-windows-arm64.zip
37-
729b76ed1d8b4e2612e38772b211503cb940e00a137bbaace1aa066f7c943737 golangci-lint-1.46.2-windows-armv6.zip
38-
ea27c86d91e0b245ecbcfbf6cdb4ac0522d4bc6dca56bba02ea1bc77ad2917ac golangci-lint-1.46.2-windows-armv7.zip
18+
632e96e6d5294fbbe7b2c410a49c8fa01c60712a0af85a567de85bcc1623ea21 golangci-lint-1.55.2-darwin-amd64.tar.gz
19+
234463f059249f82045824afdcdd5db5682d0593052f58f6a3039a0a1c3899f6 golangci-lint-1.55.2-darwin-arm64.tar.gz
20+
2bdd105e2d4e003a9058c33a22bb191a1e0f30fa0790acca0d8fbffac1d6247c golangci-lint-1.55.2-freebsd-386.tar.gz
21+
e75056e8b082386676ce23eba455cf893931a792c0d87e1e3743c0aec33c7fb5 golangci-lint-1.55.2-freebsd-amd64.tar.gz
22+
5789b933facaf6136bd23f1d50add67b79bbcf8dfdfc9069a37f729395940a66 golangci-lint-1.55.2-freebsd-armv6.tar.gz
23+
7f21ab1008d05f32c954f99470fc86a83a059e530fe2add1d0b7d8ed4d8992a7 golangci-lint-1.55.2-freebsd-armv7.tar.gz
24+
33ab06139b9219a28251f10821da94423db30285cc2af97494cbb2a281927de9 golangci-lint-1.55.2-illumos-amd64.tar.gz
25+
57ce6f8ce3ad6ee45d7cc3d9a047545a851c2547637834a3fcb086c7b40b1e6b golangci-lint-1.55.2-linux-386.tar.gz
26+
ca21c961a33be3bc15e4292dc40c98c8dcc5463a7b6768a3afc123761630c09c golangci-lint-1.55.2-linux-amd64.tar.gz
27+
8eb0cee9b1dbf0eaa49871798c7f8a5b35f2960c52d776a5f31eb7d886b92746 golangci-lint-1.55.2-linux-arm64.tar.gz
28+
3195f3e0f37d353fd5bd415cabcd4e263f5c29d3d0ffb176c26ff3d2c75eb3bb golangci-lint-1.55.2-linux-armv6.tar.gz
29+
c823ee36eb1a719e171de1f2f5ca3068033dce8d9817232fd10ed71fd6650406 golangci-lint-1.55.2-linux-armv7.tar.gz
30+
758a5d2a356dc494bd13ed4c0d4bf5a54a4dc91267ea5ecdd87b86c7ca0624e7 golangci-lint-1.55.2-linux-loong64.tar.gz
31+
2c7b9abdce7cae802a67d583cd7c6dca520bff6d0e17c8535a918e2f2b437aa0 golangci-lint-1.55.2-linux-mips64.tar.gz
32+
024e0a15b85352cc27271285526e16a4ab66d3e67afbbe446c9808c06cb8dbed golangci-lint-1.55.2-linux-mips64le.tar.gz
33+
6b00f89ba5506c1de1efdd9fa17c54093013a294fefd8b9b31534db626a672ee golangci-lint-1.55.2-linux-ppc64le.tar.gz
34+
0faa0d047d9bf7b703ed3ea65b6117043c93504f9ca1de25ae929d3901c73d4a golangci-lint-1.55.2-linux-riscv64.tar.gz
35+
30dec9b22e7d5bb4e9d5ccea96da20f71cd7db3c8cf30b8ddc7cb9174c4d742a golangci-lint-1.55.2-linux-s390x.tar.gz
36+
5a0ede48f79ad707902fdb29be8cd2abd8302dc122b65ebae3fdfc86751c7698 golangci-lint-1.55.2-netbsd-386.tar.gz
37+
95af20a2e617126dd5b08122ece7819101070e1582a961067ce8c41172f901ad golangci-lint-1.55.2-netbsd-amd64.tar.gz
38+
94fb7dacb7527847cc95d7120904e19a2a0a81a0d50d61766c9e0251da72ab9d golangci-lint-1.55.2-netbsd-armv6.tar.gz
39+
ca906bce5fee9619400e4a321c56476fe4a4efb6ac4fc989d340eb5563348873 golangci-lint-1.55.2-netbsd-armv7.tar.gz
40+
45b442f69fc8915c4500201c0247b7f3f69544dbc9165403a61f9095f2c57355 golangci-lint-1.55.2-windows-386.zip
41+
f57d434d231d43417dfa631587522f8c1991220b43c8ffadb9c7bd279508bf81 golangci-lint-1.55.2-windows-amd64.zip
42+
fd7dc8f4c6829ee6fafb252a4d81d2155cd35da7833665cbb25d53ce7cecd990 golangci-lint-1.55.2-windows-arm64.zip
43+
1892c3c24f9e7ef44b02f6750c703864b6dc350129f3ec39510300007b2376f1 golangci-lint-1.55.2-windows-armv6.zip
44+
a5e68ae73d38748b5269fad36ac7575e3c162a5dc63ef58abdea03cc5da4522a golangci-lint-1.55.2-windows-armv7.zip

build/ci.go

+12-13
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,18 @@ Usage: go run build/ci.go <command> <command flags/arguments>
2424
2525
Available commands are:
2626
27-
install [ -arch architecture ] [ -cc compiler ] [ packages... ] -- builds packages and executables
28-
test [ -coverage ] [ packages... ] -- runs the tests
29-
lint -- runs certain pre-selected linters
30-
archive [ -arch architecture ] [ -type zip|tar ] [ -signer key-envvar ] [ -signify key-envvar ] [ -upload dest ] -- archives build artifacts
31-
importkeys -- imports signing keys from env
32-
debsrc [ -signer key-id ] [ -upload dest ] -- creates a debian source package
33-
nsis -- creates a Windows NSIS installer
34-
aar [ -local ] [ -sign key-id ] [-deploy repo] [ -upload dest ] -- creates an Android archive
35-
xcode [ -local ] [ -sign key-id ] [-deploy repo] [ -upload dest ] -- creates an iOS XCode framework
36-
purge [ -store blobstore ] [ -days threshold ] -- purges old archives from the blobstore
27+
install [ -arch architecture ] [ -cc compiler ] [ packages... ] -- builds packages and executables
28+
test [ -coverage ] [ packages... ] -- runs the tests
29+
lint -- runs certain pre-selected linters
30+
archive [ -arch architecture ] [ -type zip|tar ] [ -signer key-envvar ] [ -signify key-envvar ] [ -upload dest ] -- archives build artifacts
31+
importkeys -- imports signing keys from env
32+
debsrc [ -signer key-id ] [ -upload dest ] -- creates a debian source package
33+
nsis -- creates a Windows NSIS installer
34+
aar [ -local ] [ -sign key-id ] [-deploy repo] [ -upload dest ] -- creates an Android archive
35+
xcode [ -local ] [ -sign key-id ] [-deploy repo] [ -upload dest ] -- creates an iOS XCode framework
36+
purge [ -store blobstore ] [ -days threshold ] -- purges old archives from the blobstore
3737
3838
For all commands, -n prevents execution of external programs (dry run mode).
39-
4039
*/
4140
package main
4241

@@ -148,7 +147,7 @@ var (
148147
// This is the version of go that will be downloaded by
149148
//
150149
// go run ci.go install -dlgo
151-
dlgoVersion = "1.17.2"
150+
dlgoVersion = "1.20.2"
152151
)
153152

154153
var GOBIN, _ = filepath.Abs(filepath.Join("build", "bin"))
@@ -336,7 +335,7 @@ func doLint(cmdline []string) {
336335

337336
// downloadLinter downloads and unpacks golangci-lint.
338337
func downloadLinter(cachedir string) string {
339-
const version = "1.46.2"
338+
const version = "1.55.2"
340339

341340
csdb := build.MustLoadChecksums("build/checksums.txt")
342341
base := fmt.Sprintf("golangci-lint-%s-%s-%s", version, runtime.GOOS, runtime.GOARCH)

cmd/utils/flags.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ import (
7373
"github.com/scroll-tech/go-ethereum/p2p/nat"
7474
"github.com/scroll-tech/go-ethereum/p2p/netutil"
7575
"github.com/scroll-tech/go-ethereum/params"
76+
"github.com/scroll-tech/go-ethereum/rollup/tracing"
7677
"github.com/scroll-tech/go-ethereum/rpc"
7778
)
7879

@@ -1904,7 +1905,8 @@ func RegisterEthService(stack *node.Node, cfg *ethconfig.Config) (ethapi.Backend
19041905
if err != nil {
19051906
Fatalf("Failed to register the Ethereum service: %v", err)
19061907
}
1907-
stack.RegisterAPIs(tracers.APIs(backend.ApiBackend))
1908+
scrollTracerWrapper := tracing.NewTracerWrapper()
1909+
stack.RegisterAPIs(tracers.APIs(backend.ApiBackend, scrollTracerWrapper))
19081910
return backend.ApiBackend, nil
19091911
}
19101912

@@ -1933,7 +1935,8 @@ func RegisterEthService(stack *node.Node, cfg *ethconfig.Config) (ethapi.Backend
19331935
Fatalf("Failed to create the LES server: %v", err)
19341936
}
19351937
}
1936-
stack.RegisterAPIs(tracers.APIs(backend.APIBackend))
1938+
scrollTracerWrapper := tracing.NewTracerWrapper()
1939+
stack.RegisterAPIs(tracers.APIs(backend.APIBackend, scrollTracerWrapper))
19371940
return backend.APIBackend, backend
19381941
}
19391942

@@ -2130,7 +2133,7 @@ func MakeChain(ctx *cli.Context, stack *node.Node) (chain *core.BlockChain, chai
21302133

21312134
// TODO(rjl493456442) disable snapshot generation/wiping if the chain is read only.
21322135
// Disable transaction indexing/unindexing by default.
2133-
chain, err = core.NewBlockChain(chainDb, cache, config, engine, vmcfg, nil, nil, false)
2136+
chain, err = core.NewBlockChain(chainDb, cache, config, engine, vmcfg, nil, nil)
21342137
if err != nil {
21352138
Fatalf("Can't create BlockChain: %v", err)
21362139
}

consensus/clique/clique_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func TestReimportMirroredState(t *testing.T) {
5555
genesis := genspec.MustCommit(db)
5656

5757
// Generate a batch of blocks, each properly signed
58-
chain, _ := core.NewBlockChain(db, nil, params.AllCliqueProtocolChanges, engine, vm.Config{}, nil, nil, false)
58+
chain, _ := core.NewBlockChain(db, nil, params.AllCliqueProtocolChanges, engine, vm.Config{}, nil, nil)
5959
defer chain.Stop()
6060

6161
blocks, _ := core.GenerateChain(params.AllCliqueProtocolChanges, genesis, engine, db, 3, func(i int, block *core.BlockGen) {
@@ -89,7 +89,7 @@ func TestReimportMirroredState(t *testing.T) {
8989
db = rawdb.NewMemoryDatabase()
9090
genspec.MustCommit(db)
9191

92-
chain, _ = core.NewBlockChain(db, nil, params.AllCliqueProtocolChanges, engine, vm.Config{}, nil, nil, false)
92+
chain, _ = core.NewBlockChain(db, nil, params.AllCliqueProtocolChanges, engine, vm.Config{}, nil, nil)
9393
defer chain.Stop()
9494

9595
if _, err := chain.InsertChain(blocks[:2]); err != nil {
@@ -102,7 +102,7 @@ func TestReimportMirroredState(t *testing.T) {
102102
// Simulate a crash by creating a new chain on top of the database, without
103103
// flushing the dirty states out. Insert the last block, triggering a sidechain
104104
// reimport.
105-
chain, _ = core.NewBlockChain(db, nil, params.AllCliqueProtocolChanges, engine, vm.Config{}, nil, nil, false)
105+
chain, _ = core.NewBlockChain(db, nil, params.AllCliqueProtocolChanges, engine, vm.Config{}, nil, nil)
106106
defer chain.Stop()
107107

108108
if _, err := chain.InsertChain(blocks[2:]); err != nil {

consensus/clique/snapshot_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ func TestClique(t *testing.T) {
450450
batches[len(batches)-1] = append(batches[len(batches)-1], block)
451451
}
452452
// Pass all the headers through clique and ensure tallying succeeds
453-
chain, err := core.NewBlockChain(db, nil, &config, engine, vm.Config{}, nil, nil, false)
453+
chain, err := core.NewBlockChain(db, nil, &config, engine, vm.Config{}, nil, nil)
454454
if err != nil {
455455
t.Errorf("test %d: failed to create test chain: %v", i, err)
456456
continue

core/bench_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ func benchInsertChain(b *testing.B, disk bool, gen func(int, *BlockGen)) {
201201

202202
// Time the insertion of the new chain.
203203
// State and blocks are stored in the same DB.
204-
chainman, _ := NewBlockChain(db, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil, false)
204+
chainman, _ := NewBlockChain(db, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil)
205205
defer chainman.Stop()
206206
b.ReportAllocs()
207207
b.ResetTimer()
@@ -316,7 +316,7 @@ func benchReadChain(b *testing.B, full bool, count uint64) {
316316
if err != nil {
317317
b.Fatalf("error opening database at %v: %v", dir, err)
318318
}
319-
chain, err := NewBlockChain(db, &cacheConfig, params.TestChainConfig, ethash.NewFaker(), vm.Config{}, nil, nil, false)
319+
chain, err := NewBlockChain(db, &cacheConfig, params.TestChainConfig, ethash.NewFaker(), vm.Config{}, nil, nil)
320320
if err != nil {
321321
b.Fatalf("error creating chain: %v", err)
322322
}

0 commit comments

Comments
 (0)