Skip to content

Commit f927e9b

Browse files
ci: actually enable v2 system test (#21539)
Co-authored-by: Matt Kocubinski <[email protected]>
1 parent 13f1d6c commit f927e9b

File tree

18 files changed

+48
-84
lines changed

18 files changed

+48
-84
lines changed

.github/workflows/test.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ jobs:
145145
path: ./tests/e2e-profile.out
146146

147147
test-system:
148-
needs: [tests, test-integration, test-e2e]
149148
runs-on: ubuntu-latest
150149
steps:
151150
- uses: actions/checkout@v4
@@ -177,7 +176,7 @@ jobs:
177176
- name: system tests v1
178177
if: env.GIT_DIFF
179178
run: |
180-
COSMOS_BUILD_OPTIONS=legacy make test-system
179+
make test-system
181180
- uses: actions/upload-artifact@v3
182181
if: failure()
183182
with:
@@ -187,7 +186,7 @@ jobs:
187186
- name: system tests v2
188187
if: env.GIT_DIFF
189188
run: |
190-
make test-system
189+
COSMOS_BUILD_OPTIONS=v2 make test-system
191190
- uses: actions/upload-artifact@v3
192191
if: failure()
193192
with:

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ include scripts/build/build.mk
1010

1111
.DEFAULT_GOAL := help
1212

13-
#? go.sum: Run go mod tidy and ensure dependencies have not been modified
13+
#? go.sum: Run go mod tidy and ensure dependencies have not been modified.
1414
go.sum: go.mod
1515
echo "Ensure dependencies have not been modified ..." >&2
1616
go mod verify

client/grpc/cmtservice/status_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
)
1515

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

1919
cfg, err := network.DefaultConfigWithAppConfig(depinject.Configs() /* TODO, test skipped anyway */)
2020
require.NoError(t, err)

client/v2/autocli/query_test.go

-2
Original file line numberDiff line numberDiff line change
@@ -575,8 +575,6 @@ func TestBinaryFlag(t *testing.T) {
575575
}
576576

577577
func TestAddressValidation(t *testing.T) {
578-
t.Skip() // TODO(@julienrbrt) re-able with better keyring instiantiation
579-
580578
fixture := initFixture(t)
581579

582580
_, err := runCmd(fixture, buildModuleQueryCommand,

core/server/app.go

-4
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,6 @@ type TxResult struct {
3939
Resp []transaction.Msg
4040
// Error produced by the transaction.
4141
Error error
42-
// Code produced by the transaction.
43-
// A non-zero code is an error that is either define by the module via the cosmossdk.io/errors/v2 package
44-
// or injected through the antehandler along the execution of the transaction.
45-
Code uint32
4642
// GasWanted is the maximum units of work we allow this tx to perform.
4743
GasWanted uint64
4844
// GasUsed is the amount of gas actually consumed.

scripts/local-testnet.sh

-17
This file was deleted.

server/v2/cometbft/abci.go

+14-10
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
"cosmossdk.io/core/server"
1818
"cosmossdk.io/core/store"
1919
"cosmossdk.io/core/transaction"
20-
errorsmod "cosmossdk.io/errors"
20+
errorsmod "cosmossdk.io/errors/v2"
2121
"cosmossdk.io/log"
2222
"cosmossdk.io/server/v2/appmanager"
2323
"cosmossdk.io/server/v2/cometbft/client/grpc/cmtservice"
@@ -122,7 +122,8 @@ func (c *Consensus[T]) CheckTx(ctx context.Context, req *abciproto.CheckTxReques
122122
}
123123

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

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

134135
cometResp := &abciproto.CheckTxResponse{
135-
Code: resp.Code,
136+
Code: 0,
136137
GasWanted: uint64ToInt64(resp.GasWanted),
137138
GasUsed: uint64ToInt64(resp.GasUsed),
138139
Events: events,
139140
}
140141
if resp.Error != nil {
141-
cometResp.Code = 1
142-
cometResp.Log = resp.Error.Error()
142+
space, code, log := errorsmod.ABCIInfo(resp.Error, c.cfg.AppTomlConfig.Trace)
143+
cometResp.Code = code
144+
cometResp.Codespace = space
145+
cometResp.Log = log
143146
}
147+
144148
return cometResp, nil
145149
}
146150

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

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

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

@@ -485,7 +489,7 @@ func (c *Consensus[T]) FinalizeBlock(
485489
return nil, err
486490
}
487491

488-
return finalizeBlockResponse(resp, cp, appHash, c.indexedEvents)
492+
return finalizeBlockResponse(resp, cp, appHash, c.indexedEvents, c.cfg.AppTomlConfig.Trace)
489493
}
490494

491495
// Commit implements types.Application.

server/v2/cometbft/commands.go

+6-8
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,13 @@ func ShowValidatorCmd() *cobra.Command {
106106
return err
107107
}
108108

109-
cmd.Println(sdkPK) // TODO: figure out if we need the codec here or not, see below
110-
111-
// clientCtx := client.GetClientContextFromCmd(cmd)
112-
// bz, err := clientCtx.Codec.MarshalInterfaceJSON(sdkPK)
113-
// if err != nil {
114-
// return err
115-
// }
109+
clientCtx := client.GetClientContextFromCmd(cmd)
110+
bz, err := clientCtx.Codec.MarshalInterfaceJSON(sdkPK)
111+
if err != nil {
112+
return err
113+
}
116114

117-
// cmd.Println(string(bz))
115+
cmd.Println(string(bz))
118116
return nil
119117
},
120118
}

