add some support for electra aggregated attestations (#6283)
This commit is contained in:
parent
87605d08a7
commit
3f972a2ca5
|
@ -414,7 +414,7 @@ proc scheduleAttestationCheck*(
|
||||||
|
|
||||||
proc scheduleAggregateChecks*(
|
proc scheduleAggregateChecks*(
|
||||||
batchCrypto: ref BatchCrypto, fork: Fork,
|
batchCrypto: ref BatchCrypto, fork: Fork,
|
||||||
signedAggregateAndProof: SignedAggregateAndProof, dag: ChainDAGRef,
|
signedAggregateAndProof: phase0.SignedAggregateAndProof, dag: ChainDAGRef,
|
||||||
attesting_indices: openArray[ValidatorIndex]
|
attesting_indices: openArray[ValidatorIndex]
|
||||||
): Result[tuple[
|
): Result[tuple[
|
||||||
aggregatorFut, slotFut, aggregateFut: FutureBatchResult,
|
aggregatorFut, slotFut, aggregateFut: FutureBatchResult,
|
||||||
|
|
|
@ -412,7 +412,7 @@ proc processAttestation*(
|
||||||
|
|
||||||
proc processSignedAggregateAndProof*(
|
proc processSignedAggregateAndProof*(
|
||||||
self: ref Eth2Processor, src: MsgSource,
|
self: ref Eth2Processor, src: MsgSource,
|
||||||
signedAggregateAndProof: SignedAggregateAndProof,
|
signedAggregateAndProof: phase0.SignedAggregateAndProof,
|
||||||
checkSignature = true, checkCover = true): Future[ValidationRes] {.async: (raises: [CancelledError]).} =
|
checkSignature = true, checkCover = true): Future[ValidationRes] {.async: (raises: [CancelledError]).} =
|
||||||
var wallTime = self.getCurrentBeaconTime()
|
var wallTime = self.getCurrentBeaconTime()
|
||||||
let (afterGenesis, wallSlot) = wallTime.toSlot()
|
let (afterGenesis, wallSlot) = wallTime.toSlot()
|
||||||
|
|
|
@ -822,7 +822,7 @@ proc validateAttestation*(
|
||||||
proc validateAggregate*(
|
proc validateAggregate*(
|
||||||
pool: ref AttestationPool,
|
pool: ref AttestationPool,
|
||||||
batchCrypto: ref BatchCrypto,
|
batchCrypto: ref BatchCrypto,
|
||||||
signedAggregateAndProof: SignedAggregateAndProof,
|
signedAggregateAndProof: phase0.SignedAggregateAndProof,
|
||||||
wallTime: BeaconTime,
|
wallTime: BeaconTime,
|
||||||
checkSignature = true, checkCover = true):
|
checkSignature = true, checkCover = true):
|
||||||
Future[Result[
|
Future[Result[
|
||||||
|
|
|
@ -838,7 +838,7 @@ template gossipMaxSize(T: untyped): uint32 =
|
||||||
# have lists bounded at MAX_VALIDATORS_PER_COMMITTEE (2048) items, thus
|
# have lists bounded at MAX_VALIDATORS_PER_COMMITTEE (2048) items, thus
|
||||||
# having max sizes significantly smaller than GOSSIP_MAX_SIZE.
|
# having max sizes significantly smaller than GOSSIP_MAX_SIZE.
|
||||||
elif T is phase0.Attestation or T is phase0.AttesterSlashing or
|
elif T is phase0.Attestation or T is phase0.AttesterSlashing or
|
||||||
T is SignedAggregateAndProof or T is phase0.SignedBeaconBlock or
|
T is phase0.SignedAggregateAndProof or T is phase0.SignedBeaconBlock or
|
||||||
T is altair.SignedBeaconBlock or T is SomeForkyLightClientObject:
|
T is altair.SignedBeaconBlock or T is SomeForkyLightClientObject:
|
||||||
GOSSIP_MAX_SIZE
|
GOSSIP_MAX_SIZE
|
||||||
else:
|
else:
|
||||||
|
@ -2611,7 +2611,7 @@ proc broadcastBlsToExecutionChange*(
|
||||||
node.broadcast(topic, bls_to_execution_change)
|
node.broadcast(topic, bls_to_execution_change)
|
||||||
|
|
||||||
proc broadcastAggregateAndProof*(
|
proc broadcastAggregateAndProof*(
|
||||||
node: Eth2Node, proof: SignedAggregateAndProof):
|
node: Eth2Node, proof: phase0.SignedAggregateAndProof):
|
||||||
Future[SendResult] {.async: (raises: [CancelledError], raw: true).} =
|
Future[SendResult] {.async: (raises: [CancelledError], raw: true).} =
|
||||||
let topic = getAggregateAndProofsTopic(
|
let topic = getAggregateAndProofsTopic(
|
||||||
node.forkDigestAtEpoch(node.getWallEpoch))
|
node.forkDigestAtEpoch(node.getWallEpoch))
|
||||||
|
|
|
@ -1111,6 +1111,10 @@ proc addDenebMessageHandlers(
|
||||||
for topic in blobSidecarTopics(forkDigest):
|
for topic in blobSidecarTopics(forkDigest):
|
||||||
node.network.subscribe(topic, basicParams)
|
node.network.subscribe(topic, basicParams)
|
||||||
|
|
||||||
|
proc addElectraMessageHandlers(
|
||||||
|
node: BeaconNode, forkDigest: ForkDigest, slot: Slot) =
|
||||||
|
node.addDenebMessageHandlers(forkDigest, slot)
|
||||||
|
|
||||||
proc removeAltairMessageHandlers(node: BeaconNode, forkDigest: ForkDigest) =
|
proc removeAltairMessageHandlers(node: BeaconNode, forkDigest: ForkDigest) =
|
||||||
node.removePhase0MessageHandlers(forkDigest)
|
node.removePhase0MessageHandlers(forkDigest)
|
||||||
|
|
||||||
|
@ -1131,6 +1135,9 @@ proc removeDenebMessageHandlers(node: BeaconNode, forkDigest: ForkDigest) =
|
||||||
for topic in blobSidecarTopics(forkDigest):
|
for topic in blobSidecarTopics(forkDigest):
|
||||||
node.network.unsubscribe(topic)
|
node.network.unsubscribe(topic)
|
||||||
|
|
||||||
|
proc removeElectraMessageHandlers(node: BeaconNode, forkDigest: ForkDigest) =
|
||||||
|
node.removeDenebMessageHandlers(forkDigest)
|
||||||
|
|
||||||
proc updateSyncCommitteeTopics(node: BeaconNode, slot: Slot) =
|
proc updateSyncCommitteeTopics(node: BeaconNode, slot: Slot) =
|
||||||
template lastSyncUpdate: untyped =
|
template lastSyncUpdate: untyped =
|
||||||
node.consensusManager[].actionTracker.lastSyncUpdate
|
node.consensusManager[].actionTracker.lastSyncUpdate
|
||||||
|
@ -1359,7 +1366,7 @@ proc updateGossipStatus(node: BeaconNode, slot: Slot) {.async.} =
|
||||||
removeAltairMessageHandlers, # bellatrix (altair handlers, different forkDigest)
|
removeAltairMessageHandlers, # bellatrix (altair handlers, different forkDigest)
|
||||||
removeCapellaMessageHandlers,
|
removeCapellaMessageHandlers,
|
||||||
removeDenebMessageHandlers,
|
removeDenebMessageHandlers,
|
||||||
removeDenebMessageHandlers # maybe duplicate is correct, don't know yet
|
removeElectraMessageHandlers
|
||||||
]
|
]
|
||||||
|
|
||||||
for gossipFork in oldGossipForks:
|
for gossipFork in oldGossipForks:
|
||||||
|
@ -1372,7 +1379,7 @@ proc updateGossipStatus(node: BeaconNode, slot: Slot) {.async.} =
|
||||||
addAltairMessageHandlers, # bellatrix (altair handlers, different forkDigest)
|
addAltairMessageHandlers, # bellatrix (altair handlers, different forkDigest)
|
||||||
addCapellaMessageHandlers,
|
addCapellaMessageHandlers,
|
||||||
addDenebMessageHandlers,
|
addDenebMessageHandlers,
|
||||||
addDenebMessageHandlers # repeat is probably correct
|
addElectraMessageHandlers
|
||||||
]
|
]
|
||||||
|
|
||||||
for gossipFork in newGossipForks:
|
for gossipFork in newGossipForks:
|
||||||
|
@ -1750,6 +1757,7 @@ proc installMessageValidators(node: BeaconNode) =
|
||||||
# beacon_attestation_{subnet_id}
|
# beacon_attestation_{subnet_id}
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.5/specs/phase0/p2p-interface.md#beacon_attestation_subnet_id
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.5/specs/phase0/p2p-interface.md#beacon_attestation_subnet_id
|
||||||
for it in SubnetId:
|
for it in SubnetId:
|
||||||
|
debugRaiseAssert "allow for electra.Attestation"
|
||||||
closureScope: # Needed for inner `proc`; don't lift it out of loop.
|
closureScope: # Needed for inner `proc`; don't lift it out of loop.
|
||||||
let subnet_id = it
|
let subnet_id = it
|
||||||
node.network.addAsyncValidator(
|
node.network.addAsyncValidator(
|
||||||
|
@ -1762,9 +1770,10 @@ proc installMessageValidators(node: BeaconNode) =
|
||||||
|
|
||||||
# beacon_aggregate_and_proof
|
# beacon_aggregate_and_proof
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.4/specs/phase0/p2p-interface.md#beacon_aggregate_and_proof
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.4/specs/phase0/p2p-interface.md#beacon_aggregate_and_proof
|
||||||
|
debugRaiseAssert "allow for electra.SignedAggregateAndProof"
|
||||||
node.network.addAsyncValidator(
|
node.network.addAsyncValidator(
|
||||||
getAggregateAndProofsTopic(digest), proc (
|
getAggregateAndProofsTopic(digest), proc (
|
||||||
signedAggregateAndProof: SignedAggregateAndProof
|
signedAggregateAndProof: phase0.SignedAggregateAndProof
|
||||||
): Future[ValidationResult] {.async: (raises: [CancelledError]).} =
|
): Future[ValidationResult] {.async: (raises: [CancelledError]).} =
|
||||||
return toValidationResult(
|
return toValidationResult(
|
||||||
await node.processor.processSignedAggregateAndProof(
|
await node.processor.processSignedAggregateAndProof(
|
||||||
|
@ -1848,6 +1857,9 @@ proc installMessageValidators(node: BeaconNode) =
|
||||||
node.processor[].processBlobSidecar(
|
node.processor[].processBlobSidecar(
|
||||||
MsgSource.gossip, blobSidecar, subnet_id)))
|
MsgSource.gossip, blobSidecar, subnet_id)))
|
||||||
|
|
||||||
|
when consensusFork >= ConsensusFork.Electra:
|
||||||
|
discard
|
||||||
|
|
||||||
node.installLightClientMessageValidators()
|
node.installLightClientMessageValidators()
|
||||||
|
|
||||||
proc stop(node: BeaconNode) =
|
proc stop(node: BeaconNode) =
|
||||||
|
|
|
@ -801,7 +801,7 @@ proc installValidatorApiHandlers*(router: var RestRouter, node: BeaconNode) =
|
||||||
block:
|
block:
|
||||||
if contentBody.isNone():
|
if contentBody.isNone():
|
||||||
return RestApiResponse.jsonError(Http400, EmptyRequestBodyError)
|
return RestApiResponse.jsonError(Http400, EmptyRequestBodyError)
|
||||||
let dres = decodeBody(seq[SignedAggregateAndProof], contentBody.get())
|
let dres = decodeBody(seq[phase0.SignedAggregateAndProof], contentBody.get())
|
||||||
if dres.isErr():
|
if dres.isErr():
|
||||||
return RestApiResponse.jsonError(Http400,
|
return RestApiResponse.jsonError(Http400,
|
||||||
InvalidAggregateAndProofObjectError,
|
InvalidAggregateAndProofObjectError,
|
||||||
|
|
|
@ -196,6 +196,17 @@ type
|
||||||
NextSyncCommitteeBranch =
|
NextSyncCommitteeBranch =
|
||||||
array[log2trunc(NEXT_SYNC_COMMITTEE_GINDEX), Eth2Digest]
|
array[log2trunc(NEXT_SYNC_COMMITTEE_GINDEX), Eth2Digest]
|
||||||
|
|
||||||
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/validator.md#aggregateandproof
|
||||||
|
AggregateAndProof* = object
|
||||||
|
aggregator_index*: uint64 # `ValidatorIndex` after validation
|
||||||
|
aggregate*: Attestation
|
||||||
|
selection_proof*: ValidatorSig
|
||||||
|
|
||||||
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/validator.md#signedaggregateandproof
|
||||||
|
SignedAggregateAndProof* = object
|
||||||
|
message*: AggregateAndProof
|
||||||
|
signature*: ValidatorSig
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.5/specs/capella/light-client/sync-protocol.md#modified-lightclientheader
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.5/specs/capella/light-client/sync-protocol.md#modified-lightclientheader
|
||||||
LightClientHeader* = object
|
LightClientHeader* = object
|
||||||
beacon*: BeaconBlockHeader
|
beacon*: BeaconBlockHeader
|
||||||
|
|
|
@ -44,7 +44,6 @@ type
|
||||||
createJsonFlavor RestJson
|
createJsonFlavor RestJson
|
||||||
|
|
||||||
RestJson.useDefaultSerializationFor(
|
RestJson.useDefaultSerializationFor(
|
||||||
AggregateAndProof,
|
|
||||||
AttestationData,
|
AttestationData,
|
||||||
BLSToExecutionChange,
|
BLSToExecutionChange,
|
||||||
BeaconBlockHeader,
|
BeaconBlockHeader,
|
||||||
|
@ -168,7 +167,6 @@ RestJson.useDefaultSerializationFor(
|
||||||
SetFeeRecipientRequest,
|
SetFeeRecipientRequest,
|
||||||
SetGasLimitRequest,
|
SetGasLimitRequest,
|
||||||
SetGraffitiRequest,
|
SetGraffitiRequest,
|
||||||
SignedAggregateAndProof,
|
|
||||||
SignedBLSToExecutionChange,
|
SignedBLSToExecutionChange,
|
||||||
SignedBeaconBlockHeader,
|
SignedBeaconBlockHeader,
|
||||||
SignedConsolidation,
|
SignedConsolidation,
|
||||||
|
@ -263,12 +261,14 @@ RestJson.useDefaultSerializationFor(
|
||||||
electra_mev.ExecutionPayloadAndBlobsBundle,
|
electra_mev.ExecutionPayloadAndBlobsBundle,
|
||||||
electra_mev.SignedBlindedBeaconBlock,
|
electra_mev.SignedBlindedBeaconBlock,
|
||||||
electra_mev.SignedBuilderBid,
|
electra_mev.SignedBuilderBid,
|
||||||
|
phase0.AggregateAndProof,
|
||||||
phase0.Attestation,
|
phase0.Attestation,
|
||||||
phase0.AttesterSlashing,
|
phase0.AttesterSlashing,
|
||||||
phase0.BeaconBlock,
|
phase0.BeaconBlock,
|
||||||
phase0.BeaconBlockBody,
|
phase0.BeaconBlockBody,
|
||||||
phase0.BeaconState,
|
phase0.BeaconState,
|
||||||
phase0.IndexedAttestation,
|
phase0.IndexedAttestation,
|
||||||
|
phase0.SignedAggregateAndProof,
|
||||||
phase0.SignedBeaconBlock,
|
phase0.SignedBeaconBlock,
|
||||||
phase0.TrustedAttestation
|
phase0.TrustedAttestation
|
||||||
)
|
)
|
||||||
|
@ -365,7 +365,7 @@ type
|
||||||
seq[RestSignedContributionAndProof] |
|
seq[RestSignedContributionAndProof] |
|
||||||
seq[RestSyncCommitteeMessage] |
|
seq[RestSyncCommitteeMessage] |
|
||||||
seq[RestSyncCommitteeSubscription] |
|
seq[RestSyncCommitteeSubscription] |
|
||||||
seq[SignedAggregateAndProof] |
|
seq[phase0.SignedAggregateAndProof] |
|
||||||
seq[SignedValidatorRegistrationV1] |
|
seq[SignedValidatorRegistrationV1] |
|
||||||
seq[ValidatorIndex] |
|
seq[ValidatorIndex] |
|
||||||
seq[RestBeaconCommitteeSelection] |
|
seq[RestBeaconCommitteeSelection] |
|
||||||
|
@ -2743,7 +2743,7 @@ proc readValue*(reader: var JsonReader[RestJson],
|
||||||
reader.raiseUnexpectedValue("Field `fork_info` is missing")
|
reader.raiseUnexpectedValue("Field `fork_info` is missing")
|
||||||
let data =
|
let data =
|
||||||
block:
|
block:
|
||||||
let res = decodeJsonString(AggregateAndProof, data.get())
|
let res = decodeJsonString(phase0.AggregateAndProof, data.get())
|
||||||
if res.isErr():
|
if res.isErr():
|
||||||
reader.raiseUnexpectedValue(
|
reader.raiseUnexpectedValue(
|
||||||
"Incorrect field `aggregate_and_proof` format")
|
"Incorrect field `aggregate_and_proof` format")
|
||||||
|
|
|
@ -477,7 +477,7 @@ type
|
||||||
serializedFieldName: "aggregation_slot".}: Web3SignerAggregationSlotData
|
serializedFieldName: "aggregation_slot".}: Web3SignerAggregationSlotData
|
||||||
of Web3SignerRequestKind.AggregateAndProof:
|
of Web3SignerRequestKind.AggregateAndProof:
|
||||||
aggregateAndProof* {.
|
aggregateAndProof* {.
|
||||||
serializedFieldName: "aggregate_and_proof".}: AggregateAndProof
|
serializedFieldName: "aggregate_and_proof".}: phase0.AggregateAndProof
|
||||||
of Web3SignerRequestKind.Attestation:
|
of Web3SignerRequestKind.Attestation:
|
||||||
attestation*: AttestationData
|
attestation*: AttestationData
|
||||||
of Web3SignerRequestKind.BlockV2:
|
of Web3SignerRequestKind.BlockV2:
|
||||||
|
@ -799,7 +799,7 @@ func init*(t: typedesc[Web3SignerRequest], fork: Fork,
|
||||||
)
|
)
|
||||||
|
|
||||||
func init*(t: typedesc[Web3SignerRequest], fork: Fork,
|
func init*(t: typedesc[Web3SignerRequest], fork: Fork,
|
||||||
genesis_validators_root: Eth2Digest, data: AggregateAndProof,
|
genesis_validators_root: Eth2Digest, data: phase0.AggregateAndProof,
|
||||||
signingRoot: Opt[Eth2Digest] = Opt.none(Eth2Digest)
|
signingRoot: Opt[Eth2Digest] = Opt.none(Eth2Digest)
|
||||||
): Web3SignerRequest =
|
): Web3SignerRequest =
|
||||||
Web3SignerRequest(
|
Web3SignerRequest(
|
||||||
|
|
|
@ -80,7 +80,7 @@ proc getAggregatedAttestationPlain*(
|
||||||
## https://ethereum.github.io/beacon-APIs/#/Validator/getAggregatedAttestation
|
## https://ethereum.github.io/beacon-APIs/#/Validator/getAggregatedAttestation
|
||||||
|
|
||||||
proc publishAggregateAndProofs*(
|
proc publishAggregateAndProofs*(
|
||||||
body: seq[SignedAggregateAndProof]
|
body: seq[phase0.SignedAggregateAndProof]
|
||||||
): RestPlainResponse {.
|
): RestPlainResponse {.
|
||||||
rest, endpoint: "/eth/v1/validator/aggregate_and_proofs",
|
rest, endpoint: "/eth/v1/validator/aggregate_and_proofs",
|
||||||
meth: MethodPost.}
|
meth: MethodPost.}
|
||||||
|
|
|
@ -108,7 +108,7 @@ proc verify_block_signature*(
|
||||||
|
|
||||||
func compute_aggregate_and_proof_signing_root*(
|
func compute_aggregate_and_proof_signing_root*(
|
||||||
fork: Fork, genesis_validators_root: Eth2Digest,
|
fork: Fork, genesis_validators_root: Eth2Digest,
|
||||||
aggregate_and_proof: AggregateAndProof): Eth2Digest =
|
aggregate_and_proof: phase0.AggregateAndProof): Eth2Digest =
|
||||||
let
|
let
|
||||||
epoch = epoch(aggregate_and_proof.aggregate.data.slot)
|
epoch = epoch(aggregate_and_proof.aggregate.data.slot)
|
||||||
domain = get_domain(
|
domain = get_domain(
|
||||||
|
@ -117,7 +117,7 @@ func compute_aggregate_and_proof_signing_root*(
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/validator.md#broadcast-aggregate
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/validator.md#broadcast-aggregate
|
||||||
func get_aggregate_and_proof_signature*(fork: Fork, genesis_validators_root: Eth2Digest,
|
func get_aggregate_and_proof_signature*(fork: Fork, genesis_validators_root: Eth2Digest,
|
||||||
aggregate_and_proof: AggregateAndProof,
|
aggregate_and_proof: phase0.AggregateAndProof,
|
||||||
privkey: ValidatorPrivKey): CookedSig =
|
privkey: ValidatorPrivKey): CookedSig =
|
||||||
let signing_root = compute_aggregate_and_proof_signing_root(
|
let signing_root = compute_aggregate_and_proof_signing_root(
|
||||||
fork, genesis_validators_root, aggregate_and_proof)
|
fork, genesis_validators_root, aggregate_and_proof)
|
||||||
|
@ -126,7 +126,7 @@ func get_aggregate_and_proof_signature*(fork: Fork, genesis_validators_root: Eth
|
||||||
|
|
||||||
proc verify_aggregate_and_proof_signature*(
|
proc verify_aggregate_and_proof_signature*(
|
||||||
fork: Fork, genesis_validators_root: Eth2Digest,
|
fork: Fork, genesis_validators_root: Eth2Digest,
|
||||||
aggregate_and_proof: AggregateAndProof,
|
aggregate_and_proof: phase0.AggregateAndProof,
|
||||||
pubkey: ValidatorPubKey | CookedPubKey, signature: SomeSig): bool =
|
pubkey: ValidatorPubKey | CookedPubKey, signature: SomeSig): bool =
|
||||||
withTrust(signature):
|
withTrust(signature):
|
||||||
let signing_root = compute_aggregate_and_proof_signing_root(
|
let signing_root = compute_aggregate_and_proof_signing_root(
|
||||||
|
|
|
@ -164,7 +164,7 @@ func block_signature_set*(
|
||||||
# See also: verify_aggregate_and_proof_signature
|
# See also: verify_aggregate_and_proof_signature
|
||||||
func aggregate_and_proof_signature_set*(
|
func aggregate_and_proof_signature_set*(
|
||||||
fork: Fork, genesis_validators_root: Eth2Digest,
|
fork: Fork, genesis_validators_root: Eth2Digest,
|
||||||
aggregate_and_proof: AggregateAndProof,
|
aggregate_and_proof: phase0.AggregateAndProof,
|
||||||
pubkey: CookedPubKey, signature: CookedSig): SignatureSet =
|
pubkey: CookedPubKey, signature: CookedSig): SignatureSet =
|
||||||
let signing_root = compute_aggregate_and_proof_signing_root(
|
let signing_root = compute_aggregate_and_proof_signing_root(
|
||||||
fork, genesis_validators_root, aggregate_and_proof)
|
fork, genesis_validators_root, aggregate_and_proof)
|
||||||
|
|
|
@ -1890,7 +1890,7 @@ proc produceSyncCommitteeContribution*(
|
||||||
|
|
||||||
proc publishAggregateAndProofs*(
|
proc publishAggregateAndProofs*(
|
||||||
vc: ValidatorClientRef,
|
vc: ValidatorClientRef,
|
||||||
data: seq[SignedAggregateAndProof],
|
data: seq[phase0.SignedAggregateAndProof],
|
||||||
strategy: ApiStrategyKind
|
strategy: ApiStrategyKind
|
||||||
): Future[bool] {.async.} =
|
): Future[bool] {.async.} =
|
||||||
const
|
const
|
||||||
|
|
|
@ -85,7 +85,7 @@ proc serveAttestation(
|
||||||
return res
|
return res
|
||||||
|
|
||||||
proc serveAggregateAndProof*(service: AttestationServiceRef,
|
proc serveAggregateAndProof*(service: AttestationServiceRef,
|
||||||
proof: AggregateAndProof,
|
proof: phase0.AggregateAndProof,
|
||||||
validator: AttachedValidator): Future[bool] {.
|
validator: AttachedValidator): Future[bool] {.
|
||||||
async.} =
|
async.} =
|
||||||
let
|
let
|
||||||
|
@ -117,8 +117,8 @@ proc serveAggregateAndProof*(service: AttestationServiceRef,
|
||||||
err_name = exc.name, err_msg = exc.msg
|
err_name = exc.name, err_msg = exc.msg
|
||||||
return false
|
return false
|
||||||
|
|
||||||
let signedProof = SignedAggregateAndProof(message: proof,
|
let signedProof = phase0.SignedAggregateAndProof(
|
||||||
signature: signature)
|
message: proof, signature: signature)
|
||||||
logScope:
|
logScope:
|
||||||
delay = vc.getDelay(slot.aggregate_deadline())
|
delay = vc.getDelay(slot.aggregate_deadline())
|
||||||
|
|
||||||
|
@ -306,7 +306,7 @@ proc produceAndPublishAggregates(service: AttestationServiceRef,
|
||||||
block:
|
block:
|
||||||
var res: seq[Future[bool]]
|
var res: seq[Future[bool]]
|
||||||
for item in aggregateItems:
|
for item in aggregateItems:
|
||||||
let proof = AggregateAndProof(
|
let proof = phase0.AggregateAndProof(
|
||||||
aggregator_index: item.aggregator_index,
|
aggregator_index: item.aggregator_index,
|
||||||
aggregate: aggAttestation,
|
aggregate: aggAttestation,
|
||||||
selection_proof: item.selection_proof
|
selection_proof: item.selection_proof
|
||||||
|
|
|
@ -1537,8 +1537,8 @@ proc signAndSendAggregate(
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/validator.md#construct-aggregate
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/validator.md#construct-aggregate
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/validator.md#aggregateandproof
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/validator.md#aggregateandproof
|
||||||
var
|
var
|
||||||
msg = SignedAggregateAndProof(
|
msg = phase0.SignedAggregateAndProof(
|
||||||
message: AggregateAndProof(
|
message: phase0.AggregateAndProof(
|
||||||
aggregator_index: uint64 validator_index,
|
aggregator_index: uint64 validator_index,
|
||||||
selection_proof: selectionProof))
|
selection_proof: selectionProof))
|
||||||
|
|
||||||
|
|
|
@ -252,7 +252,7 @@ proc routeAttestation*(
|
||||||
attestation, subnet_id, checkSignature = true)
|
attestation, subnet_id, checkSignature = true)
|
||||||
|
|
||||||
proc routeSignedAggregateAndProof*(
|
proc routeSignedAggregateAndProof*(
|
||||||
router: ref MessageRouter, proof: SignedAggregateAndProof,
|
router: ref MessageRouter, proof: phase0.SignedAggregateAndProof,
|
||||||
checkSignature = true):
|
checkSignature = true):
|
||||||
Future[SendResult] {.async: (raises: [CancelledError]).} =
|
Future[SendResult] {.async: (raises: [CancelledError]).} =
|
||||||
## Validate and broadcast aggregate
|
## Validate and broadcast aggregate
|
||||||
|
|
|
@ -685,7 +685,7 @@ proc registerAggregate*(
|
||||||
self: var ValidatorMonitor,
|
self: var ValidatorMonitor,
|
||||||
src: MsgSource,
|
src: MsgSource,
|
||||||
seen_timestamp: BeaconTime,
|
seen_timestamp: BeaconTime,
|
||||||
aggregate_and_proof: AggregateAndProof,
|
aggregate_and_proof: phase0.AggregateAndProof,
|
||||||
attesting_indices: openArray[ValidatorIndex]) =
|
attesting_indices: openArray[ValidatorIndex]) =
|
||||||
let
|
let
|
||||||
slot = aggregate_and_proof.aggregate.data.slot
|
slot = aggregate_and_proof.aggregate.data.slot
|
||||||
|
|
|
@ -735,7 +735,7 @@ proc getAttestationSignature*(v: AttachedValidator, fork: Fork,
|
||||||
proc getAggregateAndProofSignature*(v: AttachedValidator,
|
proc getAggregateAndProofSignature*(v: AttachedValidator,
|
||||||
fork: Fork,
|
fork: Fork,
|
||||||
genesis_validators_root: Eth2Digest,
|
genesis_validators_root: Eth2Digest,
|
||||||
aggregate_and_proof: AggregateAndProof
|
aggregate_and_proof: phase0.AggregateAndProof
|
||||||
): Future[SignatureResult]
|
): Future[SignatureResult]
|
||||||
{.async: (raises: [CancelledError]).} =
|
{.async: (raises: [CancelledError]).} =
|
||||||
case v.kind
|
case v.kind
|
||||||
|
|
|
@ -60,7 +60,7 @@ suite "Message signatures":
|
||||||
fork0, genesis_validators_root1, slot, root, privkey0).toValidatorSig)
|
fork0, genesis_validators_root1, slot, root, privkey0).toValidatorSig)
|
||||||
|
|
||||||
test "Aggregate and proof signatures":
|
test "Aggregate and proof signatures":
|
||||||
let aggregate_and_proof = AggregateAndProof(
|
let aggregate_and_proof = phase0.AggregateAndProof(
|
||||||
aggregate: phase0.Attestation(
|
aggregate: phase0.Attestation(
|
||||||
aggregation_bits: CommitteeValidatorsBits.init(8)))
|
aggregation_bits: CommitteeValidatorsBits.init(8)))
|
||||||
|
|
||||||
|
|
|
@ -678,7 +678,7 @@ block:
|
||||||
GetAggregatedAttestationResponse,
|
GetAggregatedAttestationResponse,
|
||||||
AgAttestation.toOpenArrayByte(0, len(AgAttestation) - 1),
|
AgAttestation.toOpenArrayByte(0, len(AgAttestation) - 1),
|
||||||
Opt.some(contentType)).tryGet().data
|
Opt.some(contentType)).tryGet().data
|
||||||
agProof = AggregateAndProof(
|
agProof = phase0.AggregateAndProof(
|
||||||
aggregator_index: 1'u64,
|
aggregator_index: 1'u64,
|
||||||
aggregate: agAttestation,
|
aggregate: agAttestation,
|
||||||
selection_proof: ValidatorSig.fromHex(SomeSignature).get())
|
selection_proof: ValidatorSig.fromHex(SomeSignature).get())
|
||||||
|
|
Loading…
Reference in New Issue