Joint Combinatorial Node Selection and Resource Allocations in the Lightning Network using Attention-based Reinforcement Learning

Mahdi Salahshour, Amirahmad Shafiee, Mojtaba TefagharXiv 2024 · DOI

Abstract

The Bitcoin Lightning Network (LN) enables scalable off-chain transactions through a network of payment channels. For node operators, maximizing routing fee revenue requires solving the Joint Combinatorial Node Selection and Resource Allocation (JCNSRA) problem: a complex optimization of discrete node selection and continuous capacity allocation. We propose a Deep Reinforcement Learning (DRL) framework powered by a 4-layer Transformer architecture to address this challenge. Our results show that this approach significantly outperforms standard heuristics and Graph Neural Networks (GNNs). Furthermore, we find that profit-maximizing agents naturally promote network decentralization, suggesting that individual financial incentives can enhance the overall robustness of the Lightning Network.

Introduction

The Lightning Network (LN) is a second-layer protocol that scales Bitcoin by moving transactions into payment channels. Node operators earn passive income by routing these transactions, but achieving optimal revenue is a non-trivial task. Operators must decide which nodes to connect to (node selection) and how much liquidity to commit to each channel (resource allocation) under a limited budget. This combined challenge, termed the Joint Combinatorial Node Selection and Resource Allocation (JCNSRA) problem, involves an exponentially large action space that traditional greedy heuristics fail to navigate effectively.

Current approaches often simplify the problem by ignoring capacity allocation or using static routing simulations. This paper introduces a more realistic DRL-based solution that accounts for dynamic liquidity shifts and complex network dependencies.

Methodology

The authors formulate the JCNSRA problem as a Markov Decision Process (MDP) and employ an Actor-Critic framework using Proximal Policy Optimization (PPO).

System Architecture

The environment is modeled as a custom OpenAI Gym interface that simulates the Lightning Network's routing mechanics. Unlike previous models, this simulation updates channel liquidity on a per-transaction basis, providing a high-fidelity representation of real-world dynamics.

The overall reinforcement learning framework, illustrating the interaction between the environment (LN simulation) and the Actor-Critic agent.

Transformer-Based Agent

A key innovation is the use of a 4-layer Transformer as the core decision-making unit. While Graph Neural Networks (GNNs) are often the default for graph-structured data, the authors found that Transformers are better suited for capturing the long-range dependencies and complex transaction flows inherent in the LN. The Transformer processes node features—such as degree centrality, transaction flow, and current allocation—without positional encodings, treating the network as a set of potential connection points.

The 4-layer Transformer architecture, featuring multi-head attention mechanisms to process node features and output selection scores and resource distributions.

Experimental Setup

To train and evaluate the agent, the researchers utilized:

  • Real-World Snapshots: A 2021 snapshot of the LN graph, including node capacities and fee policies.
  • Service Provider Data: Information from 1ML to identify high-traffic "sink" nodes.
  • Forest-Fire Sampling: To manage the scale of the 16,000-node LN graph, "forest-fire" sampling was used to extract representative subgraphs (50, 100, and 200 nodes) for efficient RL training while preserving structural properties.
  • Dynamic Flow Simulation: Transactions of varying sizes (10k to 100k Satoshis) were simulated based on known network density distributions.

Key Results and Insights

Revenue Performance

The Transformer-based model achieved superior normalized revenue across all tested subgraph sizes. In a 200-node environment, the Transformer reached a score of 0.8171, significantly outperforming standard MLPs (0.0499) and the best-performing heuristic, Bottom-k-Degree (0.7472). The dynamic resource allocation module also proved vital, statistically outperforming naive uniform allocation strategies (p < 0.05).

The "Hub" Fallacy

A common intuition in the LN community is to connect to high-degree "hub" nodes. However, this study proves that connecting to less central nodes (Bottom-k) often yields higher returns. These nodes likely serve as bridges to underserved parts of the network, capturing niche routing flows that hubs miss.

Incentivized Decentralization

One of the most significant findings is the impact of profit-seeking behavior on network topology. When revenue-maximizing agents were deployed, the network's modularity decreased (from 0.3970 to 0.3754), and entropy for centrality measures increased. This indicates that economically rational agents naturally seek out gaps in the network, leading to a more evenly distributed and decentralized structure.

Conclusion and Future Work

This research demonstrates that attention-based DRL can effectively solve the complex JCNSRA problem in the Lightning Network. The alignment between individual profit and network decentralization provides a positive outlook for the long-term health of the ecosystem. Future work will focus on scaling these models to the full global LN graph and integrating dynamic fee-setting strategies to further optimize operator returns.

Summary updated

BibTeX
@misc{salahshour2024joint,
  author = {Mahdi Salahshour and Amirahmad Shafiee and Mojtaba Tefagh},
  title = {{Joint Combinatorial Node Selection and Resource Allocations in the Lightning Network using Attention-based Reinforcement Learning}},
  year = {2024},
  eprint = {2411.17353},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2411.17353},
}
Figure