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

[R4R] #2730 add tx search pagination related CLI/REST API parameter #2894

Merged
merged 6 commits into from
Jan 15, 2019

Conversation

ackratos
Copy link
Contributor

@ackratos ackratos commented Nov 24, 2018

closes #2730
closes #466


  • Targeted PR against correct branch (see CONTRIBUTING.md)

  • Linked to github-issue with discussion and accepted design OR link to spec that describes this work.

  • Wrote tests

  • Updated relevant documentation (docs/)

  • Added entries in PENDING.md with issue #

  • rereviewed Files changed in the github PR explorer


For Admin Use:

  • Added appropriate labels to PR (ex. wip, ready-for-review, docs)
  • Reviewers Assigned
  • Squashed all commits, uses message "Merge pull request #XYZ: [title]" (coding standards)

@jackzampolin
Copy link
Member

cc @fedekunze per discussion: #2927

@codecov
Copy link

codecov bot commented Dec 2, 2018

Codecov Report

Merging #2894 into develop will decrease coverage by 0.44%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           develop   #2894      +/-   ##
==========================================
- Coverage    55.65%   55.2%   -0.45%     
==========================================
  Files          134     134              
  Lines         9716    9526     -190     
==========================================
- Hits          5407    5259     -148     
+ Misses        3965    3936      -29     
+ Partials       344     331      -13

@ackratos
Copy link
Contributor Author

ackratos commented Dec 2, 2018

manually tested

rest-server: https://127.0.0.1:1317/txs?tx.height=1148&page=1&limit=10

[  
   {  
      hash:"B252067C0A2A6917F6CF1B342BA32829EF32B962A7C21449E9CE63C59BF4B196",
      height:"1148",
      tx:{  
         type:"auth/StdTx",
         value:{  
            msg:[  
               {  
                  type:"cosmos-sdk/Send",
                  value:{  
                     inputs:[  
                        {  
                           address:"cosmos1h7k328ca9nt7qx2nltamp2wvsulszn8c98g9aq",
                           coins:[  
                              {  
                                 denom:"validatorToken",
                                 amount:"10"
                              }
                           ]
                        }
                     ],
                     outputs:[  
                        {  
                           address:"cosmos1xdm02sy7xnea9zcpt634uj9tufl7vq30eg3u8v",
                           coins:[  
                              {  
                                 denom:"validatorToken",
                                 amount:"10"
                              }
                           ]
                        }
                     ]
                  }
               }
            ],
            fee:{  
               amount:[  
                  {  
                     denom:"",
                     amount:"0"
                  }
               ],
               gas:"200000"
            },
            signatures:[  
               {  
                  pub_key:{  
                     type:"tendermint/PubKeySecp256k1",
                     value:"AwxauLUFhSTKJtSi87gF+Wt2nVSgNyTlqAJEHx8gjy5r"
                  },
                  signature:"NYPe/C5pUpWVDv/HXRi85I3qKpKWn1aZ3M1ywCgxf/whlR5ecHq/KYOxcaBoB5lBvUY5rcWzDydJSBOT/MWxpg==",
                  account_number:"0",
                  sequence:"1"
               }
            ],
            memo:""
         }
      },
      result:{  
         log:"Msg 0: ",
         gasWanted:"200000",
         gasUsed:"3390",
         tags:[  
            {  
               key:"YWN0aW9u",
               value:"c2VuZA=="
            },
            {  
               key:"c2VuZGVy",
               value:"Y29zbW9zMWg3azMyOGNhOW50N3F4Mm5sdGFtcDJ3dnN1bHN6bjhjOThnOWFx"
            },
            {  
               key:"cmVjaXBpZW50",
               value:"Y29zbW9zMXhkbTAyc3k3eG5lYTl6Y3B0NjM0dWo5dHVmbDd2cTMwZWczdTh2"
            }
         ]
      }
   }
]

command line: gaiacli query txs --tags 'tx.height:1148' --page 1 --limit 30 --chain-id testing

