Abstract

This article presents a detailed technical analysis of a recent update in the TON Blockchain, particularly focusing on the implementation of a gas limit override mechanism. This update was introduced in response to a significant issue encountered by the @wallet Telegram bot’s highload wallet, which became unresponsive due to the insufficient gas limit for cleaning up old queries.

Introduction

In January 2024, the TON Blockchain community faced a critical challenge when the highload wallet of the @wallet Telegram bot became stuck. The root cause was identified as the existing gas limit of 1M, which proved inadequate for processing and cleaning up old queries. This article examines the implemented solution that involves dynamically adjusting the gas limit for specific transactions.

Technical Background

The issue was first acknowledged in the comments of the crypto/smartcont/highload-wallet-v2-code.fc and was attributed to the inability of the existing gas limit to process the accumulated old queries in the wallet, leading to a lock-up of funds. The account in question has the address EQD_v9j1rlsuHHw2FIhcsCFFSD367ldfDdCKcsNmNpIRzUlu.

Solution Overview

A temporary solution proposed to validators involved increasing the gas limit for the affected account until February 16, 2024. This increase was facilitated through the gas_prices_v3 parameter in the ConfigParam 20 (config_mc_gas_prices), affecting special accounts in the masterchain.

Methodology

The implemented solution is encapsulated in two primary functions: override_gas_limit and gas_bought_for.

  1. override_gas_limit: This function determines whether a transaction requires a gas limit override. The override is conditional based on the transaction’s time, the account involved, and the specific configuration of the compute phase. It particularly checks against the predefined account address (addr_hex) and the time frame until February 16, 2024.

  2. gas_bought_for: This function computes the amount of gas that can be bought with a given number of nanograms. It includes a condition to check if the gas limit override is necessary (using override_gas_limit). If an override is required, it calculates the gas amount based on a new, higher gas limit and a modified gas threshold.

Technical Implications

The gas limit override mechanism introduces a significant change in how gas limits are handled for specific accounts, particularly in emergency situations. This approach allows for greater flexibility and responsiveness in addressing unforeseen challenges in the blockchain’s operation. However, it also necessitates careful monitoring and governance to ensure that such overrides are used judiciously and do not lead to unintended consequences in the network’s economic model.

Conclusion

The introduction of a dynamic gas limit override in the TON Blockchain represents a pragmatic approach to resolving critical operational issues. While it effectively addresses the immediate problem of the stuck highload wallet, it also underscores the need for continuous assessment and improvement of blockchain infrastructure to adapt to evolving challenges and demands. This solution highlights the balance between operational flexibility and the maintenance of rigorous network protocols. As the TON Blockchain continues to evolve, such adaptive measures will be crucial in maintaining its efficiency, security, and user trust. Future developments should focus on enhancing the blockchain’s capacity to handle high-load scenarios without compromising its underlying principles and ensuring that such emergency measures are integrated seamlessly into the broader ecosystem.

Github Code