Owner: @David Rusu

Reviewers: 🟢@Thomas Lavaur 🟢@Giacomo Pasini 🟢@Gusto Bacvinka 🔺@Daniel Sanchez Quiros 🟢@Álvaro Castro-Castilla

Introduction

This document specifies the canonical encoding of Mantle transactions and it’s sub-components. Transactions sent through the mempool and included in blocks use this encoding.

Overview

The transaction encoding is specified in ABNF form to remove any ambiguity and guarantee a canonical encoding. The high level encoding choices which were not immediately derivable from the Mantle specification are listed here:

  1. All multi-byte integers use little-endian encoding
  2. Any lists are length-prefixed with fixed width uints
  3. We derive number of proofs and type of proof from the Ops list parsed earlier

Specification

Signed Mantle Tx

SignedMantleTx = MantleTx OpsProofs LedgerTxProof

Mantle Tx

MantleTx = Ops LedgerTx ExecutionGasPrice StorageGasPrice

ExecutionGasPrice = UINT64
StorageGasPrice   = UINT64

<aside> 💡

In future iterations, we will use this encoding to derive the mantle_txhash

</aside>

Operations

Ops     = OpCount *Op
OpCount = Byte

Op     = Opcode OpPayload
Opcode = Byte

OpPayload = ChannelInscribe /
            ChannelBlob /
            ChannelSetKeys /
            SDPDeclare /
            SDPWithdraw /
            SDPActive /
            LeaderClaim

Channel Operations

ChannelInscribe = ChannelId Inscription Parent Signer
Inscription     = UINT32 *BYTE 

ChannelBlob       = ChannelId Session BlobId BlobSize DaStorageGasPrice Parent Signer
Sesssion          = UINT64
BlobId            = Hash32
BlobSize          = UINT64
DaStorageGasPrice = UINT64

ChannelSetKeys = ChannelId KeyCount *Signer
KeyCount       = Byte

ChannelId = Hash32
Parent    = Hash32
Signer    = Ed25519PublicKey

SDP Operations