[  
   {  
      "hash":"B252067C0A2A6917F6CF1B342BA32829EF32B962A7C21449E9CE63C59BF4B196",
      "height":"1148",
      "tx":{  
         "type":"auth/StdTx",
         "value":{  
            "msg":[  
               {  
                  "type":"cosmos-sdk/Send",
                  "value":{  
                     "inputs":[  
                        {  
                           "address":"cosmos1h7k328ca9nt7qx2nltamp2wvsulszn8c98g9aq",
                           "coins":[  
                              {  
                                 "denom":"validatorToken",
                                 "amount":"10"
                              }
                           ]
                        }
                     ],
                     "outputs":[  
                        {  
                           "address":"cosmos1xdm02sy7xnea9zcpt634uj9tufl7vq30eg3u8v",
                           "coins":[  
                              {  
                                 "denom":"validatorToken",
                                 "amount":"10"
                              }
                           ]
                        }
                     ]
                  }
               }
            ],
            "fee":{  
               "amount":[  
                  {  
                     "denom":"",
                     "amount":"0"
                  }
               ],
               "gas":"200000"
            },
            "signatures":[  
               {  
                  "pub_key":{  
                     "type":"tendermint/PubKeySecp256k1",
                     "value":"AwxauLUFhSTKJtSi87gF+Wt2nVSgNyTlqAJEHx8gjy5r"
                  },
                  "signature":"NYPe/C5pUpWVDv/HXRi85I3qKpKWn1aZ3M1ywCgxf/whlR5ecHq/KYOxcaBoB5lBvUY5rcWzDydJSBOT/MWxpg==",
                  "account_number":"0",
                  "sequence":"1"
               }
            ],
            "memo":""
         }
      },
      "result":{  
         "log":"Msg 0: ",
         "gasWanted":"200000",
         "gasUsed":"3390",
         "tags":[  
            {  
               "key":"YWN0aW9u",
               "value":"c2VuZA=="
            },
            {  
               "key":"c2VuZGVy",
               "value":"Y29zbW9zMWg3azMyOGNhOW50N3F4Mm5sdGFtcDJ3dnN1bHN6bjhjOThnOWFx"
            },
            {  
               "key":"cmVjaXBpZW50",
               "value":"Y29zbW9zMXhkbTAyc3k3eG5lYTl6Y3B0NjM0dWo5dHVmbDd2cTMwZWczdTh2"
            }
         ]
      }
   }
]

@ackratos ackratos changed the title [WIP] #2730 add tx search pagination related CLI/REST API parameter [R4R] #2730 add tx search pagination related CLI/REST API parameter Dec 2, 2018
@ackratos
Copy link
Contributor Author

ackratos commented Dec 2, 2018

@ebuchman @cwgoes could you please review this PR?

@cwgoes
Copy link
Contributor

cwgoes commented Dec 3, 2018

cc @fedekunze I think you had thoughts on this.

@fedekunze
Copy link
Collaborator

@cwgoes @ackratos yes it was related to #2927, but pagination is still something we want regardless of the decision of that discussion

Copy link
Collaborator

@fedekunze fedekunze left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes so far LGTM. Thanks @ackratos for fixing this ! A few additions are required before merging:

  • May I ask you to update the docs by adding the flags on gaiacli.md as well?
  • Can you add a small test case on cli_test.go too ?
  • Change perPage for limit according to standards (Source)

@ackratos
Copy link
Contributor Author

ackratos commented Dec 4, 2018

Changes so far LGTM. Thanks @ackratos for fixing this ! A few additions are required before merging:

thanks for the suggestions. I am working on them

@ackratos ackratos changed the title [R4R] #2730 add tx search pagination related CLI/REST API parameter [WIP] #2730 add tx search pagination related CLI/REST API parameter Dec 4, 2018
@ackratos ackratos changed the title [WIP] #2730 add tx search pagination related CLI/REST API parameter [R4R] #2730 add tx search pagination related CLI/REST API parameter Dec 9, 2018
@ackratos
Copy link
Contributor Author

ackratos commented Dec 9, 2018

Changes so far LGTM. Thanks @ackratos for fixing this ! A few additions are required before merging:

  • May I ask you to update the docs by adding the flags on gaiacli.md as well?
  • Can you add a small test case on cli_test.go too ?
  • Change perPage for limit according to standards (Source)

fixed, could you please review this PR again? Thanks

@jackzampolin
Copy link
Member

