From 7eb2149ea7772ae0e878418b24546d82e29072fc Mon Sep 17 00:00:00 2001 From: Giulio Date: Fri, 12 Jul 2024 21:05:31 +0200 Subject: [PATCH 1/6] =?UTF-8?q?save2=20=C2=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cl/cltypes/solid/list_ssz_test.go | 41 +++++++++++++++++++++++++++++++ cmd/capcli/cli.go | 4 +-- 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/cl/cltypes/solid/list_ssz_test.go b/cl/cltypes/solid/list_ssz_test.go index 0590af08e3e..af8cbccc16d 100644 --- a/cl/cltypes/solid/list_ssz_test.go +++ b/cl/cltypes/solid/list_ssz_test.go @@ -17,7 +17,9 @@ package solid import ( + "encoding/binary" "testing" + "unsafe" "github.com/ledgerwatch/erigon-lib/common" "github.com/stretchr/testify/assert" @@ -146,3 +148,42 @@ func TestUint64VectorSSZ(t *testing.T) { encodingSize := arr.EncodingSizeSSZ() assert.Equal(t, expectedEncodingSize, encodingSize) } + +func addLittleEndianBytesInPlace(a, b []byte) { + *(*uint64)(unsafe.Pointer(&a[0])) += *(*uint64)(unsafe.Pointer(&b[0])) +} + +func addLittleEndianBytesInPlaceWithBinLib(a, b []byte) { + sum := binary.LittleEndian.Uint64(a) + binary.LittleEndian.Uint64(b) + binary.LittleEndian.PutUint64(a, sum) +} + +func BenchmarkXXX(b *testing.B) { + for i := 0; i < b.N; i++ { + a := make([]byte, 8) + bb := make([]byte, 8) + a = []byte{byte(i), byte(i + 1), byte(i + 2), byte(i + 3), byte(i + 4), byte(i + 5), byte(i + 6), byte(i + 7)} + bb = []byte{byte(i + 8), byte(i + 9), byte(i + 10), byte(i + 11), byte(i + 12), byte(i + 13), byte(i + 14), byte(i + 15)} + addLittleEndianBytesInPlace(a, bb) + } +} + +func BenchmarkXXX2(b *testing.B) { + + for i := 0; i < b.N; i++ { + // randomize + a := make([]byte, 8) + bb := make([]byte, 8) + a = []byte{byte(i), byte(i + 1), byte(i + 2), byte(i + 3), byte(i + 4), byte(i + 5), byte(i + 6), byte(i + 7)} + bb = []byte{byte(i + 8), byte(i + 9), byte(i + 10), byte(i + 11), byte(i + 12), byte(i + 13), byte(i + 14), byte(i + 15)} + addLittleEndianBytesInPlaceWithBinLib(a, bb) + } +} + +func BenchmarkXXX3(b *testing.B) { + + for i := 0; i < b.N; i++ { + // randomize + _ = i + (i + 23) + } +} diff --git a/cmd/capcli/cli.go b/cmd/capcli/cli.go index 91460e897fd..29ba3794048 100644 --- a/cmd/capcli/cli.go +++ b/cmd/capcli/cli.go @@ -210,7 +210,7 @@ func (c *ChainEndpoint) Run(ctx *Context) error { // Let's fetch the head first currentBlock, err := core.RetrieveBlock(ctx, beaconConfig, fmt.Sprintf("%s/head", baseUri), nil) if err != nil { - return err + return fmt.Errorf("failed to retrieve head: %w, uri: %s", err, fmt.Sprintf("%s/head", baseUri)) } currentRoot, err := currentBlock.Block.HashSSZ() if err != nil { @@ -246,7 +246,7 @@ func (c *ChainEndpoint) Run(ctx *Context) error { // Let's fetch the head first currentBlock, err := core.RetrieveBlock(ctx, beaconConfig, fmt.Sprintf("%s/0x%s", baseUri, stringifiedRoot), (*libcommon.Hash)(¤tRoot)) if err != nil { - return false, err + return false, fmt.Errorf("failed to retrieve block: %w, uri: %s", err, fmt.Sprintf("%s/0x%s", baseUri, stringifiedRoot)) } currentRoot, err = currentBlock.Block.HashSSZ() if err != nil { From d4eedd789dfb1671bddaa361bef5220d6b94b290 Mon Sep 17 00:00:00 2001 From: Giulio Date: Sat, 13 Jul 2024 18:48:34 +0200 Subject: [PATCH 2/6] save --- Makefile | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 50e746c6f47..0444d960c8f 100644 --- a/Makefile +++ b/Makefile @@ -23,8 +23,18 @@ CGO_CFLAGS += -DMDBX_DISABLE_VALIDATION=0 # Can disable it on CI by separated PR #CGO_CFLAGS += -DMDBX_ENABLE_PROFGC=0 # Disabled by default, but may be useful for performance debugging #CGO_CFLAGS += -DMDBX_ENABLE_PGOP_STAT=0 # Disabled by default, but may be useful for performance debugging CGO_CFLAGS += -DMDBX_ENV_CHECKPID=0 # Erigon doesn't do fork() syscall + +# If it is arm64 or aarch64, then we need to use portable version of blst. use or with stringw "arm64" and "aarch64" to support both +ifeq ($(shell uname -m), arm64) + CGO_CFLAGS += -D__BLST_PORTABLE__ +endif +ifeq ($(shell uname -m), aarch64) + CGO_CFLAGS += -D__BLST_PORTABLE__ +endif + + CGO_CFLAGS += -D__BLST_PORTABLE__ -CGO_CFLAGS += -Wno-unknown-warning-option -Wno-enum-int-mismatch -Wno-strict-prototypes -Wno-unused-but-set-variable +CGO_CFLAGS += -Wno-unknown-warning-option -Wno-enum-int-mismatch -Wno-strict-prototypes -Wno-unused-but-set-variable -O3 CGO_LDFLAGS := $(shell $(GO) env CGO_LDFLAGS 2> /dev/null) ifeq ($(shell uname -s), Darwin) @@ -44,7 +54,7 @@ GOPRIVATE = github.com/erigontech/silkworm-go PACKAGE = github.com/ledgerwatch/erigon -GO_FLAGS += -trimpath -tags $(BUILD_TAGS) -buildvcs=false +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="$(CGO_CFLAGS)" CGO_LDFLAGS="$(CGO_LDFLAGS)" GOPRIVATE="$(GOPRIVATE)" $(GO) build $(GO_FLAGS) From 5a5718a794e74bf0330f2c03b77181a776f17b74 Mon Sep 17 00:00:00 2001 From: Giulio Date: Sat, 13 Jul 2024 18:52:29 +0200 Subject: [PATCH 3/6] save --- cl/cltypes/solid/list_ssz_test.go | 41 ------------------------------- 1 file changed, 41 deletions(-) diff --git a/cl/cltypes/solid/list_ssz_test.go b/cl/cltypes/solid/list_ssz_test.go index af8cbccc16d..0590af08e3e 100644 --- a/cl/cltypes/solid/list_ssz_test.go +++ b/cl/cltypes/solid/list_ssz_test.go @@ -17,9 +17,7 @@ package solid import ( - "encoding/binary" "testing" - "unsafe" "github.com/ledgerwatch/erigon-lib/common" "github.com/stretchr/testify/assert" @@ -148,42 +146,3 @@ func TestUint64VectorSSZ(t *testing.T) { encodingSize := arr.EncodingSizeSSZ() assert.Equal(t, expectedEncodingSize, encodingSize) } - -func addLittleEndianBytesInPlace(a, b []byte) { - *(*uint64)(unsafe.Pointer(&a[0])) += *(*uint64)(unsafe.Pointer(&b[0])) -} - -func addLittleEndianBytesInPlaceWithBinLib(a, b []byte) { - sum := binary.LittleEndian.Uint64(a) + binary.LittleEndian.Uint64(b) - binary.LittleEndian.PutUint64(a, sum) -} - -func BenchmarkXXX(b *testing.B) { - for i := 0; i < b.N; i++ { - a := make([]byte, 8) - bb := make([]byte, 8) - a = []byte{byte(i), byte(i + 1), byte(i + 2), byte(i + 3), byte(i + 4), byte(i + 5), byte(i + 6), byte(i + 7)} - bb = []byte{byte(i + 8), byte(i + 9), byte(i + 10), byte(i + 11), byte(i + 12), byte(i + 13), byte(i + 14), byte(i + 15)} - addLittleEndianBytesInPlace(a, bb) - } -} - -func BenchmarkXXX2(b *testing.B) { - - for i := 0; i < b.N; i++ { - // randomize - a := make([]byte, 8) - bb := make([]byte, 8) - a = []byte{byte(i), byte(i + 1), byte(i + 2), byte(i + 3), byte(i + 4), byte(i + 5), byte(i + 6), byte(i + 7)} - bb = []byte{byte(i + 8), byte(i + 9), byte(i + 10), byte(i + 11), byte(i + 12), byte(i + 13), byte(i + 14), byte(i + 15)} - addLittleEndianBytesInPlaceWithBinLib(a, bb) - } -} - -func BenchmarkXXX3(b *testing.B) { - - for i := 0; i < b.N; i++ { - // randomize - _ = i + (i + 23) - } -} From 6cb9ba4e1c9c790642775a83978e8460a323d82f Mon Sep 17 00:00:00 2001 From: Giulio Date: Sat, 13 Jul 2024 19:43:38 +0200 Subject: [PATCH 4/6] save --- Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/Makefile b/Makefile index 0444d960c8f..77ce2a5abec 100644 --- a/Makefile +++ b/Makefile @@ -33,7 +33,6 @@ ifeq ($(shell uname -m), aarch64) endif -CGO_CFLAGS += -D__BLST_PORTABLE__ CGO_CFLAGS += -Wno-unknown-warning-option -Wno-enum-int-mismatch -Wno-strict-prototypes -Wno-unused-but-set-variable -O3 CGO_LDFLAGS := $(shell $(GO) env CGO_LDFLAGS 2> /dev/null) From bba07e080351461d52841f94d5cab145c105483c Mon Sep 17 00:00:00 2001 From: Giulio Date: Sat, 13 Jul 2024 19:51:08 +0200 Subject: [PATCH 5/6] save --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index 77ce2a5abec..30751ab1ff1 100644 --- a/Makefile +++ b/Makefile @@ -36,6 +36,8 @@ endif CGO_CFLAGS += -Wno-unknown-warning-option -Wno-enum-int-mismatch -Wno-strict-prototypes -Wno-unused-but-set-variable -O3 CGO_LDFLAGS := $(shell $(GO) env CGO_LDFLAGS 2> /dev/null) +CGO_LDFLAGS += -O3 -g + ifeq ($(shell uname -s), Darwin) ifeq ($(filter-out 13.%,$(shell sw_vers --productVersion)),) CGO_LDFLAGS += -mmacosx-version-min=13.3 From 8dd47ee7a14493ec3b4ddf6ea9afe56b690106a5 Mon Sep 17 00:00:00 2001 From: Giulio Date: Sun, 14 Jul 2024 02:07:10 +0200 Subject: [PATCH 6/6] save --- cl/antiquary/antiquary.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cl/antiquary/antiquary.go b/cl/antiquary/antiquary.go index 45a46d03174..7fc345834d0 100644 --- a/cl/antiquary/antiquary.go +++ b/cl/antiquary/antiquary.go @@ -133,7 +133,9 @@ func (a *Antiquary) Loop() error { return err } defer logInterval.Stop() - log.Info("[Antiquary] Stopping Caplin to process historical indicies", "from", from, "to", a.sn.BlocksAvailable()) + if from != a.sn.BlocksAvailable() { + log.Info("[Antiquary] Stopping Caplin to process historical indicies", "from", from, "to", a.sn.BlocksAvailable()) + } // Now write the snapshots as indicies for i := from; i < a.sn.BlocksAvailable(); i++ {