Qoracoin / Qora

Public GIT for the Qora cryptocurrency project.
http://qora.org
Other
43 stars 24 forks source link

ArbitraryTransaction ERROR #57

Closed agran closed 6 years ago

agran commented 8 years ago

016-03-24 17:40:33 ERROR ArbitraryTransaction:225 - org.json.simple.JSONObject cannot be cast to java.lang.String java.lang.ClassCastException: org.json.simple.JSONObject cannot be cast to java.lang.String at utils.StorageUtils.getKeys(StorageUtils.java:288) at utils.StorageUtils.getAllKeysForOrphanSaving(StorageUtils.java:276) at utils.StorageUtils.processUpdate(StorageUtils.java:136) at qora.transaction.ArbitraryTransaction.process(ArbitraryTransaction.java:213) at qora.block.Block.isValid(Block.java:694) at qora.block.Block.isValid(Block.java:571) at qora.Synchronizer.process(Synchronizer.java:339) at qora.Synchronizer.synchronize(Synchronizer.java:195) at controller.Controller.update(Controller.java:1024) at qora.BlockGenerator.run(BlockGenerator.java:178) 2016-03-24 17:40:33 ERROR ArbitraryTransaction:225 - org.json.simple.JSONObject cannot be cast to java.lang.String java.lang.ClassCastException: org.json.simple.JSONObject cannot be cast to java.lang.String at utils.StorageUtils.getKeys(StorageUtils.java:288) at utils.StorageUtils.getAllKeysForOrphanSaving(StorageUtils.java:276) at utils.StorageUtils.processUpdate(StorageUtils.java:136) at qora.transaction.ArbitraryTransaction.process(ArbitraryTransaction.java:213) at qora.block.Block.process(Block.java:714) at qora.block.Block.process(Block.java:705) at qora.Synchronizer.process(Synchronizer.java:343) at qora.Synchronizer.synchronize(Synchronizer.java:195) at controller.Controller.update(Controller.java:1024) at qora.BlockGenerator.run(BlockGenerator.java:178) 2016-03-24 17:40:39 INFO Network:66 - Connection successfull : /119.176.85.152

catbref commented 6 years ago
Transaction: 752vp1Zr18jm1Xq35DyRGWs73WFya9ibEGTHqZEBicsFdoqyVspuoMBewiThUZX8LPgMTXqZZnTDaG8AoKxfNsa
Creator: QMcfbBpyGsMdXpkkMLhKv79yyF9DNeN1u7
Height: 179707
Base58: 25tJtm3KBamRSHX4NU81QWHwdp9BuwSCZv69E23xc77FuQisLREcSB8u56HutQLWGEf6TcqT7HKLpR5QapP1jHKkjujHMiXvXmqMNvQZEud3XAGF1Rkj3B7W3Y47WAxEHbAe6z6Y
Payload: {"addcomplete":{"test.txt":"this is a test text file"},"name":"QMcfbBpyGsMdXpkkMLhKv79yyF9DNeN1u7"}

Note, in the payload, how the value for "addcomplete" is another JSON object and NOT a string - which is what is expected by the QORA code in StorageUtils.java:288 (mainKey is "addcomplete"):

String addJson = (String) jsonObject.get(mainKey);

This transaction shouldn't really have made it into the blockchain due to being invalid on the above grounds. Even worse, although the exception thrown by above is caught at ArbitraryTransaction.java:235 it isn't re-thrown but simply falls through to more code that charges the creator the transaction fee before happily adding the transaction to the blockchain!

It looks like payload checking needs to be added to is_valid() for arbitrary transactions as process() is not expected to fail.

As the above transaction is "grandfathered" into the blockchain, options for allowing this transaction (e.g. when syncing from scratch) are:

Coding and testing required before this issue can be closed.

catbref commented 6 years ago

fixed with commit referenced above