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

panic: runtime error: index out of range [0] with length 0 #234

Closed
snow884 opened this issue Jan 11, 2023 · 15 comments
Closed

panic: runtime error: index out of range [0] with length 0 #234

snow884 opened this issue Jan 11, 2023 · 15 comments

Comments

@snow884
Copy link

snow884 commented Jan 11, 2023

I was running tarod for a long time - about 1 day creating about 3 transactions and minting a currency.

I randomly got this error when trying to pay a taro invoice.

2023-01-10 13:14:54.600 [DBG] FRTR: Got chain confirmation: 5e8635f6f7b4217f71f6cd218b94c68425f1d821dd845022a50e9e289bc8a02a
2023-01-10 13:14:54.601 [INF] FRTR: Importing receiver proof into local Proof Archive
2023-01-10 13:14:54.602 [DBG] FRTR: Updated proofs for sender and receiver (new_len=2)
2023-01-10 13:14:54.602 [INF] FRTR: Marking parcel (txid=5e8635f6f7b4217f71f6cd218b94c68425f1d821dd845022a50e9e289bc8a02a) as confirmed!
2023-01-10 13:14:54.602 [INF] PROF: Attempting to deliver receiver proof for send of asset_id=8717aa4830df7b7c3b78d79577527b9dcc9298e3a59a6acddf6366cd67c32c4c, amt=111
2023-01-10 13:14:54.602 [INF] PROF: Creating sender mailbox w/ sid=ba9e8e46fa9af2ea12c6e6be4c9af1b47de74f5de8239560a6ea86bd76d6223d25fe85a444ca35abb6465ba30a0af21431d3ee23234aa19f53e9322c1593835c
panic: runtime error: index out of range [0] with length 0

goroutine 3008 [running]:
github.com/lightninglabs/taro/tarodb.(*AssetStore).ConfirmParcelDelivery.func1({0x18dc548, 0xc00004e5c0})
        /home/ec2-user/taro/tarodb/assets_store.go:1579 +0x811
github.com/lightninglabs/taro/tarodb.(*TransactionExecutor[...]).ExecTx(0xc00000e090, {0x18cfa90, 0xc000ba5dc0?}, {0x18c1ac0?, 0xc000c1dab8?}, 0xc00072dcc0?)
        /home/ec2-user/taro/tarodb/interfaces.go:115 +0xe7
github.com/lightninglabs/taro/tarodb.(*AssetStore).ConfirmParcelDelivery(0xc0002eb3b0, {0x18cfa90?, 0xc000ba5dc0}, 0xc00050ed20)
        /home/ec2-user/taro/tarodb/assets_store.go:1570 +0x187
github.com/lightninglabs/taro/tarofreighter.(*ChainPorter).waitForPkgConfirmation(0xc000713bf0, 0xc000116270)
        /home/ec2-user/taro/tarofreighter/chain_porter.go:450 +0x1987
created by github.com/lightninglabs/taro/tarofreighter.(*ChainPorter).taroPorter
        /home/ec2-user/taro/tarofreighter/chain_porter.go:243 +0x4dc

when I try to restart tarod I get the error:


$ tarod --network=testnet --debuglevel=debug --lnd.host=localhost:10009 --lnd.macaroonpath=/home/ec2-user/.lnd/data/chain/bitcoin/testnet/admin.macaroon --lnd.tlspath=/home/ec2-user/.lnd/tls.cert --tarodir=/home/ec2-user/.taro --rpclisten=127.0.0.1:10029 --restlisten=127.0.0.1:8089 --batch-minting-interval="1s"
2023-01-11 10:09:42.695 [WRN] CONF: open /home/ec2-user/.taro/taro.conf: no such file or directory
2023-01-11 10:09:42.697 [INF] CONF: Opening sqlite3 database at: /home/ec2-user/.taro/data/testnet/taro.db
2023-01-11 10:09:42.710 [INF] CONF: Attempting to establish connection to lnd...
2023-01-11 10:09:42.825 [INF] CONF: lnd connection initialized
2023-01-11 10:09:42.825 [INF] SRVR: Version: 0.1.99-alpha commit=v0.1.1-alpha-107-ge40c078, build=production, logging=default, debuglevel=debug
2023-01-11 10:09:42.825 [INF] SRVR: Active network: testnet3
2023-01-11 10:09:42.826 [INF] RPCS: Validating RPC requests based on macaroon at: /home/ec2-user/.taro/data/testnet/admin.macaroon
2023-01-11 10:09:42.826 [INF] RPCS: RPC server listening on 127.0.0.1:10029
2023-01-11 10:09:42.828 [INF] RPCS: gRPC proxy started at 127.0.0.1:8089
2023-01-11 10:09:42.828 [INF] GRDN: Starting ChainPlanter
2023-01-11 10:09:42.829 [INF] GRDN: Retrieved 0 non-finalized batches from DB
2023-01-11 10:09:42.829 [INF] GRDN: Starting asset custodian
2023-01-11 10:09:42.829 [INF] FRTR: Starting ChainPorter
2023-01-11 10:09:42.830 [INF] FRTR: Resuming delivery of 1 pending asset parcels
2023-01-11 10:09:42.830 [INF] RPCS: Starting RPC Server
2023-01-11 10:09:42.830 [INF] SRVR: Taro Daemon fully active!
2023-01-11 10:09:42.830 [INF] GRDN: Gardener for ChainPlanter now active!
2023-01-11 10:09:42.830 [DBG] GRDN: Subscribing to new on-chain transactions
2023-01-11 10:09:42.830 [INF] FRTR: Attempting to resume delivery to anchor_point=dcd539d3fcc820288fd1970bcfa70f3ee9414bd0875637d815d50115ac02aa2f:0
2023-01-11 10:09:42.830 [INF] FRTR: ChainPorter advancing from state=SendStateBroadcast to state=SendStateBroadcast
2023-01-11 10:09:42.833 [INF] GRDN: Loading pending inbound asset events
2023-01-11 10:09:42.835 [INF] FRTR: Broadcasting new transfer tx, taro_anchor_output=(*wire.TxOut)(0xc00085cba0)({
 Value: (int64) 1000,
 PkScript: ([]uint8) (len=34 cap=34) {
  00000000  51 20 56 ba 41 6a 90 93  61 c0 2a bc 93 71 94 7d  |Q V.Aj..a.*..q.}|
  00000010  9b 93 7c 13 bf cc 83 09  05 83 3e b7 1b bc 8e 52  |..|.......>....R|
  00000020  b8 b6                                             |..|
 }
})

