require sync committee supermajority in CI (#5085)

* require sync committee supermajority in CI

To better catch problems with sync committee messages in CI, extend
local testnet simulation to also verify that each block is signed
by a supermajority of the sync committee.

Requires #5083 and #5084

* lint
This commit is contained in:
Etan Kissling 2023-06-17 08:00:01 +02:00 committed by GitHub
parent 8c6c8a0ffa
commit 3a6b50cf21
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 23 additions and 9 deletions

View File

@ -465,8 +465,17 @@ proc process_sync_aggregate*(
state: var (altair.BeaconState | bellatrix.BeaconState |
capella.BeaconState | deneb.BeaconState),
sync_aggregate: SomeSyncAggregate, total_active_balance: Gwei,
flags: UpdateFlags,
cache: var StateCache):
Result[void, cstring] =
if strictVerification in flags and state.slot > 1.Slot:
template sync_committee_bits(): auto = sync_aggregate.sync_committee_bits
let num_active_participants = countOnes(sync_committee_bits).uint64
if num_active_participants * 3 < static(sync_committee_bits.len * 2):
fatal "Low sync committee participation",
slot = state.slot, num_active_participants
quit 1
# Verify sync committee aggregate signature signing over the previous slot
# block root
when sync_aggregate.sync_committee_signature isnot TrustedSig:
@ -822,7 +831,8 @@ proc process_block*(
? process_operations(
cfg, state, blck.body, base_reward_per_increment, flags, cache)
? process_sync_aggregate(
state, blck.body.sync_aggregate, total_active_balance, cache) # [New in Altair]
state, blck.body.sync_aggregate, total_active_balance,
flags, cache) # [New in Altair]
ok()
@ -853,7 +863,7 @@ proc process_block*(
? process_operations(
cfg, state, blck.body, base_reward_per_increment, flags, cache)
? process_sync_aggregate(
state, blck.body.sync_aggregate, total_active_balance, cache)
state, blck.body.sync_aggregate, total_active_balance, flags, cache)
ok()
@ -890,7 +900,7 @@ proc process_block*(
cfg, state, blck.body, base_reward_per_increment,
flags, cache) # [Modified in Capella]
? process_sync_aggregate(
state, blck.body.sync_aggregate, total_active_balance, cache)
state, blck.body.sync_aggregate, total_active_balance, flags, cache)
ok()
@ -925,6 +935,6 @@ proc process_block*(
? process_operations(
cfg, state, blck.body, base_reward_per_increment, flags, cache)
? process_sync_aggregate(
state, blck.body.sync_aggregate, total_active_balance, cache)
state, blck.body.sync_aggregate, total_active_balance, flags, cache)
ok()

View File

@ -1,5 +1,5 @@
# beacon_chain
# Copyright (c) 2018-2022 Status Research & Development GmbH
# Copyright (c) 2018-2023 Status Research & Development GmbH
# Licensed and distributed under either of
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
@ -140,7 +140,8 @@ suite baseDescription & "Sync Aggregate " & preset():
Result[void, cstring] =
var cache = StateCache()
process_sync_aggregate(
preState, syncAggregate, get_total_active_balance(preState, cache), cache)
preState, syncAggregate, get_total_active_balance(preState, cache),
{}, cache)
for path in walkTests(OpSyncAggregateDir):
runTest[SyncAggregate, typeof applySyncAggregate](

View File

@ -161,7 +161,8 @@ suite baseDescription & "Sync Aggregate " & preset():
Result[void, cstring] =
var cache = StateCache()
process_sync_aggregate(
preState, syncAggregate, get_total_active_balance(preState, cache), cache)
preState, syncAggregate, get_total_active_balance(preState, cache),
{}, cache)
for path in walkTests(OpSyncAggregateDir):
runTest[SyncAggregate, typeof applySyncAggregate](

View File

@ -178,7 +178,8 @@ suite baseDescription & "Sync Aggregate " & preset():
Result[void, cstring] =
var cache = StateCache()
process_sync_aggregate(
preState, syncAggregate, get_total_active_balance(preState, cache), cache)
preState, syncAggregate, get_total_active_balance(preState, cache),
{}, cache)
for path in walkTests(OpSyncAggregateDir):
runTest[SyncAggregate, typeof applySyncAggregate](

View File

@ -180,7 +180,8 @@ suite baseDescription & "Sync Aggregate " & preset():
Result[void, cstring] =
var cache = StateCache()
process_sync_aggregate(
preState, syncAggregate, get_total_active_balance(preState, cache), cache)
preState, syncAggregate, get_total_active_balance(preState, cache),
{}, cache)
for path in walkTests(OpSyncAggregateDir):
runTest[SyncAggregate, typeof applySyncAggregate](