Skip to content
This repository has been archived by the owner on Jun 3, 2020. It is now read-only.

Support for block_results RPC method from Client #251

Closed
devashishdxt opened this issue May 9, 2019 · 3 comments
Closed

Support for block_results RPC method from Client #251

devashishdxt opened this issue May 9, 2019 · 3 comments

Comments

@devashishdxt
Copy link

devashishdxt commented May 9, 2019

Tendermint RPC Client does not have support for calling block_results RPC method.

Here's a list of all the supported methods.

@tarcieri
Copy link
Contributor

tarcieri commented Jun 18, 2019

I took a look at this. The JSON returned from the RPC endpoint differs significantly from what is documented.

From https://tendermint.com/rpc/#blockresults

{


    "height": "10",
    "results": [
     {
      "code": "0",
      "data": "CAFE00F00D"
     },
     {
      "code": "102",
      "data": ""
     }
    ]
}

This curiously seems to be missing the standard JSONRPC fields like jsonrpc, id, and result.

Here is the response I get from gaiad:

{
  "jsonrpc": "2.0",
  "id": "",
  "result": {
    "height": "20",
    "results": {
      "DeliverTx": [
        {
          "log": "[{\"msg_index\":\"0\",\"success\":true,\"log\":\"\"}]",
          "gasWanted": "200000",
          "gasUsed": "35433",
          "tags": [
            {
              "key": "YWN0aW9u",
              "value": "ZWRpdF92YWxpZGF0b3I="
            },
            {
              "key": "ZGVzdGluYXRpb24tdmFsaWRhdG9y",
              "value": "Y29zbW9zdmFsb3BlcjFyd2gwY3hhNzJkM3lsZTNyNGw4Z2Q3dnlwaHJtankya3BlNHg3Mg=="
            },
            {
              "key": "bW9uaWtlcg==",
              "value": "U3BhcmtQb29s"
            },
            {
              "key": "aWRlbnRpdHk=",
              "value": "REU4RTM3MjQwMDYxQjA0RQ=="
            }
          ]
        },
        {
          "log": "[{\"msg_index\":\"0\",\"success\":true,\"log\":\"\"}]",
          "gasWanted": "200000",
          "gasUsed": "81404",
          "tags": [
            {
              "key": "YWN0aW9u",
              "value": "ZGVsZWdhdGU="
            },
            {
              "key": "ZGVsZWdhdG9y",
              "value": "Y29zbW9zMThtY3E0bnA0MG5zYXE4eHozMHR0eWR3a240dXA2Z3JkdHh3eGNq"
            },
            {
              "key": "ZGVzdGluYXRpb24tdmFsaWRhdG9y",
              "value": "Y29zbW9zdmFsb3BlcjE0a24wa2szM3N6cHd1czluaDhuODdmamVsOGRqeDB5MDcweW1tag=="
            }
          ]
        }
      ],
      "EndBlock": {
        "validator_updates": [
          {
            "pub_key": {
              "type": "ed25519",
              "data": "2k346W3w8NFAQh21j1hBp+Mvur+ZhHFuEQk8DEOlN+c="
            },
            "power": "5010"
          }
        ]
      },
      "BeginBlock": {}
    }
  }
}

Looking at this:

https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/rpc/core/types/responses.go#L39

// ABCI results from a block
type ResultBlockResults struct {
	Height  int64                `json:"height"`
	Results *state.ABCIResponses `json:"results"`
}

and this:

https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/state/store.go#L114

// ABCIResponses retains the responses
// of the various ABCI calls during block processing.
// It is persisted to disk for each height before calling Commit.
type ABCIResponses struct {
	DeliverTx  []*abci.ResponseDeliverTx
	EndBlock   *abci.ResponseEndBlock
	BeginBlock *abci.ResponseBeginBlock
}

I can go ahead and implement it based on that. However what is presently documented appears to be wrong.

@tarcieri
Copy link
Contributor

tarcieri commented Jun 19, 2019

FWIW, I see there's already an open issue about the documentation:

tendermint/tendermint#3616

and a PR to fix it:

tendermint/tendermint#3708

...however it seems that PR also renamed the fields to be "snake case" (e.g. deliver_tx) instead of CamelCase (e.g. DeliverTx).

I think I can go ahead and impl it with the old names, and update it to the new ones later.

cc @melekes

@tarcieri
Copy link
Contributor

Added in #267. Will be released shortly as tendermint crate v0.8.0.

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

No branches or pull requests

2 participants