æternity Documentation Hub
Aeternity.comAeternity GitHub
  • æternity Hub
  • Developer Documentation
  • Aeternity Expansions
    • PULL_REQUEST_TEMPLATE
    • AEX X
    • AEXS
      • AEX 1
      • aex-10
      • AEX 11 Fungible Token Standard
      • AEX-130: æpps Metadata Format Specification
      • aex-141
      • AEX 2
      • AEX-3
      • AEX-4
      • AEX 5
      • AEX 7
      • AEX 8
      • aex-9
    • .github
      • ISSUE_TEMPLATE
        • aexpansion
  • AeMdw - Aeternity Middleware
    • Changelog
    • docs
      • AE MDW Architecture
      • AeMdw Hyperhain Setup Documentation
      • AeMdw Docker Setup Documentation
  • Æternity <> Ethereum Bridge
    • Changelog
  • aepp-cli-js
    • CHANGELOG
    • Contributor guide
    • reference
    • user-guide
    • .github
      • ISSUE_TEMPLATE
  • Hyperchain Bridge
    • Changelog
  • æternity's JavaScript SDK
    • Installation
      • Changelog
      • Compatibility Table
      • Quick Start
      • Transaction options
      • Development
        • Releases
      • guides
        • The range of possible address length
        • AENS (æternity naming system)
        • Batch Transactions
        • How to build a wallet
        • Connect an æpp to a wallet
        • Contract Events
        • Contracts
        • Error Handling
        • JWT usage
        • Ledger Hardware Wallet
        • Low vs High level API
        • Aeternity snap for MetaMask
        • Oracles
        • PayingForTx (Meta-Transactions)
        • Typed data hashing and signing
        • Usage with TypeScript
        • migration
          • Migration to 10.0.0
          • Migration to 11.0.0
          • Migration to 12.0.0
          • Migration to 13.0.0
          • Migration to 14.0.0
          • Migration to 7.0.0
          • Migration to 9.0.0
      • tutorials
        • vuejs
          • Vue.js HelloWorld
    • Examples
      • How to connect wallet to æpp using æternity's JS SDK
        • Sample æpp for contracts
        • iframe-based wallet
        • WebExtension-based wallet
    • .github
      • ISSUE_TEMPLATE
        • bug_report
        • feature_request
  • AEproject
    • Changelog
    • docs
      • Quick Start
      • AEproject Library
      • Migration from 3.x.x to 4.x.x
      • Migration from 4.x.x to 5.x.x
      • Upcoming Version Support
      • cli
        • Local Environment
        • Project Initialization
        • Unit Testing
    • .github
      • ISSUE_TEMPLATE
        • bug_report
        • feature_request
  • aerepl
    • Changelog
  • aescan
    • Changelog
    • Contributor Covenant Code of Conduct
    • Aescan Contributing Guide
    • LICENSE
    • .github
      • pull_request_template
      • ISSUE_TEMPLATE
        • bug_report
        • feature_request
    • docs
      • BRANCHING_STRATEGY
  • Sophia Support for Visual Studio Code
    • Changelog
  • aesophia
    • Changelog
    • Contributing to Sophia
    • docs
      • aeso_aci
      • aeso_compiler
      • Introduction
      • sophia
      • Contract examples
      • Features
      • Standard library
      • Syntax
  • aesophia_cli
    • Changelog
  • aesophia_http
    • Changelog
  • Æ Studio - Formerly known as 🔥 Fire Editor ! Aeternity's easy to use editor for writing smart contr
    • ideas
  • aeternity
    • .github
      • The Æternity Code of Conduct
      • Contributing to the Aeternity node
      • ISSUE_TEMPLATE
        • bug_report
        • feature_request
    • Welcome to Aeternity node documentation
      • Summary
      • Node API
      • Introduction
      • Build from source
      • Configuration
      • CUDA Miner
      • debian_ubuntu_packaging
      • Docker
      • Fork resistance in Aeternity nodes
      • Garbage Collection
      • Hacking the Aeternity Codebase
      • Hardware Requirements
      • hyperchains
      • Installation
      • Network Monitoring
      • Operation
      • Rebar Quick Guide
      • Stratum
      • Testing
      • Update
      • release-notes
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • next-ceres
          • GH-3706-micro_block_gas_limit_used_gas
          • GH-4009-allow_contract_call_by_name
          • GH-4056-add_raw_data_pointers_to_AENS
          • GH-4080-wildcard_aens_delegation_signature
          • GH3417-tamper_protection_on_ga_meta_tx
          • aega_only_allow_attach_for_fresh_accounts
          • aens_auction_adjustments
          • aens_preclaim_optional
          • deprecate_swagger
          • fate_extensions
        • next
          • GH-3088-db_direct_access-as-default
          • GH-4087_http_endpoint_info_inner_txs
          • GH4157-control-mempool-sync-start
    • Emergency patching of OTP modules
    • rosetta
    • apps
      • aehttp
        • priv
          • rosetta_README
    • data
      • aecore
        • Token migration contract
  • Hyperchains whitepaper
    • Hyperchains: Bridging Security and Scalability Through Periodic Synchronization
    • LICENSE
    • Periodically-Syncing-HyperChains
    • generations
    • Glossary
    • Hyperchain Properties
    • staking
  • æternity protocol
    • æternity naming system
    • Gossip
    • Stratum
    • SYNC
    • Serialization formats
    • State Channels
      • Off-chain
      • On-chain
      • Authentication
      • Channel off-chain state
    • æternity consensus protocol
      • Bitcoin-NG for æternity
      • Coinbase at height
      • consensus
      • Coins locking
    • Smart Contracts
      • The æternity Ethereum virtual machine (AEVM)
      • contract_state_tree
      • Contract Transactions
      • Virtual machines on the æternity blockchain
      • contracts
      • Events
      • fate
      • The Solidity Language
      • sophia
      • sophia_stdlib
    • Generalized accounts
      • Generalized accounts - explained
      • generalized_accounts
    • Oracles
      • Oracle life cycle examples
      • Oracle state tree
      • Oracle transactions
      • oracles
    • Sync
      • P2P messages
      • Mempool/TX-pool synchronization
    • node
      • æternity node API
        • Account management - intended usage
        • Encoding scheme for API identifiers and byte arrays
        • State channel WebSocket API
        • Channels - intended usage
        • Contracts - intended usage
        • Mining - intended usage
        • Naming System - intended usage
        • Oracles - intended usage
        • Spending coins - intended usage
        • examples
          • æternity node channel WebSocket API examples
            • json-rpc
              • sc_ws_basic_open_close
              • sc_ws_basic_open_close_server
              • sc_ws_broken_open_params
              • sc_ws_close_mutual
              • sc_ws_close_solo
              • sc_ws_leave_reconnect
              • sc_ws_leave_reestablish
              • sc_ws_leave_reestablish_responder_stays
              • sc_ws_leave_reestablish_wrong_fsm_id
              • sc_ws_min_depth_is_modifiable
              • sc_ws_min_depth_not_reached_timeout
              • sc_ws_opening_ping_pong
              • sc_ws_reconnect_early
              • sc_ws_slash
              • sc_ws_snapshot_solo
              • sc_ws_timeout_open
              • sc_ws_update_with_meta
              • abort_updates
                • sc_ws_abort_deposit
                • sc_ws_abort_offchain_update
                • sc_ws_abort_settle
                • sc_ws_abort_shutdown
                • sc_ws_abort_slash
                • sc_ws_abort_snapshot_solo
                • sc_ws_abort_withdraw
                • sc_ws_can_not_abort_while_open
              • assume_min_depth
                • sc_ws_basic_open_close
              • both_sign
                • init_per_group
                • conflicts
                  • sc_ws_conflict_deposit_and_offchain_update
                  • sc_ws_conflict_two_deposits
                  • sc_ws_conflict_two_offchain_updates
                  • sc_ws_conflict_two_withdrawals
                  • sc_ws_conflict_withdrawal_and_deposit
                  • sc_ws_conflict_withdrawal_and_offchain_update
              • changeable_fee
                • sc_ws_optional_params_close_solo
                • sc_ws_optional_params_create
                • sc_ws_optional_params_deposit
                • sc_ws_optional_params_settle
                • sc_ws_optional_params_slash
                • sc_ws_optional_params_snapshot
                • sc_ws_optional_params_withdrawal
                • sc_ws_set_fee_close_mutual
                • sc_ws_set_fee_close_solo
                • sc_ws_set_fee_create
                • sc_ws_set_fee_deposit
                • sc_ws_set_fee_settle
                • sc_ws_set_fee_slash
                • sc_ws_set_fee_snapshot
                • sc_ws_set_fee_withdrawal
              • changeable_fee_higher_than_gas_price
                • sc_ws_optional_params_close_solo
                • sc_ws_optional_params_create
                • sc_ws_optional_params_deposit
                • sc_ws_optional_params_settle
                • sc_ws_optional_params_slash
                • sc_ws_optional_params_snapshot
                • sc_ws_optional_params_withdrawal
              • changeable_fee_lower_than_gas_price
                • sc_ws_optional_params_close_solo
                • sc_ws_optional_params_create
                • sc_ws_optional_params_deposit
                • sc_ws_optional_params_settle
                • sc_ws_optional_params_slash
                • sc_ws_optional_params_snapshot
                • sc_ws_optional_params_withdrawal
              • changeable_gas_price
                • sc_ws_optional_params_close_solo
                • sc_ws_optional_params_create
                • sc_ws_optional_params_deposit
                • sc_ws_optional_params_settle
                • sc_ws_optional_params_slash
                • sc_ws_optional_params_snapshot
                • sc_ws_optional_params_withdrawal
              • changeable_nonce
                • sc_ws_optional_params_fail_close_mutual
                • sc_ws_optional_params_fail_close_solo
                • sc_ws_optional_params_fail_create
                • sc_ws_optional_params_fail_deposit
                • sc_ws_optional_params_fail_force_progress
                • sc_ws_optional_params_fail_settle
                • sc_ws_optional_params_fail_slash
                • sc_ws_optional_params_fail_snapshot
                • sc_ws_optional_params_fail_withdrawal
              • continuous
                • init_per_group
                • sc_ws_deposit
                • sc_ws_failed_update
                • sc_ws_generic_messages
                • sc_ws_ping_pong
                • sc_ws_update_conflict
                • sc_ws_withdraw
              • contracts
                • init_per_group
                • sc_ws_basic_contracts
                • sc_ws_environment_contract
                • sc_ws_nameservice_contract
                • sc_ws_oracle_contract
                • sc_ws_remote_call_contract
                • sc_ws_remote_call_contract_refering_onchain_data
                • sc_ws_wrong_call_data
              • force_progress
                • sc_ws_force_progress_based_on_offchain_state
                • sc_ws_force_progress_based_on_onchain_state
              • only_one_signs
                • init_per_group
                • sc_ws_conflict_on_new_offchain
                • sc_ws_conflict_snapshot_and_offchain_update
                • conflicts
                  • sc_ws_conflict_deposit_and_offchain_update
                  • sc_ws_conflict_two_deposits
                  • sc_ws_conflict_two_offchain_updates
                  • sc_ws_conflict_two_withdrawals
                  • sc_ws_conflict_withdrawal_and_deposit
                  • sc_ws_conflict_withdrawal_and_offchain_update
              • reconnect
                • sc_ws_basic_client_reconnect_i
                • sc_ws_basic_client_reconnect_i_w_reestablish
                • sc_ws_basic_client_reconnect_r
              • with_meta
                • init_per_group
                • sc_ws_deposit
                • sc_ws_remote_call_contract
                • sc_ws_withdraw
              • generalized_accounts
                • both
                  • sc_ws_basic_open_close
                • initiator
                  • sc_ws_basic_open_close
                • responder
                  • sc_ws_basic_open_close
  • Superhero Wallet
    • Changelog
    • Contributing & Guidelines
    • docs
      • Deep link URL Schema
    • .github
      • ISSUE_TEMPLATE
        • bug_report
        • feature_request
  • aerepl-web-bridge
    • AereplApi
    • aerepl_components
