Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Refactor TxSearch #14758

Merged
merged 41 commits into from
Feb 24, 2023
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
ae3e190
updates
alexanderbez Jan 24, 2023
a47cfb7
updates
alexanderbez Jan 24, 2023
8df20c4
updates
alexanderbez Jan 24, 2023
82dc102
updates
alexanderbez Jan 25, 2023
f743d0b
updates
alexanderbez Jan 25, 2023
0df2abd
updates
alexanderbez Jan 25, 2023
20579ab
updates
alexanderbez Jan 25, 2023
3bdab1f
updates
alexanderbez Jan 25, 2023
756f722
updates
alexanderbez Jan 25, 2023
0afa78f
updates
alexanderbez Jan 25, 2023
97989b0
Merge branch 'main' into bez/14727-refactor-tx-search
alexanderbez Jan 25, 2023
bee3970
updates
alexanderbez Jan 25, 2023
a96463f
updates
alexanderbez Jan 26, 2023
a933e22
updates
alexanderbez Jan 26, 2023
62652ee
Merge branch 'main' into bez/14727-refactor-tx-search
alexanderbez Jan 26, 2023
ae2e900
Merge branch 'main' into bez/14727-refactor-tx-search
alexanderbez Jan 26, 2023
0f1025a
Merge branch 'main' into bez/14727-refactor-tx-search
tac0turtle Feb 20, 2023
76a2a03
fix merge
tac0turtle Feb 20, 2023
f938b7d
address comments
tac0turtle Feb 20, 2023
bcabf4b
Merge branch 'main' into bez/14727-refactor-tx-search
tac0turtle Feb 20, 2023
b88decb
revert internal flags
tac0turtle Feb 20, 2023
5ff6d30
delete extra lines
tac0turtle Feb 20, 2023
5c83612
Merge branch 'main' into bez/14727-refactor-tx-search
tac0turtle Feb 20, 2023
573fe32
Merge branch 'main' into bez/14727-refactor-tx-search
tac0turtle Feb 21, 2023
eb4de62
remove unneeded testcase
tac0turtle Feb 21, 2023
6c3c2d0
Merge branch 'main' into bez/14727-refactor-tx-search
tac0turtle Feb 21, 2023
7977997
Merge branch 'main' into bez/14727-refactor-tx-search
julienrbrt Feb 23, 2023
1b7d3b9
surface issue by remove cometbft replace
julienrbrt Feb 23, 2023
81c63c7
Merge branch 'main' into bez/14727-refactor-tx-search
alexanderbez Feb 23, 2023
2cab281
Merge branch 'main' into bez/14727-refactor-tx-search
alexanderbez Feb 23, 2023
3a6dc4d
updates
alexanderbez Feb 23, 2023
c08fdf0
Merge branch 'main' into bez/14727-refactor-tx-search
alexanderbez Feb 23, 2023
bf69105
updates
alexanderbez Feb 23, 2023
e86ea5e
Merge branch 'main' into bez/14727-refactor-tx-search
alexanderbez Feb 23, 2023
e4d15e6
Merge branch 'main' into bez/14727-refactor-tx-search
alexanderbez Feb 24, 2023
afbaf98
updates
julienrbrt Feb 24, 2023
ec5d9e1
Merge branch 'main' into bez/14727-refactor-tx-search
julienrbrt Feb 24, 2023
4187baf
updates
julienrbrt Feb 24, 2023
4180ed1
same pagination
julienrbrt Feb 24, 2023
7cdec41
updates
julienrbrt Feb 24, 2023
79a989a
Merge branch 'main' into bez/14727-refactor-tx-search
julienrbrt Feb 24, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (query) [#14468](https://github.com/cosmos/cosmos-sdk/pull/14468) Implement pagination for collections.
* (x/bank) [#14045](https://github.com/cosmos/cosmos-sdk/pull/14045) Add CLI command `spendable-balances`, which also accepts the flag `--denom`.
* (x/slashing, x/staking) [#14363](https://github.com/cosmos/cosmos-sdk/pull/14363) Add the infraction a validator commited type as an argument to a `SlashWithInfractionReason` keeper method.
* (client) [#13867](https://github.com/cosmos/cosmos-sdk/pull/13867/) Wire AutoCLI commands with SimApp.
* (x/distribution) [#14322](https://github.com/cosmos/cosmos-sdk/pull/14322) Introduce a new gRPC message handler, `DepositValidatorRewardsPool`, that allows explicit funding of a validator's reward pool.
* (x/evidence) [#13740](https://github.com/cosmos/cosmos-sdk/pull/13740) Add new proto field `hash` of type `string` to `QueryEvidenceRequest` which helps to decode the hash properly while using query API.
* (core) [#13306](https://github.com/cosmos/cosmos-sdk/pull/13306) Add a `FormatCoins` function to in `core/coins` to format sdk Coins following the Value Renderers spec.
Expand Down Expand Up @@ -79,6 +78,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

### Improvements

* (x/auth) [#14758](https://github.com/cosmos/cosmos-sdk/pull/14758) Allow transaction event queries to directly passed to Tendermint, which will allow for full query operator support, e.g. `>`.
* (cli) [#14659](https://github.com/cosmos/cosmos-sdk/pull/14659) Added ability to query blocks by either height/hash `simd q block --type=height|hash <height|hash>`.
* (store) [#14410](https://github.com/cosmos/cosmos-sdk/pull/14410) `rootmulti.Store.loadVersion` has validation to check if all the module stores' height is correct, it will error if any module store has incorrect height.
* (x/evidence) [#14757](https://github.com/cosmos/cosmos-sdk/pull/14757) Evidence messages do not need to implement a `.Type()` anymore.
Expand Down Expand Up @@ -177,12 +177,19 @@ Ref: https://keepachangelog.com/en/1.0.0/

### API Breaking Changes


* (x/auth) [#14758](https://github.com/cosmos/cosmos-sdk/pull/14758) Refactor transaction searching:
* Refactor `QueryTxsByEvents` to accept a `query` of type `string` instead of `events` of type `[]string`
* Pass `prove=false` to Tendermint's `TxSearch` RPC method
* Refactor CLI methods to accept `--query` flag instead of `--events`
* (testutil) [#14991](https://github.com/cosmos/cosmos-sdk/pull/14991) The `testutil/testdata_pulsar` package has moved to `testutil/testdata/testpb`.
* (simapp) [#14977](https://github.com/cosmos/cosmos-sdk/pull/14977) Move simulation helpers functions (`AppStateFn` and `AppStateRandomizedFn`) to `testutil/sims`. These takes an extra genesisState argument which is the default state of the app.
* (x/gov) [#14720](https://github.com/cosmos/cosmos-sdk/pull/14720) Add an expedited field in the gov v1 proposal and `MsgNewMsgProposal`.
* [#14847](https://github.com/cosmos/cosmos-sdk/pull/14847) App and ModuleManager methods `InitGenesis`, `ExportGenesis`, `BeginBlock` and `EndBlock` now also return an error.
* (simulation) [#14728](https://github.com/cosmos/cosmos-sdk/pull/14728) Rename the `ParamChanges` field to `LegacyParamChange` and `Contents` to `LegacyProposalContents` in `simulation.SimulationState`. Additionally it adds a `ProposalMsgs` field to `simulation.SimulationState`.
* (x/upgrade) [#14764](https://github.com/cosmos/cosmos-sdk/pull/14764) The `x/upgrade` module is extracted to have a separate go.mod file which allows it to be a standalone module.

julienrbrt marked this conversation as resolved.
Show resolved Hide resolved

* (x/gov) [#14782](https://github.com/cosmos/cosmos-sdk/pull/14782) Move the `metadata` argument in `govv1.NewProposal` alongside `title` and `summary`.
* (store) [#14746](https://github.com/cosmos/cosmos-sdk/pull/14746) Extract Store in its own go.mod and rename the package to `cosmossdk.io/store`.
* (simulation) [#14751](https://github.com/cosmos/cosmos-sdk/pull/14751) Remove the `MsgType` field from `simulation.OperationInput` struct.
Expand Down
495 changes: 288 additions & 207 deletions api/cosmos/tx/v1beta1/service.pulsar.go

Large diffs are not rendered by default.

36 changes: 26 additions & 10 deletions proto/cosmos/tx/v1beta1/service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ service Service {
// GetBlockWithTxs fetches a block with decoded txs.
//
// Since: cosmos-sdk 0.45.2
rpc GetBlockWithTxs(GetBlockWithTxsRequest) returns (GetBlockWithTxsResponse) {
rpc GetBlockWithTxs(GetBlockWithTxsRequest)
returns (GetBlockWithTxsResponse) {
option (google.api.http).get = "/cosmos/tx/v1beta1/txs/block/{height}";
}
// TxDecode decodes the transaction.
Expand Down Expand Up @@ -82,22 +83,35 @@ service Service {
// RPC method.
message GetTxsEventRequest {
// events is the list of transaction event type.
repeated string events = 1;
// Deprecated post v0.47.x: use query instead, which should contain a valid
// events query.
repeated string events = 1 [deprecated = true];

// pagination defines a pagination for the request.
// Deprecated post v0.46.x: use page and limit instead.
cosmos.base.query.v1beta1.PageRequest pagination = 2 [deprecated = true];

OrderBy order_by = 3;
// page is the page number to query, starts at 1. If not provided, will default to first page.

// page is the page number to query, starts at 1. If not provided, will
// default to first page.
uint64 page = 4;

// limit is the total number of results to be returned in the result page.
// If left empty it will default to a value to be set by each app.
uint64 limit = 5;

// query defines the transaction event query that is proxied to Tendermint's
// TxSearch RPC method. The query must be valid.
//
// Since Cosmos SDK 0.48
string query = 6;
tac0turtle marked this conversation as resolved.
Show resolved Hide resolved
}

// OrderBy defines the sorting order
enum OrderBy {
// ORDER_BY_UNSPECIFIED specifies an unknown sorting order. OrderBy defaults to ASC in this case.
// ORDER_BY_UNSPECIFIED specifies an unknown sorting order. OrderBy defaults
// to ASC in this case.
ORDER_BY_UNSPECIFIED = 0;
// ORDER_BY_ASC defines ascending order
ORDER_BY_ASC = 1;
Expand Down Expand Up @@ -127,18 +141,19 @@ message BroadcastTxRequest {
BroadcastMode mode = 2;
}

// BroadcastMode specifies the broadcast mode for the TxService.Broadcast RPC method.
// BroadcastMode specifies the broadcast mode for the TxService.Broadcast RPC
// method.
enum BroadcastMode {
// zero-value for mode ordering
BROADCAST_MODE_UNSPECIFIED = 0;
// DEPRECATED: use BROADCAST_MODE_SYNC instead,
// BROADCAST_MODE_BLOCK is not supported by the SDK from v0.47.x onwards.
BROADCAST_MODE_BLOCK = 1 [deprecated = true];
// BROADCAST_MODE_SYNC defines a tx broadcasting mode where the client waits for
// a CheckTx execution response only.
// BROADCAST_MODE_SYNC defines a tx broadcasting mode where the client waits
// for a CheckTx execution response only.
BROADCAST_MODE_SYNC = 2;
// BROADCAST_MODE_ASYNC defines a tx broadcasting mode where the client returns
// immediately.
// BROADCAST_MODE_ASYNC defines a tx broadcasting mode where the client
// returns immediately.
BROADCAST_MODE_ASYNC = 3;
}

Expand Down Expand Up @@ -196,7 +211,8 @@ message GetBlockWithTxsRequest {
cosmos.base.query.v1beta1.PageRequest pagination = 2;
}

// GetBlockWithTxsResponse is the response type for the Service.GetBlockWithTxs method.
// GetBlockWithTxsResponse is the response type for the Service.GetBlockWithTxs
// method.
//
// Since: cosmos-sdk 0.45.2
message GetBlockWithTxsResponse {
Expand Down
2 changes: 1 addition & 1 deletion server/grpc/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func (s *IntegrationTestSuite) TestGRPCServer_GetTxsEvent() {
_, err := txServiceClient.GetTxsEvent(
context.Background(),
&txtypes.GetTxsEventRequest{
Events: []string{"message.action='send'"},
Query: "message.action='send'",
},
)
s.Require().NoError(err)
Expand Down
2 changes: 0 additions & 2 deletions tests/e2e/auth/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ import (
"testing"

"cosmossdk.io/simapp"

"github.com/cosmos/cosmos-sdk/testutil/network"

"github.com/stretchr/testify/suite"
)

Expand Down
12 changes: 8 additions & 4 deletions tests/e2e/auth/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -708,17 +708,21 @@ func (s *E2ETestSuite) TestCLIQueryTxsCmdByEvents() {
{
"fee event happy case",
[]string{
fmt.Sprintf("--events=tx.fee=%s",
sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
fmt.Sprintf(
"--query=tx.fee='%s'",
sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String(),
),
fmt.Sprintf("--%s=json", flags.FlagOutput),
},
false,
},
{
"no matching fee event",
[]string{
fmt.Sprintf("--events=tx.fee=%s",
sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(0))).String()),
fmt.Sprintf(
"--query=tx.fee='%s'",
sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(0))).String(),
),
fmt.Sprintf("--%s=json", flags.FlagOutput),
},
true,
Expand Down
Loading