Skip to content

Commit

Permalink
Merge branch 'main' into duplicate-nmt-proof
Browse files Browse the repository at this point in the history
  • Loading branch information
Eoous committed Sep 13, 2024
2 parents aea3118 + b7f138d commit 7630f83
Show file tree
Hide file tree
Showing 33 changed files with 194 additions and 74 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check-generated.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e-manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e-nightly-34x.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/fuzz-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/govulncheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion DOCKER/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
4 changes: 4 additions & 0 deletions cmd/cometbft/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ var RootCmd = &cobra.Command{
}

logger = logger.With("module", "main")

for _, possibleMisconfiguration := range config.PossibleMisconfigurations() {
logger.Warn(possibleMisconfiguration)
}
return nil
},
}
19 changes: 19 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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 {
Expand Down
22 changes: 22 additions & 0 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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())
Expand Down
2 changes: 1 addition & 1 deletion docs/celestia-architecture/adr-001-block-propagation.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion docs/celestia-architecture/adr-002-ipld-da-sampling.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -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
Expand Down
37 changes: 30 additions & 7 deletions libs/log/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ type level byte
const (
levelDebug level = 1 << iota
levelInfo
levelWarn
levelError
)

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
}
}

Expand All @@ -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.
Expand All @@ -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.
Expand Down
12 changes: 12 additions & 0 deletions libs/log/filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
},
Expand All @@ -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"),
},
Expand All @@ -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"),
},
Expand All @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions libs/log/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions libs/log/nop_logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading

0 comments on commit 7630f83

Please sign in to comment.