Powered by GitBook
On this page
  • Types
  • MSG_FRAGMENT
  • MSG_P2P_RESPONSE
  • MSG_PING
  • Version 1
  • Version 2
  • MSG_GET_HEADER_BY_HASH
  • MSG_GET_HEADER_BY_HEIGHT
  • MSG_HEADER
  • MSG_GET_N_SUCCESSORS
  • MSG_HEADER_HASHES
  • MSG_GET_BLOCK_TXS
  • MSG_GET_GENERATION
  • MSG_TXS
  • MSG_BLOCK_TXS
  • MSG_KEY_BLOCK
  • MSG_MICRO_BLOCK
  • MSG_GENERATION
  • MSG_TX_POOL_SYNC_INIT
  • MSG_TX_POOL_SYNC_UNFOLD
  • MSG_TX_POOL_SYNC_GET
  • MSG_TX_POOL_SYNC_FINISH
  • MSG_GET_NODE_INFO
  • MSG_NODE_INFO
  • MSG_CLOSE

Was this helpful?

Export as PDF
  1. æternity protocol
  2. Sync

P2P messages

PreviousSyncNextMempool/TX-pool synchronization

Last updated 22 days ago

Was this helpful?

P2P messages are transported using the . Since each message in the Noise protocol is limited to (65536 - 2) bytes we sometimes have to fragment larger messages (in particular blocks and transaction pool-chunks). On top of this we use a simple message format, where 2 bytes (16 bits) are used for a big-endian encoded message type integer followed by the payload for the particular message. Since Noise (and the fragmentation) handle message size we need no length field. The payload is a byte array, and messages are either fixed binary data or encoded using .

