open-web3-stack / XCQ

Cross-Consensus Query Language for Polkadot
Apache License 2.0
11 stars 2 forks source link

Extension System: stable `extension_id` calculation #33

Open indirection42 opened 1 week ago

indirection42 commented 1 week ago

Currently, the extension_id is simply calculated on AST level which is not only stable. see: https://github.com/open-web3-stack/XCQ/blob/3c0d9b4c70ff6995c6c66270e2edb18a7b199427/xcq-extension/procedural/src/lib.rs#L171 Theoretically, we want two trait methods sets produce the same extension id, after the resolution of type aliases. However, the type aliases can be defined out of the TokenStream that current proc-macro-attribute processed. So how we do with it? https://github.com/open-web3-stack/XCQ/blob/3c0d9b4c70ff6995c6c66270e2edb18a7b199427/xcq-extension-fungibles/src/lib.rs#L4-L19 And we also need a helper function/macro for "client" to easily specify the extension_id which matches the "server" side. However, these types are concrete types. https://github.com/open-web3-stack/XCQ/blob/3c0d9b4c70ff6995c6c66270e2edb18a7b199427/xcq-extension/tests/extension_executor_works.rs#L113-L117

indirection42 commented 1 week ago

Currently, we calculate like this (only consider trait_ident and method_ident): https://github.com/open-web3-stack/XCQ/blob/f1af976cd761d722c6aa7ca6b3d7e4f688b03401/xcq-extension/procedural/src/lib.rs#L169-L178