Přeskočit na obsah
Navigace dokumentace133
Dokumentace133 dokumentů
Základy17
Start5
Architektura4
Ekonomika & token4
Právní1
Další3
Archiv (starší verze)4
Další4
Knihy36
Ekam Deeksha35
Kvantová revoluce1
TerraNova29
Kompas a scéna5
Kapitoly L1–L611
Světy L513
Whitepaper47
Aktuální6
3.3 archiv1
3.1–3.2 archiv9
Whitepaper 202515
2.9.x2
2.8.514
Na této stránce
  1. 🏗️ Architecture Overview
  2. 🔗 Supported Chains
  3. 🔄 Transfer Flow
  4. Outbound: ZION L1 → External Chain
  5. Inbound: External Chain → ZION L1
  6. 💰 Fee Model
  7. Fee Distribution
  8. 🔒 Security Model
  9. 1. Validator Multisig (3-of-5)
  10. 2. Source Chain Finality
  11. 3. Timelock for Large Amounts
  12. 4. Daily Limits
  13. 5. Replay Protection
  14. 6. Emergency Pause
  15. 🔢 Decimal Conversion Table
  16. 📁 Crate Structure
  17. 🆚 WARP vs L2 Bridge
  18. 📅 Implementation Roadmap
  19. 🦀 Solana Signing Implementation (Phase 5)
  20. Overview
  21. Module: solanasigner.rs
  22. Transaction Building (legacy format, no SDK)
  23. Environment Variables
  24. 🔴 Tron Signing Implementation (Phase 6)
  25. Overview
  26. Module: tronsigner.rs
  27. Transaction Flow
  28. Address Derivation
  29. Environment Variables
  30. 🔏 EVM Signing Implementation (Phase 2.5)
  31. Overview
  32. Module: evmsigner.rs
  33. EIP-155 Signing Flow
  34. ABI Encoding for bridgeMint(address, uint256, bytes32)
  35. Environment Variables
  36. Supported Chains & Chain IDs
  37. 🧪 Testing Strategy
  38. 🔮 Roadmap Extension — Native Swap
Základy
Základy

🌀 WARP — Wormhole Architecture for Rainbow Protocol

docs/WARP_ARCHITECTURE.md

ZION TerraNova L3 — Universal Cross-Chain Interoperability

WARP connects ZION to every major blockchain, enabling seamless asset teleportation across the multi-chain universe.


🏗️ Architecture Overview

                    ┌──────────────────────────────────────────────────┐
                    │              🌀 WARP ROUTER                      │
                    │  ┌──────────┬──────────┬──────────┬───────────┐ │
                    │  │ Transfer │ Validator│   Fee    │  State    │ │
                    │  │ Routing  │ Quorum   │  Engine  │  Machine  │ │
                    │  └────┬─────┴────┬─────┴────┬─────┴────┬──────┘ │
                    └───────┼──────────┼──────────┼──────────┼────────┘
                            │          │          │          │
              ┌─────────────┼──────────┼──────────┼──────────┼────────────┐
              │             │    CHAIN ADAPTER LAYER         │            │
              │ ┌───────┐ ┌┴──────┐ ┌┴──────┐ ┌┴───────┐ ┌┴────────┐  │
              │ │  EVM  │ │Solana │ │ Tron  │ │Stellar │ │ Cardano │  │
              │ │       │ │       │ │       │ │        │ │         │  │
              │ │Base   │ │SPL    │ │TRC-20 │ │Soroban │ │Plutus   │  │
              │ │Arb    │ │Anchor │ │TVM    │ │Classic │ │Native   │  │
              │ │BSC    │ │       │ │       │ │Asset   │ │Token    │  │
              │ │Polygon│ │       │ │       │ │        │ │         │  │
              │ └───┬───┘ └───┬───┘ └───┬───┘ └───┬────┘ └────┬────┘  │
              │     │         │         │         │            │        │
              │ ┌───┴───┐ ┌──┴────┐                                    │
              │ │Cosmos │ │Bitcoin│  ← Also available                   │
              │ │IBC    │ │HTLC   │                                    │
              │ └───────┘ └───────┘                                    │
              └────────────────────────────────────────────────────────┘
                            │
              ┌─────────────┴─────────────┐
              │   ZION L1 (6 decimals)    │
              │   Bridge Vault Address    │
              │   WARP:1:chain:address    │
              └───────────────────────────┘

🔗 Supported Chains

