Skip to content

Commit

Permalink
Merge branch 'main' into unsafe.String
Browse files Browse the repository at this point in the history
  • Loading branch information
cuiweixie authored Sep 1, 2024
2 parents 1ce5b1d + f79b380 commit c7c2d19
Show file tree
Hide file tree
Showing 226 changed files with 3,549 additions and 2,274 deletions.
69 changes: 66 additions & 3 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,75 @@

# NOTE: Order is important; the last matching pattern takes the most precedence

# Primary repo maintainers
# Cosmos SDK Codeowners

* @cosmos/sdk-core-dev
# Core team as default owners

# CODEOWNERS for docs configuration
* @cosmos/sdk-core-dev

# Components

/baseapp/ @facundomedica @aaronc @testinginprod @kocubinski @cosmos/sdk-core-dev
/client/ @julienrbrt @JulianToledano @cosmos/sdk-core-dev
/client/v2/ @julienrbrt @JulianToledano @cosmos/sdk-core-dev
/collections/ @testinginprod @facundomedica @cosmos/sdk-core-dev
/core/ @cosmos/sdk-core-dev
/crypto/ @JulianToledano @raynaudoe @cosmos/sdk-core-dev
/depinject/ @aaronc @kocubinski @julienrbrt @cosmos/sdk-core-dev
/indexer/ @aaronc @cool-develope @cosmos/sdk-core-dev
/log/ @julienrbrt @sontrinh16 @cosmos/sdk-core-dev
/math/ @testinginprod @alpe @cosmos/sdk-core-dev
/orm/ @aaronc @testinginprod @lucaslopezf @cosmos/sdk-core-dev
/runtime/ @julienrbrt @hieuvubk @cosmos/sdk-core-dev
/runtime/v2/ @julienrbrt @hieuvubk @cosmos/sdk-core-dev
/schema/ @aaronc @testinginprod @cosmos/sdk-core-dev
/server/ @cosmos/sdk-core-dev
/server/v2/ @julienrbrt @hieuvubk @cosmos/sdk-core-dev
/server/v2/stf/ @testinginprod @kocubinski @cosmos/sdk-core-dev
/server/v2/appmanager/ @testinginprod @facundomedica @cosmos/sdk-core-dev
/server/v2/cometbft/ @facundomedica @sontrinh16 @cosmos/sdk-core-dev
/simapp/ @facundomedica @julienrbrt @cosmos/sdk-core-dev
/simapp/v2/ @kocubinski @julienrbrt @cosmos/sdk-core-dev
/store/ @cool-develope @kocubinski @cosmos/sdk-core-dev
/store/v2/ @cool-develope @kocubinski @cosmos/sdk-core-dev
/types/mempool/ @kocubinski @cosmos/sdk-core-dev
/tools/hubl @julienrbrt @JulianToledano @cosmos/sdk-core-dev
/tools/cosmovisor @julienrbrt @facundomedica @cosmos/sdk-core-dev
/tools/confix @julienrbrt @akhilkumarpilli @cosmos/sdk-core-dev

# x modules

/x/accounts/ @testinginprod @sontrinh16 @cosmos/sdk-core-dev
/x/auth/ @facundomedica @testinginprod @aaronc @cosmos/sdk-core-dev
/x/authz/ @akhilkumarpilli @raynaudoe @cosmos/sdk-core-dev
/x/bank/ @julienrbrt @sontrinh16 @cosmos/sdk-core-dev
/x/circuit/ @kocubinski @akhilkumarpilli @raynaudoe @cosmos/sdk-core-dev
/x/consensus/ @testinginprod @raynaudoe @cosmos/sdk-core-dev
/x/distribution/ @alpe @JulianToledano @cosmos/sdk-core-dev
/x/epochs/ @alpe @facundomedica @cosmos/sdk-core-dev
/x/evidence/ @alpe @akhilkumarpilli @cosmos/sdk-core-dev
/x/feegrant/ @cool-develope @alpe @cosmos/sdk-core-dev
/x/genutil/ @kocubinski @hieuvubk @julienrbrt @cosmos/sdk-core-dev
/x/gov/ @julienrbrt @sontrinh16 @cosmos/sdk-core-dev
/x/group/ @kocubinski @akhilkumarpilli @cosmos/sdk-core-dev
/x/mint/ @lucaslopezf @facundomedica @cosmos/sdk-core-dev
/x/nft/ @alpe @lucaslopezf @cosmos/sdk-core-dev
/x/params/ @cosmos/sdk-core-dev # deprecated so whole team
/x/protocolpool/ @facundomedica @hieuvubk @alpe @cosmos/sdk-core-dev
/x/simulation/ @cosmos/sdk-core-dev # deprecated so whole team
/x/slashing/ @testinginprod @raynaudoe @lucaslopezf @cosmos/sdk-core-dev
/x/staking/ @facundomedica @testinginprod @JulianToledano @ziscky @cosmos/sdk-core-dev
/x/tx/ @kocubinski @testinginprod @aaronc @cosmos/sdk-core-dev
/x/upgrade/ @facundomedica @cool-develope @akhilkumarpilli @lucaslopezf @cosmos/sdk-core-dev

# go mods

**/go.mod @cosmos/sdk-core-dev
**/go.sum @cosmos/sdk-core-dev

# docs configuration

