avoid rejecting empty era file in verification (#6163)

`batchVerify`'s precondition is a non-empty signature list:

```nim
  if input.len == 0:
    # Spec precondition
    return false
```

This means that in eras without any blocks (as has happened on Goerli),
calling it leads to era files being reported as invalid.
This commit is contained in:
Etan Kissling 2024-04-03 10:06:21 +02:00 committed by GitHub
parent 0000f81df0
commit 6a318d0f1a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 3 deletions

View File

@ -1276,7 +1276,7 @@ proc init*(T: type ChainDAGRef, cfg: RuntimeConfig, db: BeaconChainDB,
# If we end up in here, we failed the root comparison just below in
# an earlier iteration
fatal "Era summaries don't lead up to backfill, database or era files corrupt?",
bid
bid, backfillSlot
quit 1
# In BeaconState.block_roots, empty slots are filled with the root of
@ -1299,7 +1299,7 @@ proc init*(T: type ChainDAGRef, cfg: RuntimeConfig, db: BeaconChainDB,
blocks += 1
if blocks > 0:
info "Front-filled blocks from era files", blocks
info "Front-filled blocks from era files", blocks, backfillSlot
let frontfillTick = Moment.now()

View File

@ -257,7 +257,7 @@ proc verify*(f: EraFile, cfg: RuntimeConfig): Result[Eth2Digest, string] =
if blck[].signature != default(type(blck[].signature)):
return err("Genesis slot signature not empty")
if not batchVerify(verifier, sigs):
if sigs.len > 0 and not batchVerify(verifier, sigs):
return err("Invalid block signature")
ok(getStateRoot(state[]))