ChainFamilyToken StandardDecimalsFinalityStatus
BaseEVMERC-2018~2 min� Signing live
ArbitrumEVMERC-2018~15 min🟢 Signing live
BSCEVMBEP-2018~15 sec🟢 Signing live
PolygonEVMERC-2018~5 min🟢 Signing live
SolanaSolanaSPL Token9~12 sec🟢 Signing live
TronTronTRC-2018~57 sec🟢 Signing live
StellarStellarStellar Asset7~5 sec� Signing live
CardanoCardanoNative Token6~7 min🟡 Skeleton (D-04)
CosmosCosmosIBC / CW206~6 sec🟡 Skeleton (D-04)
BitcoinBitcoinHTLC8~60 min🟢 Signing live
LightningLightningBOLT118~instant🟡 Stub (see plan)
AptosAptosCoin8~1 sec🔴 Stub
NEARNEARFT24~1 sec🔴 Stub
SuiSuiCoin9~1 sec🔴 Stub
TONTONJetton9~5 sec🔴 Stub

🔄 Transfer Flow

Outbound: ZION L1 → External Chain

1. User sends ZION to L1 vault with memo:
   WARP:1:solana:7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU

2. L1 Watcher detects lock TX → creates DepositProof

3. Router:
   a. Validates chains, address, amount
   b. Converts decimals (L1 6 dec → Solana 9 dec: ×10³)
   c. Calculates fee (0.15%)
   d. Creates WarpMessage

4. Validators sign WarpMessage (3-of-5 quorum)

5. Destination adapter executes mint:
   - EVM: bridgeMint() on wZION contract
   - Solana: SPL token mint via Anchor program
   - Tron: TRC-20 mint via TriggerSmartContract
   - Stellar: Payment from issuer / Soroban mint
   - Cardano: Native token mint via Plutus script
   - Cosmos: IBC transfer / CW20 mint

6. Transfer marked as Completed ✅

Inbound: External Chain → ZION L1

1. User burns wZION on external chain
   (calls bridgeBurn / SPL burn / etc.)

2. Chain Watcher detects burn event → creates DepositProof

3. Router validates + creates WarpMessage

4. Validators reach quorum (3-of-5)

5. ZION L1 releases locked ZION to recipient

6. Transfer marked as Completed ✅

💰 Fee Model

RouteFeeMin FeeMax Fee
ZION ↔ EVM0.1%0.1 ZION10,000 ZION
ZION ↔ Solana0.15%0.1 ZION15,000 ZION
ZION ↔ Tron0.1%0.1 ZION10,000 ZION
ZION ↔ Stellar0.1%0.1 ZION10,000 ZION
ZION ↔ Cardano0.2%0.2 ZION20,000 ZION
ZION ↔ Cosmos0.15%0.1 ZION15,000 ZION
ZION ↔ Bitcoin0.25%0.5 ZION25,000 ZION

Fee Distribution

  • 🔥 50% BURN — permanent deflation
  • 🏛️ 25% DAO Treasury — governance fund
  • 💰 25% Validators — incentive for bridge operators

🔒 Security Model

1. Validator Multisig (3-of-5)

Every cross-chain operation requires 3 of 5 validators to sign. Validators run independent nodes and verify proofs independently.

2. Source Chain Finality

Each chain has specific finality requirements:

  • Bitcoin: 6 blocks (~60 min)
  • ZION L1: 60 blocks (~15 min)
  • EVM: 12-20 blocks (varies)
  • Solana: 31 confirmations (~12 sec)
  • Stellar/Cosmos: 1 block (instant BFT finality)

3. Timelock for Large Amounts

Transfers >1M ZION get a 24-hour delay, allowing guardians to review.

4. Daily Limits

10M ZION maximum throughput per chain per day.

5. Replay Protection

Each transfer has a unique UUID + source TX hash. Processed transfers tracked in both DB and on-chain mappings.

6. Emergency Pause

Guardian role can pause any chain adapter independently.


🔢 Decimal Conversion Table

ZION L1 uses 6 decimals — 1 ZION = 1,000,000 flowers (FLOWERS_PER_ZION = 10⁶) (updated to 6-decimal in 3.0.3 fork). The sub-unit is called flowers (canonical name per docs/CANONICAL_UNITS_AUDIT.md and AGENTS.md). All columns below convert from L1 flowers to the destination chain's native integer unit.

DestinationDecimalsflowers → native1 ZION =
EVM (wZION)18× 10¹²1,000,000,000,000,000,000 wei
Solana9× 10³1,000,000,000 lamports
Tron18× 10¹²1,000,000,000,000,000,000 sun
Stellar7× 10¹10,000,000 stroops
Cardano6× 10⁰ (1:1)1,000,000 lovelace
Cosmos6× 10⁰ (1:1)1,000,000 uatom-equiv
Bitcoin8× 10²100,000,000 satoshis

Bridge code reference: V3/L2/bridge/src/types.rs exposes l1_flowers_to_wzion_wei() (×10¹²) and wzion_wei_to_l1_flowers() (÷10¹²). Legacy aliases l1_atomic_to_wzion_wei are kept for backward compatibility but new code should use the flowers names.


📁 Crate Structure

warp/
├── Cargo.toml                  # Dependencies: tokio, ethers, bs58, ed25519-dalek, etc.
└── src/
    ├── lib.rs                  # Module exports + architecture diagram
    ├── main.rs                 # WARP node entry point
    ├── error.rs                # WarpError enum (chain, transfer, validation errors)
    ├── types.rs                # ChainId, Asset, WarpTransfer, WarpStatus, conversion
    ├── protocol.rs             # WarpMessage, DepositProof, MintInstruction, memo format
    ├── registry.rs             # ChainRegistry: register, lookup, enable/disable chains
    ├── router.rs               # WarpRouter: orchestrate transfers end-to-end
    ├── state.rs                # TransferStateMachine: lifecycle + valid transitions
    ├── fees.rs                 # FeeEngine: per-route fees, distribution (burn/DAO/validators)
    ├── validator.rs            # WarpValidatorSet + ConsensusTracker
    ├── config.rs               # WarpConfig: load from TOML
    ├── metrics.rs              # Atomic counters + MetricsSnapshot
    └── adapter/
        ├── mod.rs              # ChainAdapter trait + create_adapter factory
        ├── evm.rs              # 🟢 EVM adapter — live EIP-155 signing via evm_signer
        ├── solana.rs           # 🟢 Solana adapter — live SPL mintTo via solana_signer
        ├── tron.rs             # 🟢 Tron adapter — live TRC-20 mint via tron_signer
        ├── stellar.rs          # 🟢 Stellar adapter — live payment via stellar_signer
        ├── cardano.rs          # Cardano adapter (Native Token, Plutus)
        ├── cosmos.rs           # Cosmos adapter (IBC, CW20)
        └── bitcoin.rs          # 🟢 Bitcoin adapter — live P2WPKH sending via btc_signer

🆚 WARP vs L2 Bridge

AspectL2 Bridge (bridge/)L3 WARP (warp/)
ScopeEVM chains onlyAll chain families
ProtocolLock/Mint/BurnUniversal + HTLC
Memo FormatBRIDGE:chain:addrWARP:1:chain:addr
AdapterFixed EVMPluggable per-chain
Fees0.1% flatPer-route (0.1%–0.25%)
State MachineSimple (6 states)Full lifecycle (9 states)
RouterDirect relayMulti-chain orchestrator
Cross-Chain❌ Only L1↔EVM✅ Any↔Any via L1 hub

The L2 Bridge remains operational for fast EVM bridging. WARP extends it to the full multi-chain universe.


📅 Implementation Roadmap

PhaseScopeTarget
Phase 1 ✅L2 wZION Bridge (EVM)Done (Sprint 3.4)
Phase 2 ✅WARP Skeleton (all adapters)Done (Sprint 3.4.15-3.4.20)
Phase 2.5 ✅EVM execute_mint — real EIP-155 signingDone (2026-03-03)
Phase 3 ✅Bitcoin P2WPKH execute_mint — BIP143 signingDone (2026-03-03)
Phase 4 ✅Stellar classic Payment signing — ed25519, XDR, StrKeyDone (2026-03-03)
Phase 5 ✅Solana SPL mintTo — ed25519, compact-u16, ATA derivation, no SDKDone (2026-03-03)
Phase 6 ✅Tron TRC-20 mint — secp256k1, base58check, TronGrid RESTDone (2026-03-03)
Phase 7 ⬜Cardano native token + Plutus2026 Q3
Phase 8 ⬜Cosmos IBC integration2026 Q4
Phase 8.5 ⬜Lightning Network — BOLT11 + LND gRPC2026 Q3-Q4
Phase 9 ⬜Full E2E testing + audit2027 Q1
Phase 10 ⬜MainNet launch2027 Q2

🦀 Solana Signing Implementation (Phase 5)

Implemented: 2026-03-03 | Commit: 39d4d58 | Tests: 228 pass

Overview

The Solana adapter now performs real on-chain SPL Token mintTo transactions with zero dependency on solana-sdk or solana-client — pure Rust using ed25519-dalek, bs58, and sha2 (all already present).

Module: solana_signer.rs

