avoid altair fork version collision, update test prep, fix genesis state creator bug

This commit is contained in:
protolambda 2021-03-21 22:07:28 +01:00
parent a69ad6c2db
commit 4a82a375ae
No known key found for this signature in database
GPG Key ID: EC89FDBB2B4C7623
3 changed files with 8 additions and 3 deletions

View File

@ -35,7 +35,8 @@ DOMAIN_SYNC_COMMITTEE: 0x07000000
# Fork
# ---------------------------------------------------------------
ALTAIR_FORK_VERSION: 0x01000000
# Highest byte set to 0x01 to avoid collisions with mainnet versioning
ALTAIR_FORK_VERSION: 0x01000001
# [customized]
ALTAIR_FORK_SLOT: 0

View File

@ -97,8 +97,7 @@ def with_custom_state(balances_fn: Callable[[Any], Sequence[int]],
def entry(*args, spec: Spec, phases: SpecForks, **kw):
# make a key for the state
# genesis fork version separates configs during test-generation runtime.
key = (spec.fork, spec.GENESIS_FORK_VERSION, spec.__file__, balances_fn, threshold_fn)
key = (spec.fork, spec.CONFIG_NAME, spec.__file__, balances_fn, threshold_fn)
global _custom_state_cache_dict
if key not in _custom_state_cache_dict:
state = _prepare_state(balances_fn, threshold_fn, spec, phases)

View File

@ -28,6 +28,11 @@ def create_genesis_state(spec, validator_balances, activation_threshold):
deposit_count=len(validator_balances),
block_hash=eth1_block_hash,
),
fork=spec.Fork(
previous_version=spec.GENESIS_FORK_VERSION,
current_version=spec.GENESIS_FORK_VERSION,
epoch=spec.GENESIS_EPOCH,
),
latest_block_header=spec.BeaconBlockHeader(body_root=spec.hash_tree_root(spec.BeaconBlockBody())),
randao_mixes=[eth1_block_hash] * spec.EPOCHS_PER_HISTORICAL_VECTOR,
)