Merge PR #247: Update SDK Commit & Update CLI Doc

This commit is contained in:
Alexander Bezobchuk
2020-01-07 14:14:39 -05:00
committed by GitHub
parent 434f425241
commit 87a4269b90
16 changed files with 97 additions and 90 deletions

View File

@@ -127,7 +127,7 @@ type GaiaApp struct {
// NewGaiaApp returns a reference to an initialized GaiaApp.
func NewGaiaApp(
logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest bool,
invCheckPeriod uint, baseAppOptions ...func(*bam.BaseApp),
invCheckPeriod uint, skipUpgradeHeights map[int64]bool, baseAppOptions ...func(*bam.BaseApp),
) *GaiaApp {
cdc := MakeCodec()
@@ -190,7 +190,7 @@ func NewGaiaApp(
app.crisisKeeper = crisis.NewKeeper(
app.subspaces[crisis.ModuleName], invCheckPeriod, app.supplyKeeper, auth.FeeCollectorName,
)
app.upgradeKeeper = upgrade.NewKeeper(keys[upgrade.StoreKey], app.cdc)
app.upgradeKeeper = upgrade.NewKeeper(skipUpgradeHeights, keys[upgrade.StoreKey], app.cdc)
// create evidence keeper with evidence router
evidenceKeeper := evidence.NewKeeper(

View File

@@ -16,12 +16,12 @@ import (
func TestGaiadExport(t *testing.T) {
db := db.NewMemDB()
gapp := NewGaiaApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, 0)
gapp := NewGaiaApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, 0, map[int64]bool{})
err := setGenesis(gapp)
require.NoError(t, err)
// Making a new app object with the db, so that initchain hasn't been called
newGapp := NewGaiaApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, 0)
newGapp := NewGaiaApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, 0, map[int64]bool{})
_, _, err = newGapp.ExportAppStateAndValidators(false, []string{})
require.NoError(t, err, "ExportAppStateAndValidators should not have an error")
}
@@ -29,7 +29,7 @@ func TestGaiadExport(t *testing.T) {
// ensure that black listed addresses are properly set in bank keeper
func TestBlackListedAddrs(t *testing.T) {
db := db.NewMemDB()
gapp := NewGaiaApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, 0)
gapp := NewGaiaApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, 0, map[int64]bool{})
for acc := range maccPerms {
require.True(t, gapp.bankKeeper.BlacklistedAddr(gapp.supplyKeeper.GetModuleAddress(acc)))

View File

@@ -92,7 +92,7 @@ func (app *GaiaApp) prepForZeroHeightGenesis(ctx sdk.Context, jailWhiteList []st
// donate any unwithdrawn outstanding reward fraction tokens to the community pool
scraps := app.distrKeeper.GetValidatorOutstandingRewards(ctx, val.GetOperator())
feePool := app.distrKeeper.GetFeePool(ctx)
feePool.CommunityPool = feePool.CommunityPool.Add(scraps)
feePool.CommunityPool = feePool.CommunityPool.Add(scraps...)
app.distrKeeper.SetFeePool(ctx, feePool)
app.distrKeeper.Hooks().AfterValidatorCreated(ctx, val.GetOperator())

View File

@@ -27,7 +27,7 @@ func BenchmarkFullAppSimulation(b *testing.B) {
}
}()
app := NewGaiaApp(logger, db, nil, true, simapp.FlagPeriodValue, interBlockCacheOpt())
app := NewGaiaApp(logger, db, nil, true, simapp.FlagPeriodValue, map[int64]bool{}, interBlockCacheOpt())
// run randomized simulation
_, simParams, simErr := simulation.SimulateFromSeed(
@@ -66,7 +66,7 @@ func BenchmarkInvariants(b *testing.B) {
}
}()
app := NewGaiaApp(logger, db, nil, true, simapp.FlagPeriodValue, interBlockCacheOpt())
app := NewGaiaApp(logger, db, nil, true, simapp.FlagPeriodValue, map[int64]bool{}, interBlockCacheOpt())
// run randomized simulation
_, simParams, simErr := simulation.SimulateFromSeed(

View File

@@ -62,7 +62,7 @@ func TestFullAppSimulation(t *testing.T) {
require.NoError(t, os.RemoveAll(dir))
}()
app := NewGaiaApp(logger, db, nil, true, simapp.FlagPeriodValue, fauxMerkleModeOpt)
app := NewGaiaApp(logger, db, nil, true, simapp.FlagPeriodValue, map[int64]bool{}, fauxMerkleModeOpt)
require.Equal(t, appName, app.Name())
// run randomized simulation
@@ -94,7 +94,7 @@ func TestAppImportExport(t *testing.T) {
require.NoError(t, os.RemoveAll(dir))
}()
app := NewGaiaApp(logger, db, nil, true, simapp.FlagPeriodValue, fauxMerkleModeOpt)
app := NewGaiaApp(logger, db, nil, true, simapp.FlagPeriodValue, map[int64]bool{}, fauxMerkleModeOpt)
require.Equal(t, appName, app.Name())
// Run randomized simulation
@@ -128,7 +128,7 @@ func TestAppImportExport(t *testing.T) {
require.NoError(t, os.RemoveAll(newDir))
}()
newApp := NewGaiaApp(log.NewNopLogger(), newDB, nil, true, simapp.FlagPeriodValue, fauxMerkleModeOpt)
newApp := NewGaiaApp(log.NewNopLogger(), newDB, nil, true, simapp.FlagPeriodValue, map[int64]bool{}, fauxMerkleModeOpt)
require.Equal(t, appName, newApp.Name())
var genesisState GenesisState
@@ -180,7 +180,7 @@ func TestAppSimulationAfterImport(t *testing.T) {
require.NoError(t, os.RemoveAll(dir))
}()
app := NewGaiaApp(logger, db, nil, true, simapp.FlagPeriodValue, fauxMerkleModeOpt)
app := NewGaiaApp(logger, db, nil, true, simapp.FlagPeriodValue, map[int64]bool{}, fauxMerkleModeOpt)
require.Equal(t, appName, app.Name())
// Run randomized simulation
@@ -219,7 +219,7 @@ func TestAppSimulationAfterImport(t *testing.T) {
require.NoError(t, os.RemoveAll(newDir))
}()
newApp := NewGaiaApp(log.NewNopLogger(), newDB, nil, true, simapp.FlagPeriodValue, fauxMerkleModeOpt)
newApp := NewGaiaApp(log.NewNopLogger(), newDB, nil, true, simapp.FlagPeriodValue, map[int64]bool{}, fauxMerkleModeOpt)
require.Equal(t, appName, newApp.Name())
newApp.InitChain(abci.RequestInitChain{
@@ -263,7 +263,7 @@ func TestAppStateDeterminism(t *testing.T) {
db := dbm.NewMemDB()
app := NewGaiaApp(logger, db, nil, true, simapp.FlagPeriodValue, interBlockCacheOpt())
app := NewGaiaApp(logger, db, nil, true, simapp.FlagPeriodValue, map[int64]bool{}, interBlockCacheOpt())
fmt.Printf(
"running non-determinism simulation; seed %d: %d/%d, attempt: %d/%d\n",

View File

@@ -503,8 +503,8 @@ func TestGaiaCLISubmitProposal(t *testing.T) {
f.TxGovSubmitProposal(keyFoo, "Text", "Test", "test", sdk.NewCoin(denom, proposalTokens), "-y")
tests.WaitForNextNBlocksTM(1, f.Port)
// Ensure transaction tags can be queried
searchResult := f.QueryTxs(1, 50, "message.action:submit_proposal", fmt.Sprintf("message.sender:%s", fooAddr))
// Ensure transaction events can be queried
searchResult := f.QueryTxs(1, 50, "message.action=submit_proposal", fmt.Sprintf("message.sender=%s", fooAddr))
require.Len(t, searchResult.Txs, 1)
// Ensure deposit was deducted
@@ -547,8 +547,8 @@ func TestGaiaCLISubmitProposal(t *testing.T) {
deposit = f.QueryGovDeposit(1, fooAddr)
require.Equal(t, proposalTokens.Add(depositTokens), deposit.Amount.AmountOf(denom))
// Ensure tags are set on the transaction
searchResult = f.QueryTxs(1, 50, "message.action:deposit", fmt.Sprintf("message.sender:%s", fooAddr))
// Ensure events are set on the transaction
searchResult = f.QueryTxs(1, 50, "message.action=deposit", fmt.Sprintf("message.sender=%s", fooAddr))
require.Len(t, searchResult.Txs, 1)
// Ensure account has expected amount of funds
@@ -584,8 +584,8 @@ func TestGaiaCLISubmitProposal(t *testing.T) {
require.Equal(t, uint64(1), votes[0].ProposalID)
require.Equal(t, gov.OptionYes, votes[0].Option)
// Ensure tags are applied to voting transaction properly
searchResult = f.QueryTxs(1, 50, "message.action:vote", fmt.Sprintf("message.sender:%s", fooAddr))
// Ensure events are applied to voting transaction properly
searchResult = f.QueryTxs(1, 50, "message.action=vote", fmt.Sprintf("message.sender=%s", fooAddr))
require.Len(t, searchResult.Txs, 1)
// Ensure no proposals in deposit period
@@ -647,8 +647,8 @@ func TestGaiaCLISubmitParamChangeProposal(t *testing.T) {
f.TxGovSubmitParamChangeProposal(keyFoo, proposalFile.Name(), sdk.NewCoin(denom, proposalTokens), "-y")
tests.WaitForNextNBlocksTM(1, f.Port)
// ensure transaction tags can be queried
txsPage := f.QueryTxs(1, 50, "message.action:submit_proposal", fmt.Sprintf("message.sender:%s", fooAddr))
// ensure transaction events can be queried
txsPage := f.QueryTxs(1, 50, "message.action=submit_proposal", fmt.Sprintf("message.sender=%s", fooAddr))
require.Len(t, txsPage.Txs, 1)
// ensure deposit was deducted
@@ -731,8 +731,8 @@ func TestGaiaCLISubmitCommunityPoolSpendProposal(t *testing.T) {
f.TxGovSubmitCommunityPoolSpendProposal(keyFoo, proposalFile.Name(), sdk.NewCoin(denom, proposalTokens), "-y")
tests.WaitForNextNBlocksTM(1, f.Port)
// ensure transaction tags can be queried
txsPage := f.QueryTxs(1, 50, "message.action:submit_proposal", fmt.Sprintf("message.sender:%s", fooAddr))
// ensure transaction events can be queried
txsPage := f.QueryTxs(1, 50, "message.action=submit_proposal", fmt.Sprintf("message.sender=%s", fooAddr))
require.Len(t, txsPage.Txs, 1)
// ensure deposit was deducted
@@ -777,30 +777,30 @@ func TestGaiaCLIQueryTxPagination(t *testing.T) {
}
// perPage = 15, 2 pages
txsPage1 := f.QueryTxs(1, 15, fmt.Sprintf("message.sender:%s", fooAddr))
txsPage1 := f.QueryTxs(1, 15, fmt.Sprintf("message.sender=%s", fooAddr))
require.Len(t, txsPage1.Txs, 15)
require.Equal(t, txsPage1.Count, 15)
txsPage2 := f.QueryTxs(2, 15, fmt.Sprintf("message.sender:%s", fooAddr))
txsPage2 := f.QueryTxs(2, 15, fmt.Sprintf("message.sender=%s", fooAddr))
require.Len(t, txsPage2.Txs, 15)
require.NotEqual(t, txsPage1.Txs, txsPage2.Txs)
// perPage = 16, 2 pages
txsPage1 = f.QueryTxs(1, 16, fmt.Sprintf("message.sender:%s", fooAddr))
txsPage1 = f.QueryTxs(1, 16, fmt.Sprintf("message.sender=%s", fooAddr))
require.Len(t, txsPage1.Txs, 16)
txsPage2 = f.QueryTxs(2, 16, fmt.Sprintf("message.sender:%s", fooAddr))
txsPage2 = f.QueryTxs(2, 16, fmt.Sprintf("message.sender=%s", fooAddr))
require.Len(t, txsPage2.Txs, 14)
require.NotEqual(t, txsPage1.Txs, txsPage2.Txs)
// perPage = 50
txsPageFull := f.QueryTxs(1, 50, fmt.Sprintf("message.sender:%s", fooAddr))
txsPageFull := f.QueryTxs(1, 50, fmt.Sprintf("message.sender=%s", fooAddr))
require.Len(t, txsPageFull.Txs, 30)
require.Equal(t, txsPageFull.Txs, append(txsPage1.Txs, txsPage2.Txs...))
// perPage = 0
f.QueryTxsInvalid(errors.New("ERROR: page must greater than 0"), 0, 50, fmt.Sprintf("message.sender:%s", fooAddr))
f.QueryTxsInvalid(errors.New("ERROR: page must greater than 0"), 0, 50, fmt.Sprintf("message.sender=%s", fooAddr))
// limit = 0
f.QueryTxsInvalid(errors.New("ERROR: limit must greater than 0"), 1, 0, fmt.Sprintf("message.sender:%s", fooAddr))
f.QueryTxsInvalid(errors.New("ERROR: limit must greater than 0"), 1, 0, fmt.Sprintf("message.sender=%s", fooAddr))
// Cleanup testing directories
f.Cleanup()

View File

@@ -453,8 +453,8 @@ func (f *Fixtures) QueryAccount(address sdk.AccAddress, flags ...string) auth.Ba
// gaiacli query txs
// QueryTxs is gaiacli query txs
func (f *Fixtures) QueryTxs(page, limit int, tags ...string) *sdk.SearchTxsResult {
cmd := fmt.Sprintf("%s query txs --page=%d --limit=%d --tags='%s' %v", f.GaiacliBinary, page, limit, queryTags(tags), f.Flags())
func (f *Fixtures) QueryTxs(page, limit int, events ...string) *sdk.SearchTxsResult {
cmd := fmt.Sprintf("%s query txs --page=%d --limit=%d --events='%s' %v", f.GaiacliBinary, page, limit, queryEvents(events), f.Flags())
out, _ := tests.ExecuteT(f.T, cmd, "")
var result sdk.SearchTxsResult
cdc := app.MakeCodec()
@@ -464,8 +464,8 @@ func (f *Fixtures) QueryTxs(page, limit int, tags ...string) *sdk.SearchTxsResul
}
// QueryTxsInvalid query txs with wrong parameters and compare expected error
func (f *Fixtures) QueryTxsInvalid(expectedErr error, page, limit int, tags ...string) {
cmd := fmt.Sprintf("%s query txs --page=%d --limit=%d --tags='%s' %v", f.GaiacliBinary, page, limit, queryTags(tags), f.Flags())
func (f *Fixtures) QueryTxsInvalid(expectedErr error, page, limit int, events ...string) {
cmd := fmt.Sprintf("%s query txs --page=%d --limit=%d --events='%s' %v", f.GaiacliBinary, page, limit, queryEvents(events), f.Flags())
_, err := tests.ExecuteT(f.T, cmd, "")
require.EqualError(f.T, expectedErr, err)
}
@@ -754,9 +754,9 @@ func addFlags(cmd string, flags []string) string {
return strings.TrimSpace(cmd)
}
func queryTags(tags []string) (out string) {
for _, tag := range tags {
out += tag + "&"
func queryEvents(events []string) (out string) {
for _, event := range events {
out += event + "&"
}
return strings.TrimSuffix(out, "&")
}

View File

@@ -83,8 +83,13 @@ func newApp(logger log.Logger, db dbm.DB, traceStore io.Writer) abci.Application
cache = store.NewCommitKVStoreCacheManager()
}
skipUpgradeHeights := make(map[int64]bool)
for _, h := range viper.GetIntSlice(server.FlagUnsafeSkipUpgrades) {
skipUpgradeHeights[int64(h)] = true
}
return app.NewGaiaApp(
logger, db, traceStore, true, invCheckPeriod,
logger, db, traceStore, true, invCheckPeriod, skipUpgradeHeights,
baseapp.SetPruning(store.NewPruningOptionsFromString(viper.GetString("pruning"))),
baseapp.SetMinGasPrices(viper.GetString(server.FlagMinGasPrices)),
baseapp.SetHaltHeight(viper.GetUint64(server.FlagHaltHeight)),
@@ -98,7 +103,7 @@ func exportAppStateAndTMValidators(
) (json.RawMessage, []tmtypes.GenesisValidator, error) {
if height != -1 {
gapp := app.NewGaiaApp(logger, db, traceStore, false, uint(1))
gapp := app.NewGaiaApp(logger, db, traceStore, false, uint(1), map[int64]bool{})
err := gapp.LoadHeight(height)
if err != nil {
return nil, nil, err
@@ -106,6 +111,6 @@ func exportAppStateAndTMValidators(
return gapp.ExportAppStateAndValidators(forZeroHeight, jailWhiteList)
}
gapp := app.NewGaiaApp(logger, db, traceStore, true, uint(1))
gapp := app.NewGaiaApp(logger, db, traceStore, true, uint(1), map[int64]bool{})
return gapp.ExportAppStateAndValidators(forZeroHeight, jailWhiteList)
}

View File

@@ -93,7 +93,7 @@ func replayTxs(rootDir string) error {
// Application
fmt.Fprintln(os.Stderr, "Creating application")
gapp := app.NewGaiaApp(
ctx.Logger, appDB, traceStoreWriter, true, uint(1),
ctx.Logger, appDB, traceStoreWriter, true, uint(1), map[int64]bool{},
baseapp.SetPruning(store.PruneEverything), // nothing
)

View File

@@ -289,41 +289,43 @@ gaiacli tx broadcast --node=<node> signedSendTx.json
### Query Transactions
#### Matching a Set of Tags
#### Matching a Set of Events
You can use the transaction search command to query for transactions that match a specific set of `tags`, which are added on every transaction.
You can use the transaction search command to query for transactions that match a
specific set of `events`, which are added on every transaction.
Each tag is conformed by a key-value pair in the form of `<tag>:<value>`. Tags can also be combined to query for a more specific result using the `&` symbol.
Each event is composed by a key-value pair in the form of `{eventType}.{eventAttribute}={value}`.
Events can also be combined to query for a more specific result using the `&` symbol.
The command for querying transactions using a `tag` is the following:
You can query transactions by `events` as follows:
```bash
gaiacli query txs --tags='<tag>:<value>'
gaiacli query txs --events='message.sender=cosmos1...'
```
And for using multiple `tags`:
And for using multiple `events`:
```bash
gaiacli query txs --tags='<tag1>:<value1>&<tag2>:<value2>'
gaiacli query txs --events='message.sender=cosmos1...&message.action=withdraw_delegator_reward'
```
The pagination is supported as well via `page` and `limit`:
```bash
gaiacli query txs --tags='<tag>:<value>' --page=1 --limit=20
gaiacli query txs --events='message.sender=cosmos1...' --page=1 --limit=20
```
::: tip Note
The action tag always equals the message type returned by the `Type()` function of the relevant message.
You can find a list of available `tags` on each of the SDK modules:
You can find a list of available `events` on each of the SDK modules:
- [Common tags](https://github.com/cosmos/cosmos-sdk/blob/d1e76221d8e28824bb4791cb4ad8662d2ae9051e/types/tags.go#L57-L63)
- [Staking tags](https://cosmos.network/docs/spec/staking/06_tags.html#tags)
- [Governance tags](https://cosmos.network/docs/spec/governance/04_tags.html#tags)
- [Slashing tags](https://cosmos.network/docs/spec/slashing/06_tags.html#tags)
- [Distribution tags](https://cosmos.network/docs/spec/distribution/06_tags.html)
- [Bank tags](https://cosmos.network/docs/spec/bank/04_tags.html#tags)
- [Staking events](https://github.com/cosmos/cosmos-sdk/blob/master/x/staking/spec/07_events.md)
- [Governance events](https://github.com/cosmos/cosmos-sdk/blob/master/x/gov/spec/04_events.md)
- [Slashing events](https://github.com/cosmos/cosmos-sdk/blob/master/x/slashing/spec/06_events.md)
- [Distribution events](https://github.com/cosmos/cosmos-sdk/blob/master/x/distribution/spec/06_events.md)
- [Bank events](https://github.com/cosmos/cosmos-sdk/blob/master/x/bank/spec/04_events.md)
:::
#### Matching a Transaction's Hash

View File

@@ -253,24 +253,24 @@ gaiacli tx broadcast --node=<node> signedSendTx.json
你可以使用交易搜索命令查询与每个交易上添加的特定`标签集`匹配的交易。
每个标签都由`<tag>:<value>`形式的键值对形成。还可以使用``符号组合标签来查询更具体的结果。
每个标签都由`{eventType}.{eventAttribute}={value}`形式的键值对形成。还可以使用``符号组合标签来查询更具体的结果。
使用`标签`查询交易的命令如下:
```bash
gaiacli query txs --tags='<tag>:<value>'
gaiacli query txs --events='message.sender=cosmos1...'
```
使用多个`标签`:
```bash
gaiacli query txs --tags='<tag1>:<value1>&<tag2>:<value2>'
gaiacli query txs --events='message.sender=cosmos1...&message.action=withdraw_delegator_reward'
```
通过`page``limit`来实现分页:
```bash
gaiacli query txs --tags='<tag>:<value>' --page=1 --limit=20
gaiacli query txs --events='message.sender=cosmos1...' --page=1 --limit=20
```
::: tip 注意
@@ -278,13 +278,13 @@ gaiacli query txs --tags='<tag>:<value>' --page=1 --limit=20
action标签始终等于相关message的`Type()`函数返回的消息类型。
你可以在每个SDK的模块中找到目前的标签列表
- [Common tags](https://github.com/cosmos/cosmos-sdk/blob/d1e76221d8e28824bb4791cb4ad8662d2ae9051e/types/tags.go#L57-L63)
- [Staking tags](https://github.com/cosmos/cosmos-sdk/blob/d1e76221d8e28824bb4791cb4ad8662d2ae9051e/x/staking/tags/tags.go#L8-L24)
- [Governance tags](https://github.com/cosmos/cosmos-sdk/blob/d1e76221d8e28824bb4791cb4ad8662d2ae9051e/x/gov/tags/tags.go#L8-L22)
- [Slashing tags](https://github.com/cosmos/cosmos-sdk/blob/d1e76221d8e28824bb4791cb4ad8662d2ae9051e/x/slashing/handler.go#L52)
- [Distribution tags](https://github.com/cosmos/cosmos-sdk/blob/develop/x/distribution/tags/tags.go#L8-L17)
- [Bank tags](https://github.com/cosmos/cosmos-sdk/blob/d1e76221d8e28824bb4791cb4ad8662d2ae9051e/x/bank/keeper.go#L193-L206)
:::
- [Staking events](https://github.com/cosmos/cosmos-sdk/blob/master/x/staking/spec/07_events.md)
- [Governance events](https://github.com/cosmos/cosmos-sdk/blob/master/x/gov/spec/04_events.md)
- [Slashing events](https://github.com/cosmos/cosmos-sdk/blob/master/x/slashing/spec/06_events.md)
- [Distribution events](https://github.com/cosmos/cosmos-sdk/blob/master/x/distribution/spec/06_events.md)
- [Bank events](https://github.com/cosmos/cosmos-sdk/blob/master/x/bank/spec/04_events.md)
:::
#### 匹配一笔交易的hash

View File

@@ -256,40 +256,39 @@ gaiacli tx broadcast --node=<node> signedSendTx.json
#### 태그 매칭하기
트랜잭션 검색 명령을 이용하여 모든 트랜잭션에 추가되는 특정 `tags` 세트를 검색할 수 있습니다.
트랜잭션 검색 명령을 이용하여 모든 트랜잭션에 추가되는 특정 `events` 세트를 검색할 수 있습니다.
각 태그의 키-값 페어는 `<태그(tag)>:<값(value)>` 형태로 이루어집니다. 더 상세한 검색을 원하실 경우 `&` 를 사용하여 태그를 추가할 수 있습니다.
각 태그의 키-값 페어는 `{eventType}.{eventAttribute}={value}` 형태로 이루어집니다. 더 상세한 검색을 원하실 경우 `&` 를 사용하여 태그를 추가할 수 있습니다.
`tag`를 이용한 트랜잭션 조회는 다음과 같이 합니다:
`events`를 이용한 트랜잭션 조회는 다음과 같이 합니다:
```bash
gaiacli query txs --tags='<태그(tag)>:<값(value)>'
gaiacli query txs --events='message.sender=cosmos1...'
```
다수의 `tags`를 이용하실 경우:
다수의 `events`를 이용하실 경우:
```bash
gaiacli query txs --tags='<태그1>:<값1>&<태그2>:<값2>'
gaiacli query txs --events='message.sender=cosmos1...&message.action=withdraw_delegator_reward'
```
페이지네이션은 `page``limit` 값으로 지원됩니다.
```bash
gaiacli query txs --tags='<태그(tag)>:<값(value)>' --page=1 --limit=20
gaiacli query txs --events='message.sender=cosmos1...' --page=1 --limit=20
```
::: tip 참고
액션 태그는 관련 메시지의 `Type()` 명령이 응답하는 메시지 타입과 언제나 동일합니다.
각 SDK 모듈에 대한 `tags`는 여기에서 확인할 수 있습니다:
각 SDK 모듈에 대한 `events`는 여기에서 확인할 수 있습니다:
- [Common tags](https://github.com/cosmos/cosmos-sdk/blob/d1e76221d8e28824bb4791cb4ad8662d2ae9051e/types/tags.go#L57-L63)
- [Staking tags](https://github.com/cosmos/cosmos-sdk/blob/d1e76221d8e28824bb4791cb4ad8662d2ae9051e/x/staking/tags/tags.go#L8-L24)
- [Governance tags](https://github.com/cosmos/cosmos-sdk/blob/d1e76221d8e28824bb4791cb4ad8662d2ae9051e/x/gov/tags/tags.go#L8-L22)
- [Slashing tags](https://github.com/cosmos/cosmos-sdk/blob/d1e76221d8e28824bb4791cb4ad8662d2ae9051e/x/slashing/handler.go#L52)
- [Distribution tags](https://github.com/cosmos/cosmos-sdk/blob/develop/x/distribution/tags/tags.go#L8-L17)
- [Bank tags](https://github.com/cosmos/cosmos-sdk/blob/d1e76221d8e28824bb4791cb4ad8662d2ae9051e/x/bank/keeper.go#L193-L206)
- [Staking events](https://github.com/cosmos/cosmos-sdk/blob/master/x/staking/spec/07_events.md)
- [Governance events](https://github.com/cosmos/cosmos-sdk/blob/master/x/gov/spec/04_events.md)
- [Slashing events](https://github.com/cosmos/cosmos-sdk/blob/master/x/slashing/spec/06_events.md)
- [Distribution events](https://github.com/cosmos/cosmos-sdk/blob/master/x/distribution/spec/06_events.md)
- [Bank events](https://github.com/cosmos/cosmos-sdk/blob/master/x/bank/spec/04_events.md)
:::
#### 트랜잭션 해시로 검색하기

2
go.mod
View File

@@ -4,7 +4,7 @@ go 1.13
require (
github.com/btcsuite/btcd v0.0.0-20190807005414-4063feeff79a // indirect
github.com/cosmos/cosmos-sdk v0.34.4-0.20191227175754-9a183ffbcc01
github.com/cosmos/cosmos-sdk v0.34.4-0.20200106164931-25be589af6c9
github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d // indirect
github.com/golang/mock v1.3.1 // indirect
github.com/onsi/ginkgo v1.8.0 // indirect

4
go.sum
View File

@@ -41,8 +41,8 @@ github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8Nz
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
github.com/cosmos/cosmos-sdk v0.34.4-0.20191227175754-9a183ffbcc01 h1:p2YqSaQ3ZovoNr6xhfMRhs0r+z7gsIeCHKyAPJKVOb8=
github.com/cosmos/cosmos-sdk v0.34.4-0.20191227175754-9a183ffbcc01/go.mod h1:hasIdlU9b3FEFCWpoStvNQQPg1ZpAKnpmlFklAk1W1o=
github.com/cosmos/cosmos-sdk v0.34.4-0.20200106164931-25be589af6c9 h1:T9mJsYdwcvHRaXIZKroOLvzrsROOK3/9Jkl/XFCOXcc=
github.com/cosmos/cosmos-sdk v0.34.4-0.20200106164931-25be589af6c9/go.mod h1:hasIdlU9b3FEFCWpoStvNQQPg1ZpAKnpmlFklAk1W1o=
github.com/cosmos/go-bip39 v0.0.0-20180618194314-52158e4697b8/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y=
github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d h1:49RLWk1j44Xu4fjHb6JFYmeUnDORVwHNkDxaQ0ctCVU=
github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y=

View File

@@ -72,7 +72,7 @@ func InitializeLCD(nValidators int, initAddrs []sdk.AccAddress, minting bool, po
logger = log.NewFilter(logger, log.AllowError())
db := dbm.NewMemDB()
gapp := app.NewGaiaApp(logger, db, nil, true, 0, baseapp.SetPruning(store.PruneNothing))
gapp := app.NewGaiaApp(logger, db, nil, true, 0, map[int64]bool{}, baseapp.SetPruning(store.PruneNothing))
cdc = app.MakeCodec()
genDoc, valConsPubKeys, valOperAddrs, privVal, err := defaultGenesis(config, nValidators, initAddrs, minting)

View File

@@ -166,19 +166,20 @@ func getTransactionRequest(t *testing.T, port, hash string) (*http.Response, str
// POST /txs broadcast txs
// GET /txs search transactions
func getTransactions(t *testing.T, port string, tags ...string) *sdk.SearchTxsResult {
func getTransactions(t *testing.T, port string, events ...string) *sdk.SearchTxsResult {
var txs []sdk.TxResponse
result := sdk.NewSearchTxsResult(0, 0, 1, 30, txs)
if len(tags) == 0 {
if len(events) == 0 {
return &result
}
queryStr := strings.Join(tags, "&")
queryStr := strings.Join(events, "&")
res, body := Request(t, port, "GET", fmt.Sprintf("/txs?%s", queryStr), nil)
require.Equal(t, http.StatusOK, res.StatusCode, body)
err := cdc.UnmarshalJSON([]byte(body), &result)
require.NoError(t, err)
return &result
}