Skip to content

Latest commit

 

History

History
2591 lines (1671 loc) · 115 KB

taiko-2024-03.md

File metadata and controls

2591 lines (1671 loc) · 115 KB

Gas Optimizations

Issue Instances
GAS-2 abi.encode is more efficient than abi.encodePacked 21
GAS-3 With assembly, .call (bool success) transfer can be done gas-optimized 1
GAS-4 Use assembly to emit events 56
GAS-5 Use assembly for small keccak256 hashes, in order to save gas 7
GAS-6 Redundant event fields can be removed 1
GAS-7 Use uint256(1)/uint256(2) instead for true and false boolean states 10
GAS-9 For Operations that will not overflow, you could use unchecked 82
GAS-12 Use of emit inside a loop 3
GAS-13 >=/ <= costs less gas than >/< 96
GAS-14 Use hardcode address instead of address(this) 39
GAS-15 uint256 variable initialization to default value of 0 can be omitted 13
GAS-16 Long revert strings 1
GAS-17 Constructors can be marked payable 3
GAS-22 Usage of smaller uint/int types causes overhead 302
GAS-24 Using this to access functions results in an external call, wasting gas 3

Total: 786 instances over 26 issues

[GAS-2] abi.encode is more efficient than abi.encodePacked

abi.encode uses less gas than abi.encodePacked: the gas saved depends on the number of arguments, with an average of ~90 per argument. Test available here.

There are 21 instances of this issue:
File: packages/protocol/contracts/L1/libs/LibProposing.sol

204:         meta_.difficulty = keccak256(abi.encodePacked(block.prevrandao, b.numBlocks, block.number));
File: packages/protocol/contracts/automata-attestation/AutomataDcapV3Attestation.sol

163:         bytes memory retData = abi.encodePacked(INVALID_EXIT_CODE);

315:             abi.encodePacked(authDataV3.ecdsaAttestationKey, authDataV3.qeAuthData.data);

369:         bytes memory retData = abi.encodePacked(INVALID_EXIT_CODE);

482:         retData = abi.encodePacked(sha256(abi.encode(v3quote)), tcbStatus);
File: packages/protocol/contracts/automata-attestation/lib/PEMCertChainLib.sol

181:             cert.signature = abi.encodePacked(sigX, sigY);
File: packages/protocol/contracts/automata-attestation/lib/QuoteV3Auth/V3Parser.sol

119:         bytes memory headerBytes = abi.encodePacked(

129:         signedQuoteData = abi.encodePacked(headerBytes, V3Parser.packQEReport(localEnclaveReport));

251:         packedQEReport = abi.encodePacked(
File: packages/protocol/contracts/libs/Lib4844.sol

44:             abi.encodePacked(_blobHash, _x, _y, _commitment, _pointProof)
File: packages/protocol/contracts/libs/LibTrieProof.sol

48:                 SecureMerkleTrie.get(abi.encodePacked(_addr), _accountProof, _rootHash);
File: packages/protocol/contracts/signal/SignalService.sol

203:         return keccak256(abi.encodePacked("SIGNAL", _chainId, _app, _signal));
File: packages/protocol/contracts/team/TimelockTokenPool.sol

170:         bytes32 hash = keccak256(abi.encodePacked("Withdraw unlocked Taiko token to: ", _to));
File: packages/protocol/contracts/thirdparty/optimism/rlp/RLPWriter.sol

17:             out_ = abi.encodePacked(_writeLength(_in.length, 128), _in);

56:         bytes memory b = abi.encodePacked(_x);
File: packages/protocol/contracts/thirdparty/optimism/trie/MerkleTrie.sol

81:         bytes memory currentNodeID = abi.encodePacked(_root);

94:                     Bytes.equal(abi.encodePacked(keccak256(currentNode.encoded)), currentNodeID),

100:                     Bytes.equal(abi.encodePacked(keccak256(currentNode.encoded)), currentNodeID),
File: packages/protocol/contracts/thirdparty/optimism/trie/SecureMerkleTrie.sol

55:         hash_ = abi.encodePacked(keccak256(_key));
File: packages/protocol/contracts/tokenvault/BridgedERC721.sol

109:             abi.encodePacked(
File: packages/protocol/contracts/tokenvault/LibBridgedToken.sol

54:             abi.encodePacked(

[204] ,[163] ,[315] ,[369] ,[482] ,[181] ,[119] ,[129] ,[251] ,[44] ,[48] ,[203] ,[170] ,[17] ,[56] ,[81] ,[94] ,[100] ,[55] ,[109] ,[54] ,

[GAS-3] With assembly, .call (bool success) transfer can be done gas-optimized

When using assembly language, it is possible to call the transfer function of an Ethereum contract in a gas-optimized way by using the .call function with specific input parameters. The .call function takes a number of input parameters, including the address of the contract to call, the amount of Ether to transfer, and a specification of the gas limit for the call. By specifying a lower gas limit than the default, it is possible to reduce the gas cost of the transfer.

Instances of this issue:

File: packages/protocol/contracts/L2/CrossChainOwned.sol

50:         (bool success,) = address(this).call(txdata);

[50] ,

[GAS-4] Use assembly to emit events

We can use assembly to emit events efficiently by utilizing scratch space and the free memory pointer. This will allow us to potentially avoid memory expansion costs. Note: In order to do this optimization safely, we will need to cache and restore the free memory pointer.

There are 56 instances of this issue:
File: packages/protocol/contracts/L1/hooks/AssignmentHook.sol

129:         emit BlockAssigned(_blk.assignedProver, _meta, assignment);
File: packages/protocol/contracts/L1/libs/LibDepositing.sol

50:         emit EthDeposited(
File: packages/protocol/contracts/L1/libs/LibProposing.sol

166:                     emit BlobCached(meta_.blobHash);

273:         emit BlockProposed({
File: packages/protocol/contracts/L1/libs/LibProving.sol

80:         emit ProvingPaused(_pause);

209:             emit TransitionProved({

230:                 emit TransitionProved({

254:                 emit TransitionContested({
File: packages/protocol/contracts/L1/libs/LibVerifying.sol

73:         emit BlockVerified({

198:                 emit BlockVerified({
File: packages/protocol/contracts/L1/provers/GuardianProver.sol

54:         emit GuardianApproval(msg.sender, _meta.id, _tran.blockHash, approved_);
File: packages/protocol/contracts/L1/provers/Guardians.sol

95:         emit GuardiansUpdated(version, _newGuardians);

121:         emit Approved(_operationId, _approval, approved_);
File: packages/protocol/contracts/L2/CrossChainOwned.sol

53:         emit TransactionExecuted(nextTxId++, bytes4(txdata));
File: packages/protocol/contracts/L2/TaikoL2.sol

157:         emit Anchored(blockhash(parentId), gasExcess); //@audit do not emit state 

157:         emit Anchored(blockhash(parentId), gasExcess); //@audit do not emit state 
File: packages/protocol/contracts/L2/TaikoL2EIP1559Configurable.sol

39:         emit ConfigAndExcessChanged(_newConfig, _newGasExcess);
File: packages/protocol/contracts/bridge/Bridge.sol

93:             emit MessageSuspended(msgHash, _suspend);

111:         emit AddressBanned(_addr, _ban);

151:         emit MessageSent(msgHash_, message_);

208:             emit MessageRecalled(msgHash);

210:             emit MessageReceived(msgHash, _message, true);

301:             emit MessageExecuted(msgHash);

303:             emit MessageReceived(msgHash, _message, false);

336:         emit MessageRetried(msgHash);

519:         emit MessageStatusChanged(_msgHash, _status);
File: packages/protocol/contracts/common/AddressManager.sol

50:         emit AddressSet(_chainId, _name, _newAddress, oldAddress);
File: packages/protocol/contracts/common/EssentialContract.sol

71:         emit Paused(msg.sender);

80:         emit Unpaused(msg.sender);
File: packages/protocol/contracts/signal/SignalService.sol

59:         emit Authorized(_addr, _authorize);

250:         emit ChainDataSynced(_chainId, _blockId, _kind, _chainData, signal_);

268:         emit SignalSent(_app, _signal, slot_, _value);
File: packages/protocol/contracts/team/TimelockTokenPool.sol

143:         emit Granted(_recipient, _grant);

157:         emit Voided(_recipient, amountVoided);

222:         emit Withdrawn(_recipient, _to, amountToWithdraw, costToWithdraw);
File: packages/protocol/contracts/team/airdrop/ERC20Airdrop2.sol

93:         emit Withdrawn(user, amount);
File: packages/protocol/contracts/team/airdrop/MerkleClaimable.sol

74:         emit Claimed(hash);
File: packages/protocol/contracts/tokenvault/BridgedERC20Base.sol

51:         emit MigrationStatusChanged(_migratingAddress, _migratingInbound);

63:             emit MigratedTo(_migratingAddress, _account, _amount); //@audit cache migratingAddress

81:             emit MigratedTo(_migratingAddress, _account, _amount); 
File: packages/protocol/contracts/tokenvault/ERC1155Vault.sol

80:         emit TokenSent({

114:         emit TokenReceived({

149:         emit TokenReleased({

314:         emit BridgedTokenDeployed({
File: packages/protocol/contracts/tokenvault/ERC20Vault.sol

191:         emit BridgedTokenChanged({

241:         emit TokenSent({

273:         emit TokenReceived({

306:         emit TokenReleased({

425:         emit BridgedTokenDeployed({
File: packages/protocol/contracts/tokenvault/ERC721Vault.sol

64:         emit TokenSent({

97:         emit TokenReceived({

131:         emit TokenReleased({

250:         emit BridgedTokenDeployed({
File: packages/protocol/contracts/verifiers/SgxVerifier.sol

109:             emit InstanceDeleted(idx, instances[idx].addr);

220:             emit InstanceAdded(nextInstanceId, _instances[i], address(0), validSince);

230:         emit InstanceAdded(id, newInstance, oldInstance, block.timestamp);

[129] ,[50] ,[166] ,[273] ,[80] ,[209] ,[230] ,[254] ,[73] ,[198] ,[54] ,[95] ,[121] ,[53] ,[157] ,[157] ,[39] ,[93] ,[111] ,[151] ,[208] ,[210] ,[301] ,[303] ,[336] ,[519] ,[50] ,[71] ,[80] ,[59] ,[250] ,[268] ,[143] ,[157] ,[222] ,[93] ,[74] ,[51] ,[63] ,[81] ,[80] ,[114] ,[149] ,[314] ,[191] ,[241] ,[273] ,[306] ,[425] ,[64] ,[97] ,[131] ,[250] ,[109] ,[220] ,[230] ,

[GAS-5] Use assembly for small keccak256 hashes, in order to save gas

Use assembly for small keccak256 hashes, in order to save gas

Instances of this issue:

File: packages/protocol/contracts/L1/libs/LibProposing.sol

126:                 depositsHash: keccak256(abi.encode(deposits_)),

213:             metaHash: keccak256(abi.encode(meta_)),
File: packages/protocol/contracts/L1/libs/LibProving.sol

121:         if (blk.blockId != _meta.id || blk.metaHash != keccak256(abi.encode(_meta))) {
File: packages/protocol/contracts/L1/provers/GuardianProver.sol

46:         bytes32 hash = keccak256(abi.encode(_meta, _tran));
File: packages/protocol/contracts/bridge/Bridge.sol

450:         return keccak256(abi.encode("TAIKO_MESSAGE", _message));
File: packages/protocol/contracts/signal/SignalService.sol

186:         return keccak256(abi.encode(_chainId, _kind, _blockId));
File: packages/protocol/contracts/team/airdrop/MerkleClaimable.sol

68:         bytes32 hash = keccak256(abi.encode("CLAIM_TAIKO_AIRDROP", data));

[126] ,[213] ,[121] ,[46] ,[450] ,[186] ,[68] ,

[GAS-6] Redundant event fields can be removed

Some parameters (block.timestamp and block.number) are added to event information by default so re-adding them wastes gas, as they are already included.

Instances of this issue:

File: packages/protocol/contracts/verifiers/SgxVerifier.sol

230:         emit InstanceAdded(id, newInstance, oldInstance, block.timestamp);

[230] ,

[GAS-9] For Operations that will not overflow, you could use unchecked

There are 82 instances of this issue:

X * 2 is equivalent to X << 1 and X / 2 is the same as X >> 1. The MUL and DIV opcodes cost 5 gas, whereas SHL and SHR only cost 3 gas.

Instances of this issue:

File: packages/protocol/contracts/L1/libs/LibProposing.sol

21:     uint256 public constant MAX_BYTES_PER_BLOB = 4096 * 32;
File: packages/protocol/contracts/L1/libs/LibVerifying.sol

251:                 || _config.blockMaxTxListBytes > 128 * 1024 // calldata up to 128K
File: packages/protocol/contracts/L2/TaikoL2.sol

213:         config_.gasTargetPerL1Block = 15 * 1e6 * 4;
File: packages/protocol/contracts/automata-attestation/lib/PEMCertChainLib.sol

359:                 ? uint16(bytes2(svnValueBytes)) / 256
File: packages/protocol/contracts/automata-attestation/lib/QuoteV3Auth/V3Parser.sol

155:             uint256 upperDigit = digits / 16;
File: packages/protocol/contracts/automata-attestation/utils/Asn1Decode.sol

145:         return uint256(der.readBytesN(ptr.ixf(), len) >> (32 - len) * 8);

203:                     der.readBytesN(ix + 2, lengthbytesLength) >> (32 - lengthbytesLength) * 8

[21] ,[251] ,[213] ,[359] ,[155] ,[145] ,[203] ,

[GAS-12] Use of emit inside a loop

Emitting an event inside a loop performs a LOG op N times, where N is the loop length. Consider refactoring the code to emit the event only once at the end of loop. Gas savings should be multiplied by the average loop length.

Instances of this issue:

File: packages/protocol/contracts/bridge/Bridge.sol

90:         for (uint256 i; i < _msgHashes.length; ++i) {
File: packages/protocol/contracts/verifiers/SgxVerifier.sol

104:         for (uint256 i; i < _ids.length; ++i) {

210:         for (uint256 i; i < _instances.length; ++i) {

[90] ,[104] ,[210] ,

[GAS-13] >=/ <= costs less gas than >/<

The compiler uses opcodes GT and ISZERO for solidity code that uses >, but only requires LT for >=,which saves 3 gas

There are 96 instances of this issue:
File: packages/protocol/contracts/L1/hooks/AssignmentHook.sol

82:             block.timestamp > assignment.expiry

85:                 || assignment.maxBlockId != 0 && _meta.id > assignment.maxBlockId

86:                 || assignment.maxProposedIn != 0 && block.number > assignment.maxProposedIn

125:         if (address(this).balance > 0) { //@audit use assembly
File: packages/protocol/contracts/L1/libs/LibDepositing.sol

89:                     recipient: address(uint160(data >> 96)),

93:                 uint96 _fee = deposits_[i].amount > fee ? fee : deposits_[i].amount;

139:             return _amount >= _config.ethDepositMinAmount && _amount <= _config.ethDepositMaxAmount

150:         if (_amount > type(uint96).max) revert L1_INVALID_ETH_DEPOSIT();
File: packages/protocol/contracts/L1/libs/LibProposing.sol

98:         if (b.numBlocks >= b.lastVerifiedBlockId + _config.blockMaxProposals + 1) {

171:             if (uint256(params.txListByteOffset) + params.txListByteSize > MAX_BYTES_PER_BLOB) {

195:         if (meta_.txListByteSize == 0 || meta_.txListByteSize > _config.blockMaxTxListBytes) {

296:         return _state.reusableBlobs[_blobHash] + _config.blobExpiry > block.timestamp;
File: packages/protocol/contracts/L1/libs/LibProving.sol

111:         if (_meta.id <= b.lastVerifiedBlockId || _meta.id >= b.numBlocks) {

192:             bool returnLivenessBond = blk.livenessBond > 0 && _proof.data.length == 32

203:         if (_proof.tier > ts.tier) {

366:                 reward = _ts.contestBond >> 2;

370:                 reward = _ts.validityBond >> 2;

376:             reward = _ts.validityBond >> 1;

381:             if (reward > _tier.validityBond) {

415:             + _tier.provingWindow * 60 >= block.timestamp;
File: packages/protocol/contracts/L1/libs/LibUtils.sol

34:         if (_blockId < b.lastVerifiedBlockId || _blockId >= b.numBlocks) {

86:         if (tid_ >= _blk.nextTransitionId) revert L1_UNEXPECTED_TRANSITION_ID();
File: packages/protocol/contracts/L1/libs/LibVerifying.sol

185:                     bondToReturn -= blk.livenessBond >> 1;

212:             if (numBlocksVerified > 0) {

238:         if (_lastVerifiedBlockId > lastSyncedBlock + _config.blockSyncThreshold) {

251:                 || _config.blockMaxTxListBytes > 128 * 1024 // calldata up to 128K

256:             || _config.ethDepositMaxCountPerBlock > 32

260:                 || _config.ethDepositMaxAmount > type(uint96).max || _config.ethDepositGas == 0

262:                 || _config.ethDepositMaxFee > type(uint96).max / _config.ethDepositMaxCountPerBlock
File: packages/protocol/contracts/L1/provers/Guardians.sol

63:         if (_newGuardians.length < MIN_NUM_GUARDIANS || _newGuardians.length > type(uint8).max) {

68:         if (_minGuardians < (_newGuardians.length + 1) >> 1 || _minGuardians > _newGuardians.length)

136:                 bits >>= 1;
File: packages/protocol/contracts/L2/Lib1559Math.sol

42:         if (input > LibFixedPointMath.MAX_EXP_INPUT) {
File: packages/protocol/contracts/L2/TaikoL2.sol

82:         if (block.chainid <= 1 || block.chainid > type(uint64).max) {

145:         if (_l1BlockId > lastSyncedBlock + BLOCK_SYNC_THRESHOLD) {

201:         if (_blockId >= block.number) return 0; //@audit we can cache block.number

202:         if (_blockId + 256 >= block.number) return blockhash(_blockId);

234:             for (uint256 i; i < 255 && _blockId >= i + 1; ++i) {

263:         if (_gasExcess > 0) {

277:             if (_lastSyncedBlock > 0 && _l1BlockId > _lastSyncedBlock) { //@audit cache state variable

277:             if (_lastSyncedBlock > 0 && _l1BlockId > _lastSyncedBlock) { //@audit cache state variable

281:             if (numL1Blocks > 0) {

283:                 excess = excess > issuance ? excess - issuance : 1;
File: packages/protocol/contracts/automata-attestation/AutomataDcapV3Attestation.sol

216:             bool pceSvnIsHigherOrGreater = pck.sgxExtension.pcesvn >= current.pcesvn;

280:                 block.timestamp > certs[i].notBefore && block.timestamp < certs[i].notAfter;
File: packages/protocol/contracts/automata-attestation/lib/PEMCertChainLib.sol

56:             if (i > 0) {
File: packages/protocol/contracts/automata-attestation/lib/QuoteV3Auth/V3Parser.sol

116:         require(totalQuoteSize >= MINIMUM_QUOTE_LENGTH, "Invalid quote size");

218:         if (cert.certType < 1 || cert.certType > 5) {

249:         uint16 isvProdIdPackBE = (enclaveReport.isvProdId >> 8) | (enclaveReport.isvProdId << 8);

250:         uint16 isvSvnPackBE = (enclaveReport.isvSvn >> 8) | (enclaveReport.isvSvn << 8);
File: packages/protocol/contracts/automata-attestation/utils/Asn1Decode.sol

20:         return uint80(self >> 80);

25:         return uint80(self >> 160);
File: packages/protocol/contracts/automata-attestation/utils/BytesUtils.sol

90:                 if (shortest > 32) {

169:         return self.length >= offset + other.length && equals(self, offset, other, 0, other.length);

335:             require(char >= 0x30 && char <= 0x7A, "invalid char");

350:             ret = (ret << 3) | (decoded >> 2);

354:             ret = (ret << 1) | (decoded >> 4);

358:             ret = (ret << 4) | (decoded >> 1);

362:             ret = (ret << 2) | (decoded >> 3);
File: packages/protocol/contracts/bridge/Bridge.sol

189:         if (block.timestamp >= invocationDelay + receivedAt) {

258:         if (block.timestamp >= invocationDelay + receivedAt) {

439:         } else if (block.chainid >= 32_300 && block.chainid <= 32_400) {

491:             _message.data.length >= 4 // msg can be empty
File: packages/protocol/contracts/libs/Lib4844.sol

40:         if (_x >= BLS_MODULUS) revert POINT_X_TOO_LARGE();

41:         if (_y >= BLS_MODULUS) revert POINT_Y_TOO_LARGE();
File: packages/protocol/contracts/libs/LibMath.sol

13:         return _a > _b ? _b : _a;

21:         return _a > _b ? _a : _b;
File: packages/protocol/contracts/signal/SignalService.sol

120:             bool isFullProof = hop.accountProof.length > 0;
File: packages/protocol/contracts/team/TimelockTokenPool.sol

260:         if (block.timestamp >= _start + _period) return _amount;

275:             if (_cliff > 0) revert INVALID_GRANT();

277:             if (_cliff > 0 && _cliff <= _start) revert INVALID_GRANT();

278:             if (_cliff >= _start + _period) revert INVALID_GRANT();
File: packages/protocol/contracts/team/airdrop/ERC20Airdrop2.sol

40:         if (claimEnd > block.timestamp || claimEnd + withdrawalWindow < block.timestamp) {
File: packages/protocol/contracts/team/airdrop/MerkleClaimable.sol

35:             merkleRoot == 0x0 || claimStart == 0 || claimEnd == 0 || claimStart > block.timestamp
File: packages/protocol/contracts/thirdparty/optimism/Bytes.sol

25:             require(_length + 31 >= _length, "slice_overflow");

26:             require(_start + _length >= _start, "slice_overflow");

27:             require(_bytes.length >= _start + _length, "slice_outOfBounds");

92:         if (_start >= _bytes.length) { //@audit cache length
File: packages/protocol/contracts/thirdparty/optimism/rlp/RLPReader.sol

38:             _in.length > 0,

153:             _in.length > 0,

173:                 _in.length > strLen,

183:                 strLen != 1 || firstByteOfContent >= 0x80,

193:                 _in.length > lenOfStrLen,

194:                 "RLPReader: length of content must be > than length of string length (long string)"

213:                 strLen > 55,

218:                 _in.length > lenOfStrLen + strLen,

229:                 _in.length > listLen,

239:                 _in.length > lenOfListLen,

240:                 "RLPReader: length of content must be > than length of list length (long list)"

259:                 listLen > 55,

264:                 _in.length > lenOfListLen + listLen,
File: packages/protocol/contracts/thirdparty/optimism/trie/MerkleTrie.sol

77:         require(_key.length > 0, "MerkleTrie: empty key");

97:             } else if (currentNode.encoded.length >= 32) {

120:                         value_.length > 0,

173:                         value_.length > 0,
File: packages/protocol/contracts/tokenvault/BaseNFTVault.sol

145:         if (_op.tokenIds.length > MAX_TOKEN_PER_TXN) {

[82] ,[85] ,[86] ,[125] ,[89] ,[93] ,[139] ,[150] ,[98] ,[171] ,[195] ,[296] ,[111] ,[192] ,[203] ,[366] ,[370] ,[376] ,[381] ,[415] ,[34] ,[86] ,[185] ,[212] ,[238] ,[251] ,[256] ,[260] ,[262] ,[63] ,[68] ,[136] ,[42] ,[82] ,[145] ,[201] ,[202] ,[234] ,[263] ,[277] ,[277] ,[281] ,[283] ,[216] ,[280] ,[56] ,[116] ,[218] ,[249] ,[250] ,[20] ,[25] ,[90] ,[169] ,[335] ,[350] ,[354] ,[358] ,[362] ,[189] ,[258] ,[439] ,[491] ,[40] ,[41] ,[13] ,[21] ,[120] ,[260] ,[275] ,[277] ,[278] ,[40] ,[35] ,[25] ,[26] ,[27] ,[92] ,[38] ,[153] ,[173] ,[183] ,[193] ,[194] ,[213] ,[218] ,[229] ,[239] ,[240] ,[259] ,[264] ,[77] ,[97] ,[120] ,[173] ,[145] ,

[GAS-14] Use hardcode address instead of address(this)

Instead of using address(this), it is more gas-efficient to pre-calculate and use the hardcoded address. Foundry’s script.sol and solmate’s LibRlp.sol contracts can help achieve this. References: https://book.getfoundry.sh/reference/forge-std/compute-create-address

There are 39 instances of this issue:
File: packages/protocol/contracts/L1/TaikoToken.sol

61:         if (_to == address(this)) revert TKO_INVALID_ADDR();

79:         if (_to == address(this)) revert TKO_INVALID_ADDR();
File: packages/protocol/contracts/L1/hooks/AssignmentHook.sol

125:         if (address(this).balance > 0) { //@audit use assembly

126:             taikoL1Address.sendEther(address(this).balance);

151:                 address(this),
File: packages/protocol/contracts/L1/libs/LibProposing.sol

238:             uint256 tkoBalance = tko.balanceOf(address(this));

253:                 IHook(params.hookCalls[i].hook).onBlockProposed{ value: address(this).balance }(

260:             if (address(this).balance != 0) {

261:                 msg.sender.sendEther(address(this).balance);

268:             if (tko.balanceOf(address(this)) != tkoBalance + _config.livenessBond) {
File: packages/protocol/contracts/L1/libs/LibProving.sol

242:                 tko.transferFrom(msg.sender, address(this), tier.contestBond);

384:                 _tko.transferFrom(msg.sender, address(this), _tier.validityBond - reward);
File: packages/protocol/contracts/L2/CrossChainOwned.sol

50:         (bool success,) = address(this).call(txdata);
File: packages/protocol/contracts/L2/TaikoL2.sol

174:             _to.sendEther(address(this).balance);

176:             IERC20(_token).safeTransfer(_to, IERC20(_token).balanceOf(address(this)));
File: packages/protocol/contracts/bridge/Bridge.sol

174:             if (!ISignalService(signalService).isSignalSent(address(this), msgHash)) {

196:                 _storeContext(msgHash, address(this), _message.srcChainId);

343:             _app: address(this),

486:         assert(_message.from != address(this));
File: packages/protocol/contracts/signal/SignalService.sol

112:                 signalService = address(this);

131:         if (value == 0 || value != _loadSignalValue(address(this), signal)) {

149:         return _loadSignalValue(address(this), signal) == _chainData;

171:             chainData_ = _loadSignalValue(address(this), signal);

245:         _sendSignal(address(this), signal_, _chainData);
File: packages/protocol/contracts/tokenvault/BridgedERC1155.sol

137:         if (_to == address(this)) revert BTOKEN_CANNOT_RECEIVE();
File: packages/protocol/contracts/tokenvault/BridgedERC20.sol

147:         if (_to == address(this)) revert BTOKEN_CANNOT_RECEIVE();
File: packages/protocol/contracts/tokenvault/BridgedERC721.sol

125:         if (_to == address(this)) revert BTOKEN_CANNOT_RECEIVE();
File: packages/protocol/contracts/tokenvault/ERC1155Vault.sol

108:         if (to == address(0) || to == address(this)) revert VAULT_INVALID_TO();

226:             IERC1155(token).safeBatchTransferFrom(address(this), to, tokenIds, amounts, "");

272:                         to: address(this),
File: packages/protocol/contracts/tokenvault/ERC20Vault.sol

267:         if (to == address(0) || to == address(this)) revert VAULT_INVALID_TO();

378:             uint256 _balance = t.balanceOf(address(this));

379:             t.safeTransferFrom({ from: msg.sender, to: address(this), value: _amount });

380:             balanceChange_ = t.balanceOf(address(this)) - _balance;
File: packages/protocol/contracts/tokenvault/ERC721Vault.sol

91:         if (to == address(0) || to == address(this)) revert VAULT_INVALID_TO();

171:                 IERC721(token_).safeTransferFrom(address(this), _to, _tokenIds[i]);

211:                     t.safeTransferFrom(_user, address(this), _op.tokenIds[i]);
File: packages/protocol/contracts/tokenvault/adapters/USDCAdapter.sol

48:         usdc.transferFrom(_from, address(this), _amount);
File: packages/protocol/contracts/verifiers/SgxVerifier.sol

186:                 address(this),

[61] ,[79] ,[125] ,[126] ,[151] ,[238] ,[253] ,[260] ,[261] ,[268] ,[242] ,[384] ,[50] ,[174] ,[176] ,[174] ,[196] ,[343] ,[486] ,[112] ,[131] ,[149] ,[171] ,[245] ,[137] ,[147] ,[125] ,[108] ,[226] ,[272] ,[267] ,[378] ,[379] ,[380] ,[91] ,[171] ,[211] ,[48] ,[186] ,

[GAS-15] uint256 variable initialization to default value of 0 can be omitted

There is no need to initialize variables to their default values during declaration, since they are any way initialized to default value once declared.

There are 13 instances of this issue:
File: packages/protocol/contracts/L1/provers/Guardians.sol

80:         for (uint256 i = 0; i < _newGuardians.length; ++i) {
File: packages/protocol/contracts/automata-attestation/lib/PEMCertChainLib.sol

51:         uint256 index = 0;
File: packages/protocol/contracts/automata-attestation/lib/QuoteV3Auth/V3Parser.sol

18:     bytes4 internal constant SUPPORTED_TEE_TYPE = 0;
File: packages/protocol/contracts/automata-attestation/utils/BytesUtils.sol

80:         for (uint256 idx = 0; idx < shortest; idx += 32) {

331:         uint256 ret = 0;
File: packages/protocol/contracts/automata-attestation/utils/X509DateUtils.sol

46:         uint256 timestamp = 0;
File: packages/protocol/contracts/thirdparty/optimism/rlp/RLPReader.sol

72:         uint256 itemCount = 0;
File: packages/protocol/contracts/thirdparty/optimism/rlp/RLPWriter.sol

58:         uint256 i = 0;

66:         for (uint256 j = 0; j < out_.length; j++) {
File: packages/protocol/contracts/thirdparty/optimism/trie/MerkleTrie.sol

30:     uint8 internal constant PREFIX_EXTENSION_EVEN = 0;

82:         uint256 currentKeyIndex = 0; //@info can we initilize   

85:         for (uint256 i = 0; i < proof.length; i++) {

208:         for (uint256 i = 0; i < length;) {

[80] ,[51] ,[18] ,[80] ,[331] ,[46] ,[72] ,[58] ,[66] ,[30] ,[82] ,[85] ,[208] ,

[GAS-16] Long revert strings

Instances of this issue:

File: packages/protocol/contracts/thirdparty/optimism/trie/MerkleTrie.sol

89:             require(currentKeyIndex <= key.length, "MerkleTrie: key index exceeds total key length");

[89] ,

[GAS-17] Constructors can be marked payable

Payable functions cost less gas to execute, since the compiler does not have to add extra checks to ensure that a payment was not provided. A constructor can safely be marked as payable, since only the deployer would be able to pass funds, and the project itself would not pass any funds.

Instances of this issue:

File: packages/protocol/contracts/automata-attestation/AutomataDcapV3Attestation.sol

54:     constructor(address sigVerifyLibAddr, address pemCertLibAddr) {
File: packages/protocol/contracts/automata-attestation/utils/SigVerifyLib.sol

20:     constructor(address es256Verifier) {
File: packages/protocol/contracts/common/EssentialContract.sol

64:     constructor() {

[54] ,[20] ,[64] ,

Instances of this issue:

File: packages/protocol/contracts/automata-attestation/lib/PEMCertChainLib.sol

358:             uint16 svnValue = svnValueBytes.length < 2

[358] ,

[GAS-22] Usage of smaller uint/int types causes overhead

When using a smaller int/uint type it first needs to be converted to it's 258 bit counterpart to be operated, this increases the gass cost and thus should be avoided. However it does make sense to use smaller int/uint values within structs provided you pack the struct properly.

There are 302 instances of this issue:
File: packages/protocol/contracts/L1/ITaikoL1.sol

27:     function proveBlock(uint64 _blockId, bytes calldata _input) external;

31:     function verifyBlocks(uint64 _maxBlocksToVerify) external;
File: packages/protocol/contracts/L1/TaikoData.sol

15:         uint64 chainId;

20:         uint64 blockMaxProposals;

22:         uint64 blockRingBufferSize;

24:         uint64 maxBlocksToVerifyPerProposal;

26:         uint32 blockMaxGasLimit;

46:         uint64 ethDepositMinCountPerBlock;

48:         uint64 ethDepositMaxCountPerBlock;

59:         uint8 blockSyncThreshold; //@audit

64:         uint16 tier;

65:         uint128 fee;

69:         uint16 tier;

101:         uint64 id;

102:         uint32 gasLimit;

103:         uint64 timestamp; // slot 7

104:         uint64 l1Height;

107:         uint16 minTier;

130:         uint64 timestamp; // slot 6 (90 bits)

131:         uint16 tier;

132:         uint8 contestations;

141:         uint64 blockId; // slot 3

142:         uint64 proposedAt; // timestamp

143:         uint64 proposedIn; // L1 block number

144:         uint32 nextTransitionId;

145:         uint32 verifiedTransitionId;

153:         uint64 id;

162:         uint64 genesisHeight;

163:         uint64 genesisTimestamp;

164:         uint64 numEthDeposits;

165:         uint64 nextEthDepositToProcess;

169:         uint64 numBlocks;

170:         uint64 lastVerifiedBlockId;

172:         uint8 __reserved1;

173:         uint16 __reserved2;

174:         uint32 __reserved3;                 

175:         uint64 lastUnpausedAt;

181:         mapping(uint64 blockId_mod_blockRingBufferSize => Block blk) blocks;

183:         mapping(uint64 blockId => mapping(bytes32 parentHash => uint32 transitionId)) transitionIds;

183:         mapping(uint64 blockId => mapping(bytes32 parentHash => uint32 transitionId)) transitionIds;

186:             uint64 blockId_mod_blockRingBufferSize

187:                 => mapping(uint32 transitionId => TransitionState ts)
File: packages/protocol/contracts/L1/TaikoEvents.sol

43:         uint16 tier,

44:         uint8 contestations

58:         uint16 tier

72:         uint16 tier
File: packages/protocol/contracts/L1/TaikoL1.sol

76:         uint64 _blockId,

94:         uint8 maxBlocksToVerify = LibProving.proveBlock(state, config, this, meta, tran, proof);

100:     function verifyBlocks(uint64 _maxBlocksToVerify)

145:     function getBlock(uint64 _blockId)

150:         uint64 slot;

163:         uint64 _blockId,
File: packages/protocol/contracts/L1/hooks/AssignmentHook.sol

166:         uint16 _tierId
File: packages/protocol/contracts/L1/libs/LibDepositing.sol

84:             uint64 j = _state.slotA.nextEthDepositToProcess;
File: packages/protocol/contracts/L1/libs/LibProving.sol

37:         uint16 tier

51:         uint16 tier

100:         returns (uint8 maxBlocksToVerify_)

115:         uint64 slot = _meta.id % _config.blockRingBufferSize;

129:         (uint32 tid, TaikoData.TransitionState storage ts) =

273:         uint64 slot

276:         returns (uint32 tid_, TaikoData.TransitionState storage ts_)

405:         uint32 _tid,
File: packages/protocol/contracts/L1/libs/LibUtils.sol

26:         uint64 _blockId,

38:         uint64 slot = _blockId % _config.blockRingBufferSize;

42:         uint32 tid = getTransitionId(_state, blk, slot, _parentHash);

55:         uint64 _blockId

59:         returns (TaikoData.Block storage blk_, uint64 slot_)

73:         uint64 _slot,

78:         returns (uint32 tid_)
File: packages/protocol/contracts/L1/libs/LibVerifying.sol

34:         uint16 tier,

35:         uint8 contestations

89:         uint64 _maxBlocksToVerify

100:         uint64 blockId = b.lastVerifiedBlockId;

102:         uint64 slot = blockId % _config.blockRingBufferSize;

107:         uint32 tid = blk.verifiedTransitionId;

117:         uint64 numBlocksVerified;

213:                 uint64 lastVerifiedBlockId = b.lastVerifiedBlockId + numBlocksVerified;

227:         uint64 _lastVerifiedBlockId,

234:         (uint64 lastSyncedBlock,) = signalService.getSyncedChainData(
File: packages/protocol/contracts/L1/provers/Guardians.sol

19:     mapping(uint32 version => mapping(bytes32 hash => uint256 approvalBits)) internal _approvals;

27:     uint32 public version;

30:     uint32 public minGuardians;

37:     event GuardiansUpdated(uint32 version, address[] guardians);

55:         uint8 _minGuardians
File: packages/protocol/contracts/L1/tiers/DevnetTierProvider.sol

20:     function getTier(uint16 _tierId) public pure override returns (ITierProvider.Tier memory) {
File: packages/protocol/contracts/L1/tiers/ITierProvider.sol

13:         uint16 provingWindow; // in minutes

14:         uint8 maxBlocksToVerifyPerProof;

22:     function getTier(uint16 tierId) external view returns (Tier memory);

39:     uint16 public constant TIER_OPTIMISTIC = 100;

42:     uint16 public constant TIER_SGX = 200;

45:     uint16 public constant TIER_SGX_ZKVM = 300;

48:     uint16 public constant TIER_GUARDIAN = 1000;
File: packages/protocol/contracts/L1/tiers/MainnetTierProvider.sol

20:     function getTier(uint16 _tierId) public pure override returns (ITierProvider.Tier memory) {
File: packages/protocol/contracts/L1/tiers/TestnetTierProvider.sol

20:     function getTier(uint16 _tierId) public pure override returns (ITierProvider.Tier memory) {
File: packages/protocol/contracts/L2/CrossChainOwned.sol

16:     uint64 public ownerChainId;

19:     uint64 public nextTxId;

26:     event TransactionExecuted(uint64 indexed txId, bytes4 indexed selector);

42:         (uint64 txId, bytes memory txdata) = abi.decode(_data, (uint64, bytes));

63:         uint64 _ownerChainId
File: packages/protocol/contracts/L2/TaikoL2.sol

27:         uint32 gasTargetPerL1Block;

28:         uint8 basefeeAdjustmentQuotient;

35:     uint8 public constant BLOCK_SYNC_THRESHOLD = 5;

47:     uint64 public gasExcess;

50:     uint64 public lastSyncedBlock;

57:     event Anchored(bytes32 parentHash, uint64 gasExcess);

74:         uint64 _l1ChainId,

75:         uint64 _gasExcess

110:         uint64 _l1BlockId,

111:         uint32 _parentGasUsed

186:         uint64 _l1BlockId,

187:         uint32 _parentGasUsed

200:     function getBlockHash(uint64 _blockId) public view returns (bytes32) {

254:         uint64 _l1BlockId,

255:         uint32 _parentGasUsed

259:         returns (uint256 basefee_, uint64 gasExcess_)
File: packages/protocol/contracts/L2/TaikoL2EIP1559Configurable.sol

18:     event ConfigAndExcessChanged(Config config, uint64 gasExcess);

27:         uint64 _newGasExcess
File: packages/protocol/contracts/automata-attestation/AutomataDcapV3Attestation.sol

36:     uint8 internal constant INVALID_EXIT_CODE = 255; //@audit pack with address
File: packages/protocol/contracts/automata-attestation/lib/EnclaveIdStruct.sol

10:         uint16 isvprodid;

23:         uint16 isvsvn;
File: packages/protocol/contracts/automata-attestation/lib/PEMCertChainLib.sol

358:             uint16 svnValue = svnValueBytes.length < 2
File: packages/protocol/contracts/automata-attestation/lib/QuoteV3Auth/V3Parser.sol

106:         uint32 totalQuoteSize = 48 // header

249:         uint16 isvProdIdPackBE = (enclaveReport.isvProdId >> 8) | (enclaveReport.isvProdId << 8);

250:         uint16 isvSvnPackBE = (enclaveReport.isvSvn >> 8) | (enclaveReport.isvSvn << 8);
File: packages/protocol/contracts/automata-attestation/lib/QuoteV3Auth/V3Struct.sol

26:         uint16 isvProdId;

27:         uint16 isvSvn;

34:         uint16 parsedDataSize;

39:         uint16 certType;

43:         uint32 certDataSize;
File: packages/protocol/contracts/automata-attestation/utils/Asn1Decode.sol

196:             uint8 lengthbytesLength = uint8(der[ix + 1] & 0x7F);
File: packages/protocol/contracts/automata-attestation/utils/BytesUtils.sol

188:     function readUint8(bytes memory self, uint256 idx) internal pure returns (uint8 ret) {

198:     function readUint16(bytes memory self, uint256 idx) internal pure returns (uint16 ret) {

211:     function readUint32(bytes memory self, uint256 idx) internal pure returns (uint32 ret) {

332:         uint8 decoded;
File: packages/protocol/contracts/automata-attestation/utils/X509DateUtils.sol

9:         uint16 yrs;

10:         uint8 mnths;

11:         uint8 dys;

12:         uint8 hrs;

13:         uint8 mins;

14:         uint8 secs;

15:         uint8 offset;

35:         uint16 year,

36:         uint8 month,

37:         uint8 day,

38:         uint8 hour,

39:         uint8 minute,

40:         uint8 second

48:         for (uint16 i = 1970; i < year; ++i) {

59:         for (uint8 i = 1; i < month; ++i) {

71:     function isLeapYear(uint16 year) internal pure returns (bool) {
File: packages/protocol/contracts/bridge/Bridge.sol

31:     uint128 public nextMessageId;

64:     modifier sameChain(uint64 _chainId) {

89:         uint64 _timestamp = _suspend ? type(uint64).max : uint64(block.timestamp);

168:         uint64 receivedAt = proofReceipt[msgHash].receivedAt;

230:         uint64 receivedAt = proofReceipt[msgHash].receivedAt;  //@audit cache proofReceipt[msgHash]

392:     function isDestChainEnabled(uint64 _chainId)

541:     function _storeContext(bytes32 _msgHash, address _from, uint64 _srcChainId) private {

559:             uint64 srcChainId;

580:         uint64 _chainId,
File: packages/protocol/contracts/bridge/IBridge.sol

19:         uint128 id;

24:         uint64 srcChainId;

26:         uint64 destChainId;

51:         uint64 receivedAt;

63:         uint64 srcChainId; // Source chain ID.
File: packages/protocol/contracts/common/AddressManager.sol

22:         uint64 indexed chainId, bytes32 indexed name, address newAddress, address oldAddress

39:         uint64 _chainId,

54:     function getAddress(uint64 _chainId, bytes32 _name) public view override returns (address) {
File: packages/protocol/contracts/common/EssentialContract.sol

11:     uint8 private constant _FALSE = 1;

13:     uint8 private constant _TRUE = 2; //@audit pack

21:     uint8 private __reentry;

23:     uint8 private __paused;

119:     function _storeReentryLock(uint8 _reentry) internal virtual {

130:     function _loadReentryLock() internal view virtual returns (uint8 reentry_) {
File: packages/protocol/contracts/common/IAddressManager.sol

14:     function getAddress(uint64 _chainId, bytes32 _name) external view returns (address);
File: packages/protocol/contracts/libs/Lib4844.sol

13:     uint32 public constant FIELD_ELEMENTS_PER_BLOB = 4096;
File: packages/protocol/contracts/signal/ISignalService.sol

21:         uint64 chainId;

21:         uint64 chainId;

22:         uint64 blockId;

22:         uint64 blockId;

37:         uint64 indexed chainId,

37:         uint64 indexed chainId,

38:         uint64 indexed blockId,

38:         uint64 indexed blockId,

69:         uint64 _chainId,

69:         uint64 _chainId,

71:         uint64 _blockId,

71:         uint64 _blockId,

85:         uint64 _chainId,

85:         uint64 _chainId,

106:         uint64 _chainId,

106:         uint64 _chainId,

108:         uint64 _blockId,

108:         uint64 _blockId,

123:         uint64 _chainId,

123:         uint64 _chainId,

125:         uint64 _blockId

125:         uint64 _blockId

129:         returns (uint64 blockId_, bytes32 chainData_);

129:         returns (uint64 blockId_, bytes32 chainData_);

138:         uint64 _chainId,

138:         uint64 _chainId,

140:         uint64 _blockId

140:         uint64 _blockId
File: packages/protocol/contracts/signal/SignalService.sol

17:     mapping(uint64 chainId => mapping(bytes32 kind => uint64 blockId)) public topBlockId;

17:     mapping(uint64 chainId => mapping(bytes32 kind => uint64 blockId)) public topBlockId;

69:         uint64 _chainId,

71:         uint64 _blockId,

84:         uint64 _chainId,

97:         uint64 chainId = _chainId;

138:         uint64 _chainId,

140:         uint64 _blockId,

159:         uint64 _chainId,

161:         uint64 _blockId

165:         returns (uint64 blockId_, bytes32 chainData_)

178:         uint64 _chainId,

180:         uint64 _blockId

195:         uint64 _chainId,

207:         uint64 _chainId,

236:         uint64 _chainId,

238:         uint64 _blockId,

273:         uint64 _chainId,

274:         uint64 _blockId,
File: packages/protocol/contracts/team/TimelockTokenPool.sol

29:         uint128 amount;

31:         uint128 costPerToken;

34:         uint64 grantStart;

37:         uint64 grantCliff;

40:         uint32 grantPeriod;

43:         uint64 unlockStart;

46:         uint64 unlockCliff;

49:         uint32 unlockPeriod;

53:         uint128 amountWithdrawn;

54:         uint128 costPaid;

68:     uint128 public totalAmountGranted;

71:     uint128 public totalAmountVoided;

74:     uint128 public totalAmountWithdrawn;

77:     uint128 public totalCostPaid;

92:     event Voided(address indexed recipient, uint128 amount);

99:     event Withdrawn(address indexed recipient, address to, uint128 amount, uint128 cost);

99:     event Withdrawn(address indexed recipient, address to, uint128 amount, uint128 cost);

152:         uint128 amountVoided = _voidGrant(r.grant);

180:             uint128 amountOwned,

181:             uint128 amountUnlocked,

182:             uint128 amountWithdrawn,

183:             uint128 amountToWithdraw,

184:             uint128 costToWithdraw

197:         uint128 _amountUnlocked = amountUnlocked / 1e18; // divide first

211:         (,,, uint128 amountToWithdraw, uint128 costToWithdraw) = getMyGrantSummary(_recipient);

211:         (,,, uint128 amountToWithdraw, uint128 costToWithdraw) = getMyGrantSummary(_recipient);

225:     function _voidGrant(Grant storage _grant) private returns (uint128 amountVoided) {

226:         uint128 amountOwned = _getAmountOwned(_grant);

246:         uint128 _amount,

247:         uint64 _start,

248:         uint64 _cliff,

249:         uint64 _period

273:     function _validateCliff(uint64 _start, uint64 _cliff, uint32 _period) private pure {

273:     function _validateCliff(uint64 _start, uint64 _cliff, uint32 _period) private pure {

273:     function _validateCliff(uint64 _start, uint64 _cliff, uint32 _period) private pure {
File: packages/protocol/contracts/team/airdrop/ERC20Airdrop.sol

29:         uint64 _claimStart,

30:         uint64 _claimEnd,

69:         (address delegatee, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s) =
File: packages/protocol/contracts/team/airdrop/ERC20Airdrop2.sol

28:     uint64 public withdrawalWindow;

56:         uint64 _claimStart,

57:         uint64 _claimEnd,

61:         uint64 _withdrawalWindow
File: packages/protocol/contracts/team/airdrop/ERC721Airdrop.sol

27:         uint64 _claimStart,

28:         uint64 _claimEnd,
File: packages/protocol/contracts/team/airdrop/MerkleClaimable.sol

18:     uint64 public claimStart;

21:     uint64 public claimEnd;

46:         uint64 _claimStart,

47:         uint64 _claimEnd,

57:         uint64 _claimStart,

58:         uint64 _claimEnd,

90:     function _setConfig(uint64 _claimStart, uint64 _claimEnd, bytes32 _merkleRoot) private {

90:     function _setConfig(uint64 _claimStart, uint64 _claimEnd, bytes32 _merkleRoot) private {
File: packages/protocol/contracts/thirdparty/nomad-xyz/ExcessivelySafeCall.sol

29:         uint16 _maxCopy,
File: packages/protocol/contracts/thirdparty/optimism/trie/MerkleTrie.sol

30:     uint8 internal constant PREFIX_EXTENSION_EVEN = 0;

33:     uint8 internal constant PREFIX_EXTENSION_ODD = 1;

36:     uint8 internal constant PREFIX_LEAF_EVEN = 2;

39:     uint8 internal constant PREFIX_LEAF_ODD = 3;

134:                     uint8 branchKey = uint8(key[currentKeyIndex]);

141:                 uint8 prefix = uint8(path[0]);

142:                 uint8 offset = 2 - (prefix % 2);
File: packages/protocol/contracts/tokenvault/BaseNFTVault.sol

13:         uint64 chainId;

25:         uint64 destChainId;

70:         uint64 indexed chainId,

90:         uint64 destChainId,

126:         uint64 srcChainId,
File: packages/protocol/contracts/tokenvault/BridgedERC20.sol

24:     uint8 private __srcDecimals;

57:         uint8 _decimals,
File: packages/protocol/contracts/tokenvault/ERC20Vault.sol

24:         uint64 chainId;

26:         uint8 decimals;

33:         uint64 destChainId;

69:         uint8 ctokenDecimal

87:         uint8 ctokenDecimal

102:         uint64 destChainId,

130:         uint64 srcChainId,
File: packages/protocol/contracts/verifiers/IVerifier.sol

14:         uint64 blockId;
File: packages/protocol/contracts/verifiers/SgxVerifier.sol

26:         uint64 validSince;

30:     uint64 public constant INSTANCE_EXPIRY = 180 days;

34:     uint64 public constant INSTANCE_VALIDITY_DELAY = 1 days;

154:         uint32 id = uint32(bytes4(Bytes.slice(_proof.data, 0, 4)));

204:         uint64 validSince = uint64(block.timestamp);

[27] ,[31] ,[15] ,[20] ,[22] ,[24] ,[26] ,[46] ,[48] ,[59] ,[64] ,[65] ,[69] ,[101] ,[102] ,[103] ,[104] ,[107] ,[130] ,[131] ,[132] ,[141] ,[142] ,[143] ,[144] ,[145] ,[153] ,[162] ,[163] ,[164] ,[165] ,[169] ,[170] ,[172] ,[173] ,[174] ,[175] ,[181] ,[183] ,[183] ,[186] ,[187] ,[43] ,[44] ,[58] ,[72] ,[76] ,[94] ,[100] ,[145] ,[150] ,[163] ,[166] ,[84] ,[37] ,[51] ,[100] ,[115] ,[129] ,[273] ,[276] ,[405] ,[26] ,[38] ,[42] ,[55] ,[59] ,[73] ,[78] ,[34] ,[35] ,[89] ,[100] ,[102] ,[107] ,[117] ,[213] ,[227] ,[234] ,[19] ,[27] ,[30] ,[37] ,[55] ,[20] ,[13] ,[14] ,[22] ,[39] ,[42] ,[45] ,[48] ,[20] ,[20] ,[16] ,[19] ,[26] ,[42] ,[63] ,[27] ,[28] ,[35] ,[47] ,[50] ,[57] ,[74] ,[75] ,[110] ,[111] ,[186] ,[187] ,[200] ,[254] ,[255] ,[259] ,[18] ,[27] ,[36] ,[10] ,[23] ,[358] ,[106] ,[249] ,[250] ,[26] ,[27] ,[34] ,[39] ,[43] ,[196] ,[188] ,[198] ,[211] ,[332] ,[9] ,[10] ,[11] ,[12] ,[13] ,[14] ,[15] ,[35] ,[36] ,[37] ,[38] ,[39] ,[40] ,[48] ,[59] ,[71] ,[31] ,[64] ,[89] ,[168] ,[230] ,[392] ,[541] ,[559] ,[580] ,[19] ,[24] ,[26] ,[51] ,[63] ,[22] ,[39] ,[54] ,[11] ,[13] ,[21] ,[23] ,[119] ,[130] ,[14] ,[13] ,[21] ,[21] ,[22] ,[22] ,[37] ,[37] ,[38] ,[38] ,[69] ,[69] ,[71] ,[71] ,[85] ,[85] ,[106] ,[106] ,[108] ,[108] ,[123] ,[123] ,[125] ,[125] ,[129] ,[129] ,[138] ,[138] ,[140] ,[140] ,[17] ,[17] ,[69] ,[71] ,[84] ,[97] ,[138] ,[140] ,[159] ,[161] ,[165] ,[178] ,[180] ,[195] ,[207] ,[236] ,[238] ,[273] ,[274] ,[29] ,[31] ,[34] ,[37] ,[40] ,[43] ,[46] ,[49] ,[53] ,[54] ,[68] ,[71] ,[74] ,[77] ,[92] ,[99] ,[99] ,[152] ,[180] ,[181] ,[182] ,[183] ,[184] ,[197] ,[211] ,[211] ,[225] ,[226] ,[246] ,[247] ,[248] ,[249] ,[273] ,[273] ,[273] ,[29] ,[30] ,[69] ,[28] ,[56] ,[57] ,[61] ,[27] ,[28] ,[18] ,[21] ,[46] ,[47] ,[57] ,[58] ,[90] ,[90] ,[29] ,[30] ,[33] ,[36] ,[39] ,[134] ,[141] ,[142] ,[13] ,[25] ,[70] ,[90] ,[126] ,[24] ,[57] ,[24] ,[26] ,[33] ,[69] ,[87] ,[102] ,[130] ,[14] ,[26] ,[30] ,[34] ,[154] ,[204] ,

Instances of this issue:

File: packages/protocol/contracts/automata-attestation/utils/BytesUtils.sol

335:             require(char >= 0x30 && char <= 0x7A, "invalid char");

[335] ,

[GAS-24] Using this to access functions results in an external call, wasting gas

External calls have an overhead of 100 gas, which can be avoided by not referencing the function using this. Contracts are allowed to override their parents' functions and change the visibility from external to public, so make this change if it's required in order to call the function internally.

Instances of this issue:

File: packages/protocol/contracts/tokenvault/ERC1155Vault.sol

281:             this.onMessageInvocation, abi.encode(ctoken_, _user, _op.to, _op.tokenIds, _op.amounts)
File: packages/protocol/contracts/tokenvault/ERC20Vault.sol

384:             this.onMessageInvocation, abi.encode(ctoken_, _user, _to, balanceChange_)
File: packages/protocol/contracts/tokenvault/ERC721Vault.sol

217:             this.onMessageInvocation, abi.encode(ctoken_, _user, _op.to, _op.tokenIds)

[281] ,[384] ,[217] ,