Skip to content

Commit bc2f8bd

Browse files
authored
Merge pull request #2190 from ledgerwatch/stable-2020-06-04
2 parents 81a22af + 249e411 commit bc2f8bd

File tree

256 files changed

+3654
-3865
lines changed

Some content is hidden

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

256 files changed

+3654
-3865
lines changed

Makefile

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
GOBIN = $(CURDIR)/build/bin
2-
GOTEST = GODEBUG=cgocheck=2 go test ./... -p 1
2+
GOTEST = GODEBUG=cgocheck=0 go test ./... -p 2
33

44
GIT_COMMIT ?= $(shell git rev-list -1 HEAD)
55
GIT_BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD)
66
GIT_TAG ?= $(shell git describe --tags)
7-
GOBUILD = env GO111MODULE=on go build -trimpath -ldflags "-X main.gitCommit=${GIT_COMMIT} -X main.gitBranch=${GIT_BRANCH} -X main.gitTag=${GIT_TAG}"
8-
GO_DBG_BUILD = env CGO_CFLAGS='-O0 -g -DMDBX_BUILD_FLAGS_CONFIG="config.h"' GODEBUG=cgocheck=2 go build -trimpath -tags=debug -ldflags "-X main.gitCommit=${GIT_COMMIT} -X main.gitBranch=${GIT_BRANCH} -X main.gitTag=${GIT_TAG}" -gcflags=all="-N -l" # see delve docs
7+
GOBUILD = env GO111MODULE=on go build -trimpath -ldflags "-X github.com/ledgerwatch/erigon/params.GitCommit=${GIT_COMMIT} -X github.com/ledgerwatch/erigon/params.GitBranch=${GIT_BRANCH} -X github.com/ledgerwatch/params.GitTag=${GIT_TAG}"
8+
GO_DBG_BUILD = env CGO_CFLAGS='-O0 -g -DMDBX_BUILD_FLAGS_CONFIG="config.h"' GODEBUG=cgocheck=2 go build -trimpath -tags=debug -ldflags "-X github.com/ledgerwatch/erigon/params.GitCommit=${GIT_COMMIT} -X github.com/ledgerwatch/erigon/params.GitBranch=${GIT_BRANCH} -X github.com/ledgerwatch/erigon/params.GitTag=${GIT_TAG}" -gcflags=all="-N -l" # see delve docs
99

1010
GO_MAJOR_VERSION = $(shell go version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f1)
1111
GO_MINOR_VERSION = $(shell go version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f2)
@@ -110,27 +110,22 @@ tracker:
110110

111111
db-tools: mdbx
112112
@echo "Building bb-tools"
113-
go mod vendor; cd vendor/github.com/ledgerwatch/lmdb-go/dist; make clean mdb_stat mdb_copy mdb_dump mdb_drop mdb_load; cp mdb_stat $(GOBIN); cp mdb_copy $(GOBIN); cp mdb_dump $(GOBIN); cp mdb_drop $(GOBIN); cp mdb_load $(GOBIN); cd ../../../../..; rm -rf vendor
114113

115-
cd ethdb/mdbx/dist/ && make tools
114+
cd ethdb/mdbx/dist/ && MDBX_BUILD_TIMESTAMP=unknown make tools
116115
cp ethdb/mdbx/dist/mdbx_chk $(GOBIN)
117116
cp ethdb/mdbx/dist/mdbx_copy $(GOBIN)
118117
cp ethdb/mdbx/dist/mdbx_dump $(GOBIN)
119118
cp ethdb/mdbx/dist/mdbx_drop $(GOBIN)
120119
cp ethdb/mdbx/dist/mdbx_load $(GOBIN)
121120
cp ethdb/mdbx/dist/mdbx_stat $(GOBIN)
122-
@echo "Run \"$(GOBIN)/lmdb_stat -h\" to get info about lmdb file."
121+
@echo "Run \"$(GOBIN)/mdbx_stat -h\" to get info about mdbx db file."
123122

124123
mdbx:
125124
@echo "Building mdbx"
126125
@cd ethdb/mdbx/dist/ \
127-
&& make clean && make config.h \
126+
&& make clean && MDBX_BUILD_TIMESTAMP=unknown make config.h \
128127
&& echo '#define MDBX_DEBUG 0' >> config.h \
129128
&& echo '#define MDBX_FORCE_ASSERTIONS 0' >> config.h \
130-
&& mv config.h config2.h \
131-
&& tail -n +2 config2.h > config.h \
132-
&& rm -f config2.h \
133-
&& cat config.h \
134129
&& CFLAGS_EXTRA="-Wno-deprecated-declarations" make mdbx-static.o
135130

136131
mdbx-dbg:
@@ -142,14 +137,7 @@ mdbx-dbg:
142137
&& CFLAGS_EXTRA="-Wno-deprecated-declarations" CFLAGS='-O0 -g -Wall -Werror -Wextra -Wpedantic -ffunction-sections -fPIC -fvisibility=hidden -std=gnu11 -pthread -Wno-error=attributes' make mdbx-static.o
143138

144139
test: mdbx
145-
TEST_DB=mdbx $(GOTEST) --timeout 15m
146-
147-
test-lmdb:
148-
TEST_DB=lmdb $(GOTEST)
149-
150-
151-
test-mdbx:
152-
TEST_DB=mdbx $(GOTEST) --timeout 20m
140+
$(GOTEST) --timeout 30m
153141

154142
lint:
155143
@./build/bin/golangci-lint run --config ./.golangci.yml
@@ -194,7 +182,7 @@ grpc:
194182
rm -rf ./build/include*
195183

196184
$(eval PROTOC_TMP := $(shell mktemp -d))
197-
cd $(PROTOC_TMP); curl -sSL https://github.com/protocolbuffers/protobuf/releases/download/v3.17.0/protoc-3.17.0-$(PROTOC_OS)-$(ARCH).zip -o protoc.zip
185+
cd $(PROTOC_TMP); curl -sSL https://github.com/protocolbuffers/protobuf/releases/download/v3.17.3/protoc-3.17.3-$(PROTOC_OS)-$(ARCH).zip -o protoc.zip
198186
cd $(PROTOC_TMP); unzip protoc.zip && mv bin/protoc $(GOBIN) && mv include $(GOBIN)/..
199187

200188
$(GOBUILD) -o $(GOBIN)/protoc-gen-go google.golang.org/protobuf/cmd/protoc-gen-go # generates proto messages

README.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Erigon is an implementation of Ethereum (aka "Ethereum client"), on the efficien
2525
+ [Reporting security issues/concerns](#reporting-security-issues-concerns)
2626
+ [Team](#team)
2727
- [Known issues](#known-issues)
28-
+ [`htop` shows incorrect memory usage on LMDB](#htop-shows-incorrect-memory-usage-when-using-lmdb)
28+
+ [`htop` shows incorrect memory usage](#htop-shows-incorrect-memory-usage)
2929
<!--te-->
3030

3131

@@ -107,9 +107,6 @@ Windows users may run erigon in 3 possible ways:
107107
security products for Windows and their respective detection algorythms and we understand this might make your experience with Windows builds uncomfortable. To
108108
workaround the issue you might either set exlusions for your antivirus specifically for `ethdb\mdbx\dist\CMakeFiles` folder or you can run erigon on Docker or WSL
109109

110-
Though is still possible to run erigon with **LMDB** database there's a caveat which might cause your experience with LMDB on Windows uncomfortable: data file allocation is fixed so you need to know in advance how much space you want to allocate for database file using the command line option `--lmdb.mapSize`.
111-
Please be advised Erigon will completely remove LMDB support in future releases thus we warmly suggest to resync using the default MDBX database.
112-
113110
* Use Docker : see [docker-compose.yml](./docker-compose.yml)
114111

115112
* Use WSL (Windows Subsystem for Linux) **strictly on version 2**. Under this option you can build Erigon just as you would on a regular Linux distribution. You can point your data also to any of the mounted Windows partitions (eg. `/mnt/c/[...]`, `/mnt/d/[...]` etc) but in such case be advised performance is impacted: this is due to the fact those mount points use `DrvFS` which is a [network file system](#blocks-execution-is-slow-on-cloud-network-drives) and, additionally, MDBX locks the db for exclusive access which implies only one process at a time can access data. This has consequences on the running of `rpcdaemon` which has to be configured as [Remote DB](#for-remote-db) even if it is executed on the very same computer.
@@ -284,9 +281,9 @@ Happy testing! 🥤
284281
Known issues
285282
============
286283

287-
### `htop` shows incorrect memory usage when using LMDB
284+
### `htop` shows incorrect memory usage
288285

289-
Erigon's internal DB (LMDB) using `MemoryMap` - when OS does manage all `read, write, cache` operations instead of Application
286+
Erigon's internal DB (MDBX) using `MemoryMap` - when OS does manage all `read, write, cache` operations instead of Application
290287
([linux](https://linux-kernel-labs.github.io/refs/heads/master/labs/memory_mapping.html), [windows](https://docs.microsoft.com/en-us/windows/win32/memory/file-mapping))
291288

292289
`htop` on column `res` shows memory of "App + OS used to hold page cache for given App",

accounts/abi/bind/backends/simulated.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ var (
6666
type SimulatedBackend struct {
6767
m *stages.MockSentry
6868
getHeader func(hash common.Hash, number uint64) *types.Header
69-
checkTEVM func(hash common.Hash) (bool, error)
69+
checkTEVM func(common.Hash) (bool, error)
7070

7171
mu sync.Mutex
7272
prependBlock *types.Block

cmd/abigen/main.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,11 @@ import (
3232
"github.com/ledgerwatch/erigon/crypto"
3333
"github.com/ledgerwatch/erigon/internal/flags"
3434
"github.com/ledgerwatch/erigon/log"
35+
"github.com/ledgerwatch/erigon/params"
3536
"github.com/urfave/cli"
3637
)
3738

3839
var (
39-
// Git SHA1 commit hash of the release (set via linker flags)
40-
gitCommit = ""
41-
gitDate = ""
42-
4340
app *cli.App
4441

4542
// Flags needed by abigen
@@ -101,7 +98,7 @@ var (
10198
)
10299

103100
func init() {
104-
app = flags.NewApp(gitCommit, gitDate, "ethereum checkpoint helper tool")
101+
app = flags.NewApp(params.GitCommit, "", "ethereum checkpoint helper tool")
105102
app.Flags = []cli.Flag{
106103
abiFlag,
107104
binFlag,

cmd/cons/commands/root.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import (
1414
var (
1515
consensusAddr string // Address of the consensus engine <host>:<port>
1616
datadir string // Path to the working dir
17-
database string // Type of database (lmdb or mdbx)
1817
config string // `file:<path>`` to specify config file in file system, `embed:<path>`` to use embedded file, `test` to register test interface and receive config from test driver
1918
)
2019

@@ -52,7 +51,6 @@ func must(err error) {
5251
func withDatadir(cmd *cobra.Command) {
5352
cmd.Flags().StringVar(&datadir, "datadir", paths.DefaultDataDir(), "directory where databases and temporary files are kept")
5453
must(cmd.MarkFlagDirname("datadir"))
55-
cmd.Flags().StringVar(&database, "database", "mdbx", "lmdb|mdbx")
5654
}
5755

5856
func withApiAddr(cmd *cobra.Command) {
@@ -68,14 +66,6 @@ func openDatabase(path string) ethdb.RwKV {
6866
}
6967

7068
func openKV(path string, exclusive bool) ethdb.RwKV {
71-
if database == "lmdb" {
72-
opts := ethdb.NewLMDB().Path(path)
73-
if exclusive {
74-
opts = opts.Exclusive()
75-
}
76-
return opts.MustOpen()
77-
}
78-
7969
opts := ethdb.NewMDBX().Path(path)
8070
if exclusive {
8171
opts = opts.Exclusive()

cmd/devp2p/crawl.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package main
1919
import (
2020
"time"
2121

22+
"github.com/ledgerwatch/erigon/common/debug"
2223
"github.com/ledgerwatch/erigon/log"
2324
"github.com/ledgerwatch/erigon/p2p/enode"
2425
)
@@ -103,6 +104,7 @@ loop:
103104
}
104105

105106
func (c *crawler) runIterator(done chan<- enode.Iterator, it enode.Iterator) {
107+
defer func() { debug.LogPanic(nil, true, recover()) }()
106108
defer func() { done <- it }()
107109
for it.Next() {
108110
select {

cmd/devp2p/main.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,10 @@ import (
3030

3131
var (
3232
// Git information set by linker when building with ci.go.
33-
gitCommit string
34-
gitDate string
35-
app = &cli.App{
33+
app = &cli.App{
3634
Name: filepath.Base(os.Args[0]),
3735
Usage: "go-ethereum devp2p tool",
38-
Version: params.VersionWithCommit(gitCommit, gitDate),
36+
Version: params.VersionWithCommit(params.GitCommit, ""),
3937
Writer: os.Stdout,
4038
HideVersion: true,
4139
}

cmd/erigon/main.go

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,17 @@ import (
66
"os"
77

88
"github.com/ledgerwatch/erigon/cmd/utils"
9+
"github.com/ledgerwatch/erigon/common/debug"
910
"github.com/ledgerwatch/erigon/log"
11+
"github.com/ledgerwatch/erigon/params"
1012
erigoncli "github.com/ledgerwatch/erigon/turbo/cli"
1113
"github.com/ledgerwatch/erigon/turbo/node"
1214
"github.com/urfave/cli"
1315
)
1416

15-
var (
16-
// Following vars are injected through the build flags (see Makefile)
17-
gitCommit string
18-
gitBranch string
19-
gitTag string
20-
)
21-
2217
func main() {
18+
// catch panics from main thread and logs stack trace into a file
19+
defer func() { debug.LogPanic(nil, true, recover()) }()
2320
// creating a erigon-api app with all defaults
2421
app := erigoncli.MakeApp(runErigon, erigoncli.DefaultFlags)
2522
if err := app.Run(os.Args); err != nil {
@@ -30,12 +27,11 @@ func main() {
3027

3128
func runErigon(cliCtx *cli.Context) {
3229
// creating staged sync with all default parameters
33-
3430
ctx, _ := utils.RootContext()
3531

3632
// initializing the node and providing the current git commit there
37-
log.Info("Build info", "git_branch", gitBranch, "git_tag", gitTag, "git_commit", gitCommit)
38-
eri := node.New(cliCtx, node.Params{GitCommit: gitCommit, GitBranch: gitBranch})
33+
log.Info("Build info", "git_branch", params.GitBranch, "git_tag", params.GitTag, "git_commit", params.GitCommit)
34+
eri := node.New(cliCtx, node.Params{})
3935
eri.SetP2PListenFunc(func(network, addr string) (net.Listener, error) {
4036
var lc net.ListenConfig
4137
return lc.Listen(ctx, network, addr)

cmd/evm/internal/t8ntool/execution.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ type ExecutionResult struct {
5252
LogsHash common.Hash `json:"logsHash"`
5353
Bloom types.Bloom `json:"logsBloom" gencodec:"required"`
5454
Receipts types.Receipts `json:"receipts"`
55-
Rejected []int `json:"rejected,omitempty"`
55+
Rejected []*rejectedTx `json:"rejected,omitempty"`
5656
}
5757

5858
type ommer struct {
@@ -72,6 +72,11 @@ type stEnv struct {
7272
BaseFee *big.Int `json:"currentBaseFee,omitempty"`
7373
}
7474

75+
type rejectedTx struct {
76+
Index int `json:"index"`
77+
Err string `json:"error"`
78+
}
79+
7580
type stEnvMarshaling struct {
7681
Coinbase common.UnprefixedAddress
7782
Difficulty *math.HexOrDecimal256
@@ -106,7 +111,7 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig,
106111
signer = types.MakeSigner(chainConfig, pre.Env.Number)
107112
gaspool = new(core.GasPool)
108113
blockHash = common.Hash{0x13, 0x37}
109-
rejectedTxs []int
114+
rejectedTxs []*rejectedTx
110115
includedTxs types.Transactions
111116
gasUsed = uint64(0)
112117
receipts = make(types.Receipts, 0)
@@ -143,8 +148,8 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig,
143148
for i, tx := range txs {
144149
msg, err := tx.AsMessage(*signer, pre.Env.BaseFee)
145150
if err != nil {
146-
log.Info("rejected tx", "index", i, "hash", tx.Hash(), "error", err)
147-
rejectedTxs = append(rejectedTxs, i)
151+
log.Warn("rejected tx", "index", i, "hash", tx.Hash(), "error", err)
152+
rejectedTxs = append(rejectedTxs, &rejectedTx{i, err.Error()})
148153
continue
149154
}
150155
tracer, err := getTracerFn(txIndex, tx.Hash())
@@ -163,7 +168,7 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig,
163168
if err != nil {
164169
ibs.RevertToSnapshot(snapshot)
165170
log.Info("rejected tx", "index", i, "hash", tx.Hash(), "from", msg.From(), "error", err)
166-
rejectedTxs = append(rejectedTxs, i)
171+
rejectedTxs = append(rejectedTxs, &rejectedTx{i, err.Error()})
167172
continue
168173
}
169174
includedTxs = append(includedTxs, tx)

cmd/evm/main.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,12 @@ import (
2525
"github.com/ledgerwatch/erigon/cmd/evm/internal/t8ntool"
2626
"github.com/ledgerwatch/erigon/cmd/utils"
2727
"github.com/ledgerwatch/erigon/internal/flags"
28+
"github.com/ledgerwatch/erigon/params"
2829
"github.com/urfave/cli"
2930
)
3031

31-
var gitCommit = "" // Git SHA1 commit hash of the release (set via linker flags)
32-
var gitDate = ""
33-
3432
var (
35-
app = flags.NewApp(gitCommit, gitDate, "the evm command line interface")
33+
app = flags.NewApp(params.GitCommit, "", "the evm command line interface")
3634

3735
DebugFlag = cli.BoolFlag{
3836
Name: "debug",

0 commit comments

Comments
 (0)