-
Notifications
You must be signed in to change notification settings - Fork 2
XCQ Status Report
XCQ executor is the execution environment connecting host functions and guest programs.
The extension system includes some macros to declare and implement extensions as well as useful structs connecting the executor.
-
decl_extensions
macro defines an extension as a Rust trait with optional associated types. -
impl_extensions
macro generates extension implementations and metadata API. -
ExtensionExecutor
connects extension implementations andxcq-executor
. Host functions are aggregated under a unifiedhost_call
entry. Guest call requests are dispatched to corresponding extensions. -
PermController
filters guest XCQ program calling requests.
xcq-types
is a meta-type system similar to scale-info but much simpler. A meta-type system is required to make different chains with different type definitions work via a common operation. The front-end codes will know how to construct call data to XCQ programs according to the metadata provided by different chains.
- No generics support yet
- No type registry to compress type info and represent self-referential types
Since the Polkavm program ABI only supports several numeric types, we need to pass pointers for passing custom types between host and guest. However, pointer operations like moving and reading the correct size of bytes are error-prone. So, we provide some macros to simplify the usage.
The following XCQ program sums up the balances of several accounts and calculates the percent of the total supply.
- Every program is declared in a separate Rust mod
-
[xcq::call_def]
declares a host call to be used -
[xcq::entrypoint]
declares an entrypoint function that executes the main logic
#[xcq_api::program]
mod sum_balance {
#[xcq::call_def]
fn balance(asset: u32, who: [u8; 32]) -> u64 {}
#[xcq::call_def]
fn total_supply(asset: u32) -> u64 {}
#[xcq::entrypoint]
fn sum_balance(balances: Vec<BalanceCall>, total_supply: TotalSupplyCall) -> u64 {
let mut sum_balance = 0;
for call in balances {
sum_balance += call.call();
}
sum_balance * 100 / total_supply.call()
}
}
- No unified support yet.
- If the number of calls is not known in compile-time, the XCQ program bloats to several KBs because we need a global allocato ar to support
alloc::vec::Vec
.
- XCM use cases need to be considered. Ideally, we will have an XCM instruction for XCQ.
- Sumbit an XCQ RFC.