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

Can't parse a tx (Any). Get a signature error #151

Closed
andynog opened this issue Oct 29, 2021 · 2 comments · Fixed by #164
Closed

Can't parse a tx (Any). Get a signature error #151

andynog opened this issue Oct 29, 2021 · 2 comments · Fixed by #164

Comments

@andynog
Copy link

andynog commented Oct 29, 2021

Upgrade to cosmos v0.3, and now when trying to parse a tx I'm getting a signature error

This line is where the error is thrown https://github.com/andynog/cosmrs-tx-example/blob/0f25f3e00cfbff3367e451098809d9739d3c77ca/src/main.rs#L52

When running I get:

Getting messages for transactions in height 5258498
Error converting tx: Block 5258498 - Height "E4AD2D2B27CB57AA2B273F4E872B3BC83D9E189B670AAEFDB50A790974D18FE1" - Error: signature error

Location:
    /rustc/09c42c45858d5f3aedfa670698275303a3d19afa/library/core/src/result.rs:1915:27

the TxResponse has a tx property that is an Option<Any>, so I try to get the value as bytes

let tx_result = Tx::from_bytes(tx.value.as_slice());

So it is most likely failing to decode the bytes into the Tx proto in the code below ?

impl TryFrom<&[u8]> for Tx {
    type Error = ErrorReport;

    fn try_from(bytes: &[u8]) -> Result<Tx> {
        proto::cosmos::tx::v1beta1::Tx::decode(bytes)?.try_into()
    }
}

Here's the transactions details (with bytes at the end):

{
  "jsonrpc": "2.0",
  "id": -1,
  "result": {
    "hash": "E4AD2D2B27CB57AA2B273F4E872B3BC83D9E189B670AAEFDB50A790974D18FE1",
    "height": "5258498",
    "index": 0,
    "tx_result": {
      "code": 0,
      "data": "CgYKBHNlbmQ=",
      "log": "[{\"events\":[{\"type\":\"message\",\"attributes\":[{\"key\":\"action\",\"value\":\"send\"},{\"key\":\"sender\",\"value\":\"cosmos16plylpsgxechajltx9yeseqexzdzut9g8vla4k\"},{\"key\":\"module\",\"value\":\"bank\"}]},{\"type\":\"transfer\",\"attributes\":[{\"key\":\"recipient\",\"value\":\"cosmos13pmeycgs4snkpyplwz3t8vfaupj2sya62z6k49\"},{\"key\":\"sender\",\"value\":\"cosmos16plylpsgxechajltx9yeseqexzdzut9g8vla4k\"},{\"key\":\"amount\",\"value\":\"1900000000uatom\"}]}]}]",
      "info": "",
      "gas_wanted": "200000",
      "gas_used": "102272",
      "events": [
        {
          "type": "transfer",
          "attributes": [
            {
              "key": "cmVjaXBpZW50",
              "value": "Y29zbW9zMTd4cGZ2YWttMmFtZzk2MnlsczZmODR6M2tlbGw4YzVsc2VycXRh",
              "index": true
            },
            {
              "key": "c2VuZGVy",
              "value": "Y29zbW9zMTZwbHlscHNneGVjaGFqbHR4OXllc2VxZXh6ZHp1dDlnOHZsYTRr",
              "index": true
            },
            {
              "key": "YW1vdW50",
              "value": "MjUwMDB1YXRvbQ==",
              "index": true
            }
          ]
        },
        {
          "type": "message",
          "attributes": [
            {
              "key": "c2VuZGVy",
              "value": "Y29zbW9zMTZwbHlscHNneGVjaGFqbHR4OXllc2VxZXh6ZHp1dDlnOHZsYTRr",
              "index": true
            }
          ]
        },
        {
          "type": "message",
          "attributes": [
            {
              "key": "YWN0aW9u",
              "value": "c2VuZA==",
              "index": true
            }
          ]
        },
        {
          "type": "transfer",
          "attributes": [
            {
              "key": "cmVjaXBpZW50",
              "value": "Y29zbW9zMTNwbWV5Y2dzNHNua3B5cGx3ejN0OHZmYXVwajJzeWE2Mno2azQ5",
              "index": true
            },
            {
              "key": "c2VuZGVy",
              "value": "Y29zbW9zMTZwbHlscHNneGVjaGFqbHR4OXllc2VxZXh6ZHp1dDlnOHZsYTRr",
              "index": true
            },
            {
              "key": "YW1vdW50",
              "value": "MTkwMDAwMDAwMHVhdG9t",
              "index": true
            }
          ]
        },
        {
          "type": "message",
          "attributes": [
            {
              "key": "c2VuZGVy",
              "value": "Y29zbW9zMTZwbHlscHNneGVjaGFqbHR4OXllc2VxZXh6ZHp1dDlnOHZsYTRr",
              "index": true
            }
          ]
        },
        {
          "type": "message",
          "attributes": [
            {
              "key": "bW9kdWxl",
              "value": "YmFuaw==",
              "index": true
            }
          ]
        }
      ],
      "codespace": ""
    },
    "tx": "CpYBCpMBChwvY29zbW9zLmJhbmsudjFiZXRhMS5Nc2dTZW5kEnMKLWNvc21vczE2cGx5bHBzZ3hlY2hhamx0eDl5ZXNlcWV4emR6dXQ5Zzh2bGE0axItY29zbW9zMTNwbWV5Y2dzNHNua3B5cGx3ejN0OHZmYXVwajJzeWE2Mno2azQ5GhMKBXVhdG9tEgoxOTAwMDAwMDAwEtMDCroDCpgDCikvY29zbW9zLmNyeXB0by5tdWx0aXNpZy5MZWdhY3lBbWlub1B1YktleRLqAggDEkYKHy9jb3Ntb3MuY3J5cHRvLnNlY3AyNTZrMS5QdWJLZXkSIwohAxbrmb4nOS4lje2D3BN45Qes8btyb6QHFn5wlGGzpjHLEkYKHy9jb3Ntb3MuY3J5cHRvLnNlY3AyNTZrMS5QdWJLZXkSIwohA2Pe6/E9MKmEDyddAZEfPgXz+1+IVU9Ssu9TTc4GsdpZEkYKHy9jb3Ntb3MuY3J5cHRvLnNlY3AyNTZrMS5QdWJLZXkSIwohAy4lPPghTz1GbtKWuZGYIa5mgYBskbPCBjpFqLhc5+EVEkYKHy9jb3Ntb3MuY3J5cHRvLnNlY3AyNTZrMS5QdWJLZXkSIwohAyb/0SvRFfJgo3Hy8JvykobkyWgce8EJ9GBMgu2C1tIyEkYKHy9jb3Ntb3MuY3J5cHRvLnNlY3AyNTZrMS5QdWJLZXkSIwohA0OjtIUCFJM3AobJ9HJTWKP9RZV2+WPcwVjLgsAidrZ/EhsSGQoFCAUSAcgSBAoCCH8SBAoCCH8SBAoCCH8YCxIUCg4KBXVhdG9tEgUyNTAwMBDAmgwaxgEKQI0PpGe+CH/OOwB88URkLXUzmyPVx6pNSGsn6uU3JhvKayaX20ptWCk/eCkPI/mTqaAcCCsmOR0wfOKK2SCSkvAKQFUwlZFWm9RAH4LEFNxIvROpmuWLi2mxGr3qfAVFHxPuVUAAzujseJEM63+3oJwzA4K1hOJezJVfdyPJsY3ASVYKQDVh/powvND7m4/I75SyuNVFfZaR/PMfcD/5xqXXe+DaNCV+Er4K8+sZoOuH8stVKt8w/sLFmRn0SYu0xdQljBE="
  }
}
@andynog
Copy link
Author

