algorand / algorand/go-algorand

Panic calling dryrun endpoint

Open
#3,892 0 comments 0 reactions 0 assignees View on GitHub
Team Scytale
Dominant language
Go
Stars
1.4k
Forks
537
Avg merge
1d 6h
Merged PRs (30d)
17

Description

### Subject of the issue

Getting a "panic" error message when sending a dryrun request. I managed to reproduce it (the original request is quite large) with this smaller version (not necessarily the same issue):
```
{
"apps": [
{
"id": 34,
"params": {
"creator": "STOUDMINSIPP7JMJMGXVJYVS6HHD3TT5UODCDPYGV6KBGP7UYNTLJVJJME"
}
}
],
"txns": [
{
"txn": {
"apid": 34,
"gen": "sandnet-v1",
"snd:b64": "lN1BsQ2SHv+liWGvVOKy8c49zn2jhiG/Bq+UEz/0w2Y=",
"type": "appl"
}
}
]
}
```

The error:

```json
{
"error": "",
"protocol-version": "future",
"txns": [
{
"app-call-messages": [
"ApprovalProgram",
"REJECT",
"logic eval error: panic in TEAL Eval: runtime error: invalid memory address or nil pointer dereference\ngoroutine 2159 [running]:\ngithub.com/algorand/go-algorand/data/transactions/logic.eval.func1(0x400a581378, 0x40001f2500, 0x400a581380)\n\tgithub.com/algorand/go-algorand/data/transactions/logic/eval.go:651 +0x88\npanic({0x1173480, 0x1bd2dd0})\n\truntime/panic.go:1052 +0x2b4\ngithub.com/algorand/go-algorand/data/transactions/logic.(*EvalContext).refreshDebugState(0x40001f2500, {0x14b2e00, 0x4012e4e460})\n\tgithub.com/algorand/go-algorand/data/transactions/logic/debugger.go:229 +0x40\ngithub.com/algorand/go-algorand/data/transactions/logic.eval.func2(0x40001f2500, 0x400a581380)\n\tgithub.com/algorand/go-algorand/data/transactions/logic/eval.go:665 +0x4c\ngithub.com/algorand/go-algorand/data/transactions/logic.eval({0x0, 0x0, 0x0}, 0x40001f2500)\n\tgithub.com/algorand/go-algorand/data/transactions/logic/eval.go:683 +0x30c\ngithub.com/algorand/go-algorand/data/transactions/logic.EvalContract({0x0, 0x0, 0x0}, 0x0, 0x22, 0x400892c0c0)\n\tgithub.com/algorand/go-algorand/data/transactions/logic/eval.go:614 +0x28c\ngithub.com/algorand/go-algorand/ledger/internal.(*roundCowState).StatefulEval(0x40069d0800, 0x0, 0x400892c0c0, 0x22, {0x0, 0x0, 0x0})\n\tgithub.com/algorand/go-algorand/ledger/internal/appcow.go:467 +0x104\ngithub.com/algorand/go-algorand/daemon/algod/api/server/v2.doDryrunRequest(0x4012fac280, 0x400a584bf0)\n\tgithub.com/algorand/go-algorand/daemon/algod/api/server/v2/dryrun.go:509 +0xbe4\ngithub.com/algorand/go-algorand/daemon/algod/api/server/v2.(*Handlers).TealDryrun(0x4000169680, {0x14f7c70, 0x40000f9900})\n\tgithub.com/algorand/go-algorand/daemon/algod/api/server/v2/handlers.go:820 +0x60c\ngithub.com/algorand/go-algorand/daemon/algod/api/server/v2/generated.(*ServerInterfaceWrapper).TealDryrun(0x400053e570, {0x14f7c70, 0x40000f9900})\n\tgithub.com/algorand/go-algorand/daemon/algod/api/server/v2/generated/routes.go:560 +0x334\ngithub.com/algorand/go-algorand/daemon/algod/api/server/lib/middlewares.(*AuthMiddleware).handler.func1({0x14f7c70, 0x40000f9900})\n\tgithub.com/algorand/go-algorand/daemon/algod/api/server/lib/middlewares/auth.go:100 +0x5d0\ngithub.com/labstack/echo/v4.(*Echo).add.func1({0x14f7c70, 0x40000f9900})\n\tgithub.com/labstack/echo/v4@v4.1.17/echo.go:522 +0x5c\ngithub.com/labstack/echo/v4/middleware.CORSWithConfig.func1.1({0x14f7c70, 0x40000f9900})\n\tgithub.com/labstack/echo/v4@v4.1.17/middleware/cors.go:121 +0x5cc\ngithub.com/algorand/go-algorand/daemon/algod/api/server/lib/middlewares.(*LoggerMiddleware).handler.func1({0x14f7c70, 0x40000f9900})\n\tgithub.com/algorand/go-algorand/daemon/algod/api/server/lib/middlewares/logger.go:52 +0x9c\ngithub.com/labstack/echo/v4.(*Echo).ServeHTTP.func1({0x14f7c70, 0x40000f9900})\n\tgithub.com/labstack/echo/v4@v4.1.17/echo.go:627 +0x138\ngithub.com/labstack/echo/v4/middleware.RemoveTrailingSlashWithConfig.func1.1({0x14f7c70, 0x40000f9900})\n\tgithub.com/labstack/echo/v4@v4.1.17/middleware/slash.go:118 +0x220\ngithub.com/algorand/go-algorand/daemon/algod/api/server/lib/middlewares.MakeConnectionLimiter.func1.1({0x14f7c70, 0x40000f9900})\n\tgithub.com/algorand/go-algorand/daemon/algod/api/server/lib/middlewares/connectionLimiter.go:42 +0x8c\ngithub.com/labstack/echo/v4.(*Echo).ServeHTTP(0x400009a3c0, {0x14bf708, 0x4012cc00e0}, 0x4012c92100)\n\tgithub.com/labstack/echo/v4@v4.1.17/echo.go:633 +0x470\nnet/http.serverHandler.ServeHTTP({0x1c5eb40}, {0x14bf708, 0x4012cc00e0}, 0x4012c92100)\n\tnet/http/server.go:2879 +0x45c\nnet/http.(*conn).serve(0x400054e3c0, {0x14ccf48, 0x4000033dd0})\n\tnet/http/server.go:1930 +0xb54\ncreated by net/http.(*Server).Serve\n\tnet/http/server.go:3034 +0x4ac\n. Details: pc=0, opcodes="
],
"app-call-trace": null,
"cost": 0,
"disassembly": null
}
]
}
```

