tronprotocol / tips

TRON Improvement Proposals
232 stars 206 forks source link

TIP-397: Raise limit of the 13th network parameter #397

Closed yanghang8612 closed 2 years ago

yanghang8612 commented 2 years ago
tip: 397
title: Raise limit of the 13th network parameter    
author: yanghang8612@163.com
discussions to: https://github.com/tronprotocol/TIPs/issues/384
status: Draft
type: Standards Track
category: VM
created: 2022-04-06

Abstract

Raise the limit of the 13th(MAX_CPU_TIME_OF_ONE_TX) network parameter.

Motivation

The 13th network parameter now ranges from 10 to 100 ms. This range currently greatly limits developers from designing more diverse and complex applications such as DeFi, GameFi, etc.

Therefore the purpose of this TIP is to extend the limit of the range of the 13th network parameter.

Specifications

After the RAISE_PROPOSAL(TBD) takes effect, the limit for the 13th network parameter will change from 100 ms to 400 ms.

Rationale

The time range for SR to produce blocks

TRON network generates block every 3 seconds. According to the design of the TRON's DPOS consensus mechanism, the time range for SR to produce blocks is 450 to 1500 ms.

The timeout calculation algorithm is shown in the following code which link is at DposTask.java.

    ...
    long timeout =
        pTime + BLOCK_PRODUCED_INTERVAL / 2 * dposService.getBlockProduceTimeoutPercent() / 100;
    ...

The range of getBlockProduceTimeoutPercent() is set in the following code which link is at Args.java.

    ...
    if (PARAMETER.blockProducedTimeOut < 30) {
      PARAMETER.blockProducedTimeOut = 30;
    }
    if (PARAMETER.blockProducedTimeOut > 100) {
      PARAMETER.blockProducedTimeOut = 100;
    }
    ...

Therefore the time range for SR to produce blocks can be calculated by 3000 / 2 * 30 / 100 ~ 3000 / 2 * 100 / 100 = 450 ~ 1500

Why the limit cannot exceed 450ms

According to the above analysis, SR can set its own block production time to a minimum of 450ms. Then assuming that the 13th network parameter is set to a value greater than 450ms, it means that the SR cannot package any other system contract transaction after it packages a smart contract transaction that exceeds 450ms.

Backwards Compatibility

This is a breaking change given proposal to set the 13th network parameter to a new value greater than 100 will be legal. So need a hard fork to achieve.

Security Considerations

There are no known security considerations issues.

ethan1844 commented 2 years ago

Close this issue as it is implemented by GreatVoyage-v4.5.0. Check TIP detail at TIP-397 Check implementation PR at https://github.com/tronprotocol/java-tron/pull/4375