Interactions

This section explores how sequencer node interacts with Laïka smart contracts. It's intended for developers building sequencer applications and outlines the key functionalities sequencers perform.


Communication with Smart Contracts

Sequencer node interacts with Laïka smart contracts to fulfill its responsibilities. Here's an overview of the interaction process:

  • Sequencer Client: Sequencer node runs a client application that connects to Laïka's smart contracts using a secure communication channel, the client also requires a full Dogecoin Node be run along with the Laïka Node.

  • Contract Interaction Methods: The sequencer client utilizes functions exposed by the relevant smart contracts (e.g., Sequencer contract, Fee contract). These functions allow sequencers to perform actions like:

    • Submitting batches of L2 transactions.

    • Publishing ZK proofs for the batched transactions.

    • Withdrawing earned fees (subject to specific fee distribution mechanisms).


Batching and Submitting Transactions

Sequencers play a crucial role in optimizing transaction processing on Laïka. Here's a breakdown of their workflow:

  1. Transaction Pool: The sequencer maintains a pool of L2 transactions submitted by users on the Laïka network.

  2. Batch Creation: The sequencer node efficiently aggregates multiple transactions into batches to minimize gas costs when submitting them to the L1 blockchain.

  3. L1 Submission: The sequencer submits the batched transactions to the L1 blockchain (Dogecoin) for inclusion in a block. This leverages L1's security while enabling faster and cheaper transactions on L2.


Ensuring L2 Transaction Verifiability with zk-SNARKs

To guarantee the verifiability of L2 transactions even if the original L1 data becomes unavailable, sequencers leverage zk-SNARKs (Zero-Knowledge Succinct Non-interactive Argument of Knowledge).

zk-SNARK Proof Generation:

Data Commitment:

The sequencer generates a commitment (public key) for the entire block data, including transactions. This commitment acts as a compressed representation of the data.

zk-SNARK Proof Creation:

The sequencer utilizes a zk-SNARK proving system to generate a cryptographic proof. This proof demonstrates the knowledge of the actual block data corresponding to the commitment without revealing the data itself.

Submitting zk-SNARK Proof

Once the zk-SNARK proof is generated, the sequencer submits it alongside the batched transactions to Laika's smart contracts:

Proof Publication: The sequencer publishes the zk-SNARK proof to the Sequencer contract on L2. This allows validators to efficiently verify the data availability of L2 transactions on the L1 blockchain without requiring the entire L1 data. Validators also submit their own Proofs to further increase trust and provide decentralized trust between the Validators and Sequencers.


Package Sequencing and Submission on DogeCoin

Each Package Submitted on Dogecoin is a formatted JSON which allows the package to be readable and be verified by anyone, this package is inscribed onto Dogecoin blockchain just like Doginals, thus keeping the data permanently stored on the blockchain.

Package Format

{
  "blockHash": "0x...", // Hash of the L2 block containing the batched transactions
  "transactions": [
    {
      "id": "0x...",     // Unique identifier for the L2 transaction
      "data": "..."       // Encoded L2 transaction data
    },
    // ... more transactions within the batch
  ],
  "proof": "0x..."  // Proof representing the entire transaction batch
}

Package Submission

For each package submission the UTXO chain is progressed further

  • Current UTXO Retrieval: The code retrieves the most recent UTXO for the sequencer address, ensuring the UTXO chain is maintained.

  • Balance Validation: It checks if the current UTXO has sufficient balance to cover transaction costs before proceeding.

  • UTXO Selection: The selectUTXOsForBatch function is responsible for selecting UTXOs for the batch, considering factors like efficiency and fee optimization.

  • New Transaction Construction: The code constructs a new transaction spending the current UTXO as input.

  • UTXO Chain Update: The deriveUTXOFromTransaction function extracts the output of the new transaction, effectively creating the next UTXO in the chain.

  • L2 Data Inclusion: The L2 transaction data is encoded and included within the new transaction.

  • Batch Creation: Finally, a batch containing the newly constructed transaction is created.

// Function to retrieve the current UTXO for the sequencer (implementation detail)
function getCurrentUTXO(address sequencerAddress) -> UTXO {
  // This function should interacts with a Dogecoin node or service
  // to retrieve the most recent UTXO associated with the sequencer address.

}

// Function to build a transaction batch
function buildTransactionBatch(transactions) {
  currentUTXO <- getCurrentUTXO(sequencerAddress);

  // Validate if currentUTXO has sufficient balance for transactions and fees
  if (currentUTXO.value < calculateTotalBatchCost(transactions)) {
    // Handle insufficient balance scenario
    return;
  }

  // Select UTXOs for the batch (consider efficiency and fee optimization)
  selectedUTXOs <- selectUTXOsForBatch(currentUTXO, transactions);

  // Construct new transaction spending the current UTXO
  newTransaction <- createTransaction(currentUTXO, transactions, selectedUTXOs);

  // Update the UTXO chain by deriving the new UTXO from the transaction output
  newUTXO <- deriveUTXOFromTransaction(newTransaction);

  // Include L2 transaction data within the new transaction
  newTransaction.data <- encodeL2TransactionData(transactions);

  // Create a batch containing the newly constructed transaction
  batch <- [newTransaction];

  return batch;
}

Last updated