blinklabs-io / cardano-node-api

Multi-protocol API for interfacing with a local Cardano node
Apache License 2.0
5 stars 0 forks source link

[UTXORPC] FollowTip nil pointer dereference error #208

Closed verbotenj closed 1 month ago

verbotenj commented 1 month ago

Block Info: SlotNumber: 65017606, Hash: 8838c502a02fdf9d9e20aaf45c7a5953e861de315ae8d23afb2f9150d40fb875

http2: panic serving 172.17.0.1:43120: runtime error: invalid memory address or nil pointer dereference
goroutine 83 [running]:
golang.org/x/net/http2.(*serverConn).runHandler.func1()
    /root/go/pkg/mod/golang.org/x/net@v0.27.0/http2/server.go:2407 +0x13c
panic({0x851180?, 0x18d9930?})
    /usr/lib/go/src/runtime/panic.go:914 +0x218
github.com/blinklabs-io/gouroboros/ledger.BabbageTransactionOutput.Utxorpc(...)
    /root/go/pkg/mod/github.com/blinklabs-io/gouroboros@v0.89.1/ledger/babbage.go:419
github.com/blinklabs-io/gouroboros/ledger.(*BabbageTransactionBody).Utxorpc(0x40006f8598)
    /root/go/pkg/mod/github.com/blinklabs-io/gouroboros@v0.89.1/ledger/babbage.go:241 +0x3c0
github.com/blinklabs-io/gouroboros/ledger.(*BabbageTransaction).Utxorpc(0x40006fa000?)
    /root/go/pkg/mod/github.com/blinklabs-io/gouroboros@v0.89.1/ledger/babbage.go:581 +0x24
github.com/blinklabs-io/gouroboros/ledger.(*BabbageBlock).Utxorpc(0x400078c4d0)
    /root/go/pkg/mod/github.com/blinklabs-io/gouroboros@v0.89.1/ledger/babbage.go:97 +0x3d0
github.com/blinklabs-io/cardano-node-api/internal/utxorpc.(*chainSyncServiceServer).FollowTip(0x40000afc68?, {0x779d0c?, 0x10?}, 0x881400?, 0x1c201?)
    /app/internal/utxorpc/sync.go:319 +0x1088
connectrpc.com/connect.NewServerStreamHandler[...].func1({0xffff4331dbd8, 0x4000518020})
    /root/go/pkg/mod/connectrpc.com/connect@v1.16.2/handler.go:133 +0xb4
connectrpc.com/connect.(*Handler).ServeHTTP(0x400051c700, {0xad1110, 0x400052e1d8}, 0x4000238400)
    /root/go/pkg/mod/connectrpc.com/connect@v1.16.2/handler.go:238 +0x6f0
github.com/utxorpc/go-codegen/utxorpc/v1alpha/sync/syncconnect.NewSyncServiceHandler.func1({0xad1110, 0x400052e1d8}, 0x4000238400)
    /root/go/pkg/mod/github.com/utxorpc/go-codegen@v0.6.0/utxorpc/v1alpha/sync/syncconnect/sync.connect.go:150 +0x124
net/http.HandlerFunc.ServeHTTP(0x4000102ea0?, {0xad1110?, 0x400052e1d8?}, 0x100080420?)
    /usr/lib/go/src/net/http/server.go:2136 +0x38
net/http.(*ServeMux).ServeHTTP(0x0?, {0xad1110, 0x400052e1d8}, 0x4000238400)
    /usr/lib/go/src/net/http/server.go:2514 +0x144
golang.org/x/net/http2.(*serverConn).runHandler(0x4000059f60?, 0x400010c1e0?, 0x0?, 0x4000059f70?)
    /root/go/pkg/mod/golang.org/x/net@v0.27.0/http2/server.go:2414 +0xfc
created by golang.org/x/net/http2.(*serverConn).scheduleHandler in goroutine 74
    /root/go/pkg/mod/golang.org/x/net@v0.27.0/http2/server.go:2348 +0x208
verbotenj commented 1 month ago

cardano-node-api:0.2.0 cardano-node:8.9.4 https://github.com/utxorpc/go-sdk

Test only blockHash

