iotaledger / iri

IOTA Reference Implementation
Other
1.15k stars 370 forks source link

calling `getBalances` with an empty DB fails due to `tip` paramter #618

Open alon-e opened 6 years ago

alon-e commented 6 years ago

Bug description

when running a node with an empty database, calls to getBalances fail with the following error:

{"error":"Tip not found: 999999999999999999999999999999999999999999999999999999999999999999999999999999999","duration":10}

this is due to an edge case in: https://github.com/iotaledger/iri/blob/dev/src/main/java/com/iota/iri/service/API.java#L886 pointing tip to 999... and then not finding it in the DB: https://github.com/iotaledger/iri/blob/dev/src/main/java/com/iota/iri/service/API.java#L906

Hardware Spec

N/A

Steps To Reproduce

  1. run node without a DB
  2. call:
      curl http://localhost:14265 \
      -X POST \
      -H 'Content-Type: application/json' \
      -d '{"command": "getBalances", "addresses": ["HBBYKAKTILIPVUKFOTSLHGENPTXYBNKXZFQFR9VQFWNBMTQNRVOUKPVPRNBSZVVILMAFBKOTBLGLWLOHQ"], "threshold": 100}'

    Expected behaviour

    no failure, if the address is in the snapshot the value should appear, else 0.

Actual behavior

{"error":"Tip not found: 999999999999999999999999999999999999999999999999999999999999999999999999999999999","duration":10}

Errors

{"error":"Tip not found: 999999999999999999999999999999999999999999999999999999999999999999999999999999999","duration":10}
mkhudyakov commented 6 years ago

Hello, is there a possibility to overcome the issue, considering the private IOTA network and thus, empty DB. Any workaround?

gcameo commented 4 years ago

I am running IOTA locally and hitting this issue. Is there a work around?

GalRogozinski commented 4 years ago

Just to understand the priority of the issue from your perspectives @gcameo and @mkhudyakov.

Why do you care about the balance of a node with an empty db?