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

docs: seperate OPL and OPL sdk #982

Merged
merged 4 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/README.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ The part also covers other ParaTimes such as the non-confidential
]} />

[Oasis Sapphire]: dapp/sapphire/README.mdx
[Oasis Privacy Layer]: dapp/opl/README.md
[Oasis Privacy Layer]: dapp/opl/README.mdx
[Oasis Emerald]: dapp/emerald/README.mdx
[Oasis Cipher]: dapp/emerald/README.mdx

Expand Down
2 changes: 1 addition & 1 deletion docs/dapp/README.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ ParaTimes, you can also add privacy to your existing dApps running on other,
non-confidential chains, and only use Oasis as a *privacy service*.

The Oasis team prepared a rich cross-chain toolkit called the
[**Oasis Privacy Layer**](opl/README.md). It consists of solidity precompiles
[**Oasis Privacy Layer**](opl/README.mdx). It consists of solidity precompiles
integrating bridges and wrapping the OpenZeppelin ERC2771 contract on top of
Sapphire, demonstrates best practices for writing confidential smart contracts
and working examples for you to explore and extend.
Expand Down
11 changes: 8 additions & 3 deletions docs/dapp/diagrams/opl-contract-flow.mmd
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
sequenceDiagram
User ->> Home Contract: Transaction
Home Contract -->> SGN: SGN Watches Events
participant User
participant Home as Home Contract<br/>(Host)
participant SGN
participant Executor
participant Sapphire as Sapphire Contract<br/>(Enclave)
User ->> Home: Transaction
Home -->> SGN: SGN Watches Events
SGN -->> Executor: Waits for SGN Approval
Executor ->> Sapphire Contract: Submit Proof Tx
Executor ->> Sapphire: Submit Proof Tx
2 changes: 1 addition & 1 deletion docs/dapp/diagrams/opl-contract-flow.mmd.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/dapp/images/opl/celer-architecture.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/dapp/images/opl/celer-e2e.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
162 changes: 0 additions & 162 deletions docs/dapp/opl/README.md

This file was deleted.

76 changes: 76 additions & 0 deletions docs/dapp/opl/README.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
---
description: Integrating privacy into dApps on other blockchains
---

import DocCard from '@theme/DocCard';
import DocCardList from '@theme/DocCardList';
import {findSidebarItem} from '@site/src/sidebarUtils';

# Oasis Privacy Layer (OPL)

The Oasis Privacy Layer (OPL) is a powerful solution that enables developers
to integrate privacy features into their decentralized applications (dApps)
across multiple EVM-compatible networks.

- **Privacy-First**: OPL leverages the [Sapphire]'s privacy features to ensure
rube-de marked this conversation as resolved.
Show resolved Hide resolved
that contract data and computation remains confidential.
- **Cross-Chain Compatibility**: OPL is compatible with multiple blockchains
through message bridging protocols, making it easy to integrate privacy
regardless of the chain your dApp is built on.

For more information about OPL and to catch the latest news, please visit the
[official OPL page].

[official OPL page]: https://oasisprotocol.org/opl
[Sapphire]: ../sapphire/README.mdx

## How OPL Works

The OPL is made possible through message bridges, which enable secure
communication between OPL-enabled contracts on Sapphire and smart contracts on
other chains. This allows dApps to access privacy-preserving capabilities while
keeping their main logic on their primary chain.

![Oasis Privacy Layer diagram](../images/opl/privacy-layer-diagram.png)

:::info

For how to use use signed messages with the GSN to trigger a cross-chain
messages, please visit our [Gasless Transactions chapter].

:::

[Gasless Transactions chapter]: ../sapphire/gasless.md

## Message Bridges

You can integrate message bridges into your dApps using one of these three
methods:

- **[OPL SDK]**: A wrapper provided by the Oasis Protocol that simplifies the
integration of message bridging with Oasis’s privacy features.
- **[Celer Inter-Chain Messaging (IM)][celer]**: A generalized message bridging solution
by Celer, which lets you build more complex solutions.
- **[Router Protocol CrossTalk][router]**: An extensible cross-chain framework that
enables seamless state transitions across multiple chains.

### Comparison

| Protocol | Validator Network | Relayer | Fees |
| --------------- | ----------------- | ------ | ------ |
| **[OPL SDK]** | SGN (Celer) | Executor (self-hosted or hosted service by Celer) | SGN Fee: Paid via `msg.value` <br/> Executor Fee: Charged externally (Free on testnet) |
| **[Celer IM][celer]** | SGN (Celer) | Executor (self-hosted or hosted service by Celer) | SGN Fee: Paid via `msg.value` <br/> Executor Fee: Charged externally (Free on testnet) |
| **[Router Protocol][router]** | Orchestrators (Router Chain) | Relayer (run by 3rd party) | Paid by the approved feepayer on the Routerchain |

## Examples

<DocCardList items={[
findSidebarItem('/dapp/opl/secret-ballot-example/'),
findSidebarItem('/dapp/opl/opl-sdk/ping-example'),
findSidebarItem('/dapp/opl/celer/ping-example'),
findSidebarItem('/dapp/opl/router-protocol/pingpong-example'),
]} />

[OPL SDK]: ./opl-sdk/README.md
[celer]: ./celer/README.md
[router]: ./router-protocol/README.md
107 changes: 107 additions & 0 deletions docs/dapp/opl/celer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
---
description: A message bridge by Celer
---

# Celer Inter-Chain Messaging (IM)

**Celer Inter-Chain Messaging (IM)** is a message passing protocol that
facilitates the seamless transfer of any type of generic message, including
function calls, across multiple blockchains via a single source-chain
transaction. Celer IM currently supports message passing between Oasis Sapphire
and all other IM-supported chains. The message-passing support enables
developers to build entirely new privacy-centric dApps or add confidentiality
to existing dApps on popular EVM networks using Sapphire as a privacy layer.

**Celer IM** offers two design patterns:

- Cross-chain logic execution without fund transfer
- Cross-chain logic execution with accompanying fund transfer

This documentation focuses on cross-chain logic execution **without** fund
transfer. For information on using Celer IM with fund transfer, please refer
to the [Celer IM documentation].

[Celer IM documentation]: https://im-docs.celer.network/

## Architecture

![Celer IM Architecture](../../images/opl/celer-e2e.png)
*Architecture diagram for Celer IM[^1]*

[^1]: The Celer IM architecture diagram is courtesy of [Celer documentation][celer-architecture].

[celer-architecture]: https://im-docs.celer.network/developer/architecture-walkthrough/end-to-end-workflow

Celer IM’s architecture is composed of several core components that work
together to facilitate secure and reliable cross-chain messaging:

- **MessageBus**: The primary component managing message transmission between
source and destination blockchains. It ensures proper formatting and routing
of messages through the Celer network.
- **State Guardian Network (SGN)**: A decentralized network of validators that
manage the state of cross-chain messages. SGN validators sign off on messages
and coordinate their secure delivery, providing security and availability for
cross-chain interactions.
- **[Executor](#executor)**: An off-chain component that listens to the SGN for
validated messages ready for execution on the destination chain. Once a
message is verified, the Executor sends transactions to the MessageBus on the
destination chain, triggering the execution of the specified logic.

## Executor

The [Executor][Message Executor] is a crucial part of the Celer IM framework.
It performs two main functions:

- Monitors the Celer State Guardian Network (SGN) for messages ready to be
submitted (with sufficient validator signatures).
- Submits message execution transactions to the MessageBus contract on the
destination chain.

It is necessary a [Message Executor] runs for you dapp. To set up an executor,
you have two options

- Follow the [documentation] to set up your own executor.
- Fill out this [form][celer-form] for Celer to set up a hosted executor
service for you.

For Hackathon or Grant participants, we recommend filling out the
[relay request form][celer-form] to use the shared Message Executor.

In most cases, Celer advises dApp developers to use the shared executor
services provided by the Celer Network team to avoid server configuration and
operation concerns.

:::info

Oasis is running an executor for the Sapphire Testnet, which is okay to rely on
for a test, for a faster execution it's recommended to run your own or use the
hosted service.

:::

[Message Executor]: https://im-docs.celer.network/developer/development-guide/message-executor
[documentation]: https://im-docs.celer.network/developer/development-guide/message-executor/integration-guide
[celer-form]:https://form.typeform.com/to/RsiUR9Xz

## Fees

The cross-chain messaging process involves fees paid to two parties:

- **SGN Fee**: Paid as `msg.value` to the *MessageBus* contract by
the entity calling `sendMessge`.
- **Executor Fee**: Charged by the Executor for submitting execute message
transactions.

## Monitoring

The Celer IM Scan API can be used to retrieve status and message details by
providing the globally unique transaction ID from the chain which originated the
message.

https://api.celerscan.com/scan/searchByTxHash?tx=0x...

For details of the response format, see the [Query IM Tx Status] page of the
Celer-IM documentation. Using this API lets you to check if messages have been
delivered.

[Query IM Tx Status]: https://im-docs.celer.network/developer/development-guide/query-im-tx-status
Loading