update relevant portions of attestation aggregation spec version; tweak inspector

This commit is contained in:
Dustin Brody 2020-02-21 15:53:12 +01:00 committed by tersec
parent a8567cafb5
commit 62584b633e
3 changed files with 7 additions and 9 deletions

View File

@ -40,7 +40,7 @@ func get_slot_signature(state: BeaconState, slot: Slot, privkey: ValidatorPrivKe
get_domain(state, DOMAIN_BEACON_ATTESTER, compute_epoch_at_slot(slot))
bls_sign(privkey, hash_tree_root(slot).data, domain)
# https://github.com/ethereum/eth2.0-specs/blob/v0.9.4/specs/validator/0_beacon-chain-validator.md#aggregation-selection
# https://github.com/ethereum/eth2.0-specs/blob/v0.10.1/specs/phase0/validator.md#aggregation-selection
func is_aggregator(state: BeaconState, slot: Slot, index: uint64,
slot_signature: ValidatorSig): bool =
# TODO index is a CommitteeIndex, aka uint64
@ -65,17 +65,17 @@ proc aggregate_attestations*(
doAssert slot + ATTESTATION_PROPAGATION_SLOT_RANGE >= state.slot
doAssert state.slot >= slot
# https://github.com/ethereum/eth2.0-specs/blob/v0.9.4/specs/validator/0_beacon-chain-validator.md#aggregation-selection
# https://github.com/ethereum/eth2.0-specs/blob/v0.10.1/specs/phase0/validator.md#aggregation-selection
if not is_aggregator(state, slot, index, slot_signature):
return none(AggregateAndProof)
let attestation_data =
makeAttestationData(state, slot, index, get_block_root_at_slot(state, slot))
# https://github.com/ethereum/eth2.0-specs/blob/v0.10.0/specs/phase0/validator.md#construct-aggregate
# https://github.com/ethereum/eth2.0-specs/blob/v0.10.1/specs/phase0/validator.md#construct-aggregate
for attestation in getAttestationsForBlock(pool, state, slot):
if attestation.data == attestation_data:
# https://github.com/ethereum/eth2.0-specs/blob/v0.10.0/specs/phase0/validator.md#aggregateandproof
# https://github.com/ethereum/eth2.0-specs/blob/v0.10.1/specs/phase0/validator.md#aggregateandproof
return some(AggregateAndProof(
aggregator_index: index,
aggregate: attestation,

View File

@ -93,7 +93,7 @@ type
abbr: "d"
defaultValue: false }: bool
func getTopic(filter: TopicFilter): seq[string] {.inline.} =
func getTopics(filter: TopicFilter): seq[string] {.inline.} =
case filter
of TopicFilter.Blocks:
@[topicBeaconBlocks]
@ -106,7 +106,7 @@ func getTopic(filter: TopicFilter): seq[string] {.inline.} =
of TopicFilter.AttesterSlashings:
@[topicAttesterSlashings]
proc getPeerId(peer: PeerID, conf: InspectorConf): string {.inline.} =
func getPeerId(peer: PeerID, conf: InspectorConf): string {.inline.} =
if conf.fullPeerId:
result = peer.pretty()
else:
@ -278,8 +278,7 @@ proc run(conf: InspectorConf) {.async.} =
try:
for filter in topics:
let topics = getTopic(filter)
for topic in topics:
for topic in getTopics(filter):
let t = await api.pubsubSubscribe(topic, pubsubLogger)
info "Subscribed to topic", topic = topic
subs.add((ticket: t, future: t.transp.join()))

View File

@ -59,7 +59,6 @@ else:
const
SPEC_VERSION* = "0.10.1" ## \
## Spec version we're aiming to be compatible with, right now
## TODO: improve this scheme once we can negotiate versions in protocol
GENESIS_EPOCH* = (GENESIS_SLOT.uint64 div SLOTS_PER_EPOCH).Epoch ##\
## compute_epoch_at_slot(GENESIS_SLOT)