Skip to content

Commit

Permalink
update ShufflingRef version of get_attesting_indices to Electra v1.5.…
Browse files Browse the repository at this point in the history
…0-alpha.10 (#6801)
  • Loading branch information
tersec authored Dec 30, 2024
1 parent 1778979 commit 0e86c0d
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 25 deletions.
37 changes: 23 additions & 14 deletions beacon_chain/consensus_object_pools/spec_cache.nim
Original file line number Diff line number Diff line change
Expand Up @@ -99,21 +99,30 @@ iterator get_attesting_indices*(shufflingRef: ShufflingRef,
if bits[index_in_committee]:
yield validator_index

# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.0/specs/electra/beacon-chain.md#modified-get_attesting_indices
iterator get_attesting_indices*(shufflingRef: ShufflingRef,
slot: Slot,
committee_bits: AttestationCommitteeBits,
aggregation_bits: ElectraCommitteeValidatorsBits, on_chain: static bool):
ValidatorIndex =
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.10/specs/electra/beacon-chain.md#modified-get_attesting_indices
iterator get_attesting_indices*(
shufflingRef: ShufflingRef, slot: Slot,
committee_bits: AttestationCommitteeBits,
aggregation_bits: ElectraCommitteeValidatorsBits, on_chain: static bool):
ValidatorIndex =
when on_chain:
var pos = 0
for committee_index in get_committee_indices(committee_bits):
for _, validator_index in get_beacon_committee(
shufflingRef, slot, committee_index):

if aggregation_bits[pos]:
yield validator_index
pos += 1
var committee_offset = 0
for committee_index in committee_bits.oneIndices:
if not (committee_index.uint64 <
get_committee_count_per_slot(shufflingRef)):
continue # invalid attestation, but found in check_attestation()
let committee = get_beacon_committee(
shufflingRef, slot, committee_index.CommitteeIndex)

if aggregation_bits.len < committee_offset + len(committee):
# Would overflow, invalid attestation caught in check_attestation()
continue

for i, attester_index in committee:
if aggregation_bits[committee_offset + i]:
yield attester_index

committee_offset += len(committee)
else:
let committee_index = get_committee_index_one(committee_bits)
for validator_index in get_attesting_indices(
Expand Down
2 changes: 1 addition & 1 deletion beacon_chain/nimbus_light_client.nim
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ programMain:
db.putSyncCommittee(period, syncCommittee)
db.putLatestFinalizedHeader(finalizedHeader)

var optimisticFcuFut: Future[(PayloadExecutionStatus, Opt[BlockHash])]
var optimisticFcuFut: Future[(PayloadExecutionStatus, Opt[Hash32])]
.Raising([CancelledError])
proc onOptimisticHeader(
lightClient: LightClient, optimisticHeader: ForkedLightClientHeader) =
Expand Down
4 changes: 0 additions & 4 deletions beacon_chain/spec/crypto.nim
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@

{.push raises: [].}

# At the time of writing, the exact definitions of what should be used for
# cryptography in the spec is in flux, with sizes and test vectors still being
# hashed out. This layer helps isolate those chagnes.

# BLS signatures can be combined such that multiple signatures are aggregated.
# Each time a new signature is added, the corresponding public key must be
# added to the verification key as well - if a key signs twice, it must be added
Expand Down
2 changes: 1 addition & 1 deletion beacon_chain/sync/request_manager.nim
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ proc checkResponse(idList: seq[DataColumnIdentifier],
block_root = hash_tree_root(columns[i].signed_block_header.message)
id = idList[i]

# Check if the column reponse is a subset
# Check if the column response is a subset
if binarySearch(idList, columns[i], cmpSidecarIdentifier) == -1:
return false

Expand Down
4 changes: 2 additions & 2 deletions docs/the_nimbus_book/src/validator-client-options.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Validator client

In the most simple setup, a single beacon node paired with an execution client is all that is needed to run a successful validator setup.
In the simplest setup, a single beacon node paired with an execution client is all that is needed to run a successful validator setup.

Nimbus however also provides options for running advanded setups that provide additional security and redundancy.
Nimbus however also provides options for running advanced setups that provide additional security and redundancy.

See the [validator client page](./validator-client.md) to get started!

Expand Down
13 changes: 10 additions & 3 deletions ncli/ncli_split_keystore.nim
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
# at your option. This file may not be copied, modified, or distributed except according to those terms.

{.push raises: [].}

import
std/os,
confutils,
Expand Down Expand Up @@ -45,17 +47,22 @@ type
name: "out-dir" }: OutDir

proc main =
let conf = load Config
let conf =
try:
load Config
except ConfigurationError:
error "Configuration error"
quit 1
if conf.threshold == 0:
error "The specified treshold must be greater than zero"
error "The specified threshold must be greater than zero"
quit 1

if conf.remoteSignersUrls.len == 0:
error "Please specify at least one remote signer URL"
quit 1

if conf.threshold > conf.remoteSignersUrls.len.uint32:
error "The specified treshold must be lower or equal to the number of signers"
error "The specified threshold must be lower or equal to the number of signers"
quit 1

let rng = HmacDrbgContext.new()
Expand Down

0 comments on commit 0e86c0d

Please sign in to comment.