Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use v1.4.0-alpha.1 consensus spec test vectors #5026

Merged
merged 1 commit into from
Jun 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions ConsensusSpecPreset-mainnet.md
Original file line number Diff line number Diff line change
Expand Up @@ -2036,11 +2036,6 @@ OK: 49/49 Fail: 0/49 Skip: 0/49
+ test_process_light_client_update_not_timeout OK
```
OK: 4/4 Fail: 0/4 Skip: 0/4
## EF - Light client - Single merkle proof [Preset: mainnet]
```diff
Light client - Single merkle proof - eip6110 Skip
```
OK: 0/1 Fail: 0/1 Skip: 1/1
## EF - Phase 0 - Epoch Processing - Effective balance updates [Preset: mainnet]
```diff
+ Effective balance updates - effective_balance_hysteresis [Preset: mainnet] OK
Expand Down Expand Up @@ -2615,4 +2610,4 @@ OK: 63/63 Fail: 0/63 Skip: 0/63
OK: 100/100 Fail: 0/100 Skip: 0/100

---TOTAL---
OK: 2308/2317 Fail: 0/2317 Skip: 9/2317
OK: 2308/2316 Fail: 0/2316 Skip: 8/2316
12 changes: 1 addition & 11 deletions ConsensusSpecPreset-minimal.md
Original file line number Diff line number Diff line change
Expand Up @@ -2288,16 +2288,6 @@ OK: 49/49 Fail: 0/49 Skip: 0/49
+ test_process_light_client_update_not_timeout OK
```
OK: 4/4 Fail: 0/4 Skip: 0/4
## EF - Light client - Single merkle proof [Preset: minimal]
```diff
Light client - Single merkle proof - eip6110 Skip
```
OK: 0/1 Fail: 0/1 Skip: 1/1
## EF - Light client - Update ranking [Preset: minimal]
```diff
Light client - Update ranking - eip6110 Skip
```
OK: 0/1 Fail: 0/1 Skip: 1/1
## EF - Phase 0 - Epoch Processing - Effective balance updates [Preset: minimal]
```diff
+ Effective balance updates - effective_balance_hysteresis [Preset: minimal] OK
Expand Down Expand Up @@ -2875,4 +2865,4 @@ OK: 68/68 Fail: 0/68 Skip: 0/68
OK: 102/102 Fail: 0/102 Skip: 0/102

---TOTAL---
OK: 2547/2557 Fail: 0/2557 Skip: 10/2557
OK: 2547/2555 Fail: 0/2555 Skip: 8/2555
6 changes: 4 additions & 2 deletions beacon_chain/el/el_manager.nim
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,8 @@ func asConsensusType*(rpcExecutionPayload: ExecutionPayloadV3):
mapIt(rpcExecutionPayload.transactions, it.getTransaction)),
withdrawals: List[capella.Withdrawal, MAX_WITHDRAWALS_PER_PAYLOAD].init(
mapIt(rpcExecutionPayload.withdrawals, it.asConsensusWithdrawal)),
excess_data_gas: rpcExecutionPayload.excessDataGas)
data_gas_used: rpcExecutionPayload.dataGasUsed.uint64,
excess_data_gas: rpcExecutionPayload.excessDataGas.uint64)

func asConsensusType*(payload: engine_api.GetPayloadV3Response):
deneb.ExecutionPayloadForSigning =
Expand Down Expand Up @@ -641,7 +642,8 @@ func asEngineExecutionPayload*(executionPayload: deneb.ExecutionPayload):
blockHash: executionPayload.block_hash.asBlockHash,
transactions: mapIt(executionPayload.transactions, it.getTypedTransaction),
withdrawals: mapIt(executionPayload.withdrawals, it.asEngineWithdrawal),
excessDataGas: executionPayload.excess_data_gas)
dataGasUsed: Quantity(executionPayload.data_gas_used),
excessDataGas: Quantity(executionPayload.excess_data_gas))

func shortLog*(b: Eth1Block): string =
try:
Expand Down
2 changes: 1 addition & 1 deletion beacon_chain/nimbus_signing_node.nim
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ proc installApiHandlers*(node: SigningNodeRef) =
of ConsensusFork.Capella:
(GeneralizedIndex(401), request.beaconBlock.capellaData)
of ConsensusFork.Deneb:
(GeneralizedIndex(401), request.beaconBlock.denebData)
(GeneralizedIndex(801), request.beaconBlock.denebData)

if request.proofs.isNone() or len(request.proofs.get()) == 0:
return errorResponse(Http400, MissingMerkleProofError)
Expand Down
5 changes: 3 additions & 2 deletions beacon_chain/spec/beaconstate.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1285,7 +1285,7 @@ func upgrade_to_capella*(cfg: RuntimeConfig, pre: bellatrix.BeaconState):
# historical_summaries initialized to correct default automatically
)

# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/deneb/fork.md#upgrading-the-state
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.1/specs/deneb/fork.md#upgrading-the-state
func upgrade_to_deneb*(cfg: RuntimeConfig, pre: capella.BeaconState):
ref deneb.BeaconState =
let
Expand All @@ -1306,7 +1306,8 @@ func upgrade_to_deneb*(cfg: RuntimeConfig, pre: capella.BeaconState):
block_hash: pre.latest_execution_payload_header.block_hash,
transactions_root: pre.latest_execution_payload_header.transactions_root,
withdrawals_root: pre.latest_execution_payload_header.withdrawals_root,
excess_data_gas: 0.u256 # [New in Deneb]
data_gas_used: 0, # [New in Deneb]
excess_data_gas: 0 # [New in Deneb]
)

(ref deneb.BeaconState)(
Expand Down
2 changes: 1 addition & 1 deletion beacon_chain/spec/datatypes/base.nim
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export
tables, results, json_serialization, timer, sszTypes, beacon_time, crypto,
digest, presets

const SPEC_VERSION* = "1.4.0-alpha.0"
const SPEC_VERSION* = "1.4.0-alpha.1"
## Spec version we're aiming to be compatible with, right now

const
Expand Down
16 changes: 5 additions & 11 deletions beacon_chain/spec/datatypes/deneb.nim
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,6 @@ type

Blob* = array[BYTES_PER_FIELD_ELEMENT * FIELD_ELEMENTS_PER_BLOB, byte]

# TODO remove BlobsSidecar; it's not in rc.3 anymore
BlobsSidecar* = object
beacon_block_root*: Eth2Digest
beacon_block_slot*: Slot
blobs*: Blobs
kzg_aggregated_proof*: KzgProof

# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/deneb/p2p-interface.md#blobsidecar
BlobSidecar* = object
block_root*: Eth2Digest
Expand Down Expand Up @@ -108,7 +101,8 @@ type
block_hash*: Eth2Digest # Hash of execution block
transactions*: List[Transaction, MAX_TRANSACTIONS_PER_PAYLOAD]
withdrawals*: List[Withdrawal, MAX_WITHDRAWALS_PER_PAYLOAD]
excess_data_gas*: UInt256 # [New in Deneb]
data_gas_used*: uint64 # [New in Deneb]
excess_data_gas*: uint64 # [New in Deneb]

ExecutionPayloadForSigning* = object
executionPayload*: ExecutionPayload
Expand Down Expand Up @@ -137,8 +131,8 @@ type
## Hash of execution block
transactions_root*: Eth2Digest
withdrawals_root*: Eth2Digest
excess_data_gas*: UInt256
## [New in Deneb]
data_gas_used*: uint64 # [New in Deneb]
excess_data_gas*: uint64 # [New in Deneb]

ExecutePayload* = proc(
execution_payload: ExecutionPayload): bool {.gcsafe, raises: [Defect].}
Expand Down Expand Up @@ -616,7 +610,7 @@ func is_valid_light_client_header*(
let epoch = header.beacon.slot.epoch

if epoch < cfg.DENEB_FORK_EPOCH:
if header.execution.excess_data_gas != 0.u256:
if header.execution.excess_data_gas != 0:
return false

if epoch < cfg.CAPELLA_FORK_EPOCH:
Expand Down
10 changes: 8 additions & 2 deletions beacon_chain/spec/helpers.nim
Original file line number Diff line number Diff line change
Expand Up @@ -430,11 +430,16 @@ proc payloadToBlockHeader*(
some payload.computeWithdrawalsTrieRoot()
else:
none(Hash256)
dataGasUsed =
when typeof(payload).toFork >= ConsensusFork.Deneb:
some payload.data_gas_used
else:
none(uint64)
excessDataGas =
when typeof(payload).toFork >= ConsensusFork.Deneb:
some payload.excess_data_gas
else:
none(UInt256)
none(uint64)

ExecutionBlockHeader(
parentHash : payload.parent_hash,
Expand All @@ -454,7 +459,8 @@ proc payloadToBlockHeader*(
nonce : default(BlockNonce),
fee : some payload.base_fee_per_gas,
withdrawalsRoot: withdrawalsRoot,
excessDataGas : excessDataGas)
dataGasUsed : dataGasUsed, # EIP-4844
excessDataGas : excessDataGas) # EIP-4844

proc compute_execution_block_hash*(
payload: ForkyExecutionPayload): Eth2Digest =
Expand Down
2 changes: 1 addition & 1 deletion beacon_chain/spec/keystore.nim
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ proc readValue*(reader: var JsonReader, value: var RemoteKeystore)
if prop.path == ".execution_payload.fee_recipient":
prop.bellatrixIndex = some GeneralizedIndex(401)
prop.capellaIndex = some GeneralizedIndex(401)
prop.denebIndex = some GeneralizedIndex(401)
prop.denebIndex = some GeneralizedIndex(801)
elif prop.path == ".graffiti":
prop.bellatrixIndex = some GeneralizedIndex(18)
prop.capellaIndex = some GeneralizedIndex(18)
Expand Down
3 changes: 2 additions & 1 deletion beacon_chain/spec/state_transition_block.nim
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,8 @@ proc process_execution_payload*(
extra_data: payload.extra_data,
transactions_root: hash_tree_root(payload.transactions),
withdrawals_root: hash_tree_root(payload.withdrawals),
excess_data_gas: payload.excess_data_gas) # [New in Deneb]
data_gas_used: payload.data_gas_used, # [New in Deneb]
excess_data_gas: payload.excess_data_gas) # [New in Deneb]

ok()

Expand Down
9 changes: 8 additions & 1 deletion beacon_chain/validators/validator_duties.nim
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,13 @@ proc makeBlindedBeaconBlockForHeadAndSlot*[
else:
return err("Attempt to create pre-Bellatrix blinded block")

# TODO remove BlobsSidecar; it's not in consensus specs anymore
type BlobsSidecar = object
beacon_block_root*: Eth2Digest
beacon_block_slot*: Slot
blobs*: Blobs
kzg_aggregated_proof*: kzg_abi.KzgProof

proc proposeBlockAux(
SBBB: typedesc, EPS: typedesc, node: BeaconNode,
validator: AttachedValidator, validator_index: ValidatorIndex,
Expand Down Expand Up @@ -913,7 +920,7 @@ proc proposeBlockAux(
var forkedBlck = engineBlockFut.read.get().blck

withBlck(forkedBlck):
var blobs_sidecar = deneb.BlobsSidecar(
var blobs_sidecar = BlobsSidecar(
beacon_block_slot: slot,
)
when blck is deneb.BeaconBlock:
Expand Down
3 changes: 2 additions & 1 deletion ncli/ncli_testnet.nim
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,8 @@ func `as`(blk: BlockObject, T: type deneb.ExecutionPayloadHeader): T =
block_hash: blk.hash as Eth2Digest,
transactions_root: blk.transactionsRoot as Eth2Digest,
withdrawals_root: blk.withdrawalsRoot.getOrDefault() as Eth2Digest,
excess_data_gas: blk.excessDataGas.getOrDefault())
data_gas_used: uint64 blk.dataGasUsed.getOrDefault(),
excess_data_gas: uint64 blk.excessDataGas.getOrDefault())

proc createDepositTreeSnapshot(deposits: seq[DepositData],
blockHash: Eth2Digest,
Expand Down
4 changes: 0 additions & 4 deletions tests/consensus_spec/test_fixture_light_client_sync.nim
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ import
../testutil,
./fixtures_utils, ./os_ops

from std/strutils import contains

type
TestMeta = object
genesis_validators_root: Eth2Digest
Expand Down Expand Up @@ -271,6 +269,4 @@ suite "EF - Light client - Sync" & preset():
continue
for kind, path in walkDir(basePath, relative = true, checkDir = true):
let combinedPath = basePath/path
if combinedPath.contains("/eip6110/") or combinedPath.contains("\\eip6110\\"):
continue
runTest(basePath/path)
Loading