Excessive Gas Consumption Due to Index Out of Range Bug in chainmaker/vm-evm
【问题分类】
- 智能合约相关
- EVM
【问题描述】
When the deployed bytecode does not end with an opcode that is set finished: true (e.g., STOP
, RETURN
, REVERT
, SELFDESTRUCT
), the sealevm will charge all of the provided gas and raise an index out of range error.
As vm-evm is implemented based on SealEVM, the Index Out of Range Bug in SealEVM also affects the chainmaker vm-evm. Detailes can be found in SealEVM issue.
【相关日志文件】
I check the code in vm-evm at https://git.chainmaker.org.cn/chainmaker/vm-evm/-/blob/master/evm-go/instructions/instructions.go#L190. This line will also cause a index out of range panic.
Expected value from geth.
{"pc":0,"op":96,"gas":"0xffffff","gasCost":"0x3","memSize":0,"stack":[],"depth":1,"refund":0,"opName":"PUSH1"}
{"pc":2,"op":96,"gas":"0xfffffc","gasCost":"0x3","memSize":0,"stack":["0x0"],"depth":1,"refund":0,"opName":"PUSH1"}
{"pc":4,"op":1,"gas":"0xfffff9","gasCost":"0x3","memSize":0,"stack":["0x0","0x0"],"depth":1,"refund":0,"opName":"ADD"}
{"pc":5,"op":0,"gas":"0xfffff6","gasCost":"0x0","memSize":0,"stack":["0x0"],"depth":1,"refund":0,"opName":"STOP"}
{"output":"","gasUsed":"0x9"}
Result from SealEVM.
{"pc":0,"op":96,"gas":"0xfffffc","gasCost":"0x3","memory":"0x","stack":null,"opName":"PUSH1"}
{"pc":2,"op":96,"gas":"0xfffff9","gasCost":"0x3","memory":"0x","stack":["0x0"],"opName":"PUSH1"}
{"pc":4,"op":1,"gas":"0xfffff6","gasCost":"0x3","memory":"0x","stack":["0x0","0x0"],"opName":"ADD"}
{"output":"","gasUsed":"0xffffff","exitOpcode":"STOP","error":""}
【系统信息】
- **chainmaker-go version * : All versions of vm-evm are affected.
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information