mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-01-22 20:42:13 +00:00
remove empty block fallback now that capella's on mainnnet (#4821)
* remove empty block fallback now that capella's on mainnnet * build_empty_execution_payload is only testing infrastructure now * update error message
This commit is contained in:
parent
8f2f40f0af
commit
cc24429828
@ -509,11 +509,10 @@ OK: 12/12 Fail: 0/12 Skip: 0/12
|
||||
OK: 1/1 Fail: 0/1 Skip: 0/1
|
||||
## Spec helpers
|
||||
```diff
|
||||
+ build_empty_execution_payload - Bellatrix OK
|
||||
+ build_proof - BeaconState OK
|
||||
+ integer_squareroot OK
|
||||
```
|
||||
OK: 3/3 Fail: 0/3 Skip: 0/3
|
||||
OK: 2/2 Fail: 0/2 Skip: 0/2
|
||||
## Specific field types
|
||||
```diff
|
||||
+ root update OK
|
||||
@ -676,4 +675,4 @@ OK: 2/2 Fail: 0/2 Skip: 0/2
|
||||
OK: 9/9 Fail: 0/9 Skip: 0/9
|
||||
|
||||
---TOTAL---
|
||||
OK: 385/390 Fail: 0/390 Skip: 5/390
|
||||
OK: 384/389 Fail: 0/389 Skip: 5/389
|
||||
|
@ -13,7 +13,7 @@ import
|
||||
# Status libraries
|
||||
stew/[byteutils, endians2, objects, saturation_arith],
|
||||
chronicles,
|
||||
eth/eip1559, eth/common/[eth_types, eth_types_rlp],
|
||||
eth/common/[eth_types, eth_types_rlp],
|
||||
eth/rlp, eth/trie/[db, hexary],
|
||||
# Internal
|
||||
./datatypes/[phase0, altair, bellatrix, capella, deneb],
|
||||
@ -454,35 +454,3 @@ proc payloadToBlockHeader*(
|
||||
proc compute_execution_block_hash*(
|
||||
payload: ForkyExecutionPayload): Eth2Digest =
|
||||
rlpHash payloadToBlockHeader(payload)
|
||||
|
||||
proc build_empty_execution_payload*(
|
||||
state: bellatrix.BeaconState,
|
||||
feeRecipient: Eth1Address): bellatrix.ExecutionPayloadForSigning =
|
||||
## Assuming a pre-state of the same slot, build a valid ExecutionPayload
|
||||
## without any transactions.
|
||||
let
|
||||
latest = state.latest_execution_payload_header
|
||||
timestamp = compute_timestamp_at_slot(state, state.slot)
|
||||
randao_mix = get_randao_mix(state, get_current_epoch(state))
|
||||
base_fee = calcEip1599BaseFee(GasInt.saturate latest.gas_limit,
|
||||
GasInt.saturate latest.gas_used,
|
||||
latest.base_fee_per_gas)
|
||||
|
||||
var payload = bellatrix.ExecutionPayloadForSigning(
|
||||
executionPayload: bellatrix.ExecutionPayload(
|
||||
parent_hash: latest.block_hash,
|
||||
fee_recipient: bellatrix.ExecutionAddress(data: distinctBase(feeRecipient)),
|
||||
state_root: latest.state_root, # no changes to the state
|
||||
receipts_root: EMPTY_ROOT_HASH,
|
||||
block_number: latest.block_number + 1,
|
||||
prev_randao: randao_mix,
|
||||
gas_limit: latest.gas_limit, # retain same limit
|
||||
gas_used: 0, # empty block, 0 gas
|
||||
timestamp: timestamp,
|
||||
base_fee_per_gas: base_fee),
|
||||
blockValue: Wei.zero)
|
||||
|
||||
payload.executionPayload.block_hash =
|
||||
payload.executionPayload.compute_execution_block_hash()
|
||||
|
||||
payload
|
||||
|
@ -296,26 +296,6 @@ proc getExecutionPayload(
|
||||
else:
|
||||
node.getFeeRecipient(pubkey.get().toPubKey(), validator_index, epoch)
|
||||
|
||||
template empty_execution_payload(): auto =
|
||||
# Callers should already ensure these match, but type system doesn't
|
||||
# transmit this information through the Forked types, so this has to
|
||||
# be re-proven here.
|
||||
withState(proposalState[]):
|
||||
when consensusFork >= ConsensusFork.Capella:
|
||||
# As of Capella, because EL state root changes in way more difficult to
|
||||
# compute way from CL due to incorporation of withdrawals into EL state
|
||||
# cannot use fake-EL fallback. Unlike transactions, withdrawals are not
|
||||
# optional, so one cannot avoid this by not including any withdrawals.
|
||||
Opt.none PayloadType
|
||||
elif (consensusFork == ConsensusFork.Bellatrix and
|
||||
PayloadType is bellatrix.ExecutionPayloadForSigning):
|
||||
Opt.some build_empty_execution_payload(forkyState.data, feeRecipient)
|
||||
elif consensusFork == ConsensusFork.Bellatrix:
|
||||
raiseAssert "getExecutionPayload: mismatched proposalState and ExecutionPayload fork"
|
||||
else:
|
||||
# Vacuously -- these are pre-Bellatrix and not used.
|
||||
Opt.some default(PayloadType)
|
||||
|
||||
try:
|
||||
let
|
||||
beaconHead = node.attestationPool[].getBeaconHead(node.dag.head)
|
||||
@ -347,9 +327,9 @@ proc getExecutionPayload(
|
||||
return Opt.some payload.get
|
||||
except CatchableError as err:
|
||||
beacon_block_payload_errors.inc()
|
||||
error "Error creating non-empty execution payload; using empty execution payload",
|
||||
error "Error creating non-empty execution payload",
|
||||
msg = err.msg
|
||||
return empty_execution_payload
|
||||
return Opt.none PayloadType
|
||||
|
||||
proc makeBeaconBlockForHeadAndSlot*(
|
||||
PayloadType: type ForkyExecutionPayloadForSigning,
|
||||
|
@ -61,18 +61,3 @@ suite "Spec helpers":
|
||||
process(fieldVar, i shl childDepth)
|
||||
i += 1
|
||||
process(state, state.numLeaves)
|
||||
|
||||
test "build_empty_execution_payload - Bellatrix":
|
||||
var cfg = defaultRuntimeConfig
|
||||
cfg.ALTAIR_FORK_EPOCH = GENESIS_EPOCH
|
||||
cfg.BELLATRIX_FORK_EPOCH = GENESIS_EPOCH
|
||||
|
||||
let state = newClone(initGenesisState(cfg = cfg).bellatrixData)
|
||||
|
||||
proc testCase(recipient: Eth1Address) =
|
||||
let payload = build_empty_execution_payload(state[].data, recipient).executionPayload
|
||||
check payload.fee_recipient ==
|
||||
bellatrix.ExecutionAddress(data: distinctBase(recipient))
|
||||
|
||||
testCase default(Eth1Address)
|
||||
testCase Eth1Address.fromHex("0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b")
|
||||
|
@ -108,6 +108,42 @@ proc build_empty_merge_execution_payload(state: bellatrix.BeaconState):
|
||||
bellatrix.ExecutionPayloadForSigning(executionPayload: payload,
|
||||
blockValue: Wei.zero)
|
||||
|
||||
from eth/common/eth_types import GasInt
|
||||
from eth/eip1559 import calcEip1599BaseFee
|
||||
from stew/saturating_arith import saturate
|
||||
|
||||
proc build_empty_execution_payload(
|
||||
state: bellatrix.BeaconState,
|
||||
feeRecipient: Eth1Address): bellatrix.ExecutionPayloadForSigning =
|
||||
## Assuming a pre-state of the same slot, build a valid ExecutionPayload
|
||||
## without any transactions.
|
||||
let
|
||||
latest = state.latest_execution_payload_header
|
||||
timestamp = compute_timestamp_at_slot(state, state.slot)
|
||||
randao_mix = get_randao_mix(state, get_current_epoch(state))
|
||||
base_fee = calcEip1599BaseFee(GasInt.saturate latest.gas_limit,
|
||||
GasInt.saturate latest.gas_used,
|
||||
latest.base_fee_per_gas)
|
||||
|
||||
var payload = bellatrix.ExecutionPayloadForSigning(
|
||||
executionPayload: bellatrix.ExecutionPayload(
|
||||
parent_hash: latest.block_hash,
|
||||
fee_recipient: bellatrix.ExecutionAddress(data: distinctBase(feeRecipient)),
|
||||
state_root: latest.state_root, # no changes to the state
|
||||
receipts_root: EMPTY_ROOT_HASH,
|
||||
block_number: latest.block_number + 1,
|
||||
prev_randao: randao_mix,
|
||||
gas_limit: latest.gas_limit, # retain same limit
|
||||
gas_used: 0, # empty block, 0 gas
|
||||
timestamp: timestamp,
|
||||
base_fee_per_gas: base_fee),
|
||||
blockValue: Wei.zero)
|
||||
|
||||
payload.executionPayload.block_hash =
|
||||
payload.executionPayload.compute_execution_block_hash()
|
||||
|
||||
payload
|
||||
|
||||
proc addTestBlock*(
|
||||
state: var ForkedHashedBeaconState,
|
||||
cache: var StateCache,
|
||||
|
Loading…
x
Reference in New Issue
Block a user