iotexproject / iotex-core

Official implementation of IoTeX blockchain protocol in Go. An ultra-efficient EVM blockchain offering 1000 TPS with instant 1-block finality. Perfect for DeFi, DePIN tokenomics, Identities, and any trusted logic requiring Web3 composability
https://iotex.io
Apache License 2.0
1.55k stars 327 forks source link

Failed to load root for contract #4501

Open envestcc opened 1 week ago

envestcc commented 1 week ago

What version of iotex-core image (or code branch) are you using?

v2.0.8

What operating system and processor architecture are you using?

What did you do? If possible, provide a recipe for reproducing the error.

some eth_call

What did you expect to see?

What did you see instead?

{"level":"error","ts":"2024-11-22T08:22:35.020Z","caller":"evm/evmstatedbadapter.go:694","msg":"Failed to load root for contract.","ioAddr":"io1sllhya07z4lseycxaar68zan9sa39lnn50w0cv","error":"failed to get key e6b9527498beb3cfb8e86d0f91d0ff334168cf289ca00f11f65e1c3b5f682ecf: failed to find key e6b9527498beb3cfb8e86d0f91d0ff334168cf289ca00f11f65e1c3b5f682ecf: not exist in DB","errorVerbose":"not exist in DB
github.com/iotexproject/iotex-core/v2/db.init
    /go/apps/iotex-core/db/builder.go:7
runtime.doInit1
    /usr/local/go/src/runtime/proc.go:6740
runtime.doInit
    /usr/local/go/src/runtime/proc.go:6707
runtime.main
    /usr/local/go/src/runtime/proc.go:249
runtime.goexit
    /usr/local/go/src/runtime/asm_amd64.s:1650
failed to find key e6b9527498beb3cfb8e86d0f91d0ff334168cf289ca00f11f65e1c3b5f682ecf
github.com/iotexproject/iotex-core/v2/action/protocol.(*kvStoreForTrie).Get
    /go/apps/iotex-core/action/protocol/kvstorefortrie.go:64
github.com/iotexproject/iotex-core/v2/db/trie/mptrie.(*merklePatriciaTrie).loadNode
    /go/apps/iotex-core/db/trie/mptrie/merklepatriciatrie.go:305
github.com/iotexproject/iotex-core/v2/db/trie/mptrie.(*merklePatriciaTrie).setRootHash
    /go/apps/iotex-core/db/trie/mptrie/merklepatriciatrie.go:247
github.com/iotexproject/iotex-core/v2/db/trie/mptrie.(*merklePatriciaTrie).SetRootHash
    /go/apps/iotex-core/db/trie/mptrie/merklepatriciatrie.go:150
github.com/iotexproject/iotex-core/v2/action/protocol/execution/evm.(*contract).LoadRoot
    /go/apps/iotex-core/action/protocol/execution/evm/contract.go:153
github.com/iotexproject/iotex-core/v2/action/protocol/execution/evm.(*StateDBAdapter).RevertToSnapshot
    /go/apps/iotex-core/action/protocol/execution/evm/evmstatedbadapter.go:693
github.com/ethereum/go-ethereum/core/vm.(*EVM).Call
    /go/pkg/mod/github.com/iotexproject/go-ethereum@v1.7.4-0.20240321181400-fc0405c7567c/core/vm/evm.go:249
github.com/ethereum/go-ethereum/core/vm.opCall
    /go/pkg/mod/github.com/iotexproject/go-ethereum@v1.7.4-0.20240321181400-fc0405c7567c/core/vm/instructions.go:669
github.com/ethereum/go-ethereum/core/vm.(*EVMInterpreter).Run
    /go/pkg/mod/github.com/iotexproject/go-ethereum@v1.7.4-0.20240321181400-fc0405c7567c/core/vm/interpreter.go:234
github.com/ethereum/go-ethereum/core/vm.(*EVM).Call
    /go/pkg/mod/github.com/iotexproject/go-ethereum@v1.7.4-0.20240321181400-fc0405c7567c/core/vm/evm.go:241
github.com/ethereum/go-ethereum/core/vm.opCall
    /go/pkg/mod/github.com/iotexproject/go-ethereum@v1.7.4-0.20240321181400-fc0405c7567c/core/vm/instructions.go:669
github.com/ethereum/go-ethereum/core/vm.(*EVMInterpreter).Run
    /go/pkg/mod/github.com/iotexproject/go-ethereum@v1.7.4-0.20240321181400-fc0405c7567c/core/vm/interpreter.go:234
github.com/ethereum/go-ethereum/core/vm.(*EVM).Call
    /go/pkg/mod/github.com/iotexproject/go-ethereum@v1.7.4-0.20240321181400-fc0405c7567c/core/vm/evm.go:241
github.com/iotexproject/iotex-core/v2/action/protocol/execution/evm.executeInEVM
    /go/apps/iotex-core/action/protocol/execution/evm/evm.go:505
github.com/iotexproject/iotex-core/v2/action/protocol/execution/evm.ExecuteContract
    /go/apps/iotex-core/action/protocol/execution/evm/evm.go:245
github.com/iotexproject/iotex-core/v2/action/protocol/execution/evm.SimulateExecution
    /go/apps/iotex-core/action/protocol/execution/evm/evm.go:671
github.com/iotexproject/iotex-core/v2/state/factory.(*stateDB).SimulateExecution
    /go/apps/iotex-core/state/factory/statedb.go:291
github.com/iotexproject/iotex-core/v2/api.(*coreService).simulateExecution
    /go/apps/iotex-core/api/coreservice.go:1958
github.com/iotexproject/iotex-core/v2/api.(*coreService).ReadContract
    /go/apps/iotex-core/api/coreservice.go:591
github.com/iotexproject/iotex-core/v2/api.(*web3Handler).call
    /go/apps/iotex-core/api/web3server.go:413
github.com/iotexproject/iotex-core/v2/api.(*web3Handler).handleWeb3Req
    /go/apps/iotex-core/api/web3server.go:174
github.com/iotexproject/iotex-core/v2/api.(*web3Handler).HandlePOSTReq
    /go/apps/iotex-core/api/web3server.go:123
github.com/iotexproject/iotex-core/v2/api.(*hTTPHandler).ServeHTTP
    /go/apps/iotex-core/api/http.go:71
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp.(*Handler).ServeHTTP
    /go/pkg/mod/go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp@v0.42.0/handler.go:212
net/http.(*ServeMux).ServeHTTP
    /usr/local/go/src/net/http/server.go:2514
net/http.serverHandler.ServeHTTP
    /usr/local/go/src/net/http/server.go:2938
net/http.(*conn).serve
    /usr/local/go/src/net/http/server.go:2009
runtime.goexit
    /usr/local/go/src/runtime/asm_amd64.s:1650
failed to get key e6b9527498beb3cfb8e86d0f91d0ff334168cf289ca00f11f65e1c3b5f682ecf
github.com/iotexproject/iotex-core/v2/db/trie/mptrie.(*merklePatriciaTrie).loadNode
    /go/apps/iotex-core/db/trie/mptrie/merklepatriciatrie.go:307
github.com/iotexproject/iotex-core/v2/db/trie/mptrie.(*merklePatriciaTrie).setRootHash
    /go/apps/iotex-core/db/trie/mptrie/merklepatriciatrie.go:247
github.com/iotexproject/iotex-core/v2/db/trie/mptrie.(*merklePatriciaTrie).SetRootHash
    /go/apps/iotex-core/db/trie/mptrie/merklepatriciatrie.go:150
github.com/iotexproject/iotex-core/v2/action/protocol/execution/evm.(*contract).LoadRoot
    /go/apps/iotex-core/action/protocol/execution/evm/contract.go:153
github.com/iotexproject/iotex-core/v2/action/protocol/execution/evm.(*StateDBAdapter).RevertToSnapshot
    /go/apps/iotex-core/action/protocol/execution/evm/evmstatedbadapter.go:693
github.com/ethereum/go-ethereum/core/vm.(*EVM).Call
    /go/pkg/mod/github.com/iotexproject/go-ethereum@v1.7.4-0.20240321181400-fc0405c7567c/core/vm/evm.go:249
github.com/ethereum/go-ethereum/core/vm.opCall
    /go/pkg/mod/github.com/iotexproject/go-ethereum@v1.7.4-0.20240321181400-fc0405c7567c/core/vm/instructions.go:669
github.com/ethereum/go-ethereum/core/vm.(*EVMInterpreter).Run
    /go/pkg/mod/github.com/iotexproject/go-ethereum@v1.7.4-0.20240321181400-fc0405c7567c/core/vm/interpreter.go:234
github.com/ethereum/go-ethereum/core/vm.(*EVM).Call
    /go/pkg/mod/github.com/iotexproject/go-ethereum@v1.7.4-0.20240321181400-fc0405c7567c/core/vm/evm.go:241
github.com/ethereum/go-ethereum/core/vm.opCall
    /go/pkg/mod/github.com/iotexproject/go-ethereum@v1.7.4-0.20240321181400-fc0405c7567c/core/vm/instructions.go:669
github.com/ethereum/go-ethereum/core/vm.(*EVMInterpreter).Run
    /go/pkg/mod/github.com/iotexproject/go-ethereum@v1.7.4-0.20240321181400-fc0405c7567c/core/vm/interpreter.go:234
github.com/ethereum/go-ethereum/core/vm.(*EVM).Call
    /go/pkg/mod/github.com/iotexproject/go-ethereum@v1.7.4-0.20240321181400-fc0405c7567c/core/vm/evm.go:241
github.com/iotexproject/iotex-core/v2/action/protocol/execution/evm.executeInEVM
    /go/apps/iotex-core/action/protocol/execution/evm/evm.go:505
github.com/iotexproject/iotex-core/v2/action/protocol/execution/evm.ExecuteContract
    /go/apps/iotex-core/action/protocol/execution/evm/evm.go:245
github.com/iotexproject/iotex-core/v2/action/protocol/execution/evm.SimulateExecution
    /go/apps/iotex-core/action/protocol/execution/evm/evm.go:671
github.com/iotexproject/iotex-core/v2/state/factory.(*stateDB).SimulateExecution
    /go/apps/iotex-core/state/factory/statedb.go:291
github.com/iotexproject/iotex-core/v2/api.(*coreService).simulateExecution
    /go/apps/iotex-core/api/coreservice.go:1958
github.com/iotexproject/iotex-core/v2/api.(*coreService).ReadContract
    /go/apps/iotex-core/api/coreservice.go:591
github.com/iotexproject/iotex-core/v2/api.(*web3Handler).call
    /go/apps/iotex-core/api/web3server.go:413
github.com/iotexproject/iotex-core/v2/api.(*web3Handler).handleWeb3Req
    /go/apps/iotex-core/api/web3server.go:174
github.com/iotexproject/iotex-core/v2/api.(*web3Handler).HandlePOSTReq
    /go/apps/iotex-core/api/web3server.go:123
github.com/iotexproject/iotex-core/v2/api.(*hTTPHandler).ServeHTTP
    /go/apps/iotex-core/api/http.go:71
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp.(*Handler).ServeHTTP
    /go/pkg/mod/go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp@v0.42.0/handler.go:212
net/http.(*ServeMux).ServeHTTP
    /usr/local/go/src/net/http/server.go:2514
net/http.serverHandler.ServeHTTP
    /usr/local/go/src/net/http/server.go:2938
net/http.(*conn).serve
    /usr/local/go/src/net/http/server.go:2009
runtime.goexit
    /usr/local/go/src/runtime/asm_amd64.s:1650","addrHash":"3e8bd57eb43bbda79d0423c138a1db3dca754076"}
envestcc commented 3 days ago

It's caused by updated statedb when putblock, which is using in eth_call. Fixing this issue will require waiting for support for the historical factory feature.