Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 2 #122

Merged
merged 18 commits into from
Jul 17, 2024
Merged

Version 2 #122

merged 18 commits into from
Jul 17, 2024

Conversation

arjanz
Copy link
Member

@arjanz arjanz commented Jul 1, 2024

New from the ground up object based implementation in stead of parsing of type strings, which improves performance, flexibility and readability.

Benchmark of a MetadataV14 SCALE blob of 246kB

metadata_obj = MetadataVersioned.new()
metadata_obj.decode(ScaleBytes(metadata_fixture_dict['V14']))

# Execution time: 0.11408376693725586 seconds

Version 1 equivalent:

metadata_obj = runtime_config.create_scale_object("MetadataVersioned")
metadata_obj.decode(ScaleBytes(metadata_fixture_dict['V14']))

# Execution time: 0.40303683280944824 seconds

Other type examples

obj = Tuple(Compact(U32), Compact(U32)).new()
obj.decode(ScaleBytes("0x0c00"))

SlotNumber = U64
VrfOutput = Array(U8, 32)
VrfProof = Array(U8, 64)
RawAuraPreDigest = Struct(slot_number=U64)
RawBabePreDigestPrimary = Struct(authority_index=U32, slot_number=SlotNumber, vrf_output=VrfOutput, vrf_proof=VrfProof)
RawBabePreDigestSecondaryPlain = Struct(authority_index=U32, slot_number=SlotNumber)
RawBabePreDigestSecondaryVRF = Struct(authority_index=U32, slot_number=SlotNumber, vrf_output=VrfOutput, vrf_proof=VrfProof)
RawBabePreDigest = Enum(Phantom=None, Primary=RawBabePreDigestPrimary, SecondaryPlain=RawBabePreDigestSecondaryPlain, SecondaryVRF=RawBabePreDigestSecondaryVRF)

Configurable arguments per `Struct` subclass
Configurable values per `Tuple` subclass
Configurable variants per `Enum` subclass
* Added custom `Call` implementation
* type def override function now passes relevant *args and **kwargs
* Fixed various failing unit tests
* Refactored process_encode to _encode
* Updated unit tests
@arjanz arjanz marked this pull request as ready for review July 16, 2024 15:52
@arjanz arjanz merged commit ed78926 into v2 Jul 17, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant