Skip to content
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

contracts: Hybrid chain support #114

Open
1 of 7 tasks
athei opened this issue Mar 19, 2023 · 0 comments
Open
1 of 7 tasks

contracts: Hybrid chain support #114

athei opened this issue Mar 19, 2023 · 0 comments
Assignees
Labels
D3-involved Can be fixed by an expert coder with good knowledge of the codebase. I6-meta A specific issue for grouping tasks or bugs of a specific category.

Comments

@athei
Copy link
Member

athei commented Mar 19, 2023

https://www.rob.tech/blog/hybrid-chains/

As of right now crafting an interaction between the runtime and contracts hosted on its contracts pallet is cumbersome. We want this to be a nice experience without any manual labor. Almost all the bits and pieces to make this happen exist. We need to put them together and apply polish.

There are two sides to this endeavor and we explain them separately.

Calling a contract from the runtime

Calling into a contract from any pallet is not difficult as of right now. The pallet needs to depend on pallet-contracts and call Pallet::bare_call with the address of the contract. However, crafting the input and evaluating the output is not easy. The data is formatted according to the ink! ABI and specific to the contract. One has to manually craft code to encode input and decode output. This makes the whole thing rather pointless.

We want to change this to the following: Any runtime code that wants to call a contract will depend directly on the contract in its manifest (in addition to pallet-contracts). This dependency will then export (generated) types that allow to craft interactions for every function exposed by the contract. This code will make sure that in- and outputs are properly coded in a type safe way.

The issue for ink! to export those types can be found here. It includes a mock up of the envisioned API: use-ink/ink#1674

Next Steps

Calling the runtime

Currently, in order to call functionality within a runtime that lies outside of the core API a ChainExtension needs to be created by runtime authors. It extends the set of functions a contract can call. It is manual work because those entry points must be safe for being called by hostile actors (contracts). That includes dealing with untrusted input and charging a sound amount of weight.

It turns out there is another type of function within the runtime which has the same requirements (dealing with untrusted input, charging weight): Dispatchables. Dispatchables are already describing the set of functions within a runtime which are safe to be called by hostile actors. We just need to make them available for contracts. As a matter of fact we already have the functionality to dispatch a Call into the runtime.

However, it cannot replace chain extensions for one simple reason: A Dispatchable can't return any data on success but rather uses a side channel for that (events). It might be nice to capture those events and copy them back to the contract.

Additional ways of improvement would be to add view functions to FRAME which can be used by contracts and add a suite of macros that allow for chain extensions to be derived while generating metadata for ink!.

Next Steps

Before starting to work on any of those points create a new issue and link it here.

@athei athei changed the title contracts: Make interaction between contracts and runtime easy contracts: Hybrid chain support Apr 12, 2023
@athei athei transferred this issue from paritytech/substrate Aug 24, 2023
@the-right-joyce the-right-joyce added I6-meta A specific issue for grouping tasks or bugs of a specific category. D3-involved Can be fixed by an expert coder with good knowledge of the codebase. and removed J1-meta labels Aug 25, 2023
lexnv pushed a commit that referenced this issue Apr 3, 2024
* Add archive node description

The description for archive nodes was missing.

* Change full node description as suggested

* accept tomaka's suggestion

Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>

---------

Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>
serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Apr 8, 2024
serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Apr 8, 2024
serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Apr 9, 2024
serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Apr 9, 2024
serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Apr 9, 2024
serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Apr 9, 2024
serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Apr 9, 2024
serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Apr 9, 2024
serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Apr 10, 2024
serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Apr 10, 2024
jonathanudd pushed a commit to jonathanudd/polkadot-sdk that referenced this issue Apr 10, 2024
github-merge-queue bot pushed a commit that referenced this issue May 27, 2024
## [0.5.0] - 2023-05-24

This is a small patch release that makes the `FindNode` command a bit
more robst:

- The `FindNode` command now retains the K (replication factor) best
results.
- The `FindNode` command has been updated to handle errors and
unexpected states without panicking.

### Changed

- kad: Refactor FindNode query, keep K best results and add tests
([#114](paritytech/litep2p#114))

---------

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
lexnv added a commit that referenced this issue May 27, 2024
This is a small patch release that makes the `FindNode` command a bit
more robst:

- The `FindNode` command now retains the K (replication factor) best
results.
- The `FindNode` command has been updated to handle errors and
unexpected states without panicking.

- kad: Refactor FindNode query, keep K best results and add tests
([#114](paritytech/litep2p#114))

---------

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
lexnv added a commit that referenced this issue May 27, 2024
This is a small patch release that makes the `FindNode` command a bit
more robst:

- The `FindNode` command now retains the K (replication factor) best
results.
- The `FindNode` command has been updated to handle errors and
unexpected states without panicking.

- kad: Refactor FindNode query, keep K best results and add tests
([#114](paritytech/litep2p#114))

---------

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
hitchhooker pushed a commit to ibp-network/polkadot-sdk that referenced this issue Jun 5, 2024
## [0.5.0] - 2023-05-24

This is a small patch release that makes the `FindNode` command a bit
more robst:

- The `FindNode` command now retains the K (replication factor) best
results.
- The `FindNode` command has been updated to handle errors and
unexpected states without panicking.

### Changed

- kad: Refactor FindNode query, keep K best results and add tests
([paritytech#114](paritytech/litep2p#114))

---------

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
TarekkMA pushed a commit to moonbeam-foundation/polkadot-sdk that referenced this issue Aug 2, 2024
## [0.5.0] - 2023-05-24

This is a small patch release that makes the `FindNode` command a bit
more robst:

- The `FindNode` command now retains the K (replication factor) best
results.
- The `FindNode` command has been updated to handle errors and
unexpected states without panicking.

### Changed

- kad: Refactor FindNode query, keep K best results and add tests
([paritytech#114](paritytech/litep2p#114))

---------

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
D3-involved Can be fixed by an expert coder with good knowledge of the codebase. I6-meta A specific issue for grouping tasks or bugs of a specific category.
Projects
Status: Open
Status: Backlog 🗒
Development

No branches or pull requests

3 participants