mirror of
https://github.com/status-im/eth2.0-specs.git
synced 2025-02-26 01:05:15 +00:00
Merge pull request #3412 from dapplion/setup-file-decl
Drop need to declare spec feature files
This commit is contained in:
commit
3442dbb3e9
121
setup.py
121
setup.py
@ -50,6 +50,25 @@ DENEB = 'deneb'
|
|||||||
EIP6110 = 'eip6110'
|
EIP6110 = 'eip6110'
|
||||||
WHISK = 'whisk'
|
WHISK = 'whisk'
|
||||||
|
|
||||||
|
PREVIOUS_FORK_OF = {
|
||||||
|
PHASE0: None,
|
||||||
|
ALTAIR: PHASE0,
|
||||||
|
BELLATRIX: ALTAIR,
|
||||||
|
CAPELLA: BELLATRIX,
|
||||||
|
DENEB: CAPELLA,
|
||||||
|
EIP6110: DENEB,
|
||||||
|
WHISK: CAPELLA,
|
||||||
|
}
|
||||||
|
|
||||||
|
ALL_FORKS = list(PREVIOUS_FORK_OF.keys())
|
||||||
|
|
||||||
|
IGNORE_SPEC_FILES = [
|
||||||
|
"specs/phase0/deposit-contract.md"
|
||||||
|
]
|
||||||
|
|
||||||
|
EXTRA_SPEC_FILES = {
|
||||||
|
BELLATRIX: "sync/optimistic.md"
|
||||||
|
}
|
||||||
|
|
||||||
# The helper functions that are used when defining constants
|
# The helper functions that are used when defining constants
|
||||||
CONSTANT_DEP_SUNDRY_CONSTANTS_FUNCTIONS = '''
|
CONSTANT_DEP_SUNDRY_CONSTANTS_FUNCTIONS = '''
|
||||||
@ -96,6 +115,30 @@ class SpecObject(NamedTuple):
|
|||||||
dataclasses: Dict[str, str]
|
dataclasses: Dict[str, str]
|
||||||
|
|
||||||
|
|
||||||
|
def is_post_fork(a, b) -> bool:
|
||||||
|
"""
|
||||||
|
Returns true if fork a is after b, or if a == b
|
||||||
|
"""
|
||||||
|
if a == b:
|
||||||
|
return True
|
||||||
|
|
||||||
|
prev_fork = PREVIOUS_FORK_OF[a]
|
||||||
|
if prev_fork == b:
|
||||||
|
return True
|
||||||
|
elif prev_fork == None:
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
return is_post_fork(prev_fork, b)
|
||||||
|
|
||||||
|
def get_fork_directory(fork):
|
||||||
|
dir1 = f'specs/{fork}'
|
||||||
|
if os.path.exists(dir1):
|
||||||
|
return dir1
|
||||||
|
dir2 = f'specs/_features/{fork}'
|
||||||
|
if os.path.exists(dir2):
|
||||||
|
return dir2
|
||||||
|
raise FileNotFoundError(f"No directory found for fork: {fork}")
|
||||||
|
|
||||||
def _get_name_from_heading(heading: Heading) -> Optional[str]:
|
def _get_name_from_heading(heading: Heading) -> Optional[str]:
|
||||||
last_child = heading.children[-1]
|
last_child = heading.children[-1]
|
||||||
if isinstance(last_child, CodeSpan):
|
if isinstance(last_child, CodeSpan):
|
||||||
@ -1068,70 +1111,20 @@ class PySpecCommand(Command):
|
|||||||
if len(self.md_doc_paths) == 0:
|
if len(self.md_doc_paths) == 0:
|
||||||
print("no paths were specified, using default markdown file paths for pyspec"
|
print("no paths were specified, using default markdown file paths for pyspec"
|
||||||
" build (spec fork: %s)" % self.spec_fork)
|
" build (spec fork: %s)" % self.spec_fork)
|
||||||
if self.spec_fork in (PHASE0, ALTAIR, BELLATRIX, CAPELLA, DENEB, EIP6110, WHISK):
|
self.md_doc_paths = ""
|
||||||
self.md_doc_paths = """
|
|
||||||
specs/phase0/beacon-chain.md
|
for fork in ALL_FORKS:
|
||||||
specs/phase0/fork-choice.md
|
if is_post_fork(self.spec_fork, fork):
|
||||||
specs/phase0/validator.md
|
# Append all files in fork directory recursively
|
||||||
specs/phase0/weak-subjectivity.md
|
for root, dirs, files in os.walk(get_fork_directory(fork)):
|
||||||
specs/phase0/p2p-interface.md
|
for filename in files:
|
||||||
"""
|
filepath = os.path.join(root, filename)
|
||||||
if self.spec_fork in (ALTAIR, BELLATRIX, CAPELLA, DENEB, EIP6110, WHISK):
|
if filepath.endswith('.md') and filepath not in IGNORE_SPEC_FILES:
|
||||||
self.md_doc_paths += """
|
self.md_doc_paths += filepath + "\n"
|
||||||
specs/altair/light-client/full-node.md
|
# Append extra files if any
|
||||||
specs/altair/light-client/light-client.md
|
if fork in EXTRA_SPEC_FILES:
|
||||||
specs/altair/light-client/p2p-interface.md
|
self.md_doc_paths += EXTRA_SPEC_FILES[fork] + "\n"
|
||||||
specs/altair/light-client/sync-protocol.md
|
|
||||||
specs/altair/beacon-chain.md
|
|
||||||
specs/altair/bls.md
|
|
||||||
specs/altair/fork.md
|
|
||||||
specs/altair/validator.md
|
|
||||||
specs/altair/p2p-interface.md
|
|
||||||
"""
|
|
||||||
if self.spec_fork in (BELLATRIX, CAPELLA, DENEB, EIP6110, WHISK):
|
|
||||||
self.md_doc_paths += """
|
|
||||||
specs/bellatrix/beacon-chain.md
|
|
||||||
specs/bellatrix/fork.md
|
|
||||||
specs/bellatrix/fork-choice.md
|
|
||||||
specs/bellatrix/validator.md
|
|
||||||
specs/bellatrix/p2p-interface.md
|
|
||||||
sync/optimistic.md
|
|
||||||
"""
|
|
||||||
if self.spec_fork in (CAPELLA, DENEB, EIP6110, WHISK):
|
|
||||||
self.md_doc_paths += """
|
|
||||||
specs/capella/light-client/fork.md
|
|
||||||
specs/capella/light-client/full-node.md
|
|
||||||
specs/capella/light-client/p2p-interface.md
|
|
||||||
specs/capella/light-client/sync-protocol.md
|
|
||||||
specs/capella/beacon-chain.md
|
|
||||||
specs/capella/fork.md
|
|
||||||
specs/capella/fork-choice.md
|
|
||||||
specs/capella/validator.md
|
|
||||||
specs/capella/p2p-interface.md
|
|
||||||
"""
|
|
||||||
if self.spec_fork in (DENEB, EIP6110):
|
|
||||||
self.md_doc_paths += """
|
|
||||||
specs/deneb/light-client/fork.md
|
|
||||||
specs/deneb/light-client/full-node.md
|
|
||||||
specs/deneb/light-client/p2p-interface.md
|
|
||||||
specs/deneb/light-client/sync-protocol.md
|
|
||||||
specs/deneb/beacon-chain.md
|
|
||||||
specs/deneb/fork.md
|
|
||||||
specs/deneb/fork-choice.md
|
|
||||||
specs/deneb/polynomial-commitments.md
|
|
||||||
specs/deneb/p2p-interface.md
|
|
||||||
specs/deneb/validator.md
|
|
||||||
"""
|
|
||||||
if self.spec_fork == EIP6110:
|
|
||||||
self.md_doc_paths += """
|
|
||||||
specs/_features/eip6110/beacon-chain.md
|
|
||||||
specs/_features/eip6110/fork.md
|
|
||||||
"""
|
|
||||||
if self.spec_fork == WHISK:
|
|
||||||
self.md_doc_paths += """
|
|
||||||
specs/_features/whisk/beacon-chain.md
|
|
||||||
specs/_features/whisk/fork.md
|
|
||||||
"""
|
|
||||||
if len(self.md_doc_paths) == 0:
|
if len(self.md_doc_paths) == 0:
|
||||||
raise Exception('no markdown files specified, and spec fork "%s" is unknown', self.spec_fork)
|
raise Exception('no markdown files specified, and spec fork "%s" is unknown', self.spec_fork)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user