status-im/nimbus-eth2

[crash] `unhandled exception IndexError` when parsing ProposerSlashing

Closed this issue · 2 comments

This bug has been found by the community using beacon-fuzz and reported in our repository here.

Kudos to @Daft-Wullie for the finding !!

Please, find some extra information below for debugging ;)

Download: crash_index_numbus.zip

Crash

Traceback (most recent call last, using override)
/home/scop/Documents/consulting/sigmaprime/nim-beacon-chain/vendor/nim-confutils/confutils.nim(1020) confutils
/home/scop/Documents/consulting/sigmaprime/nim-beacon-chain/ncli/ncli_query.nim(24) CLI
/home/scop/Documents/consulting/sigmaprime/nim-beacon-chain/vendor/nimbus-build-system/vendor/Nim/lib/system/excpt.nim(407) reportUnhandledError
/home/scop/Documents/consulting/sigmaprime/nim-beacon-chain/vendor/nimbus-build-system/vendor/Nim/lib/system/excpt.nim(358) reportUnhandledErrorAux
Error: unhandled exception: index -4703124616608923521 not in 0 .. 255 [IndexError]

Reproducing code:

import
  confutils, os, strutils, chronicles, json_serialization,
  ../beacon_chain/spec/crypto,
  ../beacon_chain/spec/datatypes,
  ../beacon_chain/spec/digest,
  ../beacon_chain/spec/validator,
  ../beacon_chain/spec/beaconstate,
  ../beacon_chain/spec/state_transition_block,
  ../beacon_chain/ssz,
  ../beacon_chain/extras,
  ../beacon_chain/spec/state_transition,
  ../beacon_chain/eth2_discovery

cli do(beacon: string, container: string):
  try :
    var b = SSZ.loadFile(beacon, BeaconState)
    var c = SSZ.loadFile(container, ProposerSlashing)
    var cache = get_empty_per_epoch_cache()
    discard process_proposer_slashing(b, c, {}, cache)
  except SSZError:
    quit 1
  quit 0

Compilation:

./env.sh nim c -r -d:release -d:ETH2_SPEC="v0.12.1" -d:BLS_ETH2_SPEC="v0.12.x" -d:preset=mainnet debug.nim

Run:

./debug --beacon=beacon.ssz  --container=propo.ssz

branch: "devel"
commit: a82c38d

As a small note,

-d:ETH2_SPEC="v0.12.1" -d:BLS_ETH2_SPEC="v0.12.x"

Isn't necessary anymore since we've switched to being v0.12.1-only. It's harmless, so feel free to include it if you'd prefer, but arguably excluding it makes it clearer that one is, in fact, dealing with the default configuration, and not some exotic/untested combinatoin.

Fixed by #1325