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

ArbitraryTransaction ERROR #57

Closed
agran opened this issue Mar 24, 2016 · 2 comments
Closed

ArbitraryTransaction ERROR #57

agran opened this issue Mar 24, 2016 · 2 comments

Comments

@agran
Copy link
Collaborator

agran commented Mar 24, 2016

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
Copy link
Collaborator

catbref commented Dec 1, 2017

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:

  • checking for this specific transaction and allowing it
  • relaxing "addcomplete" (or other) value-types to allow string AND JSON object (i.e. optional string encapsulation)

Coding and testing required before this issue can be closed.

catbref added a commit that referenced this issue Dec 17, 2017
@catbref
Copy link
Collaborator

catbref commented Jan 9, 2018

fixed with commit referenced above

@catbref catbref closed this as completed Jan 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants