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]>
  • Loading branch information
julienrbrt and kocubinski authored Sep 26, 2024
1 parent 13f1d6c commit f927e9b
Show file tree
Hide file tree
Showing 18 changed files with 48 additions and 84 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
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
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
35 changes: 8 additions & 27 deletions server/v2/cometbft/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"cosmossdk.io/core/event"
"cosmossdk.io/core/server"
"cosmossdk.io/core/transaction"
errorsmod "cosmossdk.io/errors"
errorsmod "cosmossdk.io/errors/v2"
consensus "cosmossdk.io/x/consensus/types"

sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down Expand Up @@ -70,6 +70,7 @@ func finalizeBlockResponse(
cp *cmtproto.ConsensusParams,
appHash []byte,
indexSet map[string]struct{},
debug bool,
) (*abci.FinalizeBlockResponse, error) {
allEvents := append(in.BeginBlockEvents, in.EndBlockEvents...)

Expand All @@ -78,7 +79,7 @@ func finalizeBlockResponse(
return nil, err
}

txResults, err := intoABCITxResults(in.TxResults, indexSet)
txResults, err := intoABCITxResults(in.TxResults, indexSet, debug)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -107,29 +108,20 @@ func intoABCIValidatorUpdates(updates []appmodulev2.ValidatorUpdate) []abci.Vali
return valsetUpdates
}

func intoABCITxResults(results []server.TxResult, indexSet map[string]struct{}) ([]*abci.ExecTxResult, error) {
func intoABCITxResults(results []server.TxResult, indexSet map[string]struct{}, debug bool) ([]*abci.ExecTxResult, error) {
res := make([]*abci.ExecTxResult, len(results))
for i := range results {
if results[i].Error != nil {
space, code, log := errorsmod.ABCIInfo(results[i].Error, true)
res[i] = &abci.ExecTxResult{
Codespace: space,
Code: code,
Log: log,
}

continue
}
events, err := intoABCIEvents(results[i].Events, indexSet)
if err != nil {
return nil, err
}

res[i] = responseExecTxResultWithEvents(
results[i].Error,
results[i].GasWanted,
results[i].GasUsed,
events,
false,
debug,
)
}

Expand Down Expand Up @@ -387,10 +379,10 @@ func (c *Consensus[T]) GetBlockRetentionHeight(cp *cmtproto.ConsensusParams, com
func (c *Consensus[T]) checkHalt(height int64, time time.Time) error {
var halt bool
switch {
case c.cfg.AppTomlConfig.HaltHeight > 0 && uint64(height) > c.cfg.AppTomlConfig.HaltHeight:
case c.cfg.AppTomlConfig.HaltHeight > 0 && uint64(height) >= c.cfg.AppTomlConfig.HaltHeight:
halt = true

case c.cfg.AppTomlConfig.HaltTime > 0 && time.Unix() > int64(c.cfg.AppTomlConfig.HaltTime):
case c.cfg.AppTomlConfig.HaltTime > 0 && time.Unix() >= int64(c.cfg.AppTomlConfig.HaltTime):
halt = true
}

Expand All @@ -408,14 +400,3 @@ func uint64ToInt64(u uint64) int64 {
}
return int64(u)
}

// queryResult returns a ResponseQuery from an error. It will try to parse ABCI
// info from the error.
func queryResult(err error) *abci.QueryResponse {
space, code, log := errorsmod.ABCIInfo(err, false)
return &abci.QueryResponse{
Codespace: space,
Code: code,
Log: log,
}
}
2 changes: 1 addition & 1 deletion server/v2/stf/stf.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ func (s STF[T]) runTxMsgs(
execCtx.sender = txSenders[i]
resp, err := s.msgRouter.Invoke(execCtx, msg)
if err != nil {
return nil, 0, nil, fmt.Errorf("message execution at index %d failed: %w", i, err)
return nil, 0, nil, err // do not wrap the error or we lose the original error type
}
msgResps[i] = resp
}
Expand Down
1 change: 0 additions & 1 deletion tests/systemtests/testnet_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ func (s ModifyConfigYamlInitializer) Initialize() {
EditToml(filepath.Join(nodeDir, "app.toml"), func(doc *tomledit.Document) {
UpdatePort(doc, apiPortStart+i, "api", "address")
UpdatePort(doc, grpcPortStart+i, "grpc", "address")
SetBool(doc, true, "grpc-web", "enable")
})
}
}
Expand Down
3 changes: 2 additions & 1 deletion tests/systemtests/unordered_tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import (
)

func TestUnorderedTXDuplicate(t *testing.T) {
t.Skip("The unordered tx antehanlder is missing in v2")
t.Skip("The unordered tx handling is not wired in v2")

// scenario: test unordered tx duplicate
// given a running chain with a tx in the unordered tx pool
// when a new tx with the same hash is broadcasted
Expand Down
2 changes: 1 addition & 1 deletion x/auth/ante/basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func TestValidateMemo(t *testing.T) {
}

func TestConsumeGasForTxSize(t *testing.T) {
t.Skip() // TODO(@julienrbrt) Fix after https://github.com/cosmos/cosmos-sdk/pull/20072
t.Skip() // TO FIX BEFORE 0.52 FINAL.

suite := SetupTestSuite(t, true)

Expand Down

0 comments on commit f927e9b

Please sign in to comment.