2023-01-11 10:09:42.836 [INF] GRDN: Resuming 3 pending inbound asset events
2023-01-11 10:09:42.837 [ERR] SRVR: Shutting down because error in main method: received critical error from subsystem: error fetching asset proof: sql: no rows in result set
2023-01-11 10:09:42.837 [INF] RPCS: Stopping RPC Server
2023-01-11 10:09:42.837 [INF] SRVR: Shutdown complete

received critical error from subsystem: error fetching asset proof: sql: no rows in result set

I can se the following proofs:

$ls .taro/data/testnet/proofs/
805e048249e8e3ef9c1ba68ea46d9383ff1dea95da97d83c5158ab323d8e2e7a
8717aa4830df7b7c3b78d79577527b9dcc9298e3a59a6acddf6366cd67c32c4c
99bf61def907d19fe05483536e6d62a620aabd8dc5c48bcfff26bd9cf54afe8d
f9e55584f1f1ac2340c1863948ae7367a41eaef4a486353cbc5529ae199b6fcf
@guggero
Copy link
Member

guggero commented Jan 11, 2023

Thanks for the report. Looks like QueryAssetTransfers returns an empty result list but we try to access assetTransfers[0] anyway. @Roasbeef I thought sqlc would return ErrNoRows if there are no results? Or is that only returned for :one queries? We might have to revisit some of our queries.

@jharveyb
Copy link
Collaborator

Is each tarod connected to a separate lnd here?

@Roasbeef
Copy link
Member

@Roasbeef I thought sqlc would return ErrNoRows if there are no results? Or is that only returned for :one queries? We might have to revisit some of our queries.

Yeah that was my understanding as well. Looking at the logs, it looks like we did get the error (sql: no rows in result set) but didn't catch it properly?

@Roasbeef
Copy link
Member

The section in question: https://github.com/lightninglabs/taro/blob/main/tarodb/assets_store.go#L1571-L1579

First step would be a simple test to see what it returns if there's no output at all. There's an assumption here that for a given conf event, we already have an asset transfer entry on disk. Possible that's violated if something else fails upstream.

@jharveyb
Copy link
Collaborator

Based on the sqlc and sql package docs, I think @guggero is right, that error will only be passed for queries tagged with :one. So we should probably be length checking results from queries with :many.

@Roasbeef
Copy link
Member

@jharveyb good eye!

@aivansky-contractor
Copy link

Hi @Roasbeef @guggero ,

is this a non-standard configuration on my end or is this an actual issue and I should wait for a fix please ?

I keep getting this error repeatedly after making a certain number of mintings and transactions

@guggero
Copy link
Member

guggero commented Jan 17, 2023

It's an issue that needs to be fixed. Did you create your assets with the --enable_emission flag? If so, you can start over (delete the .taro directory) and re-create your assets without the flag, then I think you shouldn't run into this one (which seems to be a follow-up error anyway).

@aivansky-contractor
Copy link

aivansky-contractor commented Jan 17, 2023

Hi @guggero

I have used --enable_emission=false .

I tried deleting the .taro directory but the error keeps reoccurring after a certain number of mintings / transactions .

I will try again without selecting the flag

Also thanks a lot for developing this. Sadly I am not a Go coder. I will try to be as helpful as I can.

@guggero
Copy link
Member

guggero commented Jan 17, 2023

Yeah, the guide on that part was wrong, the --enable_emission=false notation doesn't actually work. So just omitting the flag completely should fix things (after deleting the data directory and of course restarting the Taro daemon).

@aivansky-contractor
Copy link

hmm... I keep getting the issue even when sending taro to myself repeatedly.

Removing the --enable_emission=false flag did not help.

@jharveyb
Copy link
Collaborator

To confirm, is this one tarod running where you mint and then send to the same tarod? Or two separate instances?

It looks like this is on testnet - are you waiting for a new block before trying the send, or doing it immediately after the minting? If you are not waiting for a new block, could you try that and see if the issue still appears?

@aivansky-contractor
Copy link

aivansky-contractor commented Jan 17, 2023

@jharveyb yes I confirm I am running only 1 tarod.

I am testing one idea I have. Minting currencies, creating invoices and paying them myself.

After I do this a few times this error occurs.

I am not using --enable_emission anywhere. I am using all arguments with =.

@aivansky-contractor
Copy link

@jharveyb

Let me try waiting for a new block between minting and sending

@jharveyb
Copy link
Collaborator

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

No branches or pull requests

5 participants