@ackratos how do I query the second page? Can we add an offset (either # of txns or pages) here so that subsequent pages can be queried?

@ackratos
Copy link
Contributor Author

@ackratos how do I query the second page? Can we add an offset (either # of txns or pages) here so that subsequent pages can be queried?

This PR added two (missing) parameters to cli and rest api: page and limit, setting page to 2 while keep limit with the same with page 1 can navigate you to page 2. (see the test cases I added)

This is pseudo-implementation because at tendermint tx searching side, it still query all txs meet the tags requirement only return the pagination data. This will help reduce network roundtrips but not saving query CPU time on node.

@cwgoes
Copy link
Contributor

cwgoes commented Dec 12, 2018

Needs merge conflict resolution, then I'd be glad to review (maybe @fedekunze could take a look again too).

@ackratos
Copy link
Contributor Author

Needs merge conflict resolution, then I'd be glad to review (maybe @fedekunze could take a look again too).

thanks, done

Copy link
Collaborator

@fedekunze fedekunze left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry for the delay here. One final check and we should be good to go

@@ -86,7 +86,7 @@ var _ abci.Application = (*BaseApp)(nil)
// NewBaseApp returns a reference to an initialized BaseApp.
//
// NOTE: The db is used to store the version number for now.
// Accepts a user-defined txDecoder
// Accepts a usemake install_examplesr-defined txDecoder
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

++

client/tx/search.go Outdated Show resolved Hide resolved
client/tx/search.go Outdated Show resolved Hide resolved
Copy link
Contributor

@alexanderbez alexanderbez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good @ackratos, just a few minor bits of feedback :)

@@ -86,7 +86,7 @@ var _ abci.Application = (*BaseApp)(nil)
// NewBaseApp returns a reference to an initialized BaseApp.
//
// NOTE: The db is used to store the version number for now.
// Accepts a user-defined txDecoder
// Accepts a usemake install_examplesr-defined txDecoder
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

++

client/tx/search.go Outdated Show resolved Hide resolved
client/tx/search.go Outdated Show resolved Hide resolved
client/tx/search.go Outdated Show resolved Hide resolved
@jackzampolin
Copy link
Member

@ackratos Sorry for the long review process, but if you could address this last round of comments we can get this merged. Will you be able to do that this week?

@ackratos
Copy link
Contributor Author

@ackratos Sorry for the long review process, but if you could address this last round of comments we can get this merged. Will you be able to do that this week?

yes, really sorry I was busy this week...
Will do that in next two days.

@jackzampolin
Copy link
Member

@ackratos Totally understand! Thank you for working with us to get this right!

# Conflicts:
#	cmd/gaia/cli_test/cli_test.go
@ackratos
Copy link
Contributor Author

@ackratos Totally understand! Thank you for working with us to get this right!

updated this PR, could you please review again?

Copy link
Contributor

@alexanderbez alexanderbez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ackratos -- I think there is still an issue with the use of constants. Also see my comments on parseHTTPArgs, otherwise, I think we can merge this PR afterwards 👍

infos, err := tx.SearchTxs(cliCtx, cdc, tags)
// NOTE: SearchTxs is used to facilitate the txs query which does not currently
// support configurable pagination.
infos, err := tx.SearchTxs(cliCtx, cdc, tags, 1, 30)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like these still need to be constants?

cmd/gaia/cli_test/test_helpers.go Outdated Show resolved Hide resolved
client/tx/search.go Show resolved Hide resolved
client/tx/search.go Outdated Show resolved Hide resolved
client/tx/search.go Outdated Show resolved Hide resolved
client/tx/search.go Outdated Show resolved Hide resolved
client/tx/search.go Outdated Show resolved Hide resolved
client/tx/search.go Outdated Show resolved Hide resolved
@jackzampolin
Copy link
Member

@ackratos agree with @alexanderbez and @alessio. Thanks for updating the tests as well! Glad they are passing.

@ackratos
Copy link
Contributor Author

@ackratos agree with @alexanderbez and @alessio. Thanks for updating the tests as well! Glad they are passing.

thanks! fixed again:)

Copy link
Collaborator

@fedekunze fedekunze left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @ackratos !

@cwgoes cwgoes merged commit 916ea85 into cosmos:develop Jan 15, 2019
@ackratos ackratos deleted the pagination2730 branch April 29, 2019 08:31
chillyvee pushed a commit to chillyvee/cosmos-sdk that referenced this pull request Mar 1, 2024
…cosmos#2894)

Bumps [github.com/cometbft/cometbft-db](https://github.com/cometbft/cometbft-db) from 0.8.0 to 0.9.1.
- [Release notes](https://github.com/cometbft/cometbft-db/releases)
- [Changelog](https://github.com/cometbft/cometbft-db/blob/main/CHANGELOG.md)
- [Commits](cometbft/cometbft-db@v0.8.0...v0.9.1)

---
updated-dependencies:
- dependency-name: github.com/cometbft/cometbft-db
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Philip Offtermatt <57488781+p-offtermatt@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants