ethereum / ethereumj

DEPRECATED! Java implementation of the Ethereum yellowpaper. For JSON-RPC and other client features check Ethereum Harmony
GNU Lesser General Public License v3.0
2.18k stars 1.1k forks source link

NPE while deserialization of ABI that contains a fallback function #1196

Closed jondoe1337 closed 5 years ago

jondoe1337 commented 5 years ago

Using the contract: https://gist.github.com/jondoe1337/b11b616a79f37c502021694eadab7e40 And try to deserialize from JSON: org.ethereum.solidity.Abi.fromJson Leads to:

java.lang.RuntimeException: com.fasterxml.jackson.databind.JsonMappingException: (was java.lang.NullPointerException) (through reference chain: org.ethereum.solidity.Abi[26])
        at org.ethereum.solidity.Abi.fromJson(Abi.java:53) ~[stormjar.jar:?]
        at eth.events.abi.decoder.AbiDecoder.addAbi(AbiDecoder.java:198) ~[stormjar.jar:?]
        at org.apache.storm.daemon.executor$fn__10795$tuple_action_fn__10797.invoke(executor.clj:739) [storm-core-1.2.2.jar:1.2.2]
        at org.apache.storm.daemon.executor$mk_task_receiver$fn__10716.invoke(executor.clj:468) [storm-core-1.2.2.jar:1.2.2]
        at org.apache.storm.disruptor$clojure_handler$reify__10135.onEvent(disruptor.clj:41) [storm-core-1.2.2.jar:1.2.2]
        at org.apache.storm.utils.DisruptorQueue.consumeBatchToCursor(DisruptorQueue.java:509) [storm-core-1.2.2.jar:1.2.2]
        at org.apache.storm.utils.DisruptorQueue.consumeBatchWhenAvailable(DisruptorQueue.java:487) [storm-core-1.2.2.jar:1.2.2]
        at org.apache.storm.disruptor$consume_batch_when_available.invoke(disruptor.clj:74) [storm-core-1.2.2.jar:1.2.2]
        at org.apache.storm.daemon.executor$fn__10795$fn__10808$fn__10861.invoke(executor.clj:861) [storm-core-1.2.2.jar:1.2.2]
        at org.apache.storm.util$async_loop$fn__553.invoke(util.clj:484) [storm-core-1.2.2.jar:1.2.2]
        at clojure.lang.AFn.run(AFn.java:22) [clojure-1.7.0.jar:?]
        at java.lang.Thread.run(Thread.java:748) [?:1.8.0_181]
Caused by: com.fasterxml.jackson.databind.JsonMappingException: (was java.lang.NullPointerException) (through reference chain: org.ethereum.solidity.Abi[26])
        at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:391) ~[stormjar.jar:?]
        at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:363) ~[stormjar.jar:?]
        at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:302) ~[stormjar.jar:?]
        at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:245) ~[stormjar.jar:?]
        at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:27) ~[stormjar.jar:?]
        at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4001) ~[stormjar.jar:?]
        at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2992) ~[stormjar.jar:?]
        at org.ethereum.solidity.Abi.fromJson(Abi.java:51) ~[stormjar.jar:?]
        ... 13 more

After debugging deserialization, I found that org.ethereum.solidity.Abi.Entry.create doesn't cover the fallback type (which is used in the ABI).

If I remember correctly, the fallback is not that new. Any ideas why it hasn't been covered?

mkalinin commented 5 years ago

@Nashatyrev maybe you could shed some light on that?

Nashatyrev commented 5 years ago

We need to get rid of duplicated code in Abi and CallTransaction and convert ABITest to test new version