diff --git a/.gitignore b/.gitignore
index 03b20e2..29cd92d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -26,7 +26,6 @@ yarn-error.log*
/.vscode
.gitsigners
-4bytes/
chains/
topic0/
diff --git a/Dockerfile b/Dockerfile
index ac412a0..49ff124 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,104 +1,42 @@
+# syntax=docker/dockerfile-upstream:master-labs
FROM node:16.16.0-alpine3.15 AS builder
+
+RUN apk add git subversion rsync
WORKDIR /otterscan-build
COPY ["package.json", "package-lock.json", "/otterscan-build/"]
RUN npm install
-COPY ["run-nginx.sh", "tsconfig.json", "tsconfig.node.json", "postcss.config.js", "tailwind.config.js", "vite.config.ts", "index.html", "/otterscan-build/"]
+COPY ["tsconfig.json", "tsconfig.node.json", "postcss.config.js", "tailwind.config.js", "vite.config.ts", "index.html", "/otterscan-build/"]
COPY ["public", "/otterscan-build/public/"]
COPY ["src", "/otterscan-build/src/"]
-RUN npm run build
+RUN npm run fullbuild
FROM alpine:3.15.0 AS logobuilder
-RUN apk add imagemagick parallel
-WORKDIR /assets
-COPY trustwallet/blockchains/ethereum/assets /assets/1/
-COPY trustwallet/blockchains/polygon/assets /assets/137/
-COPY trustwallet/blockchains/smartchain/assets /assets/56/
+RUN apk add imagemagick parallel subversion git
+WORKDIR /
+ADD https://github.com/trustwallet/assets.git /trustwallet
+RUN mkdir -p /assets/
+RUN mv /trustwallet/blockchains/ethereum/assets /assets/1/
+RUN mv /trustwallet/blockchains/polygon/assets /assets/137/
+RUN mv /trustwallet/blockchains/smartchain/assets /assets/56/
RUN find . -name logo.png | parallel magick convert {} -filter Lanczos -resize 32x32 {}; exit 0
-FROM alpine:3.15.0 AS fourbytesbuilder
-WORKDIR /signatures
-COPY 4bytes/signatures /signatures/
-COPY 4bytes/with_parameter_names /signatures/
-
-FROM alpine:3.15.0 AS topic0builder
-WORKDIR /topic0
-COPY topic0/with_parameter_names /topic0/
-
-FROM alpine:3.15.0 AS chainsbuilder
-WORKDIR /chains
-COPY chains/_data/chains /chains/
-
# Add brotli module to official nginx image
# Based on: https://github.com/nginxinc/docker-nginx/tree/master/modules
-FROM nginx:1.21.3-alpine as nginxbuilder
+FROM golang:1.19-alpine as gobuilder
+RUN apk add alpine-sdk
-RUN set -ex \
- && apk update \
- && apk add linux-headers openssl-dev pcre-dev zlib-dev openssl abuild \
- musl-dev libxslt libxml2-utils make mercurial gcc unzip git \
- xz g++ coreutils \
- # allow abuild as a root user \
- && printf "#!/bin/sh\\nSETFATTR=true /usr/bin/abuild -F \"\$@\"\\n" > /usr/local/bin/abuild \
- && chmod +x /usr/local/bin/abuild \
- && hg clone -r ${NGINX_VERSION}-${PKG_RELEASE} https://hg.nginx.org/pkg-oss/ \
- && cd pkg-oss \
- && mkdir /tmp/packages \
- && for module in "brotli"; do \
- echo "Building $module for nginx-$NGINX_VERSION"; \
- if [ -d /modules/$module ]; then \
- echo "Building $module from user-supplied sources"; \
- # check if module sources file is there and not empty
- if [ ! -s /modules/$module/source ]; then \
- echo "No source file for $module in modules/$module/source, exiting"; \
- exit 1; \
- fi; \
- # some modules require build dependencies
- if [ -f /modules/$module/build-deps ]; then \
- echo "Installing $module build dependencies"; \
- apk update && apk add $(cat /modules/$module/build-deps | xargs); \
- fi; \
- # if a module has a build dependency that is not in a distro, provide a
- # shell script to fetch/build/install those
- # note that shared libraries produced as a result of this script will
- # not be copied from the builder image to the main one so build static
- if [ -x /modules/$module/prebuild ]; then \
- echo "Running prebuild script for $module"; \
- /modules/$module/prebuild; \
- fi; \
- /pkg-oss/build_module.sh -v $NGINX_VERSION -f -y -o /tmp/packages -n $module $(cat /modules/$module/source); \
- BUILT_MODULES="$BUILT_MODULES $(echo $module | tr '[A-Z]' '[a-z]' | tr -d '[/_\-\.\t ]')"; \
- elif make -C /pkg-oss/alpine list | grep -E "^$module\s+\d+" > /dev/null; then \
- echo "Building $module from pkg-oss sources"; \
- cd /pkg-oss/alpine; \
- make abuild-module-$module BASE_VERSION=$NGINX_VERSION NGINX_VERSION=$NGINX_VERSION; \
- apk add $(. ./abuild-module-$module/APKBUILD; echo $makedepends;); \
- make module-$module BASE_VERSION=$NGINX_VERSION NGINX_VERSION=$NGINX_VERSION; \
- find ~/packages -type f -name "*.apk" -exec mv -v {} /tmp/packages/ \;; \
- BUILT_MODULES="$BUILT_MODULES $module"; \
- else \
- echo "Don't know how to build $module module, exiting"; \
- exit 1; \
- fi; \
- done \
- && echo "BUILT_MODULES=\"$BUILT_MODULES\"" > /tmp/packages/modules.env
+WORKDIR /wd
+COPY ["go.mod","go.sum","/wd/"]
+COPY cmd cmd
+RUN go build -o rpcdaemon ./cmd/rpcdaemon
+RUN go build -o server ./cmd/server
-FROM nginx:1.21.3-alpine
-COPY --from=nginxbuilder /tmp/packages /tmp/packages
-RUN set -ex \
- && . /tmp/packages/modules.env \
- && for module in $BUILT_MODULES; do \
- apk add --no-cache --allow-untrusted /tmp/packages/nginx-module-${module}-${NGINX_VERSION}*.apk; \
- done \
- && rm -rf /tmp/packages
-RUN apk update && apk add jq
-COPY --from=chainsbuilder /chains /usr/share/nginx/html/chains/
-COPY --from=topic0builder /topic0 /usr/share/nginx/html/topic0/
-COPY --from=fourbytesbuilder /signatures /usr/share/nginx/html/signatures/
-COPY --from=logobuilder /assets /usr/share/nginx/html/assets/
-COPY nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf
-COPY nginx/nginx.conf /etc/nginx/nginx.conf
-COPY --from=builder /otterscan-build/dist /usr/share/nginx/html/
-COPY --from=builder /otterscan-build/run-nginx.sh /
-WORKDIR /
+FROM alpine:3.15.0
+RUN apk add alpine-sdk
+WORKDIR /wd
+COPY --from=gobuilder /wd/rpcdaemon /usr/bin/rpcdaemon
+COPY --from=gobuilder /wd/server /usr/bin/server
+COPY --from=builder /otterscan-build/dist /wd/dist
+COPY --from=logobuilder /assets /wd/dist
-CMD ["/run-nginx.sh"]
+CMD ["server"]
diff --git a/cmd/rpcdaemon/cli/config.go b/cmd/rpcdaemon/cli/config.go
index dd8394b..52fb604 100644
--- a/cmd/rpcdaemon/cli/config.go
+++ b/cmd/rpcdaemon/cli/config.go
@@ -18,11 +18,11 @@ import (
"github.com/ledgerwatch/erigon/eth/ethconfig"
"github.com/ledgerwatch/erigon/rpc/rpccfg"
+ "github.com/ledgerwatch/erigon/turbo/debug"
+ "github.com/ledgerwatch/erigon/turbo/logging"
"github.com/wmitsuda/otterscan/cmd/rpcdaemon/cli/httpcfg"
"github.com/wmitsuda/otterscan/cmd/rpcdaemon/health"
"github.com/wmitsuda/otterscan/cmd/rpcdaemon/rpcservices"
- "github.com/wmitsuda/otterscan/erigon_internal/debug"
- "github.com/wmitsuda/otterscan/erigon_internal/logging"
"github.com/ledgerwatch/erigon-lib/direct"
"github.com/ledgerwatch/erigon-lib/gointerfaces"
diff --git a/cmd/rpcdaemon/commands/otterscan_api.go b/cmd/rpcdaemon/commands/otterscan_api.go
index 9fe130f..93e44cf 100644
--- a/cmd/rpcdaemon/commands/otterscan_api.go
+++ b/cmd/rpcdaemon/commands/otterscan_api.go
@@ -21,9 +21,11 @@ import (
"github.com/ledgerwatch/erigon/rpc"
"github.com/ledgerwatch/erigon/turbo/rpchelper"
"github.com/ledgerwatch/erigon/turbo/transactions"
+ "github.com/ledgerwatch/erigon/turbo/adapter/ethapi"
+
+
"github.com/ledgerwatch/log/v3"
- "github.com/wmitsuda/otterscan/erigon_internal/ethapi"
)
// API_LEVEL Must be incremented every time new additions are made
@@ -370,7 +372,7 @@ func (api *OtterscanAPIImpl) delegateGetBlockByNumber(tx kv.Tx, b *types.Block,
if err != nil {
return nil, err
}
- response, err := ethapi.RPCMarshalBlock(b, inclTx, inclTx)
+ response, err := ethapi.RPCMarshalBlockDeprecated(b, inclTx, inclTx)
if !inclTx {
delete(response, "transactions") // workaround for https://github.com/ledgerwatch/erigon/issues/4989#issuecomment-1218415666
}
diff --git a/cmd/server/main.go b/cmd/server/main.go
index 7e52aee..8f10b4b 100644
--- a/cmd/server/main.go
+++ b/cmd/server/main.go
@@ -4,9 +4,11 @@ import (
"log"
"net/http"
"os"
+ "path"
"strings"
"time"
+ "gfx.cafe/open/4bytes/sigs"
"github.com/go-chi/chi/v5"
"github.com/go-chi/chi/v5/middleware"
)
@@ -32,6 +34,21 @@ func main() {
r.Use(middleware.Recoverer)
r.Use(middleware.SetHeader("Access-Control-Allow-Origin", "*"))
+ r.HandleFunc("/signatures/{hash}", func(w http.ResponseWriter, r *http.Request) {
+ lookup := path.Base(r.URL.Path)
+ if len(lookup) > 8 {
+ http.Error(w, "bad path", 400)
+ return
+ }
+ sig := sigs.Hex(lookup)
+ if sig == "" {
+ http.Error(w, "not found", 404)
+ return
+ }
+ w.WriteHeader(http.StatusOK)
+ w.Write([]byte(sig))
+ })
+
FileServer(r, "/", filesDir)
s := http.Server{
diff --git a/docker-compose.yaml b/docker-compose.yaml
new file mode 100644
index 0000000..6c63b8e
--- /dev/null
+++ b/docker-compose.yaml
@@ -0,0 +1,24 @@
+version: '3.9'
+
+
+services:
+ rpcdaemon:
+ build:
+ context: .
+ command: |
+ rpcdaemon
+ --http.addr=0.0.0.0 --http.vhosts=* --http.corsdomain=* --ws
+ --http.api=eth,erigon,web3,net,trace,debug,txpool,ots
+ --metrics --metrics.addr=0.0.0.0 --metrics.port=6064
+ --pprof --pprof.addr=0.0.0.0 --pprof.port=6000
+ --private.api.addr=172.105.22.234:9191
+ ##--datadir=/erigon
+ ports:
+ - 8545:8545
+ server:
+ build:
+ context: .
+ command: |
+ server
+ ports:
+ - 3001:3001
diff --git a/erigon_internal/debug/api.go b/erigon_internal/debug/api.go
deleted file mode 100644
index 95d0213..0000000
--- a/erigon_internal/debug/api.go
+++ /dev/null
@@ -1,239 +0,0 @@
-// Copyright 2016 The go-ethereum Authors
-// This file is part of the go-ethereum library.
-//
-// The go-ethereum library 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.
-//
-// The go-ethereum library 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 the go-ethereum library. If not, see .
-
-// Package debug interfaces Go runtime debugging facilities.
-// This package is mostly glue code making these facilities available
-// through the CLI and RPC subsystem. If you want to use them from Go code,
-// use package runtime instead.
-package debug
-
-import (
- "bytes"
- "errors"
- "io"
- "os"
- "os/user"
- "path/filepath"
- "runtime"
- "runtime/debug"
- "runtime/pprof"
- "strings"
- "sync"
- "time"
-
- "github.com/ledgerwatch/erigon-lib/common"
- "github.com/ledgerwatch/log/v3"
-)
-
-// Handler is the global debugging handler.
-var Handler = new(HandlerT)
-
-// HandlerT implements the debugging API.
-// Do not create values of this type, use the one
-// in the Handler variable instead.
-type HandlerT struct {
- mu sync.Mutex
- cpuW io.WriteCloser
- cpuFile string
- traceW io.WriteCloser
- traceFile string
-}
-
-// Verbosity sets the log verbosity ceiling. The verbosity of individual packages
-// and source files can be raised using Vmodule.
-func (*HandlerT) Verbosity(level int) {
- //glogger.Verbosity(log.Lvl(level))
-}
-
-// Vmodule sets the log verbosity pattern. See package log for details on the
-// pattern syntax.
-func (*HandlerT) Vmodule(pattern string) error {
- //return glogger.Vmodule(pattern)
- return nil
-}
-
-// BacktraceAt sets the log backtrace location. See package log for details on
-// the pattern syntax.
-func (*HandlerT) BacktraceAt(location string) error {
- //return glogger.BacktraceAt(location)
- return nil
-}
-
-// MemStats returns detailed runtime memory statistics.
-func (*HandlerT) MemStats() *runtime.MemStats {
- s := new(runtime.MemStats)
- common.ReadMemStats(s)
- return s
-}
-
-// GcStats returns GC statistics.
-func (*HandlerT) GcStats() *debug.GCStats {
- s := new(debug.GCStats)
- debug.ReadGCStats(s)
- return s
-}
-
-// CpuProfile turns on CPU profiling for nsec seconds and writes
-// profile data to file.
-func (h *HandlerT) CpuProfile(file string, nsec uint) error {
- if err := h.StartCPUProfile(file); err != nil {
- return err
- }
- time.Sleep(time.Duration(nsec) * time.Second)
- _ = h.StopCPUProfile()
- return nil
-}
-
-// StartCPUProfile turns on CPU profiling, writing to the given file.
-func (h *HandlerT) StartCPUProfile(file string) error {
- h.mu.Lock()
- defer h.mu.Unlock()
- if h.cpuW != nil {
- return errors.New("CPU profiling already in progress")
- }
- f, err := os.Create(expandHome(file))
- if err != nil {
- return err
- }
- if err := pprof.StartCPUProfile(f); err != nil {
- f.Close()
- return err
- }
- h.cpuW = f
- h.cpuFile = file
- log.Info("CPU profiling started", "dump", h.cpuFile)
- return nil
-}
-
-// StopCPUProfile stops an ongoing CPU profile.
-func (h *HandlerT) StopCPUProfile() error {
- h.mu.Lock()
- defer h.mu.Unlock()
- pprof.StopCPUProfile()
- if h.cpuW == nil {
- return errors.New("CPU profiling not in progress")
- }
- log.Info("Done writing CPU profile", "dump", h.cpuFile)
- h.cpuW.Close()
- h.cpuW = nil
- h.cpuFile = ""
- return nil
-}
-
-// GoTrace turns on tracing for nsec seconds and writes
-// trace data to file.
-func (h *HandlerT) GoTrace(file string, nsec uint) error {
- if err := h.StartGoTrace(file); err != nil {
- return err
- }
- time.Sleep(time.Duration(nsec) * time.Second)
- _ = h.StopGoTrace()
- return nil
-}
-
-// BlockProfile turns on goroutine profiling for nsec seconds and writes profile data to
-// file. It uses a profile rate of 1 for most accurate information. If a different rate is
-// desired, set the rate and write the profile manually.
-func (*HandlerT) BlockProfile(file string, nsec uint) error {
- runtime.SetBlockProfileRate(1)
- time.Sleep(time.Duration(nsec) * time.Second)
- defer runtime.SetBlockProfileRate(0)
- return writeProfile("block", file)
-}
-
-// SetBlockProfileRate sets the rate of goroutine block profile data collection.
-// rate 0 disables block profiling.
-func (*HandlerT) SetBlockProfileRate(rate int) {
- runtime.SetBlockProfileRate(rate)
-}
-
-// WriteBlockProfile writes a goroutine blocking profile to the given file.
-func (*HandlerT) WriteBlockProfile(file string) error {
- return writeProfile("block", file)
-}
-
-// MutexProfile turns on mutex profiling for nsec seconds and writes profile data to file.
-// It uses a profile rate of 1 for most accurate information. If a different rate is
-// desired, set the rate and write the profile manually.
-func (*HandlerT) MutexProfile(file string, nsec uint) error {
- runtime.SetMutexProfileFraction(1)
- time.Sleep(time.Duration(nsec) * time.Second)
- defer runtime.SetMutexProfileFraction(0)
- return writeProfile("mutex", file)
-}
-
-// SetMutexProfileFraction sets the rate of mutex profiling.
-func (*HandlerT) SetMutexProfileFraction(rate int) {
- runtime.SetMutexProfileFraction(rate)
-}
-
-// WriteMutexProfile writes a goroutine blocking profile to the given file.
-func (*HandlerT) WriteMutexProfile(file string) error {
- return writeProfile("mutex", file)
-}
-
-// WriteMemProfile writes an allocation profile to the given file.
-// Note that the profiling rate cannot be set through the API,
-// it must be set on the command line.
-func (*HandlerT) WriteMemProfile(file string) error {
- return writeProfile("heap", file)
-}
-
-// Stacks returns a printed representation of the stacks of all goroutines.
-func (*HandlerT) Stacks() string {
- buf := new(bytes.Buffer)
- _ = pprof.Lookup("goroutine").WriteTo(buf, 2)
- return buf.String()
-}
-
-// FreeOSMemory forces a garbage collection.
-func (*HandlerT) FreeOSMemory() {
- debug.FreeOSMemory()
-}
-
-// SetGCPercent sets the garbage collection target percentage. It returns the previous
-// setting. A negative value disables GC.
-func (*HandlerT) SetGCPercent(v int) int {
- return debug.SetGCPercent(v)
-}
-
-func writeProfile(name, file string) error {
- p := pprof.Lookup(name)
- log.Info("Writing profile records", "count", p.Count(), "type", name, "dump", file)
- f, err := os.Create(expandHome(file))
- if err != nil {
- return err
- }
- defer f.Close()
- return p.WriteTo(f, 0)
-}
-
-// expands home directory in file paths.
-// ~someuser/tmp will not be expanded.
-func expandHome(p string) string {
- if strings.HasPrefix(p, "~/") || strings.HasPrefix(p, "~\\") {
- home := os.Getenv("HOME")
- if home == "" {
- if usr, err := user.Current(); err == nil {
- home = usr.HomeDir
- }
- }
- if home != "" {
- p = home + p[1:]
- }
- }
- return filepath.Clean(p)
-}
diff --git a/erigon_internal/debug/flags.go b/erigon_internal/debug/flags.go
deleted file mode 100644
index df30034..0000000
--- a/erigon_internal/debug/flags.go
+++ /dev/null
@@ -1,217 +0,0 @@
-// Copyright 2016 The go-ethereum Authors
-// This file is part of the go-ethereum library.
-//
-// The go-ethereum library 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.
-//
-// The go-ethereum library 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 the go-ethereum library. If not, see .
-
-package debug
-
-import (
- "fmt"
- "net/http"
- _ "net/http/pprof" //nolint:gosec
-
- metrics2 "github.com/VictoriaMetrics/metrics"
- "github.com/ledgerwatch/erigon/common/fdlimit"
- "github.com/ledgerwatch/erigon/metrics"
- "github.com/ledgerwatch/erigon/metrics/exp"
- "github.com/ledgerwatch/log/v3"
- "github.com/spf13/cobra"
- "github.com/urfave/cli"
- "github.com/wmitsuda/otterscan/erigon_internal/logging"
-)
-
-var (
- //nolint
- vmoduleFlag = cli.StringFlag{
- Name: "vmodule",
- Usage: "Per-module verbosity: comma-separated list of = (e.g. eth/*=5,p2p=4)",
- Value: "",
- }
- metricsAddrFlag = cli.StringFlag{
- Name: "metrics.addr",
- }
- metricsPortFlag = cli.UintFlag{
- Name: "metrics.port",
- Value: 6060,
- }
- pprofFlag = cli.BoolFlag{
- Name: "pprof",
- Usage: "Enable the pprof HTTP server",
- }
- pprofPortFlag = cli.IntFlag{
- Name: "pprof.port",
- Usage: "pprof HTTP server listening port",
- Value: 6060,
- }
- pprofAddrFlag = cli.StringFlag{
- Name: "pprof.addr",
- Usage: "pprof HTTP server listening interface",
- Value: "127.0.0.1",
- }
- cpuprofileFlag = cli.StringFlag{
- Name: "pprof.cpuprofile",
- Usage: "Write CPU profile to the given file",
- }
- traceFlag = cli.StringFlag{
- Name: "trace",
- Usage: "Write execution trace to the given file",
- }
-)
-
-// Flags holds all command-line flags required for debugging.
-var Flags = []cli.Flag{
- pprofFlag, pprofAddrFlag, pprofPortFlag,
- cpuprofileFlag, traceFlag,
-}
-
-func SetupCobra(cmd *cobra.Command) error {
- RaiseFdLimit()
- flags := cmd.Flags()
-
- _ = logging.GetLoggerCmd("debug", cmd)
-
- traceFile, err := flags.GetString(traceFlag.Name)
- if err != nil {
- return err
- }
- cpuFile, err := flags.GetString(cpuprofileFlag.Name)
- if err != nil {
- return err
- }
-
- // profiling, tracing
- if traceFile != "" {
- if err2 := Handler.StartGoTrace(traceFile); err2 != nil {
- return err2
- }
- }
- if cpuFile != "" {
- if err2 := Handler.StartCPUProfile(cpuFile); err2 != nil {
- return err2
- }
- }
-
- go ListenSignals(nil)
- pprof, err := flags.GetBool(pprofFlag.Name)
- if err != nil {
- return err
- }
- pprofAddr, err := flags.GetString(pprofAddrFlag.Name)
- if err != nil {
- return err
- }
- pprofPort, err := flags.GetInt(pprofPortFlag.Name)
- if err != nil {
- return err
- }
-
- metricsAddr, err := flags.GetString(metricsAddrFlag.Name)
- if err != nil {
- return err
- }
- metricsPort, err := flags.GetInt(metricsPortFlag.Name)
- if err != nil {
- return err
- }
-
- if metrics.Enabled && metricsAddr != "" {
- address := fmt.Sprintf("%s:%d", metricsAddr, metricsPort)
- exp.Setup(address)
- }
-
- withMetrics := metrics.Enabled && metricsAddr == ""
- if pprof {
- // metrics and pprof server
- StartPProf(fmt.Sprintf("%s:%d", pprofAddr, pprofPort), withMetrics)
- }
- return nil
-}
-
-// Setup initializes profiling and logging based on the CLI flags.
-// It should be called as early as possible in the program.
-func Setup(ctx *cli.Context) error {
- RaiseFdLimit()
-
- _ = logging.GetLoggerCtx("debug", ctx)
-
- if traceFile := ctx.String(traceFlag.Name); traceFile != "" {
- if err := Handler.StartGoTrace(traceFile); err != nil {
- return err
- }
- }
-
- if cpuFile := ctx.String(cpuprofileFlag.Name); cpuFile != "" {
- if err := Handler.StartCPUProfile(cpuFile); err != nil {
- return err
- }
- }
- pprofEnabled := ctx.Bool(pprofFlag.Name)
- metricsAddr := ctx.String(metricsAddrFlag.Name)
-
- if metrics.Enabled && (!pprofEnabled || metricsAddr != "") {
- metricsPort := ctx.Int(metricsPortFlag.Name)
- address := fmt.Sprintf("%s:%d", metricsAddr, metricsPort)
- exp.Setup(address)
- }
-
- // pprof server
- if pprofEnabled {
- pprofHost := ctx.String(pprofAddrFlag.Name)
- pprofPort := ctx.Int(pprofPortFlag.Name)
- address := fmt.Sprintf("%s:%d", pprofHost, pprofPort)
- // This context value ("metrics.addr") represents the utils.MetricsHTTPFlag.Name.
- // It cannot be imported because it will cause a cyclical dependency.
- withMetrics := metrics.Enabled && metricsAddr == ""
- StartPProf(address, withMetrics)
- }
- return nil
-}
-
-func StartPProf(address string, withMetrics bool) {
- // Hook go-metrics into expvar on any /debug/metrics request, load all vars
- // from the registry into expvar, and execute regular expvar handler.
- if withMetrics {
- http.HandleFunc("/debug/metrics/prometheus", func(w http.ResponseWriter, req *http.Request) {
- w.Header().Set("Access-Control-Allow-Origin", "*")
- metrics2.WritePrometheus(w, true)
- })
- }
- cpuMsg := fmt.Sprintf("go tool pprof -lines -http=: http://%s/%s", address, "debug/pprof/profile?seconds=20")
- heapMsg := fmt.Sprintf("go tool pprof -lines -http=: http://%s/%s", address, "debug/pprof/heap")
- log.Info("Starting pprof server", "cpu", cpuMsg, "heap", heapMsg)
- go func() {
- if err := http.ListenAndServe(address, nil); err != nil { // nolint:gosec
- log.Error("Failure in running pprof server", "err", err)
- }
- }()
-}
-
-// Exit stops all running profiles, flushing their output to the
-// respective file.
-func Exit() {
- _ = Handler.StopCPUProfile()
- _ = Handler.StopGoTrace()
-}
-
-// RaiseFdLimit raises out the number of allowed file handles per process
-func RaiseFdLimit() {
- limit, err := fdlimit.Maximum()
- if err != nil {
- log.Error("Failed to retrieve file descriptor allowance", "err", err)
- return
- }
- if _, err = fdlimit.Raise(uint64(limit)); err != nil {
- log.Error("Failed to raise file descriptor allowance", "err", err)
- }
-}
diff --git a/erigon_internal/debug/loudpanic.go b/erigon_internal/debug/loudpanic.go
deleted file mode 100644
index 3412d87..0000000
--- a/erigon_internal/debug/loudpanic.go
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright 2016 The go-ethereum Authors
-// This file is part of the go-ethereum library.
-//
-// The go-ethereum library 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.
-//
-// The go-ethereum library 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 the go-ethereum library. If not, see .
-
-//go:build go1.6
-
-package debug
-
-import "runtime/debug"
-
-// LoudPanic panics in a way that gets all goroutine stacks printed on stderr.
-func LoudPanic(x interface{}) {
- debug.SetTraceback("all")
- panic(x)
-}
diff --git a/erigon_internal/debug/loudpanic_fallback.go b/erigon_internal/debug/loudpanic_fallback.go
deleted file mode 100644
index a909f9d..0000000
--- a/erigon_internal/debug/loudpanic_fallback.go
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright 2016 The go-ethereum Authors
-// This file is part of the go-ethereum library.
-//
-// The go-ethereum library 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.
-//
-// The go-ethereum library 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 the go-ethereum library. If not, see .
-
-//go:build !go1.6
-
-package debug
-
-// LoudPanic panics in a way that gets all goroutine stacks printed on stderr.
-func LoudPanic(x interface{}) {
- panic(x)
-}
diff --git a/erigon_internal/debug/signal.go b/erigon_internal/debug/signal.go
deleted file mode 100644
index 85e1088..0000000
--- a/erigon_internal/debug/signal.go
+++ /dev/null
@@ -1,43 +0,0 @@
-//go:build !windows
-
-package debug
-
-import (
- "io"
- "os"
- "os/signal"
- "runtime/pprof"
-
- _debug "github.com/ledgerwatch/erigon/common/debug"
- "github.com/ledgerwatch/log/v3"
- "golang.org/x/sys/unix"
-)
-
-func ListenSignals(stack io.Closer) {
- sigc := make(chan os.Signal, 1)
- signal.Notify(sigc, unix.SIGINT, unix.SIGTERM)
- _debug.GetSigC(&sigc)
- defer signal.Stop(sigc)
-
- usr1 := make(chan os.Signal, 1)
- signal.Notify(usr1, unix.SIGUSR1)
- for {
- select {
- case <-sigc:
- log.Info("Got interrupt, shutting down...")
- if stack != nil {
- go stack.Close()
- }
- for i := 10; i > 0; i-- {
- <-sigc
- if i > 1 {
- log.Warn("Already shutting down, interrupt more to panic.", "times", i-1)
- }
- }
- Exit() // ensure trace and CPU profile data is flushed.
- LoudPanic("boom")
- case <-usr1:
- pprof.Lookup("goroutine").WriteTo(os.Stdout, 1)
- }
- }
-}
diff --git a/erigon_internal/debug/signal_windows.go b/erigon_internal/debug/signal_windows.go
deleted file mode 100644
index ea731be..0000000
--- a/erigon_internal/debug/signal_windows.go
+++ /dev/null
@@ -1,33 +0,0 @@
-//go:build windows
-
-package debug
-
-import (
- "io"
- "os"
- "os/signal"
-
- _debug "github.com/ledgerwatch/erigon/common/debug"
- "github.com/ledgerwatch/log/v3"
-)
-
-func ListenSignals(stack io.Closer) {
- sigc := make(chan os.Signal, 1)
- signal.Notify(sigc, os.Interrupt)
- _debug.GetSigC(&sigc)
- defer signal.Stop(sigc)
-
- <-sigc
- log.Info("Got interrupt, shutting down...")
- if stack != nil {
- go stack.Close()
- }
- for i := 10; i > 0; i-- {
- <-sigc
- if i > 1 {
- log.Warn("Already shutting down, interrupt more to panic.", "times", i-1)
- }
- }
- Exit() // ensure trace and CPU profile data is flushed.
- LoudPanic("boom")
-}
diff --git a/erigon_internal/debug/trace.go b/erigon_internal/debug/trace.go
deleted file mode 100644
index b9902e7..0000000
--- a/erigon_internal/debug/trace.go
+++ /dev/null
@@ -1,63 +0,0 @@
-// Copyright 2016 The go-ethereum Authors
-// This file is part of the go-ethereum library.
-//
-// The go-ethereum library 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.
-//
-// The go-ethereum library 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 the go-ethereum library. If not, see .
-
-//go:build go1.5
-
-package debug
-
-import (
- "errors"
- "os"
- "runtime/trace"
-
- "github.com/ledgerwatch/log/v3"
-)
-
-// StartGoTrace turns on tracing, writing to the given file.
-func (h *HandlerT) StartGoTrace(file string) error {
- h.mu.Lock()
- defer h.mu.Unlock()
- if h.traceW != nil {
- return errors.New("trace already in progress")
- }
- f, err := os.Create(expandHome(file))
- if err != nil {
- return err
- }
- if err := trace.Start(f); err != nil {
- f.Close()
- return err
- }
- h.traceW = f
- h.traceFile = file
- log.Info("Go tracing started", "dump", h.traceFile)
- return nil
-}
-
-// StopTrace stops an ongoing trace.
-func (h *HandlerT) StopGoTrace() error {
- h.mu.Lock()
- defer h.mu.Unlock()
- trace.Stop()
- if h.traceW == nil {
- return errors.New("trace not in progress")
- }
- log.Info("Done writing Go trace", "dump", h.traceFile)
- h.traceW.Close()
- h.traceW = nil
- h.traceFile = ""
- return nil
-}
diff --git a/erigon_internal/debug/trace_fallback.go b/erigon_internal/debug/trace_fallback.go
deleted file mode 100644
index ffe506e..0000000
--- a/erigon_internal/debug/trace_fallback.go
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright 2016 The go-ethereum Authors
-// This file is part of the go-ethereum library.
-//
-// The go-ethereum library 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.
-//
-// The go-ethereum library 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 the go-ethereum library. If not, see .
-
-//go:build !go1.5
-
-// no-op implementation of tracing methods for Go < 1.5.
-
-package debug
-
-import "errors"
-
-func (*HandlerT) StartGoTrace(string) error {
- return errors.New("tracing is not supported on Go < 1.5")
-}
-
-func (*HandlerT) StopGoTrace() error {
- return errors.New("tracing is not supported on Go < 1.5")
-}
diff --git a/erigon_internal/ethapi/api.go b/erigon_internal/ethapi/api.go
deleted file mode 100644
index 2c8d96a..0000000
--- a/erigon_internal/ethapi/api.go
+++ /dev/null
@@ -1,1039 +0,0 @@
-// Copyright 2015 The go-ethereum Authors
-// This file is part of the go-ethereum library.
-//
-// The go-ethereum library 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.
-//
-// The go-ethereum library 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 the go-ethereum library. If not, see .
-
-package ethapi
-
-import (
- "errors"
- "fmt"
- "math/big"
-
- "github.com/holiman/uint256"
- "github.com/ledgerwatch/erigon/accounts/abi"
- "github.com/ledgerwatch/erigon/common"
- "github.com/ledgerwatch/erigon/common/hexutil"
- "github.com/ledgerwatch/erigon/common/math"
- "github.com/ledgerwatch/erigon/core"
- "github.com/ledgerwatch/erigon/core/types"
- "github.com/ledgerwatch/erigon/core/vm"
- "github.com/ledgerwatch/log/v3"
-)
-
-// CallArgs represents the arguments for a call.
-type CallArgs struct {
- From *common.Address `json:"from"`
- To *common.Address `json:"to"`
- Gas *hexutil.Uint64 `json:"gas"`
- GasPrice *hexutil.Big `json:"gasPrice"`
- MaxPriorityFeePerGas *hexutil.Big `json:"maxPriorityFeePerGas"`
- MaxFeePerGas *hexutil.Big `json:"maxFeePerGas"`
- Value *hexutil.Big `json:"value"`
- Nonce *hexutil.Uint64 `json:"nonce"`
- Data *hexutil.Bytes `json:"data"`
- AccessList *types.AccessList `json:"accessList"`
- ChainID *hexutil.Big `json:"chainId,omitempty"`
-}
-
-// from retrieves the transaction sender address.
-func (arg *CallArgs) from() common.Address {
- if arg.From == nil {
- return common.Address{}
- }
- return *arg.From
-}
-
-// ToMessage converts CallArgs to the Message type used by the core evm
-func (args *CallArgs) ToMessage(globalGasCap uint64, baseFee *uint256.Int) (types.Message, error) {
- // Reject invalid combinations of pre- and post-1559 fee styles
- if args.GasPrice != nil && (args.MaxFeePerGas != nil || args.MaxPriorityFeePerGas != nil) {
- return types.Message{}, errors.New("both gasPrice and (maxFeePerGas or maxPriorityFeePerGas) specified")
- }
- // Set sender address or use zero address if none specified.
- addr := args.from()
-
- // Set default gas & gas price if none were set
- gas := globalGasCap
- if gas == 0 {
- gas = uint64(math.MaxUint64 / 2)
- }
- if args.Gas != nil {
- gas = uint64(*args.Gas)
- }
- if globalGasCap != 0 && globalGasCap < gas {
- log.Warn("Caller gas above allowance, capping", "requested", gas, "cap", globalGasCap)
- gas = globalGasCap
- }
-
- var (
- gasPrice *uint256.Int
- gasFeeCap *uint256.Int
- gasTipCap *uint256.Int
- )
- if baseFee == nil {
- // If there's no basefee, then it must be a non-1559 execution
- gasPrice = new(uint256.Int)
- if args.GasPrice != nil {
- overflow := gasPrice.SetFromBig(args.GasPrice.ToInt())
- if overflow {
- return types.Message{}, fmt.Errorf("args.GasPrice higher than 2^256-1")
- }
- }
- gasFeeCap, gasTipCap = gasPrice, gasPrice
- } else {
- // A basefee is provided, necessitating 1559-type execution
- if args.GasPrice != nil {
- // User specified the legacy gas field, convert to 1559 gas typing
- gasPrice = new(uint256.Int)
- overflow := gasPrice.SetFromBig(args.GasPrice.ToInt())
- if overflow {
- return types.Message{}, fmt.Errorf("args.GasPrice higher than 2^256-1")
- }
- gasFeeCap, gasTipCap = gasPrice, gasPrice
- } else {
- // User specified 1559 gas feilds (or none), use those
- gasFeeCap = new(uint256.Int)
- if args.MaxFeePerGas != nil {
- overflow := gasFeeCap.SetFromBig(args.MaxFeePerGas.ToInt())
- if overflow {
- return types.Message{}, fmt.Errorf("args.GasPrice higher than 2^256-1")
- }
- }
- gasTipCap = new(uint256.Int)
- if args.MaxPriorityFeePerGas != nil {
- overflow := gasTipCap.SetFromBig(args.MaxPriorityFeePerGas.ToInt())
- if overflow {
- return types.Message{}, fmt.Errorf("args.GasPrice higher than 2^256-1")
- }
- }
- // Backfill the legacy gasPrice for EVM execution, unless we're all zeroes
- gasPrice = new(uint256.Int)
- if !gasFeeCap.IsZero() || !gasTipCap.IsZero() {
- gasPrice = math.U256Min(new(uint256.Int).Add(gasTipCap, baseFee), gasFeeCap)
- }
- }
- }
-
- value := new(uint256.Int)
- if args.Value != nil {
- overflow := value.SetFromBig(args.Value.ToInt())
- if overflow {
- return types.Message{}, fmt.Errorf("args.Value higher than 2^256-1")
- }
- }
- var data []byte
- if args.Data != nil {
- data = *args.Data
- }
- var accessList types.AccessList
- if args.AccessList != nil {
- accessList = *args.AccessList
- }
-
- msg := types.NewMessage(addr, args.To, 0, value, gas, gasPrice, gasFeeCap, gasTipCap, data, accessList, false)
- return msg, nil
-}
-
-// account indicates the overriding fields of account during the execution of
-// a message call.
-// Note, state and stateDiff can't be specified at the same time. If state is
-// set, message execution will only use the data in the given state. Otherwise
-// if statDiff is set, all diff will be applied first and then execute the call
-// message.
-type Account struct {
- Nonce *hexutil.Uint64 `json:"nonce"`
- Code *hexutil.Bytes `json:"code"`
- Balance **hexutil.Big `json:"balance"`
- State *map[common.Hash]uint256.Int `json:"state"`
- StateDiff *map[common.Hash]uint256.Int `json:"stateDiff"`
-}
-
-func NewRevertError(result *core.ExecutionResult) *RevertError {
- reason, errUnpack := abi.UnpackRevert(result.Revert())
- err := errors.New("execution reverted")
- if errUnpack == nil {
- err = fmt.Errorf("execution reverted: %v", reason)
- }
- return &RevertError{
- error: err,
- reason: hexutil.Encode(result.Revert()),
- }
-}
-
-// RevertError is an API error that encompassas an EVM revertal with JSON error
-// code and a binary data blob.
-type RevertError struct {
- error
- reason string // revert reason hex encoded
-}
-
-// ErrorCode returns the JSON error code for a revertal.
-// See: https://github.com/ethereum/wiki/wiki/JSON-RPC-Error-Codes-Improvement-Proposal
-func (e *RevertError) ErrorCode() int {
- return 3
-}
-
-// ErrorData returns the hex encoded revert reason.
-func (e *RevertError) ErrorData() interface{} {
- return e.reason
-}
-
-// ExecutionResult groups all structured logs emitted by the EVM
-// while replaying a transaction in debug mode as well as transaction
-// execution status, the amount of gas used and the return value
-type ExecutionResult struct {
- Gas uint64 `json:"gas"`
- Failed bool `json:"failed"`
- ReturnValue string `json:"returnValue"`
- StructLogs []StructLogRes `json:"structLogs"`
-}
-
-// StructLogRes stores a structured log emitted by the EVM while replaying a
-// transaction in debug mode
-type StructLogRes struct {
- Pc uint64 `json:"pc"`
- Op string `json:"op"`
- Gas uint64 `json:"gas"`
- GasCost uint64 `json:"gasCost"`
- Depth int `json:"depth"`
- Error error `json:"error,omitempty"`
- Stack *[]string `json:"stack,omitempty"`
- Memory *[]string `json:"memory,omitempty"`
- Storage *map[string]string `json:"storage,omitempty"`
-}
-
-// FormatLogs formats EVM returned structured logs for json output
-func FormatLogs(logs []vm.StructLog) []StructLogRes {
- formatted := make([]StructLogRes, len(logs))
- for index, trace := range logs {
- formatted[index] = StructLogRes{
- Pc: trace.Pc,
- Op: trace.Op.String(),
- Gas: trace.Gas,
- GasCost: trace.GasCost,
- Depth: trace.Depth,
- Error: trace.Err,
- }
- if trace.Stack != nil {
- stack := make([]string, len(trace.Stack))
- for i, stackValue := range trace.Stack {
- stack[i] = fmt.Sprintf("%x", math.PaddedBigBytes(stackValue, 32))
- }
- formatted[index].Stack = &stack
- }
- if trace.Memory != nil {
- memory := make([]string, 0, (len(trace.Memory)+31)/32)
- for i := 0; i+32 <= len(trace.Memory); i += 32 {
- memory = append(memory, fmt.Sprintf("%x", trace.Memory[i:i+32]))
- }
- formatted[index].Memory = &memory
- }
- if trace.Storage != nil {
- storage := make(map[string]string)
- for i, storageValue := range trace.Storage {
- storage[fmt.Sprintf("%x", i)] = fmt.Sprintf("%x", storageValue)
- }
- formatted[index].Storage = &storage
- }
- }
- return formatted
-}
-
-// RPCMarshalHeader converts the given header to the RPC output .
-func RPCMarshalHeader(head *types.Header) map[string]interface{} {
- result := map[string]interface{}{
- "number": (*hexutil.Big)(head.Number),
- "hash": head.Hash(),
- "parentHash": head.ParentHash,
- "nonce": head.Nonce,
- "mixHash": head.MixDigest,
- "sha3Uncles": head.UncleHash,
- "logsBloom": head.Bloom,
- "stateRoot": head.Root,
- "miner": head.Coinbase,
- "difficulty": (*hexutil.Big)(head.Difficulty),
- "extraData": hexutil.Bytes(head.Extra),
- "size": hexutil.Uint64(head.Size()),
- "gasLimit": hexutil.Uint64(head.GasLimit),
- "gasUsed": hexutil.Uint64(head.GasUsed),
- "timestamp": hexutil.Uint64(head.Time),
- "transactionsRoot": head.TxHash,
- "receiptsRoot": head.ReceiptHash,
- }
- if head.BaseFee != nil {
- result["baseFeePerGas"] = (*hexutil.Big)(head.BaseFee)
- }
-
- return result
-}
-
-// RPCMarshalBlock converts the given block to the RPC output which depends on fullTx. If inclTx is true transactions are
-// returned. When fullTx is true the returned block contains full transaction details, otherwise it will only contain
-// transaction hashes.
-func RPCMarshalBlock(block *types.Block, inclTx bool, fullTx bool) (map[string]interface{}, error) {
- return RPCMarshalBlockEx(block, inclTx, fullTx, nil, common.Hash{})
-}
-
-func RPCMarshalBlockEx(block *types.Block, inclTx bool, fullTx bool, borTx types.Transaction, borTxHash common.Hash) (map[string]interface{}, error) {
- fields := RPCMarshalHeader(block.Header())
- fields["size"] = hexutil.Uint64(block.Size())
- if _, ok := fields["transactions"]; !ok {
- fields["transactions"] = make([]interface{}, 0)
- }
-
- if inclTx {
- formatTx := func(tx types.Transaction, index int) (interface{}, error) {
- return tx.Hash(), nil
- }
- if fullTx {
- formatTx = func(tx types.Transaction, index int) (interface{}, error) {
- return newRPCTransactionFromBlockAndTxGivenIndex(block, tx, uint64(index)), nil
- }
- }
- txs := block.Transactions()
- transactions := make([]interface{}, len(txs), len(txs)+1)
- var err error
- for i, tx := range txs {
- if transactions[i], err = formatTx(tx, i); err != nil {
- return nil, err
- }
- }
-
- if borTx != nil {
- if fullTx {
- transactions = append(transactions, newRPCBorTransaction(borTx, borTxHash, block.Hash(), block.NumberU64(), uint64(len(txs)), block.BaseFee()))
- } else {
- transactions = append(transactions, borTxHash)
- }
- }
-
- fields["transactions"] = transactions
- }
- uncles := block.Uncles()
- uncleHashes := make([]common.Hash, len(uncles))
- for i, uncle := range uncles {
- uncleHashes[i] = uncle.Hash()
- }
- fields["uncles"] = uncleHashes
-
- return fields, nil
-}
-
-/*
-
-// rpcMarshalHeader uses the generalized output filler, then adds the total difficulty field, which requires
-// a `PublicBlockchainAPI`.
-func (s *PublicBlockChainAPI) rpcMarshalHeader(ctx context.Context, header *types.Header) map[string]interface{} {
- fields := RPCMarshalHeader(header)
- fields["totalDifficulty"] = (*hexutil.Big)(s.b.GetTd(ctx, header.Hash()))
- return fields
-}
-
-// rpcMarshalBlock uses the generalized output filler, then adds the total difficulty field, which requires
-// a `PublicBlockchainAPI`.
-func (s *PublicBlockChainAPI) rpcMarshalBlock(ctx context.Context, b *types.Block, inclTx bool, fullTx bool) (map[string]interface{}, error) {
- fields, err := RPCMarshalBlock(b, inclTx, fullTx)
- if err != nil {
- return nil, err
- }
- if inclTx {
- fields["totalDifficulty"] = (*hexutil.Big)(s.b.GetTd(ctx, b.Hash()))
- }
- return fields, err
-}
-*/
-
-// RPCTransaction represents a transaction that will serialize to the RPC representation of a transaction
-type RPCTransaction struct {
- BlockHash *common.Hash `json:"blockHash"`
- BlockNumber *hexutil.Big `json:"blockNumber"`
- From common.Address `json:"from"`
- Gas hexutil.Uint64 `json:"gas"`
- GasPrice *hexutil.Big `json:"gasPrice,omitempty"`
- Tip *hexutil.Big `json:"maxPriorityFeePerGas,omitempty"`
- FeeCap *hexutil.Big `json:"maxFeePerGas,omitempty"`
- Hash common.Hash `json:"hash"`
- Input hexutil.Bytes `json:"input"`
- Nonce hexutil.Uint64 `json:"nonce"`
- To *common.Address `json:"to"`
- TransactionIndex *hexutil.Uint64 `json:"transactionIndex"`
- Value *hexutil.Big `json:"value"`
- Type hexutil.Uint64 `json:"type"`
- Accesses *types.AccessList `json:"accessList,omitempty"`
- ChainID *hexutil.Big `json:"chainId,omitempty"`
- V *hexutil.Big `json:"v"`
- R *hexutil.Big `json:"r"`
- S *hexutil.Big `json:"s"`
-}
-
-// newRPCTransaction returns a transaction that will serialize to the RPC
-// representation, with the given location metadata set (if available).
-func newRPCTransaction(tx types.Transaction, blockHash common.Hash, blockNumber uint64, index uint64, baseFee *big.Int) *RPCTransaction {
- // Determine the signer. For replay-protected transactions, use the most permissive
- // signer, because we assume that signers are backwards-compatible with old
- // transactions. For non-protected transactions, the homestead signer signer is used
- // because the return value of ChainId is zero for those transactions.
- chainId := uint256.NewInt(0)
- result := &RPCTransaction{
- Type: hexutil.Uint64(tx.Type()),
- Gas: hexutil.Uint64(tx.GetGas()),
- Hash: tx.Hash(),
- Input: hexutil.Bytes(tx.GetData()),
- Nonce: hexutil.Uint64(tx.GetNonce()),
- To: tx.GetTo(),
- Value: (*hexutil.Big)(tx.GetValue().ToBig()),
- }
- switch t := tx.(type) {
- case *types.LegacyTx:
- chainId = types.DeriveChainId(&t.V)
- result.ChainID = (*hexutil.Big)(chainId.ToBig())
- result.GasPrice = (*hexutil.Big)(t.GasPrice.ToBig())
- result.V = (*hexutil.Big)(t.V.ToBig())
- result.R = (*hexutil.Big)(t.R.ToBig())
- result.S = (*hexutil.Big)(t.S.ToBig())
- case *types.AccessListTx:
- chainId.Set(t.ChainID)
- result.ChainID = (*hexutil.Big)(chainId.ToBig())
- result.GasPrice = (*hexutil.Big)(t.GasPrice.ToBig())
- result.V = (*hexutil.Big)(t.V.ToBig())
- result.R = (*hexutil.Big)(t.R.ToBig())
- result.S = (*hexutil.Big)(t.S.ToBig())
- if len(t.AccessList) > 0 {
- result.Accesses = &t.AccessList
- }
- case *types.DynamicFeeTransaction:
- chainId.Set(t.ChainID)
- result.ChainID = (*hexutil.Big)(chainId.ToBig())
- result.Tip = (*hexutil.Big)(t.Tip.ToBig())
- result.FeeCap = (*hexutil.Big)(t.FeeCap.ToBig())
- result.V = (*hexutil.Big)(t.V.ToBig())
- result.R = (*hexutil.Big)(t.R.ToBig())
- result.S = (*hexutil.Big)(t.S.ToBig())
- if len(t.AccessList) > 0 {
- result.Accesses = &t.AccessList
- }
- // if the transaction has been mined, compute the effective gas price
- if baseFee != nil && blockHash != (common.Hash{}) {
- // price = min(tip, gasFeeCap - baseFee) + baseFee
- price := math.BigMin(new(big.Int).Add(t.Tip.ToBig(), baseFee), t.FeeCap.ToBig())
- result.GasPrice = (*hexutil.Big)(price)
- } else {
- result.GasPrice = nil
- }
- }
- signer := types.LatestSignerForChainID(chainId.ToBig())
- var err error
- result.From, err = tx.Sender(*signer)
- if err != nil {
- log.Warn("sender recovery", "err", err)
- }
- if blockHash != (common.Hash{}) {
- result.BlockHash = &blockHash
- result.BlockNumber = (*hexutil.Big)(new(big.Int).SetUint64(blockNumber))
- result.TransactionIndex = (*hexutil.Uint64)(&index)
- }
- return result
-}
-
-// newRPCBorTransaction returns a Bor transaction that will serialize to the RPC
-// representation, with the given location metadata set (if available).
-func newRPCBorTransaction(opaqueTx types.Transaction, txHash common.Hash, blockHash common.Hash, blockNumber uint64, index uint64, baseFee *big.Int) *RPCTransaction {
- tx := opaqueTx.(*types.LegacyTx)
- result := &RPCTransaction{
- Type: hexutil.Uint64(tx.Type()),
- ChainID: (*hexutil.Big)(new(big.Int)),
- GasPrice: (*hexutil.Big)(tx.GasPrice.ToBig()),
- Gas: hexutil.Uint64(tx.GetGas()),
- Hash: txHash,
- Input: hexutil.Bytes(tx.GetData()),
- Nonce: hexutil.Uint64(tx.GetNonce()),
- From: common.Address{},
- To: tx.GetTo(),
- Value: (*hexutil.Big)(tx.GetValue().ToBig()),
- V: (*hexutil.Big)(big.NewInt(0)),
- R: (*hexutil.Big)(big.NewInt(0)),
- S: (*hexutil.Big)(big.NewInt(0)),
- }
- if blockHash != (common.Hash{}) {
- result.BlockHash = &blockHash
- result.BlockNumber = (*hexutil.Big)(new(big.Int).SetUint64(blockNumber))
- result.TransactionIndex = (*hexutil.Uint64)(&index)
- }
- return result
-}
-
-/*
-// newRPCPendingTransaction returns a pending transaction that will serialize to the RPC representation
-func newRPCPendingTransaction(tx types.Transaction) *RPCTransaction {
- return newRPCTransaction(tx, common.Hash{}, 0, 0)
-}
-*/
-
-/*
-// newRPCTransactionFromBlockIndex returns a transaction that will serialize to the RPC representation.
-func newRPCTransactionFromBlockIndex(b *types.Block, index uint64) *RPCTransaction {
- txs := b.Transactions()
- if index >= uint64(len(txs)) {
- return nil
- }
- return newRPCTransaction(txs[index], b.Hash(), b.NumberU64(), index, b.BaseFee())
-}
-*/
-
-// newRPCTransactionFromBlockAndTxGivenIndex returns a transaction that will serialize to the RPC representation.
-func newRPCTransactionFromBlockAndTxGivenIndex(b *types.Block, tx types.Transaction, index uint64) *RPCTransaction {
- return newRPCTransaction(tx, b.Hash(), b.NumberU64(), index, b.BaseFee())
-}
-
-/*
-// newRPCRawTransactionFromBlockIndex returns the bytes of a transaction given a block and a transaction index.
-func newRPCRawTransactionFromBlockIndex(b *types.Block, index uint64) hexutil.Bytes {
- txs := b.Transactions()
- if index >= uint64(len(txs)) {
- return nil
- }
- var blob bytes.Buffer
- if txs[index].Type() != types.LegacyTxType {
- if err := blob.WriteByte(txs[index].Type()); err != nil {
- panic(err)
- }
- }
- if err := rlp.Encode(&blob, txs[index]); err != nil {
- panic(err)
- }
- return blob.Bytes()
-}
-*/
-
-/*
-// newRPCTransactionFromBlockHash returns a transaction that will serialize to the RPC representation.
-func newRPCTransactionFromBlockHash(b *types.Block, hash common.Hash) *RPCTransaction {
- for idx, tx := range b.Transactions() {
- if tx.Hash() == hash {
- return newRPCTransactionFromBlockIndex(b, uint64(idx))
- }
- }
- return nil
-}
-*/
-
-/*
-// PublicTransactionPoolAPI exposes methods for the RPC interface
-type PublicTransactionPoolAPI struct {
- b Backend
- nonceLock *AddrLocker
- signer *types.Signer
-}
-
-// NewPublicTransactionPoolAPI creates a new RPC service with methods specific for the transaction pool.
-func NewPublicTransactionPoolAPI(b Backend, nonceLock *AddrLocker) *PublicTransactionPoolAPI {
- // The signer used by the API should always be the 'latest' known one because we expect
- // signers to be backwards-compatible with old transactions.
- signer := types.LatestSigner(b.ChainConfig())
- return &PublicTransactionPoolAPI{b, nonceLock, signer}
-}
-
-// GetBlockTransactionCountByNumber returns the number of transactions in the block with the given block number.
-func (s *PublicTransactionPoolAPI) GetBlockTransactionCountByNumber(ctx context.Context, blockNr rpc.BlockNumber) *hexutil.Uint {
- if block, _ := s.b.BlockByNumber(ctx, blockNr); block != nil {
- n := hexutil.Uint(len(block.Transactions()))
- return &n
- }
- return nil
-}
-
-// GetBlockTransactionCountByHash returns the number of transactions in the block with the given hash.
-func (s *PublicTransactionPoolAPI) GetBlockTransactionCountByHash(ctx context.Context, blockHash common.Hash) *hexutil.Uint {
- if block, _ := s.b.BlockByHash(ctx, blockHash); block != nil {
- n := hexutil.Uint(len(block.Transactions()))
- return &n
- }
- return nil
-}
-
-// GetTransactionByBlockNumberAndIndex returns the transaction for the given block number and index.
-func (s *PublicTransactionPoolAPI) GetTransactionByBlockNumberAndIndex(ctx context.Context, blockNr rpc.BlockNumber, index hexutil.Uint) *RPCTransaction {
- if block, _ := s.b.BlockByNumber(ctx, blockNr); block != nil {
- return newRPCTransactionFromBlockIndex(block, uint64(index))
- }
- return nil
-}
-
-// GetTransactionByBlockHashAndIndex returns the transaction for the given block hash and index.
-func (s *PublicTransactionPoolAPI) GetTransactionByBlockHashAndIndex(ctx context.Context, blockHash common.Hash, index hexutil.Uint) *RPCTransaction {
- if block, _ := s.b.BlockByHash(ctx, blockHash); block != nil {
- return newRPCTransactionFromBlockIndex(block, uint64(index))
- }
- return nil
-}
-
-// GetRawTransactionByBlockNumberAndIndex returns the bytes of the transaction for the given block number and index.
-func (s *PublicTransactionPoolAPI) GetRawTransactionByBlockNumberAndIndex(ctx context.Context, blockNr rpc.BlockNumber, index hexutil.Uint) hexutil.Bytes {
- if block, _ := s.b.BlockByNumber(ctx, blockNr); block != nil {
- return newRPCRawTransactionFromBlockIndex(block, uint64(index))
- }
- return nil
-}
-
-// GetRawTransactionByBlockHashAndIndex returns the bytes of the transaction for the given block hash and index.
-func (s *PublicTransactionPoolAPI) GetRawTransactionByBlockHashAndIndex(ctx context.Context, blockHash common.Hash, index hexutil.Uint) hexutil.Bytes {
- if block, _ := s.b.BlockByHash(ctx, blockHash); block != nil {
- return newRPCRawTransactionFromBlockIndex(block, uint64(index))
- }
- return nil
-}
-
-// GetTransactionCount returns the number of transactions the given address has sent for the given block number
-func (s *PublicTransactionPoolAPI) GetTransactionCount(ctx context.Context, address common.Address, blockNrOrHash rpc.BlockNumberOrHash) (*hexutil.Uint64, error) {
- // Ask transaction pool for the nonce which includes pending transactions
- if blockNr, ok := blockNrOrHash.Number(); ok && blockNr == rpc.PendingBlockNumber {
- nonce, err := s.b.GetPoolNonce(ctx, address)
- if err != nil {
- return nil, err
- }
- return (*hexutil.Uint64)(&nonce), nil
- }
- // Resolve block number and use its state to ask for the nonce
- state, _, err := s.b.StateAndHeaderByNumberOrHash(ctx, blockNrOrHash)
- if state == nil || err != nil {
- return nil, err
- }
- nonce := state.GetNonce(address)
- return (*hexutil.Uint64)(&nonce), state.Error()
-}
-
-// GetTransactionByHash returns the transaction for the given hash
-func (s *PublicTransactionPoolAPI) GetTransactionByHash(ctx context.Context, hash common.Hash) (*RPCTransaction, error) {
- // Try to return an already finalized transaction
- tx, blockHash, blockNumber, index, err := s.b.GetTransaction(ctx, hash)
- if err != nil {
- return nil, err
- }
- if tx != nil {
- return newRPCTransaction(tx, blockHash, blockNumber, index), nil
- }
- // No finalized transaction, try to retrieve it from the pool
- if tx := s.b.GetPoolTransaction(hash); tx != nil {
- return newRPCPendingTransaction(tx), nil
- }
-
- // Transaction unknown, return as such
- return nil, nil
-}
-
-// GetRawTransactionByHash returns the bytes of the transaction for the given hash.
-func (s *PublicTransactionPoolAPI) GetRawTransactionByHash(ctx context.Context, hash common.Hash) (hexutil.Bytes, error) {
- // Retrieve a finalized transaction, or a pooled otherwise
- tx, _, _, _, err := s.b.GetTransaction(ctx, hash)
- if err != nil {
- return nil, err
- }
- if tx == nil {
- if tx = s.b.GetPoolTransaction(hash); tx == nil {
- // Transaction not found anywhere, abort
- return nil, nil
- }
- }
- // Serialize to RLP and return
- var blob bytes.Buffer
- if tx.Type() != types.LegacyTxType {
- if err := blob.WriteByte(tx.Type()); err != nil {
- return nil, err
- }
- }
- if err := rlp.Encode(&blob, tx); err != nil {
- return nil, err
- }
- return blob.Bytes(), nil
-}
-
-// GetTransactionReceipt returns the transaction receipt for the given transaction hash.
-func (s *PublicTransactionPoolAPI) GetTransactionReceipt(ctx context.Context, hash common.Hash) (map[string]interface{}, error) {
- tx, blockHash, blockNumber, index, err := s.b.GetTransaction(ctx, hash)
- if err != nil {
- return nil, nil
- }
- receipts, err := s.b.GetReceipts(ctx, blockHash)
- if err != nil {
- return nil, err
- }
- if len(receipts) <= int(index) {
- return nil, nil
- }
- receipt := receipts[index]
-
- // Derive the sender.
- signer := types.MakeSigner(s.b.ChainConfig(), blockNumber)
- from, _ := tx.Sender(*signer)
-
- fields := map[string]interface{}{
- "blockHash": blockHash,
- "blockNumber": hexutil.Uint64(blockNumber),
- "transactionHash": hash,
- "transactionIndex": hexutil.Uint64(index),
- "from": from,
- "to": tx.GetTo(),
- "gasUsed": hexutil.Uint64(receipt.GasUsed),
- "cumulativeGasUsed": hexutil.Uint64(receipt.CumulativeGasUsed),
- "contractAddress": nil,
- "logs": receipt.Logs,
- "logsBloom": receipt.Bloom,
- "type": hexutil.Uint(tx.Type()),
- }
-
- // Assign receipt status or post state.
- if len(receipt.PostState) > 0 {
- fields["root"] = hexutil.Bytes(receipt.PostState)
- } else {
- fields["status"] = hexutil.Uint(receipt.Status)
- }
- if receipt.Logs == nil {
- fields["logs"] = [][]*types.Log{}
- }
- // If the ContractAddress is 20 0x0 bytes, assume it is not a contract creation
- if receipt.ContractAddress != (common.Address{}) {
- fields["contractAddress"] = receipt.ContractAddress
- }
- return fields, nil
-}
-
-// SendTxArgs represents the arguments to sumbit a new transaction into the transaction pool.
-type SendTxArgs struct {
- From common.Address `json:"from"`
- To *common.Address `json:"to"`
- Gas *hexutil.Uint64 `json:"gas"`
- GasPrice *hexutil.Big `json:"gasPrice"`
- MaxPriorityFeePerGas *hexutil.Big `json:"tip"`
- MaxFeePerGas *hexutil.Big `json:"feeCap"`
- Value *hexutil.Big `json:"value"`
- Nonce *hexutil.Uint64 `json:"nonce"`
- // We accept "data" and "input" for backwards-compatibility reasons. "input" is the
- // newer name and should be preferred by clients.
- Data *hexutil.Bytes `json:"data"`
- Input *hexutil.Bytes `json:"input"`
-
- // For non-legacy transactions
- AccessList *types.AccessList `json:"accessList,omitempty"`
- ChainID *hexutil.Big `json:"chainId,omitempty"`
-}
-
-// setDefaults fills in default values for unspecified tx fields.
-func (args *SendTxArgs) setDefaults(ctx context.Context, b Backend) error {
- if args.GasPrice == nil {
- price, err := b.SuggestPrice(ctx)
- if err != nil {
- return err
- }
- args.GasPrice = (*hexutil.Big)(price)
- }
- if args.Value == nil {
- args.Value = new(hexutil.Big)
- }
- if args.Nonce == nil {
- nonce, err := b.GetPoolNonce(ctx, args.From)
- if err != nil {
- return err
- }
- args.Nonce = (*hexutil.Uint64)(&nonce)
- }
- if args.Data != nil && args.Input != nil && !bytes.Equal(*args.Data, *args.Input) {
- return errors.New(`both "data" and "input" are set and not equal. Please use "input" to pass transaction call data`)
- }
- if args.To == nil {
- // Contract creation
- var input []byte
- if args.Data != nil {
- input = *args.Data
- } else if args.Input != nil {
- input = *args.Input
- }
- if len(input) == 0 {
- return errors.New(`contract creation without any data provided`)
- }
- }
-
- // Estimate the gas usage if necessary.
- if args.Gas == nil {
- // For backwards-compatibility reason, we try both input and data
- // but input is preferred.
- input := args.Input
- if input == nil {
- input = args.Data
- }
- callArgs := CallArgs{
- From: &args.From, // From shouldn't be nil
- To: args.To,
- GasPrice: args.GasPrice,
- Value: args.Value,
- Data: input,
- AccessList: args.AccessList,
- }
- pendingBlockNr := rpc.BlockNumberOrHashWithNumber(rpc.PendingBlockNumber)
- estimated, err := DoEstimateGas(ctx, b, callArgs, pendingBlockNr, b.RPCGasCap())
- if err != nil {
- return err
- }
- args.Gas = &estimated
- log.Trace("Estimate gas usage automatically", "gas", args.Gas)
- }
- if args.ChainID == nil {
- id := (*hexutil.Big)(b.ChainConfig().ChainID)
- args.ChainID = id
- }
- return nil
-}
-
-// toTransaction converts the arguments to a transaction.
-// This assumes that setDefaults has been called.
-func (args *SendTxArgs) toTransaction() types.Transaction {
- var input []byte
- if args.Input != nil {
- input = *args.Input
- } else if args.Data != nil {
- input = *args.Data
- }
-
- var tx types.Transaction
- gasPrice, _ := uint256.FromBig((*big.Int)(args.GasPrice))
- value, _ := uint256.FromBig((*big.Int)(args.Value))
- if args.AccessList == nil {
- tx = &types.LegacyTx{
- CommonTx: types.CommonTx{
- To: args.To,
- Nonce: uint64(*args.Nonce),
- Gas: uint64(*args.Gas),
- Value: value,
- Data: input,
- },
- GasPrice: gasPrice,
- }
- } else {
- chainId, _ := uint256.FromBig((*big.Int)(args.ChainID))
- if args.MaxFeePerGas == nil {
- tx = &types.AccessListTx{
- LegacyTx: types.LegacyTx{
- CommonTx: types.CommonTx{
- To: args.To,
- Nonce: uint64(*args.Nonce),
- Gas: uint64(*args.Gas),
- Value: value,
- Data: input,
- },
- GasPrice: gasPrice,
- },
- ChainID: chainId,
- AccessList: *args.AccessList,
- }
- } else {
- tip, _ := uint256.FromBig((*big.Int)(args.MaxPriorityFeePerGas))
- feeCap, _ := uint256.FromBig((*big.Int)(args.MaxFeePerGas))
- tx = &types.DynamicFeeTransaction{
- CommonTx: types.CommonTx{
- To: args.To,
- Nonce: uint64(*args.Nonce),
- Gas: uint64(*args.Gas),
- Value: value,
- Data: input,
- },
- MaxPriorityFeePerGas: tip,
- MaxFeePerGas: feeCap,
- ChainID: chainId,
- AccessList: *args.AccessList,
- }
- }
- }
- return tx
-}
-
-// SubmitTransaction is a helper function that submits tx to txPool and logs a message.
-func SubmitTransaction(ctx context.Context, b Backend, tx types.Transaction) (common.Hash, error) {
- // If the transaction fee cap is already specified, ensure the
- // fee of the given transaction is _reasonable_.
- if err := checkTxFee(tx.GetPrice().ToBig(), tx.GetGas(), b.RPCTxFeeCap()); err != nil {
- return common.Hash{}, err
- }
- if !b.UnprotectedAllowed() && !tx.Protected() {
- // Ensure only eip155 signed transactions are submitted if EIP155Required is set.
- return common.Hash{}, errors.New("only replay-protected (EIP-155) transactions allowed over RPC")
- }
- if err := b.SendTx(ctx, tx); err != nil {
- return common.Hash{}, err
- }
- // Print a log with full tx details for manual investigations and interventions
- signer := types.MakeSigner(b.ChainConfig(), b.CurrentBlock().Number().Uint64())
- from, err := tx.Sender(*signer)
- if err != nil {
- return common.Hash{}, err
- }
-
- if tx.GetTo() == nil {
- addr := crypto.CreateAddress(from, tx.GetNonce())
- log.Info("Submitted contract creation", "hash", tx.Hash().Hex(), "from", from, "nonce", tx.GetNonce(), "contract", addr.Hex(), "value", tx.GetValue())
- } else {
- log.Info("Submitted transaction", "hash", tx.Hash().Hex(), "from", from, "nonce", tx.GetNonce(), "recipient", tx.GetTo(), "value", tx.GetValue())
- }
- return tx.Hash(), nil
-}
-
-// FillTransaction fills the defaults (nonce, gas, gasPrice) on a given unsigned transaction,
-// and returns it to the caller for further processing (signing + broadcast)
-func (s *PublicTransactionPoolAPI) FillTransaction(ctx context.Context, args SendTxArgs) (*SignTransactionResult, error) {
- // Set some sanity defaults and terminate on failure
- if err := args.setDefaults(ctx, s.b); err != nil {
- return nil, err
- }
- // Assemble the transaction and obtain rlp
- tx := args.toTransaction()
- var blob bytes.Buffer
- if tx.Type() != types.LegacyTxType {
- if err := blob.WriteByte(tx.Type()); err != nil {
- return nil, err
- }
- }
- if err := rlp.Encode(&blob, tx); err != nil {
- return nil, err
- }
- return &SignTransactionResult{blob.Bytes(), tx}, nil
-}
-
-// SendRawTransaction will add the signed transaction to the transaction pool.
-// The sender is responsible for signing the transaction and using the correct nonce.
-func (s *PublicTransactionPoolAPI) SendRawTransaction(ctx context.Context, input hexutil.Bytes) (common.Hash, error) {
- tx, err := types.DecodeTransaction(rlp.NewStream(bytes.NewReader(input), 0))
- if err != nil {
- return common.Hash{}, err
- }
- return SubmitTransaction(ctx, s.b, tx)
-}
-
-// SignTransactionResult represents a RLP encoded signed transaction.
-type SignTransactionResult struct {
- Raw hexutil.Bytes `json:"raw"`
- Tx types.Transaction `json:"tx"`
-}
-
-// PublicDebugAPI is the collection of Ethereum APIs exposed over the public
-// debugging endpoint.
-type PublicDebugAPI struct {
- b Backend
-}
-
-// NewPublicDebugAPI creates a new API definition for the public debug methods
-// of the Ethereum service.
-func NewPublicDebugAPI(b Backend) *PublicDebugAPI {
- return &PublicDebugAPI{b: b}
-}
-
-// GetBlockRlp retrieves the RLP encoded for of a single block.
-func (api *PublicDebugAPI) GetBlockRlp(ctx context.Context, number uint64) (string, error) {
- block, _ := api.b.BlockByNumber(ctx, rpc.BlockNumber(number))
- if block == nil {
- return "", fmt.Errorf("block #%d not found", number)
- }
- encoded, err := rlp.EncodeToBytes(block)
- if err != nil {
- return "", err
- }
- return fmt.Sprintf("%x", encoded), nil
-}
-
-// PrintBlock retrieves a block and returns its pretty printed form.
-func (api *PublicDebugAPI) PrintBlock(ctx context.Context, number uint64) (string, error) {
- block, _ := api.b.BlockByNumber(ctx, rpc.BlockNumber(number))
- if block == nil {
- return "", fmt.Errorf("block #%d not found", number)
- }
- return spew.Sdump(block), nil
-}
-
-// SeedHash retrieves the seed hash of a block.
-func (api *PublicDebugAPI) SeedHash(ctx context.Context, number uint64) (string, error) {
- block, _ := api.b.BlockByNumber(ctx, rpc.BlockNumber(number))
- if block == nil {
- return "", fmt.Errorf("block #%d not found", number)
- }
- return fmt.Sprintf("0x%x", ethash.SeedHash(number)), nil
-}
-
-// PrivateDebugAPI is the collection of Ethereum APIs exposed over the private
-// debugging endpoint.
-type PrivateDebugAPI struct {
- b Backend
-}
-
-// NewPrivateDebugAPI creates a new API definition for the private debug methods
-// of the Ethereum service.
-func NewPrivateDebugAPI(b Backend) *PrivateDebugAPI {
- return &PrivateDebugAPI{b: b}
-}
-
-// ChaindbProperty returns properties of the chain database.
-func (api *PrivateDebugAPI) ChaindbProperty(property string) (string, error) {
- return "N/A", nil
-}
-
-// ChaindbCompact flattens the entire key-value database into a single level,
-// removing all unused slots and merging all keys.
-func (api *PrivateDebugAPI) ChaindbCompact() error {
- // Intentionally disabled in Erigon
- return nil
-}
-
-// SetHead rewinds the head of the blockchain to a previous block.
-func (api *PrivateDebugAPI) SetHead(number hexutil.Uint64) {
- api.b.SetHead(uint64(number))
-}
-
-// PublicNetAPI offers network related RPC methods
-type PublicNetAPI struct {
- net *p2p.Server
- networkVersion uint64
-}
-
-// NewPublicNetAPI creates a new net API instance.
-func NewPublicNetAPI(net *p2p.Server, networkVersion uint64) *PublicNetAPI {
- return &PublicNetAPI{net, networkVersion}
-}
-
-// Listening returns an indication if the node is listening for network connections.
-func (s *PublicNetAPI) Listening() bool {
- return true // always listening
-}
-
-// PeerCount returns the number of connected peers
-func (s *PublicNetAPI) PeerCount() hexutil.Uint {
- return hexutil.Uint(s.net.PeerCount())
-}
-
-// Version returns the current ethereum protocol version.
-func (s *PublicNetAPI) Version() string {
- return fmt.Sprintf("%d", s.networkVersion)
-}
-
-// checkTxFee is an internal function used to check whether the fee of
-// the given transaction is _reasonable_(under the cap).
-func checkTxFee(gasPrice *big.Int, gas uint64, cap float64) error {
- // Short circuit if there is no cap for transaction fee at all.
- if cap == 0 {
- return nil
- }
- feeEth := new(big.Float).Quo(new(big.Float).SetInt(new(big.Int).Mul(gasPrice, new(big.Int).SetUint64(gas))), new(big.Float).SetInt(big.NewInt(params.Ether)))
- feeFloat, _ := feeEth.Float64()
- if feeFloat > cap {
- return fmt.Errorf("tx fee (%.2f ether) exceeds the configured cap (%.2f ether)", feeFloat, cap)
- }
- return nil
-}
-*/
diff --git a/erigon_internal/ethapi/backend.go b/erigon_internal/ethapi/backend.go
deleted file mode 100644
index cef737c..0000000
--- a/erigon_internal/ethapi/backend.go
+++ /dev/null
@@ -1,56 +0,0 @@
-// Copyright 2015 The go-ethereum Authors
-// This file is part of the go-ethereum library.
-//
-// The go-ethereum library 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.
-//
-// The go-ethereum library 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 the go-ethereum library. If not, see .
-
-// Package ethapi implements the general Ethereum API functions.
-package ethapi
-
-/*
-func GetAPIs(apiBackend Backend) []rpc.API {
- nonceLock := new(AddrLocker)
- return []rpc.API{
- {
- Namespace: "eth",
- Version: "1.0",
- Service: NewPublicEthereumAPI(apiBackend),
- Public: true,
- }, {
- Namespace: "eth",
- Version: "1.0",
- Service: NewPublicBlockChainAPI(apiBackend),
- Public: true,
- }, {
- Namespace: "eth",
- Version: "1.0",
- Service: NewPublicTransactionPoolAPI(apiBackend, nonceLock),
- Public: true,
- }, {
- Namespace: "txpool",
- Version: "1.0",
- Service: NewPublicTxPoolAPI(apiBackend),
- Public: true,
- }, {
- Namespace: "debug",
- Version: "1.0",
- Service: NewPublicDebugAPI(apiBackend),
- Public: true,
- }, {
- Namespace: "debug",
- Version: "1.0",
- Service: NewPrivateDebugAPI(apiBackend),
- },
- }
-}
-*/
diff --git a/erigon_internal/ethapi/get_proof.go b/erigon_internal/ethapi/get_proof.go
deleted file mode 100644
index 6c45f59..0000000
--- a/erigon_internal/ethapi/get_proof.go
+++ /dev/null
@@ -1,234 +0,0 @@
-package ethapi
-
-import (
- "bytes"
-
- "github.com/ledgerwatch/erigon/common"
- "github.com/ledgerwatch/erigon/common/hexutil"
- "github.com/ledgerwatch/erigon/core/types/accounts"
- "github.com/ledgerwatch/erigon/turbo/trie"
-)
-
-// Result structs for GetProof
-type AccountResult struct {
- Address common.Address `json:"address"`
- AccountProof []string `json:"accountProof"`
- Balance *hexutil.Big `json:"balance"`
- CodeHash common.Hash `json:"codeHash"`
- Nonce hexutil.Uint64 `json:"nonce"`
- StorageHash common.Hash `json:"storageHash"`
- StorageProof []StorageResult `json:"storageProof"`
-}
-type StorageResult struct {
- Key string `json:"key"`
- Value *hexutil.Big `json:"value"`
- Proof []string `json:"proof"`
-}
-
-/*TODO: to support proofs
-func (s *PublicBlockChainAPI) GetProof(ctx context.Context, address common.Address, storageKeys []string, blockNr rpc.BlockNumber) (*AccountResult, error) {
- block := uint64(blockNr.Int64()) + 1
- db := s.b.ChainDb()
- ts := dbutils.EncodeBlockNumber(block)
- accountMap := make(map[string]*accounts.Account)
- if err := changeset.Walk(db, dbutils.AccountChangeSetBucket, ts, 0, func(blockN uint64, a, v []byte) (bool, error) {
- a, v = common.CopyBytes(a), common.CopyBytes(v)
- var kHash, err = common.HashData(a)
- if err != nil {
- return false, err
- }
- k := kHash[:]
- if _, ok := accountMap[string(k)]; !ok {
- if len(v) > 0 {
- var a accounts.Account
- if innerErr := a.DecodeForStorage(v); innerErr != nil {
- return false, innerErr
- }
- accountMap[string(k)] = &a
- } else {
- accountMap[string(k)] = nil
- }
- }
- return true, nil
- }); err != nil {
- return nil, err
- }
-
- storageMap := make(map[string][]byte)
- if err := changeset.Walk(db, dbutils.AccountChangeSetBucket, ts, 0, func(blockN uint64, a, v []byte) (bool, error) {
- a, v = common.CopyBytes(a), common.CopyBytes(v)
- var kHash, err = common.HashData(a)
- if err != nil {
- return true, err
- }
- k := kHash[:]
- if _, ok := storageMap[string(k)]; !ok {
- storageMap[string(k)] = v
- }
- return true, nil
- }); err != nil {
- return nil, err
- }
- var unfurlList = make([]string, len(accountMap)+len(storageMap))
- unfurl := trie.NewRetainList(0)
- i := 0
- for ks, acc := range accountMap {
- unfurlList[i] = ks
- i++
- unfurl.AddKey([]byte(ks))
- if acc != nil {
- // Fill the code hashes
- if acc.Incarnation > 0 && acc.IsEmptyCodeHash() {
- if codeHash, err1 := db.Get(dbutils.ContractCodeBucket, dbutils.GenerateStoragePrefix([]byte(ks), acc.Incarnation)); err1 == nil {
- copy(acc.CodeHash[:], codeHash)
- } else {
- return nil, err1
- }
- }
- }
- }
- for ks := range storageMap {
- unfurlList[i] = ks
- i++
- var sk [64]byte
- copy(sk[:], []byte(ks)[:common.HashLength])
- copy(sk[common.HashLength:], []byte(ks)[common.HashLength+common.IncarnationLength:])
- unfurl.AddKey(sk[:])
- }
- rl := trie.NewRetainList(0)
- addrHash, err := common.HashData(address[:])
- if err != nil {
- return nil, err
- }
- rl.AddKey(addrHash[:])
- unfurl.AddKey(addrHash[:])
- for _, key := range storageKeys {
- keyAsHash := common.HexToHash(key)
- if keyHash, err1 := common.HashData(keyAsHash[:]); err1 == nil {
- trieKey := append(addrHash[:], keyHash[:]...)
- rl.AddKey(trieKey)
- unfurl.AddKey(trieKey)
- } else {
- return nil, err1
- }
- }
- sort.Strings(unfurlList)
- loader := trie.NewFlatDBTrieLoader("checkRoots")
- if err = loader.Reset(unfurl, nil, nil, false); err != nil {
- panic(err)
- }
- r := &Receiver{defaultReceiver: trie.NewDefaultReceiver(), unfurlList: unfurlList, accountMap: accountMap, storageMap: storageMap}
- r.defaultReceiver.Reset(rl, nil, false)
- loader.SetStreamReceiver(r)
- _, err = loader.CalcTrieRoot(db.(ethdb.HasTx).Tx().(ethdb.RwTx), []byte{}, nil)
- if err != nil {
- panic(err)
- }
- hash, err := rawdb.ReadCanonicalHash(db, block-1)
- if err != nil {
- return nil, err
- }
- header := rawdb.ReadHeader(db, hash, block-1)
- tr := trie.New(header.Root)
- if err = tr.HookSubTries(subTries, [][]byte{nil}); err != nil {
- return nil, err
- }
- accountProof, err2 := tr.Prove(addrHash[:], 0, false)
- if err2 != nil {
- return nil, err2
- }
- storageProof := make([]StorageResult, len(storageKeys))
- for i, key := range storageKeys {
- keyAsHash := common.HexToHash(key)
- if keyHash, err1 := common.HashData(keyAsHash[:]); err1 == nil {
- trieKey := append(addrHash[:], keyHash[:]...)
- if proof, err3 := tr.Prove(trieKey, 64 , true); err3 == nil {
- v, _ := tr.Get(trieKey)
- bv := new(big.Int)
- bv.SetBytes(v)
- storageProof[i] = StorageResult{key, (*hexutil.Big)(bv), toHexSlice(proof)}
- } else {
- return nil, err3
- }
- } else {
- return nil, err1
- }
- }
- acc, found := tr.GetAccount(addrHash[:])
- if !found {
- return nil, nil
- }
- return &AccountResult{
- Address: address,
- AccountProof: toHexSlice(accountProof),
- Balance: (*hexutil.Big)(acc.Balance.ToBig()),
- CodeHash: acc.CodeHash,
- Nonce: hexutil.Uint64(acc.Nonce),
- StorageHash: acc.Root,
- StorageProof: storageProof,
- }, nil
- return &AccountResult{}, nil
-}
-*/
-
-type Receiver struct {
- defaultReceiver *trie.RootHashAggregator
- accountMap map[string]*accounts.Account
- storageMap map[string][]byte
- unfurlList []string
- currentIdx int
-}
-
-func (r *Receiver) Root() common.Hash { panic("don't call me") }
-func (r *Receiver) Receive(
- itemType trie.StreamItem,
- accountKey []byte,
- storageKey []byte,
- accountValue *accounts.Account,
- storageValue []byte,
- hash []byte,
- hasTree bool,
- cutoff int,
-) error {
- for r.currentIdx < len(r.unfurlList) {
- ks := r.unfurlList[r.currentIdx]
- k := []byte(ks)
- var c int
- switch itemType {
- case trie.StorageStreamItem, trie.SHashStreamItem:
- c = bytes.Compare(k, storageKey)
- case trie.AccountStreamItem, trie.AHashStreamItem:
- c = bytes.Compare(k, accountKey)
- case trie.CutoffStreamItem:
- c = -1
- }
- if c > 0 {
- return r.defaultReceiver.Receive(itemType, accountKey, storageKey, accountValue, storageValue, hash, hasTree, cutoff)
- }
- if len(k) > common.HashLength {
- v := r.storageMap[ks]
- if c <= 0 && len(v) > 0 {
- if err := r.defaultReceiver.Receive(trie.StorageStreamItem, nil, k, nil, v, nil, hasTree, 0); err != nil {
- return err
- }
- }
- } else {
- v := r.accountMap[ks]
- if c <= 0 && v != nil {
- if err := r.defaultReceiver.Receive(trie.AccountStreamItem, k, nil, v, nil, nil, hasTree, 0); err != nil {
- return err
- }
- }
- }
- r.currentIdx++
- if c == 0 {
- return nil
- }
- }
- // We ran out of modifications, simply pass through
- return r.defaultReceiver.Receive(itemType, accountKey, storageKey, accountValue, storageValue, hash, hasTree, cutoff)
-}
-
-func (r *Receiver) Result() trie.SubTries {
- return r.defaultReceiver.Result()
-}
diff --git a/erigon_internal/ethapi/state_overrides.go b/erigon_internal/ethapi/state_overrides.go
deleted file mode 100644
index d3159f3..0000000
--- a/erigon_internal/ethapi/state_overrides.go
+++ /dev/null
@@ -1,50 +0,0 @@
-package ethapi
-
-import (
- "fmt"
- "math/big"
-
- "github.com/holiman/uint256"
- "github.com/ledgerwatch/erigon/common"
- "github.com/ledgerwatch/erigon/core/state"
-)
-
-type StateOverrides map[common.Address]Account
-
-func (overrides *StateOverrides) Override(state *state.IntraBlockState) error {
-
- for addr, account := range *overrides {
- // Override account nonce.
- if account.Nonce != nil {
- state.SetNonce(addr, uint64(*account.Nonce))
- }
- // Override account(contract) code.
- if account.Code != nil {
- state.SetCode(addr, *account.Code)
- }
- // Override account balance.
- if account.Balance != nil {
- balance, overflow := uint256.FromBig((*big.Int)(*account.Balance))
- if overflow {
- return fmt.Errorf("account.Balance higher than 2^256-1")
- }
- state.SetBalance(addr, balance)
- }
- if account.State != nil && account.StateDiff != nil {
- return fmt.Errorf("account %s has both 'state' and 'stateDiff'", addr.Hex())
- }
- // Replace entire state if caller requires.
- if account.State != nil {
- state.SetStorage(addr, *account.State)
- }
- // Apply state diff into specified accounts.
- if account.StateDiff != nil {
- for key, value := range *account.StateDiff {
- key := key
- state.SetState(addr, &key, value)
- }
- }
- }
-
- return nil
-}
diff --git a/erigon_internal/logging/flags.go b/erigon_internal/logging/flags.go
deleted file mode 100644
index 67d0fd9..0000000
--- a/erigon_internal/logging/flags.go
+++ /dev/null
@@ -1,56 +0,0 @@
-package logging
-
-import (
- "github.com/ledgerwatch/log/v3"
- "github.com/urfave/cli"
-)
-
-var (
- LogJsonFlag = cli.BoolFlag{
- Name: "log.json",
- Usage: "Format console logs with JSON",
- }
-
- LogConsoleJsonFlag = cli.BoolFlag{
- Name: "log.console.json",
- Usage: "Format console logs with JSON",
- }
-
- LogDirJsonFlag = cli.BoolFlag{
- Name: "log.dir.json",
- Usage: "Format file logs with JSON",
- }
-
- LogVerbosityFlag = cli.StringFlag{
- Name: "verbosity",
- Usage: "Set the log level for console logs",
- Value: log.LvlInfo.String(),
- }
-
- LogConsoleVerbosityFlag = cli.StringFlag{
- Name: "log.console.verbosity",
- Usage: "Set the log level for console logs",
- Value: log.LvlInfo.String(),
- }
-
- LogDirPathFlag = cli.StringFlag{
- Name: "log.dir.path",
- Usage: "Path to store user and error logs to disk",
- }
-
- LogDirVerbosityFlag = cli.StringFlag{
- Name: "log.dir.verbosity",
- Usage: "Set the log verbosity for logs stored to disk",
- Value: log.LvlDebug.String(),
- }
-)
-
-var Flags = []cli.Flag{
- LogJsonFlag,
- LogConsoleJsonFlag,
- LogDirJsonFlag,
- LogVerbosityFlag,
- LogConsoleVerbosityFlag,
- LogDirPathFlag,
- LogDirVerbosityFlag,
-}
diff --git a/erigon_internal/logging/logging.go b/erigon_internal/logging/logging.go
deleted file mode 100644
index 7c83c2b..0000000
--- a/erigon_internal/logging/logging.go
+++ /dev/null
@@ -1,162 +0,0 @@
-package logging
-
-import (
- "flag"
- "os"
- "path"
- "strconv"
-
- "github.com/ledgerwatch/log/v3"
- "github.com/spf13/cobra"
- "github.com/urfave/cli"
-)
-
-func GetLoggerCtx(filePrefix string, ctx *cli.Context) log.Logger {
- var consoleJson = ctx.Bool(LogJsonFlag.Name) || ctx.Bool(LogConsoleJsonFlag.Name)
- var dirJson = ctx.Bool(LogDirJsonFlag.Name)
-
- consoleLevel, lErr := tryGetLogLevel(ctx.String(LogConsoleVerbosityFlag.Name))
- if lErr != nil {
- // try verbosity flag
- consoleLevel, lErr = tryGetLogLevel(ctx.String(LogVerbosityFlag.Name))
- if lErr != nil {
- consoleLevel = log.LvlInfo
- }
- }
-
- dirLevel, dErr := tryGetLogLevel(ctx.String(LogDirVerbosityFlag.Name))
- if dErr != nil {
- dirLevel = log.LvlDebug
- }
-
- dirPath := ctx.String(LogDirPathFlag.Name)
- return initSeparatedLogging(filePrefix, dirPath, consoleLevel, dirLevel, consoleJson, dirJson)
-}
-
-func GetLoggerCmd(filePrefix string, cmd *cobra.Command) log.Logger {
-
- logJsonVal, ljerr := cmd.Flags().GetBool(LogJsonFlag.Name)
- if ljerr != nil {
- logJsonVal = false
- }
-
- logConsoleJsonVal, lcjerr := cmd.Flags().GetBool(LogConsoleJsonFlag.Name)
- if lcjerr != nil {
- logConsoleJsonVal = false
- }
-
- var consoleJson = logJsonVal || logConsoleJsonVal
- dirJson, djerr := cmd.Flags().GetBool(LogDirJsonFlag.Name)
- if djerr != nil {
- dirJson = false
- }
-
- consoleLevel, lErr := tryGetLogLevel(cmd.Flags().Lookup(LogConsoleVerbosityFlag.Name).Value.String())
- if lErr != nil {
- // try verbosity flag
- consoleLevel, lErr = tryGetLogLevel(cmd.Flags().Lookup(LogVerbosityFlag.Name).Value.String())
- if lErr != nil {
- consoleLevel = log.LvlInfo
- }
- }
-
- dirLevel, dErr := tryGetLogLevel(cmd.Flags().Lookup(LogDirVerbosityFlag.Name).Value.String())
- if dErr != nil {
- dirLevel = log.LvlDebug
- }
-
- dirPath := cmd.Flags().Lookup(LogDirPathFlag.Name).Value.String()
- return initSeparatedLogging(filePrefix, dirPath, consoleLevel, dirLevel, consoleJson, dirJson)
-}
-
-func GetLogger(filePrefix string) log.Logger {
- var logConsoleVerbosity = flag.String(LogConsoleVerbosityFlag.Name, "", LogConsoleVerbosityFlag.Usage)
- var logDirVerbosity = flag.String(LogDirVerbosityFlag.Name, "", LogDirVerbosityFlag.Usage)
- var logDirPath = flag.String(LogDirPathFlag.Name, "", LogDirPathFlag.Usage)
- var logVerbosity = flag.String(LogVerbosityFlag.Name, "", LogVerbosityFlag.Usage)
- var logConsoleJson = flag.Bool(LogConsoleJsonFlag.Name, false, LogConsoleJsonFlag.Usage)
- var logJson = flag.Bool(LogJsonFlag.Name, false, LogJsonFlag.Usage)
- var logDirJson = flag.Bool(LogDirJsonFlag.Name, false, LogDirJsonFlag.Usage)
- flag.Parse()
-
- var consoleJson = *logJson || *logConsoleJson
- var dirJson = logDirJson
-
- consoleLevel, lErr := tryGetLogLevel(*logConsoleVerbosity)
- if lErr != nil {
- // try verbosity flag
- consoleLevel, lErr = tryGetLogLevel(*logVerbosity)
- if lErr != nil {
- consoleLevel = log.LvlInfo
- }
- }
-
- dirLevel, dErr := tryGetLogLevel(*logDirVerbosity)
- if dErr != nil {
- dirLevel = log.LvlDebug
- }
-
- return initSeparatedLogging(filePrefix, *logDirPath, consoleLevel, dirLevel, consoleJson, *dirJson)
-}
-
-func initSeparatedLogging(
- filePrefix string,
- dirPath string,
- consoleLevel log.Lvl,
- dirLevel log.Lvl,
- consoleJson bool,
- dirJson bool) log.Logger {
-
- logger := log.Root()
-
- if consoleJson {
- log.Root().SetHandler(log.LvlFilterHandler(consoleLevel, log.StreamHandler(os.Stderr, log.JsonFormat())))
- } else {
- log.Root().SetHandler(log.LvlFilterHandler(consoleLevel, log.StderrHandler))
- }
-
- if len(dirPath) == 0 {
- logger.Warn("no log dir set, console logging only")
- return logger
- }
-
- err := os.MkdirAll(dirPath, 0764)
- if err != nil {
- logger.Warn("failed to create log dir, console logging only")
- return logger
- }
-
- dirFormat := log.LogfmtFormat()
- if dirJson {
- dirFormat = log.JsonFormat()
- }
-
- userLog, err := log.FileHandler(path.Join(dirPath, filePrefix+"-user.log"), dirFormat, 1<<27) // 128Mb
- if err != nil {
- logger.Warn("failed to open user log, console logging only")
- return logger
- }
- errLog, err := log.FileHandler(path.Join(dirPath, filePrefix+"-error.log"), dirFormat, 1<<27) // 128Mb
- if err != nil {
- logger.Warn("failed to open error log, console logging only")
- return logger
- }
-
- mux := log.MultiHandler(logger.GetHandler(), log.LvlFilterHandler(dirLevel, userLog), log.LvlFilterHandler(log.LvlError, errLog))
- log.Root().SetHandler(mux)
- logger.SetHandler(mux)
- logger.Info("logging to file system", "log dir", dirPath, "file prefix", filePrefix, "log level", dirLevel, "json", dirJson)
- return logger
-}
-
-func tryGetLogLevel(s string) (log.Lvl, error) {
- lvl, err := log.LvlFromString(s)
- if err != nil {
- l, err := strconv.Atoi(s)
- if err != nil {
- return 0, err
- }
- return log.Lvl(l), nil
- }
- return lvl, nil
-}
diff --git a/go.mod b/go.mod
index 51cd493..1687f44 100644
--- a/go.mod
+++ b/go.mod
@@ -6,24 +6,23 @@ replace github.com/tendermint/tendermint => github.com/bnb-chain/tendermint v0.3
require (
github.com/RoaringBitmap/roaring v1.2.1
- github.com/VictoriaMetrics/metrics v1.22.2
github.com/go-chi/chi/v5 v5.0.7
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d
github.com/holiman/uint256 v1.2.1
- github.com/ledgerwatch/erigon v1.9.7-0.20221024030055-592ad5792127
- github.com/ledgerwatch/erigon-lib v0.0.0-20221024030034-c1965e9c5ae3
+ github.com/ledgerwatch/erigon v1.9.7-0.20221025025825-26fdf9169d27
+ github.com/ledgerwatch/erigon-lib v0.0.0-20221024025924-48ff56eead80
github.com/ledgerwatch/log/v3 v3.6.0
github.com/spf13/cobra v1.5.0
- github.com/urfave/cli v1.22.9
golang.org/x/sync v0.1.0
- golang.org/x/sys v0.1.0
google.golang.org/grpc v1.50.1
google.golang.org/protobuf v1.28.1
)
require (
crawshaw.io/sqlite v0.3.3-0.20210127221821-98b1f83c5508 // indirect
+ gfx.cafe/open/4bytes v0.0.0-20221025060640-c4301cc087ee // indirect
github.com/VictoriaMetrics/fastcache v1.12.0 // indirect
+ github.com/VictoriaMetrics/metrics v1.22.2 // indirect
github.com/ajwerner/btree v0.0.0-20211221152037-f427b3e689c0 // indirect
github.com/alecthomas/atomic v0.1.0-alpha2 // indirect
github.com/anacrolix/chansync v0.3.0 // indirect
@@ -46,6 +45,7 @@ require (
github.com/benbjohnson/immutable v0.3.0 // indirect
github.com/benesch/cgosymbolizer v0.0.0-20190515212042-bec6fe6e597b // indirect
github.com/bits-and-blooms/bitset v1.2.2 // indirect
+ github.com/blang/semver v3.5.1+incompatible // indirect
github.com/bradfitz/iter v0.0.0-20191230175014-e8f45d346db8 // indirect
github.com/btcsuite/btcd v0.22.0-beta // indirect
github.com/c2h5oh/datasize v0.0.0-20220606134207-859f65c6625b // indirect
@@ -72,7 +72,7 @@ require (
github.com/goccy/go-json v0.9.7 // indirect
github.com/gofrs/flock v0.8.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
- github.com/golang-jwt/jwt/v4 v4.4.1 // indirect
+ github.com/golang-jwt/jwt/v4 v4.4.2 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/btree v1.1.2 // indirect
@@ -86,7 +86,8 @@ require (
github.com/jackpal/go-nat-pmp v1.0.2 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kevinburke/go-bindata v3.21.0+incompatible // indirect
- github.com/ledgerwatch/erigon-snapshot v1.1.1-0.20221023043405-d157dec75e9a // indirect
+ github.com/klauspost/compress v1.15.11 // indirect
+ github.com/ledgerwatch/erigon-snapshot v1.1.1-0.20221025023844-6e716b9e651c // indirect
github.com/ledgerwatch/secp256k1 v1.0.0 // indirect
github.com/lispad/go-generics-tools v1.1.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
@@ -94,6 +95,10 @@ require (
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/mschoch/smat v0.2.0 // indirect
+ github.com/openacid/errors v0.8.1 // indirect
+ github.com/openacid/low v0.1.14 // indirect
+ github.com/openacid/must v0.1.3 // indirect
+ github.com/openacid/slim v0.5.11 // indirect
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect
github.com/pelletier/go-toml/v2 v2.0.5 // indirect
github.com/pion/datachannel v1.5.2 // indirect
@@ -128,6 +133,7 @@ require (
github.com/torquem-ch/mdbx-go v0.26.1 // indirect
github.com/ugorji/go/codec v1.1.13 // indirect
github.com/ugorji/go/codec/codecgen v1.1.13 // indirect
+ github.com/urfave/cli v1.22.9 // indirect
github.com/valyala/fastjson v1.6.3 // indirect
github.com/valyala/fastrand v1.1.0 // indirect
github.com/valyala/histogram v1.2.0 // indirect
@@ -138,11 +144,12 @@ require (
go.uber.org/atomic v1.10.0 // indirect
golang.org/x/crypto v0.1.0 // indirect
golang.org/x/exp v0.0.0-20221018221608-02f3b879a704 // indirect
- golang.org/x/mod v0.6.0 // indirect
+ golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect
golang.org/x/net v0.1.0 // indirect
+ golang.org/x/sys v0.1.0 // indirect
golang.org/x/text v0.4.0 // indirect
golang.org/x/time v0.1.0 // indirect
- golang.org/x/tools v0.2.0 // indirect
+ golang.org/x/tools v0.1.12 // indirect
google.golang.org/genproto v0.0.0-20211118181313-81c1377c94b1 // indirect
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.2.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
diff --git a/go.sum b/go.sum
index 018e9a8..fd52a9b 100644
--- a/go.sum
+++ b/go.sum
@@ -6,6 +6,8 @@ crawshaw.io/sqlite v0.3.2/go.mod h1:igAO5JulrQ1DbdZdtVq48mnZUBAPOeFzer7VhDWNtW4=
crawshaw.io/sqlite v0.3.3-0.20210127221821-98b1f83c5508 h1:fILCBBFnjnrQ0whVJlGhfv1E/QiaFDNtGFBObEVRnYg=
crawshaw.io/sqlite v0.3.3-0.20210127221821-98b1f83c5508/go.mod h1:igAO5JulrQ1DbdZdtVq48mnZUBAPOeFzer7VhDWNtW4=
filippo.io/edwards25519 v1.0.0-rc.1 h1:m0VOOB23frXZvAOK44usCgLWvtsxIoMCTBGJZlpmGfU=
+gfx.cafe/open/4bytes v0.0.0-20221025060640-c4301cc087ee h1:Wbz69Iw7rhp7UbCNeHs8lSkUoha9cHwvXz9gVZvD+Fg=
+gfx.cafe/open/4bytes v0.0.0-20221025060640-c4301cc087ee/go.mod h1:2KCpg7z6U0ePqyX//YkaYEP9aJnmU5HoB6cnXVLR/d0=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
@@ -114,6 +116,8 @@ github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kB
github.com/bits-and-blooms/bitset v1.2.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA=
github.com/bits-and-blooms/bitset v1.2.2 h1:J5gbX05GpMdBjCvQ9MteIg2KKDExr7DrgK+Yc15FvIk=
github.com/bits-and-blooms/bitset v1.2.2/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA=
+github.com/blang/semver v3.5.1+incompatible h1:cQNTCjp13qL8KC3Nbxr/y2Bqb63oX6wdnnjpJbkM4JQ=
+github.com/blang/semver v3.5.1+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk=
github.com/bnb-chain/tendermint v0.31.12 h1:g+blWaXkRw6iHa56lcRfRzPXHgURCWPmgIvaGBSV7Zc=
github.com/bnb-chain/tendermint v0.31.12/go.mod h1:j6XU7CArrhQ+9XBMRwdIz63iUxdVwSrZ8f7vP7gcCqg=
github.com/bradfitz/iter v0.0.0-20140124041915-454541ec3da2/go.mod h1:PyRFw1Lt2wKX4ZVSQ2mk+PeDa1rxyObEDlApuIsUKuo=
@@ -249,8 +253,8 @@ github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7a
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
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.4.1 h1:pC5DB52sCeK48Wlb9oPcdhnjkz1TKt1D/P7WKJ0kUcQ=
-github.com/golang-jwt/jwt/v4 v4.4.1/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
+github.com/golang-jwt/jwt/v4 v4.4.2 h1:rcc4lwaZgFMCZ5jxF9ABolDcIHdBytAFgqFPbSJQAYs=
+github.com/golang-jwt/jwt/v4 v4.4.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
@@ -373,6 +377,8 @@ github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvW
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.15.11 h1:Lcadnb3RKGin4FYM/orgq0qde+nc15E5Cbqg4B9Sx9c=
+github.com/klauspost/compress v1.15.11/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM=
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=
@@ -387,12 +393,12 @@ github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/kylelemons/godebug v0.0.0-20170224010052-a616ab194758 h1:0D5M2HQSGD3PYPwICLl+/9oulQauOuETfgFvhBDffs0=
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/ledgerwatch/erigon v1.9.7-0.20221024030055-592ad5792127 h1:6CpFRXkf6p3p1hUGNhjy3KaghtLxv/Q9aPFv0G1rXLU=
-github.com/ledgerwatch/erigon v1.9.7-0.20221024030055-592ad5792127/go.mod h1:2uW5KjsMycyNF0KSiJKxKfdKFwlf91Hk0YDmRODFe3I=
-github.com/ledgerwatch/erigon-lib v0.0.0-20221024030034-c1965e9c5ae3 h1:8Kf5Yi9F1Dcmr3KrqvIM02SrPEPMzD+f7aIFaaPrxGw=
-github.com/ledgerwatch/erigon-lib v0.0.0-20221024030034-c1965e9c5ae3/go.mod h1:jv4jmffliy8Us1wXdT6Q1f/nrrmC6Xrr6V70JxZRp48=
-github.com/ledgerwatch/erigon-snapshot v1.1.1-0.20221023043405-d157dec75e9a h1:5Lw7NR/KWxtAokY11DKaMnrI6Zb04OzX8BQMbF8Lu/w=
-github.com/ledgerwatch/erigon-snapshot v1.1.1-0.20221023043405-d157dec75e9a/go.mod h1:3AuPxZc85jkehh/HA9h8gabv5MSi3kb/ddtzBsTVJFo=
+github.com/ledgerwatch/erigon v1.9.7-0.20221025025825-26fdf9169d27 h1:fPPn9w19eXQwYzVR+2qQy8gotVxGSWw5rtrwdVH10ec=
+github.com/ledgerwatch/erigon v1.9.7-0.20221025025825-26fdf9169d27/go.mod h1:+Zpwa8IkLCBQqfXrRjXO5qbvxkgBsv7D9EktGuh6iaU=
+github.com/ledgerwatch/erigon-lib v0.0.0-20221024025924-48ff56eead80 h1:cXOkc2KEW0AMwXacC3h5Ugwm7np4etAQfN7xM7b3cSA=
+github.com/ledgerwatch/erigon-lib v0.0.0-20221024025924-48ff56eead80/go.mod h1:jv4jmffliy8Us1wXdT6Q1f/nrrmC6Xrr6V70JxZRp48=
+github.com/ledgerwatch/erigon-snapshot v1.1.1-0.20221025023844-6e716b9e651c h1:OZkwKxpAnFLXMtDX3VFHSClkdbTlvBCXm6jjRxWxMjg=
+github.com/ledgerwatch/erigon-snapshot v1.1.1-0.20221025023844-6e716b9e651c/go.mod h1:3AuPxZc85jkehh/HA9h8gabv5MSi3kb/ddtzBsTVJFo=
github.com/ledgerwatch/log/v3 v3.6.0 h1:JBUSK1epPyutUrz7KYDTcJtQLEHnehECRpKbM1ugy5M=
github.com/ledgerwatch/log/v3 v3.6.0/go.mod h1:L+Sp+ma/h205EdCjviZECjGEvYUYEyXSdiuHNZzg+xQ=
github.com/ledgerwatch/secp256k1 v1.0.0 h1:Usvz87YoTG0uePIV8woOof5cQnLXGYa162rFf3YnwaQ=
@@ -411,7 +417,9 @@ github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNx
github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
+github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
+github.com/mdempsky/unconvert v0.0.0-20200228143138-95ecdbfc0b5f/go.mod h1:AmCV4WB3cDMZqgPk+OUQKumliiQS4ZYsBt3AXekyuAU=
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
@@ -457,6 +465,17 @@ github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1y
github.com/onsi/gomega v1.17.0 h1:9Luw4uT5HTjHTN8+aNcSThgH1vdXnmdJ8xIfZ4wyTRE=
github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY=
github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk=
+github.com/openacid/errors v0.8.1 h1:Hrj9WENDoj5jP27ZfF60SY5LShbxei+sxKZa0EP+oDw=
+github.com/openacid/errors v0.8.1/go.mod h1:GUQEJJOJE3W9skHm8E8Y4phdl2LLEN8iD7c5gcGgdx0=
+github.com/openacid/genr v0.1.1/go.mod h1:2B9wMFQKBKZnmo8AR/3JCRGnHs85r4OzeNy0RStLTiU=
+github.com/openacid/low v0.1.14 h1:DVg5kcwDrJMtKIGrMHU6ytr1ck2XZ3Ey1b6jm/BTS9I=
+github.com/openacid/low v0.1.14/go.mod h1:flqvccAtSrKeD+b5AejKgxCQVhVrsNYEWU7NlkpNCI8=
+github.com/openacid/must v0.1.3 h1:deanGZVyVwV+ozfwNFbRU5YF7czXeQ67s8GVyZxzKW4=
+github.com/openacid/must v0.1.3/go.mod h1:luPiXCuJlEo3UUFQngVQokV0MPGryeYvtCbQPs3U1+I=
+github.com/openacid/slim v0.5.11 h1:LIN8ktjSV5/0h9Wai9o30jpzQPPIYZmaRExmt9nGkPU=
+github.com/openacid/slim v0.5.11/go.mod h1:ddlyrp5csrPL30DlLp/SjgP4bdgCnmaCmmv4my407VI=
+github.com/openacid/tablewriter v0.0.0-20190429071406-b14f71081b86/go.mod h1:iJAvCLjVGFyZOV2Oh123q4PMcoBv2qQLEvjlVIM9E2E=
+github.com/openacid/testkeys v0.1.6/go.mod h1:MfA7cACzBpbiwekivj8StqX0WIRmqlMsci1c37CA3Do=
github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492/go.mod h1:Ngi6UdF0k5OKD5t5wlmGhe/EDKPoUM3BXZSSfIuJbis=
github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74=
github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
@@ -683,8 +702,8 @@ golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKG
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
-golang.org/x/mod v0.6.0 h1:b9gGHsz9/HhJ3HF5DHQytPpuwocVTChQJK3AvoLRD5I=
-golang.org/x/mod v0.6.0/go.mod h1:4mET923SAdbXp2ki8ey+zGs1SLqsuM2Y0uvdZR/fUNI=
+golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s=
+golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/net v0.0.0-20180524181706-dfa909b99c79/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
@@ -798,11 +817,12 @@ golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtn
golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
+golang.org/x/tools v0.0.0-20200225230052-807dcd883420/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
-golang.org/x/tools v0.2.0 h1:G6AHpWxTMGY1KyEYoAQ5WTtIekUUvDNjan3ugu60JvE=
-golang.org/x/tools v0.2.0/go.mod h1:y4OqIKeOV/fWJetJ8bXPU1sEVniLMIyDAZWeHdV+NTA=
+golang.org/x/tools v0.1.12 h1:VveCTK38A2rkS8ZqFY25HIDFscX5X9OoEhJd3quQmXU=
+golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
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=
@@ -884,6 +904,6 @@ honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWh
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
-pgregory.net/rapid v0.4.7 h1:MTNRktPuv5FNqOO151TM9mDTa+XHcX6ypYeISDVD14g=
+pgregory.net/rapid v0.5.3 h1:163N50IHFqr1phZens4FQOdPgfJscR7a562mjQqeo4M=
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU=
diff --git a/nginx/conf.d/default.conf b/nginx/conf.d/default.conf
deleted file mode 100644
index 2866389..0000000
--- a/nginx/conf.d/default.conf
+++ /dev/null
@@ -1,167 +0,0 @@
-server {
- listen 80;
- server_name localhost;
-
- gzip_static on;
-
- #access_log /var/log/nginx/host.access.log main;
-
- location /static {
- root /usr/share/nginx/html;
- expires max;
- }
-
- location /signatures {
- root /usr/share/nginx/html;
- expires 30d;
-
- # Base on: https://michielkalkman.com/snippets/nginx-cors-open-configuration/
- if ($request_method = 'OPTIONS') {
- add_header 'Access-Control-Allow-Origin' '*';
- #
- # Om nom nom cookies
- #
- add_header 'Access-Control-Allow-Credentials' 'true';
- add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS';
-
- #
- # Custom headers and headers various browsers *should* be OK with but aren't
- #
- add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
-
- #
- # Tell client that this pre-flight info is valid for 20 days
- #
- add_header 'Access-Control-Max-Age' 1728000;
- add_header 'Content-Type' 'text/plain charset=UTF-8';
- add_header 'Content-Length' 0;
- return 204;
- }
- if ($request_method = 'GET') {
- add_header 'Access-Control-Allow-Origin' '*' always;
- add_header 'Access-Control-Allow-Credentials' 'true' always;
- add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS' always;
- add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type' always;
- }
- }
-
- location /topic0 {
- root /usr/share/nginx/html;
- expires 30d;
-
- # Base on: https://michielkalkman.com/snippets/nginx-cors-open-configuration/
- if ($request_method = 'OPTIONS') {
- add_header 'Access-Control-Allow-Origin' '*';
- #
- # Om nom nom cookies
- #
- add_header 'Access-Control-Allow-Credentials' 'true';
- add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS';
-
- #
- # Custom headers and headers various browsers *should* be OK with but aren't
- #
- add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
-
- #
- # Tell client that this pre-flight info is valid for 20 days
- #
- add_header 'Access-Control-Max-Age' 1728000;
- add_header 'Content-Type' 'text/plain charset=UTF-8';
- add_header 'Content-Length' 0;
- return 204;
- }
- if ($request_method = 'GET') {
- add_header 'Access-Control-Allow-Origin' '*' always;
- add_header 'Access-Control-Allow-Credentials' 'true' always;
- add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS' always;
- add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type' always;
- }
- }
-
- location /assets {
- root /usr/share/nginx/html;
- expires 30d;
-
- # Base on: https://michielkalkman.com/snippets/nginx-cors-open-configuration/
- if ($request_method = 'OPTIONS') {
- add_header 'Access-Control-Allow-Origin' '*';
- #
- # Om nom nom cookies
- #
- add_header 'Access-Control-Allow-Credentials' 'true';
- add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS';
-
- #
- # Custom headers and headers various browsers *should* be OK with but aren't
- #
- add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
-
- #
- # Tell client that this pre-flight info is valid for 20 days
- #
- add_header 'Access-Control-Max-Age' 1728000;
- add_header 'Content-Type' 'text/plain charset=UTF-8';
- add_header 'Content-Length' 0;
- return 204;
- }
- if ($request_method = 'GET') {
- add_header 'Access-Control-Allow-Origin' '*' always;
- add_header 'Access-Control-Allow-Credentials' 'true' always;
- add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS' always;
- add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type' always;
- }
- }
-
- location /chains {
- root /usr/share/nginx/html;
- expires 30d;
-
- # Base on: https://michielkalkman.com/snippets/nginx-cors-open-configuration/
- if ($request_method = 'OPTIONS') {
- add_header 'Access-Control-Allow-Origin' '*';
- #
- # Om nom nom cookies
- #
- add_header 'Access-Control-Allow-Credentials' 'true';
- add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS';
-
- #
- # Custom headers and headers various browsers *should* be OK with but aren't
- #
- add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
-
- #
- # Tell client that this pre-flight info is valid for 20 days
- #
- add_header 'Access-Control-Max-Age' 1728000;
- add_header 'Content-Type' 'text/plain charset=UTF-8';
- add_header 'Content-Length' 0;
- return 204;
- }
- if ($request_method = 'GET') {
- add_header 'Access-Control-Allow-Origin' '*' always;
- add_header 'Access-Control-Allow-Credentials' 'true' always;
- add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS' always;
- add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type' always;
- }
- }
-
- location / {
- root /usr/share/nginx/html;
- index index.html;
- try_files $uri /index.html;
-
- # brotli_static on;
- }
-
- #error_page 404 /404.html;
-
- # redirect server error pages to the static page /50x.html
- #
- error_page 500 502 503 504 /50x.html;
- location = /50x.html {
- root /usr/share/nginx/html;
- }
-
-}
\ No newline at end of file
diff --git a/nginx/nginx.conf b/nginx/nginx.conf
deleted file mode 100644
index 72d7924..0000000
--- a/nginx/nginx.conf
+++ /dev/null
@@ -1,32 +0,0 @@
-user nginx;
-worker_processes auto;
-
-error_log /var/log/nginx/error.log notice;
-pid /var/run/nginx.pid;
-
-#load_module modules/ngx_http_brotli_static_module.so;
-
-events {
- worker_connections 1024;
-}
-
-
-http {
- include /etc/nginx/mime.types;
- default_type application/octet-stream;
-
- log_format main '$remote_addr - $remote_user [$time_local] "$request" '
- '$status $body_bytes_sent "$http_referer" '
- '"$http_user_agent" "$http_x_forwarded_for"';
-
- access_log /var/log/nginx/access.log main;
-
- sendfile on;
- #tcp_nopush on;
-
- keepalive_timeout 65;
-
- #gzip on;
-
- include /etc/nginx/conf.d/*.conf;
-}
diff --git a/package.json b/package.json
index a6ddebf..b9a8e0c 100644
--- a/package.json
+++ b/package.json
@@ -45,13 +45,17 @@
},
"scripts": {
"start": "vite",
- "download":"rm -rf chains topic0 4bytes &&npm run dl-chains && npm run dl-topic0 && npm run dl-4bytes",
+ "clean": "rm -rf chains topic0 4bytes dist",
+ "fullbuild": "npm run dl-all && npm run build",
"build": "tsc && vite build",
- "postbuild": "cp -r chains dist && cp -r topic0 dist && cp -r 4bytes dist",
+ "postbuild": "npm run copy-all",
"preview": "vite preview",
+ "dl-all":"npm run clean && npm run dl-chains && npm run dl-topic0",
"dl-chains": "svn checkout https://github.com/ethereum-lists/chains/trunk/_data/chains && rm -rf chains/.svn",
"dl-topic0": "git clone https://github.com/wmitsuda/topic0 && rm -rf topic0/.git",
- "dl-4bytes": "git clone https://github.com/ethereum-lists/4bytes && rm -rf 4bytes/.git",
+ "copy-all":"npm run copy-chains && npm run copy-topic0",
+ "copy-chains": "rsync -ah chains dist",
+ "copy-topic0": "mkdir -p dist/topic0 && rsync -ah topic0/with_parameter_names/ dist/topic0/",
"source-map-explorer": "source-map-explorer build/static/js/*.js",
"assets-start": "docker run --rm -p 3001:80 --name otterscan-assets -d -v$(pwd)/4bytes/signatures:/usr/share/nginx/html/signatures/ -v$(pwd)/trustwallet/blockchains/ethereum/assets:/usr/share/nginx/html/assets/1 -v$(pwd)/topic0/with_parameter_names:/usr/share/nginx/html/topic0/ -v$(pwd)/chains/_data/chains:/usr/share/nginx/html/chains/ -v$(pwd)/nginx/nginx.conf:/etc/nginx/nginx.conf -v$(pwd)/nginx/conf.d/default.conf:/etc/nginx/conf.d/default.conf nginx:1.21.1-alpine",
"assets-start-with-param-names": "docker run --rm -p 3001:80 --name otterscan-assets -d -v$(pwd)/4bytes/with_parameter_names:/usr/share/nginx/html/signatures/ -v$(pwd)/trustwallet/blockchains/ethereum/assets:/usr/share/nginx/html/assets/1 -v$(pwd)/topic0/with_parameter_names:/usr/share/nginx/html/topic0/ -v$(pwd)/chains/_data/chains:/usr/share/nginx/html/chains/ -v$(pwd)/nginx/nginx.conf:/etc/nginx/nginx.conf -v$(pwd)/nginx/conf.d/default.conf:/etc/nginx/conf.d/default.conf nginx:1.21.1-alpine",
diff --git a/run-nginx.sh b/run-nginx.sh
deleted file mode 100755
index b95bdad..0000000
--- a/run-nginx.sh
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/sh
-PARAMS="{\"erigonURL\": $(echo $ERIGON_URL | jq -aR .), \"beaconAPI\": $(echo $BEACON_API_URL | jq -aR .), \"assetsURLPrefix\": \"\"}"
-echo $PARAMS > /usr/share/nginx/html/config.json
-nginx -g "daemon off;"
diff --git a/trustwallet b/trustwallet
deleted file mode 160000
index 7618081..0000000
--- a/trustwallet
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit 7618081e0a5fc37e18298a0bde79f65552fe6901