add (Signed)AggregateAndProof SSZ tests (#6285)
This commit is contained in:
parent
9c669cf57a
commit
1c3aaa7be2
|
@ -16,7 +16,7 @@ import
|
||||||
../spec/datatypes/base,
|
../spec/datatypes/base,
|
||||||
./block_pools_types, blockchain_dag
|
./block_pools_types, blockchain_dag
|
||||||
|
|
||||||
debugRaiseAssert "probably just need Electra shortLog here"
|
debugComment "probably just need Electra shortLog here"
|
||||||
import ../spec/forks # prune this, it's for electra attestation logging
|
import ../spec/forks # prune this, it's for electra attestation logging
|
||||||
|
|
||||||
export
|
export
|
||||||
|
|
|
@ -938,7 +938,7 @@ proc check_attestation*(
|
||||||
return err("Electra attestation data index not 0")
|
return err("Electra attestation data index not 0")
|
||||||
|
|
||||||
var participants_count = 0
|
var participants_count = 0
|
||||||
debugRaiseAssert "cache doesn't know about forks"
|
debugComment "cache doesn't know about forks"
|
||||||
for index in attestation.committee_bits.oneIndices:
|
for index in attestation.committee_bits.oneIndices:
|
||||||
if not (index.uint64 < get_committee_count_per_slot(
|
if not (index.uint64 < get_committee_count_per_slot(
|
||||||
state, data.target.epoch, cache)):
|
state, data.target.epoch, cache)):
|
||||||
|
@ -1548,7 +1548,7 @@ func queue_entire_balance_and_reset_validator(
|
||||||
let validator = addr state.validators.mitem(index)
|
let validator = addr state.validators.mitem(index)
|
||||||
validator[].effective_balance = 0.Gwei
|
validator[].effective_balance = 0.Gwei
|
||||||
validator[].activation_eligibility_epoch = FAR_FUTURE_EPOCH
|
validator[].activation_eligibility_epoch = FAR_FUTURE_EPOCH
|
||||||
debugRaiseAssert "check hashlist add return"
|
debugComment "check hashlist add return"
|
||||||
discard state.pending_balance_deposits.add PendingBalanceDeposit(
|
discard state.pending_balance_deposits.add PendingBalanceDeposit(
|
||||||
index: index, amount: balance)
|
index: index, amount: balance)
|
||||||
|
|
||||||
|
@ -1975,7 +1975,7 @@ func upgrade_to_electra*(
|
||||||
# churn
|
# churn
|
||||||
for index, validator in post.validators:
|
for index, validator in post.validators:
|
||||||
if has_compounding_withdrawal_credential(validator):
|
if has_compounding_withdrawal_credential(validator):
|
||||||
debugRaiseAssert "in theory truncating"
|
debugComment "in theory truncating"
|
||||||
queue_excess_active_balance(post[], ValidatorIndex(index))
|
queue_excess_active_balance(post[], ValidatorIndex(index))
|
||||||
|
|
||||||
post
|
post
|
||||||
|
|
|
@ -1967,7 +1967,7 @@ proc readValue*(reader: var JsonReader[RestJson],
|
||||||
value.electraBody.execution_payload.excess_blob_gas,
|
value.electraBody.execution_payload.excess_blob_gas,
|
||||||
ep_src.excess_blob_gas.get())
|
ep_src.excess_blob_gas.get())
|
||||||
|
|
||||||
debugRaiseAssert "electra support missing, including attslashing/atts"
|
debugComment "electra support missing, including attslashing/atts"
|
||||||
|
|
||||||
## RestPublishedBeaconBlock
|
## RestPublishedBeaconBlock
|
||||||
proc readValue*(reader: var JsonReader[RestJson],
|
proc readValue*(reader: var JsonReader[RestJson],
|
||||||
|
|
|
@ -961,7 +961,7 @@ func toLightClientHeader*(
|
||||||
electra.SignedBeaconBlock | electra.TrustedSignedBeaconBlock,
|
electra.SignedBeaconBlock | electra.TrustedSignedBeaconBlock,
|
||||||
kind: static LightClientDataFork): auto =
|
kind: static LightClientDataFork): auto =
|
||||||
when blck is electra.SignedBeaconBlock or blck is electra.TrustedSignedBeaconBlock:
|
when blck is electra.SignedBeaconBlock or blck is electra.TrustedSignedBeaconBlock:
|
||||||
debugRaiseAssert "toLightClientHeader electra missing"
|
debugComment "toLightClientHeader electra missing"
|
||||||
default(deneb.LightClientHeader)
|
default(deneb.LightClientHeader)
|
||||||
elif kind == LightClientDataFork.Deneb:
|
elif kind == LightClientDataFork.Deneb:
|
||||||
blck.toDenebLightClientHeader()
|
blck.toDenebLightClientHeader()
|
||||||
|
|
|
@ -601,7 +601,7 @@ proc process_consolidation*(
|
||||||
target_validator.withdrawal_credentials.data.toOpenArray(12, 31)):
|
target_validator.withdrawal_credentials.data.toOpenArray(12, 31)):
|
||||||
return err("Consolidation: source and target don't have same withdrawal address")
|
return err("Consolidation: source and target don't have same withdrawal address")
|
||||||
|
|
||||||
debugRaiseAssert "this is per spec, near-verbatim, but Nimbus generally factors this out into spec/signatures.nim. so, create verify_consolidation_signature infra there, call here"
|
debugComment "this is per spec, near-verbatim, but Nimbus generally factors this out into spec/signatures.nim. so, create verify_consolidation_signature infra there, call here"
|
||||||
# Verify consolidation is signed by the source and the target
|
# Verify consolidation is signed by the source and the target
|
||||||
let
|
let
|
||||||
domain = compute_domain(
|
domain = compute_domain(
|
||||||
|
@ -610,7 +610,7 @@ proc process_consolidation*(
|
||||||
signing_root = compute_signing_root(consolidation, domain)
|
signing_root = compute_signing_root(consolidation, domain)
|
||||||
pubkeys = [source_validator[].pubkey, target_validator.pubkey]
|
pubkeys = [source_validator[].pubkey, target_validator.pubkey]
|
||||||
|
|
||||||
debugRaiseAssert "as a good example, this trustedsig hack typically/should live in spec/signatures.nim"
|
debugComment "as a good example, this trustedsig hack typically/should live in spec/signatures.nim"
|
||||||
when not (signed_consolidation.signature is TrustedSig):
|
when not (signed_consolidation.signature is TrustedSig):
|
||||||
if not blsFastAggregateVerify(
|
if not blsFastAggregateVerify(
|
||||||
pubkeys, signing_root.data, signed_consolidation.signature):
|
pubkeys, signing_root.data, signed_consolidation.signature):
|
||||||
|
@ -621,7 +621,7 @@ proc process_consolidation*(
|
||||||
cfg, state, source_validator[].effective_balance, cache)
|
cfg, state, source_validator[].effective_balance, cache)
|
||||||
source_validator[].withdrawable_epoch =
|
source_validator[].withdrawable_epoch =
|
||||||
source_validator[].exit_epoch + cfg.MIN_VALIDATOR_WITHDRAWABILITY_DELAY
|
source_validator[].exit_epoch + cfg.MIN_VALIDATOR_WITHDRAWABILITY_DELAY
|
||||||
debugRaiseAssert "check HashList add return value"
|
debugComment "check HashList add return value"
|
||||||
discard state.pending_consolidations.add(PendingConsolidation(
|
discard state.pending_consolidations.add(PendingConsolidation(
|
||||||
source_index: consolidation.source_index,
|
source_index: consolidation.source_index,
|
||||||
target_index: consolidation.target_index
|
target_index: consolidation.target_index
|
||||||
|
@ -706,7 +706,7 @@ proc process_operations(
|
||||||
discard ? process_execution_layer_withdrawal_request(
|
discard ? process_execution_layer_withdrawal_request(
|
||||||
cfg, state, op, default(ExitQueueInfo), cache)
|
cfg, state, op, default(ExitQueueInfo), cache)
|
||||||
for op in body.execution_payload.deposit_receipts:
|
for op in body.execution_payload.deposit_receipts:
|
||||||
debugRaiseAssert "combine with previous bloom filter construction"
|
debugComment "combine with previous bloom filter construction"
|
||||||
let bloom_filter = constructBloomFilter(state.validators.asSeq)
|
let bloom_filter = constructBloomFilter(state.validators.asSeq)
|
||||||
? process_deposit_receipt(cfg, state, bloom_filter[], op, {})
|
? process_deposit_receipt(cfg, state, bloom_filter[], op, {})
|
||||||
for op in body.consolidations:
|
for op in body.consolidations:
|
||||||
|
|
|
@ -497,7 +497,7 @@ proc makeBeaconBlockForHeadAndSlot*(
|
||||||
warn "Eth1 deposits not available. Skipping block proposal", slot
|
warn "Eth1 deposits not available. Skipping block proposal", slot
|
||||||
return err("Eth1 deposits not available")
|
return err("Eth1 deposits not available")
|
||||||
|
|
||||||
debugRaiseAssert "b_v makeBeaconBlockForHeadAndSlot doesn't know how to get Electra attestations because attpool doesn't either"
|
debugComment "b_v makeBeaconBlockForHeadAndSlot doesn't know how to get Electra attestations because attpool doesn't either"
|
||||||
let
|
let
|
||||||
attestations =
|
attestations =
|
||||||
when PayloadType.kind == ConsensusFork.Electra:
|
when PayloadType.kind == ConsensusFork.Electra:
|
||||||
|
@ -672,7 +672,7 @@ proc constructSignableBlindedBlock[T: electra_mev.SignedBlindedBeaconBlock](
|
||||||
blindedBlock.message.body.blob_kzg_commitments,
|
blindedBlock.message.body.blob_kzg_commitments,
|
||||||
blindedBundle.blob_kzg_commitments)
|
blindedBundle.blob_kzg_commitments)
|
||||||
|
|
||||||
debugRaiseAssert "check for any additional electra mev requirements"
|
debugComment "check for any additional electra mev requirements"
|
||||||
|
|
||||||
blindedBlock
|
blindedBlock
|
||||||
|
|
||||||
|
@ -722,7 +722,7 @@ func constructPlainBlindedBlock[T: electra_mev.BlindedBeaconBlock](
|
||||||
blindedBlock.body.blob_kzg_commitments,
|
blindedBlock.body.blob_kzg_commitments,
|
||||||
blindedBundle.blob_kzg_commitments)
|
blindedBundle.blob_kzg_commitments)
|
||||||
|
|
||||||
debugRaiseAssert "check for any additional electra mev requirements"
|
debugComment "check for any additional electra mev requirements"
|
||||||
|
|
||||||
blindedBlock
|
blindedBlock
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ macro copyFields*(
|
||||||
dst: untyped, src: untyped, fieldNames: static[seq[string]]): untyped =
|
dst: untyped, src: untyped, fieldNames: static[seq[string]]): untyped =
|
||||||
result = newStmtList()
|
result = newStmtList()
|
||||||
for name in fieldNames:
|
for name in fieldNames:
|
||||||
debugRaiseAssert "deposit_receipts_root and exits_root are not currently filled in anywhere properly, so blinded electra proposals will fail"
|
debugComment "deposit_receipts_root and exits_root are not currently filled in anywhere properly, so blinded electra proposals will fail"
|
||||||
if name notin [
|
if name notin [
|
||||||
# These fields are the ones which vary between the blinded and
|
# These fields are the ones which vary between the blinded and
|
||||||
# unblinded objects, and can't simply be copied.
|
# unblinded objects, and can't simply be copied.
|
||||||
|
|
|
@ -287,7 +287,7 @@ cli do(validatorsDir: string, secretsDir: string,
|
||||||
graffitiValue,
|
graffitiValue,
|
||||||
when typeof(payload).kind == ConsensusFork.Electra:
|
when typeof(payload).kind == ConsensusFork.Electra:
|
||||||
block:
|
block:
|
||||||
debugRaiseAssert "wss_sim electra aggregates"
|
debugComment "wss_sim electra aggregates"
|
||||||
default(seq[electra.Attestation])
|
default(seq[electra.Attestation])
|
||||||
else:
|
else:
|
||||||
blockAggregates,
|
blockAggregates,
|
||||||
|
|
|
@ -99,8 +99,6 @@ proc loadExpectedHashTreeRoot(
|
||||||
# Test runner
|
# Test runner
|
||||||
# ----------------------------------------------------------------
|
# ----------------------------------------------------------------
|
||||||
|
|
||||||
debugRaiseAssert "re-enable AggregateAndProof and SignedAggregateAndProof"
|
|
||||||
|
|
||||||
suite "EF - Electra - SSZ consensus objects " & preset():
|
suite "EF - Electra - SSZ consensus objects " & preset():
|
||||||
doAssert dirExists(SSZDir), "You need to run the \"download_test_vectors.sh\" script to retrieve the consensus spec test vectors."
|
doAssert dirExists(SSZDir), "You need to run the \"download_test_vectors.sh\" script to retrieve the consensus spec test vectors."
|
||||||
for pathKind, sszType in walkDir(SSZDir, relative = true, checkDir = true):
|
for pathKind, sszType in walkDir(SSZDir, relative = true, checkDir = true):
|
||||||
|
@ -118,7 +116,7 @@ suite "EF - Electra - SSZ consensus objects " & preset():
|
||||||
let hash = loadExpectedHashTreeRoot(path)
|
let hash = loadExpectedHashTreeRoot(path)
|
||||||
|
|
||||||
case sszType:
|
case sszType:
|
||||||
of "AggregateAndProof": discard # checkSSZ(AggregateAndProof, path, hash)
|
of "AggregateAndProof": checkSSZ(electra.AggregateAndProof, path, hash)
|
||||||
of "Attestation": checkSSZ(electra.Attestation, path, hash)
|
of "Attestation": checkSSZ(electra.Attestation, path, hash)
|
||||||
of "AttestationData": checkSSZ(AttestationData, path, hash)
|
of "AttestationData": checkSSZ(AttestationData, path, hash)
|
||||||
of "AttesterSlashing": checkSSZ(electra.AttesterSlashing, path, hash)
|
of "AttesterSlashing": checkSSZ(electra.AttesterSlashing, path, hash)
|
||||||
|
@ -165,7 +163,7 @@ suite "EF - Electra - SSZ consensus objects " & preset():
|
||||||
of "PowBlock": checkSSZ(PowBlock, path, hash)
|
of "PowBlock": checkSSZ(PowBlock, path, hash)
|
||||||
of "ProposerSlashing": checkSSZ(ProposerSlashing, path, hash)
|
of "ProposerSlashing": checkSSZ(ProposerSlashing, path, hash)
|
||||||
of "SignedAggregateAndProof":
|
of "SignedAggregateAndProof":
|
||||||
discard #checkSSZ(SignedAggregateAndProof, path, hash)
|
checkSSZ(electra.SignedAggregateAndProof, path, hash)
|
||||||
of "SignedBeaconBlock":
|
of "SignedBeaconBlock":
|
||||||
checkSSZ(electra.SignedBeaconBlock, path, hash)
|
checkSSZ(electra.SignedBeaconBlock, path, hash)
|
||||||
of "SignedBeaconBlockHeader":
|
of "SignedBeaconBlockHeader":
|
||||||
|
|
Loading…
Reference in New Issue