If I change the `txn` app id to something different - it works again, probably because it doesn't process the `apps` array?

While this request is not meaningful, and my original request probably has a serialization issue somewhere, the endpoint shouldn't panic and return a meaningful error message.

I'm not using any of the official SDKs. I'm trying to fix this endpoint for one of the community SDKs.

### Your environment

* Software version:
> sandbox goal version -v
> Version: [v1 v2]
> GenesisID: sandnet-v1
> Build: 3.5.142210.dev [master] (commit #8a5155ff)
(It also happens with the last release version v3.5.1-stable)

* Node status if applicable: `sandbox goal node status`

Last committed block: 26
Time since last block: 1441.4s
Sync Time: 0.0s
Last consensus protocol: future
Next consensus protocol: future
Round for next consensus protocol: 27
Next consensus protocol supported: true
Last Catchpoint:
Genesis ID: sandnet-v1
Genesis hash: 6ntkse3E9op0Suz+K7DNdbl9e8TU3GsnuI+HNfkj4fA=

* Operating System details.
MacOS 12.1 M1 Max

* In many cases log files and cadaver files are also useful to include. Since these files may be large, an Algorand developer may request them later. These files may include public addresses that you're participating with. If that is a concern please be sure to scrub that data.

### Steps to reproduce

1. Send a dry run POST request with this payload to `v2/teal/dryrun` (msg-pack endoded, with `application/x-binary` content type)
```
{
"apps": [
{
"id": 34,
"params": {
"creator": "STOUDMINSIPP7JMJMGXVJYVS6HHD3TT5UODCDPYGV6KBGP7UYNTLJVJJME"
}
}
],
"txns": [
{
"txn": {
"apid": 34,
"gen": "sandnet-v1",
"snd:b64": "lN1BsQ2SHv+liWGvVOKy8c49zn2jhiG/Bq+UEz/0w2Y=",
"type": "appl"
}
}
]
}
```

### Expected behaviour
There should be a regular error (in the `error` field of the dryrun response object, or perhaps a HTTP error), that helps understanding the problem.

### Actual behaviour
The response object's `error` field contains a panic message that seems not useful.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.