Skip to content
This repository has been archived by the owner on Oct 31, 2024. It is now read-only.

Commit

Permalink
feat: add Create your messaging protocol content (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastiendan authored Jan 19, 2024
1 parent 3ed7995 commit 3936d8e
Show file tree
Hide file tree
Showing 7 changed files with 369 additions and 79 deletions.
87 changes: 50 additions & 37 deletions config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const config: Config = {
appId: 'S36OISFKTX',
apiKey: 'fc77ad501873a0a81b4c39e02a4aaaac',
indexName: 'crawler_Toposware docs platform (new)',
placeholder: 'Search documentation'
placeholder: 'Search documentation',
},
googleSiteVerification: 'ewK_x9p9N-cr_rA0dKgdo6YGqZGgnRcBVn2bZeaZQ_o',
navigation: [
Expand All @@ -27,123 +27,136 @@ const config: Config = {
content: [
{
label: 'Chapter overview: What is Topos?',
path: '/content/module-1'
path: '/content/module-1',
},
{
label: 'Introduction',
path: '/content/module-1/1-introduction.html'
path: '/content/module-1/1-introduction.html',
},
{
label: 'Why Topos?',
path: '/content/module-1/2-why-topos.html'
path: '/content/module-1/2-why-topos.html',
},
{
label: 'Use cases',
path: '/content/module-1/3-use-cases.html'
path: '/content/module-1/3-use-cases.html',
},
{
label: 'Topos protocol',
path: '/content/module-1/4-protocol.html'
path: '/content/module-1/4-protocol.html',
},
{
label: 'Cross-subnet messages',
path: '/content/module-1/5-cross-subnet.html'
path: '/content/module-1/5-cross-subnet.html',
},
{
label: 'Messaging protocol',
path: '/content/module-1/6-messaging-protocol.html'
}
]
path: '/content/module-1/6-messaging-protocol.html',
},
],
},
{
label: 'First steps with Topos',
content: [
{
label: 'Chapter overview: First steps with Topos',
path: '/content/module-2'
path: '/content/module-2',
},
{
label: 'ERC20 Messaging',
path: '/content/module-2/1-ERC20-Messaging.html'
path: '/content/module-2/1-ERC20-Messaging.html',
},
{
label: 'Topos Explorer',
path: '/content/module-2/2-explorer.html'
path: '/content/module-2/2-explorer.html',
},
{
label: 'Topos Playground',
path: '/content/module-2/3-topos-playground.html'
path: '/content/module-2/3-topos-playground.html',
},
{
label: 'Topos CLI',
path: '/content/module-2/4-cli.html'
path: '/content/module-2/4-cli.html',
},
{
label: 'Topos Testnet',
path: '/content/module-2/5-testnet.html'
}
]
path: '/content/module-2/5-testnet.html',
},
],
},
{
label: 'Next steps',
content: [
{
label: 'Chapter overview: Next steps',
path: '/content/module-3',
},
{
label: 'Create Your Messaging Protocol',
path: '/content/module-3/1-create-your-messaging-protocol.html',
},
],
},
{
label: 'Network',
content: [
{
label: 'Faucet',
path: 'https://faucet.testnet-1.topos.technology/'
path: 'https://faucet.testnet-1.topos.technology/',
},
{
label: 'Topos Blockscout',
path: 'https://topos.blockscout.testnet-1.topos.technology/'
path: 'https://topos.blockscout.testnet-1.topos.technology/',
},
{
label: 'Incal Blockscout',
path: 'https://incal.blockscout.testnet-1.topos.technology/'
path: 'https://incal.blockscout.testnet-1.topos.technology/',
},
{
label: 'Explorer',
path: 'https://explorer.testnet-1.topos.technology/'
path: 'https://explorer.testnet-1.topos.technology/',
},
{
label: 'Important Addresses',
path: '/content/topos-reference/network.html'
}
]
path: '/content/topos-reference/network.html',
},
],
},
{
label: 'Topos Reference',
content: [
{
label: 'FAQ',
path: '/content/topos-reference/faq.html'
path: '/content/topos-reference/faq.html',
},
{
label: 'Weak Causal Probabilistic Reliable Broadcast',
path: '/content/topos-reference/wcprb.html'
path: '/content/topos-reference/wcprb.html',
},
{
label: 'Glossary',
path: '/content/glossary.html'
}
]
path: '/content/glossary.html',
},
],
},
{
label: 'Legal',
content: [
{
label: 'Privacy policy',
path: '/legal/privacy-policy.html'
}
]
}
path: '/legal/privacy-policy.html',
},
],
},
],
footerLinks: [
{
label: 'Privacy Policy',
path: '/legal/privacy-policy.html'
}
path: '/legal/privacy-policy.html',
},
],
storage: {
cookieConsentKey: 'cookieConsent'
cookieConsentKey: 'cookieConsent',
},
};

Expand Down
10 changes: 3 additions & 7 deletions content/module-1/6-messaging-protocol.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,16 @@ The Topos protocol provides for the creation, verification and delivery of certi

The developers of dApps and cross-subnet messaging flows can leverage these certificates to design **secure messaging protocols**. By storing relevant certificates on-chain, it is possible to benefit from their security guarantees when handling cross-subnet messages.

To demonstrate best practice and help bootstrap subnet administrators, Topos has created a series of smart contracts:
To demonstrate best practices and help bootstrap subnet administrators, Topos has created a series of smart contracts:

1. The **ToposCore** smart contract can be used to store certificates on-chain. Although not compulsory, it makes sense for a subnet to have a single instance of such a certificate-storing smart contract.
2. The **ToposMessaging** smart contract makes use of ToposCore. It has functions to verify proofs of inclusion and to mark completed messages as used, thereby preventing replay. It is not meant to be deployed directly, but instead to be used as an inherited smart contract for the messaging protocol proper.
2. The **ToposMessaging** smart contract gathers features that are core to messaging protocols. It has functions to verify proofs of inclusion and to mark completed messages as used, thereby preventing replay. To ease the development of new messaging protocols, these features can be had for free by creating a messaging protocol smart contract that inherits ToposMessaging.
3. **ERC20Messaging** is an example of a messaging protocol smart contract that implements the semantics of a cross-subnet ERC-20 token transfer. It inherits from ToposMessaging. With ERC20Messaging, it is possible to deploy new ERC-20 token smart contracts, and to use those to send and receive cross-subnet token transfers. With this contract, a cross-subnet token transfer was chosen to consist of a _burn_ on the source subnet and a _mint_ on the target subnet.

The **delivery** of cross-subnet messages is not part of the Topos protocol, but instead is left to the administrators of subnets. Here again, Topos has created an example of a delivery mechanism, called the **executor service**, which is compatible with ToposCore and ERC20Messaging.

<HighlightBox type="tip">

To develop intuition about how this works, consider this non-exhaustive description of the process and the concerns that are addressed by the protocol. It demonstrates a cross-subnet ERC-20 transfer implemented via ERC20Messaging and the executor service.

</HighlightBox>

1. On the source subnet:
* The user **allows** the ERC20Messaging contract instance to be a spender (and therefore burner) of a number of its tokens.
* The user sends a transaction that is a call to the **`sendToken`** function of ERC20Messaging, **specifying** a target subnet ID where the same amount of tokens are to be minted, along with the amount and a recipient.
Expand All @@ -45,7 +41,7 @@ To develop intuition about how this works, consider this non-exhaustive descript
4. On the target subnet:
* The sequencer **hears about** the relevant certificate.
* The sequencer **confirms** that the certificate mentions its subnet ID as a target and **records** the certificate in ToposCore (if it is found acceptable).
* The executor service **finds** that the certificate is already in ToposCore. Or the executor service **detects** the `CertStored` event from ToposCore with the receipts root matching that of the original transaction's state transition.
* The executor service queries ToposCore for the certificate (passing the receipts root matching that of the original transaction's state transition).
* The executor service sends a transaction that is a call to the **`execute`** function of the ERC20Messaging contract (inherited from ToposMessaging), including the previously collected receipt and its Merkle proof of inclusion.
* The ERC20Messaging contract **verifies** the inclusion proof with the stored certificate.
* Upon successful verification, the ERC20Messaging contract **is confident** that the original transaction and its receipt **are valid**.
Expand Down
Loading

0 comments on commit 3936d8e

Please sign in to comment.