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

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 BlobId BlobSize DaStorageGasPrice Parent Signer
BlobId            = Hash32
BlobSize          = UINT64
DaStorageGasPrice = UINT64

ChannelSetKeys = ChannelId KeyCount *Signer
KeyCount       = Byte

ChannelId = Hash32
Parent    = Hash32
Signer    = Ed25519PublicKey

SDP Operations

SDPDeclare   = ServiceType LocatorCount *Locator ProviderId ZkId LockedNoteId
ServiceType  = Byte        ; 0 = BN, 1 = DA
LocatorCount = Byte        ; Max 8
Locator      = 2Byte *BYTE ; Max 329 bytes, multiaddr format
ProviderId   = Ed25519PublicKey
ZkId         = ZkPublicKey
LockedNoteId = NoteId

SDPWithdraw   = DeclarationId Nonce LockedNoteId
DeclarationId = Hash32
Nonce         = UINT64

SDPActive = DeclarationId Nonce Metadata
Metadata  = UINT32 *BYTE  ; Service-specific node activeness metadata