使用java sdk调用合约查询某key的历史记录时返回message: "runtime panic"
【问题分类】
- bug
- P2P网络相关(包含libp2p,liquid)
- 链账户身份与权限相关(证书问题、public、多签投票问题)
- 核心交易引擎相关(交易池、DAG)
- 共识相关
- 智能合约相关
- 存储相关
- SDK相关
- 长安链CMC工具
- 长安链管理台
- 长安链浏览器
- 长安链合约IDE
- 长安链web签名插件
- 跨链相关
- 轻节点相关
- 隐私计算相关
- 密码学相关
- 环境依赖
- 其他补充:
【问题描述】(请对问题进行描述,方便定位问题)
使用golang编写了一个合约,包含一个可以通过key查询历史记录的方法(FindHistoryByKey)。 通过java sdk调以上的合约方法时,查询区块链中存在的key可以正确的结果,如果查询在区块链中不存在的key,方法将会返回: contract_result { code: 1 message: "runtime panic" gas_used: 11270 }
【相关日志文件】(如果有报错日志请贴图,或者上传附件)
2022-11-22 15:25:54.082 [ERROR] [Sandbox RPC Service] rpc/contract_engine_sandbox_service.go:51 failed to recv msg: rpc error: code = Canceled desc = context canceled EOF 2022-11-22 15:25:54.083 [WARN] [Process chain1#o#nft_contract#8.0#0#19 (closed)] core/process.go:245 process stopped for tx [d6307da7daf5a7b45e062d737ec0f5577926ff83761dbbf096195a3da28c6c52#94], exit status 2, panic: runtime error: slice bounds out of range [:-1]
goroutine 32 [running]: main.(*NftContract).FindHistoryByKey(0x0?) /usr/local/contract/my-contract/nft_contract.go:164 +0x62c main.(*NftContract).InvokeContract(0x7ffecf55edf6?, {0xc0000a5880, 0xc0000a0240?}) /usr/local/contract/my-contract/nft_contract.go:90 +0x825 chainmaker.org/chainmaker/contract-sdk-go/v2/sandbox.(*TxHandler).handleTxRequest(0xc000134a20, 0xc000183080) /home/gopath/pkg/mod/chainmaker.org/chainmaker/contract-sdk-go/v2@v2.3.0/sandbox/tx_handler.go:160 +0x62e chainmaker.org/chainmaker/contract-sdk-go/v2/sandbox.(*TxHandler).listenPendingQueue(0xc000134a20) /home/gopath/pkg/mod/chainmaker.org/chainmaker/contract-sdk-go/v2@v2.3.0/sandbox/tx_handler.go:96 +0x1d7 chainmaker.org/chainmaker/contract-sdk-go/v2/sandbox.(*TxHandler).Start(0xc000134a20) /home/gopath/pkg/mod/chainmaker.org/chainmaker/contract-sdk-go/v2@v2.3.0/sandbox/tx_handler.go:86 +0x6f chainmaker.org/chainmaker/contract-sdk-go/v2/sandbox.Start.func1() /home/gopath/pkg/mod/chainmaker.org/chainmaker/contract-sdk-go/v2@v2.3.0/sandbox/sandbox.go:64 +0x26 created by chainmaker.org/chainmaker/contract-sdk-go/v2/sandbox.Start /home/gopath/pkg/mod/chainmaker.org/chainmaker/contract-sdk-go/v2@v2.3.0/sandbox/sandbox.go:63 +0x7ed
2022-11-22 15:25:54.083 [WARN] [Process chain1#o#nft_contract#8.0#0#19 (closed)] core/process.go:700 process exited when busy: exit status 2 2022-11-22 15:25:54.083 [ERROR] [Process chain1#o#nft_contract#8.0#0#19 (closed)] core/process.go:835 return error result of tx [d6307da7daf5a7b45e062d737ec0f5577926ff83761dbbf096195a3da28c6c52#94]
【系统信息】(请填写系统信息,方便定位问题)
- **chainmaker-go version :v2.3.0
- **OS & version :Linux version 3.10.0-1160.59.1.el7.x86_64
- **docker镜像 version:20.10.18