Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
hwwhww committed May 16, 2019
1 parent 275c90c commit 0aef32e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 21 deletions.
6 changes: 4 additions & 2 deletions scripts/phase0/build_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ def build_phase0_spec(outfile, sourcefiles):
Any,
Dict,
List,
Map,
NewType,
Tuple,
)
Expand Down Expand Up @@ -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 = {}
Expand Down
38 changes: 20 additions & 18 deletions scripts/phase0/function_puller.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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__':
Expand Down
2 changes: 1 addition & 1 deletion specs/core/0_fork-choice.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand Down

0 comments on commit 0aef32e

Please sign in to comment.