Code Monkey home page Code Monkey logo

xbi's Introduction

XBI

codecov

An XCM-based high-level standard and interface (ABI) for smart contracts.

W3F grants

At t3rn, we aim for XBI to become the de-facto standord for integrating with smart contracts all cross the ecosystem. To facilitate that, we aim to implement XBI as a set of grants to enable a transparent, usable specification.

Standards

The XBI standard is undergoing a lot of iteration, the details can be found in ./docs.

  • The opening proposal is here, with the PSP for such here

XBI Extensions

Whilst XBI should be modular, so should extensions on XBI. Each extension can be roughly explained here, and any links to the grant proposals seen below:

xbi's People

Contributors

0xf333 avatar 3h4x avatar dndll avatar t3rn-ci avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

xbi's Issues

Investigate how to handle time across different chains

Item Type

Spike

Description

AS A message requester
I WANT to specify a timeout that a message can take to execute
SO THAT i can have garuantees by xbi 

A user must be able to provide a timeout in an XBI message. This is quite relevant when it comes to asynchronous backed channels since the time it was requested will most certainly be different from the time it was sent, or executed and so on.

Additional Information

However, there is no concept of time really, within a blockchain. We can take the time from aura but it adds a dependency on all parachains that use XBI to use aura or something else to give us time. A better notation is a block number. This is also tricky since we might send a message on #500 on source but then there must be a new timer for when we receive the message at block #12324 on dest.

It is probably reasonable to have something like two timers. Such as:

  • requested => starts on parachain A
  • sent => still A
  • delivered => starts a timer for B
  • executed => Also B
  • responded => B
  • received => A
    Then we can do some simple math on these and if it exceeded, then we can error. However, its not possible to rollback once the parachain has responded, so how much value does that bring if we were to timeout when it was received.

Really the two terminal operations of when a timeout should/could break are:

  • before it was sent by A (elapsed time, no longer needed)
  • by the time it was delivered to B (could be fine to do)
  • before B executes it

Really, these are the only terminal operations we should have in XBI.

Acceptance Criteria

Investigate risks that this approach might take and write the stories to improve time within XBI.

2d

What are the points assigned to this item?

2

Is the issue ready?

  • This issue is ready

Benchmarking for send/receive

Item Type

Story

Description

We need to add benchmarking to XBI portal, since everything is currently free.

This would take a reasonable amount of work since we are also benchmarking contract calls.

Additional Information

No response

Acceptance Criteria

  • benchmarkings enabled
  • updated benchmarks in the module

What are the points assigned to this item?

None

Is the issue ready?

  • This issue is ready

WIP: Message validation on instruction handler

Item Type

Epic

Description

AS a message sender
I WANT to be able to specify what is a successful message
SO THAT I can have fine-grained control of the result

A user should be able to specify to the receiver's instruction handler what a successful message means.

For example, a call to a smart contract is currently largely always a success if the contract was able to be called.
But what if the result is wrong? If a user is expecting a flipped to be true, and it returns false this is a failure, or is it?

Users should have this control because they have no guarantees the contract hasn't been modified since they inspected it.

Additional Information

This should be provided via the message metadata. Something like a validations field.

Additional information should be investigated via a spike to see if this is doable and the limitations/security considerations of such a feature.

Acceptance Criteria

Fill later

What are the points assigned to this item?

13

Is the issue ready?

  • This issue is ready

Unify Substrate ABI/Substrate Contracts ABI

Item Type

Task

Description

These should be unified and the contracts abi should just be a bolt-on to Substrate ABI.

This can be achieved by a feature flag contracts.

Additional Information

Ensure any dependencies are updated, and ensure breaking changes are added to the commit so that any dependents will know about it.

Acceptance Criteria

  • uses feature flag contracts to expose SCABI
  • move SCABI into substrate abi
  • use a module
  • ensure builds without contracts feature flag

What are the points assigned to this item?

1

Is the issue ready?

  • This issue is ready

Gossiping destination fees

Item Type

Spike

Description

Todo

Additional Information

No response

Acceptance Criteria

todo

What are the points assigned to this item?

None

Is the issue ready?

  • This issue is ready

Unify the requests and responses storage items

Item Type

Task

Description

We should unify the requests and responses storage items in XbiPortal. This will make it easier for the queue to manage one set of items and provide clear checks.

Additional Information

This can be reduced to just Message since it contains everything needed for us to handle the queue.

Acceptance Criteria

  • unified storage items
  • no hash collosions

What are the points assigned to this item?

None

Is the issue ready?

  • This issue is ready

Refactor timestamp progression

Item Type

Story

Description

Timestamp progression is a little optimistic. We should use an enum and just call progress(Progression(block)).

This means we can easily see gaps in the timestamp process.

Additional Information

The progress function currently just takes a block number and assumes that the progression is moving from a -> b.

Update it to take an enum with a number instead, and simply update the field.

Acceptance Criteria

  • mappings for each timestamp are an enum
  • updates the block number

What are the points assigned to this item?

0.5

Is the issue ready?

  • This issue is ready

XBI Self messages

Item Type

Story

Description

We initially removed this, but we should check that XbiMetadata src == dest in the FrameSender and if so, use ExecuteXCM/InstructionHandler instead.

Additional Information

We need to inject ExecuteXcm into FrameSender, or we might just inject InstructionHandler. This would allow us to simply execute self without going over Xcm needlessly. This would allow the Circuit to send self-messages eventually without knowing about implementation details.

This should skip the receiver-post aspect of the message too.

Acceptance Criteria

Given an XBI message with metadata that is from self -> to self
When the message is to be sent
Then the message will not be sent
And the message will be handled by the src parachain instead
And src should be validated to ensure self is src

What are the points assigned to this item?

None

Is the issue ready?

  • This issue is ready

Validate Asset Registry barrier

Item Type

Task

Description

When we built the barrier in Asset Registry, we forgot to create an integration test for it and install it.

Additional Information

Create some tests to prove the barrier works in real life using the integration-tests folder.

Acceptance Criteria

Ensure that only payable assets can be used. Create one with ROC unpayable and one with, make sure the fees are correct.

What are the points assigned to this item?

None

Is the issue ready?

  • This issue is ready

Bring xbi-precompile up to speed

Item Type

Story

Description

TODO

Additional Information

No response

Acceptance Criteria

TODO

What are the points assigned to this item?

None

Is the issue ready?

  • This issue is ready

Remove ID from `XbiResult`

Item Type

Task

Description

Remove the id field from XbiResult since we have it in the metadata anyway.

Additional Information

Update the codec to remove the id. Everything should take the id from the metadata.

Acceptance Criteria

id is removed and tests pass

What are the points assigned to this item?

None

Is the issue ready?

  • This issue is ready

Introduce storing results in the synchronous `Sender`

Item Type

Story

Description

For now, we have been emitting events with the results for debugging.

We should be storing the result to XbiResponses

Additional Information

Validation should be on the request of a message to ensure that the XbiId is uniquely stored, otherwise, return.

Introduce a trait for reading from & storing to XbiResponses or utilise one if it already exists within substrate frame_support. Inject this trait into the sender and store the result in handle_response.

Implement this for XbiPortal.

Also update the checks in process_queue to use the same trait implementation.

Acceptance Criteria

GIVEN a response
WHEN it is handled by the handler
THEN it is stored in the store

What are the points assigned to this item?

1

Is the issue ready?

  • This issue is ready

Reserve the funds for an asset in `ChargeForSender`

Item Type

Story

Description

We want to be able to reserve the funds for an asset rather than send them to some arbitrary account.

Additional Information

We currently have ways to "Reserve" an asset, but it does break the philosophy of XBI and isn't really anything to do with XBI.

There are traits InspectHold & MutateHold. These allow an asset to be treated much like ReservableCurrency, but I'm aware that they do not respect ExistentialDeposit. The other issue is that these traits are not actually implemented in assets and basically don't do anything.

One option, which is rather nuclear, is to introduce some DTO in our pallet-assets::Extra config to have the fields reserved and anything else. This does tightly couple any user of XBI to this implementation.

The other option we do in t3rn::AccountManager as a first-pass solution, is to basically just send the funds to a treasury and refund when we like via some ticketing system. This also cannot work for XBI since it couples parachains to use this very specific implementation.

We could in the meantime just send it to an account that the pallet owns, and pay it out, which we can do in the Queue PR. But this is a very feral implementation and is not for purpose.

