mirror of
https://etulab.univ-amu.fr/v18003685/pfe-blockchain.git
synced 2024-02-26 02:14:01 +01:00
ajout notes wormhole
This commit is contained in:
@ -67,48 +67,98 @@ Wormhole, le bridge de Solana, a été manipulé pour créditer 120k ETH comme a
|
|||||||
|
|
||||||
## Wormhole
|
## Wormhole
|
||||||
|
|
||||||
Token bridge entre Ethereum et Solana. (initialement)
|
### Nutshell
|
||||||
|
|
||||||
|
Protocole générique de passage de messages ("generic message passing protocol") qui connecte plusieurs chaînes (Ethereum, Solana, Binance Smart Chain, Polygon, Avalanche, Algorand, Fantom, Karura, Celo, Acala, Aptos and Arbitrum).
|
||||||
|
|
||||||
|
Wormhole émet des messages à partir d'une chaîne qui sont observés par un réseau de nœuds "Guardian" puis vérifiés. Après vérification, ce message est soumis à la chaîne cible pour traitement.
|
||||||
|
|
||||||
|
### VAA (verified action approval)
|
||||||
|
|
||||||
|
Primitive de messagerie de base de Wormhole, content une en-tête et un corps ("body").
|
||||||
|
|
||||||
```
|
```
|
||||||
struct WormholeMsg {
|
(header)
|
||||||
|
byte version (VAA Version)
|
||||||
|
u32 guardian_set_index (Indicates which guardian set is signing)
|
||||||
|
u8 len_signatures (Number of signatures stored)
|
||||||
|
[][66]byte signatures (Collection of ecdsa signatures)
|
||||||
|
|
||||||
uint8 version;
|
|
||||||
uint32 timestamp;
|
|
||||||
uint32 nonce;
|
|
||||||
uint16 emitterChainId;
|
|
||||||
bytes32 emitterAddress;
|
|
||||||
uint64 sequence;
|
|
||||||
uint8 consistencyLevel;
|
|
||||||
bytes payload;
|
|
||||||
uint32 guardianSetIndex;
|
|
||||||
Signature[] signatures;
|
|
||||||
bytes32 hash;
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
5 payloads :
|
```
|
||||||
|
(body)
|
||||||
|
u32 timestamp (Timestamp of the block where the source transaction occurred)
|
||||||
|
u32 nonce (A grouping number)
|
||||||
|
u16 emitter_chain (Wormhole ChainId of emitter contract)
|
||||||
|
[32]byte emitter_address (Emitter contract address, in Wormhole format)
|
||||||
|
u64 sequence (Strictly increasing sequence, tied to emitter address & chain)
|
||||||
|
u8 consistency_level (What finality level was reached before emitting this message)
|
||||||
|
[]byte payload (VAA message content)
|
||||||
|
```
|
||||||
|
|
||||||
|
### Portal payloads
|
||||||
|
|
||||||
|
Charges utiles spécifiques attachés à un VAA depuis une chaîne source pour indiquer à la chaîne cible comment traiter le message Wormhole après vérification.
|
||||||
|
|
||||||
|
5 charges utiles au total :
|
||||||
|
|
||||||
* Transfer (déclenche la libération de jetons verrouillés)
|
* Transfer (déclenche la libération de jetons verrouillés)
|
||||||
* TransferWithPayload (pareil que ci-dessus avec un payload supplémentaire spécifique au domaine)
|
* TransferWithPayload (pareil que ci-dessus avec un payload supplémentaire spécifique au domaine)
|
||||||
* AssetMeta (requis avant le premier transfert, atteste les metadatas de l'actif)
|
* AssetMeta (atteste les metadatas de l'actif)
|
||||||
* RegisterChain (enregistre le contrat bridge for une chaîne étrangère)
|
* RegisterChain (enregistre le contrat bridge pour une chaîne étrangère)
|
||||||
* UpgradeContract
|
* UpgradeContract
|
||||||
|
|
||||||
|
#### Transfer
|
||||||
|
|
||||||
|
Les jetons sont transférés d'une chaîne à l'autre à l'aide d'un mécanisme de verrouillage/monnayage ("lockup/mint") et de brûlage/déverrouillage ("burn/unlock").
|
||||||
|
|
||||||
|
Pour transférer des jetons de A à B, nous devons verrouiller les jetons sur A et les frapper sur B. Il est important de prouver que les jetons sur A sont verrouillés avant que la frappe puisse avoir lieu sur B. Pour faciliter ce processus, la chaîne A verrouille d'abord les jetons et émet un message indiquant que le verrouillage a été effectué.
|
||||||
|
|
||||||
|
"Chain B is agnostic as to how the token on the sending side were locked".
|
||||||
|
|
||||||
|
Le protocole se contente de relayer l'événement une fois qu'un nombre suffisant de gardiens en ont attesté l'existence.
|
||||||
|
|
||||||
```
|
```
|
||||||
PayloadID uint8 = 1
|
u8 payload_id = 1 Transfer
|
||||||
// Amount being transferred (big-endian uint256)
|
u256 amount Amount of tokens being transferred.
|
||||||
Amount uint256
|
u8[32] token_address Address on the origin chain.
|
||||||
// Address of the token. Left-zero-padded if shorter than 32 bytes
|
u16 token_chain Numeric ID for the origin chain.
|
||||||
TokenAddress bytes32
|
u8[32] to Address on the destination chain.
|
||||||
// Chain ID of the token
|
u16 to_chain Numeric ID for the destination chain.
|
||||||
TokenChain uint16
|
u256 fee Portion of amount paid to a relayer.
|
||||||
// Address of the recipient. Left-zero-padded if shorter than 32 bytes
|
|
||||||
To bytes32
|
|
||||||
// Chain ID of the recipient
|
|
||||||
ToChain uint16
|
|
||||||
// Amount of tokens (big-endian uint256) that the user is willing to pay as relayer fee. Must be <= Amount.
|
|
||||||
Fee uint256
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Asset
|
||||||
|
|
||||||
|
La chaîne A émet un message contenant des métadonnées sur une adresse, que la chaîne B peut stocker afin de connaître le nom, le symbole et la précision décimale de l'adresse d'un jeton.
|
||||||
|
|
||||||
|
Obligatoire avant de pouvoir effectuer un transfert !!
|
||||||
|
|
||||||
|
```
|
||||||
|
u8 payload_id = 2
|
||||||
|
[32]byte token_address
|
||||||
|
u16 token_chain
|
||||||
|
u8 decimals
|
||||||
|
[32]byte symbol
|
||||||
|
[32]byte name
|
||||||
|
```
|
||||||
|
|
||||||
|
### Relayer
|
||||||
|
|
||||||
|
"Un processus qui délivre un ou plusieurs VAA(s) à une destination"
|
||||||
|
|
||||||
|
* Trustless
|
||||||
|
* Sans privilèges
|
||||||
|
|
||||||
|
1) Effectuer une action sur la chaîne A
|
||||||
|
2) Récupérer le VAA résultant du "Guardian Network"
|
||||||
|
3) Effectuer une action sur la chaîne B en utilisant le VAA
|
||||||
|
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
|
||||||
## ERC 5164
|
## ERC 5164
|
||||||
|
|
||||||
Exécution cross-chain (14/06/2022)
|
Exécution cross-chain (14/06/2022)
|
||||||
@ -138,20 +188,20 @@ interface MessageDispatcher {
|
|||||||
```
|
```
|
||||||
|
|
||||||
Sources :
|
Sources :
|
||||||
* [Article 4 PFE](https://medium.com/coinmonks/cross-chain-bridge-vulnerability-summary-f16b7747f364)
|
|
||||||
* [DeFi Hacks Analysis - Root Cause](https://web3sec.notion.site/web3sec/ba459372dc434341b99ec92a932f98dc?v=7fceca7b3da74aa8a99b49c44a2a3916)
|
* [DeFi Hacks Analysis - Root Cause](https://web3sec.notion.site/web3sec/ba459372dc434341b99ec92a932f98dc?v=7fceca7b3da74aa8a99b49c44a2a3916)
|
||||||
* [Slowmist Hacked - Summary of blockchain attack events](https://hacked.slowmist.io/?c=Bridge)
|
* [Slowmist Hacked - Summary of blockchain attack events](https://hacked.slowmist.io/?c=Bridge)
|
||||||
|
* [Article 4 PFE](https://medium.com/coinmonks/cross-chain-bridge-vulnerability-summary-f16b7747f364)
|
||||||
* [Coinbase - Nomad bridge incident analysis](https://www.coinbase.com/blog/nomad-bridge-incident-analysis)
|
* [Coinbase - Nomad bridge incident analysis](https://www.coinbase.com/blog/nomad-bridge-incident-analysis)
|
||||||
* [Rekt - Le layer 2](https://rekt.news/fr/the-second-layer/)
|
* [Rekt - Le layer 2](https://rekt.news/fr/the-second-layer/)
|
||||||
* [Rekt - Wormhole](https://rekt.news/fr/wormhole-rekt/)
|
* [Rekt - Wormhole](https://rekt.news/fr/wormhole-rekt/)
|
||||||
* [Wormhole whitepaper](https://github.com/wormhole-foundation/wormhole/blob/main/whitepapers/0003_token_bridge.md)
|
* [Ethereum - Bridges](https://ethereum.org/fr/developers/docs/bridges/)
|
||||||
|
|
||||||
|
* [Wormhole 'whitepaper'](https://github.com/wormhole-foundation/wormhole/blob/main/whitepapers/0003_token_bridge.md)
|
||||||
|
* [Wormhole docs 1](https://docs.wormhole.com/wormhole/)
|
||||||
|
* [Wormhole docs 2](https://book.wormhole.com/)
|
||||||
|
* [Wormhole token bridge relayer example](https://github.com/wormhole-foundation/example-token-bridge-relayer)
|
||||||
|
|
||||||
* [ERC 5164, 6170](https://eips.ethereum.org/erc)
|
* [ERC 5164, 6170](https://eips.ethereum.org/erc)
|
||||||
* [ERC 5164 Thread](https://ethereum-magicians.org/t/eip-5164-cross-chain-execution/9658/13)
|
* [ERC 5164 Thread](https://ethereum-magicians.org/t/eip-5164-cross-chain-execution/9658/13)
|
||||||
* [ERC 5164 Implementation](https://github.com/pooltogether/ERC5164)
|
* [ERC 5164 Implementation](https://github.com/pooltogether/ERC5164)
|
||||||
|
|
||||||
A fouiller :
|
|
||||||
|
|
||||||
* [Ethereum - Bridges](https://ethereum.org/fr/developers/docs/bridges/)
|
|
||||||
* [Github - Blockchain bridge simplified](https://github.com/chainstack/blockchain-bridge-simplified)
|
|
||||||
* [Github - EVM Bridge](https://github.com/mineables/EVMBridge)
|
|
||||||
|
|
||||||
|
BIN
team_centralisé/wormhole_design.png
Normal file
BIN
team_centralisé/wormhole_design.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 463 KiB |
Reference in New Issue
Block a user