|
|
3 жил өмнө | |
|---|---|---|
| .. | ||
| sandbox-algorand | 3 жил өмнө | |
| teal | 3 жил өмнө | |
| test | 3 жил өмнө | |
| .gitignore | 3 жил өмнө | |
| Dockerfile | 3 жил өмнө | |
| MEMORY.md | 3 жил өмнө | |
| Makefile | 3 жил өмнө | |
| NOTES.md | 3 жил өмнө | |
| Pipfile | 3 жил өмнө | |
| Pipfile.lock | 3 жил өмнө | |
| README.md | 3 жил өмнө | |
| TmplSig.py | 3 жил өмнө | |
| admin.py | 3 жил өмнө | |
| deploy.sh | 3 жил өмнө | |
| gentest.py | 3 жил өмнө | |
| globals.py | 3 жил өмнө | |
| inlineasm.py | 3 жил өмнө | |
| local_blob.py | 3 жил өмнө | |
| package-lock.json | 3 жил өмнө | |
| package.json | 3 жил өмнө | |
| requirements.txt | 3 жил өмнө | |
| runPythonUnitTests.sh | 3 жил өмнө | |
| sandbox | 3 жил өмнө | |
| test_contract.py | 3 жил өмнө | |
| testnet-update | 3 жил өмнө | |
| token_bridge.py | 3 жил өмнө | |
| vaa_verify.py | 3 жил өмнө | |
| wormhole_core.py | 3 жил өмнө | |
This directory contains the components needed to support full Wormhole functionality under the Algorand blockchain platform.
This system is comprised of the following main components:
Core contract (wormhole_core.py): Algorand stateful contract with entrypoints for publishing messages (VAAs), verification of VAA signatures, and triggering of governance chores. This will be referred as CoreContract in this document.
Token bridge contract (token_bridge.py): Algorand stateful contract supporting cross-chain bridging, exposing entrypoints for exchanging attestations, native tokens and ASAs, and triggering of governance. This will be referred as TokenBridge in this document.
VAA verification stateless program (vaa_verify.py): Stateless program for verifying the signatures of a Wormhole VAA payload against the set of active guardian public keys. This will be referred as VaaVerify in this document.
Dynamic storage stateless program (TmplSig.py): A stateless program that is bound to the main core and token bridge contracts to provide dynamic storage spaces addressable as a raw blob of bytes. See local_blob.py. This will be referred as TmplSig in this document.
Helper utilities and code include support PyTEAL code, deployment tools and tests.
This stateless program code is parameterized with several values that give different output address. The stateless code will check for several transaction parameters accordingly.
| Text | Replaced by |
|---|---|
TMPL_ADDR_IDX |
Where storage starts interpreting the space as a raw array of bytes |
TMPL_EMITTER_ID |
Concatenation of chain Id + emitter Id in VAAs to be processed, or a hardcoded string identifying the type of information stored e.g guardian utf8 string stored in hex. |
TMPL_APP_ID |
Application Id of CoreContract, TokenBridge, etc that is specified as the opt-in target transaction |
TMPL_APP_ADDRESS |
Escrow address of the stateful contract specified in APP_ID. Used for rekey target in the transaction |
seq_addr) for storing verified sequence number bits based on chainId,emitter,int(vaa.sequence / MAX_BITS) where MAX_BITS = 15240. This allows the system to reject duplicated VAAs for the last 2K sequence numbers.guardian_addr and new_guardian_addr) for storing total guardian count , the guardian public keys and guardian set expiration time.Briefly, the semantics of the transaction when TmplSig is "attached" to a stateful app is:
TMPL_APP_ID for the app to use LogicSig account local storageNOTE: A more detailed overview of TmplSig can be found in MEMORY.md.
The initialization call needs a governance VAA to be passed in, typically to setup initial guardian list. The init call will:
vphash global state keybooted global state to 1See below on how governance VAAs are processed, and how duplicate detection technique is used.
The publishMessage call will retrieve the current sequence number from related TmplSig local store, increment in by 1, store the new sequence number and emit a Log message which can be picked by Wormhole network for subsequently creating a guardian-signed VAA message.
Governance messages can carry requests for:
validUpdateApproveHash). The upgrade process itself is triggered with the update action, where the clear and approval program hashes are checked against what the governance VAA carried. If they differ, an assertion is thrown and the update call is aborted. A successful call writes an onchain Log with the new hashes and allows the update process to go on.A governance request packed in a VAA must be verified by a verifyVaa call in the transaction group.
The VAA verify call will work by design only in a transaction group structured as:
| TX | args | accounts | sender |
|---|---|---|---|
| verifySigs | [sigs0..n, keyset0..n, digest] | seq_addr, guardian_addr | vaa_verify_stateless |
| verifySigs | ... | seq_addr, guardian_addr | vaa_verify_stateless |
| verifyVAA | vaa | seq_addr, guardian_addr | foundation |
Keep in mind that depending on the number of signatures to verify there can be one or several verifySigs calls working in tandem with the VaaVerify stateless program. This depends on how many signatures we can verify on a single TX. At time of this writing, considering the opcode budget limitation of AVM 1.1, a total of nine (9) signatures can be verified at once, so for the current 19 guardians three verifySigs calls would be needed for verifying signatures 0..8, 9..17, 18.
A successful call must:
The vaaVerify call does allow nop (dummy) TX in the group to maximize opcode budgets and/or storage capacity. After the verifyVAA call, a client can issue more transactions with the fact that the VAA was verified.
To detect duplicate VAA sequence numbers the following technique is used:
LocalBlob class.TMPL_ADDR_IDX to formula vaa_sequence_number / 15240, we have designated storage for marking VAAs in consecutive 16k-bit blocks.