Skip to content

Commit

Permalink
Merge branch 'main' into feat-#21726
Browse files Browse the repository at this point in the history
  • Loading branch information
Teyz authored Sep 26, 2024
2 parents 5c9aca0 + dc2cea5 commit 63272b1
Show file tree
Hide file tree
Showing 34 changed files with 156 additions and 170 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ jobs:
path: ./tests/e2e-profile.out

test-system:
needs: [tests, test-integration, test-e2e]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -177,7 +176,7 @@ jobs:
- name: system tests v1
if: env.GIT_DIFF
run: |
COSMOS_BUILD_OPTIONS=legacy make test-system
make test-system
- uses: actions/upload-artifact@v3
if: failure()
with:
Expand All @@ -187,7 +186,7 @@ jobs:
- name: system tests v2
if: env.GIT_DIFF
run: |
make test-system
COSMOS_BUILD_OPTIONS=v2 make test-system
- uses: actions/upload-artifact@v3
if: failure()
with:
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i
### Bug Fixes

* (sims) [21906](https://github.com/cosmos/cosmos-sdk/pull/21906) Skip sims test when running dry on validators
* (cli) [#21919](https://github.com/cosmos/cosmos-sdk/pull/21919) Query address-by-acc-num by account_id instead of id.

### API Breaking Changes

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ include scripts/build/build.mk

.DEFAULT_GOAL := help

#? go.sum: Run go mod tidy and ensure dependencies have not been modified
#? go.sum: Run go mod tidy and ensure dependencies have not been modified.
go.sum: go.mod
echo "Ensure dependencies have not been modified ..." >&2
go mod verify
Expand Down
2 changes: 1 addition & 1 deletion client/grpc/cmtservice/status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
)

func TestStatusCommand(t *testing.T) {
t.Skip() // https://github.com/cosmos/cosmos-sdk/issues/17446
t.Skip() // Rewrite as system test

cfg, err := network.DefaultConfigWithAppConfig(depinject.Configs() /* TODO, test skipped anyway */)
require.NoError(t, err)
Expand Down
4 changes: 4 additions & 0 deletions client/v2/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ Ref: https://keepachangelog.com/en/1.0.0/
* [#18626](https://github.com/cosmos/cosmos-sdk/pull/18626) Support for off-chain signing and verification of a file.
* [#18461](https://github.com/cosmos/cosmos-sdk/pull/18461) Support governance proposals.

### Improvements

* [#21936](https://github.com/cosmos/cosmos-sdk/pull/21936) Print possible enum values in error message after an invalid input was provided.

### API Breaking Changes

* [#17709](https://github.com/cosmos/cosmos-sdk/pull/17709) Address codecs have been removed from `autocli.AppOptions` and `flag.Builder`. Instead client/v2 uses the address codecs present in the context (introduced in [#17503](https://github.com/cosmos/cosmos-sdk/pull/17503)).
Expand Down
7 changes: 6 additions & 1 deletion client/v2/autocli/flag/enum.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,12 @@ func (e enumValue) String() string {
func (e *enumValue) Set(s string) error {
valDesc, ok := e.valMap[s]
if !ok {
return fmt.Errorf("%s is not a valid value for enum %s", s, e.enum.FullName())
var validValues []string
for k := range e.valMap {
validValues = append(validValues, k)
}

return fmt.Errorf("%s is not a valid value for enum %s. Valid values are: %s", s, e.enum.FullName(), strings.Join(validValues, ", "))
}
e.value = valDesc.Number()
return nil
Expand Down
4 changes: 3 additions & 1 deletion client/v2/autocli/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ func (b *Builder) AddMsgServiceCommands(cmd *cobra.Command, cmdDescriptor *autoc
return err
}

cmd.AddCommand(subCmd)
if !subCmdDescriptor.EnhanceCustomCommand {
cmd.AddCommand(subCmd)
}
}

if cmdDescriptor.Service == "" {
Expand Down
4 changes: 3 additions & 1 deletion client/v2/autocli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ func (b *Builder) AddQueryServiceCommands(cmd *cobra.Command, cmdDescriptor *aut
return err
}

cmd.AddCommand(subCmd)
if !subCmdDesc.EnhanceCustomCommand {
cmd.AddCommand(subCmd)
}
}

// skip empty command descriptors
Expand Down
2 changes: 0 additions & 2 deletions client/v2/autocli/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -575,8 +575,6 @@ func TestBinaryFlag(t *testing.T) {
}

func TestAddressValidation(t *testing.T) {
t.Skip() // TODO(@julienrbrt) re-able with better keyring instiantiation

fixture := initFixture(t)

_, err := runCmd(fixture, buildModuleQueryCommand,
Expand Down
4 changes: 0 additions & 4 deletions core/server/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ type TxResult struct {
Resp []transaction.Msg
// Error produced by the transaction.
Error error
// Code produced by the transaction.
// A non-zero code is an error that is either define by the module via the cosmossdk.io/errors/v2 package
// or injected through the antehandler along the execution of the transaction.
Code uint32
// GasWanted is the maximum units of work we allow this tx to perform.
GasWanted uint64
// GasUsed is the amount of gas actually consumed.
Expand Down
2 changes: 1 addition & 1 deletion docs/Introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Get familiar with the SDK and explore its main concepts.
* [**Core Concepts**](learn/advanced/00-baseapp.md) - Read about the core concepts like baseapp, the store, or the server.
* [**Building Modules**](build/building-modules/00-intro.md) - Discover how to build modules for the Cosmos SDK.
* [**Running a Node**](https://docs.cosmos.network/main/user/run-node/keyring) - Running and interacting with nodes using the CLI and API.
* [**Modules**](./build/modules/README.md) - Explore existing modules to build your application with.
* [**Modules**](./build/building-modules/00-intro.md) - Explore existing modules to build your application with.

## Explore the Stack

Expand Down
17 changes: 0 additions & 17 deletions scripts/local-testnet.sh

This file was deleted.

24 changes: 14 additions & 10 deletions server/v2/cometbft/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"cosmossdk.io/core/server"
"cosmossdk.io/core/store"
"cosmossdk.io/core/transaction"
errorsmod "cosmossdk.io/errors"
errorsmod "cosmossdk.io/errors/v2"
"cosmossdk.io/log"
"cosmossdk.io/server/v2/appmanager"
"cosmossdk.io/server/v2/cometbft/client/grpc/cmtservice"
Expand Down Expand Up @@ -122,7 +122,8 @@ func (c *Consensus[T]) CheckTx(ctx context.Context, req *abciproto.CheckTxReques
}

resp, err := c.app.ValidateTx(ctx, decodedTx)
if err != nil {
// we do not want to return a cometbft error, but a check tx response with the error
if err != nil && err != resp.Error {
return nil, err
}

Expand All @@ -132,15 +133,18 @@ func (c *Consensus[T]) CheckTx(ctx context.Context, req *abciproto.CheckTxReques
}

cometResp := &abciproto.CheckTxResponse{
Code: resp.Code,
Code: 0,
GasWanted: uint64ToInt64(resp.GasWanted),
GasUsed: uint64ToInt64(resp.GasUsed),
Events: events,
}
if resp.Error != nil {
cometResp.Code = 1
cometResp.Log = resp.Error.Error()
space, code, log := errorsmod.ABCIInfo(resp.Error, c.cfg.AppTomlConfig.Trace)
cometResp.Code = code
cometResp.Codespace = space
cometResp.Log = log
}

return cometResp, nil
}

Expand Down Expand Up @@ -196,7 +200,7 @@ func (c *Consensus[T]) Query(ctx context.Context, req *abciproto.QueryRequest) (
}
res, err := c.app.Query(ctx, uint64(req.Height), protoRequest)
if err != nil {
resp := queryResult(err)
resp := QueryResult(err, c.cfg.AppTomlConfig.Trace)
resp.Height = req.Height
return resp, err

Expand Down Expand Up @@ -283,10 +287,10 @@ func (c *Consensus[T]) InitChain(ctx context.Context, req *abciproto.InitChainRe
return nil, fmt.Errorf("genesis state init failure: %w", err)
}

// TODO necessary? where should this WARN live if it all. helpful for testing
for _, txRes := range blockresponse.TxResults {
if txRes.Error != nil {
c.logger.Warn("genesis tx failed", "code", txRes.Code, "error", txRes.Error)
if err := txRes.Error; err != nil {
space, code, log := errorsmod.ABCIInfo(err, c.cfg.AppTomlConfig.Trace)
c.logger.Warn("genesis tx failed", "codespace", space, "code", code, "log", log)
}
}

Expand Down Expand Up @@ -485,7 +489,7 @@ func (c *Consensus[T]) FinalizeBlock(
return nil, err
}

return finalizeBlockResponse(resp, cp, appHash, c.indexedEvents)
return finalizeBlockResponse(resp, cp, appHash, c.indexedEvents, c.cfg.AppTomlConfig.Trace)
}

// Commit implements types.Application.
Expand Down
14 changes: 6 additions & 8 deletions server/v2/cometbft/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,13 @@ func ShowValidatorCmd() *cobra.Command {
return err
}

cmd.Println(sdkPK) // TODO: figure out if we need the codec here or not, see below

// clientCtx := client.GetClientContextFromCmd(cmd)
// bz, err := clientCtx.Codec.MarshalInterfaceJSON(sdkPK)
// if err != nil {
// return err
// }
clientCtx := client.GetClientContextFromCmd(cmd)
bz, err := clientCtx.Codec.MarshalInterfaceJSON(sdkPK)
if err != nil {
return err
}

// cmd.Println(string(bz))
cmd.Println(string(bz))
return nil
},
}
Expand Down
5 changes: 3 additions & 2 deletions server/v2/cometbft/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.23.1

replace (
cosmossdk.io/api => ../../../api
cosmossdk.io/core => ../../../core
cosmossdk.io/server/v2 => ../
cosmossdk.io/server/v2/appmanager => ../appmanager
cosmossdk.io/server/v2/stf => ../stf
Expand All @@ -19,7 +20,7 @@ replace (
require (
cosmossdk.io/api v0.7.6
cosmossdk.io/core v1.0.0-alpha.3
cosmossdk.io/errors v1.0.1
cosmossdk.io/errors/v2 v2.0.0-20240731132947-df72853b3ca5
cosmossdk.io/log v1.4.1
cosmossdk.io/server/v2 v2.0.0-00010101000000-000000000000
cosmossdk.io/server/v2/appmanager v0.0.0-20240802110823-cffeedff643d
Expand All @@ -43,7 +44,7 @@ require (
cosmossdk.io/collections v0.4.0 // indirect
cosmossdk.io/core/testing v0.0.0-20240923163230-04da382a9f29 // indirect
cosmossdk.io/depinject v1.0.0 // indirect
cosmossdk.io/errors/v2 v2.0.0-20240731132947-df72853b3ca5 // indirect
cosmossdk.io/errors v1.0.1 // indirect
cosmossdk.io/math v1.3.0 // indirect
cosmossdk.io/schema v0.3.0 // indirect
cosmossdk.io/store v1.1.1-0.20240418092142-896cdf1971bc // indirect
Expand Down
2 changes: 0 additions & 2 deletions server/v2/cometbft/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s=
cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0=
cosmossdk.io/core v1.0.0-alpha.3 h1:pnxaYAas7llXgVz1lM7X6De74nWrhNKnB3yMKe4OUUA=
cosmossdk.io/core v1.0.0-alpha.3/go.mod h1:3u9cWq1FAVtiiCrDPpo4LhR+9V6k/ycSG4/Y/tREWCY=
cosmossdk.io/core/testing v0.0.0-20240923163230-04da382a9f29 h1:NxxUo0GMJUbIuVg0R70e3cbn9eFTEuMr7ev1AFvypdY=
cosmossdk.io/core/testing v0.0.0-20240923163230-04da382a9f29/go.mod h1:8s2tPeJtSiQuoyPmr2Ag7meikonISO4Fv4MoO8+ORrs=
cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050=
Expand Down
2 changes: 1 addition & 1 deletion server/v2/cometbft/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
abci "github.com/cometbft/cometbft/api/cometbft/abci/v1"
crypto "github.com/cometbft/cometbft/api/cometbft/crypto/v1"

errorsmod "cosmossdk.io/errors"
errorsmod "cosmossdk.io/errors/v2"
"cosmossdk.io/server/v2/cometbft/types"
cometerrors "cosmossdk.io/server/v2/cometbft/types/errors"
)
Expand Down
8 changes: 7 additions & 1 deletion server/v2/cometbft/streaming.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"cosmossdk.io/core/event"
"cosmossdk.io/core/server"
"cosmossdk.io/core/store"
errorsmod "cosmossdk.io/errors/v2"
"cosmossdk.io/server/v2/streaming"
)

Expand All @@ -21,12 +22,17 @@ func (c *Consensus[T]) streamDeliverBlockChanges(
// convert txresults to streaming txresults
streamingTxResults := make([]*streaming.ExecTxResult, len(txResults))
for i, txResult := range txResults {
space, code, log := errorsmod.ABCIInfo(txResult.Error, c.cfg.AppTomlConfig.Trace)

events, err := streaming.IntoStreamingEvents(txResult.Events)
if err != nil {
return err
}

streamingTxResults[i] = &streaming.ExecTxResult{
Code: txResult.Code,
Code: code,
Codespace: space,
Log: log,
GasWanted: uint64ToInt64(txResult.GasWanted),
GasUsed: uint64ToInt64(txResult.GasUsed),
Events: events,
Expand Down
2 changes: 1 addition & 1 deletion server/v2/cometbft/types/errors/errors.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package errors

import (
errorsmod "cosmossdk.io/errors"
errorsmod "cosmossdk.io/errors/v2"
)

// RootCodespace is the codespace for all errors defined in this package
Expand Down
Loading

0 comments on commit 63272b1

Please sign in to comment.