pub struct SolanaSigner { /* ed25519 SigningKey */ }

impl SolanaSigner {
    pub fn from_env() -> WarpResult<Self>           // reads WARP_SOLANA_RELAY_KEY
    pub fn from_base58(key_b58: &str) -> WarpResult<Self>  // 32 or 64-byte keypair
    pub fn pubkey(&self) -> [u8; 32]
    pub async fn mint_to(
        &self, client: &Client, rpc_url: &str,
        recipient_wallet: &str, mint_addr: &str, amount: u64,
    ) -> WarpResult<String>                         // returns base58 tx signature
}

pub fn derive_ata(owner: &[u8;32], mint: &[u8;32]) -> WarpResult<[u8;32]>
pub async fn get_latest_blockhash(client: &Client, rpc_url: &str) -> WarpResult<[u8;32]>

Transaction Building (legacy format, no SDK)

1. derive_ata(recipient_wallet, mint_addr)
            via findProgramAddress(seeds=[wallet, TOKEN_PROGRAM, mint], ATA_PROGRAM)
            SHA-256 hash of seeds, off-curve check (not a valid Ed25519 point)
            bump nonce 255→0 search

2. getLatestBlockhash → 32-byte blockhash

3. build_mint_to_message(authority, mint, dest_ata, blockhash, amount)
   Message header: [1, 0, 1]   (1 signer, 0 readonly-signed, 1 readonly-unsigned)
   Accounts (compact-u16 = 4):
     [0] authority      (signer, writable)
     [1] mint           (writable)
     [2] dest_ata       (writable)
     [3] TOKEN_PROGRAM  (read-only)
   Instruction: program_idx=3, accounts=[1,2,0], data=[0x07, amount_u64_le]

4. sig = ed25519.sign(message_bytes)   ← Solana: no pre-hashing, sign raw

5. serialize_transaction: compact-u16(1) || sig[64] || message
   → base64 encode → sendTransaction

Environment Variables

VariableDescription
WARP_SOLANA_RELAY_KEYBase58-encoded keypair (64-byte seed||pubkey or 32-byte seed)
SOLANA_CLUSTERmainnet-beta | devnet | testnet (default: mainnet-beta)
WARP_SOLANA_RPCCustom RPC endpoint override

🔴 Tron Signing Implementation (Phase 6)

Implemented: 2026-03-03 | Commit: 1ad0aca | Tests: 252 pass

Overview

The Tron adapter now performs real on-chain TRC-20 mint transactions via TronGrid REST API, using the same k256 secp256k1 crate already present for EVM.

Module: tron_signer.rs

pub struct TronSigner { /* k256 secp256k1 SigningKey */ }

impl TronSigner {
    pub fn from_env() -> WarpResult<Self>           // reads WARP_TRON_RELAY_KEY
    pub fn from_hex(hex_key: &str) -> WarpResult<Self>
    pub fn address(&self) -> String                 // Tron base58check address
    pub async fn mint_trc20(
        &self, client: &Client, api_url: &str,
        contract: &str, recipient: &str, amount: u64,
    ) -> WarpResult<String>                         // returns txID
}

pub fn tron_address_from_key(key: &SigningKey) -> String
pub fn tron_base58check_encode(payload: &[u8]) -> String
pub fn tron_base58check_decode(addr: &str) -> WarpResult<[u8;21]>
pub fn abi_encode_mint_params(recipient: &str, amount: u64) -> WarpResult<String>

Transaction Flow

1. abi_encode_mint_params(recipient, amount)
   Tron ABI (64 bytes / 128 hex chars):
     Bytes  0-11: 0x00 padding
     Bytes 12-31: Tron address bytes (drop 0x41 prefix)
     Bytes 32-55: 0x00 padding
     Bytes 56-63: amount as u64 big-endian

2. POST /wallet/triggersmartcontract
   {
     owner_address: relay_wallet_address,
     contract_address: wzion_contract,
     function_selector: "mint(address,uint256)",
     parameter: <abi_hex>,
     fee_limit: 50_000_000   ← 50 TRX max
   }
   → unsigned tx JSON + txID = SHA256(raw_data)

3. tron_sign_txid(key, txID)
   (sig, recid) = sign_prehash_recoverable(txid_bytes)
   out = r[32] || s[32] || v[1]   v = recid (0 or 1, NOT +27)

4. tx["signature"] = [sig_hex]

5. POST /wallet/broadcasttransaction → result=true → txID returned

Address Derivation

