oasisprotocol / oasis-rosetta-gateway

The official Rosetta server implementation for the Oasis Network.
Apache License 2.0
21 stars 9 forks source link

Reclaim Escrow runtime error #424

Closed rocco-piovani closed 1 year ago

rocco-piovani commented 1 year ago

Hi all. I succesfully use the rosetta-getaway to send tokens, see balances and add esrcow, but when i try to "reclaim escrow" and i send my request to the endpoint '/construction/payloads', I get this error: ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')).

Looking at the rosetta-gateway log i get this:

level=debug ts=2023-02-23T16:05:20.078038049Z caller=network.go:50 module=services/network msg="NetworkList OK" response="{\"network_identifiers\":[{\"b
lockchain\":\"Oasis\",\"network\":\"50304f98ddb656620ea817cc1446c401752a05a249b36c9b90dba4616829977a\"}]}"
level=debug ts=2023-02-23T16:05:20.205111422Z caller=network.go:50 module=services/network msg="NetworkList OK" response="{\"network_identifiers\":[{\"b
lockchain\":\"Oasis\",\"network\":\"50304f98ddb656620ea817cc1446c401752a05a249b36c9b90dba4616829977a\"}]}"
level=debug ts=2023-02-23T16:05:20.40966378Z caller=construction.go:418 module=services/construction msg="ConstructionPreprocess OK" response="{\"option
s\":{\"id\":\"oasis1qp52kdehfuzu7vqn26exfwfy3grmgprh9supkc2s\"}}"
level=debug ts=2023-02-23T16:05:20.615197418Z caller=network.go:50 module=services/network msg="NetworkList OK" response="{\"network_identifiers\":[{\"b
lockchain\":\"Oasis\",\"network\":\"50304f98ddb656620ea817cc1446c401752a05a249b36c9b90dba4616829977a\"}]}"                                              level=debug ts=2023-02-23T16:05:20.817717349Z caller=construction.go:109 module=services/construction msg="ConstructionMetadata OK" response="{\"metadat
a\":{\"nonce\":10}}"
2023/02/23 17:05:22 http: panic serving 93.36.247.128:49787: runtime error: invalid memory address or nil pointer dereference
goroutine 82 [running]:
net/http.(*conn).serve.func1()
        net/http/server.go:1850 +0xbf
panic({0xbfb4a0, 0x13a16b0})
        runtime/panic.go:890 +0x262
github.com/oasisprotocol/oasis-rosetta-gateway/services.readCurrency(0x100c00003d260?, 0x7fce8977c538?, 0x0?)
        github.com/oasisprotocol/oasis-rosetta-gateway/services/operations.go:342 +0x18
github.com/oasisprotocol/oasis-rosetta-gateway/services.readOasisCurrencyNeg(...)
        github.com/oasisprotocol/oasis-rosetta-gateway/services/operations.go:364
github.com/oasisprotocol/oasis-rosetta-gateway/services.getStakingTransfer({0xc000089a70?, 0x2?, 0x2e?})
        github.com/oasisprotocol/oasis-rosetta-gateway/services/operations.go:370 +0x65
github.com/oasisprotocol/oasis-rosetta-gateway/services.(*operationToTransactionMapper).GetTransaction(0xc000269870)
        github.com/oasisprotocol/oasis-rosetta-gateway/services/operations.go:563 +0x251                                                                github.com/oasisprotocol/oasis-rosetta-gateway/services.(*constructionAPIService).ConstructionPayloads(0xc000225600?, {0xec3c40?, 0xc00027d530?}, 0xc000
402700)
        github.com/oasisprotocol/oasis-rosetta-gateway/services/construction.go:459 +0x1e5
github.com/coinbase/rosetta-sdk-go/server.(*ConstructionAPIController).ConstructionPayloads(0xc000012c60, {0xec32d0, 0xc0001a6620}, 0xc000422200)
        github.com/coinbase/rosetta-sdk-go@v0.8.1/server/api_construction.go:270 +0x1b6
net/http.HandlerFunc.ServeHTTP(0xc000422100?, {0xec32d0?, 0xc0001a6620?}, 0xc00007d9e0?)
        net/http/server.go:2109 +0x2f
github.com/gorilla/mux.(*Router).ServeHTTP(0xc0001a8180, {0xec32d0, 0xc0001a6620}, 0xc000422000)
        github.com/gorilla/mux@v1.8.0/mux.go:210 +0x1cf
net/http.serverHandler.ServeHTTP({0xec0a60?}, {0xec32d0, 0xc0001a6620}, 0xc000422000)
        net/http/server.go:2947 +0x30c
net/http.(*conn).serve(0xc00023ce60, {0xec3c40, 0xc00025a060})
        net/http/server.go:1991 +0x607
created by net/http.(*Server).Serve
        net/http/server.go:3102 +0x4db

Can anyone help?

pro-wh commented 1 year ago

sounds like from the stack trace that you didn't enter an amount in the 'from' operation. could be operations[2] or operations[0] if you aren't including a transaction fee. make sure you follow the template here https://github.com/oasisprotocol/oasis-rosetta-gateway#staking-transfer

we should fix the nil dereference crash though. thanks for reporting

rocco-piovani commented 1 year ago

Thanks for the quick response. i was setting the fees to 0. I changed it but it still gives the same error. Following the template for the reclaim escrow operation there is no "amount" on operations [2] and [3] but only

"metadata": {
            "reclaim_escrow_shares": amount_sh.toString()
        }

in operation[3].

rocco-piovani commented 1 year ago

I found the error. it was an error on the documentation. the type for the third and fourth block of the "operations" input has to be "ReclaimEscrow" instead of "Transfer". I made a Pull request #425 from another account.

pro-wh commented 1 year ago

oh you're right

pro-wh commented 1 year ago

corrected in #427