Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eth_call - return an error in case the request is to the pruned block #3152

Closed
iSOcH opened this issue Dec 21, 2021 · 10 comments
Closed

eth_call - return an error in case the request is to the pruned block #3152

iSOcH opened this issue Dec 21, 2021 · 10 comments

Comments

@iSOcH
Copy link

iSOcH commented Dec 21, 2021

System information

Erigon version: erigon version 2021.12.3-beta

OS & Version: Linux erigon-mainnet 5.4.157-1-pve #1 SMP PVE 5.4.157-1 (Mon, 29 Nov 2021 12:01:44 +0100) x86_64 x86_64 x86_64 GNU/Linux (Ubuntu 20.04.3 LTS running in LXC Container on Proxmox 6.4)

Commit hash : 2021.12.3-beta release

Erigon command line: /usr/local/bin/erigon --datadir /srv --maxpeers 20 --private.api.addr=127.0.0.1:9090 --metrics --pprof --prune htc
Rpcdaemon command line: /usr/local/bin/rpcdaemon --private.api.addr=127.0.0.1:9090 --datadir /srv --http.addr 0.0.0.0 --http.api=eth,erigon,web3,net,debug,trace,txpool,shh --http.vhosts * --ws

Expected behaviour

eth_call returns correct data (or explains the reason of the error)

Actual behaviour

seth -B 13758499 --rpc-host=http://eth1-rpc-mainnet call 0xD71eCFF9342A5Ced620049e616c5035F1dB98620 'totalSupply()'
seth-rpc: {"id":1,"jsonrpc":"2.0","method":"eth_call","params":[{"data":"0x18160ddd","to":"0xD71eCFF9342A5Ced620049e616c5035F1dB98620"},"0xd1f023"]}
seth-rpc: error:   code       -32000
seth-rpc: error:   message    method handler crashed

Steps to reproduce the behaviour

See above. The same call works with higher block numbers. The lowest block where the call succeeds shifts up over time.

seth -B 13758500 --rpc-host=http://eth1-rpc-mainnet call 0xD71eCFF9342A5Ced620049e616c5035F1dB98620 'totalSupply()'
0x0000000000000000000000000000000000000000005946f89b147f2bd6c9dac7

Backtrace

[EROR] [12-21|12:28:47.868] RPC method eth_call crashed: runtime error: slice bounds out of range [:20] with capacity 0
goroutine 28152 [running]:
github.com/ledgerwatch/erigon/rpc.(*callback).call.func1()
        github.com/ledgerwatch/erigon/rpc/service.go:219 +0x89
panic({0xfbf600, 0xc0033ae708})
        runtime/panic.go:1038 +0x215
github.com/ledgerwatch/erigon/common/changeset.DecodeAccounts({0xc00269a360, 0xc00269a360, 0xc002459cc8}, {0x0, 0xc0033ae6d8, 0xc0004ae3c0})
        github.com/ledgerwatch/erigon/common/changeset/account_changeset.go:40 +0x85
github.com/ledgerwatch/erigon/common/changeset.FindAccount({0x7f5d6ee8d058, 0xc0004da030}, 0xd1f036, {0xc0033ae6d8, 0xc002459d48, 0x14})
        github.com/ledgerwatch/erigon/common/changeset/account_changeset.go:52 +0xba
github.com/ledgerwatch/erigon/core/state.FindByHistory({0x11b5af8, 0xc00305e540}, {0x7f5d6ee6f1d0, 0xc000590a80}, {0x7f5d6ee8d058, 0xc0004da030}, 0x0, {0xc0033ae6d8, 0x14, 0x14}, ...)
        github.com/ledgerwatch/erigon/core/state/history.go:69 +0x3cf
github.com/ledgerwatch/erigon/core/state.GetAsOf({0x11b5af8, 0xc00305e540}, {0x7f5d6ee6f1d0, 0xc000590a80}, {0x7f5d6ee8d058, 0xc0004da030}, 0x10, {0xc0033ae6d8, 0x14, 0x14}, ...)
        github.com/ledgerwatch/erigon/core/state/history.go:20 +0x70
github.com/ledgerwatch/erigon/core/state.(*PlainState).ReadAccountData(0xc000590c00, {0xe3, 0x1, 0xda, 0x3d, 0x2d, 0x3e, 0x96, 0xe5, 0x7d, ...})
        github.com/ledgerwatch/erigon/core/state/plain_readonly.go:148 +0xac
github.com/ledgerwatch/erigon/core/state.(*IntraBlockState).getStateObject(0xc0012fe0e0, {0xe3, 0x1, 0xda, 0x3d, 0x2d, 0x3e, 0x96, 0xe5, 0x7d, ...})
        github.com/ledgerwatch/erigon/core/state/intra_block_state.go:548 +0xb6
github.com/ledgerwatch/erigon/core/state.(*IntraBlockState).GetCodeSize(0xc0012fe0e0, {0xe3, 0x1, 0xda, 0x3d, 0x2d, 0x3e, 0x96, 0xe5, 0x7d, ...})
        github.com/ledgerwatch/erigon/core/state/intra_block_state.go:317 +0x113
github.com/ledgerwatch/erigon/core/vm.opExtCodeSize(0xc00079c420, 0xc002138260, 0xc0012a43a8)
        github.com/ledgerwatch/erigon/core/vm/instructions.go:374 +0x94
github.com/ledgerwatch/erigon/core/vm.(*EVMInterpreter).Run(0xc002138260, 0xc002c8e0d0, {0xc00269a1a0, 0x4, 0x4}, 0x0)
        github.com/ledgerwatch/erigon/core/vm/interpreter.go:318 +0xaf1
