mirror of
https://github.com/status-im/eth2.0-specs.git
synced 2025-01-20 07:29:02 +00:00
Clean up. Add execution_payload_header
to initialization meta.yaml
This commit is contained in:
parent
789eea0060
commit
e235aa8296
@ -355,11 +355,11 @@ def process_execution_payload(state: BeaconState, payload: ExecutionPayload, exe
|
|||||||
|
|
||||||
*Note*: The function `initialize_beacon_state_from_eth1` is modified for pure Merge testing only.
|
*Note*: The function `initialize_beacon_state_from_eth1` is modified for pure Merge testing only.
|
||||||
Modifications include:
|
Modifications include:
|
||||||
1. Use `MERGE_FORK_VERSION` as the current fork version
|
1. Use `MERGE_FORK_VERSION` as the current fork version.
|
||||||
2. Utilize the Merge `BeaconBlockBody` when constructing the initial `latest_block_header`
|
2. Utilize the Merge `BeaconBlockBody` when constructing the initial `latest_block_header`.
|
||||||
3. Initialize `latest_execution_payload_header`.
|
3. Initialize `latest_execution_payload_header`.
|
||||||
If `execution_payload_header == ExecutionPayloadHeader()`, then the Merge has not yet occurred.
|
If `execution_payload_header == ExecutionPayloadHeader()`, then the Merge has not yet occurred.
|
||||||
Else, the Merge starts from genesis.
|
Else, the Merge starts from genesis and the transition is incomplete.
|
||||||
|
|
||||||
```python
|
```python
|
||||||
def initialize_beacon_state_from_eth1(eth1_block_hash: Bytes32,
|
def initialize_beacon_state_from_eth1(eth1_block_hash: Bytes32,
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
from eth2spec.test.context import (
|
from eth2spec.test.context import (
|
||||||
|
MERGE,
|
||||||
single_phase,
|
single_phase,
|
||||||
spec_test,
|
spec_test,
|
||||||
with_presets,
|
with_presets,
|
||||||
|
with_phases,
|
||||||
with_merge_and_later,
|
with_merge_and_later,
|
||||||
)
|
)
|
||||||
from eth2spec.test.helpers.constants import MINIMAL
|
from eth2spec.test.helpers.constants import MINIMAL
|
||||||
@ -17,7 +19,7 @@ def eth1_init_data(eth1_block_hash, eth1_timestamp):
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@with_merge_and_later
|
@with_phases([MERGE])
|
||||||
@spec_test
|
@spec_test
|
||||||
@single_phase
|
@single_phase
|
||||||
@with_presets([MINIMAL], reason="too slow")
|
@with_presets([MINIMAL], reason="too slow")
|
||||||
@ -37,11 +39,11 @@ def test_initialize_pre_transition_no_param(spec):
|
|||||||
yield 'deposits', deposits
|
yield 'deposits', deposits
|
||||||
|
|
||||||
# initialize beacon_state *without* an execution_payload_header
|
# initialize beacon_state *without* an execution_payload_header
|
||||||
|
yield 'execution_payload_header', 'meta', False
|
||||||
state = spec.initialize_beacon_state_from_eth1(eth1_block_hash, eth1_timestamp, deposits)
|
state = spec.initialize_beacon_state_from_eth1(eth1_block_hash, eth1_timestamp, deposits)
|
||||||
|
|
||||||
assert not spec.is_merge_comp(state)
|
assert not spec.is_merge_complete(state)
|
||||||
|
|
||||||
# yield state
|
|
||||||
yield 'state', state
|
yield 'state', state
|
||||||
|
|
||||||
|
|
||||||
@ -64,19 +66,20 @@ def test_initialize_pre_transition_empty_payload(spec):
|
|||||||
yield from eth1_init_data(eth1_block_hash, eth1_timestamp)
|
yield from eth1_init_data(eth1_block_hash, eth1_timestamp)
|
||||||
yield 'deposits', deposits
|
yield 'deposits', deposits
|
||||||
|
|
||||||
# initialize beacon_state *without* an execution_payload_header
|
# initialize beacon_state *with* an *empty* execution_payload_header
|
||||||
|
yield 'execution_payload_header', 'meta', True
|
||||||
|
execution_payload_header = spec.ExecutionPayloadHeader()
|
||||||
state = spec.initialize_beacon_state_from_eth1(
|
state = spec.initialize_beacon_state_from_eth1(
|
||||||
eth1_block_hash,
|
eth1_block_hash,
|
||||||
eth1_timestamp,
|
eth1_timestamp,
|
||||||
deposits,
|
deposits,
|
||||||
spec.ExecutionPayloadHeader()
|
execution_payload_header=execution_payload_header,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert not spec.is_merge_complete(state)
|
assert not spec.is_merge_complete(state)
|
||||||
|
|
||||||
yield 'execution_payload_header', spec.ExecutionPayloadHeader()
|
yield 'execution_payload_header', execution_payload_header
|
||||||
|
|
||||||
# yield state
|
|
||||||
yield 'state', state
|
yield 'state', state
|
||||||
|
|
||||||
|
|
||||||
@ -100,6 +103,7 @@ def test_initialize_post_transition(spec):
|
|||||||
yield 'deposits', deposits
|
yield 'deposits', deposits
|
||||||
|
|
||||||
# initialize beacon_state *with* an execution_payload_header
|
# initialize beacon_state *with* an execution_payload_header
|
||||||
|
yield 'execution_payload_header', 'meta', True
|
||||||
genesis_execution_payload_header = spec.ExecutionPayloadHeader(
|
genesis_execution_payload_header = spec.ExecutionPayloadHeader(
|
||||||
parent_hash=b'\x30' * 32,
|
parent_hash=b'\x30' * 32,
|
||||||
coinbase=b'\x42' * 20,
|
coinbase=b'\x42' * 20,
|
||||||
@ -118,12 +122,11 @@ def test_initialize_post_transition(spec):
|
|||||||
eth1_block_hash,
|
eth1_block_hash,
|
||||||
eth1_timestamp,
|
eth1_timestamp,
|
||||||
deposits,
|
deposits,
|
||||||
genesis_execution_payload_header,
|
execution_payload_header=genesis_execution_payload_header,
|
||||||
)
|
)
|
||||||
|
|
||||||
yield 'execution_payload_header', genesis_execution_payload_header
|
yield 'execution_payload_header', genesis_execution_payload_header
|
||||||
|
|
||||||
assert spec.is_merge_complete(state)
|
assert spec.is_merge_complete(state)
|
||||||
|
|
||||||
# yield state
|
|
||||||
yield 'state', state
|
yield 'state', state
|
||||||
|
@ -17,8 +17,9 @@ eth1_timestamp: int -- An integer. The timestamp of the block, in seconds.
|
|||||||
A yaml file to help read the deposit count:
|
A yaml file to help read the deposit count:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
description: string -- Optional. Description of test case, purely for debugging purposes.
|
description: string -- Optional. Description of test case, purely for debugging purposes.
|
||||||
deposits_count: int -- Amount of deposits.
|
deposits_count: int -- Amount of deposits.
|
||||||
|
execution_payload_header: bool -- `execution_payload_header` field is filled or not. If `true`, `execution_payload_header.ssz_snappy` file exists.
|
||||||
```
|
```
|
||||||
|
|
||||||
### `deposits_<index>.ssz_snappy`
|
### `deposits_<index>.ssz_snappy`
|
||||||
|
@ -9,7 +9,12 @@ if __name__ == "__main__":
|
|||||||
]}
|
]}
|
||||||
altair_mods = phase_0_mods
|
altair_mods = phase_0_mods
|
||||||
# we have new unconditional lines in `initialize_beacon_state_from_eth1` and we want to test it
|
# we have new unconditional lines in `initialize_beacon_state_from_eth1` and we want to test it
|
||||||
merge_mods = altair_mods
|
merge_mods = {
|
||||||
|
**{key: 'eth2spec.test.merge.genesis.test_' + key for key in [
|
||||||
|
'initialization',
|
||||||
|
]},
|
||||||
|
**altair_mods,
|
||||||
|
}
|
||||||
all_mods = {
|
all_mods = {
|
||||||
PHASE0: phase_0_mods,
|
PHASE0: phase_0_mods,
|
||||||
ALTAIR: altair_mods,
|
ALTAIR: altair_mods,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user