Keccak256(uncompressed_pubkey[1..])  → 32 bytes
→ last 20 bytes = EVM-style address
→ prepend 0x41 → 21 bytes
→ SHA256(SHA256(21 bytes))[0..4] = checksum
→ base58(21 bytes + 4 checksum bytes) = Tron address (starts with 'T')

Environment Variables

VariableDescription
WARP_TRON_RELAY_KEY32-byte secp256k1 private key, hex-encoded
TRON_NETWORKmainnet | nile | shasta (default: mainnet)
WARP_TRON_APITronGrid API base URL override
TRON_API_KEYTronGrid API key (added as TRON-PRO-API-KEY header)

🔏 EVM Signing Implementation (Phase 2.5)

Implemented: 2026-03-03 | Commit: 5e6dc58 | Tests: 180 pass

Overview

The EVM adapter now performs real on-chain transactions for execute_mint without any external ethers-rs dependency — pure Rust using k256, sha3, and rlp.

Module: evm_signer.rs

// Key public API:
pub struct EvmSigner { /* secp256k1 SigningKey */ }

impl EvmSigner {
    pub fn from_env() -> WarpResult<Self>   // reads WARP_EVM_RELAY_KEY env var
    pub fn from_hex(key: &str) -> WarpResult<Self>
    pub async fn send_tx(
        &self, client: &Client, rpc_url: &str,
        chain_id: u64, to: &str,
        calldata: &[u8], value: u128, gas_limit: u64,
    ) -> WarpResult<String>                 // returns 0x tx hash
}

pub fn abi_encode_bridge_mint(
    recipient: &str, amount: u128, msg_hash: &[u8; 32],
) -> WarpResult<Vec<u8>>

EIP-155 Signing Flow

1. Fetch nonce  → eth_getTransactionCount (latest)
2. Fetch gasPrice → eth_gasPrice
3. Build TX fields: nonce, gasPrice, gasLimit=300_000, to, value=0, data=calldata
4. RLP-encode pre-sign tuple + (chainId, 0, 0)  ← EIP-155
5. hash = Keccak256(rlp_bytes)
6. (sig, recid) = k256 ECDSA sign(hash)
7. v = recid + 2*chainId + 35            ← EIP-155 replay protection
8. RLP-encode final TX (nonce, gasPrice, gasLimit, to, value, data, v, r, s)
9. eth_sendRawTransaction("0x" + hex(raw_tx)) → tx_hash

ABI Encoding for bridgeMint(address, uint256, bytes32)

Bytes  0- 3: selector = keccak256("bridgeMint(address,uint256,bytes32)")[0..4]
Bytes  4-35: address  = 12×0x00 + 20 addr bytes   (left-padded to 32)
Bytes 36-67: amount   = 16×0x00 + u128.to_be_bytes (right-aligned uint256)
Bytes 68-99: msgHash  = 32 bytes verbatim

Environment Variables

VariableRequiredDescription
WARP_EVM_RELAY_KEYYes (for live minting)Hex-encoded secp256k1 private key of relay wallet
WARP_EVM_GAS_LIMITNo (default 300,000)Override per-call gas limit

If WARP_EVM_RELAY_KEY is not set, execute_mint falls back to a dry-run eth_call simulation and returns a clear error — no silent failures.

Supported Chains & Chain IDs

ChainChain ID
Base8453
Base Sepolia84532
Arbitrum One42161
BSC56
Polygon137
Ethereum Mainnet1 (default)

🧪 Testing Strategy

Unit Tests (per module):
  cargo test -p zion-warp

Integration Tests (per chain):
  cargo test -p zion-warp --test solana_integration
  cargo test -p zion-warp --test tron_integration

E2E Test (full flow):
  ZION L1 → lock → WARP → mint on Solana Devnet → burn → WARP → unlock on L1


🔮 Roadmap Extension — Native Swap

Plánovaná rozšíření WARP o přímý swap nativních coinů (BTC↔ETH↔SOL) bez wZION.

Viz kompletní návrh: docs/NATIVE_SWAP_DESIGN.md

TL;DR:

  • Uživatel zadá swap(ETH, SOL, amount) — ZION funguje jen jako fee token
  • Interně: DEX agregátor (1inch/Jupiter) + USDC settlement relay přes WARP
  • Dvě implementační cesty: Aggregated (rychlé, DEX) a HTLC Atomic (trustless, bez custody)
  • Fee distribuce: 50% burn / 25% DAO / 25% validátoři (stejná jako WARP transfer)
  • Thorchain integrace jako alternativa pro BTC↔X (nativní, testovaná likvidita)

Built with 🌀 for the ZION multi-chain universe. Peace and One Love. ☮️❤️