capella VC support (#4586)
This commit is contained in:
parent
956aee2d35
commit
1c62a5eb24
|
@ -798,6 +798,7 @@ proc installBeaconApiHandlers*(router: var RestRouter, node: BeaconNode) =
|
||||||
|
|
||||||
if forked.kind != node.dag.cfg.blockForkAtEpoch(
|
if forked.kind != node.dag.cfg.blockForkAtEpoch(
|
||||||
getForkedBlockField(forked, slot).epoch):
|
getForkedBlockField(forked, slot).epoch):
|
||||||
|
doAssert strictVerification notin node.dag.updateFlags
|
||||||
return RestApiResponse.jsonError(Http400, InvalidBlockObjectError)
|
return RestApiResponse.jsonError(Http400, InvalidBlockObjectError)
|
||||||
|
|
||||||
withBlck(forked):
|
withBlck(forked):
|
||||||
|
|
|
@ -925,7 +925,9 @@ template prepareForkedBlockReading(
|
||||||
of "bellatrix":
|
of "bellatrix":
|
||||||
version = some(ConsensusFork.Bellatrix)
|
version = some(ConsensusFork.Bellatrix)
|
||||||
of "capella":
|
of "capella":
|
||||||
version = some(ConsensusFork.Bellatrix)
|
version = some(ConsensusFork.Capella)
|
||||||
|
of "eip4844":
|
||||||
|
version = some(ConsensusFork.EIP4844)
|
||||||
else:
|
else:
|
||||||
reader.raiseUnexpectedValue("Incorrect version field value")
|
reader.raiseUnexpectedValue("Incorrect version field value")
|
||||||
of "block", "block_header", "data":
|
of "block", "block_header", "data":
|
||||||
|
@ -1200,7 +1202,8 @@ proc readValue*(reader: var JsonReader[RestJson],
|
||||||
voluntary_exits: Option[
|
voluntary_exits: Option[
|
||||||
List[SignedVoluntaryExit, Limit MAX_VOLUNTARY_EXITS]]
|
List[SignedVoluntaryExit, Limit MAX_VOLUNTARY_EXITS]]
|
||||||
sync_aggregate: Option[SyncAggregate]
|
sync_aggregate: Option[SyncAggregate]
|
||||||
execution_payload: Option[bellatrix.ExecutionPayload]
|
execution_payload: Option[RestExecutionPayload]
|
||||||
|
bls_to_execution_changes: Option[SignedBLSToExecutionChangeList]
|
||||||
|
|
||||||
for fieldName in readObjectFields(reader):
|
for fieldName in readObjectFields(reader):
|
||||||
case fieldName
|
case fieldName
|
||||||
|
@ -1259,7 +1262,12 @@ proc readValue*(reader: var JsonReader[RestJson],
|
||||||
if execution_payload.isSome():
|
if execution_payload.isSome():
|
||||||
reader.raiseUnexpectedField("Multiple `execution_payload` fields found",
|
reader.raiseUnexpectedField("Multiple `execution_payload` fields found",
|
||||||
"RestPublishedBeaconBlockBody")
|
"RestPublishedBeaconBlockBody")
|
||||||
execution_payload = some(reader.readValue(bellatrix.ExecutionPayload))
|
execution_payload = some(reader.readValue(RestExecutionPayload))
|
||||||
|
of "bls_to_execution_changes":
|
||||||
|
if bls_to_execution_changes.isSome():
|
||||||
|
reader.raiseUnexpectedField("Multiple `bls_to_execution_changes` fields found",
|
||||||
|
"RestPublishedBeaconBlockBody")
|
||||||
|
bls_to_execution_changes = some(reader.readValue(SignedBLSToExecutionChangeList))
|
||||||
else:
|
else:
|
||||||
unrecognizedFieldWarning()
|
unrecognizedFieldWarning()
|
||||||
|
|
||||||
|
@ -1280,15 +1288,36 @@ proc readValue*(reader: var JsonReader[RestJson],
|
||||||
if voluntary_exits.isNone():
|
if voluntary_exits.isNone():
|
||||||
reader.raiseUnexpectedValue("Field `voluntary_exits` is missing")
|
reader.raiseUnexpectedValue("Field `voluntary_exits` is missing")
|
||||||
|
|
||||||
discard $capellaImplementationMissing & ": autodetect via added field"
|
|
||||||
let bodyKind =
|
let bodyKind =
|
||||||
if execution_payload.isSome() and sync_aggregate.isSome():
|
if execution_payload.isSome() and
|
||||||
|
execution_payload.get().withdrawals.isSome() and
|
||||||
|
bls_to_execution_changes.isSome() and
|
||||||
|
sync_aggregate.isSome():
|
||||||
|
ConsensusFork.Capella
|
||||||
|
elif execution_payload.isSome() and sync_aggregate.isSome():
|
||||||
ConsensusFork.Bellatrix
|
ConsensusFork.Bellatrix
|
||||||
elif execution_payload.isNone() and sync_aggregate.isSome():
|
elif execution_payload.isNone() and sync_aggregate.isSome():
|
||||||
ConsensusFork.Altair
|
ConsensusFork.Altair
|
||||||
else:
|
else:
|
||||||
ConsensusFork.Phase0
|
ConsensusFork.Phase0
|
||||||
|
|
||||||
|
template ep_src: auto = execution_payload.get()
|
||||||
|
template copy_ep_bellatrix(ep_dst: auto) =
|
||||||
|
assign(ep_dst.parent_hash, ep_src.parent_hash)
|
||||||
|
assign(ep_dst.fee_recipient, ep_src.fee_recipient)
|
||||||
|
assign(ep_dst.state_root, ep_src.state_root)
|
||||||
|
assign(ep_dst.receipts_root, ep_src.receipts_root)
|
||||||
|
assign(ep_dst.logs_bloom, ep_src.logs_bloom)
|
||||||
|
assign(ep_dst.prev_randao, ep_src.prev_randao)
|
||||||
|
assign(ep_dst.block_number, ep_src.block_number)
|
||||||
|
assign(ep_dst.gas_limit, ep_src.gas_limit)
|
||||||
|
assign(ep_dst.gas_used, ep_src.gas_used)
|
||||||
|
assign(ep_dst.timestamp, ep_src.timestamp)
|
||||||
|
assign(ep_dst.extra_Data, ep_src.extra_Data)
|
||||||
|
assign(ep_dst.base_fee_per_Gas, ep_src.base_fee_per_Gas)
|
||||||
|
assign(ep_dst.block_hash, ep_src.block_hash)
|
||||||
|
assign(ep_dst.transactions, ep_src.transactions)
|
||||||
|
|
||||||
case bodyKind
|
case bodyKind
|
||||||
of ConsensusFork.Phase0:
|
of ConsensusFork.Phase0:
|
||||||
value = RestPublishedBeaconBlockBody(
|
value = RestPublishedBeaconBlockBody(
|
||||||
|
@ -1332,11 +1361,29 @@ proc readValue*(reader: var JsonReader[RestJson],
|
||||||
deposits: deposits.get(),
|
deposits: deposits.get(),
|
||||||
voluntary_exits: voluntary_exits.get(),
|
voluntary_exits: voluntary_exits.get(),
|
||||||
sync_aggregate: sync_aggregate.get(),
|
sync_aggregate: sync_aggregate.get(),
|
||||||
execution_payload: execution_payload.get()
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
copy_ep_bellatrix(value.bellatrixBody.execution_payload)
|
||||||
of ConsensusFork.Capella:
|
of ConsensusFork.Capella:
|
||||||
reader.raiseUnexpectedValue($capellaImplementationMissing)
|
value = RestPublishedBeaconBlockBody(
|
||||||
|
kind: ConsensusFork.Capella,
|
||||||
|
capellaBody: capella.BeaconBlockBody(
|
||||||
|
randao_reveal: randao_reveal.get(),
|
||||||
|
eth1_data: eth1_data.get(),
|
||||||
|
graffiti: graffiti.get(),
|
||||||
|
proposer_slashings: proposer_slashings.get(),
|
||||||
|
attester_slashings: attester_slashings.get(),
|
||||||
|
attestations: attestations.get(),
|
||||||
|
deposits: deposits.get(),
|
||||||
|
voluntary_exits: voluntary_exits.get(),
|
||||||
|
sync_aggregate: sync_aggregate.get(),
|
||||||
|
bls_to_execution_changes: bls_to_execution_changes.get()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
copy_ep_bellatrix(value.capellaBody.execution_payload)
|
||||||
|
assign(
|
||||||
|
value.capellaBody.execution_payload.withdrawals,
|
||||||
|
ep_src.withdrawals.get())
|
||||||
of ConsensusFork.EIP4844:
|
of ConsensusFork.EIP4844:
|
||||||
reader.raiseUnexpectedValue($eip4844ImplementationMissing)
|
reader.raiseUnexpectedValue($eip4844ImplementationMissing)
|
||||||
|
|
||||||
|
@ -1524,6 +1571,8 @@ proc readValue*(reader: var JsonReader[RestJson],
|
||||||
version = some(ConsensusFork.Bellatrix)
|
version = some(ConsensusFork.Bellatrix)
|
||||||
of "capella":
|
of "capella":
|
||||||
version = some(ConsensusFork.Capella)
|
version = some(ConsensusFork.Capella)
|
||||||
|
of "eip4844":
|
||||||
|
version = some(ConsensusFork.EIP4844)
|
||||||
else:
|
else:
|
||||||
reader.raiseUnexpectedValue("Incorrect version field value")
|
reader.raiseUnexpectedValue("Incorrect version field value")
|
||||||
of "data":
|
of "data":
|
||||||
|
|
|
@ -277,6 +277,26 @@ type
|
||||||
index*: ValidatorIndex
|
index*: ValidatorIndex
|
||||||
is_live*: bool
|
is_live*: bool
|
||||||
|
|
||||||
|
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-rc.2/specs/capella/beacon-chain.md#executionpayload
|
||||||
|
RestExecutionPayload* = object
|
||||||
|
parent_hash*: Eth2Digest
|
||||||
|
fee_recipient*: ExecutionAddress # 'beneficiary' in the yellow paper
|
||||||
|
state_root*: Eth2Digest
|
||||||
|
receipts_root*: Eth2Digest # 'receipts root' in the yellow paper
|
||||||
|
logs_bloom*: BloomLogs
|
||||||
|
prev_randao*: Eth2Digest # 'difficulty' in the yellow paper
|
||||||
|
block_number*: uint64 # 'number' in the yellow paper
|
||||||
|
gas_limit*: uint64
|
||||||
|
gas_used*: uint64
|
||||||
|
timestamp*: uint64
|
||||||
|
extra_data*: List[byte, MAX_EXTRA_DATA_BYTES]
|
||||||
|
base_fee_per_gas*: UInt256
|
||||||
|
|
||||||
|
# Extra payload fields
|
||||||
|
block_hash*: Eth2Digest # Hash of execution block
|
||||||
|
transactions*: List[Transaction, MAX_TRANSACTIONS_PER_PAYLOAD]
|
||||||
|
withdrawals*: Option[List[Withdrawal, MAX_WITHDRAWALS_PER_PAYLOAD]] # [New in Capella]
|
||||||
|
|
||||||
PrepareBeaconProposer* = object
|
PrepareBeaconProposer* = object
|
||||||
validator_index*: ValidatorIndex
|
validator_index*: ValidatorIndex
|
||||||
fee_recipient*: Eth1Address
|
fee_recipient*: Eth1Address
|
||||||
|
@ -636,7 +656,6 @@ type
|
||||||
GetVersionResponse* = DataEnclosedObject[RestNodeVersion]
|
GetVersionResponse* = DataEnclosedObject[RestNodeVersion]
|
||||||
GetEpochSyncCommitteesResponse* = DataEnclosedObject[RestEpochSyncCommittee]
|
GetEpochSyncCommitteesResponse* = DataEnclosedObject[RestEpochSyncCommittee]
|
||||||
ProduceAttestationDataResponse* = DataEnclosedObject[AttestationData]
|
ProduceAttestationDataResponse* = DataEnclosedObject[AttestationData]
|
||||||
ProduceBlockResponse* = DataEnclosedObject[phase0.BeaconBlock]
|
|
||||||
ProduceBlockResponseV2* = ForkedBeaconBlock
|
ProduceBlockResponseV2* = ForkedBeaconBlock
|
||||||
ProduceBlindedBlockResponse* = ForkedBlindedBeaconBlock
|
ProduceBlindedBlockResponse* = ForkedBlindedBeaconBlock
|
||||||
ProduceSyncCommitteeContributionResponse* = DataEnclosedObject[SyncCommitteeContribution]
|
ProduceSyncCommitteeContributionResponse* = DataEnclosedObject[SyncCommitteeContribution]
|
||||||
|
|
|
@ -183,8 +183,7 @@ switch("warning", "ObservableStores:off")
|
||||||
switch("warning", "LockLevel:off")
|
switch("warning", "LockLevel:off")
|
||||||
|
|
||||||
# Too many of these because of Defect compat in 1.2
|
# Too many of these because of Defect compat in 1.2
|
||||||
if (NimMajor, NimMinor) >= (1, 6):
|
switch("hint", "XCannotRaiseY:off")
|
||||||
switch("hint", "XCannotRaiseY:off")
|
|
||||||
|
|
||||||
# Useful for Chronos metrics.
|
# Useful for Chronos metrics.
|
||||||
#--define:chronosFutureTracking
|
#--define:chronosFutureTracking
|
||||||
|
|
|
@ -785,6 +785,7 @@ DEPOSIT_CONTRACT_ADDRESS: ${DEPOSIT_CONTRACT_ADDRESS}
|
||||||
ETH1_FOLLOW_DISTANCE: 1
|
ETH1_FOLLOW_DISTANCE: 1
|
||||||
ALTAIR_FORK_EPOCH: 1
|
ALTAIR_FORK_EPOCH: 1
|
||||||
BELLATRIX_FORK_EPOCH: 2
|
BELLATRIX_FORK_EPOCH: 2
|
||||||
|
CAPELLA_FORK_EPOCH: 3
|
||||||
TERMINAL_TOTAL_DIFFICULTY: 0
|
TERMINAL_TOTAL_DIFFICULTY: 0
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue