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

Ilariae/core contracts #8

Merged
merged 64 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
767993d
messaging section setup
Jul 30, 2024
8168e05
core contracts page setup
Jul 30, 2024
1a886f3
core contracts and bridges content
Jul 30, 2024
b3ffb13
meta descriptions
Jul 30, 2024
06c3b57
sync with main
Aug 1, 2024
9062118
sync with main
Aug 1, 2024
41b82a1
cc grammarly check and overview partial content
Aug 1, 2024
309c35d
bridge grammarly check
Aug 1, 2024
1039a80
Merge branch 'ilariae/core-contracts' of https://github.com/wormhole-…
Aug 1, 2024
f1133cc
minor fix
Aug 1, 2024
0e64abf
minor fix
Aug 1, 2024
ff878ba
overview update
Aug 1, 2024
c3bdc36
sync main
Aug 5, 2024
043ca3a
sync main
Aug 5, 2024
6100604
meta description
Aug 6, 2024
fab1565
sync main
Aug 6, 2024
4979b68
sync with main and add meta description
Aug 6, 2024
f7e8218
Update learn/messaging/core-contracts.md
ilariae Aug 6, 2024
ec08709
Update learn/messaging/core-contracts.md
ilariae Aug 6, 2024
4148b17
Update learn/messaging/overview.md
ilariae Aug 6, 2024
baaed16
Merge branch 'ilariae/VAAs' of https://github.com/wormhole-foundation…
Aug 7, 2024
1671845
Update learn/messaging/core-contracts.md
ilariae Aug 8, 2024
b6353a2
Update learn/messaging/core-contracts.md
ilariae Aug 8, 2024
de63190
Update learn/messaging/core-contracts.md
ilariae Aug 8, 2024
39d3492
Update learn/messaging/core-contracts.md
ilariae Aug 8, 2024
35a3aa6
Update learn/messaging/core-contracts.md
ilariae Aug 8, 2024
3dfe2c2
Update learn/messaging/core-contracts.md
ilariae Aug 8, 2024
8695c95
Update learn/messaging/core-contracts.md
ilariae Aug 8, 2024
0ca6a67
Update learn/messaging/core-contracts.md
ilariae Aug 8, 2024
29369cb
Update learn/messaging/core-contracts.md
ilariae Aug 8, 2024
9e0bd80
Update learn/messaging/core-contracts.md
ilariae Aug 8, 2024
4ed22c0
Update learn/messaging/core-contracts.md
ilariae Aug 8, 2024
29a3240
Update learn/messaging/core-contracts.md
ilariae Aug 8, 2024
92c1da1
Update learn/messaging/core-contracts.md
ilariae Aug 8, 2024
0b173e7
Update learn/messaging/core-contracts.md
ilariae Aug 8, 2024
821eca0
Update learn/messaging/core-contracts.md
ilariae Aug 8, 2024
baa6c0d
Update learn/messaging/core-contracts.md
ilariae Aug 8, 2024
c588664
Update learn/messaging/core-contracts.md
ilariae Aug 8, 2024
ec4e848
Update learn/messaging/core-contracts.md
ilariae Aug 8, 2024
407b0bc
Update learn/messaging/core-contracts.md
ilariae Aug 8, 2024
a56c0eb
Update learn/messaging/core-contracts.md
ilariae Aug 8, 2024
5a88302
Update learn/messaging/core-contracts.md
ilariae Aug 8, 2024
14583e8
Update learn/messaging/core-contracts.md
ilariae Aug 8, 2024
dce18ff
Update learn/messaging/core-contracts.md
ilariae Aug 8, 2024
d2832a9
Update learn/messaging/overview.md
ilariae Aug 8, 2024
06b8fe2
Merge branch 'ilariae/VAAs' of https://github.com/wormhole-foundation…
Aug 8, 2024
73da350
Merge branch 'main' of https://github.com/wormhole-foundation/wormhol…
Aug 8, 2024
73e8cba
Update learn/messaging/core-contracts.md
ilariae Aug 9, 2024
a6ae993
Update learn/messaging/core-contracts.md
ilariae Aug 9, 2024
6d14294
Update learn/messaging/core-contracts.md
ilariae Aug 9, 2024
477a7f8
Update learn/messaging/core-contracts.md
ilariae Aug 9, 2024
e78b093
Update learn/messaging/core-contracts.md
ilariae Aug 9, 2024
5bee745
Update learn/messaging/core-contracts.md
ilariae Aug 9, 2024
93cb0bb
Update learn/messaging/core-contracts.md
ilariae Aug 9, 2024
77b97c8
Update learn/messaging/core-contracts.md
ilariae Aug 9, 2024
6527e8e
Update learn/messaging/core-contracts.md
ilariae Aug 9, 2024
c662c93
Update learn/messaging/core-contracts.md
ilariae Aug 9, 2024
d9b6bfc
Update learn/messaging/overview.md
ilariae Aug 9, 2024
0e8b55f
Update learn/messaging/overview.md
ilariae Aug 9, 2024
b9cf7e3
feedback fixes
Aug 9, 2024
fbd0bda
renaming token bridge page
Aug 9, 2024
340d79f
pulled complete overview from messaging branch
Aug 9, 2024
ea527ed
Update learn/messaging/core-contracts.md
ilariae Aug 12, 2024
638b304
link fixes
Aug 12, 2024
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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
parseAndVerifyVAA(byte[] VAA)
5 changes: 5 additions & 0 deletions .snippets/code/learn/messaging/core-contracts/sending.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
publishMessage(
int nonce,
byte[] payload,
int consistencyLevel
) returns int sequenceNumber
1 change: 1 addition & 0 deletions learn/.pages
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ nav:
- 'Security': 'security.md'
- 'Architecture Overview': 'architecture.md'
- infrastructure
- messaging
6 changes: 6 additions & 0 deletions learn/messaging/.pages
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
title: Messaging
nav:
- index.md
- 'Overview': 'overview.md'
- 'Core Contracts': 'core-contracts.md'
- 'Token and NFT Bridge': 'token-nft-bridge.md'
75 changes: 75 additions & 0 deletions learn/messaging/core-contracts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
---
title: Core Contracts
description: Discover Wormhole's Core Contracts, enabling cross-chain communication with message sending, receiving, and multicast features for efficient synchronization.
---

# Core Contracts

The Core Contracts are the mechanism by which all Wormhole messages are emitted. All cross-chain applications either interact directly with the Core Contract or interact with another contract that does. There is one Core Contract on each blockchain in the ecosystem, which is the contract which the Guardians are required to observe. The Core Contract is the contract that ultimately emits the messages the [Guardians](/learn/infrastructure/guardians/){target=\_blank} pick up as an [Observation](#){target=\_blank}.

In general, Core Contracts are simple and can be broken down to a sending and receiving side, which will be defined next.

## Sending

Currently, there are no fees to publish a message (with the exception of publishing on Solana), but this is not guaranteed to always be the case.

The implementation strategy for `publishMessage` differs by chain. However, the general strategy consists of the Core Contract posting the `emitterAddress` (the contract which called `publishMessage`), `sequenceNumber`, and `consistencyLevel` into the blockchain logs. Once the desired `consistencyLevel` has been reached and the message passes all of the Guardians' optional checks, the Guardian Network will produce the requested Verified Action Approvals [VAAs].

The method signature for publishing messages:

```js
--8<-- 'code/learn/messaging/core-contracts/sending.js'
```

#### Parameters

**payload**

The content of the emitted message is an arbitrary byte array. Due to the constraints of individual blockchains, it may be capped to a certain maximum length.

**consistencyLevel**

!!! note
Some advanced integrators may want to get messages before finality, which is where the `consistency_level` field offers chain-specific flexibility.

The `consistency_level` can be considered as a numeric `enum` data type where the value is treated differently for different chains.

It describes the level of finality to reach before the Guardians will observe and attest the emitted event. This is a defense against reorgs and rollbacks since a transaction, once considered `final`, is guaranteed not to have the state changes it caused be rolled back.

Different chains use different consensus mechanisms, so there are different finality assumptions with each one, see the options for finality in the [Environments](#){target=\_blank} pages. <!-- link to blockchain platforms -->

**nonce**

A free integer field that can be used however the developer would like. Note that a different `nonce` will result in a different digest.

#### Returns

**sequenceNumber**

A unique number that increments for every message for a given emitter (and implicitly chain). This combined with the emitter address and emitter chain ID allows the VAA for this message to be queried from the [APIs](#){target=\_blank}.

## Receiving

The method signature for receiving messages, encoded as a VAA:

```js
--8<-- 'code/learn/messaging/core-contracts/receiving.js'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this really be parseAndVerifyVM? I'm not seeing anything related to parseAndVerifyVAA when I look through GitHub 🤔

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in which repo did you find the parseAndVerifyVM?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just couldn't find anything at all when searching for parseAndVerifyVAA, but I saw that, it could be totally unrelated. I didn't really dig into it

```

When passed a VAA, this function will either return the payload and associated metadata for the VAA or throw an exception. An exception should only ever be thrown if the VAA fails signature verification, indicating that the VAA is invalid or inauthentic in some form.

!!! note
A developer should take care to make sure this method is called during the execution of a transaction where a VAA is passed to ensure the signatures are checked and verified.

## Multicast

Please notice that there is no destination address or chain in these functions.

VAAs simply attest that "this contract on this chain said this thing." Therefore, VAAs are multicast by default and will be verified as authentic on any chain they are brought to.

This multicast-by-default model is integral to the design. Having this multicast capacity makes it easy to synchronize state across the entire ecosystem, because a single blockchain can make its data available to every chain in a single action with low latency. This reduces the complexity of the n^2 problems encountered by routing data to a large number of blockchains.

This does not mean an application _cannot_ specify a destination address or chain. For example, the Token Bridge and Standard Relayer contracts require that some destination details be passed and verified on the destination chain.

Because the VAA creation is separate from relaying, there is no _additional_ cost to the multicast model when a single chain is being targeted. If the data isn't needed on a certain blockchain, don't relay it there, and it won't cost anything.

4 changes: 4 additions & 0 deletions learn/messaging/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
title: TODO
description: TODO
---
26 changes: 26 additions & 0 deletions learn/messaging/overview.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
title: Overview
description: Discover Wormhole's Messaging features, including cross-chain communication, token and NFT bridges, and the Circle Bridge integration.
---

# Messaging Overview

The Messaging section covers various aspects and services related to communication protocols and systems within the Wormhole platform. Each subsection provides detailed information on specific components, contracts, and bridges used for messaging and data transfer. Below is a brief overview of each subsection.

## Core Contracts

The Core Contracts form the backbone of Wormhole's cross-chain communication system, allowing for the emission and receipt of messages across different blockchains. Each blockchain in the ecosystem has its own Core Contract, which Guardians observe to ensure the integrity and synchronization of data. These contracts handle message sending, receiving, and multicast, providing a seamless mechanism for inter-chain communication without additional costs.

## NTT (Native Token Transfers)
_A description will be added here._

## Token and NFT Bridge

The Token and NFT Bridges facilitate cross-chain transfers of both fungible tokens and non-fungible tokens (NFTs). Utilizing a lock and mint mechanism, the bridge ensures secure and efficient asset movement between blockchains. The Token Bridge allows for token transfers with specific receiver details, while the NFT Bridge handles the transfer of unique digital assets with specialized rules for creating wrapped versions on the destination chain.

## CCTP and Circle Bridge

The CCTP and Circle Bridge support fast and cost-effective native USDC transfers across blockchains using Circle's Cross Chain Transfer Protocol (CCTP). While distinct from Wormhole, this protocol is enhanced by Wormhole's features such as automated relaying, gas payment on the destination chain, and native gas dropoff, making it more user-friendly. The integration can be achieved through the Wormhole Connect Widget or the Connect SDK, providing a seamless experience for developers and users.

## Gateway
_A description will be added here._
21 changes: 21 additions & 0 deletions learn/messaging/token-nft-bridge.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
title: Token and NFT Bridge
description: Learn about Wormhole's Token and NFT Bridge for cross-chain transfers using lock and mint mechanisms, ensuring secure and efficient asset movement.
---

# Token and NFT Bridge

## Token Bridge

!!! note
Before a token transfer can be made, the token being transferred must exist as a wrapped asset on the target chain. This is done by [Attesting](#){target=\_blank} the token details on the target chain. <!-- link to VAAs -->

The Token Bridge contract allows token transfers between blockchains through a lock and mint mechanism, using the [Core Contract](/learn/messaging/core-contracts/){target=\_blank} with a specific [payload](#){target=\_blank} to pass information about the transfer. <!--payload links to VAAs page payloads -->

The Token Bridge also supports sending tokens with some additional data in the form of arbitrary byte payload attached to the token transfer. This type of transfer is referred to as a [Contract Controlled Transfer](#){target=\_blank}. <!-- links to VAAs page token + msg -->

While the [Core Contract](/learn/messaging/core-contracts/){target=\_blank} has no specific receiver by default, transfers sent through the token bridge do have a specific receiver chain and address to ensure the tokens are minted to the expected recipient.

## NFT Bridge

The NFT Bridge functions similarly to the Token Bridge but with special rules for what may be transferred and how the wrapped version is created on the destination chain.
Loading