followTip(ctx, client, "235f9a217b826276d6cdfbb05c11572a06aef092535b6df8c682d501af59c230", -1, nil)

Server logs: {"level":"info","timestamp":"2024-07-15T00:59:40Z","caller":"api/api.go:96","msg":"starting metrics listener on :8081"} Got a FollowTip request with intersect [hash:"#_\x9a!{\x82bv\xd6\xcd\xfb\xb0\\x11W*\x06\xae\xf0\x92S[m\xf8Ƃ\xd5\x01\xafY\xc20"] ERROR: chain intersection not found

//Additional log from custom image Starting point: slot: 0, hash: 235f9a217b826276d6cdfbb05c11572a06aef092535b6df8c682d501af59c230 Expected following tip to succeed


Test blockHash and slot

followTip(ctx, client, "235f9a217b826276d6cdfbb05c11572a06aef092535b6df8c682d501af59c230", 65017558, nil)

Server logs:} runtime error: invalid memory address or nil pointer dereference

Expected following tip to succeed


Test only slot

followTip(ctx, client, "", 65017558, nil)

Got a FollowTip request with intersect [index:65017558] Intersect: [index:65017558], Len intersect: 1 Getting current tip Starting point: slot: 65324301, hash: 19d6f73b7bff659bc1010b18bf19e52aa0a5612d66b23e7bdecfa2a80eab6934

Expected following tip to succeed

Fails when reaches runtime error: invalid memory address or nil pointer dereference

verbotenj commented 1 month ago

Addressed nil dereference

verbotenj commented 1 month ago

cardano-node-api:local (gouroborus:v0.90.0) cardano-node:8.9.4 https://github.com/utxorpc/go-sdk https://github.com/utxorpc/go-sdk/pull/36 network: preprod

Test only blockHash

followTip(ctx, client, "235f9a217b826276d6cdfbb05c11572a06aef092535b6df8c682d501af59c230", -1, nil)

Server logs: 2024/07/18 13:00:28 Got a FollowTip request with intersect [hash:"#\x9a!{\x82bv\xd6\xcd\xfb\xb0\\x11W*\x06\xae\xf0\x92S[m\xf8Ƃ\xd5\x01\xafY\xc20"] 2024/07/18 13:00:28 Intersect: [hash:"#\x9a!{\x82bv\xd6\xcd\xfb\xb0\\x11W*\x06\xae\xf0\x92S[m\xf8Ƃ\xd5\x01\xafY\xc20"], Len intersect: 1 2024/07/18 13:00:28 BlockRef: idx: 0, Blockhash: 235f9a217b826276d6cdfbb05c11572a06aef092535b6df8c682d501af59c230 2024/07/18 13:00:28 Starting point: slot: 0, hash: 235f9a217b826276d6cdfbb05c11572a06aef092535b6df8c682d501af59c230 2024/07/18 13:00:28 ERROR: chain intersection not found

Expected: error: chain intersection not found status: pass In this particular case, if the block doesn't exist in the chain, it should return an intersection not found


Test blockHash and slot

followTip(ctx, client, "235f9a217b826276d6cdfbb05c11572a06aef092535b6df8c682d501af59c230", 65017558, nil)

CLient logs: Action: Apply Block Slot: 65045641, Block Hash: 5f929015ab29faaa4ad779c6b52ff3fb5a7a4b218e0f154b441dc7023275ca4a Action: Apply Block Slot: 65045663, Block Hash: 64276682f9870de43033de6b6c8ade086d57b893c501a3d8bad6253a47e25c8a Action: Apply Block Slot: 65045675, Block Hash: 796fb9a2bc56bb1c4ec4dabf91ebf85f3b3fa64f68be852d7400e55fa8d8253a

Expected following tip to succeed status: pass

Test only slot

followTip(ctx, client, "", 65017558, nil)

Blockref: 65017558, connecting to utxorpc host: http://localhost:9090 Connected to utxorpc host, following tip... Action: Apply Block Slot: 65624631, Block Hash: 0f930ac71ddce81075060b619a7edaf45ce2fdc76562a2fed1a2164140203764 Action: Apply Block Slot: 65624653, Block Hash: bdaba422576051b0fe10b527a569a58bc220636c818c922908bdd837cc2a406c

Expected following tip to succeed status: pass