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

Issue Report: Runtime Error with slice bounds out of range in 0g-storage-client #15

Closed
Josephtran102 opened this issue Jul 3, 2024 · 3 comments

Comments

@Josephtran102
Copy link

I encountered a runtime error when attempting to download a file using the 0g-storage-client with RPC endpoint STORAGE_RPC2 from VPS1. Here are the details:

1. Setup:
VPS 1 with RPC: STORAGE_RPC1="https://storage-node1.0gchain.josephtran.xyz/"
VPS 2 with RPC: STORAGE_RPC2="https://storage-node2.0gchain.josephtran.xyz/"

2. Run download:
On VPS 1, use the following command:

./0g-storage-client download --node $STORAGE_RPC2 --root 0xd5235f0ffe9c20d5eed863959ad7e7570437f6d6bb7a36b7a1574afe946457b4 --file /root/0g-storage-client/out3.test.txt

The following error occurs:

panic: runtime error: slice bounds out of range [:-243]

goroutine 16 [running]:
github.com/0glabs/0g-storage-client/transfer.(*SegmentDownloader).ParallelDo(0xc000521740, 0xc000521708, 0x0)
        /root/0g-storage-client/transfer/download_parallel.go:107 +0x905
github.com/0glabs/0g-storage-client/common/parallel.work({0xdfe300, 0xc0003f1860}, 0x0, {0xdfac20, 0xc000512f00}, 0xc0002659d0, 0xc000512f60, 0xc00036e2f1)
        /root/0g-storage-client/common/parallel/serial.go:59 +0x131
created by github.com/0glabs/0g-storage-client/common/parallel.Serial in goroutine 1
        /root/0g-storage-client/common/parallel/serial.go:37 +0x1bf

3. Additional Information:
Using RPC endpoint STORAGE_RPC1 on VPS 1 works as expected without any errors.

RPC endpoint STORAGE_RPC2 has been tested independently using curl and download function correctly.

root@vmi1810073:~/0g-storage-client# curl -X POST $STORAGE_RPC2 -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"zgs_getStatus","params":[],"id":1}'  | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   223  100   162  100    61    197     74 --:--:-- --:--:-- --:--:--   274

Result:

{
  "jsonrpc": "2.0",
  "result": {
    "connectedPeers": 46,
    "logSyncHeight": 125836,
    "logSyncBlock": "0x8a528b56863e30c50333c23dea5db82e91bee2f2ed1028d5945669cedd364809"
  },
  "id": 1
}

4. Further Testing:
I tested using STORAGE_RPC1 on VPS 2 and encountered no issues. The file downloaded successfully without errors.

*Environment:

Operating System: Linux (Ubuntu 22.04.4 LTS)
Go version: go1.22.0 linux/amd64

This issue seems to be specific to how 0g-storage-client interacts with data from RPC endpoint STORAGE_RPC2 on VPS 1. Please investigate and provide guidance on resolving this issue.

@MiniFrenchBread
Copy link
Contributor

Hi @Josephtran102 , Thanks for reporting this!

The data you are querying for is missing on the storage node behind STORAGE_RPC2, meanwhile the client did not handle the returned empty data properly. This issue will be fixed in an upcoming PR.

@MiniFrenchBread
Copy link
Contributor

added checks for downloaded data in #16

@Josephtran102
Copy link
Author

Thanks @MiniFrenchBread

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

2 participants