diff --git a/scripts/phase0/build_spec.py b/scripts/phase0/build_spec.py index 0dba32b17f..f50afc3d36 100644 --- a/scripts/phase0/build_spec.py +++ b/scripts/phase0/build_spec.py @@ -10,6 +10,7 @@ def build_phase0_spec(outfile, sourcefiles): Any, Dict, List, + Map, NewType, Tuple, ) @@ -39,10 +40,11 @@ def build_phase0_spec(outfile, sourcefiles): BLSSignature = NewType('BLSSignature', bytes) # bytes96 Store = None """) - for sourcefile in sourcefiles: - code_lines += function_puller.get_spec(sourcefile) + for index, sourcefile in enumerate(sourcefiles): + code_lines += function_puller.get_spec(sourcefile, index) code_lines.append(""" + # Monkey patch validator compute committee code _compute_committee = compute_committee committee_cache = {} diff --git a/scripts/phase0/function_puller.py b/scripts/phase0/function_puller.py index 3f2f56ac1b..7d118adb30 100644 --- a/scripts/phase0/function_puller.py +++ b/scripts/phase0/function_puller.py @@ -1,7 +1,7 @@ import sys from typing import List -def get_spec(file_name: str) -> List[str]: +def get_spec(file_name: str, file_index: int=0) -> List[str]: code_lines = [] pulling_from = None current_name = None @@ -54,23 +54,25 @@ def get_spec(file_name: str) -> List[str]: if eligible: code_lines.append(row[0] + ' = ' + (row[1].replace('**TBD**', '0x1234567890123456789012345678901234567890'))) # Build type-def re-initialization - code_lines.append('\n') - code_lines.append('def init_SSZ_types():') - code_lines.append(' global_vars = globals()') - for ssz_type_name, ssz_type in type_defs: - code_lines.append('') - for type_line in ssz_type: - if len(type_line) > 0: - code_lines.append(' ' + type_line) - code_lines.append('\n') - code_lines.append('ssz_types = [\n') - for (ssz_type_name, _) in type_defs: - code_lines.append(f' {ssz_type_name},\n') - code_lines.append(']') - code_lines.append('\n') - code_lines.append('def get_ssz_type_by_name(name: str) -> SSZType:') - code_lines.append(' return globals()[name]') - code_lines.append('') + if file_index == 0: + code_lines.append('\n') + code_lines.append('def init_SSZ_types():') + code_lines.append(' global_vars = globals()') + for ssz_type_name, ssz_type in type_defs: + code_lines.append('') + for type_line in ssz_type: + if len(type_line) > 0: + code_lines.append(' ' + type_line) + code_lines.append('\n') + code_lines.append('ssz_types = [\n') + for (ssz_type_name, _) in type_defs: + code_lines.append(f' {ssz_type_name},\n') + code_lines.append(']') + code_lines.append('\n') + code_lines.append('def get_ssz_type_by_name(name: str) -> SSZType:') + code_lines.append(' return globals()[name]') + code_lines.append('\n') + return code_lines if __name__ == '__main__': diff --git a/specs/core/0_fork-choice.md b/specs/core/0_fork-choice.md index 237caa0033..0145acf256 100644 --- a/specs/core/0_fork-choice.md +++ b/specs/core/0_fork-choice.md @@ -128,7 +128,7 @@ def get_head(store: Store) -> Bytes32: #### `on_tick` ```python -def on_tick(store: Store, time: uint64) -> None: +def on_tick(store: Store, time: int) -> None: store.time = time ```