Skip to content

Commit 0380c62

Browse files
authored
Merge branch 'main' into claude/github-actions
2 parents e4b085b + 99b4858 commit 0380c62

File tree

18 files changed

+306
-231
lines changed

18 files changed

+306
-231
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,7 @@ jobs:
855855
- uses: actions/checkout@v4
856856
- uses: actions/setup-go@v5
857857
with:
858-
go-version: "1.20"
858+
go-version: "1.21"
859859
check-latest: true
860860
cache: true
861861
cache-dependency-path: log/go.sum

log/CHANGELOG.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@ Each entry must include the Github issue reference in the following format:
2222

2323
## [Unreleased]
2424

25-
### Improvements
25+
## [v1.5.0](https://github.com/cosmos/cosmos-sdk/releases/tag/log/v1.4.1) - 2024-11-07
2626

27-
* [#22233](https://github.com/cosmos/cosmos-sdk/pull/22233) Use sonic json library for faster json handling
28-
* [#22347](https://github.com/cosmos/cosmos-sdk/pull/22347) Add cosmossdk.io/log/slog to allow using a standard library log/slog-backed logger.
27+
* [#22466](https://github.com/cosmos/cosmos-sdk/pull/22466) Disable coloring in testing logger.
28+
* [#22233](https://github.com/cosmos/cosmos-sdk/pull/22233) Use sonic json library for faster json handling.
29+
* [#22347](https://github.com/cosmos/cosmos-sdk/pull/22347) Add `cosmossdk.io/log/slog` to allow using a standard library log/slog-backed logger. This required to bump the minimum go version of `cosmossdk.io/log` to 1.21.
2930

3031
## [v1.4.1](https://github.com/cosmos/cosmos-sdk/releases/tag/log/v1.4.1) - 2024-08-16
3132

log/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module cosmossdk.io/log
22

3-
go 1.20
3+
go 1.21
44

55
require (
66
github.com/bytedance/sonic v1.12.3

log/testing.go

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
package log
22

3-
import "github.com/rs/zerolog"
3+
import (
4+
"time"
5+
6+
"github.com/rs/zerolog"
7+
)
48

59
// TestingT is the interface required for logging in tests.
610
// It is a subset of testing.T to avoid a direct dependency on the testing package.
@@ -39,15 +43,18 @@ func NewTestLoggerError(t TestingT) Logger {
3943
}
4044

4145
func newTestLogger(t TestingT, lvl zerolog.Level) Logger {
42-
cw := zerolog.NewConsoleWriter()
43-
cw.Out = zerolog.TestWriter{
44-
T: t,
45-
// Normally one would use zerolog.ConsoleTestWriter
46-
// to set the option on NewConsoleWriter,
47-
// but the zerolog source for that is hardcoded to Frame=6.
48-
// With Frame=6, all source locations are printed as "logger.go",
49-
// but Frame=7 prints correct source locations.
50-
Frame: 7,
46+
cw := zerolog.ConsoleWriter{
47+
NoColor: true,
48+
TimeFormat: time.Kitchen,
49+
Out: zerolog.TestWriter{
50+
T: t,
51+
// Normally one would use zerolog.ConsoleTestWriter
52+
// to set the option on NewConsoleWriter,
53+
// but the zerolog source for that is hardcoded to Frame=6.
54+
// With Frame=6, all source locations are printed as "logger.go",
55+
// but Frame=7 prints correct source locations.
56+
Frame: 7,
57+
},
5158
}
5259
return NewCustomLogger(zerolog.New(cw).Level(lvl))
5360
}

runtime/v2/go.mod

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ go 1.23
55
// server v2 integration
66
replace (
77
cosmossdk.io/api => ../../api
8+
cosmossdk.io/core/testing => ../../core/testing
89
cosmossdk.io/server/v2/appmanager => ../../server/v2/appmanager
910
cosmossdk.io/server/v2/stf => ../../server/v2/stf
1011
cosmossdk.io/store/v2 => ../../store/v2
@@ -30,7 +31,7 @@ require (
3031
require (
3132
buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1 // indirect
3233
buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1 // indirect
33-
cosmossdk.io/core/testing v0.0.0-20240923163230-04da382a9f29 // indirect
34+
cosmossdk.io/core/testing v0.0.0 // indirect
3435
cosmossdk.io/errors/v2 v2.0.0-20240731132947-df72853b3ca5 // indirect
3536
github.com/DataDog/zstd v1.5.5 // indirect
3637
github.com/beorn7/perks v1.0.1 // indirect

runtime/v2/go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88e
44
buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1/go.mod h1:zqi/LZjZhyvjCMTEVIwAf5VRlkLduuCfqmZxgoormq0=
55
cosmossdk.io/core v1.0.0-alpha.5 h1:McjYXAQ6XcT20v2uHyH7PhoWH8V+mebzfVFqT3GinsI=
66
cosmossdk.io/core v1.0.0-alpha.5/go.mod h1:3u9cWq1FAVtiiCrDPpo4LhR+9V6k/ycSG4/Y/tREWCY=
7-
cosmossdk.io/core/testing v0.0.0-20240923163230-04da382a9f29 h1:NxxUo0GMJUbIuVg0R70e3cbn9eFTEuMr7ev1AFvypdY=
8-
cosmossdk.io/core/testing v0.0.0-20240923163230-04da382a9f29/go.mod h1:8s2tPeJtSiQuoyPmr2Ag7meikonISO4Fv4MoO8+ORrs=
97
cosmossdk.io/depinject v1.1.0 h1:wLan7LG35VM7Yo6ov0jId3RHWCGRhe8E8bsuARorl5E=
108
cosmossdk.io/depinject v1.1.0/go.mod h1:kkI5H9jCGHeKeYWXTqYdruogYrEeWvBQCw1Pj4/eCFI=
119
cosmossdk.io/errors/v2 v2.0.0-20240731132947-df72853b3ca5 h1:IQNdY2kB+k+1OM2DvqFG1+UgeU1JzZrWtwuWzI3ZfwA=

server/v2/cometbft/go.mod

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ go 1.23.1
44

55
replace (
66
cosmossdk.io/api => ../../../api
7+
cosmossdk.io/core/testing => ../../../core/testing
78
cosmossdk.io/server/v2 => ../
89
cosmossdk.io/server/v2/appmanager => ../appmanager
910
cosmossdk.io/server/v2/stf => ../stf
@@ -43,7 +44,7 @@ require (
4344
require (
4445
buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1 // indirect
4546
buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1 // indirect
46-
cosmossdk.io/core/testing v0.0.0-20240923163230-04da382a9f29 // indirect
47+
cosmossdk.io/core/testing v0.0.0 // indirect
4748
cosmossdk.io/depinject v1.1.0 // indirect
4849
cosmossdk.io/errors v1.0.1 // indirect
4950
cosmossdk.io/math v1.3.0 // indirect

server/v2/cometbft/go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s=
88
cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0=
99
cosmossdk.io/core v1.0.0-alpha.5 h1:McjYXAQ6XcT20v2uHyH7PhoWH8V+mebzfVFqT3GinsI=
1010
cosmossdk.io/core v1.0.0-alpha.5/go.mod h1:3u9cWq1FAVtiiCrDPpo4LhR+9V6k/ycSG4/Y/tREWCY=
11-
cosmossdk.io/core/testing v0.0.0-20240923163230-04da382a9f29 h1:NxxUo0GMJUbIuVg0R70e3cbn9eFTEuMr7ev1AFvypdY=
12-
cosmossdk.io/core/testing v0.0.0-20240923163230-04da382a9f29/go.mod h1:8s2tPeJtSiQuoyPmr2Ag7meikonISO4Fv4MoO8+ORrs=
1311
cosmossdk.io/depinject v1.1.0 h1:wLan7LG35VM7Yo6ov0jId3RHWCGRhe8E8bsuARorl5E=
1412
cosmossdk.io/depinject v1.1.0/go.mod h1:kkI5H9jCGHeKeYWXTqYdruogYrEeWvBQCw1Pj4/eCFI=
1513
cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0=

server/v2/stf/branch/bench_test.go

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
package branch
2+
3+
import (
4+
"fmt"
5+
"testing"
6+
7+
"cosmossdk.io/core/store"
8+
coretesting "cosmossdk.io/core/testing"
9+
)
10+
11+
var (
12+
stackSizes = []int{1, 10, 100}
13+
elemsInStack = 10
14+
)
15+
16+
func Benchmark_CacheStack_Set(b *testing.B) {
17+
for _, stackSize := range stackSizes {
18+
b.Run(fmt.Sprintf("StackSize%d", stackSize), func(b *testing.B) {
19+
bs := makeBranchStack(b, stackSize)
20+
b.ResetTimer()
21+
b.ReportAllocs()
22+
for i := 0; i < b.N; i++ {
23+
_ = bs.Set([]byte{0}, []byte{0})
24+
}
25+
})
26+
}
27+
}
28+
29+
func Benchmark_Get(b *testing.B) {
30+
for _, stackSize := range stackSizes {
31+
b.Run(fmt.Sprintf("StackSize%d", stackSize), func(b *testing.B) {
32+
bs := makeBranchStack(b, stackSize)
33+
b.ResetTimer()
34+
b.ReportAllocs()
35+
for i := 0; i < b.N; i++ {
36+
_, _ = bs.Get([]byte{0})
37+
}
38+
})
39+
}
40+
}
41+
42+
func Benchmark_Iterate(b *testing.B) {
43+
var keySink, valueSink any
44+
45+
for _, stackSize := range stackSizes {
46+
b.Run(fmt.Sprintf("StackSize%d", stackSize), func(b *testing.B) {
47+
bs := makeBranchStack(b, stackSize)
48+
b.ResetTimer()
49+
b.ReportAllocs()
50+
for i := 0; i < b.N; i++ {
51+
iter, _ := bs.Iterator(nil, nil)
52+
for iter.Valid() {
53+
keySink = iter.Key()
54+
valueSink = iter.Value()
55+
iter.Next()
56+
}
57+
_ = iter.Close()
58+
}
59+
})
60+
}
61+
62+
_ = keySink
63+
_ = valueSink
64+
}
65+
66+
// makeBranchStack creates a branch stack of the given size and initializes it with unique key-value pairs.
67+
func makeBranchStack(b *testing.B, stackSize int) Store[store.KVStore] {
68+
parent := coretesting.NewMemKV()
69+
branch := NewStore[store.KVStore](parent)
70+
for i := 1; i < stackSize; i++ {
71+
branch = NewStore[store.KVStore](branch)
72+
for j := 0; j < elemsInStack; j++ {
73+
// create unique keys by including the branch index.
74+
key := []byte{byte(i), byte(j)}
75+
value := []byte{byte(j)}
76+
err := branch.Set(key, value)
77+
if err != nil {
78+
b.Fatal(err)
79+
}
80+
}
81+
}
82+
return branch
83+
}

server/v2/stf/branch/changeset.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const (
1515

1616
var errKeyEmpty = errors.New("key cannot be empty")
1717

18-
// changeSet implements the sorted cache for cachekv store,
18+
// changeSet implements the sorted tree for cachekv store,
1919
// we don't use MemDB here because cachekv is used extensively in sdk core path,
2020
// we need it to be as fast as possible, while `MemDB` is mainly used as a mocking db in unit tests.
2121
//

0 commit comments

Comments
 (0)