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

#2051 Make kv index for tx.height #2324

Merged
merged 1 commit into from
Sep 5, 2018

Conversation

ackratos
Copy link
Contributor

@ackratos ackratos commented Sep 4, 2018

Partially fixed #2051 to make rest api request like http://127.0.0.1:8080/txs?tag=tx.height=1330 work

This is tested against our ABCI application which relies on cosmos default Send msg tx.
To make sure this change works, I:
0. change config.toml file: index_all_tags=true and timeout_commit=30000 (so that 2 transactions issued manually can be included in same block

  1. started local test net in 4 docker container
  2. restored two accounts for different home (so that I can run 2 gaiacli to make transaction at the same time)
  3. transfer coins "at the same time"
  4. start a node rest api-server and check http://127.0.0.1:8080/txs?tag=tx.height=1330

I can get json response like:

[  
   {  
      hash:"798E4CE82A5CFEB65E9DECD3F4D00F9753509FE7",
      height:"1330",
      tx:{  
         type:"auth/StdTx",
         value:{  
            msg:[  
               {  
                  type:"cosmos-sdk/Send",
                  value:{  
                     inputs:[  
                        {  
                           address:"cosmosaccaddr19zqnmalreaugjf8mxm5z0x99ew49anghxpv3x4",
                           coins:[  
                              {  
                                 denom:"BBB",
                                 amount:"10000000000"
                              }
                           ]
                        }
                     ],
                     outputs:[  
                        {  
                           address:"cosmosaccaddr1gtj97w4sxz0eademencfdj8nesmy4c306a3g50",
                           coins:[  
                              {  
                                 denom:"BBB",
                                 amount:"10000000000"
                              }
                           ]
                        }
                     ]
                  }
               }
            ],
            fee:{  
               amount:[  
                  {  
                     denom:"",
                     amount:"0"
                  }
               ],
               gas:"200000"
            },
            signatures:[  
               {  
                  pub_key:{  
                     type:"tendermint/PubKeySecp256k1",
                     value:"AgOIKfLYQ0qmtER5Dy58oH4VcAEJodb4xMG29QuHr/2P"
                  },
                  signature:{  
                     type:"tendermint/SignatureSecp256k1",
                     value:"MEUCIQCJSAW5yPYpiHLeSm4DwnQUrwXz05sYB1cD10kS4o3qSAIgQu/a7+WS3fh6KCQ8MMML+Q4sYVDH4aa3nPzvrPLbGyg="
                  },
                  account_number:"2",
                  sequence:"0"
               }
            ],
            memo:""
         }
      },
      result:{  
         log:"Msg 0: ",
         gasUsed:"4924",
         tags:[  
            {  
               key:"c2VuZGVy",
               value:"Y29zbW9zYWNjYWRkcjE5enFubWFscmVhdWdqZjhteG01ejB4OTlldzQ5YW5naHhwdjN4NA=="
            },
            {  
               key:"cmVjaXBpZW50",
               value:"Y29zbW9zYWNjYWRkcjFndGo5N3c0c3h6MGVhZGVtZW5jZmRqOG5lc215NGMzMDZhM2c1MA=="
            }
         ],
         fee:{  

         }
      }
   },
   {  
      hash:"81D9D88B85B86C52BEEAE56CF77791AEE81A08FE",
      height:"1330",
      tx:{  
         type:"auth/StdTx",
         value:{  
            msg:[  
               {  
                  type:"cosmos-sdk/Send",
                  value:{  
                     inputs:[  
                        {  
                           address:"cosmosaccaddr1gtj97w4sxz0eademencfdj8nesmy4c306a3g50",
                           coins:[  
                              {  
                                 denom:"BBB",
                                 amount:"100000000000"
                              }
                           ]
                        }
                     ],
                     outputs:[  
                        {  
                           address:"cosmosaccaddr19zqnmalreaugjf8mxm5z0x99ew49anghxpv3x4",
                           coins:[  
                              {  
                                 denom:"BBB",
                                 amount:"100000000000"
                              }
                           ]
                        }
                     ]
                  }
               }
            ],
            fee:{  
               amount:[  
                  {  
                     denom:"",
                     amount:"0"
                  }
               ],
               gas:"200000"
            },
            signatures:[  
               {  
                  pub_key:{  
                     type:"tendermint/PubKeySecp256k1",
                     value:"Aso+s1hyS8mhjVxH0TsVtEKe7jyq5XHY6e4UhnYXqWbI"
                  },
                  signature:{  
                     type:"tendermint/SignatureSecp256k1",
                     value:"MEQCIFRRELdb6gMV6ICRUXIF4BVCiKXiSEnZ2oGaQKkGeKZpAiA76pVmlFSlGco6O6cbMIcylq3KijF7dxY0e74HcikZvg=="
                  },
                  account_number:"0",
                  sequence:"2"
               }
            ],
            memo:""
         }
      },
      result:{  
         log:"Msg 0: ",
         gasUsed:"5029",
         tags:[  
            {  
               key:"c2VuZGVy",
               value:"Y29zbW9zYWNjYWRkcjFndGo5N3c0c3h6MGVhZGVtZW5jZmRqOG5lc215NGMzMDZhM2c1MA=="
            },
            {  
               key:"cmVjaXBpZW50",
               value:"Y29zbW9zYWNjYWRkcjE5enFubWFscmVhdWdqZjhteG01ejB4OTlldzQ5YW5naHhwdjN4NA=="
            }
         ],
         fee:{  

         }
      }
   }
]
  • Updated all relevant documentation in docs
  • Updated all code comments where relevant
  • Wrote tests
  • Updated CHANGELOG_PENDING.md

@codecov-io
Copy link

codecov-io commented Sep 4, 2018

Codecov Report

Merging #2324 into develop will increase coverage by 1.42%.
The diff coverage is 72.72%.

@@             Coverage Diff             @@
##           develop    #2324      +/-   ##
===========================================
+ Coverage    60.96%   62.39%   +1.42%     
===========================================
  Files          197      215      +18     
  Lines        16282    17645    +1363     
===========================================
+ Hits          9927    11010    +1083     
- Misses        5490     5723     +233     
- Partials       865      912      +47
Impacted Files Coverage Δ
state/txindex/kv/kv.go 75.21% <72.72%> (+0.43%) ⬆️
libs/common/math.go 7.95% <0%> (-35.8%) ⬇️
lite/multiprovider.go 50% <0%> (-14.11%) ⬇️
libs/db/go_level_db.go 65% <0%> (-1.67%) ⬇️
crypto/encoding/amino/amino.go 84.21% <0%> (-1.51%) ⬇️
libs/clist/clist.go 65.44% <0%> (-1.06%) ⬇️
consensus/state.go 76.58% <0%> (-0.83%) ⬇️
libs/autofile/autofile.go 69.23% <0%> (-0.47%) ⬇️
privval/priv_validator.go 69.44% <0%> (ø) ⬆️
evidence/pool.go 56.14% <0%> (ø) ⬆️
... and 55 more

state/txindex/kv/kv.go Outdated Show resolved Hide resolved
state/txindex/kv/kv.go Outdated Show resolved Hide resolved
state/txindex/kv/kv.go Outdated Show resolved Hide resolved
@ackratos
Copy link
Contributor Author

ackratos commented Sep 4, 2018

@melekes review comments have been fixed, would you like review again?

Copy link
Contributor

@melekes melekes left a comment

Choose a reason for hiding this comment

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

🥇 🏎 🍰

@melekes
Copy link
Contributor

melekes commented Sep 5, 2018

Could you add a changelog entry to CHANGELOG_PENDING.md file?

@ackratos
Copy link
Contributor Author

ackratos commented Sep 5, 2018

Could you add a changelog entry to CHANGELOG_PENDING.md file?

done~

@ebuchman
Copy link
Contributor

ebuchman commented Sep 5, 2018

THANKS!

@webmaster128
Copy link

Does this add support for range searches? E.g. tx.height>100, tx.height<100, tx.height>=100, tx.height<=100? Those seem to not work in Tendermint 0.25.0

@melekes
Copy link
Contributor

melekes commented Nov 21, 2018

@webmaster128 it does, but there's an issue #2759

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants