WeBankBlockchain / WeBASE-Collect-Bee

目前本项目处于维护模式,新特性和新功能请移步:https://github.com/WeBankBlockchain/Data-Export
Apache License 2.0
27 stars 8 forks source link

当合约函数返回值不是String类型,触发合约内require语句的异常交易,将触发异常无法导出到数据库。 #19

Closed xiaomdong closed 4 years ago

xiaomdong commented 4 years ago

WeBASE-Collect-Bee v1.3.2版本,存在异常情况:

合约函数如下: function updateTable(string memory tableName, string memory key, string memory value) public { TableFactory tf = TableFactory(0x1001); Table table = tf.openTable(tableName);

    ( , string memory _value ) = selectTable(tableName, key);

    Entry entry = table.newEntry();

    require( keccak256(_value) != keccak256(value), "value is same");

    entry.set("value", value);

    Condition condition = table.newCondition();

    int count = table.update(key, entry, condition);

    emit UpdateTable(count);
}

触发 require( keccak256(_value) != keccak256(value), "value is same");的异常交易,将无法导出到数据库,会报异常,异常记录如下:

2020-09-04 14:31:27.936 ERROR 27674 --- [taskExecutor-4] .a.i.SimpleAsyncUncaughtExceptionHandler : Unexpected exception occurred invoking async method: public void com.webank.webasebee.core.service.BlockAsyncService.handleSingleBlock(org.fisco.bcos.web3j.protocol.core.methods.response.BcosBlock$Block,long)

java.lang.UnsupportedOperationException: Unable to create instance of org.fisco.bcos.web3j.abi.datatypes.generated.Int256 at org.fisco.bcos.web3j.abi.TypeDecoder.decodeNumeric(TypeDecoder.java:88) ~[web3sdk-2.4.2.jar!/:na] at org.fisco.bcos.web3j.abi.TypeDecoder.decode(TypeDecoder.java:41) ~[web3sdk-2.4.2.jar!/:na] at org.fisco.bcos.web3j.abi.FunctionReturnDecoder.build(FunctionReturnDecoder.java:109) ~[web3sdk-2.4.2.jar!/:na] at org.fisco.bcos.web3j.abi.FunctionReturnDecoder.decode(FunctionReturnDecoder.java:36) ~[web3sdk-2.4.2.jar!/:na] at com.webank.webasebee.parser.generated.crawler.method.UserControllerUpdateTableMethodCrawlerImpl.transactionHandler(UserControllerUpdateTableMethodCrawlerImpl.java:74) ~[WeBASE-Collect-Bee-WeBASE-Collect-Bee-parser1.3.1.jar!/:na] at com.webank.webasebee.parser.handler.MethodCrawlerHandler.crawl(MethodCrawlerHandler.java:109) ~[WeBASE-Collect-Bee-WeBASE-Collect-Bee-parser1.3.1.jar!/:na] at com.webank.webasebee.parser.facade.ParseFacade.parse(ParseFacade.java:60) ~[WeBASE-Collect-Bee-WeBASE-Collect-Bee-parser1.3.1.jar!/:na] at com.webank.webasebee.core.service.BlockCrawlService.parse(BlockCrawlService.java:64) ~[classes!/:na] at com.webank.webasebee.core.service.BlockDepotService.process(BlockDepotService.java:93) ~[classes!/:na] at com.webank.webasebee.core.service.BlockAsyncService.handleSingleBlock(BlockAsyncService.java:40) ~[classes!/:na] at com.webank.webasebee.core.service.BlockAsyncService$$FastClassBySpringCGLIB$$80ad7e0.invoke() ~[classes!/:na] at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) ~[spring-core-5.2.7.RELEASE.jar!/:5.2.7.RELEASE] at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) ~[spring-aop-5.2.7.RELEASE.jar!/:5.2.7.RELEASE] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) ~[spring-aop-5.2.7.RELEASE.jar!/:5.2.7.RELEASE] at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) ~[spring-aop-5.2.7.RELEASE.jar!/:5.2.7.RELEASE] at org.springframework.aop.interceptor.AsyncExecutionInterceptor.lambda$invoke$0(AsyncExecutionInterceptor.java:115) ~[spring-aop-5.2.7.RELEASE.jar!/:5.2.7.RELEASE] at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[na:1.8.0_265] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) ~[na:1.8.0_265] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ~[na:1.8.0_265] at java.lang.Thread.run(Thread.java:748) ~[na:1.8.0_265] Caused by: java.lang.reflect.InvocationTargetException: null at sun.reflect.GeneratedConstructorAccessor110.newInstance(Unknown Source) ~[na:na] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_265] at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[na:1.8.0_265] at org.fisco.bcos.web3j.abi.TypeDecoder.decodeNumeric(TypeDecoder.java:79) ~[web3sdk-2.4.2.jar!/:na] ... 19 common frames omitted Caused by: java.lang.UnsupportedOperationException: Bitsize must be 8 bit aligned, and in range 0 < bitSize <= 256, and in valid range. at org.fisco.bcos.web3j.abi.datatypes.IntType.(IntType.java:11) ~[web3sdk-2.4.2.jar!/:na] at org.fisco.bcos.web3j.abi.datatypes.Int.(Int.java:34) ~[web3sdk-2.4.2.jar!/:na] at org.fisco.bcos.web3j.abi.datatypes.generated.Int256.(Int256.java:18) ~[web3sdk-2.4.2.jar!/:na] ... 23 common frames omitted

dalaocu commented 4 years ago

Good report. Already hot fixed.