The following P2P messages are implemented in the :

Each message type (except for MSG_FRAGMENT) is versioned such that the message can easily be changed while still maintaining backwards compatibility by adding logic to handle several versions of a message.

Types

In the following we use some types to abbreviate the documentation here is how various types should be interpreted (corresponds to their encoding):

  • uint16 - 16 bit, big endian unsigned integer.

  • byte_array - variable sized byte array (either the last field in a static message or RLP encoded).

  • bool - representing true or false - encoded as 0 or 1.

  • int - variable (RLP encoded) integer

  • [X] - variable (RLP encoded) list of X:s

MSG_FRAGMENT

(Tag = 0)

Fields:

  • N :: uint16 - fragment N of M

  • M :: uint16 - total number of fragments

  • Data :: byte_array

NOTE: Data is either (65536 - 6) bytes or N is equal to M.

MSG_P2P_RESPONSE

(Tag = 100)

Message is RLP encoded, fields:

  • Result :: bool - true means ok, false means error.

  • Type :: int - the type of the response

  • Reason :: byte_array - Human readable (UTF8) reason (only set if Result is false)*

  • Object :: byte_array - an object of type Type if Result is true.

MSG_PING

(Tag = 1)

Message is RLP encoded, fields:

Version 1

  • Port :: int - listen port.

  • Share :: int - number of peers to share.

  • GenesisHash :: byte_array

  • Difficulty :: int - the total difficulty of the chain.

  • TopHash :: byte_array

  • SyncAllowed :: bool - if the sender of this ping message is accepting synchronization messages.

  • Peers :: [byte_array] - list of shared peers.

Version 2

  • Versions :: list

    • Protocol :: binary - type of message, currently only "ping" is supported.

    • Vsns :: [int] - versions supported

  • Port :: int - listen port.

  • Share :: int - number of peers to share.

  • GenesisHash :: byte_array

  • Height :: int - current height.

  • Difficulty :: int - the total difficulty of the chain.

  • TopHash :: byte_array

  • SyncAllowed :: bool - if the sender of this ping message is accepting synchronization messages.

  • Capabilities :: byte_array - list of supported capabilites.

  • Peers :: [byte_array] - list of shared peers.

Peers are serialized/deserialized in aec_peer_messages

MSG_GET_HEADER_BY_HASH

(Tag = 3)

Message is RLP encoded, fields:

  • Hash :: byte_array

MSG_GET_HEADER_BY_HEIGHT

(Tag = 15)

Message is RLP encoded, fields:

  • Height :: int

  • TopHash :: byte_array - to ensure we get a header at height from the right fork

MSG_HEADER

(Tag = 4)

Message is RLP encoded, fields:

  • Header :: byte_array

The Header is serialized using theaec_headers:serialize_to_binary/1 function.

MSG_GET_N_SUCCESSORS

(Tag = 5)

Message is RLP encoded, fields:

  • FromHash :: byte_array - header hash to start at

  • TargetHash :: byte_array - target header hash (to ensure we get headers from the right fork)

  • N :: int - number of header hashes to get

MSG_HEADER_HASHES

(Tag = 6)

Message is RLP encoded, fields:

  • HeaderHashes :: [byte_array]

Each header hash contains a 64-bit big endian height and the corresponding hash, see aec_peer_messages for details.

MSG_GET_BLOCK_TXS

(Tag = 7)

Message is RLP encoded, fields:

  • Hash :: byte_array - The block we fetch TXs from

  • TxHashes :: [byte_array] - List of TxHashes to fetch TXs for

MSG_GET_GENERATION

(Tag = 8)

Message is RLP encoded, fields:

  • Hash :: byte_array

  • Forward :: bool

MSG_TXS

(Tag = 9)

Message is RLP encoded, fields:

  • Txs:: [byte_array]

MSG_BLOCK_TXS

*(Tag = 13)

Message is RLP encoded, fields:

  • Hash :: byte_array - The block we fetch TXs from

  • Txs :: [byte_array] - List of serialized signed TXs

MSG_KEY_BLOCK

*(Tag = 10)

Message is RLP encoded, fields:

  • KeyBlock :: byte_array - Serialized key block

MSG_MICRO_BLOCK

*(Tag = 11)

Message is RLP encoded, fields:

  • MicroBlock :: byte_array - Serialized micro block

  • Light :: bool - flag if micro block is light or normal

MSG_GENERATION

(Tag = 12)

Message is RLP encoded, fields:

  • KeyBlock :: byte_array

  • MicroBlocks :: [byte_array]

  • Forward :: bool

The key block and each of the microblocks are serialized using the aec_blocks:serialize_to_binary/1 function.

MSG_TX_POOL_SYNC_INIT

(Tag = 20)

Message has no body.

MSG_TX_POOL_SYNC_UNFOLD

(Tag = 21)

Message is RLP encoded, fields:

  • Unfolds :: [byte_array]

Unfolds are serialized in aec_tx_pool_sync - the serialization is described in [tx_pool_sync])(./tx_pool_sync.md).

MSG_TX_POOL_SYNC_GET

(Tag = 22)

Message is RLP encoded, fields:

  • TxHashes :: [byte_array]

MSG_TX_POOL_SYNC_FINISH

(Tag = 23)

Message is RLP encoded, fields:

  • Done :: bool

MSG_GET_NODE_INFO

(Tag = 125)

This message has no fields.

This is to be used for network monitoring.

MSG_NODE_INFO

(Tag = 126)

Message is RLP encoded, fields:

  • Version :: byte_array - the version of the node

  • Revision :: byte_array - the revision of the node

  • Vendor :: byte_array - a string to differentiate between different protocol implementations

  • OS :: byte_array - the operating system the node is being ran

  • NetworkId :: byte_array - the node's expectation of the network_id. This has heavy impact on authentication validations

  • VerifiedPeers :: integer - the amount of peers the node consideres to be verified

  • UnverifiedPeers :: integer - the amount of peers the node consideres to be unverified

MSG_CLOSE

(Tag = 127)

This message has no fields.

A signed transaction is serialized as a tagged and versioned.

A signed transaction is serialized as a tagged and versioned.

The key block is .

A normal micro block is . A light micro block is serialized usingaec_peer_connection:serialize_light_micro_block/1 - in effect replacing the list of serialized signed transactions with a list of transaction hashes.

This message is the response for the message. It is important to note that responding to it is not required by the p2p protocol as a peer might prefer keeping this information private.

Noise protocol
RLP
æternity node
MSG_FRAGMENT
MSG_P2P_RESPONSE
MSG_PING
MSG_GET_HEADER_BY_HASH
MSG_GET_HEADER_BY_HEIGHT
MSG_HEADER
MSG_GET_N_SUCCESSORS
MSG_HEADER_HASHES
MSG_GET_BLOCK_TXS
MSG_GET_GENERATION
MSG_TXS
MSG_BLOCK_TXS
MSG_KEY_BLOCK
MSG_MICRO_BLOCK
MSG_GENERATION
MSG_TX_POOL_SYNC_INIT
MSG_TX_POOL_SYNC_UNFOLD
MSG_TX_POOL_SYNC_GET
MSG_TX_POOL_SYNC_FINISH
MSG_GET_NODE_INFO
MSG_NODE_INFO
MSG_CLOSE
MSG_GET_NODE_INFO
signed transaction
signed transaction
serialized
serialized