From 9ea079f878779adf8ea4a19e76b21cff62244151 Mon Sep 17 00:00:00 2001 From: wsodsong Date: Wed, 12 Jun 2024 04:15:31 +0000 Subject: [PATCH 01/26] upgrade geth version --- Makefile | 7 - carmen | 2 +- go.mod | 104 +++++++---- go.sum | 324 ++++++++++++++++++--------------- state/carmen.go | 77 ++++---- state/carmen_test.go | 7 +- state/chain_conduit.go | 12 +- state/geth.go | 113 +++++++----- state/memory.go | 50 ++--- state/state.go | 34 ++-- state/substate.go | 14 +- tosca | 2 +- txcontext/account.go | 11 +- txcontext/nil_tx_context.go | 2 +- txcontext/substate/account.go | 7 +- txcontext/substate/substate.go | 16 +- txcontext/txgenerator/norma.go | 29 +-- 17 files changed, 467 insertions(+), 344 deletions(-) diff --git a/Makefile b/Makefile index 83cb53877..40eb7b813 100644 --- a/Makefile +++ b/Makefile @@ -41,28 +41,24 @@ tosca: aida-rpc: carmen tosca GOPROXY=$(GOPROXY) \ - GOPRIVATE=github.com/Fantom-foundation/Carmen,github.com/Fantom-foundation/Sonic \ go build -ldflags "-s -w -X 'github.com/Fantom-foundation/Aida/utils.GitCommit=$(BUILD_COMMIT)'" \ -o $(GO_BIN)/aida-rpc \ ./cmd/aida-rpc aida-stochastic-sdb: carmen tosca GOPROXY=$(GOPROXY) \ - GOPRIVATE=github.com/Fantom-foundation/Carmen,github.com/Fantom-foundation/Sonic \ go build -ldflags "-s -w -X 'github.com/Fantom-foundation/Aida/utils.GitCommit=$(BUILD_COMMIT)'" \ -o $(GO_BIN)/aida-stochastic-sdb \ ./cmd/aida-stochastic-sdb aida-vm-adb: carmen tosca GOPROXY=$(GOPROXY) \ - GOPRIVATE=github.com/Fantom-foundation/Carmen,github.com/Fantom-foundation/Sonic \ go build -ldflags "-s -w -X 'github.com/Fantom-foundation/Aida/utils.GitCommit=$(BUILD_COMMIT)'" \ -o $(GO_BIN)/aida-vm-adb \ ./cmd/aida-vm-adb aida-vm-sdb: carmen tosca GOPROXY=$(GOPROXY) \ - GOPRIVATE=github.com/Fantom-foundation/Carmen,github.com/Fantom-foundation/Sonic \ CGO_CFLAGS="-g -O2 -DMDBX_FORCE_ASSERTIONS=1 -Wno-error=strict-prototypes" \ go build -ldflags "-s -w -X 'github.com/Fantom-foundation/Aida/utils.GitCommit=$(BUILD_COMMIT)'" \ -o $(GO_BIN)/aida-vm-sdb \ @@ -70,21 +66,18 @@ aida-vm-sdb: carmen tosca aida-vm: carmen tosca GOPROXY=$(GOPROXY) \ - GOPRIVATE=github.com/Fantom-foundation/Carmen,github.com/Fantom-foundation/Sonic \ go build -ldflags "-s -w -X 'github.com/Fantom-foundation/Aida/utils.GitCommit=$(BUILD_COMMIT)'" \ -o $(GO_BIN)/aida-vm \ ./cmd/aida-vm aida-sdb: carmen tosca GOPROXY=$(GOPROXY) \ - GOPRIVATE=github.com/Fantom-foundation/Carmen,github.com/Fantom-foundation/Sonic \ go build -ldflags "-s -w -X 'github.com/Fantom-foundation/Aida/utils.GitCommit=$(BUILD_COMMIT)'" \ -o $(GO_BIN)/aida-sdb \ ./cmd/aida-sdb aida-profile: carmen tosca GOPROXY=$(GOPROXY) \ - GOPRIVATE=github.com/Fantom-foundation/Carmen,github.com/Fantom-foundation/Sonic \ CGO_CFLAGS="-g -O2 -DMDBX_FORCE_ASSERTIONS=1 -Wno-error=strict-prototypes" \ go build -ldflags "-s -w -X 'github.com/Fantom-foundation/Aida/utils.GitCommit=$(BUILD_COMMIT)'" \ -o $(GO_BIN)/aida-profile \ diff --git a/carmen b/carmen index 67008e380..2967c9cad 160000 --- a/carmen +++ b/carmen @@ -1 +1 @@ -Subproject commit 67008e3801f9718da0284207e90d72b35ca294e5 +Subproject commit 2967c9cad7634ba0e6cf4116a03dfdcca394e960 diff --git a/go.mod b/go.mod index 2e4952a7d..fd4508dc5 100644 --- a/go.mod +++ b/go.mod @@ -12,85 +12,109 @@ require ( github.com/Fantom-foundation/go-opera v1.1.1-rc.2 github.com/Fantom-foundation/lachesis-base v0.0.0-20240116072301-a75735c4ef00 github.com/dsnet/compress v0.0.1 - github.com/ethereum/go-ethereum v1.13.14 + github.com/ethereum/go-ethereum v1.14.3 github.com/go-echarts/go-echarts/v2 v2.2.5 github.com/goccy/go-graphviz v0.1.0 github.com/gogo/protobuf v1.3.2 github.com/google/martian v2.1.0+incompatible + github.com/holiman/uint256 v1.2.4 github.com/jedib0t/go-pretty/v6 v6.4.9 github.com/jmoiron/sqlx v1.3.5 - github.com/klauspost/compress v1.15.15 - github.com/mattn/go-sqlite3 v1.14.17 + github.com/klauspost/compress v1.17.8 + github.com/mattn/go-sqlite3 v1.14.22 github.com/onsi/gomega v1.19.0 github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 github.com/paulmach/orb v0.9.0 github.com/sigurn/crc8 v0.0.0-20220107193325-2243fe600f9f - github.com/status-im/keycard-go v0.0.0-20190424133014-d95853db0f48 + github.com/status-im/keycard-go v0.3.2 github.com/stretchr/testify v1.9.0 github.com/syndtr/goleveldb v1.0.1-0.20220614013038-64ee5596c38a - github.com/urfave/cli/v2 v2.25.7 + github.com/urfave/cli/v2 v2.27.2 go.uber.org/mock v0.4.0 - golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa + golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 gonum.org/v1/gonum v0.12.0 ) require ( + github.com/DataDog/zstd v1.5.5 // indirect github.com/FactomProject/basen v0.0.0-20150613233007-fe3947df716e // indirect github.com/FactomProject/btcutilecc v0.0.0-20130527213604-d3a63a5752ec // indirect - github.com/VictoriaMetrics/fastcache v1.12.0 // indirect + github.com/Microsoft/go-winio v0.6.2 // indirect + github.com/VictoriaMetrics/fastcache v1.12.2 // indirect + github.com/beorn7/perks v1.0.1 // indirect + github.com/bits-and-blooms/bitset v1.13.0 // indirect github.com/btcsuite/btcd v0.22.0-beta // indirect - github.com/cakturk/go-netstat v0.0.0-20200220111822-e5b49efee7a5 // indirect - github.com/cespare/xxhash/v2 v2.2.0 // indirect - github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect + github.com/btcsuite/btcd/btcec/v2 v2.3.3 // indirect + github.com/cespare/xxhash/v2 v2.3.0 // indirect + github.com/cockroachdb/errors v1.11.1 // indirect + github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect + github.com/cockroachdb/pebble v1.1.0 // indirect + github.com/cockroachdb/redact v1.1.5 // indirect + github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect + github.com/consensys/bavard v0.1.13 // indirect + github.com/consensys/gnark-crypto v0.12.1 // indirect + github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect + github.com/crate-crypto/go-ipa v0.0.0-20231025140028-3c0104f4b233 // indirect + github.com/crate-crypto/go-kzg-4844 v1.0.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect - github.com/deckarep/golang-set v1.8.0 // indirect - github.com/edsrzf/mmap-go v1.0.0 // indirect - github.com/ethereum/evmc/v10 v10.0.0 // indirect + github.com/deckarep/golang-set/v2 v2.6.0 // indirect + github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 // indirect + github.com/distribution/reference v0.6.0 // indirect + github.com/ethereum/c-kzg-4844 v1.0.2 // indirect + github.com/ethereum/evmc/v11 v11.0.0 // indirect github.com/fogleman/gg v1.3.0 // indirect + github.com/fsnotify/fsnotify v1.7.0 // indirect github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08 // indirect - github.com/go-kit/kit v0.9.0 // indirect - github.com/go-logfmt/logfmt v0.5.0 // indirect + github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46 // indirect + github.com/getsentry/sentry-go v0.27.0 // indirect github.com/go-ole/go-ole v1.3.0 // indirect - github.com/go-stack/stack v1.8.1 // indirect + github.com/gofrs/flock v0.8.1 // indirect github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect github.com/golang/mock v1.6.0 // indirect github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect - github.com/google/uuid v1.3.0 // indirect - github.com/gorilla/websocket v1.5.0 // indirect - github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d // indirect + github.com/google/uuid v1.6.0 // indirect + github.com/gorilla/websocket v1.5.1 // indirect + github.com/hashicorp/golang-lru v1.0.2 // indirect + github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect github.com/holiman/bloomfilter/v2 v2.0.3 // indirect - github.com/holiman/uint256 v1.2.4 // indirect - github.com/huin/goupnp v1.0.3 // indirect + github.com/huin/goupnp v1.3.0 // indirect github.com/jackpal/go-nat-pmp v1.0.2 // indirect - github.com/mattn/go-colorable v0.1.13 // indirect - github.com/mattn/go-isatty v0.0.17 // indirect - github.com/mattn/go-runewidth v0.0.14 // indirect + github.com/kr/pretty v0.3.1 // indirect + github.com/kr/text v0.2.0 // indirect + github.com/mattn/go-runewidth v0.0.15 // indirect + github.com/mmcloughlin/addchain v0.4.0 // indirect + github.com/moby/docker-image-spec v1.3.1 // indirect github.com/olekukonko/tablewriter v0.0.5 // indirect github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/prometheus/tsdb v0.10.0 // indirect - github.com/rivo/uniseg v0.4.2 // indirect - github.com/rjeczalik/notify v0.9.2 // indirect - github.com/rs/cors v1.8.2 // indirect + github.com/prometheus/client_golang v1.19.1 // indirect + github.com/prometheus/client_model v0.6.1 // indirect + github.com/prometheus/common v0.53.0 // indirect + github.com/prometheus/procfs v0.15.0 // indirect + github.com/rivo/uniseg v0.4.7 // indirect + github.com/rogpeppe/go-internal v1.12.0 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/shirou/gopsutil v3.21.11+incompatible // indirect - github.com/tklauser/go-sysconf v0.3.12 // indirect - github.com/tklauser/numcpus v0.6.1 // indirect + github.com/supranational/blst v0.3.11 // indirect + github.com/tklauser/go-sysconf v0.3.14 // indirect + github.com/tklauser/numcpus v0.8.0 // indirect github.com/tyler-smith/go-bip32 v1.0.0 // indirect github.com/tyler-smith/go-bip39 v1.1.0 // indirect - github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect - github.com/yusufpapurcu/wmi v1.2.2 // indirect + github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913 // indirect + github.com/yusufpapurcu/wmi v1.2.4 // indirect + go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.52.0 // indirect + go.opentelemetry.io/otel/trace v1.27.0 // indirect golang.org/x/crypto v0.23.0 // indirect golang.org/x/image v0.11.0 // indirect - golang.org/x/sync v0.5.0 // indirect + golang.org/x/net v0.25.0 // indirect + golang.org/x/sync v0.7.0 // indirect golang.org/x/sys v0.20.0 // indirect golang.org/x/text v0.15.0 // indirect - google.golang.org/protobuf v1.28.1 // indirect - gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect - gopkg.in/olebedev/go-duktape.v3 v3.0.0-20200619000410-60c24ae608a6 // indirect + google.golang.org/protobuf v1.34.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect pgregory.net/rand v1.0.2 // indirect + rsc.io/tmplfunc v0.0.3 // indirect ) // The Carmen project is integrated as a git-submodule since we need to run extra @@ -101,10 +125,12 @@ replace github.com/Fantom-foundation/Carmen/go => ./carmen/go // Carmen. Furthermore, the EVMC library, which is part of Tosca, needs to be used. replace github.com/Fantom-foundation/Tosca => ./tosca -replace github.com/ethereum/evmc/v10 => ./tosca/third_party/evmc +replace github.com/ethereum/evmc/v11 => ./tosca/third_party/evmc -replace github.com/ethereum/go-ethereum => github.com/Fantom-foundation/go-ethereum-substate v1.1.1-0.20240607093315-d7d9138e5fdf +replace github.com/ethereum/go-ethereum => github.com/Fantom-foundation/go-ethereum-sonic v0.0.0-20240529085303-2400937cc3b1 -replace github.com/Fantom-foundation/go-opera => github.com/Fantom-foundation/sonic v1.0.0-a +replace github.com/Fantom-foundation/lachesis-base => github.com/Fantom-foundation/lachesis-base-sonic v0.0.0-20240320160249-81827a18147c + +replace github.com/Fantom-foundation/go-opera => github.com/Fantom-foundation/sonic v1.2.1-b.0.20240610064725-fc9986b8bf5d replace github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 diff --git a/go.sum b/go.sum index 3191c6777..5978eefe0 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,5 @@ +github.com/DataDog/zstd v1.5.5 h1:oWf5W7GtOLgp6bciQYDmhHHjdhYkALu6S/5Ni9ZgSvQ= +github.com/DataDog/zstd v1.5.5/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= github.com/FactomProject/basen v0.0.0-20150613233007-fe3947df716e h1:ahyvB3q25YnZWly5Gq1ekg6jcmWaGj/vG/MhF4aisoc= github.com/FactomProject/basen v0.0.0-20150613233007-fe3947df716e/go.mod h1:kGUqhHd//musdITWjFvNTHn90WG9bMLBEPQZ17Cmlpw= github.com/FactomProject/btcutilecc v0.0.0-20130527213604-d3a63a5752ec h1:1Qb69mGp/UtRPn422BH4/Y4Q3SLUrD9KHuDkm8iodFc= @@ -6,28 +8,29 @@ github.com/Fantom-foundation/Norma v0.0.0-20240422103552-42e37352b2f4 h1:vtziTKo github.com/Fantom-foundation/Norma v0.0.0-20240422103552-42e37352b2f4/go.mod h1:NLvaNtS7elcJ9Q/Ypz7ZzA2DuQqd+UC+Bccue2EVRWk= github.com/Fantom-foundation/Substate v0.0.0-20240606095437-0d28864f0a7a h1:xnFmk1o0faM8qksrUDNkkt3HL0y4MoXbdNjs/67TdRs= github.com/Fantom-foundation/Substate v0.0.0-20240606095437-0d28864f0a7a/go.mod h1:8dW0EnFHo0PegzvTFLUa5oxUgKvhLudPR0Ro3fUV7ag= -github.com/Fantom-foundation/go-ethereum-substate v1.1.1-0.20240607093315-d7d9138e5fdf h1:+on3LIdi54bude/KdPl94K+homdttL1T9EB1dlOZY1M= -github.com/Fantom-foundation/go-ethereum-substate v1.1.1-0.20240607093315-d7d9138e5fdf/go.mod h1:9e69ZhWA6jYhPsMVjFzfIeptd/Fnelk7Eo+QrMyJXJM= -github.com/Fantom-foundation/lachesis-base v0.0.0-20240116072301-a75735c4ef00 h1:yw5QaA7u4t2/j7VIGrMt640Kuhsx6pEIHM3bj10glWc= -github.com/Fantom-foundation/lachesis-base v0.0.0-20240116072301-a75735c4ef00/go.mod h1:Ogv5etzSmM2rQ4eN3OfmyitwWaaPjd4EIDiW/NAbYGk= -github.com/Fantom-foundation/sonic v1.0.0-a h1:uDJC/vgIt8Dr8KAjMLdMf4LbqJE/JLfe0KumNxjt1u0= -github.com/Fantom-foundation/sonic v1.0.0-a/go.mod h1:0fzvTCCLyipNpatOlIh4T+aAUven9iQqKHTE94PgbV4= -github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= -github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= -github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= -github.com/VictoriaMetrics/fastcache v1.12.0 h1:vnVi/y9yKDcD9akmc4NqAoqgQhJrOwUF+j9LTgn4QDE= -github.com/VictoriaMetrics/fastcache v1.12.0/go.mod h1:tjiYeEfYXCqacuvYw/7UoDIeJaNxq6132xHICNP77w8= +github.com/Fantom-foundation/go-ethereum-sonic v0.0.0-20240529085303-2400937cc3b1 h1:iVbLlmFYPlK31O8psS9H+Y+uop0AC1jqCoRErauaHj0= +github.com/Fantom-foundation/go-ethereum-sonic v0.0.0-20240529085303-2400937cc3b1/go.mod h1:6LG3apXyp0InsMXGq9YmzUiV7H0BOuUHrcu3oQY9boE= +github.com/Fantom-foundation/lachesis-base-sonic v0.0.0-20240320160249-81827a18147c h1:g35kQNkq/VGiFak0joC4hcL/TZIi1KQZkatIlLZnOy0= +github.com/Fantom-foundation/lachesis-base-sonic v0.0.0-20240320160249-81827a18147c/go.mod h1:Z3oZXqOteUH9KZkuw9zXXtcVnflkjOofhXYjBH8Exh0= +github.com/Fantom-foundation/sonic v1.2.1-b.0.20240610064725-fc9986b8bf5d h1:3/hXfiHNX563rw0bpIMMllY3o69CWP3rT/9G6YmMaoo= +github.com/Fantom-foundation/sonic v1.2.1-b.0.20240610064725-fc9986b8bf5d/go.mod h1:HkAgCee1Sfb9ANu5MVD3paC+dJjdpoS3RC0fxq9jwdc= +github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= +github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= +github.com/VictoriaMetrics/fastcache v1.12.2 h1:N0y9ASrJ0F6h0QaC3o6uJb3NIZ9VKLjCM7NQbSmF7WI= +github.com/VictoriaMetrics/fastcache v1.12.2/go.mod h1:AmC+Nzz1+3G2eCPapF6UcsnkThDcMsQicp4xDukwJYI= github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= -github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= -github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM= github.com/allegro/bigcache v1.2.1 h1:hg1sY1raCwic3Vnsvje6TT7/pnZba83LeFck5NrFKSc= github.com/allegro/bigcache v1.2.1/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM= -github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= -github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= +github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= +github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/bits-and-blooms/bitset v1.13.0 h1:bAQ9OPNFYbGHV6Nez0tmNI0RiEu7/hxlYJRUA0wFAVE= +github.com/bits-and-blooms/bitset v1.13.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8= github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ= github.com/btcsuite/btcd v0.22.0-beta h1:LTDpDKUM5EeOFBPM8IXpinEcmZ6FWfNZbE3lfrfdnWo= github.com/btcsuite/btcd v0.22.0-beta/go.mod h1:9n5ntfhhHQBIhUvlhDvD3Qg6fRUj4jkN0VB8L8svzOA= +github.com/btcsuite/btcd/btcec/v2 v2.3.3 h1:6+iXlDKE8RMtKsvK0gshlXIuPbyWM/h84Ensb7o3sC0= +github.com/btcsuite/btcd/btcec/v2 v2.3.3/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04= github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA= github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce/go.mod h1:0DVlHczLPewLcPGEIeUEzfOJhqGPQ0mJJRDBtD307+o= @@ -38,33 +41,54 @@ github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku github.com/btcsuite/snappy-go v1.0.0/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY= github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs= -github.com/cakturk/go-netstat v0.0.0-20200220111822-e5b49efee7a5 h1:BjkPE3785EwPhhyuFkbINB+2a1xATwk8SNDWnJiD41g= -github.com/cakturk/go-netstat v0.0.0-20200220111822-e5b49efee7a5/go.mod h1:jtAfVaU/2cu1+wdSRPWE2c1N2qeAA3K4RH9pYgqwets= github.com/cespare/cp v1.1.1 h1:nCb6ZLdB7NRaqsm91JtQTAme2SKJzXVsdPIPkyJr1MU= github.com/cespare/cp v1.1.1/go.mod h1:SOGHArjBr4JWaSDEVpWpo/hNg6RoKrls6Oh40hiwW+s= -github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= -github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= +github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cinar/indicator v1.2.24/go.mod h1:5eX8f1PG9g3RKSoHsoQxKd8bIN97Cf/gbgxXjihROpI= github.com/cmars/basen v0.0.0-20150613233007-fe3947df716e h1:0XBUw73chJ1VYSsfvcPvVT7auykAJce9FpRr10L6Qhw= github.com/cmars/basen v0.0.0-20150613233007-fe3947df716e/go.mod h1:P13beTBKr5Q18lJe1rIoLUqjM+CB1zYrRg44ZqGuQSA= +github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f h1:otljaYPt5hWxV3MUfO5dFPFiOXg9CyG5/kCfayTqsJ4= +github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f/go.mod h1:a9RdTaap04u637JoCzcUoIcDmvwSUtcUFtT/C3kJlTU= +github.com/cockroachdb/errors v1.11.1 h1:xSEW75zKaKCWzR3OfxXUxgrk/NtT4G1MiOv5lWZazG8= +github.com/cockroachdb/errors v1.11.1/go.mod h1:8MUxA3Gi6b25tYlFEBGLf+D8aISL+M4MIpiWMSNRfxw= +github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b h1:r6VH0faHjZeQy818SGhaone5OnYfxFR/+AzdY3sf5aE= +github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b/go.mod h1:Vz9DsVWQQhf3vs21MhPMZpMGSht7O/2vFW2xusFUVOs= +github.com/cockroachdb/pebble v1.1.0 h1:pcFh8CdCIt2kmEpK0OIatq67Ln9uGDYY3d5XnE0LJG4= +github.com/cockroachdb/pebble v1.1.0/go.mod h1:sEHm5NOXxyiAoKWhoFxT8xMgd/f3RA6qUqQ1BXKrh2E= +github.com/cockroachdb/redact v1.1.5 h1:u1PMllDkdFfPWaNGMyLD1+so+aq3uUItthCFqzwPJ30= +github.com/cockroachdb/redact v1.1.5/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= +github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 h1:zuQyyAKVxetITBuuhv3BI9cMrmStnpT18zmgmTxunpo= +github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06/go.mod h1:7nc4anLGjupUW/PeY5qiNYsdNXj7zopG+eqsS7To5IQ= +github.com/consensys/bavard v0.1.13 h1:oLhMLOFGTLdlda/kma4VOJazblc7IM5y5QPd2A/YjhQ= +github.com/consensys/bavard v0.1.13/go.mod h1:9ItSMtA/dXMAiL7BG6bqW2m3NdSEObYWoH223nGHukI= +github.com/consensys/gnark-crypto v0.12.1 h1:lHH39WuuFgVHONRl3J0LRBtuYdQTumFSDtJF7HpyG8M= +github.com/consensys/gnark-crypto v0.12.1/go.mod h1:v2Gy7L/4ZRosZ7Ivs+9SfUDr0f5UlG+EM5t7MPHiLuY= github.com/corona10/goimagehash v1.0.2 h1:pUfB0LnsJASMPGEZLj7tGY251vF+qLGqOgEP4rUs6kA= github.com/corona10/goimagehash v1.0.2/go.mod h1:/l9umBhvcHQXVtQO1V6Gp1yD20STawkhRnnX0D1bvVI= -github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= -github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/cpuguy83/go-md2man/v2 v2.0.4 h1:wfIWP927BUkWJb2NmU/kNDYIBTh/ziUX91+lVfRxZq4= +github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/crate-crypto/go-ipa v0.0.0-20231025140028-3c0104f4b233 h1:d28BXYi+wUpz1KBmiF9bWrjEMacUEREV6MBi2ODnrfQ= +github.com/crate-crypto/go-ipa v0.0.0-20231025140028-3c0104f4b233/go.mod h1:geZJZH3SzKCqnz5VT0q/DyIG/tvu/dZk+VIfXicupJs= +github.com/crate-crypto/go-kzg-4844 v1.0.0 h1:TsSgHwrkTKecKJ4kadtHi4b3xHW5dCFUDFnUp1TsawI= +github.com/crate-crypto/go-kzg-4844 v1.0.0/go.mod h1:1kMhvPgI0Ky3yIa+9lFySEBUBXkYxeOi8ZF1sYioxhc= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/deckarep/golang-set v1.8.0 h1:sk9/l/KqpunDwP7pSjUg0keiOOLEnOBHzykLrsPppp4= -github.com/deckarep/golang-set v1.8.0/go.mod h1:5nI87KwE7wgsBU1F4GKAw2Qod7p5kyS383rP6+o6qqo= +github.com/deckarep/golang-set/v2 v2.6.0 h1:XfcQbWM1LlMB8BsJ8N9vW5ehnnPVIw0je80NsVHagjM= +github.com/deckarep/golang-set/v2 v2.6.0/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4= +github.com/decred/dcrd/crypto/blake256 v1.0.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5ilcvdfma9wOH6Y= +github.com/decred/dcrd/crypto/blake256 v1.0.1/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 h1:rpfIENRNNilwHwZeG5+P150SMrnNEcHYvcCuK6dPZSg= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218= -github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= -github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m322EBzniBPB6ZIzuh8= -github.com/docker/distribution v2.8.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= -github.com/docker/docker v24.0.5+incompatible h1:WmgcE4fxyI6EEXxBRxsHnZXrO1pQ3smi0k/jho4HLeY= -github.com/docker/docker v24.0.5+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk= +github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= +github.com/docker/docker v26.1.3+incompatible h1:lLCzRbrVZrljpVNobJu1J2FHk8V0s4BawoZippkc+xo= +github.com/docker/docker v26.1.3+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= @@ -72,45 +96,52 @@ github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDD github.com/dsnet/compress v0.0.1 h1:PlZu0n3Tuv04TzpfPbrnI0HW/YwodEXDS+oPKahKF0Q= github.com/dsnet/compress v0.0.1/go.mod h1:Aw8dCMJ7RioblQeTqt88akK31OvO8Dhf5JflhBbQEHo= github.com/dsnet/golib v0.0.0-20171103203638-1ea166775780/go.mod h1:Lj+Z9rebOhdfkVLjJ8T6VcRQv3SXugXy999NBtR9aFY= -github.com/edsrzf/mmap-go v1.0.0 h1:CEBF7HpRnUCSJgGUb5h1Gm7e3VkmVDrR8lvWVLtrOFw= -github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= -github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 h1:FtmdgXiUlNeRsoNMFlKLDt+S+6hbjVMEW6RGQ7aUf7c= -github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0= +github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= +github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= +github.com/ethereum/c-kzg-4844 v1.0.2 h1:8tV84BCEiPeOkiVgW9mpYBeBUir2bkCNVqxPwwVeO+s= +github.com/ethereum/c-kzg-4844 v1.0.2/go.mod h1:VewdlzQmpT5QSrVhbBuGoCdFJkpaJlO1aQputP83wc0= +github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= +github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= +github.com/fjl/memsize v0.0.2 h1:27txuSD9or+NZlnOWdKUxeBzTAUkWCVh+4Gf2dWFOzA= +github.com/fjl/memsize v0.0.2/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0= github.com/fogleman/gg v1.3.0 h1:/7zJX8F6AaYQc57WQCyN9cAIz+4bCJGO9B+dyW29am8= github.com/fogleman/gg v1.3.0/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= -github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= -github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= +github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= +github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08 h1:f6D9Hr8xV8uYKlyuj8XIruxlh9WjVjdh1gIicAS7ays= github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww= +github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46 h1:BAIP2GihuqhwdILrV+7GJel5lyPV3u1+PgzrWLc0TkE= +github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46/go.mod h1:QNpY22eby74jVhqH4WhDLDwxc/vqsern6pW+u2kbkpc= +github.com/getsentry/sentry-go v0.27.0 h1:Pv98CIbtB3LkMWmXi4Joa5OOcwbmnX88sF5qbK3r3Ps= +github.com/getsentry/sentry-go v0.27.0/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w1gwTf25trprY= github.com/go-echarts/go-echarts/v2 v2.2.5 h1:Jl0gtQa9i/iTZHEsmzf89HoxX2WTGa4K5r0be4qaquE= github.com/go-echarts/go-echarts/v2 v2.2.5/go.mod h1:IN5P8jIRZKENmAJf2lHXBzv8U9YwdVnY9urdzGkEDA0= -github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-kit/kit v0.9.0 h1:wDJmvq38kDhkVxi50ni9ykkdUr1PKgqKOoi01fa0Mdk= -github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= -github.com/go-logfmt/logfmt v0.5.0 h1:TrB8swr/68K7m9CcGut2g3UOihhbcbiMAYiuTXdEih4= -github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= +github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA= +github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og= +github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= +github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= +github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE= github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78= github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE= github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= -github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= -github.com/go-stack/stack v1.8.1 h1:ntEHSVwIt7PNXNpgPmVfMrNhLtgjlmnZha2kOpuRiDw= -github.com/go-stack/stack v1.8.1/go.mod h1:dcoOX6HbPZSZptuspn9bctJ+N/CnF5gGygcUP3XYfe4= github.com/goccy/go-graphviz v0.1.0 h1:6OqQoQ5PeAiHYe/YcusyeulqBrOkUb16HQ4ctRdyVUU= github.com/goccy/go-graphviz v0.1.0/go.mod h1:wXVsXxmyMQU6TN3zGRttjNn3h+iCAS7xQFC6TlNvLhk= -github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= +github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw= +github.com/gofrs/flock v0.8.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= +github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= @@ -118,8 +149,6 @@ github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:W github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= -github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb h1:PBC98N2aIaM3XXiurYmW7fx4GZkL8feAMVq7nEjURHk= @@ -129,22 +158,32 @@ github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= +github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian v2.1.0+incompatible h1:/CP5g8u/VJHijgedC/Legn3BAbAaWPgecwXBIDzw5no= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= -github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= -github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d h1:dg1dEPuWpEqDnvIw251EVy4zlP8gWbsGj4BsUKCRpYs= -github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= +github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY= +github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY= +github.com/hashicorp/go-bexpr v0.1.14 h1:uKDeyuOhWhT1r5CiMTjdVY4Aoxdxs6EtwgTGnlosyp4= +github.com/hashicorp/go-bexpr v0.1.14/go.mod h1:gN7hRKB3s7yT+YvTdnhZVLTENejvhlkZ8UE4YVBS+Q8= +github.com/hashicorp/golang-lru v1.0.2 h1:dV3g9Z/unq5DpblPpw+Oqcv4dU/1omnb4Ok8iPY6p1c= +github.com/hashicorp/golang-lru v1.0.2/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= +github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k= +github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM= +github.com/holiman/billy v0.0.0-20240322075458-72a4e81ec6da h1:8qEhdMGSUx67L2s5aGQinJhOwLfIRKLRBHPQq8m6WxE= +github.com/holiman/billy v0.0.0-20240322075458-72a4e81ec6da/go.mod h1:5GuXa7vkL8u9FkFuWdVvfR5ix8hRB7DbOAaYULamFpc= github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao= github.com/holiman/bloomfilter/v2 v2.0.3/go.mod h1:zpoh+gs7qcpqrHr3dB55AMiJwo0iURXE7ZOP9L9hSkA= github.com/holiman/uint256 v1.2.4 h1:jUc4Nk8fm9jZabQuqr2JzednajVmBpC+oiTiXZJEApU= github.com/holiman/uint256 v1.2.4/go.mod h1:EOMSn4q6Nyt9P6efbI3bueV4e1b3dGlUCXeiRV4ng7E= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/huin/goupnp v1.0.3 h1:N8No57ls+MnjlB+JPiCVSOyy/ot7MJTqlo7rn+NYSqQ= -github.com/huin/goupnp v1.0.3/go.mod h1:ZxNlw5WqJj6wSsRK5+YfflQGXYfccj5VgQsMNixHM7Y= -github.com/huin/goutil v0.0.0-20170803182201-1ca381bf3150/go.mod h1:PpLOETDnJ0o3iZrZfqZzyLl6l7F3c6L1oWn7OICBi6o= +github.com/huin/goupnp v1.3.0 h1:UvLUlWDNpoUdYzb2TCn+MuTWtcjXKSza2n6CBdQ0xXc= +github.com/huin/goupnp v1.3.0/go.mod h1:gnGPsThkYa7bFi/KWmEysQRf48l2dvR5bxr2OFckNX8= github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus= github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= github.com/jedib0t/go-pretty/v6 v6.4.9 h1:vZ6bjGg2eBSrJn365qlxGcaWu09Id+LHtrfDWlB2Usc= @@ -154,51 +193,53 @@ github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJS github.com/jmoiron/sqlx v1.3.5 h1:vFFPA71p1o5gAeqtEAwLU4dnX2napprKtHr7PYIcN3g= github.com/jmoiron/sqlx v1.3.5/go.mod h1:nRVWtLre0KfCLJvgxzCsLVMogSvQ1zNJtpYr2Ccp0mQ= github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ= -github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= -github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= -github.com/karalabe/usb v0.0.2 h1:M6QQBNxF+CQ8OFvxrT90BA0qBOXymndZnk5q235mFc4= -github.com/karalabe/usb v0.0.2/go.mod h1:Od972xHfMJowv7NGVDiWVxk2zxnWgjLlJzE+F4F7AGU= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= github.com/klauspost/compress v1.4.1/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= -github.com/klauspost/compress v1.15.15 h1:EF27CXIuDsYJ6mmvtBRlEuB2UVOqHG1tAXgZ7yIO+lw= -github.com/klauspost/compress v1.15.15/go.mod h1:ZcK2JAFqKOpnBlxcLsJzYfrS9X1akm9fHZNnD9+Vo/4= +github.com/klauspost/compress v1.17.8 h1:YcnTYrq7MikUT7k0Yb5eceMmALQPYBW/Xltxn0NAMnU= +github.com/klauspost/compress v1.17.8/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= github.com/klauspost/cpuid v1.2.0/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= -github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= +github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= +github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c= +github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8= github.com/lib/pq v1.2.0 h1:LXpIM/LZ5xGFhOpXAQUIMM1HdyqzVYM13zNdjCEEcA0= github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= -github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= -github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng= -github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= -github.com/mattn/go-runewidth v0.0.14 h1:+xnbZSEeDbOIg5/mE6JF0w6n9duR1l3/WmbinWVwUuU= -github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U= +github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mattn/go-sqlite3 v1.14.6/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= -github.com/mattn/go-sqlite3 v1.14.17 h1:mCRHCLDUBXgpKAqIKsaAaAsrAlbkeomtRFKXh2L6YIM= -github.com/mattn/go-sqlite3 v1.14.17/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= -github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU= +github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= +github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= +github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/mitchellh/pointerstructure v1.2.1 h1:ZhBBeX8tSlRpu/FFhXH4RC4OJzFlqsQhoHZAz4x7TIw= +github.com/mitchellh/pointerstructure v1.2.1/go.mod h1:BRAsLI5zgXmw97Lf6s25bs8ohIXc3tViBH44KcwB2g4= +github.com/mmcloughlin/addchain v0.4.0 h1:SobOdjm2xLj1KkXN5/n0xTIWyZA2+s99UCY1iPfkHRY= +github.com/mmcloughlin/addchain v0.4.0/go.mod h1:A86O+tHqZLMNO4w6ZZ4FlVQEadcoqkyU72HC5wJ4RlU= +github.com/mmcloughlin/profile v0.1.1/go.mod h1:IhHD7q1ooxgwTgjxQYkACGA77oFTDdFVejUS1/tS/qU= +github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0= +github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo= github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc= -github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/nfnt/resize v0.0.0-20160724205520-891127d8d1b5 h1:BvoENQQU+fZ9uukda/RzCAL/191HHwJA5b13R6diVlY= github.com/nfnt/resize v0.0.0-20160724205520-891127d8d1b5/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8= -github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= -github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= -github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= -github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= +github.com/nxadm/tail v1.4.11 h1:8feyoE3OzPrcshW5/MJ4sGESc5cqmGkGCWlco4l0bqY= +github.com/nxadm/tail v1.4.11/go.mod h1:OTaG3NK980DZzxbRq6lEuzgU+mug70nY11sMd4JXXHc= github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= @@ -225,43 +266,41 @@ github.com/paulmach/orb v0.9.0/go.mod h1:SudmOk85SXtmXAB3sLGyJ6tZy/8pdfrV0o6ef98 github.com/paulmach/protoscan v0.2.1/go.mod h1:SpcSwydNLrxUGSDvXvO0P7g7AuhJ7lcKfDlhJCDw2gY= github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 h1:onHthvaw9LFnH4t2DcNVpwGmV9E1BkGknEliJkfwQj0= github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58/go.mod h1:DXv8WO4yhMYhSNPKjeNKa5WY9YCIEBRbNzFFPJbWO6Y= -github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4= +github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= +github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/profile v1.6.0/go.mod h1:qBsxPvzyUincmltOk6iyRVxHYg4adc0OFOv72ZdLa18= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= -github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= -github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= -github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= -github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= -github.com/prometheus/tsdb v0.10.0 h1:If5rVCMTp6W2SiRAQFlbpJNgVlgMEd+U2GZckwK38ic= -github.com/prometheus/tsdb v0.10.0/go.mod h1:oi49uRhEe9dPUTlS3JRZOwJuVi6tmh10QSgwXEyGCt4= +github.com/prometheus/client_golang v1.19.1 h1:wZWJDwK+NameRJuPGDhlnFgx8e8HN3XHQeLaYJFJBOE= +github.com/prometheus/client_golang v1.19.1/go.mod h1:mP78NwGzrVks5S2H6ab8+ZZGJLZUq1hoULYBAYBw1Ho= +github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= +github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= +github.com/prometheus/common v0.53.0 h1:U2pL9w9nmJwJDa4qqLQ3ZaePJ6ZTwt7cMD3AG3+aLCE= +github.com/prometheus/common v0.53.0/go.mod h1:BrxBKv3FWBIGXw89Mg1AeBq7FSyRzXWI3l3e7W3RN5U= +github.com/prometheus/procfs v0.15.0 h1:A82kmvXJq2jTu5YUhSGNlYoxh85zLnKgPz4bMZgI5Ek= +github.com/prometheus/procfs v0.15.0/go.mod h1:Y0RJ/Y5g5wJpkTisOtqwDSo4HwhGmLB4VQSw2sQJLHk= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= -github.com/rivo/uniseg v0.4.2 h1:YwD0ulJSJytLpiaWua0sBDusfsCZohxjxzVTYjwxfV8= -github.com/rivo/uniseg v0.4.2/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= -github.com/rjeczalik/notify v0.9.2 h1:MiTWrPj55mNDHEiIX5YUSKefw/+lCQVoAFmD6oQm5w8= -github.com/rjeczalik/notify v0.9.2/go.mod h1:aErll2f0sUX9PXZnVNyeiObbmTlk5jnMoCa4QEjJeqM= -github.com/rs/cors v1.8.2 h1:KCooALfAYGs415Cwu5ABvv9n9509fSiG5SQJn/AQo4U= -github.com/rs/cors v1.8.2/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= +github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= +github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= +github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= +github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= +github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= +github.com/rs/cors v1.11.0 h1:0B9GE/r9Bc2UxRMMtymBkHTenPkHDv0CW4Y98GBY+po= +github.com/rs/cors v1.11.0/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI= github.com/shirou/gopsutil v3.21.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/sigurn/crc8 v0.0.0-20220107193325-2243fe600f9f h1:1R9KdKjCNSd7F8iGTxIpoID9prlYH8nuNYKt0XvweHA= github.com/sigurn/crc8 v0.0.0-20220107193325-2243fe600f9f/go.mod h1:vQhwQ4meQEDfahT5kd61wLAF5AAeh5ZPLVI4JJ/tYo8= -github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= -github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= -github.com/status-im/keycard-go v0.0.0-20190424133014-d95853db0f48 h1:ju5UTwk5Odtm4trrY+4Ca4RMj5OyXbmVeDAVad2T0Jw= -github.com/status-im/keycard-go v0.0.0-20190424133014-d95853db0f48/go.mod h1:RZLeN1LMWmRsyYjvAu+I6Dm9QmlDaIIt+Y+4Kd7Tp+Q= +github.com/status-im/keycard-go v0.3.2 h1:YusIF/bHx6YZis8UTOJrpZFnTs4IkRBdmJXqdiXkpFE= +github.com/status-im/keycard-go v0.3.2/go.mod h1:wlp8ZLbsmrF6g6WjugPAx+IzoLrkdf9+mHxBEeo3Hbg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/testify v1.1.5-0.20170601210322-f6abca593680/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.6.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= @@ -269,40 +308,49 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.4/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/supranational/blst v0.3.11 h1:LyU6FolezeWAhvQk0k6O/d49jqgO52MSDDfYgbeoEm4= +github.com/supranational/blst v0.3.11/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= -github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU= -github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI= -github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk= -github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY= +github.com/tklauser/go-sysconf v0.3.14 h1:g5vzr9iPFFz24v2KZXs/pvpvh8/V9Fw6vQK5ZZb78yU= +github.com/tklauser/go-sysconf v0.3.14/go.mod h1:1ym4lWMLUOhuBOPGtRcJm7tEGX4SCYNEEEtghGG/8uY= +github.com/tklauser/numcpus v0.8.0 h1:Mx4Wwe/FjZLeQsK/6kt2EOepwwSl7SmJrK5bV/dXYgY= +github.com/tklauser/numcpus v0.8.0/go.mod h1:ZJZlAY+dmR4eut8epnzf0u/VwodKmryxR8txiloSqBE= github.com/tyler-smith/go-bip32 v1.0.0 h1:sDR9juArbUgX+bO/iblgZnMPeWY1KZMUC2AFUJdv5KE= github.com/tyler-smith/go-bip32 v1.0.0/go.mod h1:onot+eHknzV4BVPwrzqY5OoVpyCvnwD7lMawL5aQupE= github.com/tyler-smith/go-bip39 v1.1.0 h1:5eUemwrMargf3BSLRRCalXT93Ns6pQJIjYQN2nyfOP8= github.com/tyler-smith/go-bip39 v1.1.0/go.mod h1:gUYDtqQw1JS3ZJ8UWVcGTGqqr6YIN3CWg+kkNaLt55U= github.com/ulikunitz/xz v0.5.6/go.mod h1:2bypXElzHzzJZwzH67Y6wb67pO62Rzfn7BSiF4ABRW8= -github.com/urfave/cli/v2 v2.25.7 h1:VAzn5oq403l5pHjc4OhD54+XGO9cdKVL/7lDjF+iKUs= -github.com/urfave/cli/v2 v2.25.7/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ= +github.com/urfave/cli/v2 v2.27.2 h1:6e0H+AkS+zDckwPCUrZkKX38mRaau4nL2uipkJpbkcI= +github.com/urfave/cli/v2 v2.27.2/go.mod h1:g0+79LmHHATl7DAcHO99smiR/T7uGLw84w8Y42x+4eM= github.com/valyala/fastrand v1.1.0 h1:f+5HkLW4rsgzdNoleUOB69hyT9IlD2ZQh9GyDMfb5G8= github.com/valyala/fastrand v1.1.0/go.mod h1:HWqCzkrkg6QXT8V2EXWvXCoow7vLwOFN002oeRzjapQ= github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= github.com/xdg-go/scram v1.1.1/go.mod h1:RaEWvsqvNKKvBPvcKeFjrG2cJqOkHTiyTpzz23ni57g= github.com/xdg-go/stringprep v1.0.3/go.mod h1:W3f5j4i+9rC0kuIEJL0ky1VpHXQU3ocBgklLGvcBnW8= -github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= -github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= +github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913 h1:+qGGcbkzsfDQNPPe9UDgpxAWQrhbbBXOYJFQDq/dtJw= +github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913/go.mod h1:4aEEwZQutDLsQv2Deui4iYQ6DWTxR14g6m8Wv88+Xqk= github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -github.com/yusufpapurcu/wmi v1.2.2 h1:KBNDSne4vP5mbSWnJbO+51IMOXJB67QiYCSBrubbPRg= -github.com/yusufpapurcu/wmi v1.2.2/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= +github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0= +github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= go.mongodb.org/mongo-driver v1.11.1/go.mod h1:s7p5vEtfbeR1gYi6pnj3c3/urpbLv2T5Sfd6Rp2HBB8= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.52.0 h1:9l89oX4ba9kHbBol3Xin3leYJ+252h0zszDtBwyKe2A= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.52.0/go.mod h1:XLZfZboOJWHNKUv7eH0inh0E9VV6eWDFB/9yJyTLPp0= +go.opentelemetry.io/otel v1.27.0 h1:9BZoF3yMK/O1AafMiQTVu0YDj5Ea4hPhxCs7sGva+cg= +go.opentelemetry.io/otel v1.27.0/go.mod h1:DMpAK8fzYRzs+bi3rS5REupisuqTheUlSZJ1WnZaPAQ= +go.opentelemetry.io/otel/metric v1.27.0 h1:hvj3vdEKyeCi4YaYfNjv2NUje8FqKqUY8IlF0FxV/ik= +go.opentelemetry.io/otel/metric v1.27.0/go.mod h1:mVFgmRlhljgBiuk/MP/oKylr4hs85GZAylncepAX/ak= +go.opentelemetry.io/otel/trace v1.27.0 h1:IqYb813p7cmbHk0a5y6pD5JPakbVfftRXABGt5/Rscw= +go.opentelemetry.io/otel/trace v1.27.0/go.mod h1:6RiD1hkAprV4/q+yd2ln1HG9GoPx39SuvvstaLBl+l4= go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU= go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc= golang.org/x/crypto v0.0.0-20170613210332-850760c427c5/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200115085410-6d4e4cb37c7d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= @@ -313,8 +361,8 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI= golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= -golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa h1:FRnLl4eNAQl8hwxVVC17teOw8kdjVDVAiFMtgUdTSRQ= -golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa/go.mod h1:zk2irFbV9DP96SEBUUAy67IdHUaZuSnrz1n472HUCLE= +golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 h1:vr/HnozRka3pE4EsMEg1lgkXJkTFJCVUX+S/ZT6wYzM= +golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc= golang.org/x/image v0.0.0-20200119044424-58c23975cae1/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/image v0.11.0 h1:ds2RoQvBvYTiJkwpSFDwCcDFNX7DqjL2WsUgTNk0Ooo= golang.org/x/image v0.11.0/go.mod h1:bglhjqbqVuEb9e9+eNR45Jfu7D+T4Qan+NhQk8Ck2P8= @@ -323,11 +371,8 @@ golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0= -golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -339,23 +384,18 @@ golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96b golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4= -golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= +golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac= +golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE= -golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= -golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= +golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180926160741-c2ed4eda69e7/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -371,14 +411,11 @@ golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220405052023-b1e9470b6e64/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y= golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= @@ -393,8 +430,8 @@ golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk= golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4= -golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= +golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= @@ -402,8 +439,6 @@ golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4f golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= -golang.org/x/tools v0.15.0 h1:zdAyfUGbYmuVokhzVmghFl2ZJh5QhcfebBgmVPFYA+8= -golang.org/x/tools v0.15.0/go.mod h1:hpksKq4dtpQWS1uQ61JkdqWM3LscIS6Slf+VVkm+wQk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -418,22 +453,17 @@ google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzi google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= -google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= +google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg= +google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU= -gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= -gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce h1:+JknDZhAj8YMt7GC73Ei8pv4MzjDUNPHgQWJdtMAaDU= -gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce/go.mod h1:5AcXVHNjg+BDxry382+8OKon8SEWiKktQR07RKPsv1c= -gopkg.in/olebedev/go-duktape.v3 v3.0.0-20200619000410-60c24ae608a6 h1:a6cXbcDDUkSBlpnkWV1bJ+vv3mOgQEltEJ2rPxroVu0= -gopkg.in/olebedev/go-duktape.v3 v3.0.0-20200619000410-60c24ae608a6/go.mod h1:uAJfkITjFhyEEuUfm7bsmCZRbW5WRq8s9EY8HZ6hCns= +gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc= +gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= -gopkg.in/urfave/cli.v1 v1.20.0 h1:NdAVW6RYxDif9DhDHaAortIu956m2c0v+09AZBPTbE0= -gopkg.in/urfave/cli.v1 v1.20.0/go.mod h1:vuBzUtMdQeixQj8LVd+/98pzhxNGQoyuPBlsXHOQNO0= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= @@ -448,3 +478,5 @@ pgregory.net/rand v1.0.2 h1:ASEbkvwOmY/UPF2evJPBJ8XZg71xdKWYdByqKapI7Vw= pgregory.net/rand v1.0.2/go.mod h1:EyNx8APnDE3Svi8sWgUZ5lOiz60cNZUPPBTyzOUpPl4= pgregory.net/rapid v0.4.8 h1:d+5SGZWUbJPbl3ss6tmPFqnNeQR6VDOFly+eTjwPiEw= pgregory.net/rapid v0.4.8/go.mod h1:Z5PbWqjvWR1I3UGjvboUuan4fe4ZYEYNLNQLExzCoUs= +rsc.io/tmplfunc v0.0.3 h1:53XFQh69AfOa8Tw0Jm7t+GV7KZhOi6jzsCzTtKbMvzU= +rsc.io/tmplfunc v0.0.3/go.mod h1:AG3sTPzElb1Io3Yg4voV9AGZJuleGAwaVRxL9M49PhA= diff --git a/state/carmen.go b/state/carmen.go index 032c7b215..cdabe6643 100644 --- a/state/carmen.go +++ b/state/carmen.go @@ -26,7 +26,10 @@ import ( _ "github.com/Fantom-foundation/Carmen/go/state/cppstate" _ "github.com/Fantom-foundation/Carmen/go/state/gostate" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/tracing" "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/params" + "github.com/holiman/uint256" ) func MakeCarmenStateDB(dir string, variant string, schema int, archive string) (StateDB, error) { @@ -104,6 +107,11 @@ func (s *carmenStateDB) CreateAccount(addr common.Address) { s.txCtx.CreateAccount(carmen.Address(addr)) } +func (s *carmenStateDB) CreateContract(addr common.Address) { + panic("CreateContract not implemented") + return +} + func (s *carmenStateDB) Exist(addr common.Address) bool { return s.txCtx.Exist(carmen.Address(addr)) } @@ -112,32 +120,31 @@ func (s *carmenStateDB) Empty(addr common.Address) bool { return s.txCtx.Empty(carmen.Address(addr)) } -func (s *carmenStateDB) Suicide(addr common.Address) bool { - return s.txCtx.SelfDestruct(carmen.Address(addr)) +func (s *carmenStateDB) SelfDestruct(addr common.Address) { + s.txCtx.SelfDestruct(carmen.Address(addr)) +} + +func (s *carmenStateDB) Selfdestruct6780(addr common.Address) { + panic("Selfdestruct6780 not implemented") + return } -func (s *carmenStateDB) HasSuicided(addr common.Address) bool { +func (s *carmenStateDB) HasSelfDestructed(addr common.Address) bool { return s.txCtx.HasSelfDestructed(carmen.Address(addr)) } -func (s *carmenStateDB) GetBalance(addr common.Address) *big.Int { - return s.txCtx.GetBalance(carmen.Address(addr)).ToBig() +func (s *carmenStateDB) GetBalance(addr common.Address) *uint256.Int { + // TODO + //return &s.txCtx.GetBalance(carmen.Address(addr)).Uint256() + return uint256.MustFromBig(s.txCtx.GetBalance(carmen.Address(addr)).ToBig()) } -func (s *carmenStateDB) AddBalance(addr common.Address, value *big.Int) { - amount, err := carmen.NewAmountFromBigInt(value) - if err != nil { - amount = carmen.NewAmount() - } - s.txCtx.AddBalance(carmen.Address(addr), amount) +func (s *carmenStateDB) AddBalance(addr common.Address, value *uint256.Int, _ tracing.BalanceChangeReason) { + s.txCtx.AddBalance(carmen.Address(addr), carmen.NewAmountFromUint256(value)) } -func (s *carmenStateDB) SubBalance(addr common.Address, value *big.Int) { - amount, err := carmen.NewAmountFromBigInt(value) - if err != nil { - amount = carmen.NewAmount() - } - s.txCtx.SubBalance(carmen.Address(addr), amount) +func (s *carmenStateDB) SubBalance(addr common.Address, value *uint256.Int, _ tracing.BalanceChangeReason) { + s.txCtx.SubBalance(carmen.Address(addr), carmen.NewAmountFromUint256(value)) } func (s *carmenStateDB) GetNonce(addr common.Address) uint64 { @@ -160,6 +167,21 @@ func (s *carmenStateDB) SetState(addr common.Address, key common.Hash, value com s.txCtx.SetState(carmen.Address(addr), carmen.Key(key), carmen.Value(value)) } +func (s *carmenStateDB) GetStorageRoot(addr common.Address) common.Hash { + panic("GetStorageRoot not implemented") + return common.Hash{} +} + +func (s *carmenStateDB) GetTransientState(addr common.Address, key common.Hash) common.Hash { + panic("GetTransientState not implemented") + return common.Hash{} +} + +func (s *carmenStateDB) SetTransientState(addr common.Address, key common.Hash, value common.Hash) { + panic("SetTransientState not implemented") + return +} + func (s *carmenStateDB) GetCode(addr common.Address) []byte { return s.txCtx.GetCode(carmen.Address(addr)) } @@ -236,7 +258,7 @@ func (s *carmenStateDB) GetRefund() uint64 { return s.txCtx.GetRefund() } -func (s *carmenStateDB) PrepareAccessList(sender common.Address, dest *common.Address, precompiles []common.Address, txAccesses types.AccessList) { +func (s *carmenStateDB) Prepare(rules params.Rules, sender, coinbase common.Address, dest *common.Address, precompiles []common.Address, txAccesses types.AccessList) { s.txCtx.ClearAccessList() s.txCtx.AddAddressToAccessList(carmen.Address(sender)) if dest != nil { @@ -281,7 +303,7 @@ func (s *carmenStateDB) AddLog(log *types.Log) { }) } -func (s *carmenStateDB) GetLogs(common.Hash, common.Hash) []*types.Log { +func (s *carmenStateDB) GetLogs(common.Hash, uint64, common.Hash) []*types.Log { list := s.txCtx.GetLogs() res := make([]*types.Log, 0, len(list)) @@ -309,12 +331,12 @@ func (s *carmenStateDB) IntermediateRoot(bool) common.Hash { return common.Hash{} } -func (s *carmenStateDB) Commit(bool) (common.Hash, error) { +func (s *carmenStateDB) Commit(uint64, bool) (common.Hash, error) { // ignored return common.Hash{}, nil } -func (s *carmenStateDB) Prepare(common.Hash, int) { +func (s *carmenStateDB) SetTxContext(common.Hash, int) { // ignored } @@ -332,11 +354,6 @@ func (s *carmenStateDB) AddPreimage(common.Hash, []byte) { panic("AddPreimage not implemented") } -func (s *carmenStateDB) ForEachStorage(common.Address, func(common.Hash, common.Hash) bool) error { - // ignored - panic("ForEachStorage not implemented") -} - func (s *carmenStateDB) Error() error { // ignored return nil @@ -416,12 +433,8 @@ func (l *carmenBulkLoad) CreateAccount(addr common.Address) { l.load.CreateAccount(carmen.Address(addr)) } -func (l *carmenBulkLoad) SetBalance(addr common.Address, value *big.Int) { - balance, err := carmen.NewAmountFromBigInt(value) - if err != nil { - balance = carmen.NewAmount() - } - l.load.SetBalance(carmen.Address(addr), balance) +func (l *carmenBulkLoad) SetBalance(addr common.Address, value *uint256.Int) { + l.load.SetBalance(carmen.Address(addr), carmen.NewAmountFromUint256(value)) } func (l *carmenBulkLoad) SetNonce(addr common.Address, nonce uint64) { diff --git a/state/carmen_test.go b/state/carmen_test.go index 8e28009ee..0b4da4f0f 100644 --- a/state/carmen_test.go +++ b/state/carmen_test.go @@ -97,11 +97,8 @@ func TestCarmenState_AccountLifecycle(t *testing.T) { t.Fatal("failed to create carmen state DB account; should be empty") } - if !csDB.Suicide(addr) { - t.Fatal("failed to suicide carmen state DB account;") - } - - if !csDB.HasSuicided(addr) { + csDB.SelfDestruct(addr) + if !csDB.HasSelfDestructed(addr) { t.Fatal("failed to suicide carmen state DB account;") } }) diff --git a/state/chain_conduit.go b/state/chain_conduit.go index 7cff39b16..b29781897 100644 --- a/state/chain_conduit.go +++ b/state/chain_conduit.go @@ -35,20 +35,22 @@ type ChainConduit struct { chainConfig *params.ChainConfig } -func (c *ChainConduit) IsFinalise(block *big.Int) bool { +func (c *ChainConduit) IsFinalise(block uint64) bool { + b := big.NewInt(int64(block)) if !c.isEthereum { return true } else { - return c.chainConfig.IsByzantium(block) + return c.chainConfig.IsByzantium(b) } } -func (c *ChainConduit) DeleteEmptyObjects(block *big.Int) bool { +func (c *ChainConduit) DeleteEmptyObjects(block uint64) bool { if !c.isEthereum { return true } else { - bz := c.chainConfig.IsByzantium(block) - ei := c.chainConfig.IsEIP158(block) + b := big.NewInt(int64(block)) + bz := c.chainConfig.IsByzantium(b) + ei := c.chainConfig.IsEIP158(b) return bz || ei } } diff --git a/state/geth.go b/state/geth.go index d40959273..a84d71054 100644 --- a/state/geth.go +++ b/state/geth.go @@ -26,9 +26,12 @@ import ( "github.com/ethereum/go-ethereum/common/prque" "github.com/ethereum/go-ethereum/core/rawdb" geth "github.com/ethereum/go-ethereum/core/state" + "github.com/ethereum/go-ethereum/core/tracing" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/ethdb" + "github.com/ethereum/go-ethereum/params" + "github.com/holiman/uint256" ) const ( @@ -57,7 +60,7 @@ func MakeGethStateDB(directory, variant string, rootHash common.Hash, isArchiveM db: db, evmState: evmState, stateRoot: rootHash, - triegc: prque.New(nil), + triegc: prque.New[uint64,common.Hash](nil), isArchiveMode: isArchiveMode, chainConduit: chainConduit, }, nil @@ -66,7 +69,7 @@ func MakeGethStateDB(directory, variant string, rootHash common.Hash, isArchiveM // openStateDB creates a new statedb from an existing geth database func (s *gethStateDB) openStateDB() error { var err error - s.db, err = geth.NewWithSnapLayers(s.stateRoot, s.evmState, nil, 0) + s.db, err = geth.New(s.stateRoot, s.evmState, nil) return err } @@ -74,16 +77,20 @@ type gethStateDB struct { db vm.StateDB // statedb evmState geth.Database // key-value database stateRoot common.Hash // lastest root hash - triegc *prque.Prque + triegc *prque.Prque[uint64,common.Hash] isArchiveMode bool chainConduit *ChainConduit // chain configuration - block *big.Int + block uint64 } func (s *gethStateDB) CreateAccount(addr common.Address) { s.db.CreateAccount(addr) } +func (s *gethStateDB) CreateContract(addr common.Address) { + s.db.CreateContract(addr) +} + func (s *gethStateDB) Exist(addr common.Address) bool { return s.db.Exist(addr) } @@ -92,24 +99,28 @@ func (s *gethStateDB) Empty(addr common.Address) bool { return s.db.Empty(addr) } -func (s *gethStateDB) Suicide(addr common.Address) bool { - return s.db.Suicide(addr) +func (s *gethStateDB) SelfDestruct(addr common.Address) { + s.db.SelfDestruct(addr) +} + +func (s *gethStateDB) Selfdestruct6780(addr common.Address) { + s.db.Selfdestruct6780(addr) } -func (s *gethStateDB) HasSuicided(addr common.Address) bool { - return s.db.HasSuicided(addr) +func (s *gethStateDB) HasSelfDestructed(addr common.Address) bool { + return s.db.HasSelfDestructed(addr) } -func (s *gethStateDB) GetBalance(addr common.Address) *big.Int { +func (s *gethStateDB) GetBalance(addr common.Address) *uint256.Int { return s.db.GetBalance(addr) } -func (s *gethStateDB) AddBalance(addr common.Address, value *big.Int) { - s.db.AddBalance(addr, value) +func (s *gethStateDB) AddBalance(addr common.Address, value *uint256.Int, reason tracing.BalanceChangeReason) { + s.db.AddBalance(addr, value, reason) } -func (s *gethStateDB) SubBalance(addr common.Address, value *big.Int) { - s.db.SubBalance(addr, value) +func (s *gethStateDB) SubBalance(addr common.Address, value *uint256.Int, reason tracing.BalanceChangeReason) { + s.db.SubBalance(addr, value, reason) } func (s *gethStateDB) GetNonce(addr common.Address) uint64 { @@ -132,6 +143,18 @@ func (s *gethStateDB) SetState(addr common.Address, key common.Hash, value commo s.db.SetState(addr, key, value) } +func (s *gethStateDB) GetStorageRoot(addr common.Address) common.Hash { + return s.db.GetStorageRoot(addr) +} + +func (s *gethStateDB) GetTransientState(addr common.Address, key common.Hash) common.Hash { + return s.db.GetTransientState(addr, key) +} + +func (s *gethStateDB) SetTransientState(addr common.Address, key common.Hash, value common.Hash) { + s.db.SetTransientState(addr, key, value) +} + func (s *gethStateDB) GetCode(addr common.Address) []byte { return s.db.GetCode(addr) } @@ -181,14 +204,14 @@ func (s *gethStateDB) BeginBlock(number uint64) error { if err := s.openStateDB(); err != nil { return fmt.Errorf("cannot open geth state-db; %w", err) } - s.block = new(big.Int).SetUint64(number) + s.block = number return nil } func (s *gethStateDB) EndBlock() error { var err error //commit at the end of a block - s.stateRoot, err = s.Commit(true) + s.stateRoot, err = s.Commit(s.block, true) if err != nil { panic("StateDB commit failed") } @@ -231,17 +254,18 @@ func (s *gethStateDB) IntermediateRoot(deleteEmptyObjects bool) common.Hash { return common.Hash{} } -func (s *gethStateDB) Commit(deleteEmptyObjects bool) (common.Hash, error) { +func (s *gethStateDB) Commit(block uint64, deleteEmptyObjects bool) (common.Hash, error) { if db, ok := s.db.(*geth.StateDB); ok { - return db.Commit(deleteEmptyObjects) + return db.Commit(block, deleteEmptyObjects) } return common.Hash{}, nil } -func (s *gethStateDB) Prepare(thash common.Hash, ti int) { +func (s *gethStateDB) SetTxContext(thash common.Hash, ti int) { if db, ok := s.db.(*geth.StateDB); ok { - db.Prepare(thash, ti) + db.SetTxContext(thash, ti) } + return } func (s *gethStateDB) PrepareSubstate(substate txcontext.WorldState, block uint64) { @@ -249,9 +273,10 @@ func (s *gethStateDB) PrepareSubstate(substate txcontext.WorldState, block uint6 } func (s *gethStateDB) GetSubstatePostAlloc() txcontext.WorldState { - if db, ok := s.db.(*geth.StateDB); ok { - return substatecontext.NewWorldState(db.GetPostWorldState()) - } + //TODO reenable equal check + //if db, ok := s.db.(*geth.StateDB); ok { + // return substatecontext.NewWorldState(db.GetPostWorldState()) + //} return nil } @@ -263,19 +288,19 @@ func (s *gethStateDB) Close() error { return nil } // Commit data to trie. - hash, err := state.Commit(true) + hash, err := state.Commit(s.block, true) if err != nil { return err } // Close underlying trie caching intermediate results. - db := state.Database().TrieDB() - if err := db.Commit(hash, true, nil); err != nil { + tdb := state.Database().TrieDB() + if err := tdb.Commit(hash, true); err != nil { return err } // Close underlying LevelDB instance. - return db.DiskDB().Close() + return tdb.Close() } func (s *gethStateDB) AddRefund(gas uint64) { @@ -288,8 +313,8 @@ func (s *gethStateDB) SubRefund(gas uint64) { func (s *gethStateDB) GetRefund() uint64 { return s.db.GetRefund() } -func (s *gethStateDB) PrepareAccessList(sender common.Address, dest *common.Address, precompiles []common.Address, txAccesses types.AccessList) { - s.db.PrepareAccessList(sender, dest, precompiles, txAccesses) +func (s *gethStateDB) Prepare(rules params.Rules, sender, coinbase common.Address, dest *common.Address, precompiles []common.Address, txAccesses types.AccessList) { + s.db.Prepare(rules, sender, coinbase, dest, precompiles, txAccesses) } func (s *gethStateDB) AddressInAccessList(addr common.Address) bool { @@ -312,12 +337,10 @@ func (s *gethStateDB) AddPreimage(hash common.Hash, preimage []byte) { panic("Add Preimage") s.db.AddPreimage(hash, preimage) } -func (s *gethStateDB) ForEachStorage(addr common.Address, cb func(common.Hash, common.Hash) bool) error { - return s.db.ForEachStorage(addr, cb) -} -func (s *gethStateDB) GetLogs(hash common.Hash, blockHash common.Hash) []*types.Log { + +func (s *gethStateDB) GetLogs(hash common.Hash, block uint64, blockHash common.Hash) []*types.Log { if db, ok := s.db.(*geth.StateDB); ok { - return db.GetLogs(hash, blockHash) + return db.GetLogs(hash, block, blockHash) } return []*types.Log{} } @@ -347,16 +370,17 @@ func (s *gethStateDB) GetMemoryUsage() *MemoryUsage { type gethBulkLoad struct { db *gethStateDB + block uint64 } func (l *gethBulkLoad) CreateAccount(addr common.Address) { l.db.CreateAccount(addr) } -func (l *gethBulkLoad) SetBalance(addr common.Address, value *big.Int) { +func (l *gethBulkLoad) SetBalance(addr common.Address, value *uint256.Int) { old := l.db.GetBalance(addr) value = value.Sub(value, old) - l.db.AddBalance(addr, value) + l.db.AddBalance(addr, value, 0) } func (l *gethBulkLoad) SetNonce(addr common.Address, nonce uint64) { @@ -374,7 +398,8 @@ func (l *gethBulkLoad) SetCode(addr common.Address, code []byte) { func (l *gethBulkLoad) Close() error { l.db.EndTransaction() l.db.EndBlock() - _, err := l.db.Commit(false) + _, err := l.db.Commit(l.block, false) + l.block++ return err } @@ -383,15 +408,15 @@ func (s *gethStateDB) trieCommit() error { triedb := s.evmState.TrieDB() // If we're applying genesis or running an archive node, always flush if s.isArchiveMode { - if err := triedb.Commit(s.stateRoot, false, nil); err != nil { + if err := triedb.Commit(s.stateRoot, false); err != nil { return fmt.Errorf("Failed to flush trie DB into main DB. %v", err) } } else { // Full but not archive node, do proper garbage collection triedb.Reference(s.stateRoot, common.Hash{}) // metadata reference to keep trie alive - s.triegc.Push(s.stateRoot, -int64(s.block.Uint64())) + s.triegc.Push(s.stateRoot, s.block) - if current := s.block.Uint64(); current > triesInMemory { + if current := s.block; current > triesInMemory { // If we exceeded our memory allowance, flush matured singleton nodes to disk s.trieCap() @@ -405,7 +430,7 @@ func (s *gethStateDB) trieCommit() error { s.triegc.Push(root, number) break } - triedb.Dereference(root.(common.Hash)) + triedb.Dereference(root) } } } @@ -417,7 +442,7 @@ func (s *gethStateDB) trieCleanCommit() error { // Don't need to reference the current state root // due to it already be referenced on `Commit()` function triedb := s.evmState.TrieDB() - if current := s.block.Uint64(); current > triesInMemory { + if current := s.block; current > triesInMemory { // Find the next state trie we need to commit chosen := current - triesInMemory // Garbage collect all below the chosen block @@ -427,18 +452,18 @@ func (s *gethStateDB) trieCleanCommit() error { s.triegc.Push(root, number) break } - triedb.Dereference(root.(common.Hash)) + triedb.Dereference(root) } } // commit the state trie after clean up - err := triedb.Commit(s.stateRoot, false, nil) + err := triedb.Commit(s.stateRoot, false) return err } // trieCap flushes matured singleton nodes to disk. func (s *gethStateDB) trieCap() { triedb := s.evmState.TrieDB() - nodes, imgs := triedb.Size() + _, nodes, imgs := triedb.Size() if nodes > memoryUpperLimit+ethdb.IdealBatchSize || imgs > imgUpperLimit { //If we exceeded our memory allowance, flush matured singleton nodes to disk triedb.Cap(memoryUpperLimit) diff --git a/state/memory.go b/state/memory.go index 6eafb92b6..1d6f9610f 100644 --- a/state/memory.go +++ b/state/memory.go @@ -25,7 +25,10 @@ import ( "github.com/Fantom-foundation/Substate/substate" substatetypes "github.com/Fantom-foundation/Substate/types" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/tracing" "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/params" + "github.com/holiman/uint256" ) func MakeEmptyGethInMemoryStateDB(variant string) (StateDB, error) { @@ -60,7 +63,7 @@ type snapshot struct { id int touched map[common.Address]int // Set of referenced accounts - balances map[common.Address]*big.Int + balances map[common.Address]*uint256.Int nonces map[common.Address]uint64 codes map[common.Address][]byte suicided map[common.Address]int // Set of destructed accounts @@ -82,7 +85,7 @@ func makeSnapshot(parent *snapshot, id int) *snapshot { parent: parent, id: id, touched: map[common.Address]int{}, - balances: map[common.Address]*big.Int{}, + balances: map[common.Address]*uint256.Int{}, nonces: map[common.Address]uint64{}, codes: map[common.Address][]byte{}, suicided: map[common.Address]int{}, @@ -102,31 +105,36 @@ func (db *inMemoryStateDB) CreateAccount(addr common.Address) { } } -func (db *inMemoryStateDB) SubBalance(addr common.Address, value *big.Int) { +func (db *inMemoryStateDB) CreateContract(addr common.Address) { + panic("CreateContract not implemented") +} + + +func (db *inMemoryStateDB) SubBalance(addr common.Address, value *uint256.Int, _ tracing.BalanceChangeReason) { if value.Sign() == 0 { return } db.state.touched[addr] = 0 - db.state.balances[addr] = new(big.Int).Sub(db.GetBalance(addr), value) + db.state.balances[addr] = new(uint256.Int).Sub(db.GetBalance(addr), value) } -func (db *inMemoryStateDB) AddBalance(addr common.Address, value *big.Int) { +func (db *inMemoryStateDB) AddBalance(addr common.Address, value *uint256.Int, _ tracing.BalanceChangeReason) { db.state.touched[addr] = 0 - db.state.balances[addr] = new(big.Int).Add(db.GetBalance(addr), value) + db.state.balances[addr] = new(uint256.Int).Add(db.GetBalance(addr), value) } -func (db *inMemoryStateDB) GetBalance(addr common.Address) *big.Int { +func (db *inMemoryStateDB) GetBalance(addr common.Address) *uint256.Int { for state := db.state; state != nil; state = state.parent { val, exists := state.balances[addr] if exists { - return new(big.Int).Set(val) + return val } } acc := db.ws.Get(addr) if acc == nil { - return new(big.Int).Set(common.Big0) + return uint256.MustFromBig(common.Big0) } - return new(big.Int).Set(acc.GetBalance()) + return new(uint256.Int).Set(acc.GetBalance()) } func (db *inMemoryStateDB) GetNonce(addr common.Address) uint64 { @@ -195,7 +203,6 @@ func (db *inMemoryStateDB) GetCommittedState(addr common.Address, key common.Has } func (db *inMemoryStateDB) GetState(addr common.Address, key common.Hash) common.Hash { - //fmt.Printf("SLOAD: %v %v\n", addr, key) slot := slot{addr, key} for state := db.state; state != nil; state = state.parent { val, exists := state.storage[slot] @@ -217,12 +224,16 @@ func (db *inMemoryStateDB) SetState(addr common.Address, key common.Hash, value db.state.storage[slot{addr, key}] = value } -func (db *inMemoryStateDB) Suicide(addr common.Address) bool { +func (db *inMemoryStateDB) GetStorageRoot(addr common.Address, key common.Hash) common.Hash { + panic("GetStorageRoot not implemented") +} + +func (db *inMemoryStateDB) SelfDestruct(addr common.Address) { db.state.suicided[addr] = 0 - db.state.balances[addr] = new(big.Int) // Apparently when you die all your money is gone. - return true + db.state.balances[addr] = new(uint256.Int) // Apparently when you die all your money is gone. } -func (db *inMemoryStateDB) HasSuicided(addr common.Address) bool { + +func (db *inMemoryStateDB) HasSelfDestructed(addr common.Address) bool { for state := db.state; state != nil; state = state.parent { _, exists := state.suicided[addr] if exists { @@ -321,11 +332,6 @@ func (db *inMemoryStateDB) AddPreimage(common.Hash, []byte) { panic("not implemented") } -func (db *inMemoryStateDB) ForEachStorage(common.Address, func(common.Hash, common.Hash) bool) error { - panic("not implemented") - return nil -} - func (db *inMemoryStateDB) Prepare(common.Hash, int) { // nothing to do ... } @@ -446,7 +452,7 @@ func (db *inMemoryStateDB) GetSubstatePostAlloc() txcontext.WorldState { } for key := range res { - if db.HasSuicided(common.Address(key)) || db.Empty(common.Address(key)) { + if db.HasSelfDestructed(common.Address(key)) || db.Empty(common.Address(key)) { delete(res, key) continue } @@ -525,7 +531,7 @@ func (l *gethInMemoryBulkLoad) CreateAccount(addr common.Address) { // ignored } -func (l *gethInMemoryBulkLoad) SetBalance(addr common.Address, value *big.Int) { +func (l *gethInMemoryBulkLoad) SetBalance(addr common.Address, value *uint256.Int) { // ignored } diff --git a/state/state.go b/state/state.go index 3848d1f30..11d3a74ad 100644 --- a/state/state.go +++ b/state/state.go @@ -24,7 +24,10 @@ import ( "github.com/Fantom-foundation/Aida/txcontext" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/tracing" "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/params" + "github.com/holiman/uint256" ) // VmStateDB is the basic StateDB interface required by the EVM and related @@ -32,17 +35,19 @@ import ( type VmStateDB interface { // Account management. CreateAccount(common.Address) + CreateContract(common.Address) Exist(common.Address) bool Empty(common.Address) bool - Suicide(common.Address) bool - HasSuicided(common.Address) bool + SelfDestruct(common.Address) + Selfdestruct6780(common.Address) + HasSelfDestructed(common.Address) bool // Balance - GetBalance(common.Address) *big.Int - AddBalance(common.Address, *big.Int) - SubBalance(common.Address, *big.Int) - + GetBalance(common.Address) *uint256.Int + AddBalance(common.Address, *uint256.Int, tracing.BalanceChangeReason) + SubBalance(common.Address, *uint256.Int, tracing.BalanceChangeReason) + // Nonce GetNonce(common.Address) uint64 SetNonce(common.Address, uint64) @@ -51,6 +56,10 @@ type VmStateDB interface { GetCommittedState(common.Address, common.Hash) common.Hash GetState(common.Address, common.Hash) common.Hash SetState(common.Address, common.Hash, common.Hash) + GetStorageRoot(addr common.Address) common.Hash + + GetTransientState(addr common.Address, key common.Hash) common.Hash + SetTransientState(addr common.Address, key, value common.Hash) // Code handling. GetCodeHash(common.Address) common.Hash @@ -64,7 +73,7 @@ type VmStateDB interface { GetRefund() uint64 // Access list - PrepareAccessList(sender common.Address, dest *common.Address, precompiles []common.Address, txAccesses types.AccessList) + Prepare(params.Rules, common.Address, common.Address, *common.Address, []common.Address, types.AccessList) AddressInAccessList(addr common.Address) bool SlotInAccessList(addr common.Address, slot common.Hash) (addressOk bool, slotOk bool) AddAddressToAccessList(addr common.Address) @@ -72,7 +81,7 @@ type VmStateDB interface { // Logging AddLog(*types.Log) - GetLogs(common.Hash, common.Hash) []*types.Log + GetLogs(common.Hash, uint64, common.Hash) []*types.Log // Transaction handling // There are 4 layers of concepts governing the visibility of state effects: @@ -93,9 +102,7 @@ type VmStateDB interface { // and will be called accordingly by the tracer and EVM runner. However, implementations may // chose to ignore those. - Prepare(common.Hash, int) AddPreimage(common.Hash, []byte) - ForEachStorage(common.Address, func(common.Hash, common.Hash) bool) error // ---- Optional Development & Debugging Features ---- @@ -176,7 +183,7 @@ type StateDB interface { Finalise(bool) IntermediateRoot(bool) common.Hash - Commit(bool) (common.Hash, error) + Commit(uint64, bool) (common.Hash, error) // ---- Optional Development & Debugging Features ---- @@ -188,6 +195,9 @@ type StateDB interface { // the shadow DB can be used to query state directly. If there is no shadow DB, // nil is returned. GetShadowDB() StateDB + + // SetTxContext is geth utility function which set transaction index and transaction hash. + SetTxContext(common.Hash, int) } // BulkWrite is a faster interface to StateDB instances for writing data without @@ -195,7 +205,7 @@ type StateDB interface { // instances before running evaluations. type BulkLoad interface { CreateAccount(common.Address) - SetBalance(common.Address, *big.Int) + SetBalance(common.Address, *uint256.Int) SetNonce(common.Address, uint64) SetState(common.Address, common.Hash, common.Hash) SetCode(common.Address, []byte) diff --git a/state/substate.go b/state/substate.go index 224571d1c..ad25efc7f 100644 --- a/state/substate.go +++ b/state/substate.go @@ -26,17 +26,19 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/state" + "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/trie" + "github.com/ethereum/go-ethereum/triedb" ) // offTheChainDB is state.cachingDB clone without disk caches type offTheChainDB struct { - db *trie.Database + db *triedb.Database } // OpenTrie opens the main account trie at a specific root hash. func (db *offTheChainDB) OpenTrie(root common.Hash) (state.Trie, error) { - tr, err := trie.NewSecure(root, db.db) + tr, err := trie.NewStateTrie(trie.StateTrieID(root), db.db) if err != nil { return nil, err } @@ -44,8 +46,8 @@ func (db *offTheChainDB) OpenTrie(root common.Hash) (state.Trie, error) { } // OpenStorageTrie opens the storage trie of an account. -func (db *offTheChainDB) OpenStorageTrie(addrHash, root common.Hash) (state.Trie, error) { - tr, err := trie.NewSecure(root, db.db) +func (db *offTheChainDB) OpenStorageTrie(stateRoot common.Hash, addrHash, root common.Hash) (state.Trie, error) { + tr, err := trie.NewStateTrie(trie.StorageTrieID(stateRoot, crypto.Keccak256Hash(address.Bytes()), root), db.db) if err != nil { return nil, err } @@ -55,7 +57,7 @@ func (db *offTheChainDB) OpenStorageTrie(addrHash, root common.Hash) (state.Trie // CopyTrie returns an independent copy of the given trie. func (db *offTheChainDB) CopyTrie(t state.Trie) state.Trie { switch t := t.(type) { - case *trie.SecureTrie: + case *trie.StateTrie: return t.Copy() default: panic(fmt.Errorf("unknown trie type %T", t)) @@ -89,7 +91,7 @@ func (db *offTheChainDB) ContractCodeSize(addrHash, codeHash common.Hash) (int, } // TrieDB retrieves any intermediate trie-node caching layer. -func (db *offTheChainDB) TrieDB() *trie.Database { +func (db *offTheChainDB) TrieDB() *triedb.Database { return db.db } diff --git a/tosca b/tosca index 1c4cde3a3..7d737ec9f 160000 --- a/tosca +++ b/tosca @@ -1 +1 @@ -Subproject commit 1c4cde3a36f7abc7067033425ea4e4fbc5bbc730 +Subproject commit 7d737ec9f5f83e4e53b7b8c73cf292fdba1cecde diff --git a/txcontext/account.go b/txcontext/account.go index aa662f379..245e913df 100644 --- a/txcontext/account.go +++ b/txcontext/account.go @@ -24,6 +24,7 @@ import ( "strings" "github.com/ethereum/go-ethereum/common" + "github.com/holiman/uint256" ) // Account represents an interface for interacting with an Ethereum-like account. @@ -32,7 +33,7 @@ type Account interface { GetNonce() uint64 // GetBalance returns the current balance of the account. - GetBalance() *big.Int + GetBalance() *uint256.Int HasStorageAt(key common.Hash) bool @@ -59,13 +60,13 @@ func NewNilAccount() Account { } func NewAccount(code []byte, storage map[common.Hash]common.Hash, balance *big.Int, nonce uint64) Account { - return &account{Code: code, Storage: storage, Balance: balance, Nonce: nonce} + return &account{Code: code, Storage: storage, Balance: uint256.MustFromBig(balance), Nonce: nonce} } type account struct { Code []byte Storage map[common.Hash]common.Hash - Balance *big.Int + Balance *uint256.Int Nonce uint64 } @@ -73,8 +74,8 @@ func (a *account) GetNonce() uint64 { return a.Nonce } -func (a *account) GetBalance() *big.Int { - return new(big.Int).Set(a.Balance) +func (a *account) GetBalance() *uint256.Int { + return new(uint256.Int).Set(a.Balance) } func (a *account) HasStorageAt(key common.Hash) bool { diff --git a/txcontext/nil_tx_context.go b/txcontext/nil_tx_context.go index 9f2b8c24f..07a5c7545 100644 --- a/txcontext/nil_tx_context.go +++ b/txcontext/nil_tx_context.go @@ -31,7 +31,7 @@ func (NilTxContext) GetInputState() WorldState { return nil } func (NilTxContext) GetBlockEnvironment() BlockEnvironment { return nil } -func (NilTxContext) GetMessage() core.Message { return nil } +func (NilTxContext) GetMessage() core.Message { return core.Message{} } func (NilTxContext) GetOutputState() WorldState { return nil } diff --git a/txcontext/substate/account.go b/txcontext/substate/account.go index 49a684589..eded6bd72 100644 --- a/txcontext/substate/account.go +++ b/txcontext/substate/account.go @@ -17,12 +17,11 @@ package substate import ( - "math/big" - "github.com/Fantom-foundation/Aida/txcontext" "github.com/Fantom-foundation/Substate/substate" substatetypes "github.com/Fantom-foundation/Substate/types" "github.com/ethereum/go-ethereum/common" + "github.com/holiman/uint256" ) func NewAccount(acc *substate.Account) txcontext.Account { @@ -37,8 +36,8 @@ func (a *account) GetNonce() uint64 { return a.Nonce } -func (a *account) GetBalance() *big.Int { - return a.Balance +func (a *account) GetBalance() *uint256.Int { + return uint256.MustFromBig(a.Balance) } func (a *account) HasStorageAt(key common.Hash) bool { diff --git a/txcontext/substate/substate.go b/txcontext/substate/substate.go index 9e5e74459..f3edf72fe 100644 --- a/txcontext/substate/substate.go +++ b/txcontext/substate/substate.go @@ -58,7 +58,21 @@ func (t *substateData) GetMessage() core.Message { } list = append(list, types.AccessTuple{Address: common.Address(tuple.Address), StorageKeys: keys}) } - return types.NewMessage(common.Address(t.Message.From), (*common.Address)(t.Message.To), t.Message.Nonce, t.Message.Value, t.Message.Gas, t.Message.GasPrice, t.Message.GasFeeCap, t.Message.GasTipCap, t.Message.Data, list, !t.Message.CheckNonce) + return core.Message{ + (*common.Address)(t.Message.To), + common.Address(t.Message.From), + t.Message.Nonce, + t.Message.Value, + t.Message.Gas, + t.Message.GasPrice, + t.Message.GasFeeCap, + t.Message.GasTipCap, + t.Message.Data, + list, + nil, //TODO support BlobGasFeeCap + []common.Hash{}, //TODO support BlobHashes + !t.Message.CheckNonce, + } } func (t *substateData) GetResult() txcontext.Result { diff --git a/txcontext/txgenerator/norma.go b/txcontext/txgenerator/norma.go index 7b420882c..4c966c8b2 100644 --- a/txcontext/txgenerator/norma.go +++ b/txcontext/txgenerator/norma.go @@ -22,6 +22,7 @@ import ( "github.com/Fantom-foundation/Aida/txcontext" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/types" ) @@ -43,19 +44,21 @@ func NewNormaTxContext(tx *types.Transaction, blkNumber uint64, sender *common.A Env: normaTxBlockEnv{ blkNumber: blkNumber, }, - Message: types.NewMessage( - s, - tx.To(), - tx.Nonce(), - tx.Value(), - tx.Gas(), - tx.GasPrice(), - tx.GasFeeCap(), - tx.GasTipCap(), - tx.Data(), - tx.AccessList(), - false, - ), + Message: core.Message{ + To: tx.To(), + From: s, + Nonce: tx.Nonce(), + Value: tx.Value(), + GasLimit: tx.Gas(), + GasPrice: tx.GasPrice(), + GasFeeCap: tx.GasFeeCap(), + GasTipCap: tx.GasTipCap(), + Data: tx.Data(), + AccessList: tx.AccessList(), + SkipAccountChecks: false, + BlobGasFeeCap: tx.BlobGasFeeCap(), + BlobHashes: tx.BlobHashes(), + }, }, }, nil } From cd523d157912fc7d8789c27a02879f1312aad66b Mon Sep 17 00:00:00 2001 From: wsodsong Date: Wed, 12 Jun 2024 14:13:25 +0000 Subject: [PATCH 02/26] fix state --- state/carmen.go | 1 - state/geth.go | 8 +++----- state/memory.go | 27 +++++++++++++++++++-------- state/state.go | 3 +-- state/substate.go | 30 +++++++++++++++++++----------- txcontext/substate/substate.go | 28 ++++++++++++++-------------- txcontext/txgenerator/norma.go | 24 ++++++++++++------------ 7 files changed, 68 insertions(+), 53 deletions(-) diff --git a/state/carmen.go b/state/carmen.go index cdabe6643..04347deeb 100644 --- a/state/carmen.go +++ b/state/carmen.go @@ -18,7 +18,6 @@ package state import ( "fmt" - "math/big" "strings" "github.com/Fantom-foundation/Aida/txcontext" diff --git a/state/geth.go b/state/geth.go index a84d71054..f396b0a23 100644 --- a/state/geth.go +++ b/state/geth.go @@ -18,10 +18,8 @@ package state import ( "fmt" - "math/big" "github.com/Fantom-foundation/Aida/txcontext" - substatecontext "github.com/Fantom-foundation/Aida/txcontext/substate" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/prque" "github.com/ethereum/go-ethereum/core/rawdb" @@ -60,7 +58,7 @@ func MakeGethStateDB(directory, variant string, rootHash common.Hash, isArchiveM db: db, evmState: evmState, stateRoot: rootHash, - triegc: prque.New[uint64,common.Hash](nil), + triegc: prque.New[uint64, common.Hash](nil), isArchiveMode: isArchiveMode, chainConduit: chainConduit, }, nil @@ -77,7 +75,7 @@ type gethStateDB struct { db vm.StateDB // statedb evmState geth.Database // key-value database stateRoot common.Hash // lastest root hash - triegc *prque.Prque[uint64,common.Hash] + triegc *prque.Prque[uint64, common.Hash] isArchiveMode bool chainConduit *ChainConduit // chain configuration block uint64 @@ -369,7 +367,7 @@ func (s *gethStateDB) GetMemoryUsage() *MemoryUsage { } type gethBulkLoad struct { - db *gethStateDB + db *gethStateDB block uint64 } diff --git a/state/memory.go b/state/memory.go index 1d6f9610f..4e8261178 100644 --- a/state/memory.go +++ b/state/memory.go @@ -109,7 +109,6 @@ func (db *inMemoryStateDB) CreateContract(addr common.Address) { panic("CreateContract not implemented") } - func (db *inMemoryStateDB) SubBalance(addr common.Address, value *uint256.Int, _ tracing.BalanceChangeReason) { if value.Sign() == 0 { return @@ -224,15 +223,27 @@ func (db *inMemoryStateDB) SetState(addr common.Address, key common.Hash, value db.state.storage[slot{addr, key}] = value } -func (db *inMemoryStateDB) GetStorageRoot(addr common.Address, key common.Hash) common.Hash { +func (db *inMemoryStateDB) GetStorageRoot(addr common.Address) common.Hash { panic("GetStorageRoot not implemented") } +func (db *inMemoryStateDB) GetTransientState(addr common.Address, key common.Hash) common.Hash { + panic("GetTransientState not implemented") +} + +func (db *inMemoryStateDB) SetTransientState(addr common.Address, key common.Hash, value common.Hash) { + panic("SetTransientState not implemented") +} + func (db *inMemoryStateDB) SelfDestruct(addr common.Address) { db.state.suicided[addr] = 0 db.state.balances[addr] = new(uint256.Int) // Apparently when you die all your money is gone. } +func (db *inMemoryStateDB) Selfdestruct6780(addr common.Address) { + panic("Selfdestruct6780 not implemented") +} + func (db *inMemoryStateDB) HasSelfDestructed(addr common.Address) bool { for state := db.state; state != nil; state = state.parent { _, exists := state.suicided[addr] @@ -257,7 +268,7 @@ func (db *inMemoryStateDB) Empty(addr common.Address) bool { return db.GetNonce(addr) == 0 && db.GetBalance(addr).Sign() == 0 && db.GetCodeSize(addr) == 0 } -func (db *inMemoryStateDB) PrepareAccessList(sender common.Address, dest *common.Address, precompiles []common.Address, txAccesses types.AccessList) { +func (db *inMemoryStateDB) Prepare(rules params.Rules, sender, coinbase common.Address, dest *common.Address, precompiles []common.Address, txAccesses types.AccessList) { db.AddAddressToAccessList(sender) if dest != nil { db.AddAddressToAccessList(*dest) @@ -332,7 +343,7 @@ func (db *inMemoryStateDB) AddPreimage(common.Hash, []byte) { panic("not implemented") } -func (db *inMemoryStateDB) Prepare(common.Hash, int) { +func (db *inMemoryStateDB) SetTxContext(common.Hash, int) { // nothing to do ... } @@ -343,7 +354,7 @@ func (db *inMemoryStateDB) IntermediateRoot(deleteEmptyObjects bool) common.Hash panic("not implemented") } -func (db *inMemoryStateDB) Commit(deleteEmptyObjects bool) (common.Hash, error) { +func (db *inMemoryStateDB) Commit(block uint64, deleteEmptyObjects bool) (common.Hash, error) { return common.Hash{}, nil } @@ -356,7 +367,7 @@ func collectLogs(s *snapshot) []*types.Log { return logs } -func (db *inMemoryStateDB) GetLogs(txHash common.Hash, blockHash common.Hash) []*types.Log { +func (db *inMemoryStateDB) GetLogs(txHash common.Hash, block uint64, blockHash common.Hash) []*types.Log { // Since the in-memory stateDB is only to be used for a single // transaction, all logs are from the same transactions. But // those need to be collected in the right order (inverse order @@ -384,7 +395,7 @@ func (db *inMemoryStateDB) getEffects() substate.WorldState { for addr := range touched { cur := new(substate.Account) cur.Nonce = db.GetNonce(addr) - cur.Balance = db.GetBalance(addr) + cur.Balance = db.GetBalance(addr).ToBig() cur.Code = db.GetCode(addr) cur.Storage = make(map[substatetypes.Hash]substatetypes.Hash) @@ -418,7 +429,7 @@ func (db *inMemoryStateDB) GetSubstatePostAlloc() txcontext.WorldState { }) res[substatetypes.Address(addr)] = &substate.Account{ Nonce: acc.GetNonce(), - Balance: acc.GetBalance(), + Balance: acc.GetBalance().ToBig(), Storage: storage, Code: acc.GetCode(), } diff --git a/state/state.go b/state/state.go index 11d3a74ad..7a9de1662 100644 --- a/state/state.go +++ b/state/state.go @@ -20,7 +20,6 @@ package state import ( "fmt" - "math/big" "github.com/Fantom-foundation/Aida/txcontext" "github.com/ethereum/go-ethereum/common" @@ -47,7 +46,7 @@ type VmStateDB interface { GetBalance(common.Address) *uint256.Int AddBalance(common.Address, *uint256.Int, tracing.BalanceChangeReason) SubBalance(common.Address, *uint256.Int, tracing.BalanceChangeReason) - + // Nonce GetNonce(common.Address) uint64 SetNonce(common.Address, uint64) diff --git a/state/substate.go b/state/substate.go index ad25efc7f..95b38e61a 100644 --- a/state/substate.go +++ b/state/substate.go @@ -27,13 +27,15 @@ import ( "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/trie" "github.com/ethereum/go-ethereum/triedb" ) // offTheChainDB is state.cachingDB clone without disk caches type offTheChainDB struct { - db *triedb.Database + db *triedb.Database + disk ethdb.Database } // OpenTrie opens the main account trie at a specific root hash. @@ -46,7 +48,7 @@ func (db *offTheChainDB) OpenTrie(root common.Hash) (state.Trie, error) { } // OpenStorageTrie opens the storage trie of an account. -func (db *offTheChainDB) OpenStorageTrie(stateRoot common.Hash, addrHash, root common.Hash) (state.Trie, error) { +func (db *offTheChainDB) OpenStorageTrie(stateRoot common.Hash, address common.Address, root common.Hash, _ trie.Trie) (state.Trie, error) { tr, err := trie.NewStateTrie(trie.StorageTrieID(stateRoot, crypto.Keccak256Hash(address.Bytes()), root), db.db) if err != nil { return nil, err @@ -65,8 +67,8 @@ func (db *offTheChainDB) CopyTrie(t state.Trie) state.Trie { } // ContractCode retrieves a particular contract's code. -func (db *offTheChainDB) ContractCode(addrHash, codeHash common.Hash) ([]byte, error) { - code := rawdb.ReadCode(db.db.DiskDB(), codeHash) +func (db *offTheChainDB) ContractCode(address common.Address, codeHash common.Hash) ([]byte, error) { + code := rawdb.ReadCode(db.disk, codeHash) if len(code) > 0 { return code, nil } @@ -76,8 +78,8 @@ func (db *offTheChainDB) ContractCode(addrHash, codeHash common.Hash) ([]byte, e // ContractCodeWithPrefix retrieves a particular contract's code. If the // code can't be found in the cache, then check the existence with **new** // db scheme. -func (db *offTheChainDB) ContractCodeWithPrefix(addrHash, codeHash common.Hash) ([]byte, error) { - code := rawdb.ReadCodeWithPrefix(db.db.DiskDB(), codeHash) +func (db *offTheChainDB) ContractCodeWithPrefix(address common.Address, codeHash common.Hash) ([]byte, error) { + code := rawdb.ReadCodeWithPrefix(db.disk, codeHash) if len(code) > 0 { return code, nil } @@ -85,11 +87,16 @@ func (db *offTheChainDB) ContractCodeWithPrefix(addrHash, codeHash common.Hash) } // ContractCodeSize retrieves a particular contracts code's size. -func (db *offTheChainDB) ContractCodeSize(addrHash, codeHash common.Hash) (int, error) { - code, err := db.ContractCode(addrHash, codeHash) +func (db *offTheChainDB) ContractCodeSize(address common.Address, codeHash common.Hash) (int, error) { + code, err := db.ContractCode(address, codeHash) return len(code), err } +// DiskDB returns the underlying key-value disk database. +func (db *offTheChainDB) DiskDB() ethdb.KeyValueStore { + return db.disk +} + // TrieDB retrieves any intermediate trie-node caching layer. func (db *offTheChainDB) TrieDB() *triedb.Database { return db.db @@ -101,11 +108,12 @@ func NewOffTheChainStateDB() *state.StateDB { kvdb := rawdb.NewMemoryDatabase() // zeroed trie.Config to disable Cache, Journal, Preimages, ... - zerodConfig := &trie.Config{} - tdb := trie.NewDatabaseWithConfig(kvdb, zerodConfig) + zerodConfig := &triedb.Config{} + tdb := state.NewDatabaseWithConfig(kvdb, zerodConfig) sdb := &offTheChainDB{ - db: tdb, + db: tdb, + disk: kvdb, } statedb, err := state.New(common.Hash{}, sdb, nil) diff --git a/txcontext/substate/substate.go b/txcontext/substate/substate.go index f3edf72fe..31fa215f7 100644 --- a/txcontext/substate/substate.go +++ b/txcontext/substate/substate.go @@ -59,20 +59,20 @@ func (t *substateData) GetMessage() core.Message { list = append(list, types.AccessTuple{Address: common.Address(tuple.Address), StorageKeys: keys}) } return core.Message{ - (*common.Address)(t.Message.To), - common.Address(t.Message.From), - t.Message.Nonce, - t.Message.Value, - t.Message.Gas, - t.Message.GasPrice, - t.Message.GasFeeCap, - t.Message.GasTipCap, - t.Message.Data, - list, - nil, //TODO support BlobGasFeeCap - []common.Hash{}, //TODO support BlobHashes - !t.Message.CheckNonce, - } + (*common.Address)(t.Message.To), + common.Address(t.Message.From), + t.Message.Nonce, + t.Message.Value, + t.Message.Gas, + t.Message.GasPrice, + t.Message.GasFeeCap, + t.Message.GasTipCap, + t.Message.Data, + list, + nil, //TODO support BlobGasFeeCap + []common.Hash{}, //TODO support BlobHashes + !t.Message.CheckNonce, + } } func (t *substateData) GetResult() txcontext.Result { diff --git a/txcontext/txgenerator/norma.go b/txcontext/txgenerator/norma.go index 4c966c8b2..3fa060ffd 100644 --- a/txcontext/txgenerator/norma.go +++ b/txcontext/txgenerator/norma.go @@ -45,19 +45,19 @@ func NewNormaTxContext(tx *types.Transaction, blkNumber uint64, sender *common.A blkNumber: blkNumber, }, Message: core.Message{ - To: tx.To(), - From: s, - Nonce: tx.Nonce(), - Value: tx.Value(), - GasLimit: tx.Gas(), - GasPrice: tx.GasPrice(), - GasFeeCap: tx.GasFeeCap(), - GasTipCap: tx.GasTipCap(), - Data: tx.Data(), - AccessList: tx.AccessList(), + To: tx.To(), + From: s, + Nonce: tx.Nonce(), + Value: tx.Value(), + GasLimit: tx.Gas(), + GasPrice: tx.GasPrice(), + GasFeeCap: tx.GasFeeCap(), + GasTipCap: tx.GasTipCap(), + Data: tx.Data(), + AccessList: tx.AccessList(), SkipAccountChecks: false, - BlobGasFeeCap: tx.BlobGasFeeCap(), - BlobHashes: tx.BlobHashes(), + BlobGasFeeCap: tx.BlobGasFeeCap(), + BlobHashes: tx.BlobHashes(), }, }, }, nil From 7389c6c8c9e83bc0f41fbaa2c4f3c4a24132d3da Mon Sep 17 00:00:00 2001 From: wsodsong Date: Wed, 12 Jun 2024 14:35:22 +0000 Subject: [PATCH 03/26] fix off-the-chain db --- state/substate.go | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/state/substate.go b/state/substate.go index 95b38e61a..bd79b758d 100644 --- a/state/substate.go +++ b/state/substate.go @@ -20,7 +20,6 @@ package state import ( "errors" "fmt" - "math/big" "github.com/Fantom-foundation/Aida/txcontext" "github.com/ethereum/go-ethereum/common" @@ -34,13 +33,13 @@ import ( // offTheChainDB is state.cachingDB clone without disk caches type offTheChainDB struct { - db *triedb.Database + trie *triedb.Database disk ethdb.Database } // OpenTrie opens the main account trie at a specific root hash. func (db *offTheChainDB) OpenTrie(root common.Hash) (state.Trie, error) { - tr, err := trie.NewStateTrie(trie.StateTrieID(root), db.db) + tr, err := trie.NewStateTrie(trie.StateTrieID(root), db.trie) if err != nil { return nil, err } @@ -48,8 +47,8 @@ func (db *offTheChainDB) OpenTrie(root common.Hash) (state.Trie, error) { } // OpenStorageTrie opens the storage trie of an account. -func (db *offTheChainDB) OpenStorageTrie(stateRoot common.Hash, address common.Address, root common.Hash, _ trie.Trie) (state.Trie, error) { - tr, err := trie.NewStateTrie(trie.StorageTrieID(stateRoot, crypto.Keccak256Hash(address.Bytes()), root), db.db) +func (db *offTheChainDB) OpenStorageTrie(stateRoot common.Hash, address common.Address, root common.Hash, _ state.Trie) (state.Trie, error) { + tr, err := trie.NewStateTrie(trie.StorageTrieID(stateRoot, crypto.Keccak256Hash(address.Bytes()), root), db.trie) if err != nil { return nil, err } @@ -99,7 +98,7 @@ func (db *offTheChainDB) DiskDB() ethdb.KeyValueStore { // TrieDB retrieves any intermediate trie-node caching layer. func (db *offTheChainDB) TrieDB() *triedb.Database { - return db.db + return db.trie } // NewOffTheChainStateDB returns an empty in-memory *state.StateDB without disk caches @@ -109,10 +108,10 @@ func NewOffTheChainStateDB() *state.StateDB { // zeroed trie.Config to disable Cache, Journal, Preimages, ... zerodConfig := &triedb.Config{} - tdb := state.NewDatabaseWithConfig(kvdb, zerodConfig) + tdb := triedb.NewDatabase(kvdb, zerodConfig) sdb := &offTheChainDB{ - db: tdb, + trie: tdb, disk: kvdb, } @@ -128,9 +127,9 @@ func MakeOffTheChainStateDB(alloc txcontext.WorldState, block uint64, chainCondu statedb := NewOffTheChainStateDB() alloc.ForEachAccount(func(addr common.Address, acc txcontext.Account) { code := acc.GetCode() - statedb.SetPrehashedCode(addr, createCodeHash(code), code) + statedb.SetCode(addr, code) statedb.SetNonce(addr, acc.GetNonce()) - statedb.SetBalance(addr, acc.GetBalance()) + statedb.SetBalance(addr, acc.GetBalance(), 0) // DON'T USE SetStorage because it makes REVERT and dirtyStorage unavailble acc.ForEachStorage(func(keyHash common.Hash, valueHash common.Hash) { statedb.SetState(addr, keyHash, valueHash) @@ -138,11 +137,10 @@ func MakeOffTheChainStateDB(alloc txcontext.WorldState, block uint64, chainCondu }) // Commit and re-open to start with a clean state. - _, err := statedb.Commit(false) + _, err := statedb.Commit(block, false) if err != nil { return nil, fmt.Errorf("cannot commit offTheChainDb; %v", err) } - blk := new(big.Int).SetUint64(block) - return &gethStateDB{db: statedb, block: blk, chainConduit: chainConduit}, nil + return &gethStateDB{db: statedb, block: block, chainConduit: chainConduit}, nil } From 7ecd8c6711bcdc0474b38123864dcefb4208774c Mon Sep 17 00:00:00 2001 From: wsodsong Date: Wed, 12 Jun 2024 14:51:33 +0000 Subject: [PATCH 04/26] apply workaround to tracer operations --- tracer/operation/addbalance.go | 14 +++++++------- tracer/operation/hassuicided.go | 3 ++- tracer/operation/subbalance.go | 16 ++++++++-------- tracer/operation/suicide.go | 2 +- 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/tracer/operation/addbalance.go b/tracer/operation/addbalance.go index 8eeca50c4..8659adb26 100644 --- a/tracer/operation/addbalance.go +++ b/tracer/operation/addbalance.go @@ -21,13 +21,12 @@ import ( "fmt" "io" "log" - "math/big" "time" "github.com/ethereum/go-ethereum/common" - "github.com/Fantom-foundation/Aida/state" "github.com/Fantom-foundation/Aida/tracer/context" + "github.com/holiman/uint256" ) // AddBalance data structure @@ -42,14 +41,14 @@ func (op *AddBalance) GetId() byte { } // NewAddBalance creates a new add-balance operation. -func NewAddBalance(contract common.Address, amount *big.Int) *AddBalance { +func NewAddBalance(contract common.Address, amount *uint256.Int) *AddBalance { // check if amount requires more than 256 bits (16 bytes) if amount.BitLen() > 256 { log.Fatalf("Amount exceeds 256 bit") } ret := &AddBalance{Contract: contract} // copy amount to a 16-byte array with leading zeros - amount.FillBytes(ret.Amount[:]) + amount.SetBytes(ret.Amount[:]) return ret } @@ -70,13 +69,14 @@ func (op *AddBalance) Write(f io.Writer) error { func (op *AddBalance) Execute(db state.StateDB, ctx *context.Replay) time.Duration { contract := ctx.DecodeContract(op.Contract) // construct bit.Int from a byte array - amount := new(big.Int).SetBytes(op.Amount[:]) + amount := new(uint256.Int).SetBytes(op.Amount[:]) start := time.Now() - db.AddBalance(contract, amount) + // ignore reason + db.AddBalance(contract, amount, 0) return time.Since(start) } // Debug prints a debug message for the add-balance operation. func (op *AddBalance) Debug(ctx *context.Context) { - fmt.Print(op.Contract, new(big.Int).SetBytes(op.Amount[:])) + fmt.Print(op.Contract, new(uint256.Int).SetBytes(op.Amount[:])) } diff --git a/tracer/operation/hassuicided.go b/tracer/operation/hassuicided.go index 5f8a043d2..0cc976c3e 100644 --- a/tracer/operation/hassuicided.go +++ b/tracer/operation/hassuicided.go @@ -59,7 +59,8 @@ func (op *HasSuicided) Write(f io.Writer) error { func (op *HasSuicided) Execute(db state.StateDB, ctx *context.Replay) time.Duration { contract := ctx.DecodeContract(op.Contract) start := time.Now() - db.HasSuicided(contract) + //TODO change function name + db.HasSelfDestructed(contract) return time.Since(start) } diff --git a/tracer/operation/subbalance.go b/tracer/operation/subbalance.go index 632bca955..295cd14bf 100644 --- a/tracer/operation/subbalance.go +++ b/tracer/operation/subbalance.go @@ -21,13 +21,12 @@ import ( "fmt" "io" "log" - "math/big" "time" - "github.com/Fantom-foundation/Aida/state" "github.com/ethereum/go-ethereum/common" - + "github.com/Fantom-foundation/Aida/state" "github.com/Fantom-foundation/Aida/tracer/context" + "github.com/holiman/uint256" ) // SubBalance data structure @@ -42,14 +41,14 @@ func (op *SubBalance) GetId() byte { } // NewSubBalance creates a new sub-balance operation. -func NewSubBalance(contract common.Address, amount *big.Int) *SubBalance { +func NewSubBalance(contract common.Address, amount *uint256.Int) *SubBalance { // check if amount requires more than 256 bits (16 bytes) if amount.BitLen() > 256 { log.Fatalf("Amount exceeds 256 bit") } ret := &SubBalance{Contract: contract} // copy amount to a 16-byte array with leading zeros - amount.FillBytes(ret.Amount[:]) + amount.SetBytes(ret.Amount[:]) return ret } @@ -70,13 +69,14 @@ func (op *SubBalance) Write(f io.Writer) error { func (op *SubBalance) Execute(db state.StateDB, ctx *context.Replay) time.Duration { contract := ctx.DecodeContract(op.Contract) // construct bit.Int from a byte array - amount := new(big.Int).SetBytes(op.Amount[:]) + amount := new(uint256.Int).SetBytes(op.Amount[:]) start := time.Now() - db.SubBalance(contract, amount) + // Ignore reason + db.SubBalance(contract, amount, 0) return time.Since(start) } // Debug prints a debug message for the sub-balance operation. func (op *SubBalance) Debug(ctx *context.Context) { - fmt.Print(op.Contract, new(big.Int).SetBytes(op.Amount[:])) + fmt.Print(op.Contract, new(uint256.Int).SetBytes(op.Amount[:])) } diff --git a/tracer/operation/suicide.go b/tracer/operation/suicide.go index 02de6aa6d..359d9bc2a 100644 --- a/tracer/operation/suicide.go +++ b/tracer/operation/suicide.go @@ -60,7 +60,7 @@ func (op *Suicide) Write(f io.Writer) error { func (op *Suicide) Execute(db state.StateDB, ctx *context.Replay) time.Duration { contract := ctx.DecodeContract(op.Contract) start := time.Now() - db.Suicide(contract) + db.SelfDestruct(contract) return time.Since(start) } From f06f19d7b9f1005c215f0b459f3f830b32c6f8a4 Mon Sep 17 00:00:00 2001 From: wsodsong Date: Thu, 13 Jun 2024 07:50:50 +0000 Subject: [PATCH 05/26] fix proxy --- executor/transaction_processor.go | 4 +- state/proxy/deletion.go | 80 +++++++++++++++------------ state/proxy/logger.go | 87 +++++++++++++++++++----------- state/proxy/profiler.go | 78 +++++++++++++++------------ state/proxy/recorder.go | 74 ++++++++++++++----------- state/proxy/shadow.go | 89 ++++++++++++++++++++----------- state/proxy/shadow_test.go | 12 ++--- 7 files changed, 258 insertions(+), 166 deletions(-) diff --git a/executor/transaction_processor.go b/executor/transaction_processor.go index 025a89a21..58fa38553 100644 --- a/executor/transaction_processor.go +++ b/executor/transaction_processor.go @@ -158,7 +158,7 @@ func (s *TxProcessor) processRegularTx(db state.VmStateDB, block int, tx int, st // prepare tx gasPool.AddGas(inputEnv.GetGasLimit()) - db.Prepare(txHash, tx) + db.SetTxContext(txHash, tx) blockCtx := prepareBlockCtx(inputEnv, &hashError) txCtx := evmcore.NewEVMTxContext(msg) evm := vm.NewEVM(*blockCtx, txCtx, db, s.chainCfg, s.vmCfg) @@ -184,7 +184,7 @@ func (s *TxProcessor) processRegularTx(db state.VmStateDB, block int, tx int, st // if no prior error, create result and pass it to the data. blockHash := common.HexToHash(fmt.Sprintf("0x%016d", block)) - res = newTransactionResult(db.GetLogs(txHash, blockHash), msg, msgResult, err, evm.TxContext.Origin) + res = newTransactionResult(db.GetLogs(txHash, uint64(block), blockHash), msg, msgResult, err, evm.TxContext.Origin) return } diff --git a/state/proxy/deletion.go b/state/proxy/deletion.go index e6827ba99..a89662b37 100644 --- a/state/proxy/deletion.go +++ b/state/proxy/deletion.go @@ -17,13 +17,14 @@ package proxy import ( - "math/big" - "github.com/Fantom-foundation/Aida/logger" "github.com/Fantom-foundation/Aida/state" "github.com/Fantom-foundation/Aida/txcontext" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/tracing" "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/params" + "github.com/holiman/uint256" ) type ContractLiveliness struct { @@ -55,17 +56,17 @@ func (r *DeletionProxy) CreateAccount(addr common.Address) { } // SubBalance subtracts amount from a contract address. -func (r *DeletionProxy) SubBalance(addr common.Address, amount *big.Int) { - r.db.SubBalance(addr, amount) +func (r *DeletionProxy) SubBalance(addr common.Address, amount *uint256.Int, reason tracing.BalanceChangeReason) { + r.db.SubBalance(addr, amount, reason) } // AddBalance adds amount to a contract address. -func (r *DeletionProxy) AddBalance(addr common.Address, amount *big.Int) { - r.db.AddBalance(addr, amount) +func (r *DeletionProxy) AddBalance(addr common.Address, amount *uint256.Int, reason tracing.BalanceChangeReason) { + r.db.AddBalance(addr, amount, reason) } // GetBalance retrieves the amount of a contract address. -func (r *DeletionProxy) GetBalance(addr common.Address) *big.Int { +func (r *DeletionProxy) GetBalance(addr common.Address) *uint256.Int { balance := r.db.GetBalance(addr) return balance } @@ -137,21 +138,18 @@ func (r *DeletionProxy) SetState(addr common.Address, key common.Hash, value com r.db.SetState(addr, key, value) } -// Suicide marks the given account as suicided. This clears the account balance. +// SelfDestruct marks the given account as suicided. This clears the account balance. // The account is still available until the state is committed; -// return a non-nil account after Suicide. -func (r *DeletionProxy) Suicide(addr common.Address) bool { - ok := r.db.Suicide(addr) - if ok { - r.ch <- ContractLiveliness{Addr: addr, IsDeleted: true} - } - return ok +// return a non-nil account after SelfDestruct. +func (r *DeletionProxy) SelfDestruct(addr common.Address) { + r.db.SelfDestruct(addr) + r.ch <- ContractLiveliness{Addr: addr, IsDeleted: true} } -// HasSuicided checks whether a contract has been suicided. -func (r *DeletionProxy) HasSuicided(addr common.Address) bool { - hasSuicided := r.db.HasSuicided(addr) - return hasSuicided +// HasSelfDestructed checks whether a contract has been suicided. +func (r *DeletionProxy) HasSelfDestructed(addr common.Address) bool { + hasSelfDestructed := r.db.HasSelfDestructed(addr) + return hasSelfDestructed } // Exist checks whether the contract exists in the StateDB. @@ -167,7 +165,7 @@ func (r *DeletionProxy) Empty(addr common.Address) bool { return empty } -// PrepareAccessList handles the preparatory steps for executing a state transition with +// Prepare handles the preparatory steps for executing a state transition with // regards to both EIP-2929 and EIP-2930: // // - Add sender to access list (2929) @@ -176,8 +174,8 @@ func (r *DeletionProxy) Empty(addr common.Address) bool { // - Add the contents of the optional tx access list (2930) // // This method should only be called if Berlin/2929+2930 is applicable at the current number. -func (r *DeletionProxy) PrepareAccessList(render common.Address, dest *common.Address, precompiles []common.Address, txAccesses types.AccessList) { - r.db.PrepareAccessList(render, dest, precompiles, txAccesses) +func (r *DeletionProxy) Prepare(rules params.Rules, sender, coinbase common.Address, dest *common.Address, precompiles []common.Address, txAccesses types.AccessList) { + r.db.Prepare(rules, sender, coinbase, dest, precompiles, txAccesses) } // AddAddressToAccessList adds an address to the access list. @@ -219,8 +217,8 @@ func (r *DeletionProxy) AddLog(log *types.Log) { } // GetLogs retrieves log entries. -func (r *DeletionProxy) GetLogs(hash common.Hash, blockHash common.Hash) []*types.Log { - return r.db.GetLogs(hash, blockHash) +func (r *DeletionProxy) GetLogs(hash common.Hash, block uint64, blockHash common.Hash) []*types.Log { + return r.db.GetLogs(hash, block, blockHash) } // AddPreimage adds a SHA3 preimage. @@ -228,14 +226,9 @@ func (r *DeletionProxy) AddPreimage(addr common.Hash, image []byte) { r.db.AddPreimage(addr, image) } -// ForEachStorage performs a function over all storage locations in a contract. -func (r *DeletionProxy) ForEachStorage(addr common.Address, fn func(common.Hash, common.Hash) bool) error { - return r.db.ForEachStorage(addr, fn) -} - // Prepare sets the current transaction hash and index. -func (r *DeletionProxy) Prepare(thash common.Hash, ti int) { - r.db.Prepare(thash, ti) +func (r *DeletionProxy) SetTxContext(thash common.Hash, ti int) { + r.db.SetTxContext(thash, ti) } // Finalise the state in StateDB. @@ -250,8 +243,8 @@ func (r *DeletionProxy) IntermediateRoot(deleteEmptyObjects bool) common.Hash { return r.db.IntermediateRoot(deleteEmptyObjects) } -func (r *DeletionProxy) Commit(deleteEmptyObjects bool) (common.Hash, error) { - return r.db.Commit(deleteEmptyObjects) +func (r *DeletionProxy) Commit(block uint64, deleteEmptyObjects bool) (common.Hash, error) { + return r.db.Commit(block, deleteEmptyObjects) } func (r *DeletionProxy) GetHash() (common.Hash, error) { @@ -319,3 +312,24 @@ func (r *DeletionProxy) GetMemoryUsage() *state.MemoryUsage { func (r *DeletionProxy) GetShadowDB() state.StateDB { return r.db.GetShadowDB() } + +func (r *DeletionProxy) CreateContract(addr common.Address) { + r.db.CreateContract(addr) +} + +func (r *DeletionProxy) Selfdestruct6780(addr common.Address) { + r.db.Selfdestruct6780(addr) +} + +func (r *DeletionProxy) GetStorageRoot(addr common.Address) common.Hash { + return r.db.GetStorageRoot(addr) +} + +func (r *DeletionProxy) SetTransientState(addr common.Address, key common.Hash, value common.Hash) { + r.db.SetTransientState(addr, key, value) +} + +func (r *DeletionProxy) GetTransientState(addr common.Address, key common.Hash) common.Hash { + value := r.db.GetTransientState(addr, key) + return value +} diff --git a/state/proxy/logger.go b/state/proxy/logger.go index cf4a64840..2592cd11a 100644 --- a/state/proxy/logger.go +++ b/state/proxy/logger.go @@ -19,14 +19,16 @@ package proxy import ( "encoding/hex" "fmt" - "math/big" "sync" "github.com/Fantom-foundation/Aida/logger" "github.com/Fantom-foundation/Aida/state" "github.com/Fantom-foundation/Aida/txcontext" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/tracing" "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/params" + "github.com/holiman/uint256" ) // NewLoggerProxy wraps the given StateDB instance into a logging wrapper causing @@ -78,32 +80,31 @@ func (s *loggingVmStateDb) Empty(addr common.Address) bool { return res } -func (s *loggingVmStateDb) Suicide(addr common.Address) bool { - res := s.db.Suicide(addr) - s.writeLog("Suicide, %v, %v", addr, res) - return res +func (s *loggingVmStateDb) SelfDestruct(addr common.Address) { + s.db.SelfDestruct(addr) + s.writeLog("SelfDestruct, %v", addr) } -func (s *loggingVmStateDb) HasSuicided(addr common.Address) bool { - res := s.db.HasSuicided(addr) - s.writeLog("HasSuicided, %v, %v", addr, res) +func (s *loggingVmStateDb) HasSelfDestructed(addr common.Address) bool { + res := s.db.HasSelfDestructed(addr) + s.writeLog("HasSelfDestructed, %v, %v", addr, res) return res } -func (s *loggingVmStateDb) GetBalance(addr common.Address) *big.Int { +func (s *loggingVmStateDb) GetBalance(addr common.Address) *uint256.Int { res := s.db.GetBalance(addr) s.writeLog("GetBalance, %v, %v", addr, res) return res } -func (s *loggingVmStateDb) AddBalance(addr common.Address, value *big.Int) { - s.db.AddBalance(addr, value) - s.writeLog("AddBalance, %v, %v, %v", addr, value, s.db.GetBalance(addr)) +func (s *loggingVmStateDb) AddBalance(addr common.Address, value *uint256.Int, reason tracing.BalanceChangeReason) { + s.db.AddBalance(addr, value, reason) + s.writeLog("AddBalance, %v, %v, %v, %v", addr, value, s.db.GetBalance(addr), reason) } -func (s *loggingVmStateDb) SubBalance(addr common.Address, value *big.Int) { - s.db.SubBalance(addr, value) - s.writeLog("SubBalance, %v, %v, %v", addr, value, s.db.GetBalance(addr)) +func (s *loggingVmStateDb) SubBalance(addr common.Address, value *uint256.Int, reason tracing.BalanceChangeReason) { + s.db.SubBalance(addr, value, reason) + s.writeLog("SubBalance, %v, %v, %v, %v", addr, value, s.db.GetBalance(addr), reason) } func (s *loggingVmStateDb) GetNonce(addr common.Address) uint64 { @@ -246,9 +247,9 @@ func (s *loggingVmStateDb) GetRefund() uint64 { return res } -func (s *loggingVmStateDb) PrepareAccessList(sender common.Address, dest *common.Address, precompiles []common.Address, txAccesses types.AccessList) { - s.writeLog("PrepareAccessList, %v, %v, %v, %v", sender, dest, precompiles, txAccesses) - s.db.PrepareAccessList(sender, dest, precompiles, txAccesses) +func (s *loggingVmStateDb) Prepare(rules params.Rules, sender, coinbase common.Address, dest *common.Address, precompiles []common.Address, txAccesses types.AccessList) { + s.writeLog("Prepare, %v, %v, %v, %v", sender, dest, precompiles, txAccesses) + s.db.Prepare(rules, sender, coinbase, dest, precompiles, txAccesses) } func (s *loggingVmStateDb) AddressInAccessList(addr common.Address) bool { @@ -278,9 +279,9 @@ func (s *loggingVmStateDb) AddLog(entry *types.Log) { s.db.AddLog(entry) } -func (s *loggingVmStateDb) GetLogs(hash common.Hash, blockHash common.Hash) []*types.Log { - res := s.db.GetLogs(hash, blockHash) - s.writeLog("GetLogs, %v, %v, %v", hash, blockHash, res) +func (s *loggingVmStateDb) GetLogs(hash common.Hash, block uint64, blockHash common.Hash) []*types.Log { + res := s.db.GetLogs(hash, block, blockHash) + s.writeLog("GetLogs, %v, %v, %v, %v", hash, block, blockHash, res) return res } @@ -295,15 +296,15 @@ func (s *LoggingStateDb) IntermediateRoot(deleteEmptyObjects bool) common.Hash { return res } -func (s *LoggingStateDb) Commit(deleteEmptyObjects bool) (common.Hash, error) { - hash, err := s.state.Commit(deleteEmptyObjects) +func (s *LoggingStateDb) Commit(block uint64, deleteEmptyObjects bool) (common.Hash, error) { + hash, err := s.state.Commit(block, deleteEmptyObjects) s.writeLog("Commit, %v, %v, %v", deleteEmptyObjects, hash, err) return hash, err } -func (s *loggingVmStateDb) Prepare(thash common.Hash, ti int) { - s.db.Prepare(thash, ti) - s.writeLog("Prepare, %v, %v", thash, ti) +func (s *LoggingStateDb) SetTxContext(thash common.Hash, ti int) { + s.state.SetTxContext(thash, ti) + s.writeLog("SetTxContext, %v, %v", thash, ti) } func (s *LoggingStateDb) PrepareSubstate(substate txcontext.WorldState, block uint64) { @@ -322,11 +323,6 @@ func (s *loggingVmStateDb) AddPreimage(hash common.Hash, data []byte) { s.writeLog("AddPreimage, %v, %v", hash, data) } -func (s *loggingVmStateDb) ForEachStorage(addr common.Address, op func(common.Hash, common.Hash) bool) error { - // no logging in this case - return s.db.ForEachStorage(addr, op) -} - func (s *LoggingStateDb) StartBulkLoad(block uint64) (state.BulkLoad, error) { bl, err := s.state.StartBulkLoad(block) if err != nil { @@ -368,6 +364,33 @@ func (s *LoggingStateDb) GetShadowDB() state.StateDB { return s.state.GetShadowDB() } +func (s *loggingVmStateDb) CreateContract(addr common.Address) { + s.writeLog("CreateContract, %v", addr) + s.db.CreateContract(addr) +} + +func (s *loggingVmStateDb) Selfdestruct6780(addr common.Address) { + s.writeLog("Selfdestruct6780, %v", addr) + s.db.Selfdestruct6780(addr) +} + +func (s *loggingVmStateDb) GetStorageRoot(addr common.Address) common.Hash { + res := s.db.GetStorageRoot(addr) + s.writeLog("GetStorageRoot, %v, %v", res, addr) + return res +} + +func (s *loggingVmStateDb) SetTransientState(addr common.Address, key common.Hash, value common.Hash) { + s.writeLog("SetTransientState, %v, %v, %v", addr, key, value) + s.db.SetTransientState(addr, key, value) +} + +func (s *loggingVmStateDb) GetTransientState(addr common.Address, key common.Hash) common.Hash { + value := s.db.GetTransientState(addr, key) + s.writeLog("GetTransientState, %v, %v, %v", value, addr, key) + return value +} + func (s *loggingNonCommittableStateDb) Release() error { s.writeLog("Release") s.nonCommittableStateDB.Release() @@ -383,7 +406,7 @@ func (l *loggingBulkLoad) CreateAccount(addr common.Address) { l.nested.CreateAccount(addr) l.writeLog("Bulk, CreateAccount, %v", addr) } -func (l *loggingBulkLoad) SetBalance(addr common.Address, balance *big.Int) { +func (l *loggingBulkLoad) SetBalance(addr common.Address, balance *uint256.Int) { l.nested.SetBalance(addr, balance) l.writeLog("Bulk, SetBalance, %v, %v", addr, balance) } diff --git a/state/proxy/profiler.go b/state/proxy/profiler.go index 016681c4b..050a21aa9 100644 --- a/state/proxy/profiler.go +++ b/state/proxy/profiler.go @@ -18,7 +18,6 @@ package proxy import ( "fmt" - "math/big" "time" "github.com/Fantom-foundation/Aida/logger" @@ -27,7 +26,10 @@ import ( "github.com/Fantom-foundation/Aida/txcontext" "github.com/Fantom-foundation/Aida/utils/analytics" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/tracing" "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/params" + "github.com/holiman/uint256" ) // ProfilerProxy data structure for capturing and recording @@ -55,22 +57,22 @@ func (p *ProfilerProxy) CreateAccount(addr common.Address) { } // SubBalance subtracts amount from a contract address. -func (p *ProfilerProxy) SubBalance(addr common.Address, amount *big.Int) { +func (p *ProfilerProxy) SubBalance(addr common.Address, amount *uint256.Int, reason tracing.BalanceChangeReason) { p.do(operation.SubBalanceID, func() { - p.db.SubBalance(addr, amount) + p.db.SubBalance(addr, amount, reason) }) } // AddBalance adds amount to a contract address. -func (p *ProfilerProxy) AddBalance(addr common.Address, amount *big.Int) { +func (p *ProfilerProxy) AddBalance(addr common.Address, amount *uint256.Int, reason tracing.BalanceChangeReason) { p.do(operation.AddBalanceID, func() { - p.db.AddBalance(addr, amount) + p.db.AddBalance(addr, amount, reason) }) } // GetBalance retrieves the amount of a contract address. -func (p *ProfilerProxy) GetBalance(addr common.Address) *big.Int { - var res *big.Int +func (p *ProfilerProxy) GetBalance(addr common.Address) *uint256.Int { + var res *uint256.Int p.do(operation.GetBalanceID, func() { res = p.db.GetBalance(addr) }) @@ -175,22 +177,20 @@ func (p *ProfilerProxy) SetState(addr common.Address, key common.Hash, value com }) } -// Suicide marks the given account as suicided. This clears the account balance. +// SelfDestruct marks the given account as suicided. This clears the account balance. // The account is still available until the state is committed; -// return a non-nil account after Suicide. -func (p *ProfilerProxy) Suicide(addr common.Address) bool { - var suicide bool +// return a non-nil account after SelfDestruct. +func (p *ProfilerProxy) SelfDestruct(addr common.Address) { p.do(operation.SuicideID, func() { - suicide = p.db.Suicide(addr) + p.db.SelfDestruct(addr) }) - return suicide } -// HasSuicided checks whether a contract has been suicided. -func (p *ProfilerProxy) HasSuicided(addr common.Address) bool { +// HasSelfDestructed checks whether a contract has been suicided. +func (p *ProfilerProxy) HasSelfDestructed(addr common.Address) bool { var res bool p.do(operation.HasSuicidedID, func() { - res = p.db.HasSuicided(addr) + res = p.db.HasSelfDestructed(addr) }) return res } @@ -224,9 +224,9 @@ func (p *ProfilerProxy) Empty(addr common.Address) bool { // - Add the contents of the optional tx access list (2930) // // This method should only be called if Berlin/2929+2930 is applicable at the current number. -func (p *ProfilerProxy) PrepareAccessList(render common.Address, dest *common.Address, precompiles []common.Address, txAccesses types.AccessList) { +func (p *ProfilerProxy) PrepareAccessList(rules params.Rules, sender, coinbase common.Address, dest *common.Address, precompiles []common.Address, txAccesses types.AccessList) { p.do(operation.PrepareAccessListID, func() { - p.db.PrepareAccessList(render, dest, precompiles, txAccesses) + p.db.Prepare(rules, sender, coinbase, dest, precompiles, txAccesses) }) } @@ -346,10 +346,10 @@ func (p *ProfilerProxy) AddLog(log *types.Log) { } // GetLogs retrieves log entries. -func (p *ProfilerProxy) GetLogs(hash common.Hash, blockHash common.Hash) []*types.Log { +func (p *ProfilerProxy) GetLogs(hash common.Hash, block uint64, blockHash common.Hash) []*types.Log { var logs []*types.Log p.do(operation.GetLogsID, func() { - logs = p.db.GetLogs(hash, blockHash) + logs = p.db.GetLogs(hash, block, blockHash) }) return logs } @@ -361,19 +361,10 @@ func (p *ProfilerProxy) AddPreimage(addr common.Hash, image []byte) { }) } -// ForEachStorage performs a function over all storage locations in a contract. -func (p *ProfilerProxy) ForEachStorage(addr common.Address, fn func(common.Hash, common.Hash) bool) error { - var err error - p.do(operation.ForEachStorageID, func() { - err = p.db.ForEachStorage(addr, fn) - }) - return err -} - // Prepare sets the current transaction hash and index. -func (p *ProfilerProxy) Prepare(thash common.Hash, ti int) { +func (p *ProfilerProxy) SetTxContext(thash common.Hash, ti int) { p.do(operation.PrepareID, func() { - p.db.Prepare(thash, ti) + p.db.SetTxContext(thash, ti) }) } @@ -395,11 +386,11 @@ func (p *ProfilerProxy) IntermediateRoot(deleteEmptyObjects bool) common.Hash { return hash } -func (p *ProfilerProxy) Commit(deleteEmptyObjects bool) (common.Hash, error) { +func (p *ProfilerProxy) Commit(block uint64, deleteEmptyObjects bool) (common.Hash, error) { var hash common.Hash var err error p.do(operation.CommitID, func() { - hash, err = p.db.Commit(deleteEmptyObjects) + hash, err = p.db.Commit(block, deleteEmptyObjects) }) return hash, err } @@ -441,3 +432,24 @@ func (p *ProfilerProxy) GetMemoryUsage() *state.MemoryUsage { func (p *ProfilerProxy) GetShadowDB() state.StateDB { return p.db.GetShadowDB() } + +//TODO profile new operations +func (p *ProfilerProxy) CreateContract(addr common.Address) { + p.db.CreateContract(addr) +} + +func (p *ProfilerProxy) Selfdestruct6780(addr common.Address) { + p.db.Selfdestruct6780(addr) +} + +func (p *ProfilerProxy) GetStorageRoot(addr common.Address) common.Hash { + return p.db.GetStorageRoot(addr) +} + +func (p *ProfilerProxy) SetTransientState(addr common.Address, key common.Hash, value common.Hash) { + p.db.SetTransientState(addr, key, value) +} + +func (p *ProfilerProxy) GetTransientState(addr common.Address, key common.Hash) common.Hash { + return p.db.GetTransientState(addr, key) +} diff --git a/state/proxy/recorder.go b/state/proxy/recorder.go index 341ec616f..ca25f90f9 100644 --- a/state/proxy/recorder.go +++ b/state/proxy/recorder.go @@ -18,14 +18,16 @@ package proxy import ( "fmt" - "math/big" "github.com/Fantom-foundation/Aida/state" "github.com/Fantom-foundation/Aida/tracer/context" "github.com/Fantom-foundation/Aida/tracer/operation" "github.com/Fantom-foundation/Aida/txcontext" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/tracing" "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/params" + "github.com/holiman/uint256" ) // RecorderProxy data structure for capturing and recording @@ -56,21 +58,21 @@ func (r *RecorderProxy) CreateAccount(addr common.Address) { } // SubBalance subtracts amount from a contract address. -func (r *RecorderProxy) SubBalance(addr common.Address, amount *big.Int) { +func (r *RecorderProxy) SubBalance(addr common.Address, amount *uint256.Int, reason tracing.BalanceChangeReason) { contract := r.ctx.EncodeContract(addr) r.write(operation.NewSubBalance(contract, amount)) - r.db.SubBalance(addr, amount) + r.db.SubBalance(addr, amount, reason) } // AddBalance adds amount to a contract address. -func (r *RecorderProxy) AddBalance(addr common.Address, amount *big.Int) { +func (r *RecorderProxy) AddBalance(addr common.Address, amount *uint256.Int, reason tracing.BalanceChangeReason) { contract := r.ctx.EncodeContract(addr) r.write(operation.NewAddBalance(contract, amount)) - r.db.AddBalance(addr, amount) + r.db.AddBalance(addr, amount, reason) } // GetBalance retrieves the amount of a contract address. -func (r *RecorderProxy) GetBalance(addr common.Address) *big.Int { +func (r *RecorderProxy) GetBalance(addr common.Address) *uint256.Int { contract := r.ctx.EncodeContract(addr) r.write(operation.NewGetBalance(contract)) balance := r.db.GetBalance(addr) @@ -194,20 +196,19 @@ func (r *RecorderProxy) SetState(addr common.Address, key common.Hash, value com r.db.SetState(addr, key, value) } -// Suicide marks the given account as suicided. This clears the account balance. +// SelfDestruct marks the given account as suicided. This clears the account balance. // The account is still available until the state is committed; -// return a non-nil account after Suicide. -func (r *RecorderProxy) Suicide(addr common.Address) bool { +// return a non-nil account after SelfDestruct. +func (r *RecorderProxy) SelfDestruct(addr common.Address) { contract := r.ctx.EncodeContract(addr) r.write(operation.NewSuicide(contract)) - ok := r.db.Suicide(addr) - return ok + r.db.SelfDestruct(addr) } -// HasSuicided checks whether a contract has been suicided. -func (r *RecorderProxy) HasSuicided(addr common.Address) bool { - hasSuicided := r.db.HasSuicided(addr) - return hasSuicided +// HasSelfDestructed checks whether a contract has been suicided. +func (r *RecorderProxy) HasSelfDestructed(addr common.Address) bool { + hasSelfDestructed := r.db.HasSelfDestructed(addr) + return hasSelfDestructed } // Exist checks whether the contract exists in the StateDB. @@ -234,8 +235,8 @@ func (r *RecorderProxy) Empty(addr common.Address) bool { // - Add the contents of the optional tx access list (2930) // // This method should only be called if Berlin/2929+2930 is applicable at the current number. -func (r *RecorderProxy) PrepareAccessList(render common.Address, dest *common.Address, precompiles []common.Address, txAccesses types.AccessList) { - r.db.PrepareAccessList(render, dest, precompiles, txAccesses) +func (r *RecorderProxy) Prepare(rules params.Rules, sender, coinbase common.Address, dest *common.Address, precompiles []common.Address, txAccesses types.AccessList) { + r.db.Prepare(rules, sender, coinbase, dest, precompiles, txAccesses) } // AddAddressToAccessList adds an address to the access list. @@ -280,8 +281,8 @@ func (r *RecorderProxy) AddLog(log *types.Log) { } // GetLogs retrieves log entries. -func (r *RecorderProxy) GetLogs(hash common.Hash, blockHash common.Hash) []*types.Log { - return r.db.GetLogs(hash, blockHash) +func (r *RecorderProxy) GetLogs(hash common.Hash, block uint64, blockHash common.Hash) []*types.Log { + return r.db.GetLogs(hash, block, blockHash) } // AddPreimage adds a SHA3 preimage. @@ -289,15 +290,9 @@ func (r *RecorderProxy) AddPreimage(addr common.Hash, image []byte) { r.db.AddPreimage(addr, image) } -// ForEachStorage performs a function over all storage locations in a contract. -func (r *RecorderProxy) ForEachStorage(addr common.Address, fn func(common.Hash, common.Hash) bool) error { - err := r.db.ForEachStorage(addr, fn) - return err -} - -// Prepare sets the current transaction hash and index. -func (r *RecorderProxy) Prepare(thash common.Hash, ti int) { - r.db.Prepare(thash, ti) +// SetTxContext sets the current transaction hash and index. +func (r *RecorderProxy) SetTxContext(thash common.Hash, ti int) { + r.db.SetTxContext(thash, ti) } // Finalise the state in StateDB. @@ -313,8 +308,8 @@ func (r *RecorderProxy) IntermediateRoot(deleteEmptyObjects bool) common.Hash { return r.db.IntermediateRoot(deleteEmptyObjects) } -func (r *RecorderProxy) Commit(deleteEmptyObjects bool) (common.Hash, error) { - return r.db.Commit(deleteEmptyObjects) +func (r *RecorderProxy) Commit(block uint64, deleteEmptyObjects bool) (common.Hash, error) { + return r.db.Commit(block, deleteEmptyObjects) } func (r *RecorderProxy) Error() error { @@ -392,3 +387,22 @@ func (r *RecorderProxy) GetMemoryUsage() *state.MemoryUsage { func (r *RecorderProxy) GetShadowDB() state.StateDB { return r.db.GetShadowDB() } +func (r *RecorderProxy) CreateContract(addr common.Address) { + r.db.CreateContract(addr) +} + +func (r *RecorderProxy) Selfdestruct6780(addr common.Address) { + r.db.Selfdestruct6780(addr) +} + +func (r *RecorderProxy) GetStorageRoot(addr common.Address) common.Hash { + return r.db.GetStorageRoot(addr) +} + +func (r *RecorderProxy) SetTransientState(addr common.Address, key common.Hash, value common.Hash) { + r.db.SetTransientState(addr, key, value) +} + +func (r *RecorderProxy) GetTransientState(addr common.Address, key common.Hash) common.Hash { + return r.db.GetTransientState(addr, key) +} diff --git a/state/proxy/shadow.go b/state/proxy/shadow.go index 937e362cf..64d5faec0 100644 --- a/state/proxy/shadow.go +++ b/state/proxy/shadow.go @@ -21,14 +21,16 @@ import ( "errors" "fmt" "log" - "math/big" "strings" "github.com/Fantom-foundation/Aida/logger" "github.com/Fantom-foundation/Aida/state" "github.com/Fantom-foundation/Aida/txcontext" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/tracing" "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/params" + "github.com/holiman/uint256" ) // NewShadowProxy creates a StateDB instance bundling two other instances and running each @@ -88,28 +90,31 @@ func (s *shadowVmStateDb) Empty(addr common.Address) bool { return s.getBool("Empty", func(s state.VmStateDB) bool { return s.Empty(addr) }, addr) } -func (s *shadowVmStateDb) Suicide(addr common.Address) bool { - return s.getBool("Suicide", func(s state.VmStateDB) bool { return s.Suicide(addr) }, addr) +func (s *shadowVmStateDb) SelfDestruct(addr common.Address) { + s.run("SelfDestruct", func(s state.VmStateDB) error { + s.SelfDestruct(addr) + return nil + }) } -func (s *shadowVmStateDb) HasSuicided(addr common.Address) bool { - return s.getBool("HasSuicided", func(s state.VmStateDB) bool { return s.HasSuicided(addr) }, addr) +func (s *shadowVmStateDb) HasSelfDestructed(addr common.Address) bool { + return s.getBool("HasSelfDestructed", func(s state.VmStateDB) bool { return s.HasSelfDestructed(addr) }, addr) } -func (s *shadowVmStateDb) GetBalance(addr common.Address) *big.Int { - return s.getBigInt("GetBalance", func(s state.VmStateDB) *big.Int { return s.GetBalance(addr) }, addr) +func (s *shadowVmStateDb) GetBalance(addr common.Address) *uint256.Int { + return s.getUint256("GetBalance", func(s state.VmStateDB) *uint256.Int { return s.GetBalance(addr) }, addr) } -func (s *shadowVmStateDb) AddBalance(addr common.Address, value *big.Int) { +func (s *shadowVmStateDb) AddBalance(addr common.Address, value *uint256.Int, reason tracing.BalanceChangeReason) { s.run("AddBalance", func(s state.VmStateDB) error { - s.AddBalance(addr, value) + s.AddBalance(addr, value, reason) return nil }) } -func (s *shadowVmStateDb) SubBalance(addr common.Address, value *big.Int) { +func (s *shadowVmStateDb) SubBalance(addr common.Address, value *uint256.Int, reason tracing.BalanceChangeReason) { s.run("SubBalance", func(s state.VmStateDB) error { - s.SubBalance(addr, value) + s.SubBalance(addr, value, reason) return nil }) } @@ -257,9 +262,9 @@ func (s *shadowVmStateDb) GetRefund() uint64 { return s.getUint64("GetRefund", func(s state.VmStateDB) uint64 { return s.GetRefund() }) } -func (s *shadowVmStateDb) PrepareAccessList(sender common.Address, dest *common.Address, precompiles []common.Address, txAccesses types.AccessList) { - s.run("PrepareAccessList", func(s state.VmStateDB) error { - s.PrepareAccessList(sender, dest, precompiles, txAccesses) +func (s *shadowVmStateDb) Prepare(rules params.Rules, sender, coinbase common.Address, dest *common.Address, precompiles []common.Address, txAccesses types.AccessList) { + s.run("Prepare", func(s state.VmStateDB) error { + s.Prepare(rules, sender, coinbase, dest, precompiles, txAccesses) return nil }) } @@ -293,9 +298,9 @@ func (s *shadowVmStateDb) AddLog(log *types.Log) { }) } -func (s *shadowVmStateDb) GetLogs(hash common.Hash, blockHash common.Hash) []*types.Log { - logsP := s.prime.GetLogs(hash, blockHash) - logsS := s.shadow.GetLogs(hash, blockHash) +func (s *shadowVmStateDb) GetLogs(hash common.Hash, block uint64, blockHash common.Hash) []*types.Log { + logsP := s.prime.GetLogs(hash, block, blockHash) + logsS := s.shadow.GetLogs(hash, block, blockHash) equal := len(logsP) == len(logsS) if equal { @@ -326,10 +331,10 @@ func (s *shadowStateDb) IntermediateRoot(deleteEmptyObjects bool) common.Hash { return s.prime.IntermediateRoot(deleteEmptyObjects) } -func (s *shadowStateDb) Commit(deleteEmptyObjects bool) (common.Hash, error) { +func (s *shadowStateDb) Commit(block uint64, deleteEmptyObjects bool) (common.Hash, error) { // Do not check hashes for equivalents. - s.shadow.Commit(deleteEmptyObjects) - return s.prime.Commit(deleteEmptyObjects) + s.shadow.Commit(block, deleteEmptyObjects) + return s.prime.Commit(block, deleteEmptyObjects) } // GetError returns an error then reset it. @@ -340,9 +345,9 @@ func (s *shadowVmStateDb) Error() error { return err } -func (s *shadowVmStateDb) Prepare(thash common.Hash, ti int) { - s.run("AddPreimage", func(s state.VmStateDB) error { - s.Prepare(thash, ti) +func (s *shadowStateDb) SetTxContext(thash common.Hash, ti int) { + s.run("SetTxContext", func(s state.StateDB) error { + s.SetTxContext(thash, ti) return nil }) } @@ -367,11 +372,6 @@ func (s *shadowVmStateDb) AddPreimage(hash common.Hash, plain []byte) { }) } -func (s *shadowVmStateDb) ForEachStorage(common.Address, func(common.Hash, common.Hash) bool) error { - // ignored - panic("ForEachStorage not implemented") -} - func (s *shadowStateDb) StartBulkLoad(block uint64) (state.BulkLoad, error) { pbl, err := s.prime.StartBulkLoad(block) if err != nil { @@ -477,7 +477,7 @@ func (l *shadowBulkLoad) CreateAccount(addr common.Address) { l.shadow.CreateAccount(addr) } -func (l *shadowBulkLoad) SetBalance(addr common.Address, value *big.Int) { +func (l *shadowBulkLoad) SetBalance(addr common.Address, value *uint256.Int) { l.prime.SetBalance(addr, value) l.shadow.SetBalance(addr, value) } @@ -631,7 +631,7 @@ func (s *shadowVmStateDb) getHash(opName string, op func(s state.VmStateDB) comm return resP } -func (s *shadowVmStateDb) getBigInt(opName string, op func(s state.VmStateDB) *big.Int, args ...any) *big.Int { +func (s *shadowVmStateDb) getUint256(opName string, op func(s state.VmStateDB) *uint256.Int, args ...any) *uint256.Int { resP := op(s.prime) resS := op(s.shadow) if resP.Cmp(resS) != 0 { @@ -687,3 +687,32 @@ func (s *shadowVmStateDb) logIssue(opName string, prime, shadow any, args ...any "\tShadow: %v", getOpcodeString(opName, args), prime, shadow) } + +func (s *shadowVmStateDb) CreateContract(addr common.Address) { + s.run("CreateContract", func(s state.VmStateDB) error { + s.CreateContract(addr) + return nil + }) +} + +func (s *shadowVmStateDb) Selfdestruct6780(addr common.Address) { + s.run("Selfdestruct6780", func(s state.VmStateDB) error { + s.Selfdestruct6780(addr) + return nil + }) +} + +func (s *shadowVmStateDb) GetStorageRoot(addr common.Address) common.Hash { + return s.getHash("GetStorageRoot", func(s state.VmStateDB) common.Hash { return s.GetStorageRoot(addr) }, addr) +} + +func (s *shadowVmStateDb) SetTransientState(addr common.Address, key common.Hash, value common.Hash) { + s.run("SetTransientState", func(s state.VmStateDB) error { + s.SetTransientState(addr, key, value) + return nil + }) +} + +func (s *shadowVmStateDb) GetTransientState(addr common.Address, key common.Hash) common.Hash { + return s.getHash("GetTransientState", func(s state.VmStateDB) common.Hash { return s.GetTransientState(addr, key) }, addr, key) +} diff --git a/state/proxy/shadow_test.go b/state/proxy/shadow_test.go index fc0ce0af9..1f1496367 100644 --- a/state/proxy/shadow_test.go +++ b/state/proxy/shadow_test.go @@ -19,7 +19,6 @@ package proxy import ( "bytes" "errors" - "math/big" "testing" "github.com/Fantom-foundation/Aida/state" @@ -27,6 +26,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "go.uber.org/mock/gomock" + "github.com/holiman/uint256" ) func makeTestShadowDBWithCarmenTestContext(t *testing.T, ctc state.CarmenStateTestCase) state.StateDB { @@ -146,7 +146,7 @@ func TestShadowState_AccountBalanceOperations(t *testing.T) { // get randomized balance additionBase := state.GetRandom(1, 1000*5000) - addition := big.NewInt(int64(additionBase)) + addition := uint256.NewInt(int64(additionBase)) shadowDB.AddBalance(addr, addition) @@ -154,8 +154,8 @@ func TestShadowState_AccountBalanceOperations(t *testing.T) { t.Fatal("failed to add balance to carmen state DB account") } - subtraction := big.NewInt(int64(state.GetRandom(1, additionBase))) - expectedResult := big.NewInt(0).Sub(addition, subtraction) + subtraction := uint256.NewInt(int64(state.GetRandom(1, additionBase))) + expectedResult := uint256.NewInt(0).Sub(addition, subtraction) shadowDB.SubBalance(addr, subtraction) @@ -461,7 +461,7 @@ func TestShadowState_SetBalanceUsingBulkInsertion(t *testing.T) { cbl.CreateAccount(addr) - newBalance := big.NewInt(int64(state.GetRandom(1, 1000*5000))) + newBalance := uint256.NewInt(int64(state.GetRandom(1, 1000*5000))) cbl.SetBalance(addr, newBalance) err = cbl.Close() @@ -657,7 +657,7 @@ func TestShadowState_BulkloadOperations(t *testing.T) { switch { case operationType == 1: // set balance - newBalance := big.NewInt(int64(state.GetRandom(0, 1000*5000))) + newBalance := uint256.NewInt(int64(state.GetRandom(0, 1000*5000))) cbl.SetBalance(account, newBalance) case operationType == 2: From 87e85e2233a3959b8a0f5fc5992c2a0357b5fa6c Mon Sep 17 00:00:00 2001 From: wsodsong Date: Thu, 13 Jun 2024 10:34:28 +0000 Subject: [PATCH 06/26] fix state processing --- ethtest/transaction.go | 39 +++++++++++++++++++++++++++------------ utils/prime_ctx.go | 6 +++--- utils/statedb.go | 2 +- 3 files changed, 31 insertions(+), 16 deletions(-) diff --git a/ethtest/transaction.go b/ethtest/transaction.go index 3a8a9bcd8..72eb62c5b 100644 --- a/ethtest/transaction.go +++ b/ethtest/transaction.go @@ -25,6 +25,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/common/math" + "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" ) @@ -40,15 +41,16 @@ type stTransaction struct { GasLimit []*BigInt `json:"gasLimit"` Value []string `json:"value"` PrivateKey hexutil.Bytes `json:"secretKey"` + //TODO support Blob type } -func (tx *stTransaction) toMessage(ps stPostState, baseFee *BigInt) (*types.Message, error) { +func (tx *stTransaction) toMessage(ps stPostState, baseFee *BigInt) (core.Message, error) { // Derive sender from private key if present. var from common.Address if len(tx.PrivateKey) > 0 { key, err := crypto.ToECDSA(tx.PrivateKey) if err != nil { - return nil, fmt.Errorf("invalid private key: %v", err) + return core.Message{}, fmt.Errorf("invalid private key: %v", err) } from = crypto.PubkeyToAddress(key.PublicKey) } @@ -57,19 +59,19 @@ func (tx *stTransaction) toMessage(ps stPostState, baseFee *BigInt) (*types.Mess if tx.To != "" { to = new(common.Address) if err := to.UnmarshalText([]byte(tx.To)); err != nil { - return nil, fmt.Errorf("invalid to address: %v", err) + return core.Message{}, fmt.Errorf("invalid to address: %v", err) } } // Get values specific to this post state. if ps.indexes.Data > len(tx.Data) { - return nil, fmt.Errorf("tx data index %d out of bounds", ps.indexes.Data) + return core.Message{}, fmt.Errorf("tx data index %d out of bounds", ps.indexes.Data) } if ps.indexes.Value > len(tx.Value) { - return nil, fmt.Errorf("tx value index %d out of bounds", ps.indexes.Value) + return core.Message{}, fmt.Errorf("tx value index %d out of bounds", ps.indexes.Value) } if ps.indexes.Gas > len(tx.GasLimit) { - return nil, fmt.Errorf("tx gas limit index %d out of bounds", ps.indexes.Gas) + return core.Message{}, fmt.Errorf("tx gas limit index %d out of bounds", ps.indexes.Gas) } dataHex := tx.Data[ps.indexes.Data] valueHex := tx.Value[ps.indexes.Value] @@ -79,13 +81,13 @@ func (tx *stTransaction) toMessage(ps stPostState, baseFee *BigInt) (*types.Mess if valueHex != "0x" { v, ok := math.ParseBig256(valueHex) if !ok { - return nil, fmt.Errorf("invalid tx value %q", valueHex) + return core.Message{}, fmt.Errorf("invalid tx value %q", valueHex) } value = v } data, err := hex.DecodeString(strings.TrimPrefix(dataHex, "0x")) if err != nil { - return nil, fmt.Errorf("invalid tx data %q", dataHex) + return core.Message{}, fmt.Errorf("invalid tx data %q", dataHex) } var accessList types.AccessList if tx.AccessLists != nil && tx.AccessLists[ps.indexes.Data] != nil { @@ -107,10 +109,23 @@ func (tx *stTransaction) toMessage(ps stPostState, baseFee *BigInt) (*types.Mess tx.MaxFeePerGas.Convert())} } if gasPrice == nil { - return nil, fmt.Errorf("no gas price provided") + return core.Message{}, fmt.Errorf("no gas price provided") } - msg := types.NewMessage(from, to, tx.Nonce.Uint64(), value, gasLimit.Uint64(), gasPrice.Convert(), - tx.MaxFeePerGas.Convert(), tx.MaxPriorityFeePerGas.Convert(), data, accessList, false) - return &msg, nil + msg := core.Message{ + to, + from, + tx.Nonce.Uint64(), + value, + gasLimit.Uint64(), + gasPrice.Convert(), + tx.MaxFeePerGas.Convert(), + tx.MaxPriorityFeePerGas.Convert(), + data, + accessList, + nil, //TODO support BlobGasFeeCap + []common.Hash{}, //TODO support BlobHashes + false, + } + return msg, nil } diff --git a/utils/prime_ctx.go b/utils/prime_ctx.go index 2563bd6a0..02b7e0eab 100644 --- a/utils/prime_ctx.go +++ b/utils/prime_ctx.go @@ -231,8 +231,8 @@ func (pc *PrimeContext) PrimeStateDBRandom(ws txcontext.WorldState, db state.Sta return err } -// SuicideAccounts clears storage of all input accounts. -func (pc *PrimeContext) SuicideAccounts(db state.StateDB, accounts []substatetypes.Address) { +// SelfDestructAccounts clears storage of all input accounts. +func (pc *PrimeContext) SelfDestructAccounts(db state.StateDB, accounts []substatetypes.Address) { count := 0 db.BeginSyncPeriod(0) db.BeginBlock(pc.block) @@ -240,7 +240,7 @@ func (pc *PrimeContext) SuicideAccounts(db state.StateDB, accounts []substatetyp for _, addr := range accounts { a := common.Address(addr) if db.Exist(a) { - db.Suicide(a) + db.SelfDestruct(a) pc.log.Debugf("\t\t Perform suicide on %s", a) count++ pc.exist[a] = false diff --git a/utils/statedb.go b/utils/statedb.go index 8556145d4..48b06efa9 100644 --- a/utils/statedb.go +++ b/utils/statedb.go @@ -265,7 +265,7 @@ func DeleteDestroyedAccountsFromStateDB(sdb state.StateDB, cfg *Config, target u return err } for _, addr := range accounts { - sdb.Suicide(common.Address(addr)) + sdb.SelfDestruct(common.Address(addr)) log.Debugf("Perform suicide on %v", addr) } err = sdb.EndTransaction() From a3bfa2d6fc6b39b9824d8904e1ec3de048cdb3e7 Mon Sep 17 00:00:00 2001 From: wsodsong Date: Thu, 13 Jun 2024 11:01:32 +0000 Subject: [PATCH 07/26] Revert "Update carmen version. Use new Carmen type Amount. (#1108)" This reverts commit 2982012f9c85d2a1a56d74c3486c85e38472e7cc. --- carmen | 2 +- go.mod | 2 +- state/carmen.go | 10 ++++------ 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/carmen b/carmen index 2967c9cad..dddf65b4e 160000 --- a/carmen +++ b/carmen @@ -1 +1 @@ -Subproject commit 2967c9cad7634ba0e6cf4116a03dfdcca394e960 +Subproject commit dddf65b4e1f3b09c884d10eb97d23399cf07ea74 diff --git a/go.mod b/go.mod index fd4508dc5..71f2cfaa8 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.22 toolchain go1.22.0 require ( - github.com/Fantom-foundation/Carmen/go v0.0.0-20240527074610-67008e3801f9 + github.com/Fantom-foundation/Carmen/go v0.0.0-20240517062523-dddf65b4e1f3 github.com/Fantom-foundation/Norma v0.0.0-20240422103552-42e37352b2f4 github.com/Fantom-foundation/Substate v0.0.0-20240606095437-0d28864f0a7a github.com/Fantom-foundation/Tosca v0.0.0-20230527064715-aa1fc97baebe diff --git a/state/carmen.go b/state/carmen.go index 04347deeb..e7669b9c0 100644 --- a/state/carmen.go +++ b/state/carmen.go @@ -133,17 +133,15 @@ func (s *carmenStateDB) HasSelfDestructed(addr common.Address) bool { } func (s *carmenStateDB) GetBalance(addr common.Address) *uint256.Int { - // TODO - //return &s.txCtx.GetBalance(carmen.Address(addr)).Uint256() - return uint256.MustFromBig(s.txCtx.GetBalance(carmen.Address(addr)).ToBig()) + return uint256.MustFromBig(s.txCtx.GetBalance(carmen.Address(addr))) } func (s *carmenStateDB) AddBalance(addr common.Address, value *uint256.Int, _ tracing.BalanceChangeReason) { - s.txCtx.AddBalance(carmen.Address(addr), carmen.NewAmountFromUint256(value)) + s.txCtx.AddBalance(carmen.Address(addr), value.ToBig()) } func (s *carmenStateDB) SubBalance(addr common.Address, value *uint256.Int, _ tracing.BalanceChangeReason) { - s.txCtx.SubBalance(carmen.Address(addr), carmen.NewAmountFromUint256(value)) + s.txCtx.SubBalance(carmen.Address(addr), value.ToBig()) } func (s *carmenStateDB) GetNonce(addr common.Address) uint64 { @@ -433,7 +431,7 @@ func (l *carmenBulkLoad) CreateAccount(addr common.Address) { } func (l *carmenBulkLoad) SetBalance(addr common.Address, value *uint256.Int) { - l.load.SetBalance(carmen.Address(addr), carmen.NewAmountFromUint256(value)) + l.load.SetBalance(carmen.Address(addr), value.ToBig()) } func (l *carmenBulkLoad) SetNonce(addr common.Address, nonce uint64) { From 86cb0f5372b26c02a59f41278adfaffeb00f4ef1 Mon Sep 17 00:00:00 2001 From: wsodsong Date: Thu, 13 Jun 2024 15:29:43 +0000 Subject: [PATCH 08/26] fix rpc --- rpc/evm.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/rpc/evm.go b/rpc/evm.go index c96ff6604..357a1cd8f 100644 --- a/rpc/evm.go +++ b/rpc/evm.go @@ -31,7 +31,6 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/core" - eth "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/params" "github.com/status-im/keycard-go/hexutils" @@ -112,7 +111,7 @@ func newTxArgs(params map[string]interface{}) ethapi.TransactionArgs { } // newEVM creates new instance of EVM with given parameters -func (e *EvmExecutor) newEVM(msg eth.Message, hashErr *error) *vm.EVM { +func (e *EvmExecutor) newEVM(msg core.Message, hashErr *error) *vm.EVM { var ( getHash func(uint64) common.Hash blockCtx vm.BlockContext @@ -135,14 +134,14 @@ func (e *EvmExecutor) newEVM(msg eth.Message, hashErr *error) *vm.EVM { GasLimit: math.MaxUint64, // evmcore/dummy_block.go GetHash: getHash, BaseFee: e.rules.MinGasPrice, // big.NewInt(1e9) - Time: new(big.Int).SetUint64(e.timestamp), + Time: e.timestamp, } vmConfig = opera.DefaultVMConfig vmConfig.NoBaseFee = true vmConfig.InterpreterImpl = e.vmImpl - txCtx = evmcore.NewEVMTxContext(msg) + txCtx = evmcore.NewEVMTxContext(&msg) return vm.NewEVM(blockCtx, txCtx, e.archive, e.chainCfg, vmConfig) } @@ -153,7 +152,7 @@ func (e *EvmExecutor) sendCall() (*evmcore.ExecutionResult, error) { gp *evmcore.GasPool executionResult *evmcore.ExecutionResult err error - msg eth.Message + msg *core.Message evm *vm.EVM ) @@ -164,7 +163,7 @@ func (e *EvmExecutor) sendCall() (*evmcore.ExecutionResult, error) { } var hashErr *error - evm = e.newEVM(msg, hashErr) + evm = e.newEVM(*msg, hashErr) executionResult, err = evmcore.ApplyMessage(evm, msg, gp) if executionResult.Err != nil { @@ -278,7 +277,7 @@ func (e *EvmExecutor) findHiLoCap() (uint64, uint64, uint64, error) { // Recap the highest gas limit with account's available balance. if feeCap.BitLen() != 0 { balance := e.archive.GetBalance(*e.args.From) // from can't be nil - available := new(big.Int).Set(balance) + available := new(big.Int).Set(balance.ToBig()) if e.args.Value != nil { if e.args.Value.ToInt().Cmp(available) >= 0 { return 0, 0, 0, errors.New("insufficient funds for transfer") From e8f984650ddff49bff0185ef96cfdeedec1c0743 Mon Sep 17 00:00:00 2001 From: wsodsong Date: Fri, 14 Jun 2024 09:38:26 +0000 Subject: [PATCH 09/26] fix tx processor --- ethtest/statetestcontext.go | 2 +- ethtest/transaction.go | 20 +++++++++--------- executor/norma_tx_provider.go | 7 ++++--- executor/transaction_processor.go | 8 ++++---- executor/transaction_result.go | 6 +++--- state/proxy/logger.go | 4 ++-- state/proxy/shadow.go | 4 ++-- state/proxy/shadow_test.go | 29 ++++++++++++++------------- state/state.go | 6 +++--- txcontext/nil_tx_context.go | 2 +- txcontext/substate/substate.go | 4 ++-- txcontext/tx_context.go | 2 +- txcontext/txgenerator/norma.go | 2 +- txcontext/txgenerator/tx_generator.go | 6 +++--- 14 files changed, 52 insertions(+), 50 deletions(-) diff --git a/ethtest/statetestcontext.go b/ethtest/statetestcontext.go index 0fa875d8d..d4408b5aa 100644 --- a/ethtest/statetestcontext.go +++ b/ethtest/statetestcontext.go @@ -62,7 +62,7 @@ func (s *StJSON) GetBlockEnvironment() txcontext.BlockEnvironment { return &s.Env } -func (s *StJSON) GetMessage() core.Message { +func (s *StJSON) GetMessage() *core.Message { baseFee := s.Env.BaseFee if baseFee == nil { // ethereum uses `0x10` for genesis baseFee. Therefore, it defaults to diff --git a/ethtest/transaction.go b/ethtest/transaction.go index 72eb62c5b..e4e845dea 100644 --- a/ethtest/transaction.go +++ b/ethtest/transaction.go @@ -44,13 +44,13 @@ type stTransaction struct { //TODO support Blob type } -func (tx *stTransaction) toMessage(ps stPostState, baseFee *BigInt) (core.Message, error) { +func (tx *stTransaction) toMessage(ps stPostState, baseFee *BigInt) (*core.Message, error) { // Derive sender from private key if present. var from common.Address if len(tx.PrivateKey) > 0 { key, err := crypto.ToECDSA(tx.PrivateKey) if err != nil { - return core.Message{}, fmt.Errorf("invalid private key: %v", err) + return &core.Message{}, fmt.Errorf("invalid private key: %v", err) } from = crypto.PubkeyToAddress(key.PublicKey) } @@ -59,19 +59,19 @@ func (tx *stTransaction) toMessage(ps stPostState, baseFee *BigInt) (core.Messag if tx.To != "" { to = new(common.Address) if err := to.UnmarshalText([]byte(tx.To)); err != nil { - return core.Message{}, fmt.Errorf("invalid to address: %v", err) + return &core.Message{}, fmt.Errorf("invalid to address: %v", err) } } // Get values specific to this post state. if ps.indexes.Data > len(tx.Data) { - return core.Message{}, fmt.Errorf("tx data index %d out of bounds", ps.indexes.Data) + return &core.Message{}, fmt.Errorf("tx data index %d out of bounds", ps.indexes.Data) } if ps.indexes.Value > len(tx.Value) { - return core.Message{}, fmt.Errorf("tx value index %d out of bounds", ps.indexes.Value) + return &core.Message{}, fmt.Errorf("tx value index %d out of bounds", ps.indexes.Value) } if ps.indexes.Gas > len(tx.GasLimit) { - return core.Message{}, fmt.Errorf("tx gas limit index %d out of bounds", ps.indexes.Gas) + return &core.Message{}, fmt.Errorf("tx gas limit index %d out of bounds", ps.indexes.Gas) } dataHex := tx.Data[ps.indexes.Data] valueHex := tx.Value[ps.indexes.Value] @@ -81,13 +81,13 @@ func (tx *stTransaction) toMessage(ps stPostState, baseFee *BigInt) (core.Messag if valueHex != "0x" { v, ok := math.ParseBig256(valueHex) if !ok { - return core.Message{}, fmt.Errorf("invalid tx value %q", valueHex) + return &core.Message{}, fmt.Errorf("invalid tx value %q", valueHex) } value = v } data, err := hex.DecodeString(strings.TrimPrefix(dataHex, "0x")) if err != nil { - return core.Message{}, fmt.Errorf("invalid tx data %q", dataHex) + return &core.Message{}, fmt.Errorf("invalid tx data %q", dataHex) } var accessList types.AccessList if tx.AccessLists != nil && tx.AccessLists[ps.indexes.Data] != nil { @@ -109,10 +109,10 @@ func (tx *stTransaction) toMessage(ps stPostState, baseFee *BigInt) (core.Messag tx.MaxFeePerGas.Convert())} } if gasPrice == nil { - return core.Message{}, fmt.Errorf("no gas price provided") + return &core.Message{}, fmt.Errorf("no gas price provided") } - msg := core.Message{ + msg := &core.Message{ to, from, tx.Nonce.Uint64(), diff --git a/executor/norma_tx_provider.go b/executor/norma_tx_provider.go index 33f5f3b36..2d0f3a8ab 100644 --- a/executor/norma_tx_provider.go +++ b/executor/norma_tx_provider.go @@ -32,6 +32,7 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/params" + "github.com/holiman/uint256" ) // treasureAccountPrivateKey is the private key of the treasure account. @@ -167,7 +168,7 @@ func (p normaTxProvider) initializeTreasureAccount(blkNumber int) (*app.Account, fromAddress := crypto.PubkeyToAddress(*publicKeyECDSA) // fund the treasure account directly in the state database - amount := big.NewInt(0).Mul(big.NewInt(params.Ether), big.NewInt(2_000_000_000)) + amount := uint256.NewInt(0).Mul(uint256.NewInt(params.Ether), uint256.NewInt(2_000_000_000)) // we need to begin and end the block and transaction to be able to create an account // and add balance to it (otherwise the account would not be funded for geth storage implementation) err = p.stateDb.BeginBlock(uint64(blkNumber)) @@ -179,7 +180,7 @@ func (p normaTxProvider) initializeTreasureAccount(blkNumber int) (*app.Account, return nil, fmt.Errorf("cannot begin transaction; %w", err) } p.stateDb.CreateAccount(fromAddress) - p.stateDb.AddBalance(fromAddress, amount) + p.stateDb.AddBalance(fromAddress, amount, 0) err = p.stateDb.EndTransaction() if err != nil { return nil, fmt.Errorf("cannot end transaction; %w", err) @@ -258,7 +259,7 @@ func (f fakeRpcClient) BalanceAt(_ context.Context, account common.Address, _ *b if err != nil { return nil, err } - return balance, nil + return balance.ToBig(), nil } func (f fakeRpcClient) Close() { diff --git a/executor/transaction_processor.go b/executor/transaction_processor.go index 58fa38553..4a8591796 100644 --- a/executor/transaction_processor.go +++ b/executor/transaction_processor.go @@ -109,7 +109,7 @@ func MakeTxProcessor(cfg *utils.Config) *TxProcessor { vmCfg.InterpreterImpl = cfg.VmImpl vmCfg.Tracer = nil - vmCfg.Debug = false + //vmCfg.Debug = false return &TxProcessor{ cfg: cfg, @@ -192,8 +192,8 @@ func (s *TxProcessor) processRegularTx(db state.VmStateDB, block int, tx int, st // The pseudo transactions includes Lachesis SFC, lachesis genesis and lachesis-opera transition. func (s *TxProcessor) processPseudoTx(ws txcontext.WorldState, db state.VmStateDB) txcontext.Result { ws.ForEachAccount(func(addr common.Address, acc txcontext.Account) { - db.SubBalance(addr, db.GetBalance(addr)) - db.AddBalance(addr, acc.GetBalance()) + db.SubBalance(addr, db.GetBalance(addr), 0) + db.AddBalance(addr, acc.GetBalance(), 0) db.SetNonce(addr, acc.GetNonce()) db.SetCode(addr, acc.GetCode()) acc.ForEachStorage(func(keyHash common.Hash, valueHash common.Hash) { @@ -216,7 +216,7 @@ func prepareBlockCtx(inputEnv txcontext.BlockEnvironment, hashError *error) *vm. Transfer: core.Transfer, Coinbase: inputEnv.GetCoinbase(), BlockNumber: new(big.Int).SetUint64(inputEnv.GetNumber()), - Time: new(big.Int).SetUint64(inputEnv.GetTimestamp()), + Time: inputEnv.GetTimestamp(), Difficulty: inputEnv.GetDifficulty(), GasLimit: inputEnv.GetGasLimit(), GetHash: getHash, diff --git a/executor/transaction_result.go b/executor/transaction_result.go index 2d75df712..a0cce2390 100644 --- a/executor/transaction_result.go +++ b/executor/transaction_result.go @@ -74,15 +74,15 @@ func (r transactionResult) String() string { return fmt.Sprintf("Status: %v\nBloom: %s\nContract Address: %s\nGas Used: %v\nLogs: %v\n", r.status, string(r.bloom.Bytes()), r.contractAddress, r.gasUsed, r.logs) } -func newTransactionResult(logs []*types.Log, msg core.Message, msgResult *evmcore.ExecutionResult, err error, origin common.Address) transactionResult { +func newTransactionResult(logs []*types.Log, msg *core.Message, msgResult *evmcore.ExecutionResult, err error, origin common.Address) transactionResult { var ( contract common.Address gasUsed uint64 status uint64 ) - if to := msg.To(); to == nil { - contract = crypto.CreateAddress(origin, msg.Nonce()) + if msg.To == nil { + contract = crypto.CreateAddress(origin, msg.Nonce) } var returnData []byte diff --git a/state/proxy/logger.go b/state/proxy/logger.go index 2592cd11a..3d0e6450a 100644 --- a/state/proxy/logger.go +++ b/state/proxy/logger.go @@ -302,8 +302,8 @@ func (s *LoggingStateDb) Commit(block uint64, deleteEmptyObjects bool) (common.H return hash, err } -func (s *LoggingStateDb) SetTxContext(thash common.Hash, ti int) { - s.state.SetTxContext(thash, ti) +func (s *loggingVmStateDb) SetTxContext(thash common.Hash, ti int) { + s.db.SetTxContext(thash, ti) s.writeLog("SetTxContext, %v, %v", thash, ti) } diff --git a/state/proxy/shadow.go b/state/proxy/shadow.go index 64d5faec0..325b92aab 100644 --- a/state/proxy/shadow.go +++ b/state/proxy/shadow.go @@ -345,8 +345,8 @@ func (s *shadowVmStateDb) Error() error { return err } -func (s *shadowStateDb) SetTxContext(thash common.Hash, ti int) { - s.run("SetTxContext", func(s state.StateDB) error { +func (s *shadowVmStateDb) SetTxContext(thash common.Hash, ti int) { + s.run("SetTxContext", func(s state.VmStateDB) error { s.SetTxContext(thash, ti) return nil }) diff --git a/state/proxy/shadow_test.go b/state/proxy/shadow_test.go index 1f1496367..25a8c6b39 100644 --- a/state/proxy/shadow_test.go +++ b/state/proxy/shadow_test.go @@ -24,6 +24,7 @@ import ( "github.com/Fantom-foundation/Aida/state" carmen "github.com/Fantom-foundation/Carmen/go/state" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/core/types" "go.uber.org/mock/gomock" "github.com/holiman/uint256" @@ -115,11 +116,8 @@ func TestShadowState_AccountLifecycle(t *testing.T) { t.Fatal("failed to create carmen state DB account; should be empty") } - if !shadowDB.Suicide(addr) { - t.Fatal("failed to suicide carmen state DB account;") - } - - if !shadowDB.HasSuicided(addr) { + shadowDB.SelfDestruct(addr) + if !shadowDB.HasSelfDestructed(addr) { t.Fatal("failed to suicide carmen state DB account;") } }) @@ -146,18 +144,18 @@ func TestShadowState_AccountBalanceOperations(t *testing.T) { // get randomized balance additionBase := state.GetRandom(1, 1000*5000) - addition := uint256.NewInt(int64(additionBase)) + addition := uint256.NewInt(uint64(additionBase)) - shadowDB.AddBalance(addr, addition) + shadowDB.AddBalance(addr, addition, 0) if shadowDB.GetBalance(addr).Cmp(addition) != 0 { t.Fatal("failed to add balance to carmen state DB account") } - subtraction := uint256.NewInt(int64(state.GetRandom(1, additionBase))) + subtraction := uint256.NewInt(uint64(state.GetRandom(1, additionBase))) expectedResult := uint256.NewInt(0).Sub(addition, subtraction) - shadowDB.SubBalance(addr, subtraction) + shadowDB.SubBalance(addr, subtraction, 0) if shadowDB.GetBalance(addr).Cmp(expectedResult) != 0 { t.Fatal("failed to subtract balance to carmen state DB account") @@ -362,7 +360,9 @@ func TestShadowState_AccessListOperations(t *testing.T) { }(shadowDB) // prepare content of access list + rules := params.Rules{} sender := common.BytesToAddress(state.MakeRandomByteSlice(t, 40)) + coinbase := common.BytesToAddress(state.MakeRandomByteSlice(t, 40)) dest := common.BytesToAddress(state.MakeRandomByteSlice(t, 40)) precompiles := []common.Address{ common.BytesToAddress(state.MakeRandomByteSlice(t, 40)), @@ -389,7 +389,7 @@ func TestShadowState_AccessListOperations(t *testing.T) { } // create access list - shadowDB.PrepareAccessList(sender, &dest, precompiles, txAccesses) + shadowDB.Prepare(rules, sender, coinbase, &dest, precompiles, txAccesses) // add some more data after the creation for good measure newAddr := common.BytesToAddress(state.MakeRandomByteSlice(t, 40)) @@ -461,7 +461,7 @@ func TestShadowState_SetBalanceUsingBulkInsertion(t *testing.T) { cbl.CreateAccount(addr) - newBalance := uint256.NewInt(int64(state.GetRandom(1, 1000*5000))) + newBalance := uint256.NewInt(uint64(state.GetRandom(1, 1000*5000))) cbl.SetBalance(addr, newBalance) err = cbl.Close() @@ -657,7 +657,7 @@ func TestShadowState_BulkloadOperations(t *testing.T) { switch { case operationType == 1: // set balance - newBalance := uint256.NewInt(int64(state.GetRandom(0, 1000*5000))) + newBalance := uint256.NewInt(uint64(state.GetRandom(0, 1000*5000))) cbl.SetBalance(account, newBalance) case operationType == 2: @@ -743,9 +743,10 @@ func TestShadowState_GetLogs_Success(t *testing.T) { txHash := common.HexToHash("0x1") blockHash := common.HexToHash("0x2") log1 := &types.Log{} + block := uint64(0) - pdb.EXPECT().GetLogs(txHash, blockHash).Return([]*types.Log{log1}) - sdb.EXPECT().GetLogs(txHash, blockHash).Return([]*types.Log{log1}) + pdb.EXPECT().GetLogs(txHash, block, blockHash).Return([]*types.Log{log1}) + sdb.EXPECT().GetLogs(txHash, block, blockHash).Return([]*types.Log{log1}) db.GetLogs(txHash, blockHash) if err := db.Error(); err != nil { diff --git a/state/state.go b/state/state.go index 7a9de1662..18baa9cf2 100644 --- a/state/state.go +++ b/state/state.go @@ -82,6 +82,9 @@ type VmStateDB interface { AddLog(*types.Log) GetLogs(common.Hash, uint64, common.Hash) []*types.Log + // SetTxContext is geth utility function which set transaction index and transaction hash. + SetTxContext(common.Hash, int) + // Transaction handling // There are 4 layers of concepts governing the visibility of state effects: // - snapshots .. enclosing (sub-)contract calls, supporting reverts (=rollbacks) @@ -194,9 +197,6 @@ type StateDB interface { // the shadow DB can be used to query state directly. If there is no shadow DB, // nil is returned. GetShadowDB() StateDB - - // SetTxContext is geth utility function which set transaction index and transaction hash. - SetTxContext(common.Hash, int) } // BulkWrite is a faster interface to StateDB instances for writing data without diff --git a/txcontext/nil_tx_context.go b/txcontext/nil_tx_context.go index 07a5c7545..bc4d16fd8 100644 --- a/txcontext/nil_tx_context.go +++ b/txcontext/nil_tx_context.go @@ -31,7 +31,7 @@ func (NilTxContext) GetInputState() WorldState { return nil } func (NilTxContext) GetBlockEnvironment() BlockEnvironment { return nil } -func (NilTxContext) GetMessage() core.Message { return core.Message{} } +func (NilTxContext) GetMessage() *core.Message { return &core.Message{} } func (NilTxContext) GetOutputState() WorldState { return nil } diff --git a/txcontext/substate/substate.go b/txcontext/substate/substate.go index 31fa215f7..fbd0b0261 100644 --- a/txcontext/substate/substate.go +++ b/txcontext/substate/substate.go @@ -48,7 +48,7 @@ func (t *substateData) GetBlockEnvironment() txcontext.BlockEnvironment { return NewBlockEnvironment(t.Env) } -func (t *substateData) GetMessage() core.Message { +func (t *substateData) GetMessage() *core.Message { // todo remove iteration once fantom types are created var list types.AccessList for _, tuple := range t.Message.AccessList { @@ -58,7 +58,7 @@ func (t *substateData) GetMessage() core.Message { } list = append(list, types.AccessTuple{Address: common.Address(tuple.Address), StorageKeys: keys}) } - return core.Message{ + return &core.Message{ (*common.Address)(t.Message.To), common.Address(t.Message.From), t.Message.Nonce, diff --git a/txcontext/tx_context.go b/txcontext/tx_context.go index b8eb88b94..4b672a067 100644 --- a/txcontext/tx_context.go +++ b/txcontext/tx_context.go @@ -45,7 +45,7 @@ type Transaction interface { // GetMessage returns the message of the transaction. // Message holds data needed by the EVM to execute the transaction. - GetMessage() core.Message + GetMessage() *core.Message // GetOutputState returns the state of the WorldState AFTER executing the transaction. // This is mainly used for confirming that StateDb has correct data AFTER execution diff --git a/txcontext/txgenerator/norma.go b/txcontext/txgenerator/norma.go index 3fa060ffd..4225ad528 100644 --- a/txcontext/txgenerator/norma.go +++ b/txcontext/txgenerator/norma.go @@ -44,7 +44,7 @@ func NewNormaTxContext(tx *types.Transaction, blkNumber uint64, sender *common.A Env: normaTxBlockEnv{ blkNumber: blkNumber, }, - Message: core.Message{ + Message: &core.Message{ To: tx.To(), From: s, Nonce: tx.Nonce(), diff --git a/txcontext/txgenerator/tx_generator.go b/txcontext/txgenerator/tx_generator.go index d8fc357f6..d50aa26c0 100644 --- a/txcontext/txgenerator/tx_generator.go +++ b/txcontext/txgenerator/tx_generator.go @@ -22,14 +22,14 @@ import ( "github.com/ethereum/go-ethereum/core" ) -func NewTxContext(env txcontext.BlockEnvironment, msg core.Message) txcontext.TxContext { +func NewTxContext(env txcontext.BlockEnvironment, msg *core.Message) txcontext.TxContext { return &txData{Env: env, Message: msg} } type txData struct { txcontext.NilTxContext Env txcontext.BlockEnvironment - Message core.Message + Message *core.Message } func (t *txData) GetStateHash() common.Hash { @@ -41,6 +41,6 @@ func (t *txData) GetBlockEnvironment() txcontext.BlockEnvironment { return t.Env } -func (t *txData) GetMessage() core.Message { +func (t *txData) GetMessage() *core.Message { return t.Message } From 99280c15310279dd31115f27b26b0a581a4ed8da Mon Sep 17 00:00:00 2001 From: wsodsong Date: Fri, 14 Jun 2024 10:44:08 +0000 Subject: [PATCH 10/26] fix commands, use subset checks --- cmd/aida-sdb/record.go | 3 +-- executor/extension/primer/primer.go | 4 ++-- .../extension/statedb/temporary_state_prepper.go | 3 +-- executor/extension/validator/utils.go | 12 ++++++------ profile/blockprofile/context.go | 8 ++++---- state/proxy/profiler.go | 4 ++-- utils/default_config.go | 3 ++- 7 files changed, 18 insertions(+), 19 deletions(-) diff --git a/cmd/aida-sdb/record.go b/cmd/aida-sdb/record.go index 1c1769b89..6545072d8 100644 --- a/cmd/aida-sdb/record.go +++ b/cmd/aida-sdb/record.go @@ -28,7 +28,6 @@ import ( "github.com/Fantom-foundation/Aida/txcontext" "github.com/Fantom-foundation/Aida/utils" "github.com/Fantom-foundation/Substate/db" - "github.com/ethereum/go-ethereum/core/state" "github.com/urfave/cli/v2" ) @@ -66,7 +65,7 @@ func RecordStateDbTrace(ctx *cli.Context) error { // force enable transaction validation cfg.ValidateTxState = true - state.EnableRecordReplay() + //state.EnableRecordReplay() aidaDb, err := db.NewReadOnlyBaseDB(cfg.AidaDb) if err != nil { return fmt.Errorf("cannot open aida-db; %w", err) diff --git a/executor/extension/primer/primer.go b/executor/extension/primer/primer.go index 7d677e349..41e617815 100644 --- a/executor/extension/primer/primer.go +++ b/executor/extension/primer/primer.go @@ -133,7 +133,7 @@ func (p *stateDbPrimer[T]) prime(stateDb state.StateDB, aidaDb db.BaseDB) error utils.ClearAccountStorage(update, newSet.DeletedAccounts) // if exists in DB, suicide if hasPrimed { - p.ctx.SuicideAccounts(stateDb, newSet.DeletedAccounts) + p.ctx.SelfDestructAccounts(stateDb, newSet.DeletedAccounts) } update.Merge(newSet.WorldState) @@ -164,7 +164,7 @@ func (p *stateDbPrimer[T]) prime(stateDb state.StateDB, aidaDb db.BaseDB) error return fmt.Errorf("cannot generate update-set; %w", err) } if hasPrimed { - p.ctx.SuicideAccounts(stateDb, deletedAccounts) + p.ctx.SelfDestructAccounts(stateDb, deletedAccounts) } if err = p.ctx.PrimeStateDB(substatecontext.NewWorldState(update), stateDb); err != nil { return fmt.Errorf("cannot prime state-db; %w", err) diff --git a/executor/extension/statedb/temporary_state_prepper.go b/executor/extension/statedb/temporary_state_prepper.go index c940c9ab0..539da6f69 100644 --- a/executor/extension/statedb/temporary_state_prepper.go +++ b/executor/extension/statedb/temporary_state_prepper.go @@ -22,7 +22,6 @@ import ( statedb "github.com/Fantom-foundation/Aida/state" "github.com/Fantom-foundation/Aida/txcontext" "github.com/Fantom-foundation/Aida/utils" - "github.com/ethereum/go-ethereum/core/state" ) // MakeTemporaryStatePrepper creates an executor.Extension which Makes a fresh StateDb @@ -36,7 +35,7 @@ func MakeTemporaryStatePrepper(cfg *utils.Config) executor.Extension[txcontext.T fallthrough default: // offTheChainStateDb is default value - state.EnableRecordReplay() + //state.EnableRecordReplay() return &temporaryOffTheChainStatePrepper{ chainConduit: statedb.NewChainConduit(cfg.ChainID == utils.EthereumChainID, utils.GetChainConfig(utils.EthereumChainID)), } diff --git a/executor/extension/validator/utils.go b/executor/extension/validator/utils.go index 3cd95ec5a..cc70e8cda 100644 --- a/executor/extension/validator/utils.go +++ b/executor/extension/validator/utils.go @@ -19,7 +19,6 @@ package validator import ( "bytes" "fmt" - "math/big" "github.com/Fantom-foundation/Aida/logger" "github.com/Fantom-foundation/Aida/state" @@ -27,6 +26,7 @@ import ( "github.com/Fantom-foundation/Aida/utils" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/holiman/uint256" ) // validateWorldState compares states of accounts in stateDB to an expected set of states. @@ -68,8 +68,8 @@ func printIfDifferentBytes(label string, want, have []byte, log logger.Logger) b return false } -// printIfDifferentBigInt compares two values of big int type and reports differences if any. -func printIfDifferentBigInt(label string, want, have *big.Int, log logger.Logger) bool { +// printIfDifferentUint256 compares two values of big int type and reports differences if any. +func printIfDifferentUint256(label string, want, have *uint256.Int, log logger.Logger) bool { if want == nil && have == nil { return false } @@ -117,7 +117,7 @@ func printAllocationDiffSummary(want, have txcontext.WorldState, log logger.Logg // PrintAccountDiffSummary compares attributes of two accounts and reports differences if any. func printAccountDiffSummary(label string, want, have txcontext.Account, log logger.Logger) { printIfDifferent(fmt.Sprintf("%s.Nonce", label), want.GetNonce(), have.GetNonce(), log) - printIfDifferentBigInt(fmt.Sprintf("%s.Balance", label), want.GetBalance(), have.GetBalance(), log) + printIfDifferentUint256(fmt.Sprintf("%s.Balance", label), want.GetBalance(), have.GetBalance(), log) printIfDifferentBytes(fmt.Sprintf("%s.Code", label), want.GetCode(), have.GetCode(), log) printIfDifferent(fmt.Sprintf("len(%s.Storage)", label), want.GetStorageSize(), have.GetStorageSize(), log) @@ -163,8 +163,8 @@ func doSubsetValidation(alloc txcontext.WorldState, db state.VmStateDB, updateOn " want %v\n", addr.Hex(), balance, accBalance) if updateOnFail { - db.SubBalance(addr, balance) - db.AddBalance(addr, accBalance) + db.SubBalance(addr, balance, 0) + db.AddBalance(addr, accBalance, 0) } } if nonce := db.GetNonce(addr); nonce != acc.GetNonce() { diff --git a/profile/blockprofile/context.go b/profile/blockprofile/context.go index 2c3ddbb54..619d91d69 100644 --- a/profile/blockprofile/context.go +++ b/profile/blockprofile/context.go @@ -119,11 +119,11 @@ func findTxAddresses(tx executor.State[txcontext.TxContext]) AddressSet { addresses[addr] = struct{}{} }) var zero common.Address - from := tx.Data.GetMessage().From() + from := tx.Data.GetMessage().From if from != zero { addresses[from] = struct{}{} } - to := tx.Data.GetMessage().To() + to := tx.Data.GetMessage().To if to != nil { addresses[*to] = struct{}{} } @@ -278,8 +278,8 @@ func (ctx *Context) GetProfileData(curBlock uint64, tBlock time.Duration) (*Prof // getTransactionType reads a message and determines a transaction type. func getTransactionType(tx executor.State[txcontext.TxContext]) TxType { msg := tx.Data.GetMessage() - to := msg.To() - from := msg.From() + to := msg.To + from := msg.From alloc := tx.Data.GetInputState() zero := common.HexToAddress("0x0000000000000000000000000000000000000000") diff --git a/state/proxy/profiler.go b/state/proxy/profiler.go index 050a21aa9..5288279a3 100644 --- a/state/proxy/profiler.go +++ b/state/proxy/profiler.go @@ -215,7 +215,7 @@ func (p *ProfilerProxy) Empty(addr common.Address) bool { return empty } -// PrepareAccessList handles the preparatory steps for executing a state transition with +// Prepare handles the preparatory steps for executing a state transition with // regards to both EIP-2929 and EIP-2930: // // - Add sender to access list (2929) @@ -224,7 +224,7 @@ func (p *ProfilerProxy) Empty(addr common.Address) bool { // - Add the contents of the optional tx access list (2930) // // This method should only be called if Berlin/2929+2930 is applicable at the current number. -func (p *ProfilerProxy) PrepareAccessList(rules params.Rules, sender, coinbase common.Address, dest *common.Address, precompiles []common.Address, txAccesses types.AccessList) { +func (p *ProfilerProxy) Prepare(rules params.Rules, sender, coinbase common.Address, dest *common.Address, precompiles []common.Address, txAccesses types.AccessList) { p.do(operation.PrepareAccessListID, func() { p.db.Prepare(rules, sender, coinbase, dest, precompiles, txAccesses) }) diff --git a/utils/default_config.go b/utils/default_config.go index 304e679d3..0b35261cc 100644 --- a/utils/default_config.go +++ b/utils/default_config.go @@ -97,7 +97,8 @@ func createConfigFromFlags(ctx *cli.Context) *Config { SnapshotDepth: getFlagValue(ctx, SnapshotDepthFlag).(int), StateDbSrc: getFlagValue(ctx, StateDbSrcFlag).(string), StateDbSrcDirectAccess: getFlagValue(ctx, SrcDbOverwriteFlag).(bool), - StateValidationMode: EqualityCheck, + // TODO re-enable equality check once supported in Carmen + StateValidationMode: SubsetCheck, SubstateDb: getFlagValue(ctx, AidaDbFlag).(string), SyncPeriodLength: getFlagValue(ctx, SyncPeriodLengthFlag).(uint64), TargetDb: getFlagValue(ctx, TargetDbFlag).(string), From 4b7d8fe005433b5659cd17a08ebb965e32748a7c Mon Sep 17 00:00:00 2001 From: wsodsong Date: Fri, 14 Jun 2024 14:24:54 +0000 Subject: [PATCH 11/26] fix stochastic --- cmd/aida-stochastic-sdb/stochastic/record.go | 3 +- stochastic/event_proxy.go | 74 ++++++++++++-------- stochastic/replay.go | 20 +++--- 3 files changed, 56 insertions(+), 41 deletions(-) diff --git a/cmd/aida-stochastic-sdb/stochastic/record.go b/cmd/aida-stochastic-sdb/stochastic/record.go index ca5d83243..11887499a 100644 --- a/cmd/aida-stochastic-sdb/stochastic/record.go +++ b/cmd/aida-stochastic-sdb/stochastic/record.go @@ -29,7 +29,6 @@ import ( substatecontext "github.com/Fantom-foundation/Aida/txcontext/substate" "github.com/Fantom-foundation/Aida/utils" "github.com/Fantom-foundation/Substate/db" - gethstate "github.com/ethereum/go-ethereum/core/state" "github.com/urfave/cli/v2" ) @@ -58,7 +57,7 @@ last block for recording events.`, // stochasticRecordAction implements recording of events. func stochasticRecordAction(ctx *cli.Context) error { - gethstate.EnableRecordReplay() + //gethstate.EnableRecordReplay() var err error cfg, err := utils.NewConfig(ctx, utils.BlockRangeArgs) diff --git a/stochastic/event_proxy.go b/stochastic/event_proxy.go index a9cca6862..7f2216033 100644 --- a/stochastic/event_proxy.go +++ b/stochastic/event_proxy.go @@ -19,12 +19,13 @@ package stochastic // TODO: Provide Mocking tests for proxy import ( - "math/big" - "github.com/Fantom-foundation/Aida/state" "github.com/Fantom-foundation/Aida/txcontext" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/tracing" "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/params" + "github.com/holiman/uint256" ) // EventProxy data structure for capturing StateDB events @@ -53,25 +54,25 @@ func (p *EventProxy) CreateAccount(address common.Address) { } // SubBalance subtracts amount from a contract address. -func (p *EventProxy) SubBalance(address common.Address, amount *big.Int) { +func (p *EventProxy) SubBalance(address common.Address, amount *uint256.Int, reason tracing.BalanceChangeReason) { // register event p.registry.RegisterAddressOp(SubBalanceID, &address) // call real StateDB - p.db.SubBalance(address, amount) + p.db.SubBalance(address, amount, reason) } // AddBalance adds amount to a contract address. -func (p *EventProxy) AddBalance(address common.Address, amount *big.Int) { +func (p *EventProxy) AddBalance(address common.Address, amount *uint256.Int, reason tracing.BalanceChangeReason) { // register event p.registry.RegisterAddressOp(AddBalanceID, &address) // call real StateDB - p.db.AddBalance(address, amount) + p.db.AddBalance(address, amount, reason) } // GetBalance retrieves the amount of a contract address. -func (p *EventProxy) GetBalance(address common.Address) *big.Int { +func (p *EventProxy) GetBalance(address common.Address) *uint256.Int { // register event p.registry.RegisterAddressOp(GetBalanceID, &address) @@ -178,22 +179,22 @@ func (p *EventProxy) SetState(address common.Address, key common.Hash, value com p.db.SetState(address, key, value) } -// Suicide an account. -func (p *EventProxy) Suicide(address common.Address) bool { +// SelfDestruct an account. +func (p *EventProxy) SelfDestruct(address common.Address) { // register event p.registry.RegisterAddressOp(SuicideID, &address) // call real StateDB - return p.db.Suicide(address) + p.db.SelfDestruct(address) } -// HasSuicided checks whether a contract has been suicided. -func (p *EventProxy) HasSuicided(address common.Address) bool { +// HasSelfDestructed checks whether a contract has been suicided. +func (p *EventProxy) HasSelfDestructed(address common.Address) bool { // register event p.registry.RegisterAddressOp(HasSuicidedID, &address) // call real StateDB - return p.db.HasSuicided(address) + return p.db.HasSelfDestructed(address) } // Exist checks whether the contract exists in the StateDB. @@ -215,10 +216,10 @@ func (p *EventProxy) Empty(address common.Address) bool { return p.db.Empty(address) } -// PrepareAccessList handles the preparatory steps for executing a state transition. -func (p *EventProxy) PrepareAccessList(render common.Address, dest *common.Address, precompiles []common.Address, txAccesses types.AccessList) { +// Prepare handles the preparatory steps for executing a state transition. +func (p *EventProxy) Prepare(rules params.Rules, sender, coinbase common.Address, dest *common.Address, precompiles []common.Address, txAccesses types.AccessList) { // call real StateDB - p.db.PrepareAccessList(render, dest, precompiles, txAccesses) + p.db.Prepare(rules, sender, coinbase, dest, precompiles, txAccesses) } // AddAddressToAccessList adds an address to the access list. @@ -287,9 +288,9 @@ func (p *EventProxy) AddLog(log *types.Log) { } // GetLogs retrieves log entries. -func (p *EventProxy) GetLogs(hash common.Hash, blockHash common.Hash) []*types.Log { +func (p *EventProxy) GetLogs(hash common.Hash, block uint64, blockHash common.Hash) []*types.Log { // call real StateDB - return p.db.GetLogs(hash, blockHash) + return p.db.GetLogs(hash, block, blockHash) } // AddPreimage adds a SHA3 preimage. @@ -298,16 +299,10 @@ func (p *EventProxy) AddPreimage(address common.Hash, image []byte) { p.db.AddPreimage(address, image) } -// ForEachStorage performs a function over all storage locations in a contract. -func (p *EventProxy) ForEachStorage(address common.Address, fn func(common.Hash, common.Hash) bool) error { - // call real StateDB - return p.db.ForEachStorage(address, fn) -} - -// Prepare sets the current transaction hash and index. -func (p *EventProxy) Prepare(thash common.Hash, ti int) { +// SetTxContext sets the current transaction hash and index. +func (p *EventProxy) SetTxContext(thash common.Hash, ti int) { // call real StateDB - p.db.Prepare(thash, ti) + p.db.SetTxContext(thash, ti) } // Finalise the state in StateDB. @@ -323,9 +318,9 @@ func (p *EventProxy) IntermediateRoot(deleteEmptyObjects bool) common.Hash { } // Commit StateDB -func (p *EventProxy) Commit(deleteEmptyObjects bool) (common.Hash, error) { +func (p *EventProxy) Commit(block uint64, deleteEmptyObjects bool) (common.Hash, error) { // call real StateDB - return p.db.Commit(deleteEmptyObjects) + return p.db.Commit(block, deleteEmptyObjects) } func (p *EventProxy) GetHash() (common.Hash, error) { @@ -429,3 +424,24 @@ func (p *EventProxy) GetArchiveBlockHeight() (uint64, bool, error) { func (p *EventProxy) GetShadowDB() state.StateDB { return p.db.GetShadowDB() } + +//TODO support new operations +func (p *EventProxy) CreateContract(addr common.Address) { + p.db.CreateContract(addr) +} + +func (p *EventProxy) Selfdestruct6780(addr common.Address) { + p.db.Selfdestruct6780(addr) +} + +func (p *EventProxy) GetStorageRoot(addr common.Address) common.Hash { + return p.db.GetStorageRoot(addr) +} + +func (p *EventProxy) SetTransientState(addr common.Address, key common.Hash, value common.Hash) { + p.db.SetTransientState(addr, key, value) +} + +func (p *EventProxy) GetTransientState(addr common.Address, key common.Hash) common.Hash { + return p.db.GetTransientState(addr, key) +} diff --git a/stochastic/replay.go b/stochastic/replay.go index fde83798a..725a49e82 100644 --- a/stochastic/replay.go +++ b/stochastic/replay.go @@ -19,7 +19,6 @@ package stochastic import ( "encoding/binary" "fmt" - "math/big" "math/rand" "time" @@ -30,6 +29,7 @@ import ( "github.com/Fantom-foundation/Aida/stochastic/statistics" "github.com/Fantom-foundation/Aida/utils" "github.com/ethereum/go-ethereum/common" + "github.com/holiman/uint256" ) // Parameterisable simulation constants @@ -269,7 +269,7 @@ func (ss *stochasticState) prime() { for i := int64(0); i <= numInitialAccounts; i++ { addr := toAddress(i) db.CreateAccount(addr) - db.AddBalance(addr, big.NewInt(ss.rg.Int63n(BalanceRange))) + db.AddBalance(addr, uint256.NewInt(uint64(ss.rg.Int63n(BalanceRange))), 0) pt.PrintProgress() } ss.log.Notice("Finalizing...") @@ -333,7 +333,7 @@ func (ss *stochasticState) execute(op int, addrCl int, keyCl int, valueCl int) { if ss.traceDebug { ss.log.Infof("value: %v", value) } - db.AddBalance(addr, big.NewInt(value)) + db.AddBalance(addr, uint256.NewInt(uint64(value)), 0) case BeginBlockID: if ss.traceDebug { @@ -402,7 +402,7 @@ func (ss *stochasticState) execute(op int, addrCl int, keyCl int, valueCl int) { db.GetState(addr, key) case HasSuicidedID: - db.HasSuicided(addr) + db.HasSelfDestructed(addr) case RevertToSnapshotID: snapshotNum := len(ss.snapshot) @@ -448,24 +448,24 @@ func (ss *stochasticState) execute(op int, addrCl int, keyCl int, valueCl int) { case SubBalanceID: shadowDB := db.GetShadowDB() - var balance int64 + var balance uint64 if shadowDB == nil { - balance = db.GetBalance(addr).Int64() + balance = db.GetBalance(addr).Uint64() } else { - balance = shadowDB.GetBalance(addr).Int64() + balance = shadowDB.GetBalance(addr).Uint64() } if balance > 0 { // get a delta that does not exceed current balance // in the current snapshot - value := rg.Int63n(balance) + value := uint64(rg.Int63n(int64(balance))) if ss.traceDebug { ss.log.Infof(" value: %v", value) } - db.SubBalance(addr, big.NewInt(value)) + db.SubBalance(addr, uint256.NewInt(value), 0) } case SuicideID: - db.Suicide(addr) + db.SelfDestruct(addr) if idx := find(ss.suicided, addrIdx); idx == -1 { ss.suicided = append(ss.suicided, addrIdx) } From 7f442792dd5f54d271a19b16da24dbdd5928a7f7 Mon Sep 17 00:00:00 2001 From: wsodsong Date: Sat, 15 Jun 2024 06:04:44 +0000 Subject: [PATCH 12/26] fix mocks --- executor/executor_mocks.go | 26 +- executor/provider_mocks.go | 17 +- executor/test_consumer_mocks.go | 17 +- logger/logger_mocks.go | 17 +- rpc/reader_mocks.go | 17 +- state/cache_mocks.go | 1 + state/state_mocks.go | 547 ++++++++++++++++++++------------ utils/state_hash_mocks.go | 17 +- 8 files changed, 351 insertions(+), 308 deletions(-) diff --git a/executor/executor_mocks.go b/executor/executor_mocks.go index a65c687c0..b453d9826 100644 --- a/executor/executor_mocks.go +++ b/executor/executor_mocks.go @@ -1,19 +1,3 @@ -// Copyright 2024 Fantom Foundation -// This file is part of Aida Testing Infrastructure for Sonic -// -// Aida is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Aida is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with Aida. If not, see . - // Code generated by MockGen. DO NOT EDIT. // Source: executor.go // @@ -21,12 +5,14 @@ // // mockgen -source executor.go -destination executor_mocks.go -package executor // + // Package executor is a generated GoMock package. package executor import ( reflect "reflect" + db "github.com/Fantom-foundation/Substate/db" gomock "go.uber.org/mock/gomock" ) @@ -54,17 +40,17 @@ func (m *MockExecutor[T]) EXPECT() *MockExecutorMockRecorder[T] { } // Run mocks base method. -func (m *MockExecutor[T]) Run(params Params, processor Processor[T], extensions []Extension[T]) error { +func (m *MockExecutor[T]) Run(params Params, processor Processor[T], extensions []Extension[T], aidaDb db.BaseDB) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Run", params, processor, extensions) + ret := m.ctrl.Call(m, "Run", params, processor, extensions, aidaDb) ret0, _ := ret[0].(error) return ret0 } // Run indicates an expected call of Run. -func (mr *MockExecutorMockRecorder[T]) Run(params, processor, extensions any) *gomock.Call { +func (mr *MockExecutorMockRecorder[T]) Run(params, processor, extensions, aidaDb any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Run", reflect.TypeOf((*MockExecutor[T])(nil).Run), params, processor, extensions) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Run", reflect.TypeOf((*MockExecutor[T])(nil).Run), params, processor, extensions, aidaDb) } // MockProcessor is a mock of Processor interface. diff --git a/executor/provider_mocks.go b/executor/provider_mocks.go index e5600b306..cd42b874c 100644 --- a/executor/provider_mocks.go +++ b/executor/provider_mocks.go @@ -1,19 +1,3 @@ -// Copyright 2024 Fantom Foundation -// This file is part of Aida Testing Infrastructure for Sonic -// -// Aida is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Aida is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with Aida. If not, see . - // Code generated by MockGen. DO NOT EDIT. // Source: provider.go // @@ -21,6 +5,7 @@ // // mockgen -source provider.go -destination provider_mocks.go -package executor // + // Package executor is a generated GoMock package. package executor diff --git a/executor/test_consumer_mocks.go b/executor/test_consumer_mocks.go index 669c15416..3561d45ed 100644 --- a/executor/test_consumer_mocks.go +++ b/executor/test_consumer_mocks.go @@ -1,19 +1,3 @@ -// Copyright 2024 Fantom Foundation -// This file is part of Aida Testing Infrastructure for Sonic -// -// Aida is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Aida is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with Aida. If not, see . - // Code generated by MockGen. DO NOT EDIT. // Source: test_consumer.go // @@ -21,6 +5,7 @@ // // mockgen -source test_consumer.go -destination test_consumer_mocks.go -package executor // + // Package executor is a generated GoMock package. package executor diff --git a/logger/logger_mocks.go b/logger/logger_mocks.go index 415475be7..433bc4608 100644 --- a/logger/logger_mocks.go +++ b/logger/logger_mocks.go @@ -1,19 +1,3 @@ -// Copyright 2024 Fantom Foundation -// This file is part of Aida Testing Infrastructure for Sonic -// -// Aida is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Aida is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with Aida. If not, see . - // Code generated by MockGen. DO NOT EDIT. // Source: logger.go // @@ -21,6 +5,7 @@ // // mockgen -source logger.go -destination logger_mocks.go -package logger // + // Package logger is a generated GoMock package. package logger diff --git a/rpc/reader_mocks.go b/rpc/reader_mocks.go index a4243bc84..8d0841fcf 100644 --- a/rpc/reader_mocks.go +++ b/rpc/reader_mocks.go @@ -1,19 +1,3 @@ -// Copyright 2024 Fantom Foundation -// This file is part of Aida Testing Infrastructure for Sonic -// -// Aida is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Aida is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with Aida. If not, see . - // Code generated by MockGen. DO NOT EDIT. // Source: reader.go // @@ -21,6 +5,7 @@ // // mockgen -source reader.go -destination reader_mocks.go -package rpc // + // Package rpc is a generated GoMock package. package rpc diff --git a/state/cache_mocks.go b/state/cache_mocks.go index 7245d104b..29cf11af9 100644 --- a/state/cache_mocks.go +++ b/state/cache_mocks.go @@ -5,6 +5,7 @@ // // mockgen -source cache.go -destination cache_mocks.go -package state // + // Package state is a generated GoMock package. package state diff --git a/state/state_mocks.go b/state/state_mocks.go index 90aff02dc..14054587b 100644 --- a/state/state_mocks.go +++ b/state/state_mocks.go @@ -1,19 +1,3 @@ -// Copyright 2024 Fantom Foundation -// This file is part of Aida Testing Infrastructure for Sonic -// -// Aida is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Aida is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with Aida. If not, see . - // Code generated by MockGen. DO NOT EDIT. // Source: state.go // @@ -21,16 +5,19 @@ // // mockgen -source state.go -destination state_mocks.go -package state // + // Package state is a generated GoMock package. package state import ( - big "math/big" reflect "reflect" txcontext "github.com/Fantom-foundation/Aida/txcontext" common "github.com/ethereum/go-ethereum/common" + tracing "github.com/ethereum/go-ethereum/core/tracing" types "github.com/ethereum/go-ethereum/core/types" + params "github.com/ethereum/go-ethereum/params" + uint256 "github.com/holiman/uint256" gomock "go.uber.org/mock/gomock" ) @@ -70,15 +57,15 @@ func (mr *MockVmStateDBMockRecorder) AddAddressToAccessList(addr any) *gomock.Ca } // AddBalance mocks base method. -func (m *MockVmStateDB) AddBalance(arg0 common.Address, arg1 *big.Int) { +func (m *MockVmStateDB) AddBalance(arg0 common.Address, arg1 *uint256.Int, arg2 tracing.BalanceChangeReason) { m.ctrl.T.Helper() - m.ctrl.Call(m, "AddBalance", arg0, arg1) + m.ctrl.Call(m, "AddBalance", arg0, arg1, arg2) } // AddBalance indicates an expected call of AddBalance. -func (mr *MockVmStateDBMockRecorder) AddBalance(arg0, arg1 any) *gomock.Call { +func (mr *MockVmStateDBMockRecorder) AddBalance(arg0, arg1, arg2 any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddBalance", reflect.TypeOf((*MockVmStateDB)(nil).AddBalance), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddBalance", reflect.TypeOf((*MockVmStateDB)(nil).AddBalance), arg0, arg1, arg2) } // AddLog mocks base method. @@ -169,6 +156,18 @@ func (mr *MockVmStateDBMockRecorder) CreateAccount(arg0 any) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateAccount", reflect.TypeOf((*MockVmStateDB)(nil).CreateAccount), arg0) } +// CreateContract mocks base method. +func (m *MockVmStateDB) CreateContract(arg0 common.Address) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "CreateContract", arg0) +} + +// CreateContract indicates an expected call of CreateContract. +func (mr *MockVmStateDBMockRecorder) CreateContract(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateContract", reflect.TypeOf((*MockVmStateDB)(nil).CreateContract), arg0) +} + // Empty mocks base method. func (m *MockVmStateDB) Empty(arg0 common.Address) bool { m.ctrl.T.Helper() @@ -211,25 +210,11 @@ func (mr *MockVmStateDBMockRecorder) Exist(arg0 any) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Exist", reflect.TypeOf((*MockVmStateDB)(nil).Exist), arg0) } -// ForEachStorage mocks base method. -func (m *MockVmStateDB) ForEachStorage(arg0 common.Address, arg1 func(common.Hash, common.Hash) bool) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ForEachStorage", arg0, arg1) - ret0, _ := ret[0].(error) - return ret0 -} - -// ForEachStorage indicates an expected call of ForEachStorage. -func (mr *MockVmStateDBMockRecorder) ForEachStorage(arg0, arg1 any) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ForEachStorage", reflect.TypeOf((*MockVmStateDB)(nil).ForEachStorage), arg0, arg1) -} - // GetBalance mocks base method. -func (m *MockVmStateDB) GetBalance(arg0 common.Address) *big.Int { +func (m *MockVmStateDB) GetBalance(arg0 common.Address) *uint256.Int { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetBalance", arg0) - ret0, _ := ret[0].(*big.Int) + ret0, _ := ret[0].(*uint256.Int) return ret0 } @@ -296,17 +281,17 @@ func (mr *MockVmStateDBMockRecorder) GetCommittedState(arg0, arg1 any) *gomock.C } // GetLogs mocks base method. -func (m *MockVmStateDB) GetLogs(arg0, arg1 common.Hash) []*types.Log { +func (m *MockVmStateDB) GetLogs(arg0 common.Hash, arg1 uint64, arg2 common.Hash) []*types.Log { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetLogs", arg0, arg1) + ret := m.ctrl.Call(m, "GetLogs", arg0, arg1, arg2) ret0, _ := ret[0].([]*types.Log) return ret0 } // GetLogs indicates an expected call of GetLogs. -func (mr *MockVmStateDBMockRecorder) GetLogs(arg0, arg1 any) *gomock.Call { +func (mr *MockVmStateDBMockRecorder) GetLogs(arg0, arg1, arg2 any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetLogs", reflect.TypeOf((*MockVmStateDB)(nil).GetLogs), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetLogs", reflect.TypeOf((*MockVmStateDB)(nil).GetLogs), arg0, arg1, arg2) } // GetNonce mocks base method. @@ -351,6 +336,20 @@ func (mr *MockVmStateDBMockRecorder) GetState(arg0, arg1 any) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetState", reflect.TypeOf((*MockVmStateDB)(nil).GetState), arg0, arg1) } +// GetStorageRoot mocks base method. +func (m *MockVmStateDB) GetStorageRoot(addr common.Address) common.Hash { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetStorageRoot", addr) + ret0, _ := ret[0].(common.Hash) + return ret0 +} + +// GetStorageRoot indicates an expected call of GetStorageRoot. +func (mr *MockVmStateDBMockRecorder) GetStorageRoot(addr any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetStorageRoot", reflect.TypeOf((*MockVmStateDB)(nil).GetStorageRoot), addr) +} + // GetSubstatePostAlloc mocks base method. func (m *MockVmStateDB) GetSubstatePostAlloc() txcontext.WorldState { m.ctrl.T.Helper() @@ -365,42 +364,44 @@ func (mr *MockVmStateDBMockRecorder) GetSubstatePostAlloc() *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSubstatePostAlloc", reflect.TypeOf((*MockVmStateDB)(nil).GetSubstatePostAlloc)) } -// HasSuicided mocks base method. -func (m *MockVmStateDB) HasSuicided(arg0 common.Address) bool { +// GetTransientState mocks base method. +func (m *MockVmStateDB) GetTransientState(addr common.Address, key common.Hash) common.Hash { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "HasSuicided", arg0) - ret0, _ := ret[0].(bool) + ret := m.ctrl.Call(m, "GetTransientState", addr, key) + ret0, _ := ret[0].(common.Hash) return ret0 } -// HasSuicided indicates an expected call of HasSuicided. -func (mr *MockVmStateDBMockRecorder) HasSuicided(arg0 any) *gomock.Call { +// GetTransientState indicates an expected call of GetTransientState. +func (mr *MockVmStateDBMockRecorder) GetTransientState(addr, key any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HasSuicided", reflect.TypeOf((*MockVmStateDB)(nil).HasSuicided), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTransientState", reflect.TypeOf((*MockVmStateDB)(nil).GetTransientState), addr, key) } -// Prepare mocks base method. -func (m *MockVmStateDB) Prepare(arg0 common.Hash, arg1 int) { +// HasSelfDestructed mocks base method. +func (m *MockVmStateDB) HasSelfDestructed(arg0 common.Address) bool { m.ctrl.T.Helper() - m.ctrl.Call(m, "Prepare", arg0, arg1) + ret := m.ctrl.Call(m, "HasSelfDestructed", arg0) + ret0, _ := ret[0].(bool) + return ret0 } -// Prepare indicates an expected call of Prepare. -func (mr *MockVmStateDBMockRecorder) Prepare(arg0, arg1 any) *gomock.Call { +// HasSelfDestructed indicates an expected call of HasSelfDestructed. +func (mr *MockVmStateDBMockRecorder) HasSelfDestructed(arg0 any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Prepare", reflect.TypeOf((*MockVmStateDB)(nil).Prepare), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HasSelfDestructed", reflect.TypeOf((*MockVmStateDB)(nil).HasSelfDestructed), arg0) } -// PrepareAccessList mocks base method. -func (m *MockVmStateDB) PrepareAccessList(sender common.Address, dest *common.Address, precompiles []common.Address, txAccesses types.AccessList) { +// Prepare mocks base method. +func (m *MockVmStateDB) Prepare(arg0 params.Rules, arg1, arg2 common.Address, arg3 *common.Address, arg4 []common.Address, arg5 types.AccessList) { m.ctrl.T.Helper() - m.ctrl.Call(m, "PrepareAccessList", sender, dest, precompiles, txAccesses) + m.ctrl.Call(m, "Prepare", arg0, arg1, arg2, arg3, arg4, arg5) } -// PrepareAccessList indicates an expected call of PrepareAccessList. -func (mr *MockVmStateDBMockRecorder) PrepareAccessList(sender, dest, precompiles, txAccesses any) *gomock.Call { +// Prepare indicates an expected call of Prepare. +func (mr *MockVmStateDBMockRecorder) Prepare(arg0, arg1, arg2, arg3, arg4, arg5 any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PrepareAccessList", reflect.TypeOf((*MockVmStateDB)(nil).PrepareAccessList), sender, dest, precompiles, txAccesses) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Prepare", reflect.TypeOf((*MockVmStateDB)(nil).Prepare), arg0, arg1, arg2, arg3, arg4, arg5) } // RevertToSnapshot mocks base method. @@ -415,6 +416,30 @@ func (mr *MockVmStateDBMockRecorder) RevertToSnapshot(arg0 any) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RevertToSnapshot", reflect.TypeOf((*MockVmStateDB)(nil).RevertToSnapshot), arg0) } +// SelfDestruct mocks base method. +func (m *MockVmStateDB) SelfDestruct(arg0 common.Address) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "SelfDestruct", arg0) +} + +// SelfDestruct indicates an expected call of SelfDestruct. +func (mr *MockVmStateDBMockRecorder) SelfDestruct(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SelfDestruct", reflect.TypeOf((*MockVmStateDB)(nil).SelfDestruct), arg0) +} + +// Selfdestruct6780 mocks base method. +func (m *MockVmStateDB) Selfdestruct6780(arg0 common.Address) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "Selfdestruct6780", arg0) +} + +// Selfdestruct6780 indicates an expected call of Selfdestruct6780. +func (mr *MockVmStateDBMockRecorder) Selfdestruct6780(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Selfdestruct6780", reflect.TypeOf((*MockVmStateDB)(nil).Selfdestruct6780), arg0) +} + // SetCode mocks base method. func (m *MockVmStateDB) SetCode(arg0 common.Address, arg1 []byte) { m.ctrl.T.Helper() @@ -451,6 +476,30 @@ func (mr *MockVmStateDBMockRecorder) SetState(arg0, arg1, arg2 any) *gomock.Call return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetState", reflect.TypeOf((*MockVmStateDB)(nil).SetState), arg0, arg1, arg2) } +// SetTransientState mocks base method. +func (m *MockVmStateDB) SetTransientState(addr common.Address, key, value common.Hash) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "SetTransientState", addr, key, value) +} + +// SetTransientState indicates an expected call of SetTransientState. +func (mr *MockVmStateDBMockRecorder) SetTransientState(addr, key, value any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetTransientState", reflect.TypeOf((*MockVmStateDB)(nil).SetTransientState), addr, key, value) +} + +// SetTxContext mocks base method. +func (m *MockVmStateDB) SetTxContext(arg0 common.Hash, arg1 int) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "SetTxContext", arg0, arg1) +} + +// SetTxContext indicates an expected call of SetTxContext. +func (mr *MockVmStateDBMockRecorder) SetTxContext(arg0, arg1 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetTxContext", reflect.TypeOf((*MockVmStateDB)(nil).SetTxContext), arg0, arg1) +} + // SlotInAccessList mocks base method. func (m *MockVmStateDB) SlotInAccessList(addr common.Address, slot common.Hash) (bool, bool) { m.ctrl.T.Helper() @@ -481,15 +530,15 @@ func (mr *MockVmStateDBMockRecorder) Snapshot() *gomock.Call { } // SubBalance mocks base method. -func (m *MockVmStateDB) SubBalance(arg0 common.Address, arg1 *big.Int) { +func (m *MockVmStateDB) SubBalance(arg0 common.Address, arg1 *uint256.Int, arg2 tracing.BalanceChangeReason) { m.ctrl.T.Helper() - m.ctrl.Call(m, "SubBalance", arg0, arg1) + m.ctrl.Call(m, "SubBalance", arg0, arg1, arg2) } // SubBalance indicates an expected call of SubBalance. -func (mr *MockVmStateDBMockRecorder) SubBalance(arg0, arg1 any) *gomock.Call { +func (mr *MockVmStateDBMockRecorder) SubBalance(arg0, arg1, arg2 any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SubBalance", reflect.TypeOf((*MockVmStateDB)(nil).SubBalance), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SubBalance", reflect.TypeOf((*MockVmStateDB)(nil).SubBalance), arg0, arg1, arg2) } // SubRefund mocks base method. @@ -504,20 +553,6 @@ func (mr *MockVmStateDBMockRecorder) SubRefund(arg0 any) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SubRefund", reflect.TypeOf((*MockVmStateDB)(nil).SubRefund), arg0) } -// Suicide mocks base method. -func (m *MockVmStateDB) Suicide(arg0 common.Address) bool { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Suicide", arg0) - ret0, _ := ret[0].(bool) - return ret0 -} - -// Suicide indicates an expected call of Suicide. -func (mr *MockVmStateDBMockRecorder) Suicide(arg0 any) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Suicide", reflect.TypeOf((*MockVmStateDB)(nil).Suicide), arg0) -} - // MockNonCommittableStateDB is a mock of NonCommittableStateDB interface. type MockNonCommittableStateDB struct { ctrl *gomock.Controller @@ -554,15 +589,15 @@ func (mr *MockNonCommittableStateDBMockRecorder) AddAddressToAccessList(addr any } // AddBalance mocks base method. -func (m *MockNonCommittableStateDB) AddBalance(arg0 common.Address, arg1 *big.Int) { +func (m *MockNonCommittableStateDB) AddBalance(arg0 common.Address, arg1 *uint256.Int, arg2 tracing.BalanceChangeReason) { m.ctrl.T.Helper() - m.ctrl.Call(m, "AddBalance", arg0, arg1) + m.ctrl.Call(m, "AddBalance", arg0, arg1, arg2) } // AddBalance indicates an expected call of AddBalance. -func (mr *MockNonCommittableStateDBMockRecorder) AddBalance(arg0, arg1 any) *gomock.Call { +func (mr *MockNonCommittableStateDBMockRecorder) AddBalance(arg0, arg1, arg2 any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddBalance", reflect.TypeOf((*MockNonCommittableStateDB)(nil).AddBalance), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddBalance", reflect.TypeOf((*MockNonCommittableStateDB)(nil).AddBalance), arg0, arg1, arg2) } // AddLog mocks base method. @@ -653,6 +688,18 @@ func (mr *MockNonCommittableStateDBMockRecorder) CreateAccount(arg0 any) *gomock return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateAccount", reflect.TypeOf((*MockNonCommittableStateDB)(nil).CreateAccount), arg0) } +// CreateContract mocks base method. +func (m *MockNonCommittableStateDB) CreateContract(arg0 common.Address) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "CreateContract", arg0) +} + +// CreateContract indicates an expected call of CreateContract. +func (mr *MockNonCommittableStateDBMockRecorder) CreateContract(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateContract", reflect.TypeOf((*MockNonCommittableStateDB)(nil).CreateContract), arg0) +} + // Empty mocks base method. func (m *MockNonCommittableStateDB) Empty(arg0 common.Address) bool { m.ctrl.T.Helper() @@ -695,25 +742,11 @@ func (mr *MockNonCommittableStateDBMockRecorder) Exist(arg0 any) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Exist", reflect.TypeOf((*MockNonCommittableStateDB)(nil).Exist), arg0) } -// ForEachStorage mocks base method. -func (m *MockNonCommittableStateDB) ForEachStorage(arg0 common.Address, arg1 func(common.Hash, common.Hash) bool) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ForEachStorage", arg0, arg1) - ret0, _ := ret[0].(error) - return ret0 -} - -// ForEachStorage indicates an expected call of ForEachStorage. -func (mr *MockNonCommittableStateDBMockRecorder) ForEachStorage(arg0, arg1 any) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ForEachStorage", reflect.TypeOf((*MockNonCommittableStateDB)(nil).ForEachStorage), arg0, arg1) -} - // GetBalance mocks base method. -func (m *MockNonCommittableStateDB) GetBalance(arg0 common.Address) *big.Int { +func (m *MockNonCommittableStateDB) GetBalance(arg0 common.Address) *uint256.Int { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetBalance", arg0) - ret0, _ := ret[0].(*big.Int) + ret0, _ := ret[0].(*uint256.Int) return ret0 } @@ -795,17 +828,17 @@ func (mr *MockNonCommittableStateDBMockRecorder) GetHash() *gomock.Call { } // GetLogs mocks base method. -func (m *MockNonCommittableStateDB) GetLogs(arg0, arg1 common.Hash) []*types.Log { +func (m *MockNonCommittableStateDB) GetLogs(arg0 common.Hash, arg1 uint64, arg2 common.Hash) []*types.Log { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetLogs", arg0, arg1) + ret := m.ctrl.Call(m, "GetLogs", arg0, arg1, arg2) ret0, _ := ret[0].([]*types.Log) return ret0 } // GetLogs indicates an expected call of GetLogs. -func (mr *MockNonCommittableStateDBMockRecorder) GetLogs(arg0, arg1 any) *gomock.Call { +func (mr *MockNonCommittableStateDBMockRecorder) GetLogs(arg0, arg1, arg2 any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetLogs", reflect.TypeOf((*MockNonCommittableStateDB)(nil).GetLogs), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetLogs", reflect.TypeOf((*MockNonCommittableStateDB)(nil).GetLogs), arg0, arg1, arg2) } // GetNonce mocks base method. @@ -850,6 +883,20 @@ func (mr *MockNonCommittableStateDBMockRecorder) GetState(arg0, arg1 any) *gomoc return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetState", reflect.TypeOf((*MockNonCommittableStateDB)(nil).GetState), arg0, arg1) } +// GetStorageRoot mocks base method. +func (m *MockNonCommittableStateDB) GetStorageRoot(addr common.Address) common.Hash { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetStorageRoot", addr) + ret0, _ := ret[0].(common.Hash) + return ret0 +} + +// GetStorageRoot indicates an expected call of GetStorageRoot. +func (mr *MockNonCommittableStateDBMockRecorder) GetStorageRoot(addr any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetStorageRoot", reflect.TypeOf((*MockNonCommittableStateDB)(nil).GetStorageRoot), addr) +} + // GetSubstatePostAlloc mocks base method. func (m *MockNonCommittableStateDB) GetSubstatePostAlloc() txcontext.WorldState { m.ctrl.T.Helper() @@ -864,42 +911,44 @@ func (mr *MockNonCommittableStateDBMockRecorder) GetSubstatePostAlloc() *gomock. return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSubstatePostAlloc", reflect.TypeOf((*MockNonCommittableStateDB)(nil).GetSubstatePostAlloc)) } -// HasSuicided mocks base method. -func (m *MockNonCommittableStateDB) HasSuicided(arg0 common.Address) bool { +// GetTransientState mocks base method. +func (m *MockNonCommittableStateDB) GetTransientState(addr common.Address, key common.Hash) common.Hash { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "HasSuicided", arg0) - ret0, _ := ret[0].(bool) + ret := m.ctrl.Call(m, "GetTransientState", addr, key) + ret0, _ := ret[0].(common.Hash) return ret0 } -// HasSuicided indicates an expected call of HasSuicided. -func (mr *MockNonCommittableStateDBMockRecorder) HasSuicided(arg0 any) *gomock.Call { +// GetTransientState indicates an expected call of GetTransientState. +func (mr *MockNonCommittableStateDBMockRecorder) GetTransientState(addr, key any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HasSuicided", reflect.TypeOf((*MockNonCommittableStateDB)(nil).HasSuicided), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTransientState", reflect.TypeOf((*MockNonCommittableStateDB)(nil).GetTransientState), addr, key) } -// Prepare mocks base method. -func (m *MockNonCommittableStateDB) Prepare(arg0 common.Hash, arg1 int) { +// HasSelfDestructed mocks base method. +func (m *MockNonCommittableStateDB) HasSelfDestructed(arg0 common.Address) bool { m.ctrl.T.Helper() - m.ctrl.Call(m, "Prepare", arg0, arg1) + ret := m.ctrl.Call(m, "HasSelfDestructed", arg0) + ret0, _ := ret[0].(bool) + return ret0 } -// Prepare indicates an expected call of Prepare. -func (mr *MockNonCommittableStateDBMockRecorder) Prepare(arg0, arg1 any) *gomock.Call { +// HasSelfDestructed indicates an expected call of HasSelfDestructed. +func (mr *MockNonCommittableStateDBMockRecorder) HasSelfDestructed(arg0 any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Prepare", reflect.TypeOf((*MockNonCommittableStateDB)(nil).Prepare), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HasSelfDestructed", reflect.TypeOf((*MockNonCommittableStateDB)(nil).HasSelfDestructed), arg0) } -// PrepareAccessList mocks base method. -func (m *MockNonCommittableStateDB) PrepareAccessList(sender common.Address, dest *common.Address, precompiles []common.Address, txAccesses types.AccessList) { +// Prepare mocks base method. +func (m *MockNonCommittableStateDB) Prepare(arg0 params.Rules, arg1, arg2 common.Address, arg3 *common.Address, arg4 []common.Address, arg5 types.AccessList) { m.ctrl.T.Helper() - m.ctrl.Call(m, "PrepareAccessList", sender, dest, precompiles, txAccesses) + m.ctrl.Call(m, "Prepare", arg0, arg1, arg2, arg3, arg4, arg5) } -// PrepareAccessList indicates an expected call of PrepareAccessList. -func (mr *MockNonCommittableStateDBMockRecorder) PrepareAccessList(sender, dest, precompiles, txAccesses any) *gomock.Call { +// Prepare indicates an expected call of Prepare. +func (mr *MockNonCommittableStateDBMockRecorder) Prepare(arg0, arg1, arg2, arg3, arg4, arg5 any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PrepareAccessList", reflect.TypeOf((*MockNonCommittableStateDB)(nil).PrepareAccessList), sender, dest, precompiles, txAccesses) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Prepare", reflect.TypeOf((*MockNonCommittableStateDB)(nil).Prepare), arg0, arg1, arg2, arg3, arg4, arg5) } // Release mocks base method. @@ -928,6 +977,30 @@ func (mr *MockNonCommittableStateDBMockRecorder) RevertToSnapshot(arg0 any) *gom return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RevertToSnapshot", reflect.TypeOf((*MockNonCommittableStateDB)(nil).RevertToSnapshot), arg0) } +// SelfDestruct mocks base method. +func (m *MockNonCommittableStateDB) SelfDestruct(arg0 common.Address) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "SelfDestruct", arg0) +} + +// SelfDestruct indicates an expected call of SelfDestruct. +func (mr *MockNonCommittableStateDBMockRecorder) SelfDestruct(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SelfDestruct", reflect.TypeOf((*MockNonCommittableStateDB)(nil).SelfDestruct), arg0) +} + +// Selfdestruct6780 mocks base method. +func (m *MockNonCommittableStateDB) Selfdestruct6780(arg0 common.Address) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "Selfdestruct6780", arg0) +} + +// Selfdestruct6780 indicates an expected call of Selfdestruct6780. +func (mr *MockNonCommittableStateDBMockRecorder) Selfdestruct6780(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Selfdestruct6780", reflect.TypeOf((*MockNonCommittableStateDB)(nil).Selfdestruct6780), arg0) +} + // SetCode mocks base method. func (m *MockNonCommittableStateDB) SetCode(arg0 common.Address, arg1 []byte) { m.ctrl.T.Helper() @@ -964,6 +1037,30 @@ func (mr *MockNonCommittableStateDBMockRecorder) SetState(arg0, arg1, arg2 any) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetState", reflect.TypeOf((*MockNonCommittableStateDB)(nil).SetState), arg0, arg1, arg2) } +// SetTransientState mocks base method. +func (m *MockNonCommittableStateDB) SetTransientState(addr common.Address, key, value common.Hash) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "SetTransientState", addr, key, value) +} + +// SetTransientState indicates an expected call of SetTransientState. +func (mr *MockNonCommittableStateDBMockRecorder) SetTransientState(addr, key, value any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetTransientState", reflect.TypeOf((*MockNonCommittableStateDB)(nil).SetTransientState), addr, key, value) +} + +// SetTxContext mocks base method. +func (m *MockNonCommittableStateDB) SetTxContext(arg0 common.Hash, arg1 int) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "SetTxContext", arg0, arg1) +} + +// SetTxContext indicates an expected call of SetTxContext. +func (mr *MockNonCommittableStateDBMockRecorder) SetTxContext(arg0, arg1 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetTxContext", reflect.TypeOf((*MockNonCommittableStateDB)(nil).SetTxContext), arg0, arg1) +} + // SlotInAccessList mocks base method. func (m *MockNonCommittableStateDB) SlotInAccessList(addr common.Address, slot common.Hash) (bool, bool) { m.ctrl.T.Helper() @@ -994,15 +1091,15 @@ func (mr *MockNonCommittableStateDBMockRecorder) Snapshot() *gomock.Call { } // SubBalance mocks base method. -func (m *MockNonCommittableStateDB) SubBalance(arg0 common.Address, arg1 *big.Int) { +func (m *MockNonCommittableStateDB) SubBalance(arg0 common.Address, arg1 *uint256.Int, arg2 tracing.BalanceChangeReason) { m.ctrl.T.Helper() - m.ctrl.Call(m, "SubBalance", arg0, arg1) + m.ctrl.Call(m, "SubBalance", arg0, arg1, arg2) } // SubBalance indicates an expected call of SubBalance. -func (mr *MockNonCommittableStateDBMockRecorder) SubBalance(arg0, arg1 any) *gomock.Call { +func (mr *MockNonCommittableStateDBMockRecorder) SubBalance(arg0, arg1, arg2 any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SubBalance", reflect.TypeOf((*MockNonCommittableStateDB)(nil).SubBalance), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SubBalance", reflect.TypeOf((*MockNonCommittableStateDB)(nil).SubBalance), arg0, arg1, arg2) } // SubRefund mocks base method. @@ -1017,20 +1114,6 @@ func (mr *MockNonCommittableStateDBMockRecorder) SubRefund(arg0 any) *gomock.Cal return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SubRefund", reflect.TypeOf((*MockNonCommittableStateDB)(nil).SubRefund), arg0) } -// Suicide mocks base method. -func (m *MockNonCommittableStateDB) Suicide(arg0 common.Address) bool { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Suicide", arg0) - ret0, _ := ret[0].(bool) - return ret0 -} - -// Suicide indicates an expected call of Suicide. -func (mr *MockNonCommittableStateDBMockRecorder) Suicide(arg0 any) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Suicide", reflect.TypeOf((*MockNonCommittableStateDB)(nil).Suicide), arg0) -} - // MockStateDB is a mock of StateDB interface. type MockStateDB struct { ctrl *gomock.Controller @@ -1067,15 +1150,15 @@ func (mr *MockStateDBMockRecorder) AddAddressToAccessList(addr any) *gomock.Call } // AddBalance mocks base method. -func (m *MockStateDB) AddBalance(arg0 common.Address, arg1 *big.Int) { +func (m *MockStateDB) AddBalance(arg0 common.Address, arg1 *uint256.Int, arg2 tracing.BalanceChangeReason) { m.ctrl.T.Helper() - m.ctrl.Call(m, "AddBalance", arg0, arg1) + m.ctrl.Call(m, "AddBalance", arg0, arg1, arg2) } // AddBalance indicates an expected call of AddBalance. -func (mr *MockStateDBMockRecorder) AddBalance(arg0, arg1 any) *gomock.Call { +func (mr *MockStateDBMockRecorder) AddBalance(arg0, arg1, arg2 any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddBalance", reflect.TypeOf((*MockStateDB)(nil).AddBalance), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddBalance", reflect.TypeOf((*MockStateDB)(nil).AddBalance), arg0, arg1, arg2) } // AddLog mocks base method. @@ -1195,18 +1278,18 @@ func (mr *MockStateDBMockRecorder) Close() *gomock.Call { } // Commit mocks base method. -func (m *MockStateDB) Commit(arg0 bool) (common.Hash, error) { +func (m *MockStateDB) Commit(arg0 uint64, arg1 bool) (common.Hash, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Commit", arg0) + ret := m.ctrl.Call(m, "Commit", arg0, arg1) ret0, _ := ret[0].(common.Hash) ret1, _ := ret[1].(error) return ret0, ret1 } // Commit indicates an expected call of Commit. -func (mr *MockStateDBMockRecorder) Commit(arg0 any) *gomock.Call { +func (mr *MockStateDBMockRecorder) Commit(arg0, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Commit", reflect.TypeOf((*MockStateDB)(nil).Commit), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Commit", reflect.TypeOf((*MockStateDB)(nil).Commit), arg0, arg1) } // CreateAccount mocks base method. @@ -1221,6 +1304,18 @@ func (mr *MockStateDBMockRecorder) CreateAccount(arg0 any) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateAccount", reflect.TypeOf((*MockStateDB)(nil).CreateAccount), arg0) } +// CreateContract mocks base method. +func (m *MockStateDB) CreateContract(arg0 common.Address) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "CreateContract", arg0) +} + +// CreateContract indicates an expected call of CreateContract. +func (mr *MockStateDBMockRecorder) CreateContract(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateContract", reflect.TypeOf((*MockStateDB)(nil).CreateContract), arg0) +} + // Empty mocks base method. func (m *MockStateDB) Empty(arg0 common.Address) bool { m.ctrl.T.Helper() @@ -1315,20 +1410,6 @@ func (mr *MockStateDBMockRecorder) Finalise(arg0 any) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Finalise", reflect.TypeOf((*MockStateDB)(nil).Finalise), arg0) } -// ForEachStorage mocks base method. -func (m *MockStateDB) ForEachStorage(arg0 common.Address, arg1 func(common.Hash, common.Hash) bool) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ForEachStorage", arg0, arg1) - ret0, _ := ret[0].(error) - return ret0 -} - -// ForEachStorage indicates an expected call of ForEachStorage. -func (mr *MockStateDBMockRecorder) ForEachStorage(arg0, arg1 any) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ForEachStorage", reflect.TypeOf((*MockStateDB)(nil).ForEachStorage), arg0, arg1) -} - // GetArchiveBlockHeight mocks base method. func (m *MockStateDB) GetArchiveBlockHeight() (uint64, bool, error) { m.ctrl.T.Helper() @@ -1361,10 +1442,10 @@ func (mr *MockStateDBMockRecorder) GetArchiveState(block any) *gomock.Call { } // GetBalance mocks base method. -func (m *MockStateDB) GetBalance(arg0 common.Address) *big.Int { +func (m *MockStateDB) GetBalance(arg0 common.Address) *uint256.Int { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetBalance", arg0) - ret0, _ := ret[0].(*big.Int) + ret0, _ := ret[0].(*uint256.Int) return ret0 } @@ -1446,17 +1527,17 @@ func (mr *MockStateDBMockRecorder) GetHash() *gomock.Call { } // GetLogs mocks base method. -func (m *MockStateDB) GetLogs(arg0, arg1 common.Hash) []*types.Log { +func (m *MockStateDB) GetLogs(arg0 common.Hash, arg1 uint64, arg2 common.Hash) []*types.Log { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetLogs", arg0, arg1) + ret := m.ctrl.Call(m, "GetLogs", arg0, arg1, arg2) ret0, _ := ret[0].([]*types.Log) return ret0 } // GetLogs indicates an expected call of GetLogs. -func (mr *MockStateDBMockRecorder) GetLogs(arg0, arg1 any) *gomock.Call { +func (mr *MockStateDBMockRecorder) GetLogs(arg0, arg1, arg2 any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetLogs", reflect.TypeOf((*MockStateDB)(nil).GetLogs), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetLogs", reflect.TypeOf((*MockStateDB)(nil).GetLogs), arg0, arg1, arg2) } // GetMemoryUsage mocks base method. @@ -1529,6 +1610,20 @@ func (mr *MockStateDBMockRecorder) GetState(arg0, arg1 any) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetState", reflect.TypeOf((*MockStateDB)(nil).GetState), arg0, arg1) } +// GetStorageRoot mocks base method. +func (m *MockStateDB) GetStorageRoot(addr common.Address) common.Hash { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetStorageRoot", addr) + ret0, _ := ret[0].(common.Hash) + return ret0 +} + +// GetStorageRoot indicates an expected call of GetStorageRoot. +func (mr *MockStateDBMockRecorder) GetStorageRoot(addr any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetStorageRoot", reflect.TypeOf((*MockStateDB)(nil).GetStorageRoot), addr) +} + // GetSubstatePostAlloc mocks base method. func (m *MockStateDB) GetSubstatePostAlloc() txcontext.WorldState { m.ctrl.T.Helper() @@ -1543,18 +1638,32 @@ func (mr *MockStateDBMockRecorder) GetSubstatePostAlloc() *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSubstatePostAlloc", reflect.TypeOf((*MockStateDB)(nil).GetSubstatePostAlloc)) } -// HasSuicided mocks base method. -func (m *MockStateDB) HasSuicided(arg0 common.Address) bool { +// GetTransientState mocks base method. +func (m *MockStateDB) GetTransientState(addr common.Address, key common.Hash) common.Hash { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "HasSuicided", arg0) + ret := m.ctrl.Call(m, "GetTransientState", addr, key) + ret0, _ := ret[0].(common.Hash) + return ret0 +} + +// GetTransientState indicates an expected call of GetTransientState. +func (mr *MockStateDBMockRecorder) GetTransientState(addr, key any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTransientState", reflect.TypeOf((*MockStateDB)(nil).GetTransientState), addr, key) +} + +// HasSelfDestructed mocks base method. +func (m *MockStateDB) HasSelfDestructed(arg0 common.Address) bool { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "HasSelfDestructed", arg0) ret0, _ := ret[0].(bool) return ret0 } -// HasSuicided indicates an expected call of HasSuicided. -func (mr *MockStateDBMockRecorder) HasSuicided(arg0 any) *gomock.Call { +// HasSelfDestructed indicates an expected call of HasSelfDestructed. +func (mr *MockStateDBMockRecorder) HasSelfDestructed(arg0 any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HasSuicided", reflect.TypeOf((*MockStateDB)(nil).HasSuicided), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HasSelfDestructed", reflect.TypeOf((*MockStateDB)(nil).HasSelfDestructed), arg0) } // IntermediateRoot mocks base method. @@ -1572,27 +1681,15 @@ func (mr *MockStateDBMockRecorder) IntermediateRoot(arg0 any) *gomock.Call { } // Prepare mocks base method. -func (m *MockStateDB) Prepare(arg0 common.Hash, arg1 int) { +func (m *MockStateDB) Prepare(arg0 params.Rules, arg1, arg2 common.Address, arg3 *common.Address, arg4 []common.Address, arg5 types.AccessList) { m.ctrl.T.Helper() - m.ctrl.Call(m, "Prepare", arg0, arg1) + m.ctrl.Call(m, "Prepare", arg0, arg1, arg2, arg3, arg4, arg5) } // Prepare indicates an expected call of Prepare. -func (mr *MockStateDBMockRecorder) Prepare(arg0, arg1 any) *gomock.Call { +func (mr *MockStateDBMockRecorder) Prepare(arg0, arg1, arg2, arg3, arg4, arg5 any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Prepare", reflect.TypeOf((*MockStateDB)(nil).Prepare), arg0, arg1) -} - -// PrepareAccessList mocks base method. -func (m *MockStateDB) PrepareAccessList(sender common.Address, dest *common.Address, precompiles []common.Address, txAccesses types.AccessList) { - m.ctrl.T.Helper() - m.ctrl.Call(m, "PrepareAccessList", sender, dest, precompiles, txAccesses) -} - -// PrepareAccessList indicates an expected call of PrepareAccessList. -func (mr *MockStateDBMockRecorder) PrepareAccessList(sender, dest, precompiles, txAccesses any) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PrepareAccessList", reflect.TypeOf((*MockStateDB)(nil).PrepareAccessList), sender, dest, precompiles, txAccesses) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Prepare", reflect.TypeOf((*MockStateDB)(nil).Prepare), arg0, arg1, arg2, arg3, arg4, arg5) } // PrepareSubstate mocks base method. @@ -1619,6 +1716,30 @@ func (mr *MockStateDBMockRecorder) RevertToSnapshot(arg0 any) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RevertToSnapshot", reflect.TypeOf((*MockStateDB)(nil).RevertToSnapshot), arg0) } +// SelfDestruct mocks base method. +func (m *MockStateDB) SelfDestruct(arg0 common.Address) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "SelfDestruct", arg0) +} + +// SelfDestruct indicates an expected call of SelfDestruct. +func (mr *MockStateDBMockRecorder) SelfDestruct(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SelfDestruct", reflect.TypeOf((*MockStateDB)(nil).SelfDestruct), arg0) +} + +// Selfdestruct6780 mocks base method. +func (m *MockStateDB) Selfdestruct6780(arg0 common.Address) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "Selfdestruct6780", arg0) +} + +// Selfdestruct6780 indicates an expected call of Selfdestruct6780. +func (mr *MockStateDBMockRecorder) Selfdestruct6780(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Selfdestruct6780", reflect.TypeOf((*MockStateDB)(nil).Selfdestruct6780), arg0) +} + // SetCode mocks base method. func (m *MockStateDB) SetCode(arg0 common.Address, arg1 []byte) { m.ctrl.T.Helper() @@ -1655,6 +1776,30 @@ func (mr *MockStateDBMockRecorder) SetState(arg0, arg1, arg2 any) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetState", reflect.TypeOf((*MockStateDB)(nil).SetState), arg0, arg1, arg2) } +// SetTransientState mocks base method. +func (m *MockStateDB) SetTransientState(addr common.Address, key, value common.Hash) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "SetTransientState", addr, key, value) +} + +// SetTransientState indicates an expected call of SetTransientState. +func (mr *MockStateDBMockRecorder) SetTransientState(addr, key, value any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetTransientState", reflect.TypeOf((*MockStateDB)(nil).SetTransientState), addr, key, value) +} + +// SetTxContext mocks base method. +func (m *MockStateDB) SetTxContext(arg0 common.Hash, arg1 int) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "SetTxContext", arg0, arg1) +} + +// SetTxContext indicates an expected call of SetTxContext. +func (mr *MockStateDBMockRecorder) SetTxContext(arg0, arg1 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetTxContext", reflect.TypeOf((*MockStateDB)(nil).SetTxContext), arg0, arg1) +} + // SlotInAccessList mocks base method. func (m *MockStateDB) SlotInAccessList(addr common.Address, slot common.Hash) (bool, bool) { m.ctrl.T.Helper() @@ -1700,15 +1845,15 @@ func (mr *MockStateDBMockRecorder) StartBulkLoad(block any) *gomock.Call { } // SubBalance mocks base method. -func (m *MockStateDB) SubBalance(arg0 common.Address, arg1 *big.Int) { +func (m *MockStateDB) SubBalance(arg0 common.Address, arg1 *uint256.Int, arg2 tracing.BalanceChangeReason) { m.ctrl.T.Helper() - m.ctrl.Call(m, "SubBalance", arg0, arg1) + m.ctrl.Call(m, "SubBalance", arg0, arg1, arg2) } // SubBalance indicates an expected call of SubBalance. -func (mr *MockStateDBMockRecorder) SubBalance(arg0, arg1 any) *gomock.Call { +func (mr *MockStateDBMockRecorder) SubBalance(arg0, arg1, arg2 any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SubBalance", reflect.TypeOf((*MockStateDB)(nil).SubBalance), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SubBalance", reflect.TypeOf((*MockStateDB)(nil).SubBalance), arg0, arg1, arg2) } // SubRefund mocks base method. @@ -1723,20 +1868,6 @@ func (mr *MockStateDBMockRecorder) SubRefund(arg0 any) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SubRefund", reflect.TypeOf((*MockStateDB)(nil).SubRefund), arg0) } -// Suicide mocks base method. -func (m *MockStateDB) Suicide(arg0 common.Address) bool { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Suicide", arg0) - ret0, _ := ret[0].(bool) - return ret0 -} - -// Suicide indicates an expected call of Suicide. -func (mr *MockStateDBMockRecorder) Suicide(arg0 any) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Suicide", reflect.TypeOf((*MockStateDB)(nil).Suicide), arg0) -} - // MockBulkLoad is a mock of BulkLoad interface. type MockBulkLoad struct { ctrl *gomock.Controller @@ -1787,7 +1918,7 @@ func (mr *MockBulkLoadMockRecorder) CreateAccount(arg0 any) *gomock.Call { } // SetBalance mocks base method. -func (m *MockBulkLoad) SetBalance(arg0 common.Address, arg1 *big.Int) { +func (m *MockBulkLoad) SetBalance(arg0 common.Address, arg1 *uint256.Int) { m.ctrl.T.Helper() m.ctrl.Call(m, "SetBalance", arg0, arg1) } diff --git a/utils/state_hash_mocks.go b/utils/state_hash_mocks.go index 72c573f58..2c8764927 100644 --- a/utils/state_hash_mocks.go +++ b/utils/state_hash_mocks.go @@ -1,19 +1,3 @@ -// Copyright 2024 Fantom Foundation -// This file is part of Aida Testing Infrastructure for Sonic -// -// Aida is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Aida is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with Aida. If not, see . - // Code generated by MockGen. DO NOT EDIT. // Source: state_hash.go // @@ -21,6 +5,7 @@ // // mockgen -source state_hash.go -destination state_hash_mocks.go -package utils // + // Package utils is a generated GoMock package. package utils From c29ab99791e471b0aa4a1ed2f15dbe7469e73907 Mon Sep 17 00:00:00 2001 From: wsodsong Date: Sat, 15 Jun 2024 06:44:07 +0000 Subject: [PATCH 13/26] fix state tests --- state/carmen_test.go | 19 ++++++++++--------- state/chain_conduit_test.go | 4 ++-- state/geth_test.go | 2 +- state/proxy/shadow_test.go | 20 +++++++++++--------- state/substate.go | 4 ++-- 5 files changed, 26 insertions(+), 23 deletions(-) diff --git a/state/carmen_test.go b/state/carmen_test.go index 0b4da4f0f..60d8afd21 100644 --- a/state/carmen_test.go +++ b/state/carmen_test.go @@ -19,12 +19,13 @@ package state import ( "bytes" "errors" - "math/big" "testing" carmen "github.com/Fantom-foundation/Carmen/go/state" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/params" + "github.com/holiman/uint256" ) // TestCarmenState_MakeCarmenStateDBInvalid tests db initialization with invalid Variant @@ -131,18 +132,18 @@ func TestCarmenState_AccountBalanceOperations(t *testing.T) { // get randomized balance additionBase := GetRandom(1, 1000*5000) - addition := big.NewInt(int64(additionBase)) + addition := uint256.NewInt(uint64(additionBase)) - csDB.AddBalance(addr, addition) + csDB.AddBalance(addr, addition, 0) if csDB.GetBalance(addr).Cmp(addition) != 0 { t.Fatal("failed to add balance to carmen state DB account") } - subtraction := big.NewInt(int64(GetRandom(1, additionBase))) - expectedResult := big.NewInt(0).Sub(addition, subtraction) + subtraction := uint256.NewInt(uint64(GetRandom(1, additionBase))) + expectedResult := uint256.NewInt(0).Sub(addition, subtraction) - csDB.SubBalance(addr, subtraction) + csDB.SubBalance(addr, subtraction, 0) if csDB.GetBalance(addr).Cmp(expectedResult) != 0 { t.Fatal("failed to subtract balance to carmen state DB account") @@ -414,7 +415,7 @@ func TestCarmenState_AccessListOperations(t *testing.T) { } // create access list - csDB.PrepareAccessList(sender, &dest, precompiles, txAccesses) + csDB.Prepare(params.Rules{}, sender, common.Address{}, &dest, precompiles, txAccesses) // add some more data after the creation for good measure newAddr := common.BytesToAddress(MakeRandomByteSlice(t, 40)) @@ -549,7 +550,7 @@ func TestCarmenState_SetBalanceUsingBulkInsertion(t *testing.T) { cbl.CreateAccount(addr) - newBalance := big.NewInt(int64(GetRandom(1, 1000*5000))) + newBalance := uint256.NewInt(uint64(GetRandom(1, 1000*5000))) cbl.SetBalance(addr, newBalance) err = cbl.Close() @@ -772,7 +773,7 @@ func TestCarmenState_BulkloadOperations(t *testing.T) { switch { case operationType == 1: // set balance - newBalance := big.NewInt(int64(GetRandom(0, 1000*5000))) + newBalance := uint256.NewInt(uint64(GetRandom(0, 1000*5000))) cbl.SetBalance(account, newBalance) case operationType == 2: diff --git a/state/chain_conduit_test.go b/state/chain_conduit_test.go index 2f6847ab3..f65765da6 100644 --- a/state/chain_conduit_test.go +++ b/state/chain_conduit_test.go @@ -97,7 +97,7 @@ func TestChainConduit_IsFinalise(t *testing.T) { } for _, test := range tests { c := NewChainConduit(test.isEthereum, test.chainConfig) - got := c.IsFinalise(test.block) + got := c.IsFinalise(test.block.Uint64()) if got != test.want { t.Errorf("ChainConduit.IsFinalise(%v)[%v, %v] = %v, want %v", test.block, test.isEthereum, test.chainConfig, got, test.want) } @@ -144,7 +144,7 @@ func TestChainConduit_DeleteEmptyObjects(t *testing.T) { } for _, test := range tests { c := NewChainConduit(test.isEthereum, test.chainConfig) - got := c.DeleteEmptyObjects(test.block) + got := c.DeleteEmptyObjects(test.block.Uint64()) if got != test.want { t.Errorf("ChainConduit.DeleteEmptyObjects(%v)[%v, %v] = %v, want %v", test.block, test.isEthereum, test.chainConfig, got, test.want) } diff --git a/state/geth_test.go b/state/geth_test.go index a74dbb1e4..9b7fecf0e 100644 --- a/state/geth_test.go +++ b/state/geth_test.go @@ -40,7 +40,7 @@ func fillDb(t *testing.T, directory string) (common.Hash, error) { db.SetState(address, key, value) } - hash, err := db.Commit(true) + hash, err := db.Commit(0, true) if err != nil { t.Fatalf("Failed to commit: %v", err) } diff --git a/state/proxy/shadow_test.go b/state/proxy/shadow_test.go index 25a8c6b39..1c05fb528 100644 --- a/state/proxy/shadow_test.go +++ b/state/proxy/shadow_test.go @@ -24,10 +24,10 @@ import ( "github.com/Fantom-foundation/Aida/state" carmen "github.com/Fantom-foundation/Carmen/go/state" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/core/types" - "go.uber.org/mock/gomock" + "github.com/ethereum/go-ethereum/params" "github.com/holiman/uint256" + "go.uber.org/mock/gomock" ) func makeTestShadowDBWithCarmenTestContext(t *testing.T, ctc state.CarmenStateTestCase) state.StateDB { @@ -748,7 +748,7 @@ func TestShadowState_GetLogs_Success(t *testing.T) { pdb.EXPECT().GetLogs(txHash, block, blockHash).Return([]*types.Log{log1}) sdb.EXPECT().GetLogs(txHash, block, blockHash).Return([]*types.Log{log1}) - db.GetLogs(txHash, blockHash) + db.GetLogs(txHash, block, blockHash) if err := db.Error(); err != nil { t.Fatalf("Failed to compare logs; %v", err) } @@ -762,11 +762,12 @@ func TestShadowState_GetLogsExpectError_LengthDifferent(t *testing.T) { txHash := common.HexToHash("0x1") blockHash := common.HexToHash("0x2") log1 := &types.Log{} + block := uint64(0) - pdb.EXPECT().GetLogs(txHash, blockHash).Return(nil) - sdb.EXPECT().GetLogs(txHash, blockHash).Return([]*types.Log{log1}) + pdb.EXPECT().GetLogs(txHash, block, blockHash).Return(nil) + sdb.EXPECT().GetLogs(txHash, block, blockHash).Return([]*types.Log{log1}) - db.GetLogs(txHash, blockHash) + db.GetLogs(txHash, block, blockHash) if err := db.Error(); err == nil { t.Fatal("Expect mismatched GetLogs lengths") } @@ -781,11 +782,12 @@ func TestShadowState_GetLogsExpectError_BloomDifferent(t *testing.T) { blockHash := common.HexToHash("0x2") log1 := &types.Log{} log2 := &types.Log{Address: common.HexToAddress("0x3")} + block := uint64(0) - pdb.EXPECT().GetLogs(txHash, blockHash).Return([]*types.Log{log1}) - sdb.EXPECT().GetLogs(txHash, blockHash).Return([]*types.Log{log2}) + pdb.EXPECT().GetLogs(txHash, block, blockHash).Return([]*types.Log{log1}) + sdb.EXPECT().GetLogs(txHash, block, blockHash).Return([]*types.Log{log2}) - db.GetLogs(txHash, blockHash) + db.GetLogs(txHash, block, blockHash) if err := db.Error(); err == nil { t.Fatal("Expect mismatched log values") } diff --git a/state/substate.go b/state/substate.go index bd79b758d..3748e92bd 100644 --- a/state/substate.go +++ b/state/substate.go @@ -33,7 +33,7 @@ import ( // offTheChainDB is state.cachingDB clone without disk caches type offTheChainDB struct { - trie *triedb.Database + trie *triedb.Database disk ethdb.Database } @@ -111,7 +111,7 @@ func NewOffTheChainStateDB() *state.StateDB { tdb := triedb.NewDatabase(kvdb, zerodConfig) sdb := &offTheChainDB{ - trie: tdb, + trie: tdb, disk: kvdb, } From 4571e1d7ada16e846ab8b35b5ade6b3655ec71aa Mon Sep 17 00:00:00 2001 From: wsodsong Date: Mon, 17 Jun 2024 03:36:40 +0000 Subject: [PATCH 14/26] fix aida-vm tests --- cmd/aida-vm/run_vm_test.go | 46 +++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/cmd/aida-vm/run_vm_test.go b/cmd/aida-vm/run_vm_test.go index 1058e2e18..3501334be 100644 --- a/cmd/aida-vm/run_vm_test.go +++ b/cmd/aida-vm/run_vm_test.go @@ -29,7 +29,9 @@ import ( "github.com/Fantom-foundation/Aida/utils" "github.com/Fantom-foundation/Substate/substate" substatetypes "github.com/Fantom-foundation/Substate/types" + "github.com/ethereum/go-ethereum/core/tracing" "github.com/ethereum/go-ethereum/common" + "github.com/holiman/uint256" "go.uber.org/mock/gomock" ) @@ -71,27 +73,27 @@ func TestVm_AllDbEventsAreIssuedInOrder_Sequential(t *testing.T) { // Block 2 // Tx 1 db.EXPECT().BeginTransaction(uint32(1)), - db.EXPECT().Prepare(gomock.Any(), 1), + db.EXPECT().SetTxContext(gomock.Any(), 1), db.EXPECT().Snapshot().Return(15), - db.EXPECT().GetBalance(gomock.Any()).Return(big.NewInt(1000)), + db.EXPECT().GetBalance(gomock.Any()).Return(uint256.NewInt(1000)), db.EXPECT().RevertToSnapshot(15), - db.EXPECT().GetLogs(common.HexToHash(fmt.Sprintf("0x%016d%016d", 2, 1)), common.HexToHash(fmt.Sprintf("0x%016d", 2))), + db.EXPECT().GetLogs(common.HexToHash(fmt.Sprintf("0x%016d%016d", 2, 1)), uint64(2), common.HexToHash(fmt.Sprintf("0x%016d", 2))), db.EXPECT().EndTransaction(), // Tx 2 db.EXPECT().BeginTransaction(uint32(2)), - db.EXPECT().Prepare(gomock.Any(), 2), + db.EXPECT().SetTxContext(gomock.Any(), 2), db.EXPECT().Snapshot().Return(17), - db.EXPECT().GetBalance(gomock.Any()).Return(big.NewInt(1000)), + db.EXPECT().GetBalance(gomock.Any()).Return(uint256.NewInt(1000)), db.EXPECT().RevertToSnapshot(17), - db.EXPECT().GetLogs(common.HexToHash(fmt.Sprintf("0x%016d%016d", 2, 2)), common.HexToHash(fmt.Sprintf("0x%016d", 2))), + db.EXPECT().GetLogs(common.HexToHash(fmt.Sprintf("0x%016d%016d", 2, 2)), uint64(2), common.HexToHash(fmt.Sprintf("0x%016d", 2))), db.EXPECT().EndTransaction(), // Block 3 db.EXPECT().BeginTransaction(uint32(1)), - db.EXPECT().Prepare(gomock.Any(), 1), + db.EXPECT().SetTxContext(gomock.Any(), 1), db.EXPECT().Snapshot().Return(19), - db.EXPECT().GetBalance(gomock.Any()).Return(big.NewInt(1000)), + db.EXPECT().GetBalance(gomock.Any()).Return(uint256.NewInt(1000)), db.EXPECT().RevertToSnapshot(19), - db.EXPECT().GetLogs(common.HexToHash(fmt.Sprintf("0x%016d%016d", 3, 1)), common.HexToHash(fmt.Sprintf("0x%016d", 3))), + db.EXPECT().GetLogs(common.HexToHash(fmt.Sprintf("0x%016d%016d", 3, 1)), uint64(3), common.HexToHash(fmt.Sprintf("0x%016d", 3))), db.EXPECT().EndTransaction(), // Pseudo Tx db.EXPECT().BeginTransaction(uint32(utils.PseudoTx)), @@ -267,17 +269,17 @@ func TestVmAdb_ValidationDoesNotFailOnValidTransaction_Sequential(t *testing.T) gomock.InOrder( // we return correct expected data so tx does not fail db.EXPECT().Exist(testingAddress).Return(true), - db.EXPECT().GetBalance(testingAddress).Return(new(big.Int).SetUint64(1)), + db.EXPECT().GetBalance(testingAddress).Return(new(uint256.Int).SetUint64(1)), db.EXPECT().GetNonce(testingAddress).Return(uint64(1)), db.EXPECT().GetCode(testingAddress).Return([]byte{}), db.EXPECT().BeginTransaction(uint32(1)), - db.EXPECT().Prepare(gomock.Any(), 1), + db.EXPECT().SetTxContext(gomock.Any(), 1), db.EXPECT().Snapshot().Return(15), - db.EXPECT().GetBalance(gomock.Any()).Return(big.NewInt(1000)), - db.EXPECT().SubBalance(gomock.Any(), gomock.Any()), + db.EXPECT().GetBalance(gomock.Any()).Return(uint256.NewInt(1000)), + db.EXPECT().SubBalance(gomock.Any(), gomock.Any(), tracing.BalanceDecreaseGasBuy), db.EXPECT().RevertToSnapshot(15), - db.EXPECT().GetLogs(common.HexToHash(fmt.Sprintf("0x%016d%016d", 2, 1)), common.HexToHash(fmt.Sprintf("0x%016d", 2))), + db.EXPECT().GetLogs(common.HexToHash(fmt.Sprintf("0x%016d%016d", 2, 1)), uint64(2), common.HexToHash(fmt.Sprintf("0x%016d", 2))), ) // run fails but not on validation @@ -317,17 +319,17 @@ func TestVmAdb_ValidationDoesNotFailOnValidTransaction_Parallel(t *testing.T) { gomock.InOrder( // we return correct expected data so tx does not fail db.EXPECT().Exist(testingAddress).Return(true), - db.EXPECT().GetBalance(testingAddress).Return(new(big.Int).SetUint64(1)), + db.EXPECT().GetBalance(testingAddress).Return(new(uint256.Int).SetUint64(1)), db.EXPECT().GetNonce(testingAddress).Return(uint64(1)), db.EXPECT().GetCode(testingAddress).Return([]byte{}), db.EXPECT().BeginTransaction(uint32(1)), - db.EXPECT().Prepare(gomock.Any(), 1), + db.EXPECT().SetTxContext(gomock.Any(), 1), db.EXPECT().Snapshot().Return(15), - db.EXPECT().GetBalance(gomock.Any()).Return(big.NewInt(1000)), - db.EXPECT().SubBalance(gomock.Any(), gomock.Any()), + db.EXPECT().GetBalance(gomock.Any()).Return(uint256.NewInt(1000)), + db.EXPECT().SubBalance(gomock.Any(), gomock.Any(), tracing.BalanceDecreaseGasBuy), db.EXPECT().RevertToSnapshot(15), - db.EXPECT().GetLogs(common.HexToHash(fmt.Sprintf("0x%016d%016d", 2, 1)), common.HexToHash(fmt.Sprintf("0x%016d", 2))), + db.EXPECT().GetLogs(common.HexToHash(fmt.Sprintf("0x%016d%016d", 2, 1)), uint64(2), common.HexToHash(fmt.Sprintf("0x%016d", 2))), ) // run fails but not on validation @@ -366,7 +368,7 @@ func TestVm_ValidationFailsOnInvalidTransaction_Sequential(t *testing.T) { gomock.InOrder( db.EXPECT().Exist(testingAddress).Return(false), // address does not exist - db.EXPECT().GetBalance(testingAddress).Return(new(big.Int).SetUint64(1)), + db.EXPECT().GetBalance(testingAddress).Return(new(uint256.Int).SetUint64(1)), db.EXPECT().GetNonce(testingAddress).Return(uint64(1)), db.EXPECT().GetCode(testingAddress).Return([]byte{}), db.EXPECT().BeginTransaction(uint32(1)), @@ -406,7 +408,7 @@ func TestVm_ValidationFailsOnInvalidTransaction_Parallel(t *testing.T) { gomock.InOrder( db.EXPECT().Exist(testingAddress).Return(false), // address does not exist - db.EXPECT().GetBalance(testingAddress).Return(new(big.Int).SetUint64(1)), + db.EXPECT().GetBalance(testingAddress).Return(new(uint256.Int).SetUint64(1)), db.EXPECT().GetNonce(testingAddress).Return(uint64(1)), db.EXPECT().GetCode(testingAddress).Return([]byte{}), db.EXPECT().BeginTransaction(uint32(1)), @@ -431,6 +433,7 @@ var emptyTx = &substate.Substate{ Message: &substate.Message{ Gas: 10000, GasPrice: big.NewInt(0), + Value: big.NewInt(1), }, Result: &substate.Result{ GasUsed: 1, @@ -443,6 +446,7 @@ var testTx = &substate.Substate{ Env: &substate.Env{}, Message: &substate.Message{ GasPrice: big.NewInt(12), + Value: big.NewInt(1), }, Result: &substate.Result{ GasUsed: 1, From 65eeaa088dba91f305f61666545e0534249b5713 Mon Sep 17 00:00:00 2001 From: wsodsong Date: Mon, 17 Jun 2024 04:16:13 +0000 Subject: [PATCH 15/26] fix aida-vm-sdb tests --- cmd/aida-vm-sdb/run_eth_test.go | 47 ++++++++++++------------ cmd/aida-vm-sdb/run_substate_test.go | 40 +++++++++++--------- cmd/aida-vm-sdb/run_tx_generator_test.go | 27 +++++++------- 3 files changed, 60 insertions(+), 54 deletions(-) diff --git a/cmd/aida-vm-sdb/run_eth_test.go b/cmd/aida-vm-sdb/run_eth_test.go index cb573bb4d..a531669b4 100644 --- a/cmd/aida-vm-sdb/run_eth_test.go +++ b/cmd/aida-vm-sdb/run_eth_test.go @@ -19,7 +19,6 @@ package main import ( "errors" "fmt" - "math/big" "strings" "testing" @@ -29,6 +28,8 @@ import ( "github.com/Fantom-foundation/Aida/txcontext" "github.com/Fantom-foundation/Aida/utils" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/tracing" + "github.com/holiman/uint256" "go.uber.org/mock/gomock" ) @@ -59,27 +60,27 @@ func TestVmSdb_Eth_AllDbEventsAreIssuedInOrder(t *testing.T) { // Tx 1 db.EXPECT().BeginBlock(uint64(2)), db.EXPECT().BeginTransaction(uint32(1)), - db.EXPECT().Prepare(gomock.Any(), 1), + db.EXPECT().SetTxContext(gomock.Any(), 1), db.EXPECT().Snapshot().Return(15), - db.EXPECT().GetNonce(data.GetMessage().From()).Return(uint64(1)), - db.EXPECT().GetCodeHash(data.GetMessage().From()).Return(common.HexToHash("0x0")), - db.EXPECT().GetBalance(gomock.Any()).Return(big.NewInt(1000)), - db.EXPECT().SubBalance(gomock.Any(), gomock.Any()), + db.EXPECT().GetNonce(data.GetMessage().From).Return(uint64(1)), + db.EXPECT().GetCodeHash(data.GetMessage().From).Return(common.HexToHash("0x0")), + db.EXPECT().GetBalance(gomock.Any()).Return(uint256.NewInt(1000)), + db.EXPECT().SubBalance(gomock.Any(), gomock.Any(), tracing.BalanceDecreaseGasBuy), db.EXPECT().RevertToSnapshot(15), - db.EXPECT().GetLogs(common.HexToHash(fmt.Sprintf("0x%016d%016d", 2, 1)), common.HexToHash(fmt.Sprintf("0x%016d", 2))), + db.EXPECT().GetLogs(common.HexToHash(fmt.Sprintf("0x%016d%016d", 2, 1)), uint64(2), common.HexToHash(fmt.Sprintf("0x%016d", 2))), db.EXPECT().EndTransaction(), db.EXPECT().EndBlock(), db.EXPECT().BeginBlock(uint64(2)), db.EXPECT().BeginTransaction(uint32(2)), - db.EXPECT().Prepare(gomock.Any(), 2), + db.EXPECT().SetTxContext(gomock.Any(), 2), db.EXPECT().Snapshot().Return(15), - db.EXPECT().GetNonce(data.GetMessage().From()).Return(uint64(1)), - db.EXPECT().GetCodeHash(data.GetMessage().From()).Return(common.HexToHash("0x0")), - db.EXPECT().GetBalance(gomock.Any()).Return(big.NewInt(1000)), - db.EXPECT().SubBalance(gomock.Any(), gomock.Any()), + db.EXPECT().GetNonce(data.GetMessage().From).Return(uint64(1)), + db.EXPECT().GetCodeHash(data.GetMessage().From).Return(common.HexToHash("0x0")), + db.EXPECT().GetBalance(gomock.Any()).Return(uint256.NewInt(1000)), + db.EXPECT().SubBalance(gomock.Any(), gomock.Any(), tracing.BalanceDecreaseGasBuy), db.EXPECT().RevertToSnapshot(15), - db.EXPECT().GetLogs(common.HexToHash(fmt.Sprintf("0x%016d%016d", 2, 2)), common.HexToHash(fmt.Sprintf("0x%016d", 2))), + db.EXPECT().GetLogs(common.HexToHash(fmt.Sprintf("0x%016d%016d", 2, 2)), uint64(2), common.HexToHash(fmt.Sprintf("0x%016d", 2))), db.EXPECT().EndTransaction(), db.EXPECT().EndBlock(), ) @@ -198,13 +199,13 @@ func TestVmSdb_Eth_ValidationDoesNotFailOnValidTransaction(t *testing.T) { gomock.InOrder( db.EXPECT().Exist(common.HexToAddress("0x1")).Return(true), - db.EXPECT().GetBalance(gomock.Any()).Return(big.NewInt(1000)), + db.EXPECT().GetBalance(gomock.Any()).Return(uint256.NewInt(1000)), db.EXPECT().GetNonce(common.HexToAddress("0x1")).Return(uint64(1)), db.EXPECT().GetCode(common.HexToAddress("0x1")).Return([]byte{}), ) gomock.InOrder( db.EXPECT().Exist(common.HexToAddress("0x2")).Return(true), - db.EXPECT().GetBalance(gomock.Any()).Return(big.NewInt(2000)), + db.EXPECT().GetBalance(gomock.Any()).Return(uint256.NewInt(2000)), db.EXPECT().GetNonce(common.HexToAddress("0x2")).Return(uint64(2)), db.EXPECT().GetCode(common.HexToAddress("0x2")).Return([]byte{}), ) @@ -213,14 +214,14 @@ func TestVmSdb_Eth_ValidationDoesNotFailOnValidTransaction(t *testing.T) { // Tx execution db.EXPECT().BeginBlock(uint64(2)), db.EXPECT().BeginTransaction(uint32(1)), - db.EXPECT().Prepare(gomock.Any(), 1), + db.EXPECT().SetTxContext(gomock.Any(), 1), db.EXPECT().Snapshot().Return(15), - db.EXPECT().GetNonce(data.GetMessage().From()).Return(uint64(1)), - db.EXPECT().GetCodeHash(data.GetMessage().From()).Return(common.HexToHash("0x0")), - db.EXPECT().GetBalance(gomock.Any()).Return(big.NewInt(1000)), - db.EXPECT().SubBalance(gomock.Any(), gomock.Any()), + db.EXPECT().GetNonce(data.GetMessage().From).Return(uint64(1)), + db.EXPECT().GetCodeHash(data.GetMessage().From).Return(common.HexToHash("0x0")), + db.EXPECT().GetBalance(gomock.Any()).Return(uint256.NewInt(1000)), + db.EXPECT().SubBalance(gomock.Any(), gomock.Any(), tracing.BalanceDecreaseGasBuy), db.EXPECT().RevertToSnapshot(15), - db.EXPECT().GetLogs(common.HexToHash(fmt.Sprintf("0x%016d%016d", 2, 1)), common.HexToHash(fmt.Sprintf("0x%016d", 2))), + db.EXPECT().GetLogs(common.HexToHash(fmt.Sprintf("0x%016d%016d", 2, 1)), uint64(2), common.HexToHash(fmt.Sprintf("0x%016d", 2))), // EndTransaction is not called because execution fails ) @@ -262,14 +263,14 @@ func TestVmSdb_Eth_ValidationDoesFailOnInvalidTransaction(t *testing.T) { // Validation fails on incorrect input so no db events are expected // first account has correct data db.EXPECT().Exist(common.HexToAddress("0x1")).Return(true), - db.EXPECT().GetBalance(gomock.Any()).Return(big.NewInt(1000)), + db.EXPECT().GetBalance(gomock.Any()).Return(uint256.NewInt(1000)), db.EXPECT().GetNonce(common.HexToAddress("0x1")).Return(uint64(1)), db.EXPECT().GetCode(common.HexToAddress("0x1")).Return([]byte{}), ) gomock.InOrder( // second account has incorrect balance db.EXPECT().Exist(common.HexToAddress("0x2")).Return(true), - db.EXPECT().GetBalance(gomock.Any()).Return(big.NewInt(9999)), // incorrect balance + db.EXPECT().GetBalance(gomock.Any()).Return(uint256.NewInt(9999)), // incorrect balance db.EXPECT().GetNonce(common.HexToAddress("0x2")).Return(uint64(2)), db.EXPECT().GetCode(common.HexToAddress("0x2")).Return([]byte{}), ) diff --git a/cmd/aida-vm-sdb/run_substate_test.go b/cmd/aida-vm-sdb/run_substate_test.go index 01298de9e..5da7b3ec9 100644 --- a/cmd/aida-vm-sdb/run_substate_test.go +++ b/cmd/aida-vm-sdb/run_substate_test.go @@ -31,6 +31,8 @@ import ( "github.com/Fantom-foundation/Substate/substate" substatetypes "github.com/Fantom-foundation/Substate/types" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/tracing" + "github.com/holiman/uint256" "go.uber.org/mock/gomock" ) @@ -71,34 +73,34 @@ func TestVmSdb_Substate_AllDbEventsAreIssuedInOrder(t *testing.T) { // Tx 1 db.EXPECT().PrepareSubstate(gomock.Any(), uint64(2)), db.EXPECT().BeginTransaction(uint32(1)), - db.EXPECT().Prepare(gomock.Any(), 1), + db.EXPECT().SetTxContext(gomock.Any(), 1), db.EXPECT().Snapshot().Return(15), - db.EXPECT().GetBalance(gomock.Any()).Return(big.NewInt(1000)), - db.EXPECT().SubBalance(gomock.Any(), gomock.Any()), + db.EXPECT().GetBalance(gomock.Any()).Return(uint256.NewInt(1000)), + db.EXPECT().SubBalance(gomock.Any(), gomock.Any(), tracing.BalanceDecreaseGasBuy), db.EXPECT().RevertToSnapshot(15), - db.EXPECT().GetLogs(common.HexToHash(fmt.Sprintf("0x%016d%016d", 2, 1)), common.HexToHash(fmt.Sprintf("0x%016d", 2))), + db.EXPECT().GetLogs(common.HexToHash(fmt.Sprintf("0x%016d%016d", 2, 1)), uint64(2), common.HexToHash(fmt.Sprintf("0x%016d", 2))), db.EXPECT().EndTransaction(), // Tx 2 db.EXPECT().PrepareSubstate(gomock.Any(), uint64(2)), db.EXPECT().BeginTransaction(uint32(2)), - db.EXPECT().Prepare(gomock.Any(), 2), + db.EXPECT().SetTxContext(gomock.Any(), 2), db.EXPECT().Snapshot().Return(17), - db.EXPECT().GetBalance(gomock.Any()).Return(big.NewInt(1000)), - db.EXPECT().SubBalance(gomock.Any(), gomock.Any()), + db.EXPECT().GetBalance(gomock.Any()).Return(uint256.NewInt(1000)), + db.EXPECT().SubBalance(gomock.Any(), gomock.Any(), tracing.BalanceDecreaseGasBuy), db.EXPECT().RevertToSnapshot(17), - db.EXPECT().GetLogs(common.HexToHash(fmt.Sprintf("0x%016d%016d", 2, 2)), common.HexToHash(fmt.Sprintf("0x%016d", 2))), + db.EXPECT().GetLogs(common.HexToHash(fmt.Sprintf("0x%016d%016d", 2, 2)), uint64(2), common.HexToHash(fmt.Sprintf("0x%016d", 2))), db.EXPECT().EndTransaction(), db.EXPECT().EndBlock(), // Block 3 db.EXPECT().BeginBlock(uint64(3)), db.EXPECT().PrepareSubstate(gomock.Any(), uint64(3)), db.EXPECT().BeginTransaction(uint32(1)), - db.EXPECT().Prepare(gomock.Any(), 1), + db.EXPECT().SetTxContext(gomock.Any(), 1), db.EXPECT().Snapshot().Return(19), - db.EXPECT().GetBalance(gomock.Any()).Return(big.NewInt(1000)), - db.EXPECT().SubBalance(gomock.Any(), gomock.Any()), + db.EXPECT().GetBalance(gomock.Any()).Return(uint256.NewInt(1000)), + db.EXPECT().SubBalance(gomock.Any(), gomock.Any(), tracing.BalanceDecreaseGasBuy), db.EXPECT().RevertToSnapshot(19), - db.EXPECT().GetLogs(common.HexToHash(fmt.Sprintf("0x%016d%016d", 3, 1)), common.HexToHash(fmt.Sprintf("0x%016d", 3))), + db.EXPECT().GetLogs(common.HexToHash(fmt.Sprintf("0x%016d%016d", 3, 1)), uint64(3), common.HexToHash(fmt.Sprintf("0x%016d", 3))), db.EXPECT().EndTransaction(), db.EXPECT().EndBlock(), // Pseudo transaction do not use snapshots. @@ -233,15 +235,15 @@ func TestVmSdb_Substate_ValidationDoesNotFailOnValidTransaction(t *testing.T) { // we return correct expected data so tx does not fail db.EXPECT().Exist(testingAddress).Return(true), - db.EXPECT().GetBalance(testingAddress).Return(new(big.Int).SetUint64(1)), + db.EXPECT().GetBalance(testingAddress).Return(new(uint256.Int).SetUint64(1)), db.EXPECT().GetNonce(testingAddress).Return(uint64(1)), db.EXPECT().GetCode(testingAddress).Return([]byte{}), - db.EXPECT().Prepare(gomock.Any(), 1), + db.EXPECT().SetTxContext(gomock.Any(), 1), db.EXPECT().Snapshot().Return(15), - db.EXPECT().GetBalance(gomock.Any()).Return(big.NewInt(1000)), - db.EXPECT().SubBalance(gomock.Any(), gomock.Any()), + db.EXPECT().GetBalance(gomock.Any()).Return(uint256.NewInt(1000)), + db.EXPECT().SubBalance(gomock.Any(), gomock.Any(), tracing.BalanceDecreaseGasBuy), db.EXPECT().RevertToSnapshot(15), - db.EXPECT().GetLogs(common.HexToHash(fmt.Sprintf("0x%016d%016d", 2, 1)), common.HexToHash(fmt.Sprintf("0x%016d", 2))), + db.EXPECT().GetLogs(common.HexToHash(fmt.Sprintf("0x%016d%016d", 2, 1)), uint64(2), common.HexToHash(fmt.Sprintf("0x%016d", 2))), // EndTransaction does not get called because execution fails ) @@ -282,7 +284,7 @@ func TestVmSdb_Substate_ValidationFailsOnInvalidTransaction(t *testing.T) { db.EXPECT().PrepareSubstate(gomock.Any(), uint64(2)), db.EXPECT().BeginTransaction(uint32(1)), db.EXPECT().Exist(testingAddress).Return(false), // address does not exist - db.EXPECT().GetBalance(testingAddress).Return(new(big.Int).SetUint64(1)), + db.EXPECT().GetBalance(testingAddress).Return(new(uint256.Int).SetUint64(1)), db.EXPECT().GetNonce(testingAddress).Return(uint64(1)), db.EXPECT().GetCode(testingAddress).Return([]byte{}), // EndTransaction does not get called because validation fails @@ -307,6 +309,7 @@ var emptyTx = &substate.Substate{ Env: &substate.Env{}, Message: &substate.Message{ GasPrice: big.NewInt(12), + Value: big.NewInt(1), }, Result: &substate.Result{ GasUsed: 1, @@ -319,6 +322,7 @@ var testTx = &substate.Substate{ Env: &substate.Env{}, Message: &substate.Message{ GasPrice: big.NewInt(12), + Value: big.NewInt(1), }, Result: &substate.Result{ GasUsed: 1, diff --git a/cmd/aida-vm-sdb/run_tx_generator_test.go b/cmd/aida-vm-sdb/run_tx_generator_test.go index 97f85d677..d10e2fb17 100644 --- a/cmd/aida-vm-sdb/run_tx_generator_test.go +++ b/cmd/aida-vm-sdb/run_tx_generator_test.go @@ -27,6 +27,7 @@ import ( "github.com/Fantom-foundation/Aida/txcontext/txgenerator" "github.com/Fantom-foundation/Aida/utils" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/types" "go.uber.org/mock/gomock" ) @@ -115,19 +116,19 @@ func TestVmSdb_TxGenerator_AllTransactionsAreProcessedInOrder(t *testing.T) { func newTestTxCtx(blkNumber uint64) txcontext.TxContext { return txgenerator.NewTxContext( testTxBlkEnv{blkNumber}, - types.NewMessage( - common.Address{0x1}, - &common.Address{0x2}, - 0, - big.NewInt(1), - 21_000, - big.NewInt(1), - big.NewInt(1), - big.NewInt(1), - []byte{}, - types.AccessList{}, - false, - ), + &core.Message{ + To: &common.Address{0x2}, + From: common.Address{0x1}, + Nonce: 0, + Value: big.NewInt(1), + GasLimit: 21_000, + GasPrice: big.NewInt(1), + GasFeeCap: big.NewInt(1), + GasTipCap: big.NewInt(1), + Data: []byte{}, + AccessList: types.AccessList{}, + SkipAccountChecks: false, + }, ) } From cb2114642ef0d3db7991282d63bc3b08313d1c1b Mon Sep 17 00:00:00 2001 From: wsodsong Date: Mon, 17 Jun 2024 04:41:55 +0000 Subject: [PATCH 16/26] fix aida-vm-adb and aida-rpc tests --- cmd/aida-rpc/rpc_test.go | 16 +++--- cmd/aida-vm-adb/run_vm_adb_test.go | 75 +++++++++++++++------------- cmd/aida-vm-sdb/run_substate_test.go | 4 +- cmd/aida-vm/run_vm_test.go | 2 +- tracer/operation/addbalance_test.go | 6 +-- tracer/operation/operation_test.go | 30 +++++------ 6 files changed, 69 insertions(+), 64 deletions(-) diff --git a/cmd/aida-rpc/rpc_test.go b/cmd/aida-rpc/rpc_test.go index 9dd67858b..8cbc033d2 100644 --- a/cmd/aida-rpc/rpc_test.go +++ b/cmd/aida-rpc/rpc_test.go @@ -18,7 +18,6 @@ package main import ( "encoding/json" - "math/big" "strings" "testing" @@ -28,6 +27,7 @@ import ( "github.com/Fantom-foundation/Aida/utils" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/holiman/uint256" "go.uber.org/mock/gomock" ) @@ -70,13 +70,13 @@ func TestRpc_AllDbEventsAreIssuedInOrder_Sequential(t *testing.T) { // Req 1 db.EXPECT().GetArchiveState(uint64(2)).Return(archiveOne, nil), archiveOne.EXPECT().BeginTransaction(uint32(1)), - archiveOne.EXPECT().GetBalance(common.HexToAddress(testingAddress)).Return(new(big.Int).SetInt64(1)), + archiveOne.EXPECT().GetBalance(common.HexToAddress(testingAddress)).Return(new(uint256.Int).SetUint64(1)), archiveOne.EXPECT().EndTransaction(), archiveOne.EXPECT().Release(), // Req 2 db.EXPECT().GetArchiveState(uint64(2)).Return(archiveTwo, nil), archiveTwo.EXPECT().BeginTransaction(uint32(2)), - archiveTwo.EXPECT().GetBalance(common.HexToAddress(testingAddress)).Return(new(big.Int).SetInt64(1)), + archiveTwo.EXPECT().GetBalance(common.HexToAddress(testingAddress)).Return(new(uint256.Int).SetUint64(1)), archiveTwo.EXPECT().EndTransaction(), archiveTwo.EXPECT().Release(), // Req 3 @@ -133,7 +133,7 @@ func TestRpc_AllDbEventsAreIssuedInOrder_Parallel(t *testing.T) { // Req 1 db.EXPECT().GetArchiveState(uint64(2)).Return(archiveOne, nil), archiveOne.EXPECT().BeginTransaction(uint32(1)), - archiveOne.EXPECT().GetBalance(common.HexToAddress(testingAddress)).Return(new(big.Int).SetInt64(1)), + archiveOne.EXPECT().GetBalance(common.HexToAddress(testingAddress)).Return(new(uint256.Int).SetUint64(1)), archiveOne.EXPECT().EndTransaction(), archiveOne.EXPECT().Release(), ) @@ -354,7 +354,7 @@ func TestRpc_ValidationDoesNotFailOnValidTransaction_Sequential(t *testing.T) { gomock.InOrder( db.EXPECT().GetArchiveState(uint64(2)).Return(archive, nil), archive.EXPECT().BeginTransaction(uint32(1)), - archive.EXPECT().GetBalance(common.HexToAddress(testingAddress)).Return(new(big.Int).SetInt64(1)), + archive.EXPECT().GetBalance(common.HexToAddress(testingAddress)).Return(new(uint256.Int).SetUint64(1)), archive.EXPECT().EndTransaction(), archive.EXPECT().Release(), ) @@ -396,7 +396,7 @@ func TestRpc_ValidationDoesNotFailOnValidTransaction_Parallel(t *testing.T) { gomock.InOrder( db.EXPECT().GetArchiveState(uint64(2)).Return(archive, nil), archive.EXPECT().BeginTransaction(uint32(1)), - archive.EXPECT().GetBalance(common.HexToAddress(testingAddress)).Return(new(big.Int).SetInt64(1)), + archive.EXPECT().GetBalance(common.HexToAddress(testingAddress)).Return(new(uint256.Int).SetUint64(1)), archive.EXPECT().EndTransaction(), archive.EXPECT().Release(), ) @@ -438,7 +438,7 @@ func TestRpc_ValidationFailsOnValidTransaction_Sequential(t *testing.T) { gomock.InOrder( db.EXPECT().GetArchiveState(uint64(2)).Return(archive, nil), archive.EXPECT().BeginTransaction(uint32(1)), - archive.EXPECT().GetBalance(common.HexToAddress(testingAddress)).Return(new(big.Int).SetInt64(2)), + archive.EXPECT().GetBalance(common.HexToAddress(testingAddress)).Return(new(uint256.Int).SetUint64(2)), archive.EXPECT().EndTransaction(), archive.EXPECT().Release(), ) @@ -484,7 +484,7 @@ func TestRpc_ValidationFailsOnValidTransaction_Parallel(t *testing.T) { gomock.InOrder( db.EXPECT().GetArchiveState(uint64(2)).Return(archive, nil), archive.EXPECT().BeginTransaction(uint32(1)), - archive.EXPECT().GetBalance(common.HexToAddress(testingAddress)).Return(new(big.Int).SetInt64(2)), + archive.EXPECT().GetBalance(common.HexToAddress(testingAddress)).Return(new(uint256.Int).SetUint64(2)), archive.EXPECT().EndTransaction(), archive.EXPECT().Release(), ) diff --git a/cmd/aida-vm-adb/run_vm_adb_test.go b/cmd/aida-vm-adb/run_vm_adb_test.go index bb9d25105..2bf805b49 100644 --- a/cmd/aida-vm-adb/run_vm_adb_test.go +++ b/cmd/aida-vm-adb/run_vm_adb_test.go @@ -30,6 +30,7 @@ import ( "github.com/Fantom-foundation/Substate/substate" substatetypes "github.com/Fantom-foundation/Substate/types" "github.com/ethereum/go-ethereum/common" + "github.com/holiman/uint256" "go.uber.org/mock/gomock" ) @@ -75,32 +76,32 @@ func TestVmAdb_AllDbEventsAreIssuedInOrder_Sequential(t *testing.T) { // Tx 1 db.EXPECT().GetArchiveState(uint64(1)).Return(archiveBlockOne, nil), archiveBlockOne.EXPECT().BeginTransaction(uint32(1)), - archiveBlockOne.EXPECT().Prepare(gomock.Any(), 1), + archiveBlockOne.EXPECT().SetTxContext(gomock.Any(), 1), archiveBlockOne.EXPECT().Snapshot().Return(15), - archiveBlockOne.EXPECT().GetBalance(gomock.Any()).Return(big.NewInt(1000)), - archiveBlockOne.EXPECT().SubBalance(gomock.Any(), gomock.Any()), + archiveBlockOne.EXPECT().GetBalance(gomock.Any()).Return(uint256.NewInt(1000)), + archiveBlockOne.EXPECT().SubBalance(gomock.Any(), gomock.Any(), gomock.Any()), archiveBlockOne.EXPECT().RevertToSnapshot(15), - archiveBlockOne.EXPECT().GetLogs(common.HexToHash(fmt.Sprintf("0x%016d%016d", 2, 1)), common.HexToHash(fmt.Sprintf("0x%016d", 2))), + archiveBlockOne.EXPECT().GetLogs(common.HexToHash(fmt.Sprintf("0x%016d%016d", 2, 1)), uint64(2), common.HexToHash(fmt.Sprintf("0x%016d", 2))), archiveBlockOne.EXPECT().EndTransaction(), // Tx 2 archiveBlockOne.EXPECT().BeginTransaction(uint32(2)), - archiveBlockOne.EXPECT().Prepare(gomock.Any(), 2), + archiveBlockOne.EXPECT().SetTxContext(gomock.Any(), 2), archiveBlockOne.EXPECT().Snapshot().Return(16), - archiveBlockOne.EXPECT().GetBalance(gomock.Any()).Return(big.NewInt(1000)), - archiveBlockOne.EXPECT().SubBalance(gomock.Any(), gomock.Any()), + archiveBlockOne.EXPECT().GetBalance(gomock.Any()).Return(uint256.NewInt(1000)), + archiveBlockOne.EXPECT().SubBalance(gomock.Any(), gomock.Any(), gomock.Any()), archiveBlockOne.EXPECT().RevertToSnapshot(16), - archiveBlockOne.EXPECT().GetLogs(common.HexToHash(fmt.Sprintf("0x%016d%016d", 2, 2)), common.HexToHash(fmt.Sprintf("0x%016d", 2))), + archiveBlockOne.EXPECT().GetLogs(common.HexToHash(fmt.Sprintf("0x%016d%016d", 2, 2)), uint64(2), common.HexToHash(fmt.Sprintf("0x%016d", 2))), archiveBlockOne.EXPECT().EndTransaction(), archiveBlockOne.EXPECT().Release(), // Block 3 db.EXPECT().GetArchiveState(uint64(2)).Return(archiveBlockTwo, nil), archiveBlockTwo.EXPECT().BeginTransaction(uint32(1)), - archiveBlockTwo.EXPECT().Prepare(gomock.Any(), 1), + archiveBlockTwo.EXPECT().SetTxContext(gomock.Any(), 1), archiveBlockTwo.EXPECT().Snapshot().Return(17), - archiveBlockTwo.EXPECT().GetBalance(gomock.Any()).Return(big.NewInt(1000)), - archiveBlockTwo.EXPECT().SubBalance(gomock.Any(), gomock.Any()), + archiveBlockTwo.EXPECT().GetBalance(gomock.Any()).Return(uint256.NewInt(1000)), + archiveBlockTwo.EXPECT().SubBalance(gomock.Any(), gomock.Any(), gomock.Any()), archiveBlockTwo.EXPECT().RevertToSnapshot(17), - archiveBlockTwo.EXPECT().GetLogs(common.HexToHash(fmt.Sprintf("0x%016d%016d", 3, 1)), common.HexToHash(fmt.Sprintf("0x%016d", 3))), + archiveBlockTwo.EXPECT().GetLogs(common.HexToHash(fmt.Sprintf("0x%016d%016d", 3, 1)), uint64(3), common.HexToHash(fmt.Sprintf("0x%016d", 3))), archiveBlockTwo.EXPECT().EndTransaction(), archiveBlockTwo.EXPECT().Release(), // Block 4 @@ -164,21 +165,21 @@ func TestVmAdb_AllDbEventsAreIssuedInOrder_Parallel(t *testing.T) { db.EXPECT().GetArchiveState(uint64(1)).Return(archiveBlockOne, nil), // Tx 1 archiveBlockOne.EXPECT().BeginTransaction(uint32(1)), - archiveBlockOne.EXPECT().Prepare(gomock.Any(), 1), + archiveBlockOne.EXPECT().SetTxContext(gomock.Any(), 1), archiveBlockOne.EXPECT().Snapshot().Return(15), - archiveBlockOne.EXPECT().GetBalance(gomock.Any()).Return(big.NewInt(1000)), - archiveBlockOne.EXPECT().SubBalance(gomock.Any(), gomock.Any()), + archiveBlockOne.EXPECT().GetBalance(gomock.Any()).Return(uint256.NewInt(1000)), + archiveBlockOne.EXPECT().SubBalance(gomock.Any(), gomock.Any(), gomock.Any()), archiveBlockOne.EXPECT().RevertToSnapshot(15), - archiveBlockOne.EXPECT().GetLogs(common.HexToHash(fmt.Sprintf("0x%016d%016d", 2, 1)), common.HexToHash(fmt.Sprintf("0x%016d", 2))), + archiveBlockOne.EXPECT().GetLogs(common.HexToHash(fmt.Sprintf("0x%016d%016d", 2, 1)), uint64(2), common.HexToHash(fmt.Sprintf("0x%016d", 2))), archiveBlockOne.EXPECT().EndTransaction(), // Tx 2 archiveBlockOne.EXPECT().BeginTransaction(uint32(2)), - archiveBlockOne.EXPECT().Prepare(gomock.Any(), 2), + archiveBlockOne.EXPECT().SetTxContext(gomock.Any(), 2), archiveBlockOne.EXPECT().Snapshot().Return(19), - archiveBlockOne.EXPECT().GetBalance(gomock.Any()).Return(big.NewInt(1000)), - archiveBlockOne.EXPECT().SubBalance(gomock.Any(), gomock.Any()), + archiveBlockOne.EXPECT().GetBalance(gomock.Any()).Return(uint256.NewInt(1000)), + archiveBlockOne.EXPECT().SubBalance(gomock.Any(), gomock.Any(), gomock.Any()), archiveBlockOne.EXPECT().RevertToSnapshot(19), - archiveBlockOne.EXPECT().GetLogs(common.HexToHash(fmt.Sprintf("0x%016d%016d", 2, 2)), common.HexToHash(fmt.Sprintf("0x%016d", 2))), + archiveBlockOne.EXPECT().GetLogs(common.HexToHash(fmt.Sprintf("0x%016d%016d", 2, 2)), uint64(2), common.HexToHash(fmt.Sprintf("0x%016d", 2))), archiveBlockOne.EXPECT().EndTransaction(), archiveBlockOne.EXPECT().Release(), @@ -187,12 +188,12 @@ func TestVmAdb_AllDbEventsAreIssuedInOrder_Parallel(t *testing.T) { gomock.InOrder( db.EXPECT().GetArchiveState(uint64(2)).Return(archiveBlockTwo, nil), archiveBlockTwo.EXPECT().BeginTransaction(uint32(1)), - archiveBlockTwo.EXPECT().Prepare(gomock.Any(), 1), + archiveBlockTwo.EXPECT().SetTxContext(gomock.Any(), 1), archiveBlockTwo.EXPECT().Snapshot().Return(17), - archiveBlockTwo.EXPECT().GetBalance(gomock.Any()).Return(big.NewInt(1000)), - archiveBlockTwo.EXPECT().SubBalance(gomock.Any(), gomock.Any()), + archiveBlockTwo.EXPECT().GetBalance(gomock.Any()).Return(uint256.NewInt(1000)), + archiveBlockTwo.EXPECT().SubBalance(gomock.Any(), gomock.Any(), gomock.Any()), archiveBlockTwo.EXPECT().RevertToSnapshot(17), - archiveBlockTwo.EXPECT().GetLogs(common.HexToHash(fmt.Sprintf("0x%016d%016d", 3, 1)), common.HexToHash(fmt.Sprintf("0x%016d", 3))), + archiveBlockTwo.EXPECT().GetLogs(common.HexToHash(fmt.Sprintf("0x%016d%016d", 3, 1)), uint64(3), common.HexToHash(fmt.Sprintf("0x%016d", 3))), archiveBlockTwo.EXPECT().EndTransaction(), archiveBlockTwo.EXPECT().Release(), ) @@ -420,16 +421,16 @@ func TestVmAdb_ValidationDoesNotFailOnValidTransaction_Sequential(t *testing.T) // we return correct expected data so tx does not fail archive.EXPECT().BeginTransaction(uint32(1)), archive.EXPECT().Exist(testingAddress).Return(true), - archive.EXPECT().GetBalance(testingAddress).Return(new(big.Int).SetUint64(1)), + archive.EXPECT().GetBalance(testingAddress).Return(new(uint256.Int).SetUint64(1)), archive.EXPECT().GetNonce(testingAddress).Return(uint64(1)), archive.EXPECT().GetCode(testingAddress).Return([]byte{}), - archive.EXPECT().Prepare(gomock.Any(), 1), + archive.EXPECT().SetTxContext(gomock.Any(), 1), archive.EXPECT().Snapshot().Return(15), - archive.EXPECT().GetBalance(gomock.Any()).Return(big.NewInt(1000)), - archive.EXPECT().SubBalance(gomock.Any(), gomock.Any()), + archive.EXPECT().GetBalance(gomock.Any()).Return(uint256.NewInt(1000)), + archive.EXPECT().SubBalance(gomock.Any(), gomock.Any(), gomock.Any()), archive.EXPECT().RevertToSnapshot(15), - archive.EXPECT().GetLogs(common.HexToHash(fmt.Sprintf("0x%016d%016d", 2, 1)), common.HexToHash(fmt.Sprintf("0x%016d", 2))), + archive.EXPECT().GetLogs(common.HexToHash(fmt.Sprintf("0x%016d%016d", 2, 1)), uint64(2), common.HexToHash(fmt.Sprintf("0x%016d", 2))), // end transaction is not called because we expect fail ) @@ -472,16 +473,16 @@ func TestVmAdb_ValidationDoesNotFailOnValidTransaction_Parallel(t *testing.T) { // we return correct expected data so tx does not fail archive.EXPECT().BeginTransaction(uint32(1)), archive.EXPECT().Exist(testingAddress).Return(true), - archive.EXPECT().GetBalance(testingAddress).Return(new(big.Int).SetUint64(1)), + archive.EXPECT().GetBalance(testingAddress).Return(new(uint256.Int).SetUint64(1)), archive.EXPECT().GetNonce(testingAddress).Return(uint64(1)), archive.EXPECT().GetCode(testingAddress).Return([]byte{}), - archive.EXPECT().Prepare(gomock.Any(), 1), + archive.EXPECT().SetTxContext(gomock.Any(), 1), archive.EXPECT().Snapshot().Return(15), - archive.EXPECT().GetBalance(gomock.Any()).Return(big.NewInt(1000)), - archive.EXPECT().SubBalance(gomock.Any(), gomock.Any()), + archive.EXPECT().GetBalance(gomock.Any()).Return(uint256.NewInt(1000)), + archive.EXPECT().SubBalance(gomock.Any(), gomock.Any(), gomock.Any()), archive.EXPECT().RevertToSnapshot(15), - archive.EXPECT().GetLogs(common.HexToHash(fmt.Sprintf("0x%016d%016d", 2, 1)), common.HexToHash(fmt.Sprintf("0x%016d", 2))), + archive.EXPECT().GetLogs(common.HexToHash(fmt.Sprintf("0x%016d%016d", 2, 1)), uint64(2), common.HexToHash(fmt.Sprintf("0x%016d", 2))), ) // run fails but not on validation @@ -521,7 +522,7 @@ func TestVmAdb_ValidationFailsOnInvalidTransaction_Sequential(t *testing.T) { db.EXPECT().GetArchiveState(uint64(1)).Return(archive, nil), archive.EXPECT().BeginTransaction(uint32(1)), archive.EXPECT().Exist(testingAddress).Return(false), // address does not exist - archive.EXPECT().GetBalance(testingAddress).Return(new(big.Int).SetUint64(1)), + archive.EXPECT().GetBalance(testingAddress).Return(new(uint256.Int).SetUint64(1)), archive.EXPECT().GetNonce(testingAddress).Return(uint64(1)), archive.EXPECT().GetCode(testingAddress).Return([]byte{}), ) @@ -564,7 +565,7 @@ func TestVmAdb_ValidationFailsOnInvalidTransaction_Parallel(t *testing.T) { db.EXPECT().GetArchiveState(uint64(1)).Return(archive, nil), archive.EXPECT().BeginTransaction(uint32(1)), archive.EXPECT().Exist(testingAddress).Return(false), // address does not exist - archive.EXPECT().GetBalance(testingAddress).Return(new(big.Int).SetUint64(1)), + archive.EXPECT().GetBalance(testingAddress).Return(new(uint256.Int).SetUint64(1)), archive.EXPECT().GetNonce(testingAddress).Return(uint64(1)), archive.EXPECT().GetCode(testingAddress).Return([]byte{}), ) @@ -588,6 +589,7 @@ var emptyTx = &substate.Substate{ Env: &substate.Env{}, Message: &substate.Message{ GasPrice: big.NewInt(12), + Value: big.NewInt(1), }, Result: &substate.Result{ GasUsed: 1, @@ -600,6 +602,7 @@ var testTx = &substate.Substate{ Env: &substate.Env{}, Message: &substate.Message{ GasPrice: big.NewInt(12), + Value: big.NewInt(1), }, Result: &substate.Result{ GasUsed: 1, diff --git a/cmd/aida-vm-sdb/run_substate_test.go b/cmd/aida-vm-sdb/run_substate_test.go index 5da7b3ec9..cc7abb5d2 100644 --- a/cmd/aida-vm-sdb/run_substate_test.go +++ b/cmd/aida-vm-sdb/run_substate_test.go @@ -309,7 +309,7 @@ var emptyTx = &substate.Substate{ Env: &substate.Env{}, Message: &substate.Message{ GasPrice: big.NewInt(12), - Value: big.NewInt(1), + Value: big.NewInt(1), }, Result: &substate.Result{ GasUsed: 1, @@ -322,7 +322,7 @@ var testTx = &substate.Substate{ Env: &substate.Env{}, Message: &substate.Message{ GasPrice: big.NewInt(12), - Value: big.NewInt(1), + Value: big.NewInt(1), }, Result: &substate.Result{ GasUsed: 1, diff --git a/cmd/aida-vm/run_vm_test.go b/cmd/aida-vm/run_vm_test.go index 3501334be..f99f6af20 100644 --- a/cmd/aida-vm/run_vm_test.go +++ b/cmd/aida-vm/run_vm_test.go @@ -29,8 +29,8 @@ import ( "github.com/Fantom-foundation/Aida/utils" "github.com/Fantom-foundation/Substate/substate" substatetypes "github.com/Fantom-foundation/Substate/types" - "github.com/ethereum/go-ethereum/core/tracing" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/tracing" "github.com/holiman/uint256" "go.uber.org/mock/gomock" ) diff --git a/tracer/operation/addbalance_test.go b/tracer/operation/addbalance_test.go index 8fecadf02..5c82a3ef7 100644 --- a/tracer/operation/addbalance_test.go +++ b/tracer/operation/addbalance_test.go @@ -18,19 +18,19 @@ package operation import ( "fmt" - "math/big" "math/rand" "testing" "time" "github.com/Fantom-foundation/Aida/tracer/context" "github.com/ethereum/go-ethereum/common" + "github.com/holiman/uint256" ) -func initAddBalance(t *testing.T) (*context.Replay, *AddBalance, common.Address, *big.Int) { +func initAddBalance(t *testing.T) (*context.Replay, *AddBalance, common.Address, *uint256.Int) { rand.Seed(time.Now().UnixNano()) addr := getRandomAddress(t) - value := big.NewInt(rand.Int63n(100000)) + value := uint256.NewInt(uint64(rand.Int63n(100000))) // create context context ctx := context.NewReplay() contract := ctx.EncodeContract(addr) diff --git a/tracer/operation/operation_test.go b/tracer/operation/operation_test.go index 6a0724c74..82071393c 100644 --- a/tracer/operation/operation_test.go +++ b/tracer/operation/operation_test.go @@ -19,7 +19,6 @@ package operation import ( "bytes" "io" - "math/big" "os" "reflect" "testing" @@ -28,8 +27,11 @@ import ( "github.com/Fantom-foundation/Aida/tracer/context" "github.com/Fantom-foundation/Aida/txcontext" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/tracing" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/params" + "github.com/holiman/uint256" ) // MockStateDB data structure @@ -77,17 +79,17 @@ func (s *MockStateDB) HasSuicided(addr common.Address) bool { return false } -func (s *MockStateDB) GetBalance(addr common.Address) *big.Int { +func (s *MockStateDB) GetBalance(addr common.Address) *uint256.Int { s.recording = append(s.recording, Record{GetBalanceID, []any{addr}}) - return &big.Int{} + return &uint256.Int{} } -func (s *MockStateDB) AddBalance(addr common.Address, value *big.Int) { - s.recording = append(s.recording, Record{AddBalanceID, []any{addr, value}}) +func (s *MockStateDB) AddBalance(addr common.Address, value *uint256.Int, reason tracing.BalanceChangeReason) { + s.recording = append(s.recording, Record{AddBalanceID, []any{addr, value, reason}}) } -func (s *MockStateDB) SubBalance(addr common.Address, value *big.Int) { - s.recording = append(s.recording, Record{SubBalanceID, []any{addr, value}}) +func (s *MockStateDB) SubBalance(addr common.Address, value *uint256.Int, reason tracing.BalanceChangeReason) { + s.recording = append(s.recording, Record{SubBalanceID, []any{addr, value, reason}}) } func (s *MockStateDB) GetNonce(addr common.Address) uint64 { @@ -198,8 +200,8 @@ func (s *MockStateDB) IntermediateRoot(deleteEmptyObjects bool) common.Hash { return common.Hash{} } -func (s *MockStateDB) Commit(deleteEmptyObjects bool) (common.Hash, error) { - s.recording = append(s.recording, Record{CommitID, []any{deleteEmptyObjects}}) +func (s *MockStateDB) Commit(block uint64, deleteEmptyObjects bool) (common.Hash, error) { + s.recording = append(s.recording, Record{CommitID, []any{block, deleteEmptyObjects}}) return common.Hash{}, nil } @@ -207,7 +209,7 @@ func (s *MockStateDB) GetHash() (common.Hash, error) { panic("GetHash not supported in mock") } -func (s *MockStateDB) Prepare(thash common.Hash, ti int) { +func (s *MockStateDB) GetTxState(thash common.Hash, ti int) { s.recording = append(s.recording, Record{PrepareID, []any{thash, ti}}) } @@ -224,8 +226,8 @@ func (s *MockStateDB) GetRefund() uint64 { return uint64(0) } -func (s *MockStateDB) PrepareAccessList(sender common.Address, dest *common.Address, precompiles []common.Address, txAccesses types.AccessList) { - s.recording = append(s.recording, Record{PrepareAccessListID, []any{sender, dest, precompiles, txAccesses}}) +func (s *MockStateDB) Prepare(rules params.Rules, sender, coinbase common.Address, dest *common.Address, precompiles []common.Address, txAccesses types.AccessList) { + s.recording = append(s.recording, Record{PrepareAccessListID, []any{rules, sender, coinbase, dest, precompiles, txAccesses}}) } func (s *MockStateDB) AddressInAccessList(addr common.Address) bool { @@ -315,8 +317,8 @@ func areEqual(v1 any, v2 any) bool { case []byte: c2 := v2.([]byte) return bytes.Compare(c1, c2) == 0 - case *big.Int: - c2 := v2.(*big.Int) + case *uint256.Int: + c2 := v2.(*uint256.Int) return c2.Cmp(c1) == 0 default: return v1 == v2 From 4883fa19329c1099343e2cbe227c37a42680a60c Mon Sep 17 00:00:00 2001 From: wsodsong Date: Mon, 17 Jun 2024 06:13:55 +0000 Subject: [PATCH 17/26] fix tracer tests --- tracer/operation/addbalance.go | 2 +- tracer/operation/addbalance_test.go | 3 +- .../operation/getcommittedstate_lcls_test.go | 2 +- tracer/operation/getcommittedstate_test.go | 2 +- tracer/operation/getstate_lc_test.go | 2 +- tracer/operation/getstate_lccs_test.go | 4 +- tracer/operation/getstate_lcls_test.go | 2 +- tracer/operation/getstate_test.go | 2 +- tracer/operation/operation_test.go | 41 ++++++++++++++++--- tracer/operation/setstate_lcls_test.go | 4 +- tracer/operation/setstate_test.go | 4 +- tracer/operation/subbalance.go | 2 +- tracer/operation/subbalance_test.go | 9 ++-- 13 files changed, 55 insertions(+), 24 deletions(-) diff --git a/tracer/operation/addbalance.go b/tracer/operation/addbalance.go index 8659adb26..d9ccea2ae 100644 --- a/tracer/operation/addbalance.go +++ b/tracer/operation/addbalance.go @@ -23,9 +23,9 @@ import ( "log" "time" - "github.com/ethereum/go-ethereum/common" "github.com/Fantom-foundation/Aida/state" "github.com/Fantom-foundation/Aida/tracer/context" + "github.com/ethereum/go-ethereum/common" "github.com/holiman/uint256" ) diff --git a/tracer/operation/addbalance_test.go b/tracer/operation/addbalance_test.go index 5c82a3ef7..2f04c6e59 100644 --- a/tracer/operation/addbalance_test.go +++ b/tracer/operation/addbalance_test.go @@ -24,6 +24,7 @@ import ( "github.com/Fantom-foundation/Aida/tracer/context" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/tracing" "github.com/holiman/uint256" ) @@ -69,6 +70,6 @@ func TestAddBalanceExecute(t *testing.T) { op.Execute(mock, ctx) // check whether methods were correctly called - expected := []Record{{AddBalanceID, []any{addr, value}}} + expected := []Record{{AddBalanceID, []any{addr, value, tracing.BalanceChangeUnspecified}}} mock.compareRecordings(expected, t) } diff --git a/tracer/operation/getcommittedstate_lcls_test.go b/tracer/operation/getcommittedstate_lcls_test.go index 13c878b3d..a210e981a 100644 --- a/tracer/operation/getcommittedstate_lcls_test.go +++ b/tracer/operation/getcommittedstate_lcls_test.go @@ -41,7 +41,7 @@ func initGetCommittedStateLcls(t *testing.T) (*context.Replay, *GetCommittedStat addr := getRandomAddress(t) ctx.EncodeContract(addr) - storage := getRandomAddress(t).Hash() + storage := getRandomHash(t) ctx.EncodeKey(storage) return ctx, op, addr, storage diff --git a/tracer/operation/getcommittedstate_test.go b/tracer/operation/getcommittedstate_test.go index 7e65ddf59..9693a8172 100644 --- a/tracer/operation/getcommittedstate_test.go +++ b/tracer/operation/getcommittedstate_test.go @@ -26,7 +26,7 @@ import ( func initGetCommittedState(t *testing.T) (*context.Replay, *GetCommittedState, common.Address, common.Hash) { addr := getRandomAddress(t) - storage := getRandomAddress(t).Hash() + storage := getRandomHash(t) // create context context ctx := context.NewReplay() diff --git a/tracer/operation/getstate_lc_test.go b/tracer/operation/getstate_lc_test.go index 7ac4ef7e9..6336edf7d 100644 --- a/tracer/operation/getstate_lc_test.go +++ b/tracer/operation/getstate_lc_test.go @@ -25,7 +25,7 @@ import ( ) func initGetStateLc(t *testing.T) (*context.Replay, *GetStateLc, common.Address, common.Hash) { - storage := getRandomAddress(t).Hash() + storage := getRandomHash(t) // create context context ctx := context.NewReplay() diff --git a/tracer/operation/getstate_lccs_test.go b/tracer/operation/getstate_lccs_test.go index edb3fa1e4..9184294c5 100644 --- a/tracer/operation/getstate_lccs_test.go +++ b/tracer/operation/getstate_lccs_test.go @@ -46,10 +46,10 @@ func initGetStateLccs(t *testing.T) (*context.Replay, *GetStateLccs, common.Addr addr := getRandomAddress(t) ctx.EncodeContract(addr) - storage := getRandomAddress(t).Hash() + storage := getRandomHash(t) ctx.EncodeKey(storage) - storage2 := getRandomAddress(t).Hash() + storage2 := getRandomHash(t) return ctx, op, addr, storage, storage2 } diff --git a/tracer/operation/getstate_lcls_test.go b/tracer/operation/getstate_lcls_test.go index f7ae3c261..16fe58629 100644 --- a/tracer/operation/getstate_lcls_test.go +++ b/tracer/operation/getstate_lcls_test.go @@ -41,7 +41,7 @@ func initGetStateLcls(t *testing.T) (*context.Replay, *GetStateLcls, common.Addr addr := getRandomAddress(t) ctx.EncodeContract(addr) - storage := getRandomAddress(t).Hash() + storage := getRandomHash(t) ctx.EncodeKey(storage) return ctx, op, addr, storage diff --git a/tracer/operation/getstate_test.go b/tracer/operation/getstate_test.go index 29af16900..349026630 100644 --- a/tracer/operation/getstate_test.go +++ b/tracer/operation/getstate_test.go @@ -26,7 +26,7 @@ import ( func initGetState(t *testing.T) (*context.Replay, *GetState, common.Address, common.Hash) { addr := getRandomAddress(t) - storage := getRandomAddress(t).Hash() + storage := getRandomHash(t) // create context context ctx := context.NewReplay() diff --git a/tracer/operation/operation_test.go b/tracer/operation/operation_test.go index 82071393c..f487e9afb 100644 --- a/tracer/operation/operation_test.go +++ b/tracer/operation/operation_test.go @@ -69,12 +69,11 @@ func (s *MockStateDB) Empty(addr common.Address) bool { return false } -func (s *MockStateDB) Suicide(addr common.Address) bool { +func (s *MockStateDB) SelfDestruct(addr common.Address) { s.recording = append(s.recording, Record{SuicideID, []any{addr}}) - return false } -func (s *MockStateDB) HasSuicided(addr common.Address) bool { +func (s *MockStateDB) HasSelfDestructed(addr common.Address) bool { s.recording = append(s.recording, Record{HasSuicidedID, []any{addr}}) return false } @@ -209,7 +208,7 @@ func (s *MockStateDB) GetHash() (common.Hash, error) { panic("GetHash not supported in mock") } -func (s *MockStateDB) GetTxState(thash common.Hash, ti int) { +func (s *MockStateDB) SetTxContext(thash common.Hash, ti int) { s.recording = append(s.recording, Record{PrepareID, []any{thash, ti}}) } @@ -261,8 +260,8 @@ func (s *MockStateDB) ForEachStorage(addr common.Address, cb func(common.Hash, c return nil } -func (s *MockStateDB) GetLogs(hash common.Hash, blockHash common.Hash) []*types.Log { - s.recording = append(s.recording, Record{GetLogsID, []any{hash, blockHash}}) +func (s *MockStateDB) GetLogs(hash common.Hash, block uint64, blockHash common.Hash) []*types.Log { + s.recording = append(s.recording, Record{GetLogsID, []any{hash, block, blockHash}}) return nil } @@ -275,6 +274,26 @@ func (s *MockStateDB) GetSubstatePostAlloc() txcontext.WorldState { return nil } +func (s *MockStateDB) CreateContract(addr common.Address) { + panic("CreateContract not supported in mock") +} + +func (s *MockStateDB) Selfdestruct6780(addr common.Address) { + panic("Selfdestruct6780 not supported in mock") +} + +func (s *MockStateDB) GetStorageRoot(addr common.Address) common.Hash { + panic("GetStorageRoot not supported in mock") +} + +func (s *MockStateDB) SetTransientState(addr common.Address, key common.Hash, value common.Hash) { + panic("SetTransientState not supported in mock") +} + +func (s *MockStateDB) GetTransientState(addr common.Address, key common.Hash) common.Hash { + panic("GetTransientState not supported in mock") +} + func (s *MockStateDB) Close() error { s.recording = append(s.recording, Record{CloseID, []any{}}) return nil @@ -335,6 +354,16 @@ func getRandomAddress(t *testing.T) common.Address { return crypto.PubkeyToAddress(pk.PublicKey) } +func getRandomHash(t *testing.T) common.Hash { + // generate hash from public key + pk, err := crypto.GenerateKey() + if err != nil { + t.Fatalf("failed test data build; could not create random keys; %s", err.Error()) + } + pubBytes := crypto.FromECDSAPub(&pk.PublicKey) + return crypto.Keccak256Hash(pubBytes[:]) +} + func testOperationReadWrite(t *testing.T, op1 Operation, opRead func(f io.Reader) (Operation, error)) { opBuffer := bytes.NewBufferString("") err := op1.Write(opBuffer) diff --git a/tracer/operation/setstate_lcls_test.go b/tracer/operation/setstate_lcls_test.go index a7d235e53..6a252aadb 100644 --- a/tracer/operation/setstate_lcls_test.go +++ b/tracer/operation/setstate_lcls_test.go @@ -25,7 +25,7 @@ import ( ) func initSetStateLcls(t *testing.T) (*context.Replay, *SetStateLcls, common.Address, common.Hash, common.Hash) { - value := getRandomAddress(t).Hash() + value := getRandomHash(t) // create new operation op := NewSetStateLcls(value) @@ -43,7 +43,7 @@ func initSetStateLcls(t *testing.T) (*context.Replay, *SetStateLcls, common.Addr addr := getRandomAddress(t) ctx.EncodeContract(addr) - storage := getRandomAddress(t).Hash() + storage := getRandomHash(t) ctx.EncodeKey(storage) return ctx, op, addr, storage, value diff --git a/tracer/operation/setstate_test.go b/tracer/operation/setstate_test.go index dbf60e0d6..df5c2cfce 100644 --- a/tracer/operation/setstate_test.go +++ b/tracer/operation/setstate_test.go @@ -26,8 +26,8 @@ import ( func initSetState(t *testing.T) (*context.Replay, *SetState, common.Address, common.Hash, common.Hash) { addr := getRandomAddress(t) - storage := getRandomAddress(t).Hash() - value := getRandomAddress(t).Hash() + storage := getRandomHash(t) + value := getRandomHash(t) // create context context ctx := context.NewReplay() diff --git a/tracer/operation/subbalance.go b/tracer/operation/subbalance.go index 295cd14bf..ebad88eac 100644 --- a/tracer/operation/subbalance.go +++ b/tracer/operation/subbalance.go @@ -23,9 +23,9 @@ import ( "log" "time" - "github.com/ethereum/go-ethereum/common" "github.com/Fantom-foundation/Aida/state" "github.com/Fantom-foundation/Aida/tracer/context" + "github.com/ethereum/go-ethereum/common" "github.com/holiman/uint256" ) diff --git a/tracer/operation/subbalance_test.go b/tracer/operation/subbalance_test.go index 7eef624dc..e3ee6c605 100644 --- a/tracer/operation/subbalance_test.go +++ b/tracer/operation/subbalance_test.go @@ -18,19 +18,20 @@ package operation import ( "fmt" - "math/big" "math/rand" "testing" "time" "github.com/Fantom-foundation/Aida/tracer/context" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/tracing" + "github.com/holiman/uint256" ) -func initSubBalance(t *testing.T) (*context.Replay, *SubBalance, common.Address, *big.Int) { +func initSubBalance(t *testing.T) (*context.Replay, *SubBalance, common.Address, *uint256.Int) { rand.Seed(time.Now().UnixNano()) addr := getRandomAddress(t) - value := big.NewInt(rand.Int63n(100000)) + value := uint256.NewInt(uint64(rand.Int63n(100000))) // create context context ctx := context.NewReplay() contract := ctx.EncodeContract(addr) @@ -69,6 +70,6 @@ func TestSubBalanceExecute(t *testing.T) { op.Execute(mock, ctx) // check whether methods were correctly called - expected := []Record{{SubBalanceID, []any{addr, value}}} + expected := []Record{{SubBalanceID, []any{addr, value, tracing.BalanceChangeUnspecified}}} mock.compareRecordings(expected, t) } From 683dbd4c511c33dcf5a2059dd58b57b64b49ccbd Mon Sep 17 00:00:00 2001 From: wsodsong Date: Mon, 17 Jun 2024 06:56:11 +0000 Subject: [PATCH 18/26] fix extension tests --- executor/extension/logger/db_logger_test.go | 4 +- .../profiler/operation_profiler_test.go | 58 ++++++++++--------- .../statedb/archive_inquirer_test.go | 11 ++-- .../statedb/state_db_manager_test.go | 7 ++- .../validator/transaction_validator_test.go | 29 +++++----- executor/norma_tx_provider_test.go | 12 ++-- 6 files changed, 63 insertions(+), 58 deletions(-) diff --git a/executor/extension/logger/db_logger_test.go b/executor/extension/logger/db_logger_test.go index e63835c9a..ab6849962 100644 --- a/executor/extension/logger/db_logger_test.go +++ b/executor/extension/logger/db_logger_test.go @@ -19,7 +19,6 @@ package logger import ( "fmt" "io" - "math/big" "os" "strings" "testing" @@ -32,6 +31,7 @@ import ( "github.com/Fantom-foundation/Aida/state/proxy" "github.com/Fantom-foundation/Aida/utils" "github.com/ethereum/go-ethereum/common" + "github.com/holiman/uint256" "go.uber.org/mock/gomock" ) @@ -91,7 +91,7 @@ func TestDbLoggerExtension_LoggingHappens(t *testing.T) { t.Fatalf("pre-transaction returned err; %v", err) } - balance := new(big.Int).SetInt64(10) + balance := new(uint256.Int).SetUint64(10) beginBlock := fmt.Sprintf("BeginBlock, %v", 1) beginTransaction := fmt.Sprintf("BeginTransaction, %v", 0) diff --git a/executor/extension/profiler/operation_profiler_test.go b/executor/extension/profiler/operation_profiler_test.go index 847591134..72875530b 100644 --- a/executor/extension/profiler/operation_profiler_test.go +++ b/executor/extension/profiler/operation_profiler_test.go @@ -30,7 +30,10 @@ import ( "github.com/Fantom-foundation/Aida/utils" "github.com/Fantom-foundation/Aida/utils/analytics" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/tracing" "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/params" + "github.com/holiman/uint256" gomock "go.uber.org/mock/gomock" "golang.org/x/exp/maps" ) @@ -100,7 +103,7 @@ func TestOperationProfiler_WithEachOpOnce(t *testing.T) { // These are purposely not implemented, will be blacklisted here notImplemented := make([]bool, len(ops)) - for _, a := range []byte{14, 18, 21, 22, 23, 29} { + for _, a := range []byte{14, 18, 21, 22, 23, 29, 42} { notImplemented[a] = true } @@ -288,8 +291,8 @@ func getStateDbFuncs(db state.StateDB) []func() { mockHash := common.BigToHash(big.NewInt(0)) return []func(){ func() { db.CreateAccount(mockAddress) }, - func() { db.SubBalance(mockAddress, big.NewInt(0)) }, - func() { db.AddBalance(mockAddress, big.NewInt(0)) }, + func() { db.SubBalance(mockAddress, uint256.NewInt(0), tracing.BalanceChangeUnspecified) }, + func() { db.AddBalance(mockAddress, uint256.NewInt(0), tracing.BalanceChangeUnspecified) }, func() { db.GetBalance(mockAddress) }, func() { db.GetNonce(mockAddress) }, func() { db.SetNonce(mockAddress, 0) }, @@ -303,12 +306,14 @@ func getStateDbFuncs(db state.StateDB) []func() { func() { db.GetCommittedState(mockAddress, mockHash) }, func() { db.GetState(mockAddress, mockHash) }, func() { db.SetState(mockAddress, mockHash, mockHash) }, - func() { db.Suicide(mockAddress) }, - func() { db.HasSuicided(mockAddress) }, + func() { db.SelfDestruct(mockAddress) }, + func() { db.HasSelfDestructed(mockAddress) }, func() { db.Exist(mockAddress) }, func() { db.Empty(mockAddress) }, func() { - db.PrepareAccessList( + db.Prepare( + params.Rules{}, + mockAddress, mockAddress, &mockAddress, []common.Address{}, @@ -328,13 +333,12 @@ func getStateDbFuncs(db state.StateDB) []func() { func() { db.BeginSyncPeriod(0) }, func() { db.EndSyncPeriod() }, func() { db.AddLog(nil) }, - func() { db.GetLogs(mockHash, mockHash) }, + func() { db.GetLogs(mockHash, uint64(0), mockHash) }, func() { db.AddPreimage(mockHash, []byte{0}) }, - func() { db.ForEachStorage(mockAddress, func(h1, h2 common.Hash) bool { return false }) }, - func() { db.Prepare(mockHash, 0) }, + func() { db.SetTxContext(mockHash, 0) }, func() { db.Finalise(false) }, func() { db.IntermediateRoot(false) }, - func() { db.Commit(false) }, + func() { db.Commit(uint64(0), false) }, func() { db.Close() }, } } @@ -343,8 +347,8 @@ func getStateDbFuncs(db state.StateDB) []func() { // This functions tell MockStateDB to expect any number of calls (0 or more) to each of the functions (for randomized test) func prepareMockStateDb(m *state.MockStateDB) { m.EXPECT().CreateAccount(gomock.Any()).AnyTimes() - m.EXPECT().SubBalance(gomock.Any(), gomock.Any()).AnyTimes() - m.EXPECT().AddBalance(gomock.Any(), gomock.Any()).AnyTimes() + m.EXPECT().SubBalance(gomock.Any(), gomock.Any(), gomock.Any()).AnyTimes() + m.EXPECT().AddBalance(gomock.Any(), gomock.Any(), gomock.Any()).AnyTimes() m.EXPECT().GetBalance(gomock.Any()).AnyTimes() m.EXPECT().GetNonce(gomock.Any()).AnyTimes() m.EXPECT().SetNonce(gomock.Any(), gomock.Any()).AnyTimes() @@ -358,11 +362,11 @@ func prepareMockStateDb(m *state.MockStateDB) { m.EXPECT().GetCommittedState(gomock.Any(), gomock.Any()).AnyTimes() m.EXPECT().GetState(gomock.Any(), gomock.Any()).AnyTimes() m.EXPECT().SetState(gomock.Any(), gomock.Any(), gomock.Any()).AnyTimes() - m.EXPECT().Suicide(gomock.Any()).AnyTimes() - m.EXPECT().HasSuicided(gomock.Any()).AnyTimes() + m.EXPECT().SelfDestruct(gomock.Any()).AnyTimes() + m.EXPECT().HasSelfDestructed(gomock.Any()).AnyTimes() m.EXPECT().Exist(gomock.Any()).AnyTimes() m.EXPECT().Empty(gomock.Any()).AnyTimes() - m.EXPECT().PrepareAccessList(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).AnyTimes() + m.EXPECT().Prepare(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).AnyTimes() m.EXPECT().AddAddressToAccessList(gomock.Any()).AnyTimes() m.EXPECT().AddressInAccessList(gomock.Any()).AnyTimes() m.EXPECT().SlotInAccessList(gomock.Any(), gomock.Any()).AnyTimes() @@ -376,13 +380,12 @@ func prepareMockStateDb(m *state.MockStateDB) { m.EXPECT().BeginSyncPeriod(gomock.Any()).AnyTimes() m.EXPECT().EndSyncPeriod().AnyTimes() m.EXPECT().AddLog(gomock.Any()).AnyTimes() - m.EXPECT().GetLogs(gomock.Any(), gomock.Any()).AnyTimes() + m.EXPECT().GetLogs(gomock.Any(), gomock.Any(), gomock.Any()).AnyTimes() m.EXPECT().AddPreimage(gomock.Any(), gomock.Any()).AnyTimes() - m.EXPECT().ForEachStorage(gomock.Any(), gomock.Any()).AnyTimes() - m.EXPECT().Prepare(gomock.Any(), gomock.Any()).AnyTimes() + m.EXPECT().SetTxContext(gomock.Any(), gomock.Any()).AnyTimes() m.EXPECT().Finalise(gomock.Any()).AnyTimes() m.EXPECT().IntermediateRoot(gomock.Any()).AnyTimes() - m.EXPECT().Commit(gomock.Any()).AnyTimes() + m.EXPECT().Commit(gomock.Any(), gomock.Any()).AnyTimes() m.EXPECT().Close().AnyTimes() } @@ -390,8 +393,8 @@ func prepareMockStateDb(m *state.MockStateDB) { // This functions tell MockStateDB to expect exactly one call to each of the possible functions func prepareMockStateDbOnce(m *state.MockStateDB) { m.EXPECT().CreateAccount(gomock.Any()) - m.EXPECT().SubBalance(gomock.Any(), gomock.Any()) - m.EXPECT().AddBalance(gomock.Any(), gomock.Any()) + m.EXPECT().SubBalance(gomock.Any(), gomock.Any(), gomock.Any()) + m.EXPECT().AddBalance(gomock.Any(), gomock.Any(), gomock.Any()) m.EXPECT().GetBalance(gomock.Any()) m.EXPECT().GetNonce(gomock.Any()) m.EXPECT().SetNonce(gomock.Any(), gomock.Any()) @@ -405,11 +408,11 @@ func prepareMockStateDbOnce(m *state.MockStateDB) { m.EXPECT().GetCommittedState(gomock.Any(), gomock.Any()) m.EXPECT().GetState(gomock.Any(), gomock.Any()) m.EXPECT().SetState(gomock.Any(), gomock.Any(), gomock.Any()) - m.EXPECT().Suicide(gomock.Any()) - m.EXPECT().HasSuicided(gomock.Any()) + m.EXPECT().SelfDestruct(gomock.Any()) + m.EXPECT().HasSelfDestructed(gomock.Any()) m.EXPECT().Exist(gomock.Any()) m.EXPECT().Empty(gomock.Any()) - m.EXPECT().PrepareAccessList(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()) + m.EXPECT().Prepare(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()) m.EXPECT().AddAddressToAccessList(gomock.Any()) m.EXPECT().AddressInAccessList(gomock.Any()) m.EXPECT().SlotInAccessList(gomock.Any(), gomock.Any()) @@ -423,13 +426,12 @@ func prepareMockStateDbOnce(m *state.MockStateDB) { m.EXPECT().BeginSyncPeriod(gomock.Any()) m.EXPECT().EndSyncPeriod() m.EXPECT().AddLog(gomock.Any()) - m.EXPECT().GetLogs(gomock.Any(), gomock.Any()) + m.EXPECT().GetLogs(gomock.Any(), gomock.Any(), gomock.Any()) m.EXPECT().AddPreimage(gomock.Any(), gomock.Any()) - m.EXPECT().ForEachStorage(gomock.Any(), gomock.Any()) - m.EXPECT().Prepare(gomock.Any(), gomock.Any()) + m.EXPECT().SetTxContext(gomock.Any(), gomock.Any()) m.EXPECT().Finalise(gomock.Any()) m.EXPECT().IntermediateRoot(gomock.Any()) - m.EXPECT().Commit(gomock.Any()) + m.EXPECT().Commit(gomock.Any(), gomock.Any()) m.EXPECT().Close() } diff --git a/executor/extension/statedb/archive_inquirer_test.go b/executor/extension/statedb/archive_inquirer_test.go index 298d5972f..0b9a386ba 100644 --- a/executor/extension/statedb/archive_inquirer_test.go +++ b/executor/extension/statedb/archive_inquirer_test.go @@ -31,6 +31,7 @@ import ( "github.com/Fantom-foundation/Aida/utils" "github.com/Fantom-foundation/Substate/substate" "github.com/ethereum/go-ethereum/common" + "github.com/holiman/uint256" "go.uber.org/mock/gomock" ) @@ -104,19 +105,19 @@ func TestArchiveInquirer_RunsRandomTransactionsInBackground(t *testing.T) { db.EXPECT().GetArchiveState(uint64(14)).MinTimes(1).Return(archive, nil) archive.EXPECT().BeginTransaction(gomock.Any()).MinTimes(1) - archive.EXPECT().Prepare(gomock.Any(), gomock.Any()).AnyTimes() + archive.EXPECT().SetTxContext(gomock.Any(), gomock.Any()).AnyTimes() archive.EXPECT().Snapshot().AnyTimes() - archive.EXPECT().GetBalance(gomock.Any()).AnyTimes().Return(big.NewInt(1000)) + archive.EXPECT().GetBalance(gomock.Any()).AnyTimes().Return(uint256.NewInt(1000)) archive.EXPECT().GetNonce(gomock.Any()).AnyTimes().Return(uint64(0)) archive.EXPECT().SetNonce(gomock.Any(), gomock.Any()).AnyTimes().Return() archive.EXPECT().GetCodeHash(gomock.Any()).AnyTimes().Return(common.Hash{}) - archive.EXPECT().SubBalance(gomock.Any(), gomock.Any()).AnyTimes() + archive.EXPECT().SubBalance(gomock.Any(), gomock.Any(), gomock.Any()).AnyTimes() archive.EXPECT().CreateAccount(gomock.Any()).AnyTimes() - archive.EXPECT().AddBalance(gomock.Any(), gomock.Any()).AnyTimes() + archive.EXPECT().AddBalance(gomock.Any(), gomock.Any(), gomock.Any()).AnyTimes() archive.EXPECT().SetCode(gomock.Any(), gomock.Any()).AnyTimes() archive.EXPECT().GetRefund().AnyTimes() archive.EXPECT().RevertToSnapshot(gomock.Any()).AnyTimes() - archive.EXPECT().GetLogs(gomock.Any(), gomock.Any()).AnyTimes() + archive.EXPECT().GetLogs(gomock.Any(), gomock.Any(), gomock.Any()).AnyTimes() archive.EXPECT().EndTransaction().AnyTimes() archive.EXPECT().Release().MinTimes(1) diff --git a/executor/extension/statedb/state_db_manager_test.go b/executor/extension/statedb/state_db_manager_test.go index 62c6faa53..7a70ee21f 100644 --- a/executor/extension/statedb/state_db_manager_test.go +++ b/executor/extension/statedb/state_db_manager_test.go @@ -19,7 +19,6 @@ package statedb import ( "fmt" "io" - "math/big" "os" "path/filepath" "strings" @@ -29,6 +28,8 @@ import ( "github.com/Fantom-foundation/Aida/state" "github.com/Fantom-foundation/Aida/utils" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/tracing" + "github.com/holiman/uint256" "go.uber.org/mock/gomock" ) @@ -382,10 +383,10 @@ func insertRandomDataIntoStateDb(t *testing.T, ctx *executor.Context) { // get randomized balance additionBase := state.GetRandom(1, 1000*5000) - addition := big.NewInt(int64(additionBase)) + addition := uint256.NewInt(uint64(additionBase)) ctx.State.CreateAccount(addr) - ctx.State.AddBalance(addr, addition) + ctx.State.AddBalance(addr, addition, tracing.BalanceChangeUnspecified) } func IsEmptyDirectory(name string) (bool, error) { diff --git a/executor/extension/validator/transaction_validator_test.go b/executor/extension/validator/transaction_validator_test.go index 6bbf6d2eb..b87224e33 100644 --- a/executor/extension/validator/transaction_validator_test.go +++ b/executor/extension/validator/transaction_validator_test.go @@ -34,6 +34,7 @@ import ( substatetypes "github.com/Fantom-foundation/Substate/types" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/holiman/uint256" "go.uber.org/mock/gomock" ) @@ -118,7 +119,7 @@ func TestLiveTxValidator_SingleErrorInPreTransactionDoesNotEndProgramWithContinu gomock.InOrder( db.EXPECT().Exist(common.Address{0}).Return(false), - db.EXPECT().GetBalance(common.Address{0}).Return(new(big.Int)), + db.EXPECT().GetBalance(common.Address{0}).Return(new(uint256.Int)), db.EXPECT().GetNonce(common.Address{0}).Return(uint64(0)), db.EXPECT().GetCode(common.Address{0}).Return([]byte{0}), ) @@ -150,7 +151,7 @@ func TestLiveTxValidator_SingleErrorInPreTransactionReturnsErrorWithNoContinueOn gomock.InOrder( db.EXPECT().Exist(common.Address{0}).Return(false), - db.EXPECT().GetBalance(common.Address{0}).Return(new(big.Int)), + db.EXPECT().GetBalance(common.Address{0}).Return(new(uint256.Int)), db.EXPECT().GetNonce(common.Address{0}).Return(uint64(0)), db.EXPECT().GetCode(common.Address{0}).Return([]byte{0}), ) @@ -191,7 +192,7 @@ func TestLiveTxValidator_SingleErrorInPostTransactionReturnsErrorWithNoContinueO gomock.InOrder( db.EXPECT().Exist(common.Address{0}).Return(false), - db.EXPECT().GetBalance(common.Address{0}).Return(new(big.Int)), + db.EXPECT().GetBalance(common.Address{0}).Return(new(uint256.Int)), db.EXPECT().GetNonce(common.Address{0}).Return(uint64(0)), db.EXPECT().GetCode(common.Address{0}).Return([]byte{0}), ) @@ -277,12 +278,12 @@ func TestLiveTxValidator_TwoErrorsDoNotReturnAnErrorWhenContinueOnFailureIsEnabl log.EXPECT().Warningf(gomock.Any(), cfg.MaxNumErrors), // PreTransaction db.EXPECT().Exist(common.Address{0}).Return(false), - db.EXPECT().GetBalance(common.Address{0}).Return(new(big.Int)), + db.EXPECT().GetBalance(common.Address{0}).Return(new(uint256.Int)), db.EXPECT().GetNonce(common.Address{0}).Return(uint64(0)), db.EXPECT().GetCode(common.Address{0}).Return([]byte{0}), // PostTransaction db.EXPECT().Exist(common.Address{0}).Return(false), - db.EXPECT().GetBalance(common.Address{0}).Return(new(big.Int)), + db.EXPECT().GetBalance(common.Address{0}).Return(new(uint256.Int)), db.EXPECT().GetNonce(common.Address{0}).Return(uint64(0)), db.EXPECT().GetCode(common.Address{0}).Return([]byte{0}), ) @@ -331,12 +332,12 @@ func TestLiveTxValidator_TwoErrorsDoReturnErrorOnEventWhenContinueOnFailureIsEna log.EXPECT().Warningf(gomock.Any(), cfg.MaxNumErrors), // PreTransaction db.EXPECT().Exist(common.Address{0}).Return(false), - db.EXPECT().GetBalance(common.Address{0}).Return(new(big.Int)), + db.EXPECT().GetBalance(common.Address{0}).Return(new(uint256.Int)), db.EXPECT().GetNonce(common.Address{0}).Return(uint64(0)), db.EXPECT().GetCode(common.Address{0}).Return([]byte{0}), // PostTransaction db.EXPECT().Exist(common.Address{0}).Return(false), - db.EXPECT().GetBalance(common.Address{0}).Return(new(big.Int)), + db.EXPECT().GetBalance(common.Address{0}).Return(new(uint256.Int)), db.EXPECT().GetNonce(common.Address{0}).Return(uint64(0)), db.EXPECT().GetCode(common.Address{0}).Return([]byte{0}), ) @@ -486,7 +487,7 @@ func TestArchiveTxValidator_SingleErrorInPreTransactionDoesNotEndProgramWithCont gomock.InOrder( db.EXPECT().Exist(common.Address{0}).Return(false), - db.EXPECT().GetBalance(common.Address{0}).Return(new(big.Int)), + db.EXPECT().GetBalance(common.Address{0}).Return(new(uint256.Int)), db.EXPECT().GetNonce(common.Address{0}).Return(uint64(0)), db.EXPECT().GetCode(common.Address{0}).Return([]byte{0}), ) @@ -518,7 +519,7 @@ func TestArchiveTxValidator_SingleErrorInPreTransactionReturnsErrorWithNoContinu gomock.InOrder( db.EXPECT().Exist(common.Address{0}).Return(false), - db.EXPECT().GetBalance(common.Address{0}).Return(new(big.Int)), + db.EXPECT().GetBalance(common.Address{0}).Return(new(uint256.Int)), db.EXPECT().GetNonce(common.Address{0}).Return(uint64(0)), db.EXPECT().GetCode(common.Address{0}).Return([]byte{0}), ) @@ -559,7 +560,7 @@ func TestArchiveTxValidator_SingleErrorInPostTransactionReturnsErrorWithNoContin gomock.InOrder( db.EXPECT().Exist(common.Address{0}).Return(false), - db.EXPECT().GetBalance(common.Address{0}).Return(new(big.Int)), + db.EXPECT().GetBalance(common.Address{0}).Return(new(uint256.Int)), db.EXPECT().GetNonce(common.Address{0}).Return(uint64(0)), db.EXPECT().GetCode(common.Address{0}).Return([]byte{0}), ) @@ -639,12 +640,12 @@ func TestArchiveTxValidator_TwoErrorsDoNotReturnAnErrorWhenContinueOnFailureIsEn log.EXPECT().Warningf(gomock.Any(), cfg.MaxNumErrors), // PreTransaction db.EXPECT().Exist(common.Address{0}).Return(false), - db.EXPECT().GetBalance(common.Address{0}).Return(new(big.Int)), + db.EXPECT().GetBalance(common.Address{0}).Return(new(uint256.Int)), db.EXPECT().GetNonce(common.Address{0}).Return(uint64(0)), db.EXPECT().GetCode(common.Address{0}).Return([]byte{0}), // PostTransaction db.EXPECT().Exist(common.Address{0}).Return(false), - db.EXPECT().GetBalance(common.Address{0}).Return(new(big.Int)), + db.EXPECT().GetBalance(common.Address{0}).Return(new(uint256.Int)), db.EXPECT().GetNonce(common.Address{0}).Return(uint64(0)), db.EXPECT().GetCode(common.Address{0}).Return([]byte{0}), ) @@ -693,12 +694,12 @@ func TestArchiveTxValidator_TwoErrorsDoReturnErrorOnEventWhenContinueOnFailureIs log.EXPECT().Warningf(gomock.Any(), cfg.MaxNumErrors), // PreTransaction db.EXPECT().Exist(common.Address{0}).Return(false), - db.EXPECT().GetBalance(common.Address{0}).Return(new(big.Int)), + db.EXPECT().GetBalance(common.Address{0}).Return(new(uint256.Int)), db.EXPECT().GetNonce(common.Address{0}).Return(uint64(0)), db.EXPECT().GetCode(common.Address{0}).Return([]byte{0}), // PostTransaction db.EXPECT().Exist(common.Address{0}).Return(false), - db.EXPECT().GetBalance(common.Address{0}).Return(new(big.Int)), + db.EXPECT().GetBalance(common.Address{0}).Return(new(uint256.Int)), db.EXPECT().GetNonce(common.Address{0}).Return(uint64(0)), db.EXPECT().GetCode(common.Address{0}).Return([]byte{0}), ) diff --git a/executor/norma_tx_provider_test.go b/executor/norma_tx_provider_test.go index e93a79096..527d9a472 100644 --- a/executor/norma_tx_provider_test.go +++ b/executor/norma_tx_provider_test.go @@ -17,12 +17,12 @@ package executor import ( - "math/big" "testing" "github.com/Fantom-foundation/Aida/state" "github.com/Fantom-foundation/Aida/utils" "github.com/ethereum/go-ethereum/params" + "github.com/holiman/uint256" "go.uber.org/mock/gomock" ) @@ -43,7 +43,7 @@ func TestNormaTxProvider_Run(t *testing.T) { dbMock.EXPECT().BeginBlock(gomock.Any()), dbMock.EXPECT().BeginTransaction(gomock.Any()), dbMock.EXPECT().CreateAccount(gomock.Any()), - dbMock.EXPECT().AddBalance(gomock.Any(), gomock.Any()), + dbMock.EXPECT().AddBalance(gomock.Any(), gomock.Any(), gomock.Any()), dbMock.EXPECT().EndTransaction(), dbMock.EXPECT().EndBlock(), @@ -59,7 +59,7 @@ func TestNormaTxProvider_Run(t *testing.T) { // funding accounts // we return a lot of tokens, so we don't have to "fund" them dbMock.EXPECT().BeginTransaction(gomock.Any()), - dbMock.EXPECT().GetBalance(gomock.Any()).Return(big.NewInt(0).Mul(big.NewInt(params.Ether), big.NewInt(1_000_000))), + dbMock.EXPECT().GetBalance(gomock.Any()).Return(uint256.NewInt(0).Mul(uint256.NewInt(params.Ether), uint256.NewInt(1_000_000))), dbMock.EXPECT().EndTransaction(), // nonce for account deploying the contract has to be 1 dbMock.EXPECT().BeginTransaction(gomock.Any()), @@ -70,7 +70,7 @@ func TestNormaTxProvider_Run(t *testing.T) { dbMock.EXPECT().GetNonce(gomock.Any()).Return(uint64(0)), dbMock.EXPECT().EndTransaction(), dbMock.EXPECT().BeginTransaction(gomock.Any()), - dbMock.EXPECT().GetBalance(gomock.Any()).Return(big.NewInt(0).Mul(big.NewInt(params.Ether), big.NewInt(1_000_000))), + dbMock.EXPECT().GetBalance(gomock.Any()).Return(uint256.NewInt(0).Mul(uint256.NewInt(params.Ether), uint256.NewInt(1_000_000))), dbMock.EXPECT().EndTransaction(), // waiting for contract deployment requires checking the nonce @@ -105,14 +105,14 @@ func TestNormaTxProvider_RunAll(t *testing.T) { provider := NewNormaTxProvider(cfg, dbMock) consumer := NewMockTxConsumer(ctrl) - balance := big.NewInt(0).Mul(big.NewInt(params.Ether), big.NewInt(1_000_000)) + balance := uint256.NewInt(0).Mul(uint256.NewInt(params.Ether), uint256.NewInt(1_000_000)) gomock.InOrder( // treasure account initialization dbMock.EXPECT().BeginBlock(gomock.Any()), dbMock.EXPECT().BeginTransaction(gomock.Any()), dbMock.EXPECT().CreateAccount(gomock.Any()), - dbMock.EXPECT().AddBalance(gomock.Any(), gomock.Any()), + dbMock.EXPECT().AddBalance(gomock.Any(), gomock.Any(), gomock.Any()), dbMock.EXPECT().EndTransaction(), dbMock.EXPECT().EndBlock(), From f0fb07145b31499f230572fca0aa958926430243 Mon Sep 17 00:00:00 2001 From: wsodsong Date: Mon, 17 Jun 2024 10:51:06 +0000 Subject: [PATCH 19/26] fix tests and geth db close --- .../extension/statedb/archive_inquirer_test.go | 3 +++ .../statedb/eth_state_test_db_primer_test.go | 5 +++-- go.mod | 4 +--- state/geth.go | 8 ++++++-- state/geth_test.go | 16 ++++++++++++++-- 5 files changed, 27 insertions(+), 9 deletions(-) diff --git a/executor/extension/statedb/archive_inquirer_test.go b/executor/extension/statedb/archive_inquirer_test.go index 0b9a386ba..9ae84dd7c 100644 --- a/executor/extension/statedb/archive_inquirer_test.go +++ b/executor/extension/statedb/archive_inquirer_test.go @@ -120,6 +120,9 @@ func TestArchiveInquirer_RunsRandomTransactionsInBackground(t *testing.T) { archive.EXPECT().GetLogs(gomock.Any(), gomock.Any(), gomock.Any()).AnyTimes() archive.EXPECT().EndTransaction().AnyTimes() archive.EXPECT().Release().MinTimes(1) + archive.EXPECT().GetStorageRoot(gomock.Any()).AnyTimes() + archive.EXPECT().Exist(gomock.Any()).AnyTimes() + archive.EXPECT().CreateContract(gomock.Any()).AnyTimes() ext := makeArchiveInquirer(&cfg, log) if err := ext.PreRun(state, &context); err != nil { diff --git a/executor/extension/statedb/eth_state_test_db_primer_test.go b/executor/extension/statedb/eth_state_test_db_primer_test.go index 3cd5685a7..1b8ec978d 100644 --- a/executor/extension/statedb/eth_state_test_db_primer_test.go +++ b/executor/extension/statedb/eth_state_test_db_primer_test.go @@ -25,6 +25,7 @@ import ( "github.com/Fantom-foundation/Aida/state" "github.com/Fantom-foundation/Aida/txcontext" "github.com/Fantom-foundation/Aida/utils" + "github.com/holiman/uint256" "go.uber.org/mock/gomock" ) @@ -48,7 +49,7 @@ func Test_ethStateTestDbPrimer_PreTransactionPriming(t *testing.T) { for address, account := range testData.Pre { mockState.EXPECT().Exist(address).Return(false) mockLoad.EXPECT().CreateAccount(address) - mockLoad.EXPECT().SetBalance(address, account.Balance) + mockLoad.EXPECT().SetBalance(address, uint256.MustFromBig(account.Balance)) mockLoad.EXPECT().SetNonce(address, account.Nonce) mockLoad.EXPECT().SetCode(address, account.Code) } @@ -81,7 +82,7 @@ func Test_EthStateTestDbPrimer_PreTransactionPrimingWorksWithPreExistedStateDb(t mockState.EXPECT().StartBulkLoad(uint64(1)).Return(mockLoad, nil) for address, account := range testData.Pre { mockState.EXPECT().Exist(address).Return(true) - mockLoad.EXPECT().SetBalance(address, account.Balance) + mockLoad.EXPECT().SetBalance(address, uint256.MustFromBig(account.Balance)) mockLoad.EXPECT().SetNonce(address, account.Nonce) mockLoad.EXPECT().SetCode(address, account.Code) } diff --git a/go.mod b/go.mod index 71f2cfaa8..d749879eb 100644 --- a/go.mod +++ b/go.mod @@ -28,7 +28,7 @@ require ( github.com/sigurn/crc8 v0.0.0-20220107193325-2243fe600f9f github.com/status-im/keycard-go v0.3.2 github.com/stretchr/testify v1.9.0 - github.com/syndtr/goleveldb v1.0.1-0.20220614013038-64ee5596c38a + github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 github.com/urfave/cli/v2 v2.27.2 go.uber.org/mock v0.4.0 golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 @@ -132,5 +132,3 @@ replace github.com/ethereum/go-ethereum => github.com/Fantom-foundation/go-ether replace github.com/Fantom-foundation/lachesis-base => github.com/Fantom-foundation/lachesis-base-sonic v0.0.0-20240320160249-81827a18147c replace github.com/Fantom-foundation/go-opera => github.com/Fantom-foundation/sonic v1.2.1-b.0.20240610064725-fc9986b8bf5d - -replace github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 diff --git a/state/geth.go b/state/geth.go index f396b0a23..466b7393f 100644 --- a/state/geth.go +++ b/state/geth.go @@ -61,6 +61,7 @@ func MakeGethStateDB(directory, variant string, rootHash common.Hash, isArchiveM triegc: prque.New[uint64, common.Hash](nil), isArchiveMode: isArchiveMode, chainConduit: chainConduit, + backend: ldb, }, nil } @@ -79,6 +80,7 @@ type gethStateDB struct { isArchiveMode bool chainConduit *ChainConduit // chain configuration block uint64 + backend ethdb.Database } func (s *gethStateDB) CreateAccount(addr common.Address) { @@ -296,9 +298,11 @@ func (s *gethStateDB) Close() error { if err := tdb.Commit(hash, true); err != nil { return err } - // Close underlying LevelDB instance. - return tdb.Close() + if err := tdb.Close(); err != nil { + return err + } + return s.backend.Close() } func (s *gethStateDB) AddRefund(gas uint64) { diff --git a/state/geth_test.go b/state/geth_test.go index 9b7fecf0e..d33ad3785 100644 --- a/state/geth_test.go +++ b/state/geth_test.go @@ -32,15 +32,27 @@ func fillDb(t *testing.T, directory string) (common.Hash, error) { t.Fatalf("Failed to create DB: %v", err) } + if err := db.BeginBlock(0); err != nil { + t.Fatalf("BeginBlock failed: %v", err) + } + if err := db.BeginTransaction(0); err != nil { + t.Fatalf("BeginTransaction failed: %v", err) + } for i := 0; i < N; i++ { address := common.Address{byte(i), byte(i >> 8)} + db.CreateAccount(address) db.SetNonce(address, 12) key := common.Hash{byte(i >> 8), byte(i)} value := common.Hash{byte(15)} db.SetState(address, key, value) } - - hash, err := db.Commit(0, true) + if err := db.EndTransaction(); err != nil { + t.Fatalf("EndTransaction failed: %v", err) + } + if err := db.EndBlock(); err != nil { + t.Fatalf("EndBlock failed: %v", err) + } + hash, err := db.GetHash() if err != nil { t.Fatalf("Failed to commit: %v", err) } From 145a9fa0a6d3c07bd633b752e0806cf58b4ca714 Mon Sep 17 00:00:00 2001 From: wsodsong Date: Tue, 18 Jun 2024 06:34:20 +0000 Subject: [PATCH 20/26] fix according to comments --- cmd/aida-sdb/record.go | 1 - cmd/aida-stochastic-sdb/stochastic/record.go | 1 - ethtest/transaction.go | 7 ++++--- state/carmen_test.go | 16 ++++++++-------- state/carmen_test_enviroment.go | 4 ++-- state/proxy/shadow_test.go | 12 ++++++------ tracer/operation/hassuicided.go | 1 - 7 files changed, 20 insertions(+), 22 deletions(-) diff --git a/cmd/aida-sdb/record.go b/cmd/aida-sdb/record.go index 6545072d8..7ec332a66 100644 --- a/cmd/aida-sdb/record.go +++ b/cmd/aida-sdb/record.go @@ -65,7 +65,6 @@ func RecordStateDbTrace(ctx *cli.Context) error { // force enable transaction validation cfg.ValidateTxState = true - //state.EnableRecordReplay() aidaDb, err := db.NewReadOnlyBaseDB(cfg.AidaDb) if err != nil { return fmt.Errorf("cannot open aida-db; %w", err) diff --git a/cmd/aida-stochastic-sdb/stochastic/record.go b/cmd/aida-stochastic-sdb/stochastic/record.go index 11887499a..2ed6b1a35 100644 --- a/cmd/aida-stochastic-sdb/stochastic/record.go +++ b/cmd/aida-stochastic-sdb/stochastic/record.go @@ -57,7 +57,6 @@ last block for recording events.`, // stochasticRecordAction implements recording of events. func stochasticRecordAction(ctx *cli.Context) error { - //gethstate.EnableRecordReplay() var err error cfg, err := utils.NewConfig(ctx, utils.BlockRangeArgs) diff --git a/ethtest/transaction.go b/ethtest/transaction.go index e4e845dea..02140ecdb 100644 --- a/ethtest/transaction.go +++ b/ethtest/transaction.go @@ -41,7 +41,8 @@ type stTransaction struct { GasLimit []*BigInt `json:"gasLimit"` Value []string `json:"value"` PrivateKey hexutil.Bytes `json:"secretKey"` - //TODO support Blob type + BlobGasFeeCap *BigInt `json:"maxFeePerBlobGas"` + BlobHashes []common.Hash `json:"blobVersionHashes"` } func (tx *stTransaction) toMessage(ps stPostState, baseFee *BigInt) (*core.Message, error) { @@ -123,8 +124,8 @@ func (tx *stTransaction) toMessage(ps stPostState, baseFee *BigInt) (*core.Messa tx.MaxPriorityFeePerGas.Convert(), data, accessList, - nil, //TODO support BlobGasFeeCap - []common.Hash{}, //TODO support BlobHashes + tx.BlobGasFeeCap.Convert(), + tx.BlobHashes, false, } return msg, nil diff --git a/state/carmen_test.go b/state/carmen_test.go index 60d8afd21..2a688dddd 100644 --- a/state/carmen_test.go +++ b/state/carmen_test.go @@ -132,7 +132,7 @@ func TestCarmenState_AccountBalanceOperations(t *testing.T) { // get randomized balance additionBase := GetRandom(1, 1000*5000) - addition := uint256.NewInt(uint64(additionBase)) + addition := uint256.NewInt(additionBase) csDB.AddBalance(addr, addition, 0) @@ -140,7 +140,7 @@ func TestCarmenState_AccountBalanceOperations(t *testing.T) { t.Fatal("failed to add balance to carmen state DB account") } - subtraction := uint256.NewInt(uint64(GetRandom(1, additionBase))) + subtraction := uint256.NewInt(GetRandom(1, int(additionBase))) expectedResult := uint256.NewInt(0).Sub(addition, subtraction) csDB.SubBalance(addr, subtraction, 0) @@ -178,7 +178,7 @@ func TestCarmenState_NonceOperations(t *testing.T) { csDB.CreateAccount(addr) // get randomized nonce - newNonce := uint64(GetRandom(1, 1000*5000)) + newNonce := GetRandom(1, 1000*5000) csDB.SetNonce(addr, newNonce) @@ -349,7 +349,7 @@ func TestCarmenState_RefundOperations(t *testing.T) { } }(csDB) - refundValue := uint64(GetRandom(10000*4000, 10000*5000)) + refundValue := GetRandom(10000*4000, 10000*5000) csDB.AddRefund(refundValue) if csDB.GetRefund() != refundValue { @@ -550,7 +550,7 @@ func TestCarmenState_SetBalanceUsingBulkInsertion(t *testing.T) { cbl.CreateAccount(addr) - newBalance := uint256.NewInt(uint64(GetRandom(1, 1000*5000))) + newBalance := uint256.NewInt(GetRandom(1, 1000*5000)) cbl.SetBalance(addr, newBalance) err = cbl.Close() @@ -600,7 +600,7 @@ func TestCarmenState_SetNonceUsingBulkInsertion(t *testing.T) { cbl.CreateAccount(addr) - newNonce := uint64(GetRandom(1, 1000*5000)) + newNonce := GetRandom(1, 1000*5000) cbl.SetNonce(addr, newNonce) @@ -773,7 +773,7 @@ func TestCarmenState_BulkloadOperations(t *testing.T) { switch { case operationType == 1: // set balance - newBalance := uint256.NewInt(uint64(GetRandom(0, 1000*5000))) + newBalance := uint256.NewInt(GetRandom(0, 1000*5000)) cbl.SetBalance(account, newBalance) case operationType == 2: @@ -789,7 +789,7 @@ func TestCarmenState_BulkloadOperations(t *testing.T) { cbl.SetState(account, key, value) case operationType == 4: // set nonce - newNonce := uint64(GetRandom(0, 1000*5000)) + newNonce := GetRandom(0, 1000*5000) cbl.SetNonce(account, newNonce) default: diff --git a/state/carmen_test_enviroment.go b/state/carmen_test_enviroment.go index 4fb3b59a2..fcac517b2 100644 --- a/state/carmen_test_enviroment.go +++ b/state/carmen_test_enviroment.go @@ -90,13 +90,13 @@ func MakeRandomByteSlice(t *testing.T, bufferLength int) []byte { return buffer } -func GetRandom(rangeLower int, rangeUpper int) int { +func GetRandom(rangeLower int, rangeUpper int) uint64 { // seed the PRNG rand.Seed(time.Now().UnixNano()) // get randomized balance randInt := rangeLower + rand.Intn(rangeUpper-rangeLower+1) - return randInt + return uint64(randInt) } func MakeCarmenDbTestContext(dir string, variant string, schema int, archive string) (StateDB, error) { diff --git a/state/proxy/shadow_test.go b/state/proxy/shadow_test.go index 1c05fb528..67f7f39bc 100644 --- a/state/proxy/shadow_test.go +++ b/state/proxy/shadow_test.go @@ -144,7 +144,7 @@ func TestShadowState_AccountBalanceOperations(t *testing.T) { // get randomized balance additionBase := state.GetRandom(1, 1000*5000) - addition := uint256.NewInt(uint64(additionBase)) + addition := uint256.NewInt(additionBase) shadowDB.AddBalance(addr, addition, 0) @@ -152,7 +152,7 @@ func TestShadowState_AccountBalanceOperations(t *testing.T) { t.Fatal("failed to add balance to carmen state DB account") } - subtraction := uint256.NewInt(uint64(state.GetRandom(1, additionBase))) + subtraction := uint256.NewInt(state.GetRandom(1, int(additionBase))) expectedResult := uint256.NewInt(0).Sub(addition, subtraction) shadowDB.SubBalance(addr, subtraction, 0) @@ -183,7 +183,7 @@ func TestShadowState_NonceOperations(t *testing.T) { shadowDB.CreateAccount(addr) // get randomized nonce - newNonce := uint64(state.GetRandom(1, 1000*5000)) + newNonce := state.GetRandom(1, 1000*5000) shadowDB.SetNonce(addr, newNonce) @@ -327,7 +327,7 @@ func TestShadowState_RefundOperations(t *testing.T) { } }(shadowDB) - refundValue := uint64(state.GetRandom(10000*4000, 10000*5000)) + refundValue := state.GetRandom(10000*4000, 10000*5000) shadowDB.AddRefund(refundValue) if shadowDB.GetRefund() != refundValue { @@ -461,7 +461,7 @@ func TestShadowState_SetBalanceUsingBulkInsertion(t *testing.T) { cbl.CreateAccount(addr) - newBalance := uint256.NewInt(uint64(state.GetRandom(1, 1000*5000))) + newBalance := uint256.NewInt(state.GetRandom(1, 1000*5000)) cbl.SetBalance(addr, newBalance) err = cbl.Close() @@ -505,7 +505,7 @@ func TestShadowState_SetNonceUsingBulkInsertion(t *testing.T) { cbl.CreateAccount(addr) - newNonce := uint64(state.GetRandom(1, 1000*5000)) + newNonce := state.GetRandom(1, 1000*5000) cbl.SetNonce(addr, newNonce) diff --git a/tracer/operation/hassuicided.go b/tracer/operation/hassuicided.go index 0cc976c3e..ad232793f 100644 --- a/tracer/operation/hassuicided.go +++ b/tracer/operation/hassuicided.go @@ -59,7 +59,6 @@ func (op *HasSuicided) Write(f io.Writer) error { func (op *HasSuicided) Execute(db state.StateDB, ctx *context.Replay) time.Duration { contract := ctx.DecodeContract(op.Contract) start := time.Now() - //TODO change function name db.HasSelfDestructed(contract) return time.Since(start) } From bc6cd6cd2d79eb96557e3a93d328fc516d34d029 Mon Sep 17 00:00:00 2001 From: wsodsong Date: Tue, 18 Jun 2024 09:47:02 +0000 Subject: [PATCH 21/26] avoid geth Zero state hash log --- state/geth.go | 3 +++ state/substate.go | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/state/geth.go b/state/geth.go index 466b7393f..3b1601f9b 100644 --- a/state/geth.go +++ b/state/geth.go @@ -49,6 +49,9 @@ func MakeGethStateDB(directory, variant string, rootHash common.Hash, isArchiveM return nil, fmt.Errorf("failed to create a new Level DB. %v", err) } evmState := geth.NewDatabase(ldb) + if rootHash == (common.Hash{}) { + rootHash = types.EmptyRootHash + } db, err := geth.New(rootHash, evmState, nil) if err != nil { return nil, err diff --git a/state/substate.go b/state/substate.go index 3748e92bd..2eaf47f32 100644 --- a/state/substate.go +++ b/state/substate.go @@ -25,6 +25,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/state" + "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/trie" @@ -115,7 +116,7 @@ func NewOffTheChainStateDB() *state.StateDB { disk: kvdb, } - statedb, err := state.New(common.Hash{}, sdb, nil) + statedb, err := state.New(types.EmptyRootHash, sdb, nil) if err != nil { panic(fmt.Errorf("error calling state.New() in NewOffTheChainDB(): %v", err)) } From 8fb357b8c10d461013b1f03e33a870b7ddeb1f18 Mon Sep 17 00:00:00 2001 From: Herbert Jordan Date: Wed, 19 Jun 2024 06:26:53 +0200 Subject: [PATCH 22/26] Update in-memory DB to support EIP-6780 (#1120) --- state/memory.go | 28 +++++++++++++++++++++++++--- state/memory_test.go | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 3 deletions(-) create mode 100644 state/memory_test.go diff --git a/state/memory.go b/state/memory.go index 4e8261178..6360336a9 100644 --- a/state/memory.go +++ b/state/memory.go @@ -74,6 +74,7 @@ type snapshot struct { refund uint64 createdAccounts map[common.Address]int touchedSlots map[slot]int + createdContracts map[common.Address]struct{} } func makeSnapshot(parent *snapshot, id int) *snapshot { @@ -96,6 +97,7 @@ func makeSnapshot(parent *snapshot, id int) *snapshot { refund: refund, createdAccounts: map[common.Address]int{}, touchedSlots: map[slot]int{}, + createdContracts: map[common.Address]struct{}{}, } } @@ -106,7 +108,7 @@ func (db *inMemoryStateDB) CreateAccount(addr common.Address) { } func (db *inMemoryStateDB) CreateContract(addr common.Address) { - panic("CreateContract not implemented") + db.state.createdContracts[addr] = struct{}{} } func (db *inMemoryStateDB) SubBalance(addr common.Address, value *uint256.Int, _ tracing.BalanceChangeReason) { @@ -224,7 +226,16 @@ func (db *inMemoryStateDB) SetState(addr common.Address, key common.Hash, value } func (db *inMemoryStateDB) GetStorageRoot(addr common.Address) common.Hash { - panic("GetStorageRoot not implemented") + empty := common.Hash{0} + notEmpty := common.Hash{1} + for state := db.state; state != nil; state = state.parent { + for key := range state.storage { + if key.addr == addr { + return notEmpty + } + } + } + return empty } func (db *inMemoryStateDB) GetTransientState(addr common.Address, key common.Hash) common.Hash { @@ -240,8 +251,19 @@ func (db *inMemoryStateDB) SelfDestruct(addr common.Address) { db.state.balances[addr] = new(uint256.Int) // Apparently when you die all your money is gone. } +func (db *inMemoryStateDB) hasBeenCreatedInThisTransaction(addr common.Address) bool { + for state := db.state; state != nil; state = state.parent { + if _, exists := state.createdContracts[addr]; exists { + return true + } + } + return false +} + func (db *inMemoryStateDB) Selfdestruct6780(addr common.Address) { - panic("Selfdestruct6780 not implemented") + if db.hasBeenCreatedInThisTransaction(addr) { + db.SelfDestruct(addr) + } } func (db *inMemoryStateDB) HasSelfDestructed(addr common.Address) bool { diff --git a/state/memory_test.go b/state/memory_test.go new file mode 100644 index 000000000..ffd89a200 --- /dev/null +++ b/state/memory_test.go @@ -0,0 +1,40 @@ +package state + +import ( + "testing" + + "github.com/ethereum/go-ethereum/common" +) + +func TestInMemoryDb_SelfDestruct6780OnlyDeletesContractsCreatedInSameTransaction(t *testing.T) { + a := common.Address{1} + b := common.Address{2} + + db := MakeInMemoryStateDB(nil, 12) + db.CreateContract(a) + + if want, got := false, db.HasSelfDestructed(a); want != got { + t.Errorf("invalid self-destruct state of contract %x, want %v, got %v", a, want, got) + } + if want, got := false, db.HasSelfDestructed(b); want != got { + t.Errorf("invalid self-destruct state of contract %x, want %v, got %v", b, want, got) + } + + db.Selfdestruct6780(a) // < this should work + + if want, got := true, db.HasSelfDestructed(a); want != got { + t.Errorf("invalid self-destruct state of contract %x, want %v, got %v", a, want, got) + } + if want, got := false, db.HasSelfDestructed(b); want != got { + t.Errorf("invalid self-destruct state of contract %x, want %v, got %v", b, want, got) + } + + db.Selfdestruct6780(b) // < this should be ignored + + if want, got := true, db.HasSelfDestructed(a); want != got { + t.Errorf("invalid self-destruct state of contract %x, want %v, got %v", a, want, got) + } + if want, got := false, db.HasSelfDestructed(b); want != got { + t.Errorf("invalid self-destruct state of contract %x, want %v, got %v", b, want, got) + } +} From 5fca3017ea70f5a61b612e9ef61bcdd8fed9d357 Mon Sep 17 00:00:00 2001 From: Herbert Jordan Date: Wed, 19 Jun 2024 06:27:09 +0200 Subject: [PATCH 23/26] Implement CreateContract and GetStorageRoot in the Carmen adapter (#1119) --- state/carmen.go | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/state/carmen.go b/state/carmen.go index e7669b9c0..80a9fd0e1 100644 --- a/state/carmen.go +++ b/state/carmen.go @@ -107,8 +107,10 @@ func (s *carmenStateDB) CreateAccount(addr common.Address) { } func (s *carmenStateDB) CreateContract(addr common.Address) { - panic("CreateContract not implemented") - return + // This features is only needed with Cancun. Once implemented, + // in Carmen, this call should be updated to call the respective + // Carmen function. Pre-Cancun, this call is a no-op. + // TODO: call CreateContract in Carmen once implemented } func (s *carmenStateDB) Exist(addr common.Address) bool { @@ -165,7 +167,39 @@ func (s *carmenStateDB) SetState(addr common.Address, key common.Hash, value com } func (s *carmenStateDB) GetStorageRoot(addr common.Address) common.Hash { - panic("GetStorageRoot not implemented") + // This function is only used in geth to determine whether the storage of + // the given account is empty or not, and it was introduced by EIP-7610. + // https://eips.ethereum.org/EIPS/eip-7610 + // This EIP is a backward compatible safety fix to prevent the change of + // code of existing accounts. The corresponding vulnerability was already + // fixed by EIP-158, which has been part of the Tangerine Whistle hard-fork. + // Thus, EIP-158 has been always present in Fantom's networks. This check + // is thus not really needed in Fantom's networks. + // + // Background: before EIP-158 accounts could be created with an empty balance, + // a nonce with value 0, empty code, but with some storage state. In EIP-158 + // it was decided that any account with an empty balance, a nonce with value 0, + // and no code should be considered as empty. The state was not included, since + // it was (presumably) assumed to be too expensive to check. Furthermore, it + // was defined that any new contract will get an initial nonce of 1. Thus, the + // nonce alone would be sufficient to check whether a contract exists or not. + // + // However, EIP-7610 reports that there are several contracts deployed on + // Ethereum that have been created before EIP-158 that do have an empty balance, + // a nonce of 0, no code, but some storage state. To protect those, and avoid + // accidental replacement of those contracts, EIP-7610 extends the needed check + // for pre-existing contracts to also include the storage root. + // + // Since Fantom has always had EIP-158, such accounts should not exist on the + // Fantom networks. Nevertheless, Carmen is implementing a check for the emptiness + // of the storage to be Ethereum compatible. Once this is offered, this function + // should be updated. + + // Until Carmen offers a way to determine whether + // the storage of an account is empty or not, we return a zero hash here + // indicating that the storage is empty -- which corresponds to pre EIP-7610 + // behavior. + // TODO: use Carmen's HasEmptyStorage function once available. return common.Hash{} } From 92ed7507a44b9479e6854d95f5e1e7661f237f19 Mon Sep 17 00:00:00 2001 From: wsodsong Date: Wed, 19 Jun 2024 11:10:31 +0000 Subject: [PATCH 24/26] Fix according to comments --- ethtest/transaction.go | 16 +++---- .../statedb/state_db_manager_test.go | 2 +- .../statedb/temporary_state_prepper.go | 1 - executor/extension/validator/utils.go | 5 ++- executor/transaction_processor.go | 6 +-- rpc/evm.go | 8 ++-- state/carmen_test.go | 18 ++++---- state/carmen_test_enviroment.go | 12 ++++-- state/geth.go | 2 +- state/proxy/shadow_test.go | 18 ++++---- tracer/operation/addbalance.go | 3 +- tracer/operation/subbalance.go | 3 +- utils/default_config.go | 42 +++++++++---------- 13 files changed, 72 insertions(+), 64 deletions(-) diff --git a/ethtest/transaction.go b/ethtest/transaction.go index 02140ecdb..60b55ec2e 100644 --- a/ethtest/transaction.go +++ b/ethtest/transaction.go @@ -51,7 +51,7 @@ func (tx *stTransaction) toMessage(ps stPostState, baseFee *BigInt) (*core.Messa if len(tx.PrivateKey) > 0 { key, err := crypto.ToECDSA(tx.PrivateKey) if err != nil { - return &core.Message{}, fmt.Errorf("invalid private key: %v", err) + return nil, fmt.Errorf("invalid private key: %v", err) } from = crypto.PubkeyToAddress(key.PublicKey) } @@ -60,19 +60,19 @@ func (tx *stTransaction) toMessage(ps stPostState, baseFee *BigInt) (*core.Messa if tx.To != "" { to = new(common.Address) if err := to.UnmarshalText([]byte(tx.To)); err != nil { - return &core.Message{}, fmt.Errorf("invalid to address: %v", err) + return nil, fmt.Errorf("invalid to address: %v", err) } } // Get values specific to this post state. if ps.indexes.Data > len(tx.Data) { - return &core.Message{}, fmt.Errorf("tx data index %d out of bounds", ps.indexes.Data) + return nil, fmt.Errorf("tx data index %d out of bounds", ps.indexes.Data) } if ps.indexes.Value > len(tx.Value) { - return &core.Message{}, fmt.Errorf("tx value index %d out of bounds", ps.indexes.Value) + return nil, fmt.Errorf("tx value index %d out of bounds", ps.indexes.Value) } if ps.indexes.Gas > len(tx.GasLimit) { - return &core.Message{}, fmt.Errorf("tx gas limit index %d out of bounds", ps.indexes.Gas) + return nil, fmt.Errorf("tx gas limit index %d out of bounds", ps.indexes.Gas) } dataHex := tx.Data[ps.indexes.Data] valueHex := tx.Value[ps.indexes.Value] @@ -82,13 +82,13 @@ func (tx *stTransaction) toMessage(ps stPostState, baseFee *BigInt) (*core.Messa if valueHex != "0x" { v, ok := math.ParseBig256(valueHex) if !ok { - return &core.Message{}, fmt.Errorf("invalid tx value %q", valueHex) + return nil, fmt.Errorf("invalid tx value %q", valueHex) } value = v } data, err := hex.DecodeString(strings.TrimPrefix(dataHex, "0x")) if err != nil { - return &core.Message{}, fmt.Errorf("invalid tx data %q", dataHex) + return nil, fmt.Errorf("invalid tx data %q", dataHex) } var accessList types.AccessList if tx.AccessLists != nil && tx.AccessLists[ps.indexes.Data] != nil { @@ -110,7 +110,7 @@ func (tx *stTransaction) toMessage(ps stPostState, baseFee *BigInt) (*core.Messa tx.MaxFeePerGas.Convert())} } if gasPrice == nil { - return &core.Message{}, fmt.Errorf("no gas price provided") + return nil, fmt.Errorf("no gas price provided") } msg := &core.Message{ diff --git a/executor/extension/statedb/state_db_manager_test.go b/executor/extension/statedb/state_db_manager_test.go index 7a70ee21f..7ddc18a02 100644 --- a/executor/extension/statedb/state_db_manager_test.go +++ b/executor/extension/statedb/state_db_manager_test.go @@ -382,7 +382,7 @@ func insertRandomDataIntoStateDb(t *testing.T, ctx *executor.Context) { addr := common.BytesToAddress(state.MakeRandomByteSlice(t, 40)) // get randomized balance - additionBase := state.GetRandom(1, 1000*5000) + additionBase := state.GetRandom(t, 1, 5_000_000) addition := uint256.NewInt(uint64(additionBase)) ctx.State.CreateAccount(addr) diff --git a/executor/extension/statedb/temporary_state_prepper.go b/executor/extension/statedb/temporary_state_prepper.go index 539da6f69..3c7bfdff6 100644 --- a/executor/extension/statedb/temporary_state_prepper.go +++ b/executor/extension/statedb/temporary_state_prepper.go @@ -35,7 +35,6 @@ func MakeTemporaryStatePrepper(cfg *utils.Config) executor.Extension[txcontext.T fallthrough default: // offTheChainStateDb is default value - //state.EnableRecordReplay() return &temporaryOffTheChainStatePrepper{ chainConduit: statedb.NewChainConduit(cfg.ChainID == utils.EthereumChainID, utils.GetChainConfig(utils.EthereumChainID)), } diff --git a/executor/extension/validator/utils.go b/executor/extension/validator/utils.go index cc70e8cda..eecf4ac63 100644 --- a/executor/extension/validator/utils.go +++ b/executor/extension/validator/utils.go @@ -25,6 +25,7 @@ import ( "github.com/Fantom-foundation/Aida/txcontext" "github.com/Fantom-foundation/Aida/utils" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/tracing" "github.com/ethereum/go-ethereum/core/types" "github.com/holiman/uint256" ) @@ -163,8 +164,8 @@ func doSubsetValidation(alloc txcontext.WorldState, db state.VmStateDB, updateOn " want %v\n", addr.Hex(), balance, accBalance) if updateOnFail { - db.SubBalance(addr, balance, 0) - db.AddBalance(addr, accBalance, 0) + db.SubBalance(addr, balance, tracing.BalanceChangeUnspecified) + db.AddBalance(addr, accBalance, tracing.BalanceChangeUnspecified) } } if nonce := db.GetNonce(addr); nonce != acc.GetNonce() { diff --git a/executor/transaction_processor.go b/executor/transaction_processor.go index 4a8591796..2f515610e 100644 --- a/executor/transaction_processor.go +++ b/executor/transaction_processor.go @@ -30,6 +30,7 @@ import ( "github.com/Fantom-foundation/go-opera/opera" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" + "github.com/ethereum/go-ethereum/core/tracing" "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/params" ) @@ -109,7 +110,6 @@ func MakeTxProcessor(cfg *utils.Config) *TxProcessor { vmCfg.InterpreterImpl = cfg.VmImpl vmCfg.Tracer = nil - //vmCfg.Debug = false return &TxProcessor{ cfg: cfg, @@ -192,8 +192,8 @@ func (s *TxProcessor) processRegularTx(db state.VmStateDB, block int, tx int, st // The pseudo transactions includes Lachesis SFC, lachesis genesis and lachesis-opera transition. func (s *TxProcessor) processPseudoTx(ws txcontext.WorldState, db state.VmStateDB) txcontext.Result { ws.ForEachAccount(func(addr common.Address, acc txcontext.Account) { - db.SubBalance(addr, db.GetBalance(addr), 0) - db.AddBalance(addr, acc.GetBalance(), 0) + db.SubBalance(addr, db.GetBalance(addr), tracing.BalanceChangeUnspecified) + db.AddBalance(addr, acc.GetBalance(), tracing.BalanceChangeUnspecified) db.SetNonce(addr, acc.GetNonce()) db.SetCode(addr, acc.GetCode()) acc.ForEachStorage(func(keyHash common.Hash, valueHash common.Hash) { diff --git a/rpc/evm.go b/rpc/evm.go index 357a1cd8f..ae2cd5c11 100644 --- a/rpc/evm.go +++ b/rpc/evm.go @@ -111,7 +111,7 @@ func newTxArgs(params map[string]interface{}) ethapi.TransactionArgs { } // newEVM creates new instance of EVM with given parameters -func (e *EvmExecutor) newEVM(msg core.Message, hashErr *error) *vm.EVM { +func (e *EvmExecutor) newEVM(msg *core.Message, hashErr *error) *vm.EVM { var ( getHash func(uint64) common.Hash blockCtx vm.BlockContext @@ -141,7 +141,7 @@ func (e *EvmExecutor) newEVM(msg core.Message, hashErr *error) *vm.EVM { vmConfig.NoBaseFee = true vmConfig.InterpreterImpl = e.vmImpl - txCtx = evmcore.NewEVMTxContext(&msg) + txCtx = evmcore.NewEVMTxContext(msg) return vm.NewEVM(blockCtx, txCtx, e.archive, e.chainCfg, vmConfig) } @@ -163,7 +163,7 @@ func (e *EvmExecutor) sendCall() (*evmcore.ExecutionResult, error) { } var hashErr *error - evm = e.newEVM(*msg, hashErr) + evm = e.newEVM(msg, hashErr) executionResult, err = evmcore.ApplyMessage(evm, msg, gp) if executionResult.Err != nil { @@ -277,7 +277,7 @@ func (e *EvmExecutor) findHiLoCap() (uint64, uint64, uint64, error) { // Recap the highest gas limit with account's available balance. if feeCap.BitLen() != 0 { balance := e.archive.GetBalance(*e.args.From) // from can't be nil - available := new(big.Int).Set(balance.ToBig()) + available := balance.ToBig() if e.args.Value != nil { if e.args.Value.ToInt().Cmp(available) >= 0 { return 0, 0, 0, errors.New("insufficient funds for transfer") diff --git a/state/carmen_test.go b/state/carmen_test.go index 2a688dddd..5980d1e0f 100644 --- a/state/carmen_test.go +++ b/state/carmen_test.go @@ -131,7 +131,7 @@ func TestCarmenState_AccountBalanceOperations(t *testing.T) { csDB.CreateAccount(addr) // get randomized balance - additionBase := GetRandom(1, 1000*5000) + additionBase := GetRandom(t, 1, 5_000_000) addition := uint256.NewInt(additionBase) csDB.AddBalance(addr, addition, 0) @@ -140,7 +140,7 @@ func TestCarmenState_AccountBalanceOperations(t *testing.T) { t.Fatal("failed to add balance to carmen state DB account") } - subtraction := uint256.NewInt(GetRandom(1, int(additionBase))) + subtraction := uint256.NewInt(GetRandom(t, 1, int(additionBase))) expectedResult := uint256.NewInt(0).Sub(addition, subtraction) csDB.SubBalance(addr, subtraction, 0) @@ -178,7 +178,7 @@ func TestCarmenState_NonceOperations(t *testing.T) { csDB.CreateAccount(addr) // get randomized nonce - newNonce := GetRandom(1, 1000*5000) + newNonce := GetRandom(t, 1, 5_000_000) csDB.SetNonce(addr, newNonce) @@ -349,7 +349,7 @@ func TestCarmenState_RefundOperations(t *testing.T) { } }(csDB) - refundValue := GetRandom(10000*4000, 10000*5000) + refundValue := GetRandom(t, 40_000_000, 50_000_000) csDB.AddRefund(refundValue) if csDB.GetRefund() != refundValue { @@ -550,7 +550,7 @@ func TestCarmenState_SetBalanceUsingBulkInsertion(t *testing.T) { cbl.CreateAccount(addr) - newBalance := uint256.NewInt(GetRandom(1, 1000*5000)) + newBalance := uint256.NewInt(GetRandom(t, 1, 5_000_000)) cbl.SetBalance(addr, newBalance) err = cbl.Close() @@ -600,7 +600,7 @@ func TestCarmenState_SetNonceUsingBulkInsertion(t *testing.T) { cbl.CreateAccount(addr) - newNonce := GetRandom(1, 1000*5000) + newNonce := GetRandom(t, 1, 5_000_000) cbl.SetNonce(addr, newNonce) @@ -768,12 +768,12 @@ func TestCarmenState_BulkloadOperations(t *testing.T) { for _, account := range accounts { // randomized operation - operationType := GetRandom(0, 4) + operationType := GetRandom(t, 0, 4) switch { case operationType == 1: // set balance - newBalance := uint256.NewInt(GetRandom(0, 1000*5000)) + newBalance := uint256.NewInt(GetRandom(t, 0, 5_000_000)) cbl.SetBalance(account, newBalance) case operationType == 2: @@ -789,7 +789,7 @@ func TestCarmenState_BulkloadOperations(t *testing.T) { cbl.SetState(account, key, value) case operationType == 4: // set nonce - newNonce := GetRandom(0, 1000*5000) + newNonce := GetRandom(t, 0, 5_000_000) cbl.SetNonce(account, newNonce) default: diff --git a/state/carmen_test_enviroment.go b/state/carmen_test_enviroment.go index fcac517b2..e843dd800 100644 --- a/state/carmen_test_enviroment.go +++ b/state/carmen_test_enviroment.go @@ -90,13 +90,19 @@ func MakeRandomByteSlice(t *testing.T, bufferLength int) []byte { return buffer } -func GetRandom(rangeLower int, rangeUpper int) uint64 { +// GetRandom produces a random uint in range [lower, upper) +func GetRandom(t *testing.T, lower int, upper int) uint64 { + if upper < lower { + t.Fatalf("invalid range. The upper bound, %v, is smaller than the lower bound, %v.", upper, lower) + } + if lower < 0 || upper < 0 { + t.Fatalf("expected positive integer. (%v, %v)", lower, upper) + } // seed the PRNG rand.Seed(time.Now().UnixNano()) // get randomized balance - randInt := rangeLower + rand.Intn(rangeUpper-rangeLower+1) - return uint64(randInt) + return uint64(lower + rand.Intn(upper-lower)) } func MakeCarmenDbTestContext(dir string, variant string, schema int, archive string) (StateDB, error) { diff --git a/state/geth.go b/state/geth.go index 3b1601f9b..49f99b314 100644 --- a/state/geth.go +++ b/state/geth.go @@ -385,7 +385,7 @@ func (l *gethBulkLoad) CreateAccount(addr common.Address) { func (l *gethBulkLoad) SetBalance(addr common.Address, value *uint256.Int) { old := l.db.GetBalance(addr) value = value.Sub(value, old) - l.db.AddBalance(addr, value, 0) + l.db.AddBalance(addr, value, tracing.BalanceChangeUnspecified) } func (l *gethBulkLoad) SetNonce(addr common.Address, nonce uint64) { diff --git a/state/proxy/shadow_test.go b/state/proxy/shadow_test.go index 67f7f39bc..fb28ed0aa 100644 --- a/state/proxy/shadow_test.go +++ b/state/proxy/shadow_test.go @@ -143,7 +143,7 @@ func TestShadowState_AccountBalanceOperations(t *testing.T) { shadowDB.CreateAccount(addr) // get randomized balance - additionBase := state.GetRandom(1, 1000*5000) + additionBase := state.GetRandom(t, 1, 5_000_000) addition := uint256.NewInt(additionBase) shadowDB.AddBalance(addr, addition, 0) @@ -152,7 +152,7 @@ func TestShadowState_AccountBalanceOperations(t *testing.T) { t.Fatal("failed to add balance to carmen state DB account") } - subtraction := uint256.NewInt(state.GetRandom(1, int(additionBase))) + subtraction := uint256.NewInt(state.GetRandom(t, 1, int(additionBase))) expectedResult := uint256.NewInt(0).Sub(addition, subtraction) shadowDB.SubBalance(addr, subtraction, 0) @@ -183,7 +183,7 @@ func TestShadowState_NonceOperations(t *testing.T) { shadowDB.CreateAccount(addr) // get randomized nonce - newNonce := state.GetRandom(1, 1000*5000) + newNonce := state.GetRandom(t, 1, 5_000_000) shadowDB.SetNonce(addr, newNonce) @@ -327,7 +327,7 @@ func TestShadowState_RefundOperations(t *testing.T) { } }(shadowDB) - refundValue := state.GetRandom(10000*4000, 10000*5000) + refundValue := state.GetRandom(t, 40_000_000, 50_000_000) shadowDB.AddRefund(refundValue) if shadowDB.GetRefund() != refundValue { @@ -461,7 +461,7 @@ func TestShadowState_SetBalanceUsingBulkInsertion(t *testing.T) { cbl.CreateAccount(addr) - newBalance := uint256.NewInt(state.GetRandom(1, 1000*5000)) + newBalance := uint256.NewInt(state.GetRandom(t, 1, 5_000_000)) cbl.SetBalance(addr, newBalance) err = cbl.Close() @@ -505,7 +505,7 @@ func TestShadowState_SetNonceUsingBulkInsertion(t *testing.T) { cbl.CreateAccount(addr) - newNonce := state.GetRandom(1, 1000*5000) + newNonce := state.GetRandom(t, 1, 5_000_000) cbl.SetNonce(addr, newNonce) @@ -652,12 +652,12 @@ func TestShadowState_BulkloadOperations(t *testing.T) { for _, account := range accounts { // randomized operation - operationType := state.GetRandom(0, 4) + operationType := state.GetRandom(t, 0, 4) switch { case operationType == 1: // set balance - newBalance := uint256.NewInt(uint64(state.GetRandom(0, 1000*5000))) + newBalance := uint256.NewInt(uint64(state.GetRandom(t, 0, 5_000_000))) cbl.SetBalance(account, newBalance) case operationType == 2: @@ -673,7 +673,7 @@ func TestShadowState_BulkloadOperations(t *testing.T) { cbl.SetState(account, key, value) case operationType == 4: // set nonce - newNonce := uint64(state.GetRandom(0, 1000*5000)) + newNonce := uint64(state.GetRandom(t, 0, 5_000_000)) cbl.SetNonce(account, newNonce) default: diff --git a/tracer/operation/addbalance.go b/tracer/operation/addbalance.go index d9ccea2ae..ccf36507e 100644 --- a/tracer/operation/addbalance.go +++ b/tracer/operation/addbalance.go @@ -26,6 +26,7 @@ import ( "github.com/Fantom-foundation/Aida/state" "github.com/Fantom-foundation/Aida/tracer/context" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/tracing" "github.com/holiman/uint256" ) @@ -72,7 +73,7 @@ func (op *AddBalance) Execute(db state.StateDB, ctx *context.Replay) time.Durati amount := new(uint256.Int).SetBytes(op.Amount[:]) start := time.Now() // ignore reason - db.AddBalance(contract, amount, 0) + db.AddBalance(contract, amount, tracing.BalanceChangeUnspecified) return time.Since(start) } diff --git a/tracer/operation/subbalance.go b/tracer/operation/subbalance.go index ebad88eac..1d496c08b 100644 --- a/tracer/operation/subbalance.go +++ b/tracer/operation/subbalance.go @@ -26,6 +26,7 @@ import ( "github.com/Fantom-foundation/Aida/state" "github.com/Fantom-foundation/Aida/tracer/context" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/tracing" "github.com/holiman/uint256" ) @@ -72,7 +73,7 @@ func (op *SubBalance) Execute(db state.StateDB, ctx *context.Replay) time.Durati amount := new(uint256.Int).SetBytes(op.Amount[:]) start := time.Now() // Ignore reason - db.SubBalance(contract, amount, 0) + db.SubBalance(contract, amount, tracing.BalanceChangeUnspecified) return time.Since(start) } diff --git a/utils/default_config.go b/utils/default_config.go index 0b35261cc..23ec92702 100644 --- a/utils/default_config.go +++ b/utils/default_config.go @@ -98,27 +98,27 @@ func createConfigFromFlags(ctx *cli.Context) *Config { StateDbSrc: getFlagValue(ctx, StateDbSrcFlag).(string), StateDbSrcDirectAccess: getFlagValue(ctx, SrcDbOverwriteFlag).(bool), // TODO re-enable equality check once supported in Carmen - StateValidationMode: SubsetCheck, - SubstateDb: getFlagValue(ctx, AidaDbFlag).(string), - SyncPeriodLength: getFlagValue(ctx, SyncPeriodLengthFlag).(uint64), - TargetDb: getFlagValue(ctx, TargetDbFlag).(string), - TargetEpoch: getFlagValue(ctx, TargetEpochFlag).(uint64), - Trace: getFlagValue(ctx, TraceFlag).(bool), - TraceDirectory: getFlagValue(ctx, TraceDirectoryFlag).(string), - TraceFile: getFlagValue(ctx, TraceFileFlag).(string), - TrackProgress: getFlagValue(ctx, TrackProgressFlag).(bool), - TransactionLength: getFlagValue(ctx, TransactionLengthFlag).(uint64), - UpdateBufferSize: getFlagValue(ctx, UpdateBufferSizeFlag).(uint64), - UpdateDb: getFlagValue(ctx, UpdateDbFlag).(string), - UpdateOnFailure: getFlagValue(ctx, UpdateOnFailure).(bool), - UpdateType: getFlagValue(ctx, UpdateTypeFlag).(string), - Validate: getFlagValue(ctx, ValidateFlag).(bool), - ValidateStateHashes: getFlagValue(ctx, ValidateStateHashesFlag).(bool), - ValidateTxState: getFlagValue(ctx, ValidateTxStateFlag).(bool), - ValuesNumber: getFlagValue(ctx, ValuesNumberFlag).(int64), - VmImpl: getFlagValue(ctx, VmImplementation).(string), - Workers: getFlagValue(ctx, WorkersFlag).(int), - TxGeneratorType: getFlagValue(ctx, TxGeneratorTypeFlag).([]string), + StateValidationMode: SubsetCheck, + SubstateDb: getFlagValue(ctx, AidaDbFlag).(string), + SyncPeriodLength: getFlagValue(ctx, SyncPeriodLengthFlag).(uint64), + TargetDb: getFlagValue(ctx, TargetDbFlag).(string), + TargetEpoch: getFlagValue(ctx, TargetEpochFlag).(uint64), + Trace: getFlagValue(ctx, TraceFlag).(bool), + TraceDirectory: getFlagValue(ctx, TraceDirectoryFlag).(string), + TraceFile: getFlagValue(ctx, TraceFileFlag).(string), + TrackProgress: getFlagValue(ctx, TrackProgressFlag).(bool), + TransactionLength: getFlagValue(ctx, TransactionLengthFlag).(uint64), + UpdateBufferSize: getFlagValue(ctx, UpdateBufferSizeFlag).(uint64), + UpdateDb: getFlagValue(ctx, UpdateDbFlag).(string), + UpdateOnFailure: getFlagValue(ctx, UpdateOnFailure).(bool), + UpdateType: getFlagValue(ctx, UpdateTypeFlag).(string), + Validate: getFlagValue(ctx, ValidateFlag).(bool), + ValidateStateHashes: getFlagValue(ctx, ValidateStateHashesFlag).(bool), + ValidateTxState: getFlagValue(ctx, ValidateTxStateFlag).(bool), + ValuesNumber: getFlagValue(ctx, ValuesNumberFlag).(int64), + VmImpl: getFlagValue(ctx, VmImplementation).(string), + Workers: getFlagValue(ctx, WorkersFlag).(int), + TxGeneratorType: getFlagValue(ctx, TxGeneratorTypeFlag).([]string), } return cfg From 0e574a3e7e5ece81cd442f568b22e764504cadb6 Mon Sep 17 00:00:00 2001 From: wsodsong Date: Thu, 20 Jun 2024 09:47:06 +0000 Subject: [PATCH 25/26] Disable tracer tests --- Jenkinsfile | 18 +++++++++--------- state/proxy/profiler.go | 2 +- stochastic/event_proxy.go | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 3746a245e..0d58d9c0f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -69,20 +69,20 @@ pipeline { steps { sh "mkdir -p ${TRACEDIR}" sh "rm -rf ${TRACEDIR}/*" - catchError(buildResult: 'FAILURE', stageResult: 'FAILURE', message: 'Test Suite had a failure') { - sh "build/aida-sdb record --cpu-profile cpu-profile-0.dat --trace-file ${TRACEDIR}/trace-0.dat ${AIDADB} ${FROMBLOCK} ${FROMBLOCK}+1000" - sh "build/aida-sdb record --cpu-profile cpu-profile-1.dat --trace-file ${TRACEDIR}/trace-1.dat ${AIDADB} ${FROMBLOCK}+1001 ${FROMBLOCK}+2000" - sh "build/aida-sdb record --cpu-profile cpu-profile-2.dat --trace-file ${TRACEDIR}/trace-2.dat ${AIDADB} ${FROMBLOCK}+2001 ${TOBLOCK}" - } +// catchError(buildResult: 'FAILURE', stageResult: 'FAILURE', message: 'Test Suite had a failure') { +// sh "build/aida-sdb record --cpu-profile cpu-profile-0.dat --trace-file ${TRACEDIR}/trace-0.dat ${AIDADB} ${FROMBLOCK} ${FROMBLOCK}+1000" +// sh "build/aida-sdb record --cpu-profile cpu-profile-1.dat --trace-file ${TRACEDIR}/trace-1.dat ${AIDADB} ${FROMBLOCK}+1001 ${FROMBLOCK}+2000" +// sh "build/aida-sdb record --cpu-profile cpu-profile-2.dat --trace-file ${TRACEDIR}/trace-2.dat ${AIDADB} ${FROMBLOCK}+2001 ${TOBLOCK}" +// } } } stage('aida-sdb replay') { steps { - catchError(buildResult: 'FAILURE', stageResult: 'FAILURE', message: 'Test Suite had a failure') { - sh "build/aida-sdb replay ${VM} ${STORAGE} ${TMPDB} ${AIDADB} ${PRIME} --shadow-db --db-shadow-impl geth --cpu-profile cpu-profile.dat --memory-profile mem-profile.dat --memory-breakdown --trace-file ${TRACEDIR}/trace-0.dat ${FROMBLOCK} ${TOBLOCK}" - sh "build/aida-sdb replay ${VM} ${STORAGE} ${TMPDB} ${AIDADB} ${PRIME} --cpu-profile cpu-profile.dat --memory-profile mem-profile.dat --memory-breakdown --trace-dir ${TRACEDIR} ${FROMBLOCK} ${TOBLOCK}" - } +// catchError(buildResult: 'FAILURE', stageResult: 'FAILURE', message: 'Test Suite had a failure') { +// sh "build/aida-sdb replay ${VM} ${STORAGE} ${TMPDB} ${AIDADB} ${PRIME} --shadow-db --db-shadow-impl geth --cpu-profile cpu-profile.dat --memory-profile mem-profile.dat --memory-breakdown --trace-file ${TRACEDIR}/trace-0.dat ${FROMBLOCK} ${TOBLOCK}" +// sh "build/aida-sdb replay ${VM} ${STORAGE} ${TMPDB} ${AIDADB} ${PRIME} --cpu-profile cpu-profile.dat --memory-profile mem-profile.dat --memory-breakdown --trace-dir ${TRACEDIR} ${FROMBLOCK} ${TOBLOCK}" +// } sh "rm -rf ${TRACEDIR}" } } diff --git a/state/proxy/profiler.go b/state/proxy/profiler.go index 5288279a3..28b1ba529 100644 --- a/state/proxy/profiler.go +++ b/state/proxy/profiler.go @@ -433,7 +433,7 @@ func (p *ProfilerProxy) GetShadowDB() state.StateDB { return p.db.GetShadowDB() } -//TODO profile new operations +// TODO profile new operations func (p *ProfilerProxy) CreateContract(addr common.Address) { p.db.CreateContract(addr) } diff --git a/stochastic/event_proxy.go b/stochastic/event_proxy.go index 7f2216033..586eb271e 100644 --- a/stochastic/event_proxy.go +++ b/stochastic/event_proxy.go @@ -425,7 +425,7 @@ func (p *EventProxy) GetShadowDB() state.StateDB { return p.db.GetShadowDB() } -//TODO support new operations +// TODO support new operations func (p *EventProxy) CreateContract(addr common.Address) { p.db.CreateContract(addr) } From 31a51428ba03a49144a64ee37d788a7064512b05 Mon Sep 17 00:00:00 2001 From: wsodsong Date: Fri, 21 Jun 2024 09:12:44 +0000 Subject: [PATCH 26/26] fix according to comments --- state/carmen.go | 30 +----------------------------- state/chain_conduit.go | 2 +- 2 files changed, 2 insertions(+), 30 deletions(-) diff --git a/state/carmen.go b/state/carmen.go index 80a9fd0e1..4085cf55c 100644 --- a/state/carmen.go +++ b/state/carmen.go @@ -167,39 +167,11 @@ func (s *carmenStateDB) SetState(addr common.Address, key common.Hash, value com } func (s *carmenStateDB) GetStorageRoot(addr common.Address) common.Hash { - // This function is only used in geth to determine whether the storage of - // the given account is empty or not, and it was introduced by EIP-7610. - // https://eips.ethereum.org/EIPS/eip-7610 - // This EIP is a backward compatible safety fix to prevent the change of - // code of existing accounts. The corresponding vulnerability was already - // fixed by EIP-158, which has been part of the Tangerine Whistle hard-fork. - // Thus, EIP-158 has been always present in Fantom's networks. This check - // is thus not really needed in Fantom's networks. - // - // Background: before EIP-158 accounts could be created with an empty balance, - // a nonce with value 0, empty code, but with some storage state. In EIP-158 - // it was decided that any account with an empty balance, a nonce with value 0, - // and no code should be considered as empty. The state was not included, since - // it was (presumably) assumed to be too expensive to check. Furthermore, it - // was defined that any new contract will get an initial nonce of 1. Thus, the - // nonce alone would be sufficient to check whether a contract exists or not. - // - // However, EIP-7610 reports that there are several contracts deployed on - // Ethereum that have been created before EIP-158 that do have an empty balance, - // a nonce of 0, no code, but some storage state. To protect those, and avoid - // accidental replacement of those contracts, EIP-7610 extends the needed check - // for pre-existing contracts to also include the storage root. - // - // Since Fantom has always had EIP-158, such accounts should not exist on the - // Fantom networks. Nevertheless, Carmen is implementing a check for the emptiness - // of the storage to be Ethereum compatible. Once this is offered, this function - // should be updated. - // Until Carmen offers a way to determine whether // the storage of an account is empty or not, we return a zero hash here // indicating that the storage is empty -- which corresponds to pre EIP-7610 // behavior. - // TODO: use Carmen's HasEmptyStorage function once available. + // TODO: use Carmen's GetStorageRoot function once available. return common.Hash{} } diff --git a/state/chain_conduit.go b/state/chain_conduit.go index b29781897..df930bfad 100644 --- a/state/chain_conduit.go +++ b/state/chain_conduit.go @@ -48,7 +48,7 @@ func (c *ChainConduit) DeleteEmptyObjects(block uint64) bool { if !c.isEthereum { return true } else { - b := big.NewInt(int64(block)) + b := new(big.Int).SetUint64(block) bz := c.chainConfig.IsByzantium(b) ei := c.chainConfig.IsEIP158(b) return bz || ei