andynog commented Oct 29, 2021

Adding the tx bytes (tx.value.as_slice()) here from the Rust code just in case

[10, 150, 1, 10, 147, 1, 10, 28, 47, 99, 111, 115, 109, 111, 115, 46, 98, 97, 110, 107, 46, 118, 49, 98, 101, 116, 97, 49, 46, 77, 115, 103, 83, 101, 110, 100, 18, 115, 10, 45, 99, 111, 115, 109, 111, 115, 49, 54, 112, 108, 121, 108, 112, 115, 103, 120, 101, 99, 104, 97, 106, 108, 116, 120, 57, 121, 101, 115, 101, 113, 101, 120, 122, 100, 122, 117, 116, 57, 103, 56, 118, 108, 97, 52, 107, 18, 45, 99, 111, 115, 109, 111, 115, 49, 51, 112, 109, 101, 121, 99, 103, 115, 52, 115, 110, 107, 112, 121, 112, 108, 119, 122, 51, 116, 56, 118, 102, 97, 117, 112, 106, 50, 115, 121, 97, 54, 50, 122, 54, 107, 52, 57, 26, 19, 10, 5, 117, 97, 116, 111, 109, 18, 10, 49, 57, 48, 48, 48, 48, 48, 48, 48, 48, 18, 211, 3, 10, 186, 3, 10, 152, 3, 10, 41, 47, 99, 111, 115, 109, 111, 115, 46, 99, 114, 121, 112, 116, 111, 46, 109, 117, 108, 116, 105, 115, 105, 103, 46, 76, 101, 103, 97, 99, 121, 65, 109, 105, 110, 111, 80, 117, 98, 75, 101, 121, 18, 234, 2, 8, 3, 18, 70, 10, 31, 47, 99, 111, 115, 109, 111, 115, 46, 99, 114, 121, 112, 116, 111, 46, 115, 101, 99, 112, 50, 53, 54, 107, 49, 46, 80, 117, 98, 75, 101, 121, 18, 35, 10, 33, 3, 22, 235, 153, 190, 39, 57, 46, 37, 141, 237, 131, 220, 19, 120, 229, 7, 172, 241, 187, 114, 111, 164, 7, 22, 126, 112, 148, 97, 179, 166, 49, 203, 18, 70, 10, 31, 47, 99, 111, 115, 109, 111, 115, 46, 99, 114, 121, 112, 116, 111, 46, 115, 101, 99, 112, 50, 53, 54, 107, 49, 46, 80, 117, 98, 75, 101, 121, 18, 35, 10, 33, 3, 99, 222, 235, 241, 61, 48, 169, 132, 15, 39, 93, 1, 145, 31, 62, 5, 243, 251, 95, 136, 85, 79, 82, 178, 239, 83, 77, 206, 6, 177, 218, 89, 18, 70, 10, 31, 47, 99, 111, 115, 109, 111, 115, 46, 99, 114, 121, 112, 116, 111, 46, 115, 101, 99, 112, 50, 53, 54, 107, 49, 46, 80, 117, 98, 75, 101, 121, 18, 35, 10, 33, 3, 46, 37, 60, 248, 33, 79, 61, 70, 110, 210, 150, 185, 145, 152, 33, 174, 102, 129, 128, 108, 145, 179, 194, 6, 58, 69, 168, 184, 92, 231, 225, 21, 18, 70, 10, 31, 47, 99, 111, 115, 109, 111, 115, 46, 99, 114, 121, 112, 116, 111, 46, 115, 101, 99, 112, 50, 53, 54, 107, 49, 46, 80, 117, 98, 75, 101, 121, 18, 35, 10, 33, 3, 38, 255, 209, 43, 209, 21, 242, 96, 163, 113, 242, 240, 155, 242, 146, 134, 228, 201, 104, 28, 123, 193, 9, 244, 96, 76, 130, 237, 130, 214, 210, 50, 18, 70, 10, 31, 47, 99, 111, 115, 109, 111, 115, 46, 99, 114, 121, 112, 116, 111, 46, 115, 101, 99, 112, 50, 53, 54, 107, 49, 46, 80, 117, 98, 75, 101, 121, 18, 35, 10, 33, 3, 67, 163, 180, 133, 2, 20, 147, 55, 2, 134, 201, 244, 114, 83, 88, 163, 253, 69, 149, 118, 249, 99, 220, 193, 88, 203, 130, 192, 34, 118, 182, 127, 18, 27, 18, 25, 10, 5, 8, 5, 18, 1, 200, 18, 4, 10, 2, 8, 127, 18, 4, 10, 2, 8, 127, 18, 4, 10, 2, 8, 127, 24, 11, 18, 20, 10, 14, 10, 5, 117, 97, 116, 111, 109, 18, 5, 50, 53, 48, 48, 48, 16, 192, 154, 12, 26, 198, 1, 10, 64, 141, 15, 164, 103, 190, 8, 127, 206, 59, 0, 124, 241, 68, 100, 45, 117, 51, 155, 35, 213, 199, 170, 77, 72, 107, 39, 234, 229, 55, 38, 27, 202, 107, 38, 151, 219, 74, 109, 88, 41, 63, 120, 41, 15, 35, 249, 147, 169, 160, 28, 8, 43, 38, 57, 29, 48, 124, 226, 138, 217, 32, 146, 146, 240, 10, 64, 85, 48, 149, 145, 86, 155, 212, 64, 31, 130, 196, 20, 220, 72, 189, 19, 169, 154, 229, 139, 139, 105, 177, 26, 189, 234, 124, 5, 69, 31, 19, 238, 85, 64, 0, 206, 232, 236, 120, 145, 12, 235, 127, 183, 160, 156, 51, 3, 130, 181, 132, 226, 94, 204, 149, 95, 119, 35, 201, 177, 141, 192, 73, 86, 10, 64, 53, 97, 254, 154, 48, 188, 208, 251, 155, 143, 200, 239, 148, 178, 184, 213, 69, 125, 150, 145, 252, 243, 31, 112, 63, 249, 198, 165, 215, 123, 224, 218, 52, 37, 126, 18, 190, 10, 243, 235, 25, 160, 235, 135, 242, 203, 85, 42, 223, 48, 254, 194, 197, 153, 25, 244, 73, 139, 180, 197, 212, 37, 140, 17]

@tony-iqlusion
Copy link
Member

Right now it's using Vec<secp256k1::Signature> to model the signatures, which doesn't work with these Amino multisignatures.

I'd suggest changing that to be Vec<Vec<u8>> in the next breaking release, to support any signature type.

tony-iqlusion added a commit that referenced this issue Jan 6, 2022
Adds a `SignatureBytes` type alias for `Vec<u8>`, and changes
`Tx::signatures` to `Vec<SignatureBytes>`.

Previously signatures were being eagerly parsed as
`secp256k1::Signature`, but this prevents parsing other kinds of
signatures, such as Amino.

Closes #151
tony-iqlusion added a commit that referenced this issue Jan 7, 2022
Adds a `SignatureBytes` type alias for `Vec<u8>`, and changes
`Tx::signatures` to `Vec<SignatureBytes>`.

Previously signatures were being eagerly parsed as
`secp256k1::Signature`, but this prevents parsing other kinds of
signatures, such as Amino.

Closes #151
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 a pull request may close this issue.

2 participants