Skip to content

Commit

Permalink
ci: actually enable v2 system test (#21539)
Browse files Browse the repository at this point in the history
Co-authored-by: Matt Kocubinski <[email protected]>
(cherry picked from commit f927e9b)

# Conflicts:
#	core/server/app.go
#	server/v2/cometbft/go.mod
#	server/v2/cometbft/go.sum
#	server/v2/stf/stf.go
  • Loading branch information
julienrbrt authored and mergify[bot] committed Sep 26, 2024
1 parent 596a65c commit cee9de3
Show file tree
Hide file tree
Showing 18 changed files with 723 additions and 76 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
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
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
55 changes: 55 additions & 0 deletions core/server/app.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package server

import (
"context"
"time"

appmodulev2 "cosmossdk.io/core/appmodule/v2"
"cosmossdk.io/core/event"
"cosmossdk.io/core/transaction"
)

// BlockRequest defines the request structure for a block coming from consensus server to the state transition function.
type BlockRequest[T transaction.Tx] struct {
Height uint64
Time time.Time
Hash []byte
ChainId string
AppHash []byte
Txs []T

// IsGenesis indicates if this block is the first block of the chain.
IsGenesis bool
}

// BlockResponse defines the response structure for a block coming from the state transition function to consensus server.
type BlockResponse struct {
ValidatorUpdates []appmodulev2.ValidatorUpdate
PreBlockEvents []event.Event
BeginBlockEvents []event.Event
TxResults []TxResult
EndBlockEvents []event.Event
}

// TxResult defines the result of a transaction execution.
type TxResult struct {
// Events produced by the transaction.
Events []event.Event
// Response messages produced by the transaction.
Resp []transaction.Msg
// Error produced by the transaction.
Error error
// GasWanted is the maximum units of work we allow this tx to perform.
GasWanted uint64
// GasUsed is the amount of gas actually consumed.
GasUsed uint64
}

// VersionModifier defines the interface fulfilled by BaseApp
// which allows getting and setting its appVersion field. This
// in turn updates the consensus params that are sent to the
// consensus engine in EndBlock
type VersionModifier interface {
SetAppVersion(context.Context, uint64) error
AppVersion(context.Context) (uint64, error)
}
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
18 changes: 17 additions & 1 deletion server/v2/cometbft/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,38 @@ module cosmossdk.io/server/v2/cometbft
go 1.23.1

replace (
<<<<<<< HEAD
// pseudo version lower than the latest tag
cosmossdk.io/api => cosmossdk.io/api v0.7.3-0.20240924065902-eb7653cfecdf // main
// pseudo version lower than the latest tag
cosmossdk.io/core => cosmossdk.io/core v1.0.0-alpha.3 // main
// pseudo version lower than the latest tag
cosmossdk.io/store => cosmossdk.io/store v1.0.0-rc.0.0.20240913190136-3bc707a5a214 // main
=======
cosmossdk.io/api => ../../../api
cosmossdk.io/core => ../../../core
cosmossdk.io/server/v2 => ../
cosmossdk.io/server/v2/appmanager => ../appmanager
cosmossdk.io/server/v2/stf => ../stf
cosmossdk.io/store => ../../../store
cosmossdk.io/store/v2 => ../../../store/v2
>>>>>>> f927e9b55 (ci: actually enable v2 system test (#21539))
cosmossdk.io/x/bank => ../../../x/bank
cosmossdk.io/x/consensus => ../../../x/consensus
cosmossdk.io/x/staking => ../../../x/staking
github.com/cosmos/cosmos-sdk => ../../../
)

require (
<<<<<<< HEAD
cosmossdk.io/api v0.8.0
cosmossdk.io/core v1.0.0 // main
cosmossdk.io/errors v1.0.1
=======
cosmossdk.io/api v0.7.6
cosmossdk.io/core v1.0.0-alpha.3
cosmossdk.io/errors/v2 v2.0.0-20240731132947-df72853b3ca5
>>>>>>> f927e9b55 (ci: actually enable v2 system test (#21539))
cosmossdk.io/log v1.4.1
cosmossdk.io/server/v2 v2.0.0-20240920095614-aa90bb43d8f8 // main
cosmossdk.io/server/v2/appmanager v0.0.0-20240920095614-aa90bb43d8f8 // main
Expand All @@ -42,7 +58,7 @@ require (
cosmossdk.io/collections v0.4.1-0.20240802064046-23fac2f1b8ab // indirect
cosmossdk.io/core/testing v0.0.0-20240913164418-aaf72f20c10b // 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.20240909133312-50288938d1b6 // indirect
Expand Down
7 changes: 7 additions & 0 deletions server/v2/cometbft/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88e
buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2/go.mod h1:HqcXMSa5qnNuakaMUo+hWhF51mKbcrZxGl9Vp5EeJXc=
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
<<<<<<< HEAD
cosmossdk.io/api v0.7.3-0.20240924065902-eb7653cfecdf h1:CttA/mEIxGm4E7vwrjUpju7/Iespns08d9bOza70cIc=
cosmossdk.io/api v0.7.3-0.20240924065902-eb7653cfecdf/go.mod h1:YMfx2ATpgITsoydD3hIBa8IkDHtyXp/14rmG0d3sEew=
cosmossdk.io/collections v0.4.1-0.20240802064046-23fac2f1b8ab h1:E/IWad76v1Nc4Atswaccpt7twJ0VwHkbY94/PhmZfTo=
Expand All @@ -12,6 +13,12 @@ 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-20240913164418-aaf72f20c10b h1:uEMbr7Hdpz0fU+GXU6mSN2vgoQnr66WYUpRuiba2aEk=
cosmossdk.io/core/testing v0.0.0-20240913164418-aaf72f20c10b/go.mod h1:FllCSj/ZYskfb982HKqBSISO8DkBY4Euqq768HSFz68=
=======
cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s=
cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0=
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=
>>>>>>> f927e9b55 (ci: actually enable v2 system test (#21539))
cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050=
cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8=
cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0=
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 cee9de3

Please sign in to comment.