server/v2/cometbft/go.mod

+3-2
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 => ../../../core
78
cosmossdk.io/server/v2 => ../
89
cosmossdk.io/server/v2/appmanager => ../appmanager
910
cosmossdk.io/server/v2/stf => ../stf
@@ -19,7 +20,7 @@ replace (
1920
require (
2021
cosmossdk.io/api v0.7.6
2122
cosmossdk.io/core v1.0.0-alpha.3
22-
cosmossdk.io/errors v1.0.1
23+
cosmossdk.io/errors/v2 v2.0.0-20240731132947-df72853b3ca5
2324
cosmossdk.io/log v1.4.1
2425
cosmossdk.io/server/v2 v2.0.0-00010101000000-000000000000
2526
cosmossdk.io/server/v2/appmanager v0.0.0-20240802110823-cffeedff643d
@@ -43,7 +44,7 @@ require (
4344
cosmossdk.io/collections v0.4.0 // indirect
4445
cosmossdk.io/core/testing v0.0.0-20240923163230-04da382a9f29 // indirect
4546
cosmossdk.io/depinject v1.0.0 // indirect
46-
cosmossdk.io/errors/v2 v2.0.0-20240731132947-df72853b3ca5 // indirect
47+
cosmossdk.io/errors v1.0.1 // indirect
4748
cosmossdk.io/math v1.3.0 // indirect
4849
cosmossdk.io/schema v0.3.0 // indirect
4950
cosmossdk.io/store v1.1.1-0.20240418092142-896cdf1971bc // indirect

server/v2/cometbft/go.sum

-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT
66
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
77
cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s=
88
cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0=
9-
cosmossdk.io/core v1.0.0-alpha.3 h1:pnxaYAas7llXgVz1lM7X6De74nWrhNKnB3yMKe4OUUA=
10-
cosmossdk.io/core v1.0.0-alpha.3/go.mod h1:3u9cWq1FAVtiiCrDPpo4LhR+9V6k/ycSG4/Y/tREWCY=
119
cosmossdk.io/core/testing v0.0.0-20240923163230-04da382a9f29 h1:NxxUo0GMJUbIuVg0R70e3cbn9eFTEuMr7ev1AFvypdY=
1210
cosmossdk.io/core/testing v0.0.0-20240923163230-04da382a9f29/go.mod h1:8s2tPeJtSiQuoyPmr2Ag7meikonISO4Fv4MoO8+ORrs=
1311
cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050=

server/v2/cometbft/query.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
abci "github.com/cometbft/cometbft/api/cometbft/abci/v1"
88
crypto "github.com/cometbft/cometbft/api/cometbft/crypto/v1"
99

10-
errorsmod "cosmossdk.io/errors"
10+
errorsmod "cosmossdk.io/errors/v2"
1111
"cosmossdk.io/server/v2/cometbft/types"
1212
cometerrors "cosmossdk.io/server/v2/cometbft/types/errors"
1313
)

server/v2/cometbft/streaming.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"cosmossdk.io/core/event"
77
"cosmossdk.io/core/server"
88
"cosmossdk.io/core/store"
9+
errorsmod "cosmossdk.io/errors/v2"
910
"cosmossdk.io/server/v2/streaming"
1011
)
1112

@@ -21,12 +22,17 @@ func (c *Consensus[T]) streamDeliverBlockChanges(
2122
// convert txresults to streaming txresults
2223
streamingTxResults := make([]*streaming.ExecTxResult, len(txResults))
2324
for i, txResult := range txResults {
25+
space, code, log := errorsmod.ABCIInfo(txResult.Error, c.cfg.AppTomlConfig.Trace)
26+
2427
events, err := streaming.IntoStreamingEvents(txResult.Events)
2528
if err != nil {
2629
return err
2730
}
31+
2832
streamingTxResults[i] = &streaming.ExecTxResult{
29-
Code: txResult.Code,
33+
Code: code,
34+
Codespace: space,
35+
Log: log,
3036
GasWanted: uint64ToInt64(txResult.GasWanted),
3137
GasUsed: uint64ToInt64(txResult.GasUsed),
3238
Events: events,

server/v2/cometbft/types/errors/errors.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package errors
22

33
import (
4-
errorsmod "cosmossdk.io/errors"
4+
errorsmod "cosmossdk.io/errors/v2"
55
)
66

77
// RootCodespace is the codespace for all errors defined in this package

server/v2/cometbft/utils.go

+8-27
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
"cosmossdk.io/core/event"
1919
"cosmossdk.io/core/server"
2020
"cosmossdk.io/core/transaction"
21-
errorsmod "cosmossdk.io/errors"
21+
errorsmod "cosmossdk.io/errors/v2"
2222
consensus "cosmossdk.io/x/consensus/types"
2323

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

@@ -78,7 +79,7 @@ func finalizeBlockResponse(
7879
return nil, err
7980
}
8081

81-
txResults, err := intoABCITxResults(in.TxResults, indexSet)
82+
txResults, err := intoABCITxResults(in.TxResults, indexSet, debug)
8283
if err != nil {
8384
return nil, err
8485
}
@@ -107,29 +108,20 @@ func intoABCIValidatorUpdates(updates []appmodulev2.ValidatorUpdate) []abci.Vali
107108
return valsetUpdates
108109
}
109110

110-
func intoABCITxResults(results []server.TxResult, indexSet map[string]struct{}) ([]*abci.ExecTxResult, error) {
111+
func intoABCITxResults(results []server.TxResult, indexSet map[string]struct{}, debug bool) ([]*abci.ExecTxResult, error) {
111112
res := make([]*abci.ExecTxResult, len(results))
112113
for i := range results {
113-
if results[i].Error != nil {
114-
space, code, log := errorsmod.ABCIInfo(results[i].Error, true)
115-
res[i] = &abci.ExecTxResult{
116-
Codespace: space,
117-
Code: code,
118-
Log: log,
119-
}
120-
121-
continue
122-
}
123114
events, err := intoABCIEvents(results[i].Events, indexSet)
124115
if err != nil {
125116
return nil, err
126117
}
118+
127119
res[i] = responseExecTxResultWithEvents(
128120
results[i].Error,
129121
results[i].GasWanted,
130122
results[i].GasUsed,
131123
events,
132-
false,
124+
debug,
133125
)
134126
}
135127

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

393-
case c.cfg.AppTomlConfig.HaltTime > 0 && time.Unix() > int64(c.cfg.AppTomlConfig.HaltTime):
385+
case c.cfg.AppTomlConfig.HaltTime > 0 && time.Unix() >= int64(c.cfg.AppTomlConfig.HaltTime):
394386
halt = true
395387
}
396388

@@ -408,14 +400,3 @@ func uint64ToInt64(u uint64) int64 {
408400
}
409401
return int64(u)
410402
}
411-
412-
// queryResult returns a ResponseQuery from an error. It will try to parse ABCI
413-
// info from the error.
414-
func queryResult(err error) *abci.QueryResponse {
415-
space, code, log := errorsmod.ABCIInfo(err, false)
416-
return &abci.QueryResponse{
417-
Codespace: space,
418-
Code: code,
419-
Log: log,
420-
}
421-
}

server/v2/stf/stf.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ func (s STF[T]) runTxMsgs(
320320
execCtx.sender = txSenders[i]
321321
resp, err := s.msgRouter.Invoke(execCtx, msg)
322322
if err != nil {
323-
return nil, 0, nil, fmt.Errorf("message execution at index %d failed: %w", i, err)
323+
return nil, 0, nil, err // do not wrap the error or we lose the original error type
324324
}
325325
msgResps[i] = resp
326326
}

tests/systemtests/testnet_init.go

-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@ func (s ModifyConfigYamlInitializer) Initialize() {
162162
EditToml(filepath.Join(nodeDir, "app.toml"), func(doc *tomledit.Document) {
163163
UpdatePort(doc, apiPortStart+i, "api", "address")
164164
UpdatePort(doc, grpcPortStart+i, "grpc", "address")
165-
SetBool(doc, true, "grpc-web", "enable")
166165
})
167166
}
168167
}

tests/systemtests/unordered_tx_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ import (
1212
)
1313

1414
func TestUnorderedTXDuplicate(t *testing.T) {
15-
t.Skip("The unordered tx antehanlder is missing in v2")
15+
t.Skip("The unordered tx handling is not wired in v2")
16+
1617
// scenario: test unordered tx duplicate
1718
// given a running chain with a tx in the unordered tx pool
1819
// when a new tx with the same hash is broadcasted

x/auth/ante/basic_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ func TestValidateMemo(t *testing.T) {
9999
}
100100

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

104104
suite := SetupTestSuite(t, true)
105105

0 commit comments

Comments
 (0)