engine icon indicating copy to clipboard operation
engine copied to clipboard

Wrong encoding for json structs

Open antho1404 opened this issue 5 years ago • 2 comments

The json format for structs is really different that the one in proto.

If you look at the input/output of the execution it is a lot different and it seems that there is no json for it (key capitalized for example). I also have issues with decoding when I try to create a transaction for execution probably based on the same issue.

grpcurl --proto ./protobuf/api/execution.proto -plaintext -d "{}" localhost:50052 mesg.api.Execution/List
{
  "executions": [
    {
      "hash": "bMQOhGl+I5wZzLYkm1t1YF9Y3ipDvyOK8Fy6xLmxZdA=",
      "eventHash": "Ut2R+SqBlxCgnr/Mrp+vukdbnFUiMELYe+rMX/xV8AI=",
      "status": "Completed",
      "instanceHash": "O2peT/5TBtIsZxwN5BmaMwk91xPVE7Zu2nrQ70osWyg=",
      "taskKey": "execute",
      "inputs": {
        "fields": {
          "code": {
            "stringValue": "module.export = inputs =\u003e inputs * 2"
          },
          "inputs": {
            "stringValue": "21"
          }
        }
      },
      "outputs": {
        "fields": {
          "result": {
            "numberValue": 42
          }
        }
      },
      "tags": [
        "CLI",
        "07242f36-5fb8-4aeb-96c4-c31212ec22f4"
      ],
      "executorHash": "RACKjlh5OILyGJtfHNKN5kAde8UJb/cDxOsEEWWicrE="
    }
  ]
}

vs

curl http://localhost:1317/execution/get/8KaReNzKWAN6Tvah8c5DcmHG7uJ76WDVL635zWMdidSo
{
  "height": "267",
  "result": {
    "hash": "8KaReNzKWAN6Tvah8c5DcmHG7uJ76WDVL635zWMdidSo",
    "parentHash": "",
    "eventHash": "6aUPZhmnFKiSsHXRaddbnqsKKi9KogbQNiKUcpivaohb",
    "status": 3,
    "instanceHash": "4zw8Mz2rUURbp33zRz8F7HcvFVoxtpLnmdpDpinNcRzw",
    "taskKey": "execute",
    "inputs": [
      {
        "Key": "code",
        "Value": {
          "Kind": {
            "type": "mesg.types.Value_StringValue",
            "value": {
              "string_value": "module.export = inputs => inputs * 2"
            }
          }
        }
      },
      {
        "Key": "inputs",
        "Value": {
          "Kind": {
            "type": "mesg.types.Value_StringValue",
            "value": {
              "string_value": "21"
            }
          }
        }
      }
    ],
    "outputs": [
      {
        "Key": "result",
        "Value": {
          "Kind": {
            "type": "mesg.types.Value_NumberValue",
            "value": {
              "number_value": 42
            }
          }
        }
      }
    ],
    "tags": [
      "CLI",
      "07242f36-5fb8-4aeb-96c4-c31212ec22f4"
    ],
    "processHash": "",
    "executorHash": "5aTCivi9sjtpwSxeFAMLD2rgTUHt3EC2etX383dgaPC4"
  }
}

antho1404 avatar Feb 25 '20 04:02 antho1404

@NicolasMahe lets see the result of the new proto codec in cosmos

NicolasMahe avatar Mar 10 '20 00:03 NicolasMahe

Cosmos-sdk is working on using proto instead of amino: https://github.com/cosmos/cosmos-sdk/issues/5444. This could fix a lot of things like this issue.

NicolasMahe avatar Mar 10 '20 05:03 NicolasMahe