操作码
TVM 操作码
TRON 虚拟机(TVM)的操作码与以太坊虚拟机(EVM)兼容,并额外包含了一些 TRON 网络的特有操作码。请参阅下表获取各操作码的详细信息。
| 操作码 | 名称 | 能量 | 初始栈 (Initial Stack) | 结果栈 (Resulting Stack) | 内存 / 存储 | 注释 |
|---|---|---|---|---|---|---|
0x00 | STOP | 0 | 停止执行 | |||
0x01 | ADD | 3 | a, b | a + b | (u)int256 的模 2**256 加法 | |
0x02 | MUL | 5 | a, b | a * b | (u)int256 的模 2**256 乘法 | |
0x03 | SUB | 3 | a, b | a - b | (u)int256 的模 2**256 减法 | |
0x04 | DIV | 5 | a, b | a // b | uint256 除法 | |
0x05 | SDIV | 5 | a, b | a // b | int256 除法 | |
0x06 | MOD | 5 | a, b | a % b | uint256 取模 | |
0x07 | SMOD | 5 | a, b | a % b | int256 取模 | |
0x08 | ADDMOD | 8 | a, b, N | (a + b) % N | (u)int256 模 N 加法 | |
0x09 | MULMOD | 8 | a, b, N | (a * b) % N | (u)int256 模 N | |
0x0A | EXP | A1 | a, b | a ** b | uint256 exponentiation modulo 2**256 | |
0x0B | SIGNEXTEND | 5 | b, x | SIGNEXTEND(x, b) | sign extend 将 x 从 (b+1) 字节符号扩展至 32 字节 | |
0x0C-0x0F | invalid | |||||
0x10 | LT | 3 | a, b | a < b | uint256 less-than | |
0x11 | GT | 3 | a, b | a > b | uint256 greater-than | |
0x12 | SLT | 3 | a, b | a < b | int256 less-than | |
0x13 | SGT | 3 | a, b | a > b | int256 greater-than | |
0x14 | EQ | 3 | a, b | a == b | (u)int256 equality | |
0x15 | ISZERO | 3 | a | a == 0 | (u)int256 iszero | |
0x16 | AND | 3 | a, b | a && b | bitwise AND | |
0x17 | OR | 3 | a, b | a | b | |
0x18 | XOR | 3 | a, b | a ^ b | bitwise XOR | |
0x19 | NOT | 3 | a | ~a | bitwise NOT | |
0x1A | BYTE | 3 | i, x | (x >> (248 - i * 8)) && 0xFF | ith byte of (u)int256 x, from the left (i start from 0) | |
0x1B | SHL | 3 | shift, val | val << shift | ||
0x1C | SHR | 3 | shift, val | val >> shift | 逻辑移动 | |
0x1D | SAR | 3 | shift, val | val >> shift | 左移arithmetic shift right | |
0x1E | CLZ | 5 | x | leadingZeros(x) | Osaka。返回 256 位无符号整数 x 的前导零位数;x = 0 时返回 256 | |
0x20 | SHA3 | A2 | ost, len | keccak256(mem[ost:ost+len-1]) | keccak256 | |
0x21-0x2F | invalid | |||||
0x30 | ADDRESS | 2 | . | address(this) | address of executing contract | |
0x31 | BALANCE | 20 | addr | addr.balance | balance, in sun | |
0x32 | ORIGIN | 2 | . | tx.origin | address that originated the tx | |
0x33 | CALLER | 2 | . | msg.sender | address of msg sender | |
0x34 | CALLVALUE | 2 | . | msg.value | msg value, in sun | |
0x35 | CALLDATALOAD | 3 | idx | msg.data[idx:idx+32] | read word from msg data at indexidx | |
0x36 | CALLDATASIZE | 2 | . | len(msg.data) | length of msg data, in bytes | |
0x37 | CALLDATACOPY | A3 | dstOst, ost, len | . | mem[dstOst:dstOst+len-1] := msg.data[ost:ost+len-1] | copy msg data |
0x38 | CODESIZE | 2 | . | len(this.code) | length of executing contract's code, in bytes | |
0x39 | CODECOPY | A3 | dstOst, ost, len | . | mem[dstOst:dstOst+len-1] := this.code[ost:ost+len-1] | |
0x3A | GASPRICE | 2 | . | tx.gasprice | gas price of tx | |
0x3B | EXTCODESIZE | 20 | addr | len(addr.code) | size of code at addr, in bytes | |
0x3C | EXTCODECOPY | A4 | addr, dstOst, ost, len | . | mem[dstOst:dstOst+len-1] := addr.code[ost:ost+len-1] | copy code from addr |
0x3D | RETURNDATASIZE | 2 | . | size | size of returned data from last external call, in bytes | |
0x3E | RETURNDATACOPY | A3 | dstOst, ost, len | . | mem[dstOst:dstOst+len-1] := returndata[ost:ost+len-1] | copy returned data from last external call |
0x3F | EXTCODEHASH | 400 | addr | hash | hash = addr.exists ? keccak256(addr.code) : 0 | |
0x40 | BLOCKHASH | 20 | blockNum | blockHash(blockNum) | ||
0x41 | COINBASE | 2 | . | block.coinbase | address of proposer of current block | |
0x42 | TIMESTAMP | 2 | . | block.timestamp | timestamp of current block | |
0x43 | NUMBER | 2 | . | block.number | number of current block | |
0x44 | DIFFICULTY | 2 | . | 0 | block’s difficulty, | |
0x45 | GASLIMIT | 2 | . | block.gaslimit | gas limit of current block | |
0x46 | CHAINID | 2 | . | chain_id | push current chain id onto stack | |
0x47 | SELFBALANCE | 5 | . | address(this).balance | balance of executing contract, in sun | |
0x48 | BASEFEE | 2 | . | block.basefee | base fee of current block | |
0x50 | POP | 2 | . | . | remove item from top of stack and discard it | |
0x51 | MLOAD | A5 | ost | mem[ost:ost+32] | read word from memory at offsetost | |
0x52 | MSTORE | A5 | ost, val | . | mem[ost:ost+32] := val | write a word to memory |
0x53 | MSTORE8 | A6 | ost, val | . | mem[ost] := val && 0xFF | write a single byte to memory |
0x54 | SLOAD | 50 | key | storage[key] | read word from storage | |
0x55 | SSTORE | A7 | key, val | . | storage[key] := val | write word to storage |
0x56 | JUMP | 8 | dst | . | $pc := dstmark thatpcis only assigned ifdstis a valid jumpdest | |
0x57 | JUMPI | 10 | dst, condition | . | $pc := condition ? dst : $pc + 1 | |
0x58 | PC | 2 | . | $pc | program counter | |
0x59 | MSIZE | 2 | . | len(mem) | size of memory in current execution context, in bytes | |
0x5A | GAS | 2 | . | gasRemaining | the amount of available gas | |
0x5B | JUMPDEST | 1 | $pc := $pc + 1 | |||
0x5F | PUSH0 | 2 | . | uint8 | push the constant value 0 onto stack | |
0x60 | PUSH1 | 3 | . | uint8 | push 1-byte value onto stack | |
0x61 | PUSH2 | 3 | . | uint16 | push 2-byte value onto stack | |
0x62 | PUSH3 | 3 | . | uint24 | push 3-byte value onto stack | |
0x63 | PUSH4 | 3 | . | uint32 | push 4-byte value onto stack | |
0x64 | PUSH5 | 3 | . | uint40 | push 5-byte value onto stack | |
0x65 | PUSH6 | 3 | . | uint48 | push 6-byte value onto stack | |
0x66 | PUSH7 | 3 | . | uint56 | push 7-byte value onto stack | |
0x67 | PUSH8 | 3 | . | uint64 | push 8-byte value onto stack | |
0x68 | PUSH9 | 3 | . | uint72 | push 9-byte value onto stack | |
0x69 | PUSH10 | 3 | . | uint80 | push 10-byte value onto stack | |
0x6A | PUSH11 | 3 | . | uint88 | push 11-byte value onto stack | |
0x6B | PUSH12 | 3 | . | uint96 | push 12-byte value onto stack | |
0x6C | PUSH13 | 3 | . | uint104 | push 13-byte value onto stack | |
0x6D | PUSH14 | 3 | . | uint112 | push 14-byte value onto stack | |
0x6E | PUSH15 | 3 | . | uint120 | push 15-byte value onto stack | |
0x6F | PUSH16 | 3 | . | uint128 | push 16-byte value onto stack | |
0x70 | PUSH17 | 3 | . | uint136 | push 17-byte value onto stack | |
0x71 | PUSH18 | 3 | . | uint144 | push 18-byte value onto stack | |
0x72 | PUSH19 | 3 | . | uint152 | push 19-byte value onto stack | |
0x73 | PUSH20 | 3 | . | uint160 | push 20-byte value onto stack | |
0x74 | PUSH21 | 3 | . | uint168 | push 21-byte value onto stack | |
0x75 | PUSH22 | 3 | . | uint176 | push 22-byte value onto stack | |
0x76 | PUSH23 | 3 | . | uint184 | push 23-byte value onto stack | |
0x77 | PUSH24 | 3 | . | uint192 | push 24-byte value onto stack | |
0x78 | PUSH25 | 3 | . | uint200 | push 25-byte value onto stack | |
0x79 | PUSH26 | 3 | . | uint208 | push 26-byte value onto stack | |
0x7A | PUSH27 | 3 | . | uint216 | push 27-byte value onto stack | |
0x7B | PUSH28 | 3 | . | uint224 | push 28-byte value onto stack | |
0x7C | PUSH29 | 3 | . | uint232 | push 29-byte value onto stack | |
0x7D | PUSH30 | 3 | . | uint240 | push 30-byte value onto stack | |
0x7E | PUSH31 | 3 | . | uint248 | push 31-byte value onto stack | |
0x7F | PUSH32 | 3 | . | uint256 | push 32-byte value onto stack | |
0x80 | DUP1 | 3 | a | a, a | clone 1st value on stack | |
0x81 | DUP2 | 3 | _, a | a, _, a | clone 2nd value on stack | |
0x82 | DUP3 | 3 | , , a | a, , , a | clone 3rd value on stack | |
0x83 | DUP4 | 3 | , , _, a | a, , , _, a | clone 4th value on stack | |
0x84 | DUP5 | 3 | ..., a | a, ..., a | clone 5th value on stack | |
0x85 | DUP6 | 3 | ..., a | a, ..., a | clone 6th value on stack | |
0x86 | DUP7 | 3 | ..., a | a, ..., a | clone 7th value on stack | |
0x87 | DUP8 | 3 | ..., a | a, ..., a | clone 8th value on stack | |
0x88 | DUP9 | 3 | ..., a | a, ..., a | clone 9th value on stack | |
0x89 | DUP10 | 3 | ..., a | a, ..., a | clone 10th value on stack | |
0x8A | DUP11 | 3 | ..., a | a, ..., a | clone 11th value on stack | |
0x8B | DUP12 | 3 | ..., a | a, ..., a | clone 12th value on stack | |
0x8C | DUP13 | 3 | ..., a | a, ..., a | clone 13th value on stack | |
0x8D | DUP14 | 3 | ..., a | a, ..., a | clone 14th value on stack | |
0x8E | DUP15 | 3 | ..., a | a, ..., a | clone 15th value on stack | |
0x8F | DUP16 | 3 | ..., a | a, ..., a | clone 16th value on stack | |
0x90 | SWAP1 | 3 | a, b | b, a | swap the 1st item from the stack with the top | |
0x91 | SWAP2 | 3 | a, _, b | b, _, a | swap the 2nd item from the stack with the top | |
0x92 | SWAP3 | 3 | a, , , b | b, , , a | swap the 3rd item from the stack with the top | |
0x93 | SWAP4 | 3 | a, , , _, b | b, , , _, a | swap the 4th item from the stack with the top | |
0x94 | SWAP5 | 3 | a, ..., b | b, ..., a | swap the 5th item from the stack with the top | |
0x95 | SWAP6 | 3 | a, ..., b | b, ..., a | swap the 6th item from the stack with the top | |
0x96 | SWAP7 | 3 | a, ..., b | b, ..., a | swap the 7th item from the stack with the top | |
0x97 | SWAP8 | 3 | a, ..., b | b, ..., a | swap the 8th item from the stack with the top | |
0x98 | SWAP9 | 3 | a, ..., b | b, ..., a | swap the 9th item from the stack with the top | |
0x99 | SWAP10 | 3 | a, ..., b | b, ..., a | swap the 10th item from the stack with the top | |
0x9A | SWAP11 | 3 | a, ..., b | b, ..., a | swap the 11th item from the stack with the top | |
0x9B | SWAP12 | 3 | a, ..., b | b, ..., a | swap the 12th item from the stack with the top | |
0x9C | SWAP13 | 3 | a, ..., b | b, ..., a | swap the 13th item from the stack with the top | |
0x9D | SWAP14 | 3 | a, ..., b | b, ..., a | swap the 14th item from the stack with the top | |
0x9E | SWAP15 | 3 | a, ..., b | b, ..., a | swap the 15th item from the stack with the top | |
0x9F | SWAP16 | 3 | a, ..., b | b, ..., a | swap the 16th item from the stack with the top | |
0xA0 | LOG0 | A8 | ost, len | . | LOG0(memory[ost:ost+len-1]) | |
0xA1 | LOG1 | A8 | ost, len, topic0 | . | LOG1(memory[ost:ost+len-1], topic0) | |
0xA2 | LOG2 | A8 | ost, len, topic0, topic1 | . | LOG2(memory[ost:ost+len-1], topic0, topic1) | |
0xA3 | LOG3 | A8 | ost, len, topic0, topic1, topic2 | . | LOG3(memory[ost:ost+len-1], topic0, topic1, topic2) | |
0xA4 | LOG4 | A8 | ost, len, topic0, topic1, topic2, topic3 | . | LOG4(memory[ost:ost+len-1], topic0, topic1, topic2, topic3) | |
0xD0 | CALLTOKEN | A9 | callEnergy, addr, val, tokenId, argOst, argLen, retOst, retLen | success | mem[retOst:retOst+retLen-1] := returndata | call the addr with val and argument. |
0xD1 | TOKENBALANCE | 20 | tokenId, address | balance | balance of address on tokenId trc10 token | |
0xD2 | CALLTOKENVALUE | 2 | . | value | call token value | |
0xD3 | CALLTOKENID | 2 | tokenId | token id | ||
0xD4 | ISCONTRACT | 20 | address | isContract | 判断一个地址是否为合约 | |
0xD5 | FREEZE | A10 | resouceType, frozenBalance, receiverAddress | success | Freeze frozenBalance resource of resourceType to receiverAddress | |
0xD6 | UNFREEZE | 20000 | resourceType, targetAddress | success | Unfreeze all resource of resourceType on targetAddress | |
0xD7 | FREEZEEXPIRETIME | 50 | resourceType, targetAddress | expireTime | expireTime of resourceType on targetAddress | |
0xD8 | VOTEWITNESS | A11 | amountArrayLength, amountArrayOffset, witnessArrayLength, witnessArrayOffset | success | vote amount in amountArray for corresponding witness in witnessArray. | |
0xD9 | WITHDRAWREWARD | 20000 | . | withdrawReward | withdrawReward | |
0xDA | FREEZEBALANCEV2 | 10000 | resourceType, frozenBalance | success | freeze balance v2 | |
0xDB | UNFREEZEBALANCEV2 | 10000 | resouceType, unfreezeBalance | success | unfreeze balance v2 | |
0xDC | CANCELALLUNFREEZEV2 | 10000 | . | success | cancel all unfreeze V2 balance | |
0xDD | WITHDRAWEXPIREUNFREEZE | 10000 | . | success | Withdraw expired unfreeze balance | |
0xDE | DELEGATERESOURCE | 10000 | resouceType, delegateBalance, receiverAddress | success | Delegate resource | |
0xDF | UNDELEGATERESOURCE | 10000 | resourceType, unDelegateBalance, receiverAddress | success | Undelegate resource | |
0xF0 | CREATE | A12 | val, ost, len | . | create contract | |
0xF1 | CALL | A9 | callEnergy, addr, val, argOst, argLen, retOst, retLen | success | mem[retOst:retOst+retLen-1] := returndata | call codeAddress with value and argument. |
0xF2 | CALLCODE | A13 | gas, addr, val, argOst, argLen, retOst, retLen | success | mem[retOst:retOst+retLen-1] = returndata | same as DELEGATECALL, but does not propagate original msg.sender and msg.value |
0xF3 | RETURN | A14 | ost, len | . | halt execution and return mem[ost:ost+len-1] | |
0xF4 | DELEGATECALL | A15 | callEnergy, addr, argOst, argLen, retOst, retLen | success | mem[retOst:retOst+retLen-1] := returndata | delegate call |
0xF5 | CREATE2 | A16 | val, ost, len, salt | addr | addr = keccak256(0x41 ++ address(this) ++ salt ++ keccak256(mem[ost:ost+len-1]))[12:] | |
0xFA | STATICCALL | A15 | gas, addr, argOst, argLen, retOst, retLen | success | mem[retOst:retOst+retLen-1] := returndata | |
0xFD | REVERT | A14 | ost, len | . | revert(mem[ost:ost+len-1]) | |
0xFF | SUICIDE | A17 | addr | . | halt execution and register account for later deletion |
Osaka 预编译合约
CLZ 由 Osaka 治理提议控制。节点升级到 GreatVoyage-v4.8.2 只表示具备该指令的实现;在对应链上提议生效前,合约不能依赖该指令。
P256VERIFY
GreatVoyage-v4.8.2 实现了 P256VERIFY(TIP-7951),用于验证 secp256r1/P-256 签名。该预编译合约地址为 0x0000000000000000000000000000000000000100,固定消耗 6900 Energy。
输入必须严格为 160 字节,依次拼接五个 32 字节字段:hash || r || s || qx || qy。签名有效时返回 32 字节的 1;输入长度、签名或公钥无效时返回空字节串,调用本身不回滚。
CLZ、P256VERIFY 及下面的 MODEXP 和签名验证预编译合约变更,统一由 ALLOW_TVM_OSAKA 治理提议(参数 ID 96)控制。部署依赖这些能力的合约前,应确认目标网络已经激活该提议,而不能只根据节点版本判断。
MODEXP
GreatVoyage-v4.8.2 调整了地址 0x0000000000000000000000000000000000000005 上的 MODEXP 预编译合约:
- TIP-7823:
baseLen、expLen和modLen分别不得超过1024字节(8192 位);任一长度超限时调用失败并返回空结果。 - TIP-7883:重新定价 MODEXP,新增
500Energy 的最低收费;旧版 TRON 使用 EIP-198 风格公式,没有显式最低收费,并包含/20除数,新公式不再使用该除数。同时,将长度超过 32 字节的指数乘数从8调整为16,并重新定义 base/modulus 的乘法复杂度。 - TIP-871:当 modulus 的值为零时,返回长度恰好为
modLen的全零字节串,而不是空字节串。
这些变化可能使原有 MODEXP 调用失败、消耗更多 Energy,或观察到不同的返回数据长度。迁移自其他 EVM 链的密码学合约应重新测试相关边界输入和 Energy 预算。
签名验证预编译合约的 calldata 校验
TIP-854 对 BatchValidateSign(0x0000000000000000000000000000000000000009)和 ValidateMultiSign(0x000000000000000000000000000000000000000a)增加了总长度校验。calldata 必须按 32 字节字对齐,并包含至少一个尾部元素:
BatchValidateSign:总长度必须满足160 + 192 × N字节,其中N >= 1。ValidateMultiSign:总长度必须满足160 + 160 × N字节,其中N >= 1。
不满足上述形式的 calldata 会使预编译合约调用失败且不返回数据;该规则只校验总长度形式,不代表对所有内部动态偏移执行完整的 Solidity ABI 规范化校验。
Prague 历史区块哈希合约
TIP-2935 在状态中部署 BlockHashHistory 系统合约,用于提供最近 8191 个区块的历史哈希。合约使用与 Ethereum EIP-2935 相同的地址 0x0000F90827F1C53a10cb7A02335B175320002935,对应的 TRON Base58Check 地址为 T9yEAebSu94c1ndzJa1rpPtrjXBXp2FCMV。
查询时,将区块号编码为 32 字节大端整数并调用该合约;calldata 不是 32 字节,或目标区块不在 [block.number - 8191, block.number - 1] 范围内时,调用会回滚。该环形缓冲区只保存提议激活后逐块写入的父区块哈希,因此激活后最多需要 8191 个区块才能完全填充。
TIP-2935 不改变 BLOCKHASH opcode 的语义、Energy 或原有 256 个区块查询范围。该功能由 ALLOW_TVM_PRAGUE 治理提议(参数 ID 95)控制,并要求目标网络已经激活 ALLOW_TVM_SHANGHAI;节点升级到 GreatVoyage-v4.8.2 本身不等于该功能已经在链上生效。
附录:能量消耗计算
A01: memNeed(offset, size)
memNeed(offset, size)计算操作所需的内存大小。
offset:内存中的起始位置。size: 从offset开始需要处理的数据长度。- Return :
offset + size
A02: calcMemEnergy(oldMemorySIze, memorySize, copySize)
calcMemEnergy(oldMemorySIze, memorySize, copySize)计算内存操作消耗的能量。
oldMemorySize:操作前的内存大小。memorySize: 操作后的新内存大小。copySize: 如果操作涉及数据拷贝,copySize为拷贝的数据大小。memWords = (memorySize + 31) / 32oldMemWords = oldMemorySize / 32energyCost=3 * memWords + memWords^2 / 512 - (3 * oldMemWords + oldMemWords^2 / 512) + 3 *((copySize + 31) / 32)
A03: penalty(energyCost)
penalty(energyCost)如果允许动态能量,则返回惩罚值 (penalty)。
DYNAMIC_ENERGY_FACTOR = 10000Factor:合约上下文因子。Penalty=energyCost * factor / DYNAMIC_ENERGY_FACTOR - energyCost- 返回:
penalty > 0 ? penalty : 0
A04: isDeadAccount(address)
isDeadAccount(address)目标账户不存在,即地址尚未激活时返回 true;账户存在时返回 false。
A05: sizeInWords(len)
sizeInWords(len)计算长度 len 占用的字数(一个字为32字节)。
返回 len == 0 ? 0 : (len - 1) / 32 + 1
A1: EXP 能量消耗
byte_len_exponent: 指数 b 的字节长度。the number of bytes in the exponent (exponent is b in the stack representation)
计算:
energy_cost=10 + 10 * byte_len_exponent
A2: SHA3-energyCost
energy_cost=30 + 6 * sizeInWords(len) + [calcMemEnergy](#a02-calcmemenergyoldmemorysize-memorysize-copysize)(oldMemSize, [memNeed](#a01-memneedoffset-size)(ost, len), 0)- 不计内存扩展费用时,处理 32 字节需要 36 Energy,处理 33 字节需要 42 Energy。
A3: *COPY 系列操作
The following applies for the operations CALLDATACOPY, CODECOPY, and RETURNDATACOPY (not EXTCODECOPY).
- energy_cost = calcMemEnergy(oldMemSize, memNeed(dstOst, len), len)
A4: EXTCODECOPY
- energy_cost = 20 + calcMemEnergy(oldMemSize, memNeed(dstOst, len), len)
A5: MLOAD, MSTORE
- energy_cost = calcMemEnergy(oldMemSize, memNeed(ost,32), 0)
A6: MSTORE8
- energy_cost = calcMemEnergy(oldMemSize, memNeed(ost,1), 0)
A7: SSTORE
- oldValue: old value of storage[key]
- energy_cost = (oldValue == null && val != 0) ? 20000 : (oldValue != null && value == 0) ? 5000 : 5000
A8: LOG0, LOG1 … LOG4
- nTopics: number of topics
- energyCost = 375 + 375 + 8 * len + calcMemEnergy(oldMemSize, memNeed(ost,len), 0)
A9: CALLTOKEN, CALL
- energyCost_1 = 40 + (val != 0 ? 9000 : 0) +
(value != 0 && isDeadAccount(addr) ? 25000 : 0) +
calcMemEnergy(oldMemSize, max(memNeed(orgOst, orgLen), memNeed(retOst, retLen)), 0)
- energyCost_2 = energeCost_1 + penalty(energyCost_1)
- energyLimitLeft = energeLimit - energyCost_2
- energyCost = energyCost_2 + min(callEnergy, energyLimitLeft)
A10: FREEZE
- energyCost = 20000 + (isDeadAccount(receiverAddress) ? 25000 : 0)
A11: VOTEWITNESS
- energyCost = 30000 + ALLOW_ENERGY_ADJUSTMENT ? calcMemEnergy(oldMemSize, max(memNeed(amountArrayOffset, amountArrayLength),
memNeed(witnessArrayOffset, witnessArrayLength)), 0) : calcMemEnergy(oldMemSize, max(memNeed(amountArrayOffset, amountArrayLength _ 32 + 32),
memNeed(witnessArrayOffset, witnessArrayLength _ 32 + 32)), 0)
A12: CREATE
- energyCost = 32000 + calcMemEnergy(oldMemSIze, memNeed(ost, len), 0)
A13: CALLCODE
- energyCost_1 = 40 + (val != 0 ? 9000 : 0) +
calcMemEnergy(oldMemSize, max(memNeed(orgOst, orgLen), memNeed(retOst, retLen)), 0)
- energyCost_2 = energeCost_1 + penalty(energyCost_1)
- energyLimitLeft = energeLimit - energyCost_2
- energyCost = energyCost_2 + min(callEnergy, energyLimitLeft)
A14: RETURN, REVERT
- calcMemEnergy(oldMemSize, memNeed(ost, len), 0)
A15: DELEGATECALL, STATICCALLENERGY 能量消耗
DELEGATECALL, STATICCALLENERGY 能量消耗- energyCost_1 = 40 + calcMemEnergy(oldMemSize, max(memNeed(orgOst, orgLen), memNeed(retOst, retLen)), 0)
- energyCost_2 = energeCost_1 + penalty(energyCost_1)
- energyLimitLeft = energeLimit - energyCost_2
- energyCost = energyCost_2 + min(callEnergy, energyLimitLeft)
A16: CREATE2 能量消耗
CREATE2 能量消耗energyCost=32000 + calcMemEnergy(oldMemSIze, memNeed(ost, len), 0) + 6 * [sizeInWords](#a05-sizeinwordslen)(Len)
A17: SUICIDE 能量消耗
SUICIDE 能量消耗当前主网规则下,执行 SUICIDE 的基础能量消耗为 5,000 Energy。如果指定的余额接收地址尚未激活,还需额外消耗 25,000 Energy 作为账户创建费用。
Updated about 2 months ago
