-
Notifications
You must be signed in to change notification settings - Fork 19
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
Metadata #30
Comments
@NadigerAmit Please post your findings and thoughts here as you learn. |
Current Metadata situation of Tuxedo Why metadata is required. User Interfaces: Metadata provides essential information for constructing user-friendly interfaces in wallets and explorers. Documentation: Metadata serves as self-documentation for the blockchain's runtime, describing types, storage, and transactions. Upgradability: Metadata supports runtime upgradability, allowing descriptions of changes in the on-chain runtime state. Developer Tooling: Developers use metadata to understand runtime capabilities, design smart contracts, and interact during development. Cross-Chain Communication: In multi-chain environments, metadata facilitates communication and interaction between different blockchains. Why Tuxedo don’t have support for Metadata Tuxedo is also built based on the substrate Requirements of metadata for Tuxedo Dynamic Metadata Generation: The framework must support dynamic generation of metadata for runtime modules (Pieces) during initialization. Metadata Structure: The framework must define a structured metadata format, including information about storage entries, supported transactions, constraint checker errors, Required constraints on the input and output, and Required Verifiers for transactions such as sign, multisign, upForGrab,etc. Dynamic Extrinsic Metadata: The framework must allow runtime modules to dynamically register metadata for extrinsics. Extrinsic Metadata Structure: The metadata structure must include information about supported extrinsic. Registration Mechanism: The framework must provide a registration mechanism (macro or trait) for runtime modules to register their metadata. Serialization and Deserialization The framework must support serialization and deserialization of metadata using the SCALE codec library. Integration with SCALE Codec: The framework must integrate with the SCALE codec library, utilizing the scale-info crate for generating metadata. Polkadot.js API Compatibility: The framework must expose an API endpoint compatible with Polkadot.js (state_getMetadata()). Polkadot.js UI Integration: The framework must support integration with the Polkadot.js UI, dynamically displaying information about registered Pieces. Opaque Data Structure: The metadata structures must be designed as opaque data structures to abstract internal details from external applications. |
Below is 1st Draft Design : The important thing to notice is that FRAME is account-based and Tuxedo is UTXO-based. The tuxedo doesn’t have below :
Instead, Tuxedo has below :
Below is data structure I am thinking of now
Draft Algorithm:Steps to generate the metadata: Step 1: Define Piece Metadata Trait
Step 2: Implementation of PieceMetadataTrait for Piece. Implementation of PieceMetadataTrait The KittyPiece struct implements
Note: Currently generation of metadata by individual runtime pieces is done manually i.e. piece developer needs to implement the metadata() function from the PieceMetadata trait. Step 3: Centralized Module for Metadata Collection and Registration.
Step 4: Retrieve the metadata in the from the runtime.
Step 5: Provide Metadata via state_getMetadata() Provide Metadata via state_getMetadata() From the sp_api APIs
|
OpaqueMetadata in Substrate refers to encoding metadata into a format that is not directly human-readable, often done for efficiency or security reasons. This encoded metadata can be retrieved by clients like Polkadot.js and used to understand the runtime's capabilities and structures. Step1: Metadata is defined in the sp_core (lib.rs - source (docs.rs) )
Step2: Definition the metadata trait in the sp_api
Step 3: Implementing the metadataTrait in Runtime Implement the metadata trait in Runtime Inside the implementation of the Metadata trait, we encode runtime's metadata into a Vec using your encoding logic. The goal is to represent all the necessary information about runtime in a compact, binary form.
Step 4: Retrieving Metadata For example, in Polkadot.js, we need to call api.rpc.state.getMetadata() to get the encoded metadata. Step 5: Client Interpretations of Metadata Once the encoded metadata is retrieved, Polkadot.js or other clients need to have logic to decode this opaque format and display it in a more human-readable and user-friendly manner. |
A couple little thoughts based on what you wrote:
|
Made a tiny bit of progress on this in #211 |
We should consider using metadata so we can have a dynamic wallet to submit transactions. We could take inspiration from https://github.com/paritytech/frame-metadata.
The text was updated successfully, but these errors were encountered: