Global version is a parameter specified in ConfigParam 8 (block.tlb).
Various features are enabled depending on the global version.
Enabled in mainnet on 2023-12-20
New features of version 4 are described in detail in the documentation.
PREVMCBLOCKS,PREVKEYBLOCKGLOBALIDHASHEXT(A)(R)ECRECOVERSENDMSGRUNVM,RUNVMXGASCONSUMEDRIST255_...instructionsBLS_...instructionsP256_CHKSIGNS,P256_CHKSIGNU
Division instruction can add a number to the
intermediate value before division (e.g. (xy+w)/z).
- Arguments of
PICK,ROLL,ROLLREV,BLKSWX,REVX,DROPX,XCHGX,CHKDEPTH,ONLYTOPX,ONLYXare now unlimited. ROLL,ROLLREV,BLKSWX,REVX,ONLYTOPXconsume more gas when arguments are big.
c7 tuple extended from 10 to 14 elements:
- 10: code of the smart contract.
- 11: value of the incoming message.
- 12: fees collected in the storage phase.
- 13: information about previous blocks.
- If "send message" action fails, the account is required to pay for processing cells of the message.
- Flag +16 in actions "Send message", "Reserve", "Change library" causes bounce if action fails.
- Unpaid storage fee is now saved to
due_payment
Enabled in mainnet on 2024-02-03
Version 5 enables higher gas limits for special contracts.
- Gas limit for all transactions on special contracts is set to
special_gas_limitfromConfigParam 20(which is 35M at the moment of writing). Previously only ticktock transactions had this limit, while ordinary transactions had a default limit ofgas_limitgas (1M). - Gas usage of special contracts is not taken into account when checking block limits. This allows keeping masterchain block limits low while having high gas limits for elector.
- Gas limit on
EQD_v9j1rlsuHHw2FIhcsCFFSD367ldfDdCKcsNmNpIRzUluis increased to 70M (special_gas_limit * 2) until 2024-02-29. See this post for details.
- Loading "nested libraries" (i.e. a library cell that points to another library cell) throws an exception.
- Loading a library consumes gas for cell load only once (for the library cell), not twice (both for the library cell and the cell in the library).
XLOADnow works differently. When it takes a library cell, it returns the cell that it points to. This allows loading "nested libraries", if needed.
Enabled in mainnet on 2024-03-16
c7 tuple extended from 14 to 17 elements:
- 14: tuple that contains some config parameters as cell slices. If the parameter is absent from the config, the value is null. Asm opcode:
UNPACKEDCONFIGTUPLE.- 0:
StoragePricesfromConfigParam 18. Not the whole dict, but only the one StoragePrices entry (one which corresponds to the current time). - 1:
ConfigParam 19(global id). - 2:
ConfigParam 20(mc gas prices). - 3:
ConfigParam 21(gas prices). - 4:
ConfigParam 24(mc fwd fees). - 5:
ConfigParam 25(fwd fees). - 6:
ConfigParam 43(size limits).
- 0:
- 15: "due payment" - current debt for storage fee (nanotons). Asm opcode:
DUEPAYMENT. - 16: "precompiled gas usage" - gas usage for the current contract if it is precompiled (see
ConfigParam 45),nullotherwise. Asm opcode:GETPRECOMPILEDGAS.
GETGASFEE(gas_used is_mc - price) - calculates gas fee.GETSTORAGEFEE(cells bits seconds is_mc - price) - calculates storage fees (only current StoragePrices entry is used).GETFORWARDFEE(cells bits is_mc - price) - calculates forward fee.GETPRECOMPILEDGAS(- x) - returns gas usage for the current contract if it is precompiled,nullotherwise.GETORIGINALFWDFEE(fwd_fee is_mc - orig_fwd_fee) - calculatefwd_fee * 2^16 / first_frac. Can be used to get the originalfwd_feeof the message.GETGASFEESIMPLE(gas_used is_mc - price) - same asGETGASFEE, but without flat price (just(gas_used * price) / 2^16).GETFORWARDFEESIMPLE(cells bits is_mc - price) - same asGETFORWARDFEE, but without lump price (just(bits*bit_price + cells*cell_price) / 2^16).
gas_used, cells, bits, time_delta are integers in range 0..2^63-1.
Operations for working with Merkle proofs, where cells can have non-zero level and multiple hashes.
CLEVEL(cell - level) - returns level of the cell.CLEVELMASK(cell - level_mask) - returns level mask of the cell.i CHASHI(cell - hash) - returnsith hash of the cell.i CDEPTHI(cell - depth) - returnsith depth of the cell.CHASHIX(cell i - hash) - returnsith hash of the cell.CDEPTHIX(cell i - depth) - returnsith depth of the cell.
i is in range 0..3.
GLOBALIDgetsConfigParam 19from the tuple, not from the config dict. This decreases gas usage.SENDMSGgetsConfigParam 24/25(message prices) from the tuple, not from the config dict, and also usesConfigParam 43to get max_msg_cells.
Enabled in mainnet on 2024-04-18
Explicitly nullify due_payment after due reimbursment.
Enabled in mainnet on 2024-08-25
- Check mode on invalid
action_send_msg. Ignore action ifIGNORE_ERROR(+2) bit is set, bounce ifBOUNCE_ON_FAIL(+16) bit is set. - Slightly change random seed generation to fix mix of
addr_rewriteandaddr. - Fill in
skipped_actionsfor both invalid and valid messages withIGNORE_ERRORmode that can't be sent. - Allow unfreeze through external messages.
- Don't use user-provided
fwd_feeandihr_feefor internal messages.
Enabled in mainnet on 2025-02-13
c7 tuple parameter number 13 (previous blocks info tuple) now has the third element. It contains ids of the 16 last masterchain blocks with seqno divisible by 100.
Example: if the last masterchain block seqno is 19071 then the list contains block ids with seqnos 19000, 18900, ..., 17500.
SECP256K1_XONLY_PUBKEY_TWEAK_ADD(key tweak - 0 or f x y -1) - performssecp256k1_xonly_pubkey_tweak_add.keyandtweakare 256-bit unsigned integers. 65-byte public key is returned asuint8 f,uint256 x, y(as inECRECOVER). Gas cost:1276.mask SETCONTCTRMANY(cont - cont') - takes continuation, performs the equivalent ofc[i] PUSHCTR SWAP c[i] SETCONTCNRfor eachithat is set inmask(mask is in0..255).SETCONTCTRMANYX(cont mask - cont') - same asSETCONTCTRMANY, but takesmaskfrom stack.PREVMCBLOCKS_100returns the third element of the previous block info tuple (see above).
- Fix
RAWRESERVEaction with flag4(use original balance of the account) by explicitly settingoriginal_balancetobalance - msg_balance_remaining.- Previously it did not work if storage fee was greater than the original balance.
- Jumps to nested continuations of depth more than 8 consume 1 gas for eact subsequent continuation (this does not affect most of TVM code).
- Support extra currencies in reserve action with
+2mode. - Fix exception code in some TVM instructions: now
stk_undhas priority over other error codes.PFXDICTADD,PFXDICTSET,PFXDICTREPLACE,PFXDICTDEL,GETGASFEE,GETSTORAGEFEE,GETFORWARDFEE,GETORIGINALFWDFEE,GETGASFEESIMPLE,GETFORWARDFEESIMPLE,HASHEXT
- Now setting the contract code to a library cell does not consume additional gas on execution of the code.
- Temporary increase gas limit for some accounts (see this post for details,
override_gas_limitintransaction.cppfor the list of accounts). - Fix recursive jump to continuations with non-null control data.
- Internal messages cannot carry more than 2 different extra currencies. The limit can be changed in size limits config (
ConfigParam 43). - Amount of an extra currency in an output action "send message" can be zero.
- In action phase zero values are automatically deleted from the dictionary before sending.
- However, the size of the extra currency dictionary in the "send message" action should not be greater than 2 (or the value in size limits config).
- Extra currency dictionary is not counted in message size and does not affect message fees.
- Message mode
+64(carry all remaining message balance) is now considered as "carry all remaining TONs from message balance". - Message mode
+128(carry all remaining account balance) is now considered as "carry all remaining TONs from account balance". - Message mode
+32(delete account if balance is zero) deletes account if it has zero TONs, regardless of extra currencies.- Deleted accounts with extra currencies become
account_uninit, extra currencies remain on the account.
- Deleted accounts with extra currencies become
SENDMSGin TVM calculates message size and fees without extra currencies, uses new+64and+128mode behavior.SENDMSGdoes not check the number of extra currencies.
- Extra currency dictionary is not counted in the account size and does not affect storage fees.
- Accounts with already existing extra currencies will get their sizes recomputed without EC only after modifying
AccountState.
- Accounts with already existing extra currencies will get their sizes recomputed without EC only after modifying
- Reserve action cannot reserve extra currencies.
Reserve modes
+1,+4and+8("reserve all except", "add original balance" and "negate amount") now only affect TONs, but not extra currencies.
- Anycast addresses are not allowed in
destof internal and external messages. addr_varare not allowed indestof external messages.- Note: as before,
addr_varindestof internal messages are automatically replaced withaddr_std.
- Note: as before,
- TVM instructions
LDMSGADDR(Q),PARSEMSGADDR(Q),REWRITESTDADDR(Q),REWRITEVARADDR(Q)no more support anycast addresses andaddr_var. addr:MsgAddressIntinAccountcannot be an anycast address.- Therefore,
srcof outbound messages cannot be an anycast address. - Existing accounts with anycast addresses change to non-anycast addresses in the first transaction.
- Therefore,
- When deploying an account with
fixed_prefix_lengthinStateInitof the message (it was calledsplit_depthbefore), the firstfixed_prefix_lengthbits of the address are not compared against the state hash.- This allows deploying an account to an arbitrary shard regardless of the hash of state init.
fixed_prefix_lengthremains in the account state.fixed_prefix_lengthof the account can be at most 8. The limit can be changed in size limits config (ConfigParam 43).
SENDMSGcalculates messages size and fees without extra currencies, uses new +64 and +128 mode behavior.SENDMSGdoes not check the number of extra currencies.
- New instruction
GETEXTRABALANCE(id - amount). Takes id of the extra currency (integer in range0..2^32-1), returns the amount of this extra currency on the account balance.- This is equivalent to taking the extra currency dictionary (
BALANCE SECOND), loading value (UDICTGET) and parsing it (LDVARUINT32). Ifidis not present in the dictionary,0is returned. GETEXTRABALANCEhas special gas cost that allows writing gas-efficient code with predictable gas usage even if there are a lot of different extra currencies.- The full gas cost of
GETEXTRABALANCEis26(normal instruction cost) plus gas for loading cells (up to3300if the dictionary has maximum depth). - However, the first
5executions ofGETEXTRABALANCEcost at most26+200gas units. All subsequent executions cost the full price. RUNVMinteracts with this instructions in the following way:- Without "isolate gas" mode, the child VM shares
GETEXTRABALANCEcounter with the parent vm. - With "isolate gas" mode, in the beginning of
RUNVMthe parent VM spends full gas for all already executedGETEXTRABALANCEand resets the counter.
- Without "isolate gas" mode, the child VM shares
- This is equivalent to taking the extra currency dictionary (
LDMSGADDR(Q),PARSEMSGADDR(Q),REWRITESTDADDR(Q),REWRITEVARADDR(Q)no more support anycast addresses andaddr_var.- Fixed bug in
RUNVMcaused by throwing out-of-gas exception with "isolate gas" enabled. - Fixed setting gas limits in
RUNVMafter consuming "free gas" (e.g. afterCHKSIGNinstructions).
- Exceeding state limits in transaction now reverts
end_ltback tostart_lt + 1and collects action fines.
c7 tuple extended from 17 to 18 elements:
- 17: tuple with inbound message parameters. Asm opcode:
INMSGPARAMS.- The tuple contains:
bounce(boolean)bounced(boolean)src_addr(slice)fwd_fee(int)created_lt(int)created_at(int)orig_value(int) - this is sometimes different from the value inINCOMINGVALUEand TVM stack because of storage feesvalue(int) - same as inINCOMINGVALUEand TVM stack.value_extra(cell or null) - same as inINCOMINGVALUE.state_init(cell or null)
- For external messages, tick-tock transactions and get methods:
bounce,bounced,fwd_fee,created_lt,created_at,orig_value,valueare 0,value_extrais null. - For tick-tock transactions and get methods:
src_addrisaddr_none.
- The tuple contains:
x GETPARAMLONG- same asx GETPARAM, butxis in range[0..254]. Gas cost:34.x INMSGPARAM- equivalent toINMSGPARAMSx INDEX. Gas cost:26.- Aliases:
INMSG_BOUNCE,INMSG_BOUNCED,INMSG_SRC,INMSG_FWDFEE,INMSG_LT,INMSG_UTIME,INMSG_ORIGVALUE,INMSG_VALUE,INMSG_VALUEEXTRA,INMSG_STATEINIT.
- Aliases:
Along with the storage stat (cells and bits count), each account now stores the hash of the storage dict.
Storage dict is the dictionary that stores refcnt for each cell in the account state. This is required to help computing storage stats in the future, after collator-validator separation.