Parity has introduced the true fix for it on this pr however this is very recent and we're still on an old version of substrate.

My personal proposition is to wait. And ensure we keep an eye on this PR and maybe retro fit it to a Newtype Trait, but still requires custom work on pallet-assets.

Acceptance Criteria

A

What are the points assigned to this item?

None

Is the issue ready?

  • This issue is ready

Coverage isnt being registered correctly

Item Type

Bug

Description

Since we switched to lcov, the coverage that is being sent is null

Additional Information

No response

Acceptance Criteria

none

What are the points assigned to this item?

None

Is the issue ready?

  • This issue is ready

Queue-backed channel

Item Type

Epic

Description

We should complete the queue-backed channel. The purpose of this channel is to allow for the detached handling of messages, driven by a substrate on_initialize hook.

Most of this is in each channel part::queue_backed.

The portal pallet would need an extension to support both send(sync) and the async send.

Additional Information

For the most part, the queue is largely implemented, we just need hooks and we need to test them, we also need to add the costs of handling each queue part, and charging the user when we eventually handle the message.

We should also be refunding the user the difference in the message.

Acceptance Criteria

These tests should just call synchronous receive on the target.

GIVEN a message to asynchronously send
AND the message maximum cost is `5_000_000`
WHEN the user requests to send the message
THEN the user is charged the maximum fees for `exec & delivery` of `5_000_000`
AND the message is placed on the queue
WHEN the hook takes the message from the queue
THEN it should be sent over XCM
GIVEN a response to handle
AND the message maximum cost is `5_000_000`
AND the response cost was `4_999_999`
WHEN the queue handler takes the message
THEN the user is refunded `1`
AND the message result is written to the store

We should also be validating the signal of the queue, and ensuring that failed messages are popped to the back of the queue.

Gas should be returned from the init hook.

What are the points assigned to this item?

None

Is the issue ready?

  • This issue is ready

Allow a parachain to register information about itself in our asset registry via XBI/XCM

Item Type

Story

Description

A parachain should be able to update their own reverse lookup/master lookup.

This should be via an XBI call which would assume root on the parachains behalf to update the lookup.

Additional Information

No response

Acceptance Criteria

todo

What are the points assigned to this item?

None

Is the issue ready?

  • This issue is ready

Change the naming style of primitives to follow a standardised scheme

Item Type

Task

Description

The current scheme is random. We should follow the same style as substrate, such is prefixed with s(substrate)p(primitives)-thething

Rename the manifest to follow xp-thing.

Additional Information

No response

Acceptance Criteria

Each primitive should be updated:

  • channel-primitives
  • xcm

Consider also renaming sabi/scabi too.
Also channel parts to something like xs-thing (xbi service).

What are the points assigned to this item?

1

Is the issue ready?

  • This issue is ready

XBI multi-protocol transfer

Item Type

Story

Description

AS A user
I WANT to be able to transfer
SO THAT I can send funds across the dotsama ecosystem

We want to be able to support multi-protocol transfer.

Additional Information

Currently there are a few ways to transfer over XCM

  • teleport (mostly unsupported)
  • reserve backed asset transfer (mostly unsupported, requires liaising with parachains), no trusted common-good parachain yet (statemine)
  • natively, sending a transact call to pallet-balances on destination

We should support all three, based on the capabilities of each chain. Eventually calling native.

Introduce a new call in XBI portal, transfer which would determine which approach to take, if the parachain supports it for the asset.

Acceptance Criteria

TODO

What are the points assigned to this item?

None

Is the issue ready?

  • This issue is ready

Lookups for pallet index installed on destination

Item Type

Story

Description

The pallet index is hard coded for 200 to XBI portal. We should figure out a way to resolve these indexes fairly efficiently.

Additional Information

No response

Acceptance Criteria

todo

What are the points assigned to this item?

None

Is the issue ready?

  • This issue is ready

Generate the `id` for an XBI message

Item Type

Story

Description

Users should not be able to generate an id, we should do it ourselves by a composite hash of a nonce field stored in the pallet and the XbiMetadata => hash(nonce, metadata)

Additional Information

Remove the ability to set the field by using codec::skip and ensure that it is received on the receiver or by some other means.

Also hide timesheet. Since this should not be set by the user.

