Skip to content

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

Merged
cwgoes merged 6 commits intocosmos:developfrom
cryptom-dev:pagination2730
Jan 15, 2019
Merged

[R4R] #2730 add tx search pagination related CLI/REST API parameter#2894
cwgoes merged 6 commits intocosmos:developfrom
cryptom-dev:pagination2730

Conversation

@cryptom-dev
Copy link
Contributor

@cryptom-dev cryptom-dev 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
Contributor

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

@cryptom-dev
Copy link
Contributor Author

cryptom-dev 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"
            }
         ]
      }
   }
]

@cryptom-dev cryptom-dev 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
@cryptom-dev
Copy link
Contributor Author

@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
Contributor

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

Copy link
Contributor

@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)

@cryptom-dev
Copy link
Contributor Author

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

@cryptom-dev cryptom-dev requested a review from zramsay as a code owner December 4, 2018 15:32
@cryptom-dev cryptom-dev 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
@cryptom-dev cryptom-dev 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
@cryptom-dev
Copy link
Contributor Author

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
Contributor

@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?

@cryptom-dev
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).

@cryptom-dev
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
Contributor

@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

Copy link
Contributor

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.

++

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 :)

Copy link
Contributor

Choose a reason for hiding this comment

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

++

@jackzampolin
Copy link
Contributor

@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?

@cryptom-dev
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
Contributor

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

# Conflicts:
#	cmd/gaia/cli_test/cli_test.go
@cryptom-dev
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 👍

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?

@jackzampolin
Copy link
Contributor

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

@cryptom-dev
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
Contributor

@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 !

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.

6 participants