Skip to content

Commit

Permalink
Merge pull request #84 from testinprod-io/upstream-v2.46.0
Browse files Browse the repository at this point in the history
Upstream sync - v2.46.0
  • Loading branch information
ImTei authored Jul 20, 2023
2 parents 077a3d5 + 4c52e8a commit 1626901
Show file tree
Hide file tree
Showing 350 changed files with 7,928 additions and 5,946 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,13 @@ jobs:
# check with root permissions, should be cached from previous build
- name: sudo make docker
run: sudo DOCKER_TAG=testinprod/op-erigon:ci-$GITHUB_SHA DOCKER_UID=$(id -u) DOCKER_GID=$(id -g) make docker

automated-tests:
runs-on:
ubuntu-20.04
if: ${{ github.event_name == 'push' || !github.event.pull_request.draft }}
steps:
- uses: actions/checkout@v3

- name: run automated testing
run: BUILD_ERIGON=1 ./tests/automated-testing/run.sh
# automated-tests:
# runs-on:
# ubuntu-20.04
# if: ${{ github.event_name == 'push' || !github.event.pull_request.draft }}
# steps:
# - uses: actions/checkout@v3
#
# - name: run automated testing
# run: BUILD_ERIGON=1 ./tests/automated-testing/run.sh
6 changes: 3 additions & 3 deletions DEV_CHAIN.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ make erigon
```


## 2. Build RPC deamon
## 2. Build RPC daemon
On the same terminal folder you can build the RPC daemon.

```bash
Expand Down Expand Up @@ -43,7 +43,7 @@ Now save the enode information generated in the logs, we will use this in a minu
enode://d30d079163d7b69fcb261c0538c0c3faba4fb4429652970e60fa25deb02a789b4811e98b468726ba0be63b9dc925a019f433177eb6b45c23bb78892f786d8f7a@127.0.0.1:53171
```

## 4. Start RPC deamon
## 4. Start RPC daemon

Open terminal 2 and navigate to erigon/build/bin folder. Here type the following command

Expand All @@ -68,7 +68,7 @@ Open terminal 3 and navigate to erigon/build/bin folder. Paste in the following
--nodiscover
```

To check if the nodes are connected, you can go to the log of both the nodes and look for the line
To check if the nodes are connected, you can go to the log of both nodes and look for the line

``` [p2p] GoodPeers eth66=1 ```

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ COPY --from=builder /app/build/bin/state /usr/local/bin/state
COPY --from=builder /app/build/bin/txpool /usr/local/bin/txpool
COPY --from=builder /app/build/bin/verkle /usr/local/bin/verkle
COPY --from=builder /app/build/bin/caplin-phase1 /usr/local/bin/caplin-phase1

COPY --from=builder /app/build/bin/caplin-regression /usr/local/bin/caplin-regression


EXPOSE 8545 \
Expand Down
1 change: 1 addition & 0 deletions Dockerfile.debian
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ COPY --from=builder /app/build/bin/state /usr/local/bin/state
COPY --from=builder /app/build/bin/txpool /usr/local/bin/txpool
COPY --from=builder /app/build/bin/verkle /usr/local/bin/verkle
COPY --from=builder /app/build/bin/caplin-phase1 /usr/local/bin/caplin-phase1
COPY --from=builder /app/build/bin/caplin-regression /usr/local/bin/caplin-regression

EXPOSE 8545 \
8551 \
Expand Down
19 changes: 9 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ CGO_CFLAGS += -DMDBX_FORCE_ASSERTIONS=0 # Enable MDBX's asserts by default in 'd
CGO_CFLAGS += -O
CGO_CFLAGS += -D__BLST_PORTABLE__
CGO_CFLAGS += -Wno-error=strict-prototypes # for Clang15, remove it when can https://github.com/ledgerwatch/erigon/issues/6113#issuecomment-1359526277
CGO_CFLAGS := CGO_CFLAGS="$(CGO_CFLAGS)"
DBG_CGO_CFLAGS += -DMDBX_DEBUG=1

# about netgo see: https://github.com/golang/go/issues/30310#issuecomment-471669125 and https://github.com/golang/go/issues/57757
BUILD_TAGS = nosqlite,noboltdb
Expand All @@ -35,9 +33,9 @@ PACKAGE = github.com/testinprod-io/op-erigon
GO_FLAGS += -trimpath -tags $(BUILD_TAGS) -buildvcs=false
GO_FLAGS += -ldflags "-X ${PACKAGE}/params.GitCommit=${GIT_COMMIT} -X ${PACKAGE}/params.GitBranch=${GIT_BRANCH} -X ${PACKAGE}/params.GitTag=${GIT_TAG}"

GOBUILD = $(CGO_CFLAGS) $(GO) build $(GO_FLAGS)
GO_DBG_BUILD = $(GO) build $(GO_FLAGS) -tags $(BUILD_TAGS),debug -gcflags=all="-N -l" # see delve docs
GOTEST = $(CGO_CFLAGS) GODEBUG=cgocheck=0 $(GO) test $(GO_FLAGS) ./... -p 2
GOBUILD = CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) build $(GO_FLAGS)
GO_DBG_BUILD = CGO_CFLAGS="$(CGO_CFLAGS) -DMDBX_DEBUG=1" $(GO) build -tags $(BUILD_TAGS),debug -gcflags=all="-N -l" # see delve docs
GOTEST = CGO_CFLAGS="$(CGO_CFLAGS)" GODEBUG=cgocheck=0 $(GO) test $(GO_FLAGS) ./... -p 2

default: all

Expand Down Expand Up @@ -87,7 +85,7 @@ setup_xdg_data_home:

## docker-compose: validate build args, setup xdg data home, and run docker-compose up
docker-compose: validate_docker_build_args setup_xdg_data_home
docker-compose up
docker compose up

## dbg debug build allows see C stack traces, run it with GOTRACEBACK=crash. You don't need debug build for C pit for profiling. To profile C code use SETCGOTRCKEBACK=1
dbg:
Expand Down Expand Up @@ -152,14 +150,14 @@ test:
$(GOTEST) --timeout 100s

test3:
$(GOTEST) --timeout 100s -tags $(BUILD_TAGS),erigon3
$(GOTEST) --timeout 100s -tags $(BUILD_TAGS),e3

## test-integration: run integration tests with a 30m timeout
test-integration:
$(GOTEST) --timeout 30m -tags $(BUILD_TAGS),integration

test3-integration:
$(GOTEST) --timeout 30m -tags $(BUILD_TAGS),integration,erigon3
$(GOTEST) --timeout 30m -tags $(BUILD_TAGS),integration,e3

## lint: run golangci-lint with .golangci.yml config file
lint:
Expand Down Expand Up @@ -192,6 +190,7 @@ devtools:
$(GOBUILD) -o $(GOBIN)/codecgen github.com/ugorji/go/codec/codecgen
PATH=$(GOBIN):$(PATH) go generate ./common
# PATH=$(GOBIN):$(PATH) go generate ./core/types
PATH=$(GOBIN):$(PATH) cd ./cmd/rpcdaemon/graphql && go run github.com/99designs/gqlgen .
PATH=$(GOBIN):$(PATH) go generate ./consensus/aura/...
#PATH=$(GOBIN):$(PATH) go generate ./eth/ethconfig/...
@type "npm" 2> /dev/null || echo 'Please install node.js and npm'
Expand All @@ -205,7 +204,7 @@ bindings:

## prometheus: run prometheus and grafana with docker-compose
prometheus:
docker-compose up prometheus grafana
docker compose up prometheus grafana

## escape: run escape path={path} to check for memory leaks e.g. run escape path=cmd/erigon
escape:
Expand All @@ -221,7 +220,7 @@ git-submodules:
@git submodule update --quiet --init --recursive --force || true

PACKAGE_NAME := github.com/testinprod-io/op-erigon
GOLANG_CROSS_VERSION ?= v1.20.4
GOLANG_CROSS_VERSION ?= v1.20.5

.PHONY: release-dry-run
release-dry-run: git-submodules
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ _Flags:_
- `log.json`
- `log.console.json` (alias for `log.json`)
- `log.dir.path`
- `log.dir.prefix`
- `log.dir.verbosity`
- `log.dir.json`

Expand All @@ -304,7 +305,7 @@ int value specifying the highest output log level:
LvlTrace = 5
```

To set an output dir for logs to be collected on disk, please set `--log.dir.path`. The flag `--log.dir.verbosity` is
To set an output dir for logs to be collected on disk, please set `--log.dir.path` If you want to change the filename prodiced from `erigon` you should also set the `--log.dir.prefix` flag to an alternate name. The flag `--log.dir.verbosity` is
also available to control the verbosity of this logging, with the same int value as above, or the string value e.g. '
debug' or 'info'. Default verbosity is 'debug' (4), for disk logging.

Expand Down Expand Up @@ -451,7 +452,7 @@ http.api : ["eth","debug","net"]
Erigon can be used as an Execution Layer (EL) for Consensus Layer clients (CL). Default configuration is OK.

If your CL client is on a different device, add `--authrpc.addr 0.0.0.0` ([Engine API] listens on localhost by default)
as well as `--authrpc.vhosts <CL host>`.
as well as `--authrpc.vhosts <CL host>` where `<CL host>` is your source host or `any`.

[Engine API]: https://github.com/ethereum/execution-apis/blob/main/src/engine/specification.md

Expand Down Expand Up @@ -662,7 +663,7 @@ Windows support for docker-compose is not ready yet. Please help us with .ps1 po

### Grafana dashboard

`docker-compose up prometheus grafana`, [detailed docs](./cmd/prometheus/Readme.md).
`docker compose up prometheus grafana`, [detailed docs](./cmd/prometheus/Readme.md).

###

Expand Down
6 changes: 3 additions & 3 deletions RELEASE_INSTRUCTIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ If there are any transactions where code bitmap was useful, warning messages lik
````
WARN [08-01|14:54:27.778] Code Bitmap used for detecting invalid jump tx=0x86e55d1818b5355424975de9633a57c40789ca08552297b726333a9433949c92 block number=6426298
````
In such cases (unless there are too many instances), all block numbers need to be excluded in the `SkipAnalysis` function, and comment to it. The constant `MainnetNotCheckedFrom` needs to be update to the first block number we have not checked. The value can be taken from the output of the `checkChangeSets`
In such cases (unless there are too many instances), all block numbers need to be excluded in the `SkipAnalysis` function, and comment to it. The constant `MainnetNotCheckedFrom` needs to be updated to the first block number we have not checked. The value can be taken from the output of the `checkChangeSets`
utility before it exits, like this:
````
INFO [08-01|15:36:04.282] Checked blocks=10573804 next time specify --block=10573804 duration=36m54.789025062s
````

## Update DB Schema version if required

In the file `common/dbutils/bucket.go` there is variable `DBSchemaVersion` that needs to be update if there are any changes in the database schema, leading to data migrations.
In the file `common/dbutils/bucket.go` there is variable `DBSchemaVersion` that needs to be updated if there are any changes in the database schema, leading to data migrations.
In most cases, it is enough to bump minor version.

## Update remote KV version if required

In the file `ethdb/remote/remotedbserver/server.go` there is variable `KvServiceAPIVersion` that needs to be update if there are any changes in the remote KV interface, or
In the file `ethdb/remote/remotedbserver/server.go` there is variable `KvServiceAPIVersion` that needs to be updated if there are any changes in the remote KV interface, or
database schema, leading to data migrations.
In most cases, it is enough to bump minor version. It is best to change both DB schema version and remove KV version together.
14 changes: 7 additions & 7 deletions TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ INFO [03-24|13:41:20.391] Commit cycle in=2.16378229

Here we see that the sync cycle went through all the stages for a single block `12101885`.

After that, it is useful to wait more until an Unwind is encoutered and check that Erigon handled it without errors.
After that, it is useful to wait more until an Unwind is encountered and check that Erigon handled it without errors.
Usually, errors occur at the stage
`[7/14 IntermediateHashes]` and manifest in the wrong trie root. Here is an example of processing an unwind without
errors (look for the word "Unwind" in the log):
Expand Down Expand Up @@ -148,7 +148,7 @@ ERROR[08-01|14:30:38.299] Demoting invalidated transaction hash="859191
ERROR[08-01|14:30:38.299] Demoting invalidated transaction hash="25ee67…e73153"
```

this is also likely to disappered after the introduction of new downloader/sentry design
this is also likely to disappear after the introduction of new downloader/sentry design

### Assessing relative performance of sync

Expand All @@ -172,7 +172,7 @@ INFO [03-24|13:41:20.391] Commit cycle in=2.16378229

The line above shows how long was commit cycle. We saw in the past that after some changes the commit time dramatically
increases, and these
regressions need to be investigaged. We expect "commit cycle" on Linux with NVMe drive to usually take less than a
regressions need to be investigated. We expect "commit cycle" on Linux with NVMe drive to usually take less than a
second. For other operating
systems and devices the typical time may vary, but it should significantly increase from one release to another.
Perhaps we need to log some extra information in the log to make it easier for the tester to filter out the log
Expand Down Expand Up @@ -274,19 +274,19 @@ requests for certain RPC methods, using hits provided by options `--blockFrom` a
useful ones are:

1. `bench8` tests `eth_getLogs` RPC method (compatibility with go-ethereum and OpenEthereum)
2. `bench11` tests `trace_call` RPC method (compatiblity with OpenEthereum tracing)
2. `bench11` tests `trace_call` RPC method (compatibility with OpenEthereum tracing)
3. `bench12` tests `debug_traceCall` RPC method (compatibility with go-ethereum tracing)
4. `bench13` tests `trace_callMany` RPC method (compability with OpenEthereum tracing)
4. `bench13` tests `trace_callMany` RPC method (compatibility with OpenEthereum tracing)

Options `--erigonUrl` and `--gethUrl` specify HTTP endpoints that needs to be tested against each other. Despite its
Options `--erigonUrl` and `--gethUrl` specify HTTP endpoints that need to be tested against each other. Despite its
name, `--gethUrl` option does not have to
point to go-ethereum node, it can point to anything that it supposed to be "correct" for the purpose of the test (
go-ethereum node, OpenEthereum node,
or Erigon RPC daemon & Erigon node built from the previous release code).

Option `--needCompare` triggers the comparison of JSON RPC responses. If omitted, requests to `--gethUrl` are not done.
When comparison is turned on,
the utility stops at the first occurrence of mistmatch.
the utility stops at the first occurrence of mismatch.

## RPC test recording and replay

Expand Down
36 changes: 13 additions & 23 deletions accounts/abi/bind/backends/simulated.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,16 @@ import (
"time"

"github.com/holiman/uint256"
ethereum "github.com/ledgerwatch/erigon"
"github.com/ledgerwatch/erigon-lib/chain"
libcommon "github.com/ledgerwatch/erigon-lib/common"
"github.com/ledgerwatch/erigon-lib/common/hexutility"
"github.com/ledgerwatch/erigon-lib/kv"
state2 "github.com/ledgerwatch/erigon-lib/state"
types2 "github.com/ledgerwatch/erigon-lib/types"
"github.com/ledgerwatch/erigon/turbo/services"
"github.com/ledgerwatch/log/v3"

ethereum "github.com/ledgerwatch/erigon"
"github.com/ledgerwatch/erigon/accounts/abi"
"github.com/ledgerwatch/erigon/accounts/abi/bind"
"github.com/ledgerwatch/erigon/common/math"
Expand All @@ -44,12 +47,9 @@ import (
"github.com/ledgerwatch/erigon/core/state"
"github.com/ledgerwatch/erigon/core/types"
"github.com/ledgerwatch/erigon/core/vm"
"github.com/ledgerwatch/erigon/eth/ethconfig"
"github.com/ledgerwatch/erigon/event"
"github.com/ledgerwatch/erigon/params"
"github.com/ledgerwatch/erigon/turbo/services"
"github.com/ledgerwatch/erigon/turbo/stages"
"github.com/ledgerwatch/log/v3"
)

// This nil assignment ensures at compile time that SimulatedBackend implements bind.ContractBackend.
Expand Down Expand Up @@ -93,14 +93,13 @@ func NewSimulatedBackendWithConfig(alloc types.GenesisAlloc, config *chain.Confi
genesis := types.Genesis{Config: config, GasLimit: gasLimit, Alloc: alloc}
engine := ethash.NewFaker()
m := stages.MockWithGenesisEngine(nil, &genesis, engine, false)
br, _ := m.NewBlocksIO()
backend := &SimulatedBackend{
m: m,
prependBlock: m.Genesis,
getHeader: func(hash libcommon.Hash, number uint64) (h *types.Header) {
var err error
if err = m.DB.View(context.Background(), func(tx kv.Tx) error {
h, err = br.Header(context.Background(), tx, hash, number)
h, err = m.BlockReader.Header(context.Background(), tx, hash, number)
return nil
}); err != nil {
panic(err)
Expand All @@ -125,14 +124,11 @@ func NewTestSimulatedBackendWithConfig(t *testing.T, alloc types.GenesisAlloc, c
t.Cleanup(b.Close)
return b
}
func (b *SimulatedBackend) DB() kv.RwDB { return b.m.DB }
func (b *SimulatedBackend) Agg() *state2.AggregatorV3 { return b.m.HistoryV3Components() }
func (b *SimulatedBackend) HistoryV3() bool { return b.m.HistoryV3 }
func (b *SimulatedBackend) Engine() consensus.Engine { return b.m.Engine }
func (b *SimulatedBackend) BlockReader() services.FullBlockReader {
br, _ := b.m.NewBlocksIO()
return br
}
func (b *SimulatedBackend) DB() kv.RwDB { return b.m.DB }
func (b *SimulatedBackend) Agg() *state2.AggregatorV3 { return b.m.HistoryV3Components() }
func (b *SimulatedBackend) HistoryV3() bool { return b.m.HistoryV3 }
func (b *SimulatedBackend) Engine() consensus.Engine { return b.m.Engine }
func (b *SimulatedBackend) BlockReader() services.FullBlockReader { return b.m.BlockReader }

// Close terminates the underlying blockchain's update loop.
func (b *SimulatedBackend) Close() {
Expand All @@ -151,7 +147,7 @@ func (b *SimulatedBackend) Commit() {
Headers: []*types.Header{b.pendingHeader},
Blocks: []*types.Block{b.pendingBlock},
TopBlock: b.pendingBlock,
}); err != nil {
}, nil); err != nil {
panic(err)
}
//nolint:prealloc
Expand Down Expand Up @@ -186,13 +182,7 @@ func (b *SimulatedBackend) emptyPendingBlock() {
panic(err)
}
b.pendingReaderTx = tx

if ethconfig.EnableHistoryV4InTest {
panic("implement me")
//b.pendingReader = state.NewReaderV4(b.pendingReaderTx.(kv.TemporalTx))
} else {
b.pendingReader = state.NewPlainStateReader(b.pendingReaderTx)
}
b.pendingReader = b.m.NewStateReader(b.pendingReaderTx)
b.pendingState = state.New(b.pendingReader)
}

Expand Down Expand Up @@ -747,7 +737,7 @@ func (b *SimulatedBackend) SendTransaction(ctx context.Context, tx types.Transac
defer b.mu.Unlock()

// Check transaction validity.
signer := types.MakeSigner(b.m.ChainConfig, b.pendingBlock.NumberU64())
signer := types.MakeSigner(b.m.ChainConfig, b.pendingBlock.NumberU64(), b.pendingBlock.Time())
sender, senderErr := tx.Sender(*signer)
if senderErr != nil {
return fmt.Errorf("invalid transaction: %w", senderErr)
Expand Down
Loading

0 comments on commit 1626901

Please sign in to comment.