Add `make_function_abstract` to make it more general

This commit is contained in:
Hsiao-Wei Wang 2023-05-24 01:58:49 +08:00
parent 73df1935b1
commit dd5e6f813f
No known key found for this signature in database
GPG Key ID: AE3D6B174F971DE4
2 changed files with 9 additions and 9 deletions

View File

@ -736,6 +736,11 @@ def is_byte_vector(value: str) -> bool:
return value.startswith(('ByteVector'))
def make_function_abstract(protocol_def: ProtocolDefinition, key: str):
function = protocol_def.functions[key].split('"""')
protocol_def.functions[key] = function[0] + "..."
def objects_to_spec(preset_name: str,
spec_object: SpecObject,
builder: SpecBuilder,
@ -753,11 +758,10 @@ def objects_to_spec(preset_name: str,
)
def format_protocol(protocol_name: str, protocol_def: ProtocolDefinition) -> str:
if "verify_and_notify_new_payload" in protocol_def.functions:
# del protocol_def.functions['verify_and_notify_new_payload']
protocol_def.functions['verify_and_notify_new_payload'] = """def verify_and_notify_new_payload(self: ExecutionEngine,
new_payload_request: NewPayloadRequest) -> bool:
..."""
abstract_functions = ["verify_and_notify_new_payload"]
for key in protocol_def.functions.keys():
if key in abstract_functions:
make_function_abstract(protocol_def, key)
protocol = f"class {protocol_name}(Protocol):"
for fn_source in protocol_def.functions.values():

View File

@ -180,8 +180,6 @@ class NewPayloadRequest(object):
#### `is_valid_block_hash`
[0]: # (eth2spec: skip)
```python
def is_valid_block_hash(self: ExecutionEngine, execution_payload: ExecutionPayload) -> bool:
"""
@ -192,8 +190,6 @@ def is_valid_block_hash(self: ExecutionEngine, execution_payload: ExecutionPaylo
#### `is_valid_versioned_hashes`
[0]: # (eth2spec: skip)
```python
def is_valid_versioned_hashes(self: ExecutionEngine, new_payload_request: NewPayloadRequest) -> bool:
"""