/docs/ @cosmos/sdk-core-dev
/docs/docusaurus.config.js @julienrbrt @tac0turtle
/docs/sidebars.js @julienrbrt @tac0turtle
/docs/pre.sh @julienrbrt @tac0turtle
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ jobs:
simdv2 start &
SIMD_PID=$!
cnt=0
while ! simdv2 query block --type=height 5; do
while ! simdv2 query comet block --type=height 5; do
cnt=$((cnt + 1))
if [ $cnt -gt 30 ]; then
kill -9 "$SIMD_PID"
Expand Down
99 changes: 98 additions & 1 deletion UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,104 @@ Additionally, thanks to the genesis simplification, as explained in [the genesis

##### GRPC-WEB

Grpc-web embedded client has been removed from the server. If you would like to use grpc-web, you can use the [envoy proxy](https://www.envoyproxy.io/docs/envoy/latest/start/start).
Grpc-web embedded client has been removed from the server. If you would like to use grpc-web, you can use the [envoy proxy](https://www.envoyproxy.io/docs/envoy/latest/start/start). Here's how to set it up:

<details>
<summary>Step by step guide</summary>

1. Install Envoy following the [official installation guide](https://www.envoyproxy.io/docs/envoy/latest/start/install).

2. Create an Envoy configuration file named `envoy.yaml` with the following content:

```yaml
static_resources:
listeners:
- name: listener_0
address:
socket_address: { address: 0.0.0.0, port_value: 8080 }
filter_chains:
- filters:
- name: envoy.filters.network.http_connection_manager
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
codec_type: auto
stat_prefix: ingress_http
route_config:
name: local_route
virtual_hosts:
- name: local_service
domains: ["*"]
routes:
- match: { prefix: "/" }
route:
cluster: grpc_service
timeout: 0s
max_stream_duration:
grpc_timeout_header_max: 0s
cors:
allow_origin_string_match:
- prefix: "*"
allow_methods: GET, PUT, DELETE, POST, OPTIONS
allow_headers: keep-alive,user-agent,cache-control,content-type,content-transfer-encoding,custom-header-1,x-accept-content-transfer-encoding,x-accept-response-streaming,x-user-agent,x-grpc-web,grpc-timeout
max_age: "1728000"
expose_headers: custom-header-1,grpc-status,grpc-message
http_filters:
- name: envoy.filters.http.grpc_web
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.grpc_web.v3.GrpcWeb
- name: envoy.filters.http.cors
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.cors.v3.Cors
- name: envoy.filters.http.router
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router
clusters:
- name: grpc_service
connect_timeout: 0.25s
type: logical_dns
http2_protocol_options: {}
lb_policy: round_robin
load_assignment:
cluster_name: cluster_0
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: 0.0.0.0
port_value: 9090
```

This configuration tells Envoy to listen on port 8080 and forward requests to your gRPC service on port 9090. Note that this configuration is a starting point and can be modified according to your specific needs and preferences. You may need to adjust ports, addresses, or add additional settings based on your particular setup and requirements.

3. Start your Cosmos SDK application, ensuring it's configured to serve gRPC on port 9090.

4. Start Envoy with the configuration file:

```bash
envoy -c envoy.yaml
```

5. If Envoy starts successfully, you should see output similar to this:

```bash
[2024-08-29 10:47:08.753][6281320][info][config] [source/common/listener_manager/listener_manager_impl.cc:930] all dependencies initialized. starting workers
[2024-08-29 10:47:08.754][6281320][info][main] [source/server/server.cc:978] starting main dispatch loop
```

This indicates that Envoy has started and is ready to proxy requests.

6. Update your client applications to connect to Envoy (http://localhost:8080 by default).

</details>

By following these steps, Envoy will handle the translation between gRPC-Web and gRPC, allowing your existing gRPC-Web clients to continue functioning without modifications to your Cosmos SDK application.

To test the setup, you can use a tool like [grpcurl](https://github.com/fullstorydev/grpcurl). For example:

```bash
grpcurl -plaintext localhost:8080 cosmos.base.tendermint.v1beta1.Service/GetLatestBlock
```

##### AnteHandlers

Expand Down
6 changes: 3 additions & 3 deletions api/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ require (
buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2
github.com/cosmos/cosmos-proto v1.0.0-beta.5
github.com/cosmos/gogoproto v1.7.0
google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157
google.golang.org/grpc v1.65.0
google.golang.org/genproto/googleapis/api v0.0.0-20240604185151-ef581f913117
google.golang.org/grpc v1.66.0
google.golang.org/protobuf v1.34.2
)

Expand All @@ -17,5 +17,5 @@ require (
golang.org/x/net v0.28.0 // indirect
golang.org/x/sys v0.24.0 // indirect
golang.org/x/text v0.17.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240808171019-573a1156607a // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240827150818-7e3bb234dfed // indirect
)
16 changes: 8 additions & 8 deletions api/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ github.com/cosmos/cosmos-proto v1.0.0-beta.5 h1:eNcayDLpip+zVLRLYafhzLvQlSmyab+R
github.com/cosmos/cosmos-proto v1.0.0-beta.5/go.mod h1:hQGLpiIUloJBMdQMMWb/4wRApmI9hjHH05nefC0Ojec=
github.com/cosmos/gogoproto v1.7.0 h1:79USr0oyXAbxg3rspGh/m4SWNyoz/GLaAh0QlCe2fro=
github.com/cosmos/gogoproto v1.7.0/go.mod h1:yWChEv5IUEYURQasfyBW5ffkMHR/90hiHgbNgrtp4j0=
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE=
Expand All @@ -16,11 +16,11 @@ golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg=
golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc=
golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157 h1:7whR9kGa5LUwFtpLm2ArCEejtnxlGeLbAyjFY8sGNFw=
google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157/go.mod h1:99sLkeliLXfdj2J75X3Ho+rrVCaJze0uwN7zDDkjPVU=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240808171019-573a1156607a h1:EKiZZXueP9/T68B8Nl0GAx9cjbQnCId0yP3qPMgaaHs=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240808171019-573a1156607a/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY=
google.golang.org/grpc v1.65.0 h1:bs/cUb4lp1G5iImFFd3u5ixQzweKizoZJAwBNLR42lc=
google.golang.org/grpc v1.65.0/go.mod h1:WgYC2ypjlB0EiQi6wdKixMqukr6lBc0Vo+oOgjrM5ZQ=
google.golang.org/genproto/googleapis/api v0.0.0-20240604185151-ef581f913117 h1:+rdxYoE3E5htTEWIe15GlN6IfvbURM//Jt0mmkmm6ZU=
google.golang.org/genproto/googleapis/api v0.0.0-20240604185151-ef581f913117/go.mod h1:OimBR/bc1wPO9iV4NC2bpyjy3VnAwZh5EBPQdtaE5oo=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240827150818-7e3bb234dfed h1:J6izYgfBXAI3xTKLgxzTmUltdYaLsuBxFCgDHWJ/eXg=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240827150818-7e3bb234dfed/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU=
google.golang.org/grpc v1.66.0 h1:DibZuoBznOxbDQxRINckZcUvnCEvrW9pcWIE2yF9r1c=
google.golang.org/grpc v1.66.0/go.mod h1:s3/l6xSSCURdVfAnL+TqCNMyTDAGN6+lZeVxnZR128Y=
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
8 changes: 4 additions & 4 deletions baseapp/baseapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import (
abci "github.com/cometbft/cometbft/api/cometbft/abci/v1"
cmtproto "github.com/cometbft/cometbft/api/cometbft/types/v1"
"github.com/cometbft/cometbft/crypto/tmhash"
dbm "github.com/cosmos/cosmos-db"
"github.com/cosmos/gogoproto/proto"
"google.golang.org/protobuf/reflect/protoreflect"

"cosmossdk.io/core/header"
corestore "cosmossdk.io/core/store"
errorsmod "cosmossdk.io/errors"
"cosmossdk.io/log"
"cosmossdk.io/store"
Expand Down Expand Up @@ -65,7 +65,7 @@ type BaseApp struct {
mu sync.Mutex // mu protects the fields below.
logger log.Logger
name string // application name from abci.BlockInfo
db dbm.DB // common DB backend
db corestore.KVStoreWithBatch // common DB backend
cms storetypes.CommitMultiStore // Main (uncached) state
qms storetypes.MultiStore // Optional alternative multistore for querying only.
storeLoader StoreLoader // function to handle store loading, may be overridden with SetStoreLoader()
Expand Down Expand Up @@ -194,7 +194,7 @@ type BaseApp struct {
// variadic number of option functions, which act on the BaseApp to set
// configuration choices.
func NewBaseApp(
name string, logger log.Logger, db dbm.DB, txDecoder sdk.TxDecoder, options ...func(*BaseApp),
name string, logger log.Logger, db corestore.KVStoreWithBatch, txDecoder sdk.TxDecoder, options ...func(*BaseApp),
) *BaseApp {
app := &BaseApp{
logger: logger.With(log.ModuleKey, "baseapp"),
Expand Down Expand Up @@ -711,7 +711,7 @@ func (app *BaseApp) cacheTxContext(ctx sdk.Context, txBytes []byte) (sdk.Context
func (app *BaseApp) preBlock(req *abci.FinalizeBlockRequest) ([]abci.Event, error) {
var events []abci.Event
if app.preBlocker != nil {
ctx := app.finalizeBlockState.Context()
ctx := app.finalizeBlockState.Context().WithEventManager(sdk.NewEventManager())
if err := app.preBlocker(ctx, req); err != nil {
return nil, err
}
Expand Down
5 changes: 3 additions & 2 deletions baseapp/baseapp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
dbm "github.com/cosmos/cosmos-db"
"github.com/stretchr/testify/require"

corestore "cosmossdk.io/core/store"
errorsmod "cosmossdk.io/errors"
"cosmossdk.io/log"
"cosmossdk.io/store/metrics"
Expand Down Expand Up @@ -296,7 +297,7 @@ func TestSetLoader(t *testing.T) {
app.SetStoreLoader(baseapp.DefaultStoreLoader)
}

initStore := func(t *testing.T, db dbm.DB, storeKey string, k, v []byte) {
initStore := func(t *testing.T, db corestore.KVStoreWithBatch, storeKey string, k, v []byte) {
t.Helper()
rs := rootmulti.NewStore(db, log.NewNopLogger(), metrics.NewNoOpMetrics())
rs.SetPruning(pruningtypes.NewPruningOptions(pruningtypes.PruningNothing))
Expand All @@ -317,7 +318,7 @@ func TestSetLoader(t *testing.T) {
require.Equal(t, int64(1), commitID.Version)
}

checkStore := func(t *testing.T, db dbm.DB, ver int64, storeKey string, k, v []byte) {
checkStore := func(t *testing.T, db corestore.KVStoreWithBatch, ver int64, storeKey string, k, v []byte) {
t.Helper()
rs := rootmulti.NewStore(db, log.NewNopLogger(), metrics.NewNoOpMetrics())
rs.SetPruning(pruningtypes.NewPruningOptions(pruningtypes.PruningDefault))
Expand Down
5 changes: 2 additions & 3 deletions baseapp/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import (
"io"
"math"

dbm "github.com/cosmos/cosmos-db"

corestore "cosmossdk.io/core/store"
"cosmossdk.io/store/metrics"
pruningtypes "cosmossdk.io/store/pruning/types"
"cosmossdk.io/store/snapshots"
Expand Down Expand Up @@ -178,7 +177,7 @@ func (app *BaseApp) SetAppVersion(ctx context.Context, v uint64) error {
return nil
}

func (app *BaseApp) SetDB(db dbm.DB) {
func (app *BaseApp) SetDB(db corestore.KVStoreWithBatch) {
if app.sealed {
panic("SetDB() on sealed BaseApp")
}
Expand Down
24 changes: 16 additions & 8 deletions baseapp/streaming.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,16 @@ func (p listenerWrapper) ListenFinalizeBlock(_ context.Context, req abci.Finaliz

func (p listenerWrapper) ListenCommit(ctx context.Context, res abci.CommitResponse, changeSet []*storetypes.StoreKVPair) error {
if cb := p.listener.OnKVPair; cb != nil {
updates := make([]appdata.ModuleKVPairUpdate, len(changeSet))
updates := make([]appdata.ActorKVPairUpdate, len(changeSet))
for i, pair := range changeSet {
updates[i] = appdata.ModuleKVPairUpdate{
ModuleName: pair.StoreKey,
Update: schema.KVPairUpdate{
Key: pair.Key,
Value: pair.Value,
Delete: pair.Delete,
updates[i] = appdata.ActorKVPairUpdate{
Actor: []byte(pair.StoreKey),
StateChanges: []schema.KVPairUpdate{
{
Key: pair.Key,
Value: pair.Value,
Remove: pair.Delete,
},
},
}
}
Expand All @@ -181,10 +183,16 @@ func (p listenerWrapper) ListenCommit(ctx context.Context, res abci.CommitRespon
}

if p.listener.Commit != nil {
err := p.listener.Commit(appdata.CommitData{})
commitCb, err := p.listener.Commit(appdata.CommitData{})
if err != nil {
return err
}
if commitCb != nil {
err := commitCb()
if err != nil {
return err
}
}
}

return nil
Expand Down
3 changes: 2 additions & 1 deletion client/pruning/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/spf13/cobra"
"github.com/spf13/viper"

corestore "cosmossdk.io/core/store"
"cosmossdk.io/log"
pruningtypes "cosmossdk.io/store/pruning/types"
"cosmossdk.io/store/rootmulti"
Expand Down Expand Up @@ -107,7 +108,7 @@ Supported app-db-backend types include 'goleveldb', 'rocksdb', 'pebbledb'.`,
return cmd
}

func openDB(rootDir string, backendType dbm.BackendType) (dbm.DB, error) {
func openDB(rootDir string, backendType dbm.BackendType) (corestore.KVStoreWithBatch, error) {
dataDir := filepath.Join(rootDir, "data")
return dbm.NewDB("application", backendType, dataDir)
}
Loading

0 comments on commit c7c2d19

Please sign in to comment.