Skip to content

Commit

Permalink
EIP4844 tweaks to pass SSZ consensus object tests (#4390)
Browse files Browse the repository at this point in the history
  • Loading branch information
tersec authored Dec 5, 2022
1 parent 996a0bd commit 415b11a
Show file tree
Hide file tree
Showing 25 changed files with 415 additions and 54 deletions.
52 changes: 51 additions & 1 deletion ConsensusSpecPreset-mainnet.md
Original file line number Diff line number Diff line change
Expand Up @@ -1516,6 +1516,56 @@ OK: 1/1 Fail: 0/1 Skip: 0/1
+ Testing Withdrawal OK
```
OK: 44/44 Fail: 0/44 Skip: 0/44
## EF - EIP4844 - SSZ consensus objects [Preset: mainnet]
```diff
+ Testing AggregateAndProof OK
+ Testing Attestation OK
+ Testing AttestationData OK
+ Testing AttesterSlashing OK
+ Testing BLSToExecutionChange OK
+ Testing BeaconBlock OK
+ Testing BeaconBlockBody OK
+ Testing BeaconBlockHeader OK
+ Testing BeaconState OK
+ Testing BlobsSidecar OK
+ Testing Checkpoint OK
+ Testing ContributionAndProof OK
+ Testing Deposit OK
+ Testing DepositData OK
+ Testing DepositMessage OK
+ Testing Eth1Block OK
+ Testing Eth1Data OK
+ Testing ExecutionPayload OK
+ Testing ExecutionPayloadHeader OK
+ Testing Fork OK
+ Testing ForkData OK
+ Testing HistoricalBatch OK
+ Testing IndexedAttestation OK
+ Testing LightClientBootstrap OK
+ Testing LightClientFinalityUpdate OK
+ Testing LightClientOptimisticUpdate OK
+ Testing LightClientUpdate OK
+ Testing PendingAttestation OK
+ Testing PowBlock OK
+ Testing ProposerSlashing OK
+ Testing SignedAggregateAndProof OK
+ Testing SignedBLSToExecutionChange OK
+ Testing SignedBeaconBlock OK
+ Testing SignedBeaconBlockAndBlobsSidecar OK
+ Testing SignedBeaconBlockHeader OK
+ Testing SignedContributionAndProof OK
+ Testing SignedVoluntaryExit OK
+ Testing SigningData OK
+ Testing SyncAggregate OK
+ Testing SyncAggregatorSelectionData OK
+ Testing SyncCommittee OK
+ Testing SyncCommitteeContribution OK
+ Testing SyncCommitteeMessage OK
+ Testing Validator OK
+ Testing VoluntaryExit OK
+ Testing Withdrawal OK
```
OK: 46/46 Fail: 0/46 Skip: 0/46
## EF - Phase 0 - Epoch Processing - Effective balance updates [Preset: mainnet]
```diff
+ Effective balance updates - effective_balance_hysteresis [Preset: mainnet] OK
Expand Down Expand Up @@ -1937,4 +1987,4 @@ OK: 48/48 Fail: 0/48 Skip: 0/48
OK: 50/50 Fail: 0/50 Skip: 0/50

---TOTAL---
OK: 1691/1699 Fail: 0/1699 Skip: 8/1699
OK: 1737/1745 Fail: 0/1745 Skip: 8/1745
52 changes: 51 additions & 1 deletion ConsensusSpecPreset-minimal.md
Original file line number Diff line number Diff line change
Expand Up @@ -1642,6 +1642,56 @@ OK: 5/5 Fail: 0/5 Skip: 0/5
+ Testing Withdrawal OK
```
OK: 44/44 Fail: 0/44 Skip: 0/44
## EF - EIP4844 - SSZ consensus objects [Preset: minimal]
```diff
+ Testing AggregateAndProof OK
+ Testing Attestation OK
+ Testing AttestationData OK
+ Testing AttesterSlashing OK
+ Testing BLSToExecutionChange OK
+ Testing BeaconBlock OK
+ Testing BeaconBlockBody OK
+ Testing BeaconBlockHeader OK
+ Testing BeaconState OK
+ Testing BlobsSidecar OK
+ Testing Checkpoint OK
+ Testing ContributionAndProof OK
+ Testing Deposit OK
+ Testing DepositData OK
+ Testing DepositMessage OK
+ Testing Eth1Block OK
+ Testing Eth1Data OK
+ Testing ExecutionPayload OK
+ Testing ExecutionPayloadHeader OK
+ Testing Fork OK
+ Testing ForkData OK
+ Testing HistoricalBatch OK
+ Testing IndexedAttestation OK
+ Testing LightClientBootstrap OK
+ Testing LightClientFinalityUpdate OK
+ Testing LightClientOptimisticUpdate OK
+ Testing LightClientUpdate OK
+ Testing PendingAttestation OK
+ Testing PowBlock OK
+ Testing ProposerSlashing OK
+ Testing SignedAggregateAndProof OK
+ Testing SignedBLSToExecutionChange OK
+ Testing SignedBeaconBlock OK
+ Testing SignedBeaconBlockAndBlobsSidecar OK
+ Testing SignedBeaconBlockHeader OK
+ Testing SignedContributionAndProof OK
+ Testing SignedVoluntaryExit OK
+ Testing SigningData OK
+ Testing SyncAggregate OK
+ Testing SyncAggregatorSelectionData OK
+ Testing SyncCommittee OK
+ Testing SyncCommitteeContribution OK
+ Testing SyncCommitteeMessage OK
+ Testing Validator OK
+ Testing VoluntaryExit OK
+ Testing Withdrawal OK
```
OK: 46/46 Fail: 0/46 Skip: 0/46
## EF - Phase 0 - Epoch Processing - Effective balance updates [Preset: minimal]
```diff
+ Effective balance updates - effective_balance_hysteresis [Preset: minimal] OK
Expand Down Expand Up @@ -2078,4 +2128,4 @@ OK: 52/52 Fail: 0/52 Skip: 0/52
OK: 51/51 Fail: 0/51 Skip: 0/51

---TOTAL---
OK: 1820/1828 Fail: 0/1828 Skip: 8/1828
OK: 1866/1874 Fail: 0/1874 Skip: 8/1874
2 changes: 1 addition & 1 deletion beacon_chain/consensus_object_pools/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This folder holds the various consensus object pools needed for a blockchain cli

Object in those pools have passed the "gossip validation" filter according
to specs:
- blocks: https://github.com/ethereum/consensus-specs/blob/v1.1.10/specs/phase0/p2p-interface.md#beacon_block
- blocks: https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/phase0/p2p-interface.md#beacon_block
- aggregate attestations: https://github.com/ethereum/consensus-specs/blob/v1.1.10/specs/phase0/p2p-interface.md#beacon_aggregate_and_proof
- unaggregated attestation: https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/p2p-interface.md#beacon_attestation_subnet_id
- voluntary exits: https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/phase0/p2p-interface.md#voluntary_exit
Expand Down
2 changes: 1 addition & 1 deletion beacon_chain/consensus_object_pools/blockchain_dag.nim
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ proc getStateByParent(
dag: ChainDAGRef, bid: BlockId, state: var ForkedHashedBeaconState): bool =
## Try to load the state referenced by the parent of the given `bid` - this
## state can be used to advance to the `bid` state itself.
var slot = bid.slot
let slot = bid.slot

let
summary = dag.db.getBeaconBlockSummary(bid.root).valueOr:
Expand Down
4 changes: 2 additions & 2 deletions beacon_chain/gossip_processing/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ This folder holds a collection of modules to:

Gossip validation is different from consensus verification in particular for blocks.

- Blocks: https://github.com/ethereum/consensus-specs/blob/v1.1.10/specs/phase0/p2p-interface.md#beacon_block
- Blocks: https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/phase0/p2p-interface.md#beacon_block
- Attestations (aggregated): https://github.com/ethereum/consensus-specs/blob/v1.1.10/specs/phase0/p2p-interface.md#beacon_aggregate_and_proof
- Attestations (unaggregated): https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/p2p-interface.md#attestation-subnets
- Attestations (unaggregated): https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/phase0/p2p-interface.md#attestation-subnets
- Voluntary exits: https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/phase0/p2p-interface.md#voluntary_exit
- Proposer slashings: https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/phase0/p2p-interface.md#proposer_slashing
- Attester slashing: https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/phase0/p2p-interface.md#attester_slashing
Expand Down
18 changes: 9 additions & 9 deletions beacon_chain/gossip_processing/gossip_validation.nim
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ template validateBeaconBlockBellatrix(
parent: BlockRef): untyped =
discard

# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.0/specs/bellatrix/p2p-interface.md#beacon_block
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/bellatrix/p2p-interface.md#beacon_block
template validateBeaconBlockBellatrix(
signed_beacon_block: bellatrix.SignedBeaconBlock | capella.SignedBeaconBlock,
parent: BlockRef): untyped =
Expand Down Expand Up @@ -532,7 +532,7 @@ proc validateAttestation*(

let (cryptoFut, sig) = deferredCrypto.get()
# Await the crypto check
var x = (await cryptoFut)
let x = (await cryptoFut)
case x
of BatchResult.Invalid:
return checkedReject("Attestation: invalid signature")
Expand Down Expand Up @@ -702,7 +702,7 @@ proc validateAggregate*(

block:
# [REJECT] The aggregator signature, signed_aggregate_and_proof.signature, is valid.
var x = await aggregatorFut
let x = await aggregatorFut
case x
of BatchResult.Invalid:
return checkedReject("Aggregate: invalid aggregator signature")
Expand All @@ -714,7 +714,7 @@ proc validateAggregate*(

block:
# [REJECT] aggregate_and_proof.selection_proof
var x = await slotFut
let x = await slotFut
case x
of BatchResult.Invalid:
return checkedReject("Aggregate: invalid slot signature")
Expand All @@ -726,7 +726,7 @@ proc validateAggregate*(

block:
# [REJECT] The aggregator signature, signed_aggregate_and_proof.signature, is valid.
var x = await aggregateFut
let x = await aggregateFut
case x
of BatchResult.Invalid:
return checkedReject("Aggregate: invalid aggregate signature")
Expand Down Expand Up @@ -903,7 +903,7 @@ proc validateSyncCommitteeMessage*(
let
(cryptoFut, sig) = deferredCrypto.get()

var x = (await cryptoFut)
let x = (await cryptoFut)
case x
of BatchResult.Invalid:
return errReject("SyncCommitteeMessage: invalid signature")
Expand Down Expand Up @@ -1000,7 +1000,7 @@ proc validateContribution*(

block:
# [REJECT] The aggregator signature, signed_contribution_and_proof.signature, is valid
var x = await aggregatorFut
let x = await aggregatorFut
case x
of BatchResult.Invalid:
return errReject("SignedContributionAndProof: invalid aggregator signature")
Expand All @@ -1011,7 +1011,7 @@ proc validateContribution*(
discard

block:
var x = await proofFut
let x = await proofFut
case x
of BatchResult.Invalid:
return errReject("SignedContributionAndProof: invalid proof")
Expand All @@ -1023,7 +1023,7 @@ proc validateContribution*(

block:
# [REJECT] The aggregator signature, signed_aggregate_and_proof.signature, is valid.
var x = await contributionFut
let x = await contributionFut
case x
of BatchResult.Invalid:
return errReject("SignedContributionAndProof: invalid contribution signature")
Expand Down
2 changes: 1 addition & 1 deletion beacon_chain/rpc/rest_config_api.nim
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ proc installConfigApiHandlers*(router: var RestRouter, node: BeaconNode) =
ATTESTATION_SUBNET_COUNT:
Base10.toString(ATTESTATION_SUBNET_COUNT),

# https://github.com/ethereum/consensus-specs/blob/v1.2.0/specs/altair/validator.md#constants
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/altair/validator.md#constants
TARGET_AGGREGATORS_PER_SYNC_SUBCOMMITTEE:
Base10.toString(uint64(TARGET_AGGREGATORS_PER_SYNC_SUBCOMMITTEE)),
SYNC_COMMITTEE_SUBNET_COUNT:
Expand Down
2 changes: 1 addition & 1 deletion beacon_chain/rpc/rest_validator_api.nim
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ proc installValidatorApiHandlers*(router: var RestRouter, node: BeaconNode) =
dres.get()
# Since our validation logic supports batch processing, we will submit all
# aggregated attestations for validation.
var pending =
let pending =
block:
var res: seq[Future[SendResult]]
for proof in proofs:
Expand Down
4 changes: 2 additions & 2 deletions beacon_chain/spec/datatypes/altair.nim
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# * 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.

# Types specific to altair (ie known to have changed across hard forks) - see
# Types specific to altair (i.e. known to have changed across hard forks) - see
# `base` for types and guidelines common across forks

# TODO Careful, not nil analysis is broken / incomplete and the semantics will
Expand Down Expand Up @@ -45,7 +45,7 @@ const
TARGET_AGGREGATORS_PER_SYNC_SUBCOMMITTEE* = 16
SYNC_COMMITTEE_SUBNET_COUNT* = 4

# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.0/specs/altair/light-client/sync-protocol.md#constants
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/altair/light-client/sync-protocol.md#constants
# All of these indices are rooted in `BeaconState`.
# The first member (`genesis_time`) is 32, subsequent members +1 each.
# If there are ever more than 32 members in `BeaconState`, indices change!
Expand Down
2 changes: 1 addition & 1 deletion beacon_chain/spec/datatypes/bellatrix.nim
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# * 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.

# Types specific to bellatrix (ie known to have changed across hard forks) - see
# Types specific to bellatrix (i.e. known to have changed across hard forks) - see
# `base` for types and guidelines common across forks

# TODO Careful, not nil analysis is broken / incomplete and the semantics will
Expand Down
6 changes: 3 additions & 3 deletions beacon_chain/spec/datatypes/capella.nim
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# * 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.

# Types specific to capella (ie known to have changed across hard forks) - see
# Types specific to capella (i.e. known to have changed across hard forks) - see
# `base` for types and guidelines common across forks

# TODO Careful, not nil analysis is broken / incomplete and the semantics will
Expand Down Expand Up @@ -48,7 +48,7 @@ type
message*: BLSToExecutionChange
signature*: ValidatorSig

# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.0/specs/capella/beacon-chain.md#executionpayload
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/capella/beacon-chain.md#executionpayload
ExecutionPayload* = object
parent_hash*: Eth2Digest
fee_recipient*: ExecutionAddress # 'beneficiary' in the yellow paper
Expand All @@ -68,7 +68,7 @@ type
transactions*: List[Transaction, MAX_TRANSACTIONS_PER_PAYLOAD]
withdrawals*: List[Withdrawal, MAX_WITHDRAWALS_PER_PAYLOAD] # [New in Capella]

# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.0/specs/capella/beacon-chain.md#executionpayloadheader
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/capella/beacon-chain.md#executionpayloadheader
ExecutionPayloadHeader* = object
parent_hash*: Eth2Digest
fee_recipient*: ExecutionAddress
Expand Down
Loading

0 comments on commit 415b11a

Please sign in to comment.