github.com/ledgerwatch/erigon/core/vm.run(0x11881a0, 0xc0033ae5b8, {0xc00269a1a0, 0xc0033ae648, 0xc0021f51f8}, 0x38)
        github.com/ledgerwatch/erigon/core/vm/evm.go:71 +0x244
github.com/ledgerwatch/erigon/core/vm.(*EVM).Call(0xc00079c420, {0x11881a0, 0xc0033ae5b8}, {0xd7, 0x1e, 0xcf, 0xf9, 0x34, 0x2a, 0x5c, ...}, ...)
        github.com/ledgerwatch/erigon/core/vm/evm.go:269 +0xac9
github.com/ledgerwatch/erigon/core.(*StateTransition).TransitionDb(0xc000fd65a0, 0x1, 0x0)
        github.com/ledgerwatch/erigon/core/state_transition.go:359 +0x675
github.com/ledgerwatch/erigon/core.ApplyMessage(0x11b5998, {0x11b5998, 0xc0021f4e10}, 0x108e508, 0x82, 0x9b)
        github.com/ledgerwatch/erigon/core/state_transition.go:192 +0x3c
github.com/ledgerwatch/erigon/turbo/transactions.DoCall({0x11a0138, 0xc001366480}, {0x0, 0xc0033ae390, 0xc0000b2548, 0x0, 0x0, 0x0, 0x0, 0x0, ...}, ...)
        github.com/ledgerwatch/erigon/turbo/transactions/call.go:123 +0xa4a
github.com/ledgerwatch/erigon/cmd/rpcdaemon/commands.(*APIImpl).Call(0xc0000b2500, {0x11a0138, 0xc001366480}, {0x0, 0xc0033ae390, 0xc0000b2548, 0x0, 0x0, 0x0, 0x0, ...}, ...)
        github.com/ledgerwatch/erigon/cmd/rpcdaemon/commands/eth_call.go:66 +0x370
reflect.Value.call({0xc000034380, 0xc000010130, 0x7f5d9733cf18}, {0x10282e1, 0x4}, {0xc004960500, 0x5, 0xc000a02140})
        reflect/value.go:543 +0x814
reflect.Value.Call({0xc000034380, 0xc000010130, 0xc0012a42d0}, {0xc004960500, 0x5, 0x5})
        reflect/value.go:339 +0xc5
github.com/ledgerwatch/erigon/rpc.(*callback).call(0xc000448ea0, {0x11a0138, 0xc001366480}, {0xc00269a180, 0x8}, {0xc0004ae1e0, 0x3, 0xc000a02140}, 0xc000590900)
        github.com/ledgerwatch/erigon/rpc/service.go:226 +0x58a
github.com/ledgerwatch/erigon/rpc.(*handler).runMethod(0xc0012cc120, {0x11a0138, 0xc001366480}, 0xc0004cc000, 0x46106d, {0xc0004ae1e0, 0x4, 0x0}, 0x8)
        github.com/ledgerwatch/erigon/rpc/handler.go:484 +0x25b
github.com/ledgerwatch/erigon/rpc.(*handler).handleCall(0xc0012a80a0, 0xc00305e480, 0xc0004cc000, 0x7f5d64059380)
        github.com/ledgerwatch/erigon/rpc/handler.go:389 +0x2c9
github.com/ledgerwatch/erigon/rpc.(*handler).handleCallMsg(0xc0012a80a0, 0x7f5d64646048, 0xc0004cc000, 0x28)
        github.com/ledgerwatch/erigon/rpc/handler.go:343 +0xd6
github.com/ledgerwatch/erigon/rpc.(*handler).handleMsg.func1(0xc00305e480)
        github.com/ledgerwatch/erigon/rpc/handler.go:181 +0x111
github.com/ledgerwatch/erigon/rpc.(*handler).startCallProc.func1()
        github.com/ledgerwatch/erigon/rpc/handler.go:271 +0xc8
created by github.com/ledgerwatch/erigon/rpc.(*handler).startCallProc
        github.com/ledgerwatch/erigon/rpc/handler.go:267 +0x92
 
[WARN] [12-21|12:28:47.868] Served                                   conn=client-ip:37080 method=eth_call reqid=1 t=1.032204ms err="method handler crashed"
@AskAlexSharov
Copy link
Collaborator

Probably because block out of —prune range, but it must return error instead of crush of course

@iSOcH
Copy link
Author

iSOcH commented Dec 21, 2021

Thanks for your quick response

I see, so does --prune h (i have htc) remove the required data for such a call? But the pruning happens with a certain delay and that's the reason it works for more recent blocks?

@AskAlexSharov
Copy link
Collaborator

Yes, 90k blocks by default. See “erigon —help” part about prune

@mandrigin
Copy link
Collaborator

@AskAlexSharov shouldn’t we return an error instead of crashing in that case?

@AskAlexSharov
Copy link
Collaborator

@mandrigin of course, and better user-friendly one

@mandrigin
Copy link
Collaborator

I will reopen then

@mandrigin mandrigin reopened this Jul 14, 2022
@mandrigin mandrigin changed the title eth_call "method handler crashed" depending on block argument eth_call - return an error in case the request is to the pruned block Jul 14, 2022
@mandrigin
Copy link
Collaborator

mandrigin commented Jul 14, 2022

@dmitryselivanov will take this one

@dmitriyselivanov
Copy link

Yep, I will take this one :D

@dmitriyselivanov
Copy link

I cannot reproduce method handler crashed on current devel branch. Now eth_call returns "result": "0x" if a request is executed to the pruned block.
I added the test for such case in the following PR, feel free to comment and review
#4776

@mandrigin
Copy link
Collaborator

considering it closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants