Skip to content

Conversation

@arjanz
Copy link
Contributor

@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
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.

2 participants