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

Use new REST client feature to get better simulation result object #1

Conversation

jasonpaulos
Copy link

@jasonpaulos jasonpaulos commented Apr 3, 2023

Summary

This PR uses the new REST client feature from algorand#5253 to allow the client to get msgpack simulation responses. With this, the client can decode to the more precise v2.PreEncodedSimulateResponse instead of model.SimulateResponse.

The only real difference between the two is that model.SimulateResponse uses map[string]interface{} to represent transactions. This is actually a minor problem, since our JSON decoder will decode large integers as float64, and this could make some responses look strange when goal clerk simulate re-encodes the JSON response. For example, this response adds .0 after integers in the signed transaction:

{
  "last-round": 921,
  "txn-groups": [
    {
      "app-budget-added": 700,
      "app-budget-consumed": 50,
      "failed-at": [
        1
      ],
      "failure-message": "transaction JZ75D2OJEKIUIKLCS2BIRI4JOCMKU5YDP6YADIGZSDZGB7ZZHV4Q: logic eval error: assert failed pc=285. Details: pc=285, opcodes=txnas Accounts\n==\nassert\n",
      "txn-results": [
        {
          "missing-signature": true,
          "txn-result": {
            "pool-error": "",
            "txn": {
              "txn": {
                "amt": 20000000.0,
                "fee": 1000.0,
                "fv": 903.0,
                "gen": "Default Network Template-v1",
                "gh": "9YlKpP21uyjwiWP9dW8qdgyrtXgj+11tFimt2zgzyL0=",
                "grp": "4vqZ9bYDtPUWspTMWjyfFDywcimjOp9vdRvOr+lD6Mw=",
                "lv": 1903.0,
                "note": "LdvdxHRNj64=",
                "rcv": "WCS6TVPJRBSARHLN2326LRU5BYVJZUKI2VJ53CAWKYYHDE455ZGKANWMGM",
                "snd": "KJXS3MA3OEBUAXDU4P6VTHFYEUQUKJYYGD4I2ORDFNZBQI7OOIOYBRH74A",
                "type": "pay"
              }
            }
          }
        },
        {
          "app-budget-consumed": 50,
          "missing-signature": true,
          "txn-result": {
            "pool-error": "",
            "txn": {
              "txn": {
                "apaa": [
                  "J7vOsg==",
                  "AA=="
                ],
                "apid": 1.0,
                "fee": 1000.0,
                "fv": 919.0,
                "gh": "9YlKpP21uyjwiWP9dW8qdgyrtXgj+11tFimt2zgzyL0=",
                "grp": "4vqZ9bYDtPUWspTMWjyfFDywcimjOp9vdRvOr+lD6Mw=",
                "lv": 1919.0,
                "note": "P2NnKKJRzNI=",
                "snd": "ILAZQ3YQUQKGMXTXICRP6422NFVTKLPNQZKHMZH4RSTDO6C7K6HH5VQBRY",
                "type": "appl"
              }
            }
          }
        }
      ]
    }
  ],
  "version": 1,
  "would-succeed": false
}

Test Plan

Note, I'm having issues running the new test in test/e2e-go/restAPI/restClient_test.go locally, since algod . I think this may be because it's running an older cached version from my machine

@ahangsu ahangsu requested review from ahangsu April 3, 2023 23:55
@jasonpaulos jasonpaulos closed this Apr 5, 2023
@jasonpaulos
Copy link
Author

Replaced by algorand#5259

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