Introduce a StorageValue item in the pallet named MessageNonce to increment_and_get on each request to send an xbi message.

Note

Under no circumstances should it be implied that a user can set this message, it is not suffice to use an Option in the request. This should be handled smarter.

Acceptance Criteria

GIVEN a request to send a message
WHEN the reuqest is checked
THEN the `MessageNonce` should be incremented
AND the `id` should be added to the `XbiMetadata`
AND it should be the same when the receiver receives it

What are the points assigned to this item?

2

Is the issue ready?

  • This issue is ready

Remove the ability to configure gas fees for contract VM calls.

Item Type

Story

Description

This should be derived from max_execution_cost field in XBI

Additional Information

No response

Acceptance Criteria

  • remove the field in the codec and format, and enrich it from the fees on the instruction handler.
  • evm
  • wsm

What are the points assigned to this item?

None

Is the issue ready?

  • This issue is ready

Everything from BuyExecution is burned

Item Type

Bug

Description

We must have some magic configured in integration tests because everything from the BuyExecution call is just being burned at the target. This needs to be tied against the weight of the call and not just burn everything or at the very least allow it to be claimable.

Additional Information

Do test::user_is_refunded_most_of_fees_on_target_fail to see the events.

Acceptance Criteria

bug

What are the points assigned to this item?

None

Is the issue ready?

  • This issue is ready

Make the channel crates a single crate

Item Type

Task

Description

Sender & Receiver should be a single crate, limited by feature flags.

Additional Information

Feature flags should be for receiver and sender.

Both should be the default.

Acceptance Criteria

  • Ensure due dilligence for all features, build with one, both, none and for no-default-features && --target wasm32-unknown-unknown

What are the points assigned to this item?

None

Is the issue ready?

  • This issue is ready

Refactor some converters to a `From<T>` implementation

Item Type

Task

Description

Most of the converters in each channel crate can be a From implementation in the respective struct. Refactor these to use it and utilise DTOs.

Additional Information

No response

Acceptance Criteria

  • tests for each converter
  • should be idiomatic

What are the points assigned to this item?

None

Is the issue ready?

  • This issue is ready

Configurable response cost

Item Type

Story

Description

AS A parachain
I WANT to configure how much I'm willing to pay to send the message back
SO THAT I am not sending messages for free

On each receiver-sender, we don't pay for execution at the destination to handle the response.

A parachain implementer should be able to configure this Response Cost and provide it into the channel so that it has ownership over the notification fee on its part.

Additional Information

Inject a Get into the Sender, and utilize this when the message is being responded to in buy_execution. The parachain that sent this should then pay the fee.

There is a small amount of complexity regarding the actual fee for the notification. When should it be charged?

  • When the source sender receives the response? This isn't known until the message is handled at the destination unless a parachain was to gossip about it beforehand << this solution we can't do yet, although it is neat.
  • We don't know the cost of sending the response until it has been done
  • Emitting an event would also be tricky since this is at the destination
  • Dest could add what it took out to the aggregated costs field

Option #1 dumb option:
We can validate if the Dest response cost would overflow the aggregated cost and deny the execution

  • Upon receiving the message before handling, add the cost to the notification costs aggregation field
  • If the costs exceed, don't even execute, emit an event and if sync, return an error
  • This will timeout on the user side and then the user should be refunded their fees - source notification cost

#2 Improvement:
We know about the cost and any details of the message beforehand via some registry of response costs and any other metadata

  • We check the costs before sending the XBI message
  • If it's too much, don't send the message and reject

Utopian goal:
XBI gossips the costs via some inherent to all users who implement XBI

  • Same as above, just no need for a centralised registry

Acceptance Criteria

dsaasdas

What are the points assigned to this item?

None

Is the issue ready?

  • This issue is ready

t3rn protocol location

Item Type

Story

Description

As a user
I want to be able to call t3rn protocol
So that I can access things outside of dotsama

We should support t3rn protocol via utilisation of UniversalLocation in XCM.

If we register /Ethereum then we can submit a side effect to t3rn to hit ethereum.

Additional Information

This would have interesting complexity regarding XBI timeouts and such. Needs spec

Acceptance Criteria

needs spec

What are the points assigned to this item?

None

Is the issue ready?

  • This issue is ready

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.