From 3d4e4aeac899b446c3dfc2ed4c57502f6ec20cf5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 17 Jul 2024 11:04:20 -0400 Subject: [PATCH 1/7] build(deps): Bump github.com/celestiaorg/nmt from 0.21.0 to 0.22.0 (#1421) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [github.com/celestiaorg/nmt](https://github.com/celestiaorg/nmt) from 0.21.0 to 0.22.0.
Release notes

Sourced from github.com/celestiaorg/nmt's releases.

v0.22.0

What's Changed

New Contributors

Full Changelog: https://github.com/celestiaorg/nmt/compare/v0.21.0...v0.22.0

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=github.com/celestiaorg/nmt&package-manager=go_modules&previous-version=0.21.0&new-version=0.22.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 1a171cfe7b..b1b05c1f8f 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/btcsuite/btcd/btcec/v2 v2.2.1 github.com/btcsuite/btcd/btcutil v1.1.2 github.com/bufbuild/buf v1.9.0 - github.com/celestiaorg/nmt v0.21.0 + github.com/celestiaorg/nmt v0.22.0 github.com/cometbft/cometbft-db v0.7.0 github.com/creachadair/taskgroup v0.3.2 github.com/fortytw2/leaktest v1.3.0 diff --git a/go.sum b/go.sum index d1ef0dce8b..a4a2591c13 100644 --- a/go.sum +++ b/go.sum @@ -157,8 +157,8 @@ github.com/bufbuild/protocompile v0.1.0/go.mod h1:ix/MMMdsT3fzxfw91dvbfzKW3fRRnu github.com/butuzov/ireturn v0.1.1 h1:QvrO2QF2+/Cx1WA/vETCIYBKtRjc30vesdoPUNo1EbY= github.com/butuzov/ireturn v0.1.1/go.mod h1:Wh6Zl3IMtTpaIKbmwzqi6olnM9ptYQxxVacMsOEFPoc= github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= -github.com/celestiaorg/nmt v0.21.0 h1:81MBqxNn3orByoiCtdNVjwi5WsLgMkzHwP02ZMhTBHM= -github.com/celestiaorg/nmt v0.21.0/go.mod h1:ia/EpCk0enD5yO5frcxoNoFToz2Ghtk2i+blmCRjIY8= +github.com/celestiaorg/nmt v0.22.0 h1:AGtfmBiVgreR1KkIV5R7XFNeMp/H4IUDLlBbLjZZ3zk= +github.com/celestiaorg/nmt v0.22.0/go.mod h1:ia/EpCk0enD5yO5frcxoNoFToz2Ghtk2i+blmCRjIY8= github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4= github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= github.com/cenkalti/backoff/v4 v4.1.3 h1:cFAlzYUlVYDysBEH2T5hyJZMh3+5+WCBvSnK6Q8UtC4= From 1e71630207f4b62b9b7ec64f31b016ccbef989c9 Mon Sep 17 00:00:00 2001 From: crystalstall Date: Tue, 23 Jul 2024 18:47:24 +0900 Subject: [PATCH 2/7] chore: fix some comments for struct field (#1424) ## Description fix some comments for struct field --- #### PR checklist - [ ] Tests written/updated - [ ] Changelog entry added in `.changelog` (we use [unclog](https://github.com/informalsystems/unclog) to manage our changelog) - [ ] Updated relevant documentation (`docs/` or `spec/`) and code comments Signed-off-by: crystalstall --- config/config.go | 2 +- consensus/metrics.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/config.go b/config/config.go index 27b2db6a90..5289f5fe1d 100644 --- a/config/config.go +++ b/config/config.go @@ -1215,7 +1215,7 @@ type InstrumentationConfig struct { // pyroscope continuous profiling server. PyroscopeURL string `mapstructure:"pyroscope_url"` - // PyroscopeProfile is a flag that enables tracing with pyroscope. + // PyroscopeTrace is a flag that enables tracing with pyroscope. PyroscopeTrace bool `mapstructure:"pyroscope_trace"` // PyroscopeProfileTypes is a list of profile types to be traced with diff --git a/consensus/metrics.go b/consensus/metrics.go index cafa2ab6bc..fa7573c84e 100644 --- a/consensus/metrics.go +++ b/consensus/metrics.go @@ -75,7 +75,7 @@ type Metrics struct { // was relevant to the block the node is trying to gather or not. BlockGossipPartsReceived metrics.Counter - // QuroumPrevoteMessageDelay is the interval in seconds between the proposal + // QuorumPrevoteMessageDelay is the interval in seconds between the proposal // timestamp and the timestamp of the earliest prevote that achieved a quorum // during the prevote step. // From f03f8ec17faccf0cad76dda5660296b141308e35 Mon Sep 17 00:00:00 2001 From: Sanaz Taheri <35961250+staheri14@users.noreply.github.com> Date: Mon, 29 Jul 2024 02:56:24 -0700 Subject: [PATCH 3/7] chore: upgrades go version to 1.22.5 in main (#1434) Closes #1433 --- .github/workflows/check-generated.yml | 2 +- .github/workflows/coverage.yml | 6 +++--- .github/workflows/e2e-manual.yml | 2 +- .github/workflows/e2e-nightly-34x.yml | 2 +- .github/workflows/e2e.yml | 2 +- .github/workflows/fuzz-nightly.yml | 2 +- .github/workflows/govulncheck.yml | 2 +- .github/workflows/pre-release.yml | 2 +- .github/workflows/release-version.yml | 2 +- .github/workflows/release.yml | 2 +- .github/workflows/tests.yml | 4 ++-- DOCKER/Dockerfile | 2 +- README.md | 2 +- go.mod | 2 +- scripts/proto-gen.sh | 2 +- test/docker/Dockerfile | 2 +- test/e2e/docker/Dockerfile | 2 +- 17 files changed, 20 insertions(+), 20 deletions(-) diff --git a/.github/workflows/check-generated.yml b/.github/workflows/check-generated.yml index a47a31ada9..a51fe3936b 100644 --- a/.github/workflows/check-generated.yml +++ b/.github/workflows/check-generated.yml @@ -43,7 +43,7 @@ jobs: steps: - uses: actions/setup-go@v4 with: - go-version: "1.22.4" + go-version: "1.22.5" - uses: actions/checkout@v3 with: diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 0467f72618..d7d0665db6 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -12,7 +12,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-go@v4 with: - go-version: "1.22.4" + go-version: "1.22.5" - name: Create a file with all the pkgs run: go list ./... > pkgs.txt - name: Split pkgs into 4 files @@ -48,7 +48,7 @@ jobs: steps: - uses: actions/setup-go@v4 with: - go-version: "1.22.4" + go-version: "1.22.5" - uses: actions/checkout@v3 - uses: technote-space/get-diff-action@v6 with: @@ -70,7 +70,7 @@ jobs: steps: - uses: actions/setup-go@v4 with: - go-version: "1.22.4" + go-version: "1.22.5" - uses: actions/checkout@v3 - uses: technote-space/get-diff-action@v6 with: diff --git a/.github/workflows/e2e-manual.yml b/.github/workflows/e2e-manual.yml index a888a6b806..1ee1da6762 100644 --- a/.github/workflows/e2e-manual.yml +++ b/.github/workflows/e2e-manual.yml @@ -16,7 +16,7 @@ jobs: steps: - uses: actions/setup-go@v4 with: - go-version: '1.22.4' + go-version: '1.22.5' - uses: actions/checkout@v3 diff --git a/.github/workflows/e2e-nightly-34x.yml b/.github/workflows/e2e-nightly-34x.yml index ea18e2e07c..e3493c047d 100644 --- a/.github/workflows/e2e-nightly-34x.yml +++ b/.github/workflows/e2e-nightly-34x.yml @@ -23,7 +23,7 @@ jobs: steps: - uses: actions/setup-go@v4 with: - go-version: '1.22.4' + go-version: '1.22.5' - uses: actions/checkout@v3 with: diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index e33454c7cb..f31e283270 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -14,7 +14,7 @@ jobs: steps: - uses: actions/setup-go@v4 with: - go-version: '1.22.4' + go-version: '1.22.5' - uses: actions/checkout@v3 - uses: technote-space/get-diff-action@v6 with: diff --git a/.github/workflows/fuzz-nightly.yml b/.github/workflows/fuzz-nightly.yml index 223fb80f08..3f43f829c9 100644 --- a/.github/workflows/fuzz-nightly.yml +++ b/.github/workflows/fuzz-nightly.yml @@ -11,7 +11,7 @@ jobs: steps: - uses: actions/setup-go@v4 with: - go-version: '1.22.4' + go-version: '1.22.5' - uses: actions/checkout@v3 diff --git a/.github/workflows/govulncheck.yml b/.github/workflows/govulncheck.yml index 936ace5117..b379872850 100644 --- a/.github/workflows/govulncheck.yml +++ b/.github/workflows/govulncheck.yml @@ -16,7 +16,7 @@ jobs: steps: - uses: actions/setup-go@v3 with: - go-version: "1.22.4" + go-version: "1.22.5" - uses: actions/checkout@v3 - uses: technote-space/get-diff-action@v6 with: diff --git a/.github/workflows/pre-release.yml b/.github/workflows/pre-release.yml index b92ec2d514..7364f626f1 100644 --- a/.github/workflows/pre-release.yml +++ b/.github/workflows/pre-release.yml @@ -18,7 +18,7 @@ jobs: - uses: actions/setup-go@v4 with: - go-version: '1.22.4' + go-version: '1.22.5' # Similar check to ./release-version.yml, but enforces this when pushing # tags. The ./release-version.yml check can be bypassed and is mainly diff --git a/.github/workflows/release-version.yml b/.github/workflows/release-version.yml index 7a3ef881c0..f3dbd37c97 100644 --- a/.github/workflows/release-version.yml +++ b/.github/workflows/release-version.yml @@ -15,7 +15,7 @@ jobs: - uses: actions/setup-go@v4 with: - go-version: '1.22.4' + go-version: '1.22.5' - name: Check version run: | diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 707fa505ab..976aae81f1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,7 +16,7 @@ jobs: - uses: actions/setup-go@v4 with: - go-version: '1.22.4' + go-version: '1.22.5' - name: Generate release notes run: | diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 41cfae35bb..c1049fe754 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -25,7 +25,7 @@ jobs: steps: - uses: actions/setup-go@v4 with: - go-version: "1.22.4" + go-version: "1.22.5" - uses: actions/checkout@v3 - uses: technote-space/get-diff-action@v6 with: @@ -58,7 +58,7 @@ jobs: # steps: # - uses: actions/setup-go@v3 # with: - # go-version: "1.22.4" + # go-version: "1.22.5" # - uses: actions/checkout@v3 # - uses: technote-space/get-diff-action@v6 # with: diff --git a/DOCKER/Dockerfile b/DOCKER/Dockerfile index c1ee8ad8e7..f642c24315 100644 --- a/DOCKER/Dockerfile +++ b/DOCKER/Dockerfile @@ -1,6 +1,6 @@ # Use a build arg to ensure that both stages use the same, # hopefully current, go version. -ARG GOLANG_BASE_IMAGE=golang:1.22.4-alpine +ARG GOLANG_BASE_IMAGE=golang:1.22.5-alpine # stage 1 Generate CometBFT Binary FROM --platform=$BUILDPLATFORM $GOLANG_BASE_IMAGE as builder diff --git a/README.md b/README.md index 26960c4e9e..c34b804b49 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ This repo intends on preserving the minimal possible diff with [cometbft/cometbf - **specific to Celestia**: consider if [celestia-app](https://github.com/celestiaorg/celestia-app) is a better target - **not specific to Celestia**: consider making the contribution upstream in CometBFT -1. [Install Go](https://go.dev/doc/install) 1.22.4+ +1. [Install Go](https://go.dev/doc/install) 1.22.5+ 2. Fork this repo 3. Clone your fork 4. Find an issue to work on (see [good first issues](https://github.com/celestiaorg/celestia-core/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22)) diff --git a/go.mod b/go.mod index b1b05c1f8f..847e95823a 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/cometbft/cometbft -go 1.22.4 +go 1.22.5 require ( github.com/BurntSushi/toml v1.2.1 diff --git a/scripts/proto-gen.sh b/scripts/proto-gen.sh index 4cf0656326..545648045d 100755 --- a/scripts/proto-gen.sh +++ b/scripts/proto-gen.sh @@ -10,7 +10,7 @@ cd "$(git rev-parse --show-toplevel)" # Run inside Docker to install the correct versions of the required tools # without polluting the local system. -docker run --rm -i -v "$PWD":/w --workdir=/w golang:1.22.4-alpine sh <<"EOF" +docker run --rm -i -v "$PWD":/w --workdir=/w golang:1.22.5-alpine sh <<"EOF" apk add git make go install github.com/bufbuild/buf/cmd/buf diff --git a/test/docker/Dockerfile b/test/docker/Dockerfile index 364589845a..23b66cd6ca 100644 --- a/test/docker/Dockerfile +++ b/test/docker/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.22.4 +FROM golang:1.22.5 # Grab deps (jq, hexdump, xxd, killall) RUN apt-get update && \ diff --git a/test/e2e/docker/Dockerfile b/test/e2e/docker/Dockerfile index 41d0fc4937..c90a7e29ef 100644 --- a/test/e2e/docker/Dockerfile +++ b/test/e2e/docker/Dockerfile @@ -1,7 +1,7 @@ # We need to build in a Linux environment to support C libraries, e.g. RocksDB. # We use Debian instead of Alpine, so that we can use binary database packages # instead of spending time compiling them. -FROM golang:1.22.4-bullseye +FROM golang:1.22.5-bullseye RUN apt-get -qq update -y && apt-get -qq upgrade -y >/dev/null RUN apt-get -qq install -y libleveldb-dev librocksdb-dev >/dev/null From a50142260cf9a79b62093238b2f82a0061c73549 Mon Sep 17 00:00:00 2001 From: Sanaz Taheri <35961250+staheri14@users.noreply.github.com> Date: Mon, 29 Jul 2024 13:27:17 -0700 Subject: [PATCH 4/7] revert: enhances S3Download to filter by traced table names (#1430) Reverts celestiaorg/celestia-core#1374 --- pkg/trace/fileserver.go | 72 ++++++++++++++++------------------------- 1 file changed, 28 insertions(+), 44 deletions(-) diff --git a/pkg/trace/fileserver.go b/pkg/trace/fileserver.go index e4b4ee8f10..3f759ef0df 100644 --- a/pkg/trace/fileserver.go +++ b/pkg/trace/fileserver.go @@ -259,9 +259,7 @@ func (lt *LocalTracer) PushAll() error { // S3Download downloads files that match some prefix from an S3 bucket to a // local directory dst. -// fileNames is a list of traced jsonl file names to download. If it is empty, all traces are downloaded. -// fileNames should not have .jsonl suffix. -func S3Download(dst, prefix string, fileNames []string, cfg S3Config) error { +func S3Download(dst, prefix string, cfg S3Config) error { // Ensure local directory structure exists err := os.MkdirAll(dst, os.ModePerm) if err != nil { @@ -290,51 +288,37 @@ func S3Download(dst, prefix string, fileNames []string, cfg S3Config) error { err = s3Svc.ListObjectsV2Pages(input, func(page *s3.ListObjectsV2Output, lastPage bool) bool { for _, content := range page.Contents { - key := *content.Key + localFilePath := filepath.Join(dst, prefix, strings.TrimPrefix(*content.Key, prefix)) + fmt.Printf("Downloading %s to %s\n", *content.Key, localFilePath) - // If no fileNames are specified, download all files - if len(fileNames) == 0 { - fileNames = append(fileNames, strings.TrimPrefix(key, prefix)) + // Create the directories in the path + if err := os.MkdirAll(filepath.Dir(localFilePath), os.ModePerm); err != nil { + return false } - for _, filename := range fileNames { - // Add .jsonl suffix to the fileNames - fullFilename := filename + ".jsonl" - if strings.HasSuffix(key, fullFilename) { - localFilePath := filepath.Join(dst, prefix, strings.TrimPrefix(key, prefix)) - fmt.Printf("Downloading %s to %s\n", key, localFilePath) - - // Create the directories in the path - if err := os.MkdirAll(filepath.Dir(localFilePath), os.ModePerm); err != nil { - return false - } - - // Create a file to write the S3 Object contents to. - f, err := os.Create(localFilePath) - if err != nil { - return false - } - - resp, err := s3Svc.GetObject(&s3.GetObjectInput{ - Bucket: aws.String(cfg.BucketName), - Key: aws.String(key), - }) - if err != nil { - f.Close() - continue - } - defer resp.Body.Close() - - // Copy the contents of the S3 object to the local file - if _, err := io.Copy(f, resp.Body); err != nil { - f.Close() - return false - } - - fmt.Printf("Successfully downloaded %s to %s\n", key, localFilePath) - f.Close() - } + // Create a file to write the S3 Object contents to. + f, err := os.Create(localFilePath) + if err != nil { + return false + } + + resp, err := s3Svc.GetObject(&s3.GetObjectInput{ + Bucket: aws.String(cfg.BucketName), + Key: aws.String(*content.Key), + }) + if err != nil { + f.Close() + continue } + defer resp.Body.Close() + + // Copy the contents of the S3 object to the local file + if _, err := io.Copy(f, resp.Body); err != nil { + return false + } + + fmt.Printf("Successfully downloaded %s to %s\n", *content.Key, localFilePath) + f.Close() } return !lastPage // continue paging }) From ac057f3bc10fe7a53699fd3443fca9032f3084b2 Mon Sep 17 00:00:00 2001 From: Elias Rad <146735585+nnsW3@users.noreply.github.com> Date: Tue, 30 Jul 2024 23:45:17 +0300 Subject: [PATCH 5/7] fix: spelling issues (#1438) Hello I found some spelling issues in your docs. Glad I could help. Br, Elias. --- docs/celestia-architecture/adr-001-block-propagation.md | 2 +- docs/celestia-architecture/adr-002-ipld-da-sampling.md | 2 +- .../celestia-architecture/adr-003-application-data-retrieval.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/celestia-architecture/adr-001-block-propagation.md b/docs/celestia-architecture/adr-001-block-propagation.md index 861f7738e4..80933fd1f6 100644 --- a/docs/celestia-architecture/adr-001-block-propagation.md +++ b/docs/celestia-architecture/adr-001-block-propagation.md @@ -102,7 +102,7 @@ When a user requests a block from the LL node, the request will be set to the IP ![user request flow](./assets/user-request.png) -The goal is to not change the public interface for RPC's. It is yet to be seen if this possible. This means that CIDs will need to be set and loaded from the store in order to get all the related block information an user requires. +The goal is to not change the public interface for RPC's. It is yet to be seen if this is possible. This means that CIDs will need to be set and loaded from the store in order to get all the related block information a user requires. ## Status diff --git a/docs/celestia-architecture/adr-002-ipld-da-sampling.md b/docs/celestia-architecture/adr-002-ipld-da-sampling.md index 340ed8a2aa..6521c3590e 100644 --- a/docs/celestia-architecture/adr-002-ipld-da-sampling.md +++ b/docs/celestia-architecture/adr-002-ipld-da-sampling.md @@ -47,7 +47,7 @@ and [`NodeAdder`](https://github.com/ipfs/go-ipld-format/blob/d2e09424ddee0d7e69 As an optimization, we can also use a [`Batch`](https://github.com/ipfs/go-ipld-format/blob/d2e09424ddee0d7e696d01143318d32d0fb1ae63/batch.go#L29) to batch adding and removing nodes. This will be achieved by passing around a [CoreAPI](https://github.com/ipfs/interface-go-ipfs-core/blob/b935dfe5375eac7ea3c65b14b3f9a0242861d0b3/coreapi.go#L15) -object, which derive from the IPFS node which is created along a with a tendermint node (see [#152]). +object, which derive from the IPFS node which is created along with a tendermint node (see [#152]). This code snippet does exactly that (see the [go-ipfs documentation] for more examples): ```go // This constructs an IPFS node instance diff --git a/docs/celestia-architecture/adr-003-application-data-retrieval.md b/docs/celestia-architecture/adr-003-application-data-retrieval.md index 1f2dc9b052..689fdfdab2 100644 --- a/docs/celestia-architecture/adr-003-application-data-retrieval.md +++ b/docs/celestia-architecture/adr-003-application-data-retrieval.md @@ -7,7 +7,7 @@ ## Context This ADR builds on top of [ADR 002](adr-002-ipld-da-sampling.md) and will use the implemented APIs described there. -The reader should familiarize themselves at least with the high-level concepts the as well as in the [specs](https://github.com/celestiaorg/celestia-specs/blob/master/src/specs/data_structures.md#2d-reed-solomon-encoding-scheme). +The reader should familiarize themselves at least with the high-level concepts as well as in the [specs](https://github.com/celestiaorg/celestia-specs/blob/master/src/specs/data_structures.md#2d-reed-solomon-encoding-scheme). The academic [paper](https://arxiv.org/abs/1905.09274) describes the motivation and context for this API. The main motivation can be quoted from section 3.3 of that paper: From 025a8bca79393bb5fa869e75b330552e097bf117 Mon Sep 17 00:00:00 2001 From: Eoous <38656355+Eoous@users.noreply.github.com> Date: Wed, 31 Jul 2024 21:22:46 +0800 Subject: [PATCH 6/7] feat: metric for counting rejected transactions (#1415) ## Description Add counter to the block executor metrics : - RejectedTransactions Resolves #1241 Unblocks #1007 #### PR checklist - [ ] Tests written/updated - [ ] Changelog entry added in `.changelog` (we use [unclog](https://github.com/informalsystems/unclog) to manage our changelog) - [ ] Updated relevant documentation (`docs/` or `spec/`) and code comments --------- Co-authored-by: 0xEclair <38656355+0xEclair@users.noreply.github.com> Co-authored-by: Callum Waters --- state/execution.go | 6 ++++++ state/metrics.go | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/state/execution.go b/state/execution.go index 99d35b13d7..961a9c36f7 100644 --- a/state/execution.go +++ b/state/execution.go @@ -153,6 +153,12 @@ func (blockExec *BlockExecutor) CreateProposalBlock( panic(fmt.Sprintf("state machine returned an invalid prepare proposal response: expected last transaction to be a hash, got %d bytes", len(rpp.Txs[len(rpp.Txs)-2]))) } + // don't count the last tx in rpp.Txs which is data root back from app + rejectedTxs := len(block.Txs) - (len(rpp.Txs) - 1) + if rejectedTxs > 0 { + blockExec.metrics.RejectedTransactions.Add(float64(rejectedTxs)) + } + // update the block with the response from PrepareProposal block.Data.Txs = types.ToTxs(rpp.Txs[:len(rpp.Txs)-1]) // update the data hash with the one passed back by celestia-app diff --git a/state/metrics.go b/state/metrics.go index 6c687f8549..31c674e60d 100644 --- a/state/metrics.go +++ b/state/metrics.go @@ -19,6 +19,8 @@ type Metrics struct { BlockProcessingTime metrics.Histogram // Count of times a block was rejected via ProcessProposal ProcessProposalRejected metrics.Counter + // Count of transactions rejected by application. + RejectedTransactions metrics.Counter } // PrometheusMetrics returns Metrics build using Prometheus client library. @@ -43,6 +45,12 @@ func PrometheusMetrics(namespace string, labelsAndValues ...string) *Metrics { Name: "process_proposal_rejected", Help: "Count of times a block was rejected via ProcessProposal", }, labels).With(labelsAndValues...), + RejectedTransactions: prometheus.NewCounterFrom(stdprometheus.CounterOpts{ + Namespace: namespace, + Subsystem: MetricsSubsystem, + Name: "rejected_transactions", + Help: "Count of transactions rejected by application", + }, labels).With(labelsAndValues...), } } @@ -51,5 +59,6 @@ func NopMetrics() *Metrics { return &Metrics{ BlockProcessingTime: discard.NewHistogram(), ProcessProposalRejected: discard.NewCounter(), + RejectedTransactions: discard.NewCounter(), } } From b7f138dfa0e4eb560d77e927b495072eeb16bf00 Mon Sep 17 00:00:00 2001 From: nathan haim Date: Tue, 6 Aug 2024 21:07:47 +0200 Subject: [PATCH 7/7] feat: warn when state sync settings are set while `enable = false` (#1443) ## Description Closes https://github.com/celestiaorg/celestia-app/issues/3736 This adds warn logs when state sync settings are set while `enable = false` as it may lead to unexpected behavior whereas Config is valid. #### PR checklist - [X] Tests written/updated - [ ] Changelog entry added in `.changelog` (we use [unclog](https://github.com/informalsystems/unclog) to manage our changelog) - [ ] Updated relevant documentation (`docs/` or `spec/`) and code comments --------- Co-authored-by: Rootul P --- cmd/cometbft/commands/root.go | 4 ++++ config/config.go | 19 ++++++++++++++++++ config/config_test.go | 22 +++++++++++++++++++++ libs/log/filter.go | 37 ++++++++++++++++++++++++++++------- libs/log/filter_test.go | 12 ++++++++++++ libs/log/logger.go | 1 + libs/log/nop_logger.go | 1 + libs/log/tm_logger.go | 12 ++++++++++++ libs/log/tm_logger_test.go | 23 ++++++++++++++++++++++ libs/log/tracing_logger.go | 4 ++++ 10 files changed, 128 insertions(+), 7 deletions(-) diff --git a/cmd/cometbft/commands/root.go b/cmd/cometbft/commands/root.go index 07f8c6d5ed..7a592d0b3d 100644 --- a/cmd/cometbft/commands/root.go +++ b/cmd/cometbft/commands/root.go @@ -87,6 +87,10 @@ var RootCmd = &cobra.Command{ } logger = logger.With("module", "main") + + for _, possibleMisconfiguration := range config.PossibleMisconfigurations() { + logger.Warn(possibleMisconfiguration) + } return nil }, } diff --git a/config/config.go b/config/config.go index 5289f5fe1d..fde13fbccf 100644 --- a/config/config.go +++ b/config/config.go @@ -161,6 +161,16 @@ func (cfg *Config) ValidateBasic() error { return nil } +// PossibleMisconfigurations returns a list of possible conflicting entries that +// may lead to unexpected behavior +func (cfg *Config) PossibleMisconfigurations() []string { + res := []string{} + for _, elem := range cfg.StateSync.PossibleMisconfigurations() { + res = append(res, fmt.Sprintf("[statesync] section: %s", elem)) + } + return res +} + //----------------------------------------------------------------------------- // BaseConfig @@ -857,6 +867,15 @@ func TestStateSyncConfig() *StateSyncConfig { return DefaultStateSyncConfig() } +// PossibleMisconfigurations returns a list of possible conflicting entries that +// may lead to unexpected behavior +func (cfg *StateSyncConfig) PossibleMisconfigurations() []string { + if !cfg.Enable && len(cfg.RPCServers) != 0 { + return []string{"rpc_servers specified but enable = false"} + } + return []string{} +} + // ValidateBasic performs basic validation. func (cfg *StateSyncConfig) ValidateBasic() error { if cfg.Enable { diff --git a/config/config_test.go b/config/config_test.go index 43f0a46c49..cb58f14d02 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -38,6 +38,17 @@ func TestConfigValidateBasic(t *testing.T) { assert.Error(t, cfg.ValidateBasic()) } +func TestConfigPossibleMisconfigurations(t *testing.T) { + cfg := DefaultConfig() + require.Len(t, cfg.PossibleMisconfigurations(), 0) + // providing rpc_servers while enable = false is a possible misconfiguration + cfg.StateSync.RPCServers = []string{"first_rpc"} + require.Equal(t, []string{"[statesync] section: rpc_servers specified but enable = false"}, cfg.PossibleMisconfigurations()) + // enabling statesync deletes possible misconfiguration + cfg.StateSync.Enable = true + require.Len(t, cfg.PossibleMisconfigurations(), 0) +} + func TestTLSConfiguration(t *testing.T) { assert := assert.New(t) cfg := DefaultConfig() @@ -127,6 +138,17 @@ func TestStateSyncConfigValidateBasic(t *testing.T) { require.NoError(t, cfg.ValidateBasic()) } +func TestStateSyncPossibleMisconfigurations(t *testing.T) { + cfg := DefaultStateSyncConfig() + require.Len(t, cfg.PossibleMisconfigurations(), 0) + // providing rpc_servers while enable = false is a possible misconfiguration + cfg.RPCServers = []string{"first_rpc"} + require.Equal(t, []string{"rpc_servers specified but enable = false"}, cfg.PossibleMisconfigurations()) + // enabling statesync deletes possible misconfiguration + cfg.Enable = true + require.Len(t, cfg.PossibleMisconfigurations(), 0) +} + func TestFastSyncConfigValidateBasic(t *testing.T) { cfg := TestFastSyncConfig() assert.NoError(t, cfg.ValidateBasic()) diff --git a/libs/log/filter.go b/libs/log/filter.go index 4b7ed981cd..6e4a09775d 100644 --- a/libs/log/filter.go +++ b/libs/log/filter.go @@ -7,6 +7,7 @@ type level byte const ( levelDebug level = 1 << iota levelInfo + levelWarn levelError ) @@ -54,6 +55,14 @@ func (l *filter) Debug(msg string, keyvals ...interface{}) { l.next.Debug(msg, keyvals...) } +func (l *filter) Warn(msg string, keyvals ...interface{}) { + levelAllowed := l.allowed&levelWarn != 0 + if !levelAllowed { + return + } + l.next.Warn(msg, keyvals...) +} + func (l *filter) Error(msg string, keyvals ...interface{}) { levelAllowed := l.allowed&levelError != 0 if !levelAllowed { @@ -137,12 +146,14 @@ func AllowLevel(lvl string) (Option, error) { return AllowDebug(), nil case "info": return AllowInfo(), nil + case "warn": + return AllowWarn(), nil case "error": return AllowError(), nil case "none": return AllowNone(), nil default: - return nil, fmt.Errorf("expected either \"info\", \"debug\", \"error\" or \"none\" level, given %s", lvl) + return nil, fmt.Errorf("expected either \"info\", \"debug\", \"warn\", \"error\" or \"none\" level, given %s", lvl) } } @@ -153,12 +164,17 @@ func AllowAll() Option { // AllowDebug allows error, info and debug level log events to pass. func AllowDebug() Option { - return allowed(levelError | levelInfo | levelDebug) + return allowed(levelError | levelWarn | levelInfo | levelDebug) } // AllowInfo allows error and info level log events to pass. func AllowInfo() Option { - return allowed(levelError | levelInfo) + return allowed(levelError | levelWarn | levelInfo) +} + +// AllowWarn allows error and warn level log events to pass. +func AllowWarn() Option { + return allowed(levelError | levelWarn) } // AllowError allows only error level log events to pass. @@ -175,14 +191,21 @@ func allowed(allowed level) Option { return func(l *filter) { l.allowed = allowed } } -// AllowDebugWith allows error, info and debug level log events to pass for a specific key value pair. +// AllowDebugWith allows error, warn, info and debug level log events to pass for a specific key value pair. func AllowDebugWith(key interface{}, value interface{}) Option { - return func(l *filter) { l.allowedKeyvals[keyval{key, value}] = levelError | levelInfo | levelDebug } + return func(l *filter) { + l.allowedKeyvals[keyval{key, value}] = levelError | levelWarn | levelInfo | levelDebug + } } -// AllowInfoWith allows error and info level log events to pass for a specific key value pair. +// AllowInfoWith allows error, warn, and info level log events to pass for a specific key value pair. func AllowInfoWith(key interface{}, value interface{}) Option { - return func(l *filter) { l.allowedKeyvals[keyval{key, value}] = levelError | levelInfo } + return func(l *filter) { l.allowedKeyvals[keyval{key, value}] = levelError | levelWarn | levelInfo } +} + +// AllowWarnWith allows only error and warn log events to pass for a specific key value pair. +func AllowWarnWith(key interface{}, value interface{}) Option { + return func(l *filter) { l.allowedKeyvals[keyval{key, value}] = levelError | levelWarn } } // AllowErrorWith allows only error level log events to pass for a specific key value pair. diff --git a/libs/log/filter_test.go b/libs/log/filter_test.go index f98fd6e71e..d89b742c81 100644 --- a/libs/log/filter_test.go +++ b/libs/log/filter_test.go @@ -20,6 +20,7 @@ func TestVariousLevels(t *testing.T) { strings.Join([]string{ `{"_msg":"here","level":"debug","this is":"debug log"}`, `{"_msg":"here","level":"info","this is":"info log"}`, + `{"_msg":"here","level":"warn","this is":"warn log"}`, `{"_msg":"here","level":"error","this is":"error log"}`, }, "\n"), }, @@ -29,6 +30,7 @@ func TestVariousLevels(t *testing.T) { strings.Join([]string{ `{"_msg":"here","level":"debug","this is":"debug log"}`, `{"_msg":"here","level":"info","this is":"info log"}`, + `{"_msg":"here","level":"warn","this is":"warn log"}`, `{"_msg":"here","level":"error","this is":"error log"}`, }, "\n"), }, @@ -37,6 +39,15 @@ func TestVariousLevels(t *testing.T) { log.AllowInfo(), strings.Join([]string{ `{"_msg":"here","level":"info","this is":"info log"}`, + `{"_msg":"here","level":"warn","this is":"warn log"}`, + `{"_msg":"here","level":"error","this is":"error log"}`, + }, "\n"), + }, + { + "AllowWarn", + log.AllowWarn(), + strings.Join([]string{ + `{"_msg":"here","level":"warn","this is":"warn log"}`, `{"_msg":"here","level":"error","this is":"error log"}`, }, "\n"), }, @@ -62,6 +73,7 @@ func TestVariousLevels(t *testing.T) { logger.Debug("here", "this is", "debug log") logger.Info("here", "this is", "info log") + logger.Warn("here", "this is", "warn log") logger.Error("here", "this is", "error log") if want, have := tc.want, strings.TrimSpace(buf.String()); want != have { diff --git a/libs/log/logger.go b/libs/log/logger.go index 22ed68f1a1..ef00acbd22 100644 --- a/libs/log/logger.go +++ b/libs/log/logger.go @@ -10,6 +10,7 @@ import ( type Logger interface { Debug(msg string, keyvals ...interface{}) Info(msg string, keyvals ...interface{}) + Warn(msg string, keyvals ...interface{}) Error(msg string, keyvals ...interface{}) With(keyvals ...interface{}) Logger diff --git a/libs/log/nop_logger.go b/libs/log/nop_logger.go index 12d75abe6b..4f0d4e7fca 100644 --- a/libs/log/nop_logger.go +++ b/libs/log/nop_logger.go @@ -10,6 +10,7 @@ func NewNopLogger() Logger { return &nopLogger{} } func (nopLogger) Info(string, ...interface{}) {} func (nopLogger) Debug(string, ...interface{}) {} +func (nopLogger) Warn(string, ...interface{}) {} func (nopLogger) Error(string, ...interface{}) {} func (l *nopLogger) With(...interface{}) Logger { diff --git a/libs/log/tm_logger.go b/libs/log/tm_logger.go index ac0d08adb0..b8034d5114 100644 --- a/libs/log/tm_logger.go +++ b/libs/log/tm_logger.go @@ -33,6 +33,8 @@ func NewTMLogger(w io.Writer) Logger { switch keyvals[1].(kitlevel.Value).String() { case "debug": return term.FgBgColor{Fg: term.DarkGray} + case "warn": + return term.FgBgColor{Fg: term.Yellow} case "error": return term.FgBgColor{Fg: term.Red} default: @@ -79,6 +81,16 @@ func (l *tmLogger) Error(msg string, keyvals ...interface{}) { } } +// Warn logs a message at level Warn. +func (l *tmLogger) Warn(msg string, keyvals ...interface{}) { + lWithLevel := kitlevel.Warn(l.srcLogger) + + lWithMsg := kitlog.With(lWithLevel, msgKey, msg) + if err := lWithMsg.Log(keyvals...); err != nil { + lWithMsg.Log("err", err) //nolint:errcheck // no need to check error again + } +} + // With returns a new contextual logger with keyvals prepended to those passed // to calls to Info, Debug or Error. func (l *tmLogger) With(keyvals ...interface{}) Logger { diff --git a/libs/log/tm_logger_test.go b/libs/log/tm_logger_test.go index 95b4fd5379..4856f25e2d 100644 --- a/libs/log/tm_logger_test.go +++ b/libs/log/tm_logger_test.go @@ -66,6 +66,29 @@ func TestDebug(t *testing.T) { } } +func TestWarn(t *testing.T) { + var bufWarn bytes.Buffer + + ld := log.NewTMLogger(&bufWarn) + ld.Warn("Client initialized with old header (trusted is more recent)", + "old", 42, + "trustedHeight", "forty two", + "trustedHash", []byte("test me")) + + msg := strings.TrimSpace(bufWarn.String()) + + // Remove the timestamp information to allow + // us to test against the expected message. + receivedmsg := strings.Split(msg, "] ")[1] + + const expectedmsg = `Client initialized with old header + (trusted is more recent) old=42 trustedHeight="forty two" + trustedHash=74657374206D65` + if strings.EqualFold(receivedmsg, expectedmsg) { + t.Fatalf("received %s, expected %s", receivedmsg, expectedmsg) + } +} + func TestError(t *testing.T) { var bufErr bytes.Buffer diff --git a/libs/log/tracing_logger.go b/libs/log/tracing_logger.go index d2a6ff44e5..164bf59f5b 100644 --- a/libs/log/tracing_logger.go +++ b/libs/log/tracing_logger.go @@ -36,6 +36,10 @@ func (l *tracingLogger) Debug(msg string, keyvals ...interface{}) { l.next.Debug(msg, formatErrors(keyvals)...) } +func (l *tracingLogger) Warn(msg string, keyvals ...interface{}) { + l.next.Warn(msg, formatErrors(keyvals)...) +} + func (l *tracingLogger) Error(msg string, keyvals ...interface{}) { l.next.Error(msg, formatErrors(keyvals)...) }