shutter-network / rolling-shutter

Rolling Shutter is an MEV protection system to be plugged into rollups.
https://twitter.com/project_shutter/
26 stars 7 forks source link

segfault when shutting down chain subcommand #388

Closed schmir closed 1 month ago

schmir commented 11 months ago
$ rm -rf boot; rolling-shutter chain init --root boot --genesis-keyper 0x440Dc6F164e9241F04d282215ceF2780cd0B755e; rolling-shutter chain --config boot/config/config.toml --loglevel=debug
2023/07/17 17:06:50.322511 INF [         init.go:203] Generated private validator privValKeyFile=boot/config/priv_validator_key.json stateFile=boot/data/priv_validator_state.json
2023/07/17 17:06:50.322613 INF [         init.go:212] Saved private validator publickey path=boot/config/priv_validator_pubkey.hex validatorPublicKey=e1513d8d803bafd7f69bb4633814b4f8f428e818e417a1d605c18d4908505471
2023/07/17 17:06:50.322706 INF [         init.go:242] Generated genesis file path=boot/config/genesis.json
2023/07/17 17:06:50.322765 INF [         init.go:259] Generated node key id=de4c26ba15043483d46cfad78f9eff71fd4c35f3 path=boot/config/node_key.json
2023/07/17 17:06:50.322781 INF [          app.go:753] persisting state to disk height=0
2023/07/17 17:06:50.355138 INF [         chain.go:40] starting shuttermint version="(devel-075ecfa5e8776562a266baacceb73bbdc5288bb8) (go1.20.3, linux-amd64)"
2023/07/17 17:06:50.356174 INF [         chain.go:68] loaded node-id node-id=de4c26ba15043483d46cfad78f9eff71fd4c35f3
2023/07/17 17:06:50.356374 INF [          app.go:111] Loaded shutter app from file devmode=false file=boot/data/shutter.gob last-block-height=0 last-saved="2023/07/17 15:06:50.322810"
2023/07/17 17:06:50.451456 INF [          app.go:230] initializing new chain
2023/07/17 17:06:50.451475 INF [          app.go:232] initial keyper index=0 keyper="0x440Dc6F164e9241F04d282215ceF2780cd0B755e [chksum ok]"
^C2023/07/17 17:06:51.588071 INF [       service.go:84] received OS signal, shutting down signal=interrupt
2023/07/17 17:06:51.588180 DBG [         chain.go:97] Stopping node
2023/07/17 17:06:51.588275 ERR [         node.go:820] failed to stop event sink err="leveldb: closed"
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x58 pc=0x11955d1]

goroutine 965 [running]:
github.com/tendermint/tendermint/node.(*nodeImpl).OnStop(0xc000818b40)
        /home/ralf/go/pkg/mod/github.com/tendermint/tendermint@v0.35.9/node/node.go:853 +0x6f1
github.com/tendermint/tendermint/libs/service.(*BaseService).Stop(0xc000818b40)
        /home/ralf/go/pkg/mod/github.com/tendermint/tendermint@v0.35.9/libs/service/service.go:171 +0x2b7
github.com/shutter-network/rolling-shutter/rolling-shutter/cmd/chain.(*appService).Start.func2()
        /home/ralf/brainbot-com/rolling-shutter/rolling-shutter/cmd/chain/chain.go:98 +0x78
golang.org/x/sync/errgroup.(*Group).Go.func1()
        /home/ralf/go/pkg/mod/golang.org/x/sync@v0.1.0/errgroup/errgroup.go:75 +0x64
created by golang.org/x/sync/errgroup.(*Group).Go
        /home/ralf/go/pkg/mod/golang.org/x/sync@v0.1.0/errgroup/errgroup.go:72 +0xa5
schmir commented 11 months ago

This is caused by a bug in tendermint, which tries to shutdown the peer exchange reactor. Since we disable the peer exchange reactor starting from commit e2f95433a8cf1c4809d47ce637b034707ded9f8b the pexReactor field may be nil and the program segfaults. Prior to that commit we never disabled the pex reactor and therefore didn't run into this bug.

The bug appears to be fixed by upgrading to tendermint v0.37.0-rc2.

jannikluhn commented 1 month ago

Done