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

Add sequence and account number in tx #4713

Closed
ggomma opened this issue Jul 12, 2019 · 6 comments
Closed

Add sequence and account number in tx #4713

ggomma opened this issue Jul 12, 2019 · 6 comments

Comments

@ggomma
Copy link

ggomma commented Jul 12, 2019

Currently the transaction stored in blockchain doesn't contain sequence and account number.
So when user retrieve the transaction from blockchain or DB, user can check that the signature and hash match. But user can not verify whether the hash is correctly calculated from the transaction.

I know that there's no critical issue event if the transaction in the DB does not contain those number. But it would be much better that response(tx in DB) holds sequence and account number.

{
  "height": "160",
  "txhash": "38BD9F10563C1B9AB25BBB59B973C756948E98CC308A61CED07ADC10B686C88C",
  "raw_log": "[{\"msg_index\":\"0\",\"success\":true,\"log\":\"\"}]",
  "logs": [
    {
      "msg_index": "0",
      "success": true,
      "log": ""
    }
  ],
  "gas_wanted": "200000",
  "gas_used": "28051",
  "tags": [
    {
      "key": "action",
      "value": "send"
    },
    {
      "key": "sender",
      "value": "cosmos14ctrut3mspm5wq4jd0h9lxwve5t5e9f2wrgjjc"
    },
    {
      "key": "recipient",
      "value": "cosmos1rfpar0qx3umnhu0f6wjp4hvnr3x6u538qdmsep"
    }
  ],
  "tx": {
    "type": "auth/StdTx",
    "value": {
      "msg": [
        {
          "type": "cosmos-sdk/MsgSend",
          "value": {
            "from_address": "cosmos14ctrut3mspm5wq4jd0h9lxwve5t5e9f2wrgjjc",
            "to_address": "cosmos1rfpar0qx3umnhu0f6wjp4hvnr3x6u538qdmsep",
            "amount": [
              {
                "denom": "atom",
                "amount": "15"
              }
            ]
          }
        }
      ],
      "fee": {
        "amount": [
          {
            "denom": "atom",
            "amount": "20"
          }
        ],
        "gas": "200000"
      },
      "signatures": [
        {
          "pub_key": {
            "type": "tendermint/PubKeySecp256k1",
            "value": "AyJIaRZC58qh7BWF4NXZyPVTfo4Dlwxl3quO0WnP5euh"
          },
          "signature": "59wIqV0UgF/prfUn2qiToUvfqslDVzk8+xvoJi8+TuRICg+KEEksyyNQJOX0dc8TBG8HzCWcDwog5zUvudDwLg=="
        }
      ],
      "memo": ""
    }
  },
  "timestamp": "2019-07-10T08:04:17Z"
}
@alexanderbez
Copy link
Contributor

Thanks for opening an issue @ggomma. But we intentionally removed the sequence and account numbers from the StdSignature. This was mainly done because it was redundant and to save on state storage.

However, perhaps we can inject the account and sequence numbers when they're queried for. But this won't work when nodes are pruning.

@willclarktech
Copy link

willclarktech commented Oct 24, 2019

I'm working on a multi-chain TypeScript library and trying to add support for Cosmos. This is really an issue for us. It doesn't matter whether these numbers are coming directly from the database or being injected, but if we don't get them when we query for a transaction we can't verify the signature. Pruning nodes are not really a consideration for us.

@alexanderbez
Copy link
Contributor

alexanderbez commented Oct 24, 2019

@willclarktech we'd have to inject it by doing a query for the signing account(s). Adding it back to StdSignature is out of the question at this point I think.

That being said, the work required to inject can easily be done by your library/app. In other words, the way the SDK would do this would be the exact same way an app/library would: for every tx signer s, query for account s at tx height h.

This isn't to say the SDK won't do this, but just not likely anytime soon. Would be happy to review and merged a PR though!

@willclarktech
Copy link

willclarktech commented Oct 24, 2019

@alexanderbez I didn't realise you could query an account relative to a tx height, thanks! Is this possible via e.g the Gaia-Lite REST API or only via RPC?

EDIT: I found it by experimenting: ?tx.height=xxx works for the REST API. It would be nice to have this documented in the Swagger config.

@alexanderbez
Copy link
Contributor

Yes, you can. Just append the ?height=X query param. We're working on revamping our entire swagger doc flow. See here.

@ggomma
Copy link
Author

ggomma commented Mar 13, 2020

Thanks for your comment. @alexanderbez

@ggomma ggomma closed this as completed Mar 13, 2020
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

No branches or pull requests

3 participants