From d5fb8f7d24eb41f0ab125a62e3eecd9c6898896a Mon Sep 17 00:00:00 2001 From: ledgerwatch Date: Sat, 19 Mar 2022 16:15:12 +0000 Subject: [PATCH] [erigon2] Separate handover timing (#3736) * Separate handover timing * Update * Corrected handover time calculation * Not use compression when aggregate * Update to latest erigon-lib * Update to erigon-lib main * Update * Disable reproducible builds * Restore github actions * Restore github actions * Revert "linter to support go 1.18 (#3739)" This reverts commit 1fd434d3d1e38aa20694e7229da3ca7c471d06a5. Co-authored-by: Alexey Sharp --- .github/workflows/ci.yml | 6 +- Makefile | 2 +- cmd/rpcdaemon/cli/config.go | 84 ++++++++++++++------------- go.mod | 4 +- go.sum | 8 +-- turbo/snapshotsync/block_snapshots.go | 6 +- 6 files changed, 56 insertions(+), 54 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 15ced3909..189638246 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,7 +20,7 @@ jobs: - run: git submodule update --init --recursive --force - uses: actions/setup-go@v3 with: - go-version: 1.18.x + go-version: 1.17.x - name: Install dependencies run: | if [ "$RUNNER_OS" == "Linux" ]; then @@ -44,7 +44,7 @@ jobs: if: matrix.os == 'ubuntu-20.04' uses: golangci/golangci-lint-action@v3 with: - version: v1.45 + version: v1.44 skip-pkg-cache: true skip-build-cache: true - run: make test @@ -60,7 +60,7 @@ jobs: - run: git submodule update --init --recursive --force - uses: actions/setup-go@v3 with: - go-version: 1.18.x + go-version: 1.17.x - run: choco upgrade mingw cmake -y --no-progress - name: Build run: | diff --git a/Makefile b/Makefile index a97ea3297..a2cf9828c 100644 --- a/Makefile +++ b/Makefile @@ -97,7 +97,7 @@ lintci: lintci-deps: rm -f ./build/bin/golangci-lint - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b ./build/bin v1.45.0 + curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b ./build/bin v1.44.2 clean: go clean -cache diff --git a/cmd/rpcdaemon/cli/config.go b/cmd/rpcdaemon/cli/config.go index 7100b9302..61f1d8664 100644 --- a/cmd/rpcdaemon/cli/config.go +++ b/cmd/rpcdaemon/cli/config.go @@ -290,53 +290,55 @@ func RemoteServices(ctx context.Context, cfg httpcfg.HttpCfg, logger log.Logger, } log.Info("if you run RPCDaemon on same machine with Erigon add --datadir option") } - var cc *params.ChainConfig - if err := db.View(context.Background(), func(tx kv.Tx) error { - genesisBlock, err := rawdb.ReadBlockByNumber(tx, 0) - if err != nil { - return err - } - cc, err = rawdb.ReadChainConfig(tx, genesisBlock.Hash()) - if err != nil { - return err - } - return nil - }); err != nil { - return nil, nil, nil, nil, nil, nil, nil, nil, ff, err - } - if cc == nil { - return nil, nil, nil, nil, nil, nil, nil, nil, ff, fmt.Errorf("chain config not found in db. Need start erigon at least once on this db") - } - - // if chain config has terminal total difficulty then rpc has to have these API's to function - if cc.TerminalTotalDifficulty != nil { - hasEthApiEnabled := false - hasEngineApiEnabled := false - hasNetApiEnabled := false - - for _, api := range cfg.API { - switch api { - case "eth": - hasEthApiEnabled = true - case "engine": - hasEngineApiEnabled = true - case "net": - hasNetApiEnabled = true + if db != nil { + var cc *params.ChainConfig + if err := db.View(context.Background(), func(tx kv.Tx) error { + genesisBlock, err := rawdb.ReadBlockByNumber(tx, 0) + if err != nil { + return err } + cc, err = rawdb.ReadChainConfig(tx, genesisBlock.Hash()) + if err != nil { + return err + } + return nil + }); err != nil { + return nil, nil, nil, nil, nil, nil, nil, nil, ff, err + } + if cc == nil { + return nil, nil, nil, nil, nil, nil, nil, nil, ff, fmt.Errorf("chain config not found in db. Need start erigon at least once on this db") } - if !hasEthApiEnabled { - cfg.API = append(cfg.API, "eth") - } + // if chain config has terminal total difficulty then rpc has to have these API's to function + if cc.TerminalTotalDifficulty != nil { + hasEthApiEnabled := false + hasEngineApiEnabled := false + hasNetApiEnabled := false - if !hasEngineApiEnabled { - cfg.API = append(cfg.API, "engine") - } + for _, api := range cfg.API { + switch api { + case "eth": + hasEthApiEnabled = true + case "engine": + hasEngineApiEnabled = true + case "net": + hasNetApiEnabled = true + } + } - if !hasNetApiEnabled { - cfg.API = append(cfg.API, "net") - } + if !hasEthApiEnabled { + cfg.API = append(cfg.API, "eth") + } + if !hasEngineApiEnabled { + cfg.API = append(cfg.API, "engine") + } + + if !hasNetApiEnabled { + cfg.API = append(cfg.API, "net") + } + + } } var onNewSnapshot func() diff --git a/go.mod b/go.mod index 066478fa8..503a3637e 100644 --- a/go.mod +++ b/go.mod @@ -40,7 +40,7 @@ require ( github.com/json-iterator/go v1.1.12 github.com/julienschmidt/httprouter v1.3.0 github.com/kevinburke/go-bindata v3.21.0+incompatible - github.com/ledgerwatch/erigon-lib v0.0.0-20220318160957-ff3e07454922 + github.com/ledgerwatch/erigon-lib v0.0.0-20220319123703-71751426bcd5 github.com/ledgerwatch/log/v3 v3.4.1 github.com/ledgerwatch/secp256k1 v1.0.0 github.com/magiconair/properties v1.8.6 // indirect @@ -57,7 +57,7 @@ require ( github.com/tendermint/go-amino v0.14.1 github.com/tendermint/iavl v0.12.0 github.com/tendermint/tendermint v0.31.11 - github.com/torquem-ch/mdbx-go v0.22.16 + github.com/torquem-ch/mdbx-go v0.22.18 github.com/ugorji/go/codec v1.1.13 github.com/ugorji/go/codec/codecgen v1.1.13 github.com/urfave/cli v1.22.5 diff --git a/go.sum b/go.sum index 931c35fcb..814153b20 100644 --- a/go.sum +++ b/go.sum @@ -615,8 +615,8 @@ github.com/kylelemons/godebug v0.0.0-20170224010052-a616ab194758 h1:0D5M2HQSGD3P github.com/kylelemons/godebug v0.0.0-20170224010052-a616ab194758/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k= 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-lib v0.0.0-20220318160957-ff3e07454922 h1:/WBa+VtOWt8pfc0jTD2LpV65PM6X4/oBi0d+hnkDCTI= -github.com/ledgerwatch/erigon-lib v0.0.0-20220318160957-ff3e07454922/go.mod h1:DOOU7AueOIleumnEzs21bwDaOMu5lJAzZtuxBoTrgm4= +github.com/ledgerwatch/erigon-lib v0.0.0-20220319123703-71751426bcd5 h1:KGM2yXLg6LvGMw/gkr99o8Xkw7zRN9AhiQRe978h9hY= +github.com/ledgerwatch/erigon-lib v0.0.0-20220319123703-71751426bcd5/go.mod h1:1Ao0yXNx7956h1fm/3A8AOB2pzckvlpBvxdYvJNfgl8= github.com/ledgerwatch/log/v3 v3.4.1 h1:/xGwlVulXnsO9Uq+tzaExc8OWmXXHU0dnLalpbnY5Bc= github.com/ledgerwatch/log/v3 v3.4.1/go.mod h1:VXcz6Ssn6XEeU92dCMc39/g1F0OYAjw1Mt+dGP5DjXY= github.com/ledgerwatch/secp256k1 v1.0.0 h1:Usvz87YoTG0uePIV8woOof5cQnLXGYa162rFf3YnwaQ= @@ -991,8 +991,8 @@ github.com/tklauser/go-sysconf v0.3.9/go.mod h1:11DU/5sG7UexIrp/O6g35hrWzu0JxlwQ github.com/tklauser/numcpus v0.3.0 h1:ILuRUQBtssgnxw0XXIjKUC56fgnOrFoQQ/4+DeU2biQ= github.com/tklauser/numcpus v0.3.0/go.mod h1:yFGUr7TUHQRAhyqBcEg0Ge34zDBAsIvJJcyE6boqnA8= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= -github.com/torquem-ch/mdbx-go v0.22.16 h1:uSuQOAKSZC7TvV4N4km+6kyER2YxaOuL/0qybsQtlUY= -github.com/torquem-ch/mdbx-go v0.22.16/go.mod h1:T2fsoJDVppxfAPTLd1svUgH1kpPmeXdPESmroSHcL1E= +github.com/torquem-ch/mdbx-go v0.22.18 h1:n6iNeKMtLBiEYPaKO4Ok/L7uwftExz7xOcmIZsLqQnM= +github.com/torquem-ch/mdbx-go v0.22.18/go.mod h1:T2fsoJDVppxfAPTLd1svUgH1kpPmeXdPESmroSHcL1E= github.com/ttacon/chalk v0.0.0-20160626202418-22c06c80ed31/go.mod h1:onvgF043R+lC5RZ8IT9rBXDaEDnpnw/Cl+HFiw+v/7Q= github.com/tv42/httpunix v0.0.0-20191220191345-2ba4b9c3382c/go.mod h1:hzIxponao9Kjc7aWznkXaL4U4TWaDSs8zcsY4Ka08nM= github.com/ugorji/go v1.1.13 h1:nB3O5kBSQGjEQAcfe1aLUYuxmXdFKmYgBZhY32rQb6Q= diff --git a/turbo/snapshotsync/block_snapshots.go b/turbo/snapshotsync/block_snapshots.go index fa47c9160..2747fd556 100644 --- a/turbo/snapshotsync/block_snapshots.go +++ b/turbo/snapshotsync/block_snapshots.go @@ -1077,7 +1077,7 @@ func DumpTxs(ctx context.Context, db kv.RoDB, segmentFile, tmpDir string, blockF } valueBuf = valueBuf[:0] - valueBuf = append(valueBuf, slot.IdHash[:1]...) + valueBuf = append(valueBuf, slot.IDHash[:1]...) valueBuf = append(valueBuf, sender[:]...) valueBuf = append(valueBuf, v...) return valueBuf, nil @@ -1411,8 +1411,8 @@ RETRY: txsCh2 <- txHashWithOffet{err: it.err} return } - txsCh <- txHashWithOffet{txnHash: slot.IdHash, i: it.i, offset: it.offset} - txsCh2 <- txHashWithOffet{txnHash: slot.IdHash, i: it.i, offset: it.offset} + txsCh <- txHashWithOffet{txnHash: slot.IDHash, i: it.i, offset: it.offset} + txsCh2 <- txHashWithOffet{txnHash: slot.IDHash, i: it.i, offset: it.offset} } }()