Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(protocol): apply fixes based on OZ's inspector reports #15320

Merged
merged 10 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/protocol/contracts/4844/IBlobHashReader.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// | |/ _` | | / / _ \ | |__/ _` | '_ (_-<
// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/

pragma solidity ^0.8.20;
pragma solidity 0.8.20;

/// @title IBlobHashReader
/// @dev Labeled in AddressResolver as "blob_hash_reader"
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol/contracts/4844/Lib4844.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// | |/ _` | | / / _ \ | |__/ _` | '_ (_-<
// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/

pragma solidity ^0.8.20;
pragma solidity 0.8.20;

/// @title Lib4844
/// @notice A library for handling EIP-4844 blobs
Expand Down
38 changes: 38 additions & 0 deletions packages/protocol/contracts/L1/ITaikoL1.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// SPDX-License-Identifier: MIT
// _____ _ _ _ _
// |_ _|_ _(_) |_____ | | __ _| |__ ___
// | |/ _` | | / / _ \ | |__/ _` | '_ (_-<
// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/

pragma solidity 0.8.20;

import "./TaikoData.sol";

interface ITaikoL1 {
/// @notice Proposes a Taiko L2 block.
/// @param params Block parameters, currently an encoded BlockParams object.
/// @param txList txList data if calldata is used for DA.
/// @return meta The metadata of the proposed L2 block.
/// @return depositsProcessed The Ether deposits processed.
function proposeBlock(
bytes calldata params,
bytes calldata txList
)
external
payable
returns (
TaikoData.BlockMetadata memory meta,
TaikoData.EthDeposit[] memory depositsProcessed
);

/// @notice Proves or contests a block transition.
/// @param blockId The index of the block to prove. This is also used to
/// select the right implementation version.
/// @param input An abi-encoded (BlockMetadata, Transition, TierProof)
/// tuple.
function proveBlock(uint64 blockId, bytes calldata input) external;

/// @notice Verifies up to a certain number of blocks.
/// @param maxBlocksToVerify Max number of blocks to verify.
function verifyBlocks(uint64 maxBlocksToVerify) external;
}
2 changes: 1 addition & 1 deletion packages/protocol/contracts/L1/TaikoData.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// | |/ _` | | / / _ \ | |__/ _` | '_ (_-<
// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/

pragma solidity ^0.8.20;
pragma solidity 0.8.20;

/// @title TaikoData
/// @notice This library defines various data structures used in the Taiko
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol/contracts/L1/TaikoErrors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// | |/ _` | | / / _ \ | |__/ _` | '_ (_-<
// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/

pragma solidity ^0.8.20;
pragma solidity 0.8.20;

/// @title TaikoErrors
/// @notice This abstract contract provides custom error declartions used in
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol/contracts/L1/TaikoEvents.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// | |/ _` | | / / _ \ | |__/ _` | '_ (_-<
// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/

pragma solidity ^0.8.20;
pragma solidity 0.8.20;

import "./TaikoData.sol";

Expand Down
27 changes: 13 additions & 14 deletions packages/protocol/contracts/L1/TaikoL1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
// | |/ _` | | / / _ \ | |__/ _` | '_ (_-<
// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/

pragma solidity ^0.8.20;
pragma solidity 0.8.20;

import "../common/EssentialContract.sol";
import "./libs/LibDepositing.sol";
import "./libs/LibProposing.sol";
import "./libs/LibProving.sol";
import "./libs/LibVerifying.sol";
import "./ITaikoL1.sol";
import "./TaikoErrors.sol";
import "./TaikoEvents.sol";

Expand All @@ -23,7 +24,14 @@ import "./TaikoEvents.sol";
/// layers"). The contract also handles the deposit and withdrawal of Taiko
/// tokens and Ether.
/// This contract doesn't hold any Ether. Ether deposited to L2 are held by the Bridge contract.
contract TaikoL1 is EssentialContract, ICrossChainSync, ITierProvider, TaikoEvents, TaikoErrors {
contract TaikoL1 is
EssentialContract,
ITaikoL1,
ICrossChainSync,
ITierProvider,
TaikoEvents,
TaikoErrors
{
TaikoData.State public state;
uint256[100] private __gap;

Expand All @@ -40,11 +48,7 @@ contract TaikoL1 is EssentialContract, ICrossChainSync, ITierProvider, TaikoEven
LibVerifying.init(state, getConfig(), _genesisBlockHash);
}

/// @notice Proposes a Taiko L2 block.
/// @param params Block parameters, currently an encoded BlockParams object.
/// @param txList txList data if calldata is used for DA.
/// @return meta The metadata of the proposed L2 block.
/// @return depositsProcessed The Ether deposits processed.
/// @inheritdoc ITaikoL1
function proposeBlock(
bytes calldata params,
bytes calldata txList
Expand All @@ -70,11 +74,7 @@ contract TaikoL1 is EssentialContract, ICrossChainSync, ITierProvider, TaikoEven
}
}

/// @notice Proves or contests a block transition.
/// @param blockId The index of the block to prove. This is also used to
/// select the right implementation version.
/// @param input An abi-encoded (BlockMetadata, Transition, TierProof)
/// tuple.
/// @inheritdoc ITaikoL1
function proveBlock(uint64 blockId, bytes calldata input) external nonReentrant whenNotPaused {
if (state.slotB.provingPaused) revert L1_PROVING_PAUSED();

Expand All @@ -96,8 +96,7 @@ contract TaikoL1 is EssentialContract, ICrossChainSync, ITierProvider, TaikoEven
}
}

/// @notice Verifies up to N blocks.
/// @param maxBlocksToVerify Max number of blocks to verify.
/// @inheritdoc ITaikoL1
function verifyBlocks(uint64 maxBlocksToVerify) external nonReentrant whenNotPaused {
if (maxBlocksToVerify == 0) revert L1_INVALID_PARAM();
if (state.slotB.provingPaused) revert L1_PROVING_PAUSED();
Expand Down
3 changes: 1 addition & 2 deletions packages/protocol/contracts/L1/TaikoToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// | |/ _` | | / / _ \ | |__/ _` | '_ (_-<
// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/

pragma solidity ^0.8.20;
pragma solidity 0.8.20;

import "lib/openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol";
import
Expand All @@ -20,7 +20,6 @@ import "../common/EssentialContract.sol";
/// precision.
contract TaikoToken is EssentialContract, ERC20SnapshotUpgradeable, ERC20VotesUpgradeable {
error TKO_INVALID_ADDR();
error TKO_INVALID_PREMINT_PARAMS();

/// @notice Initializes the TaikoToken contract and mints initial tokens.
/// @param _name The name of the token.
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol/contracts/L1/gov/TaikoGovernor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// | |/ _` | | / / _ \ | |__/ _` | '_ (_-<
// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/

pragma solidity ^0.8.20;
pragma solidity 0.8.20;

import "lib/openzeppelin-contracts-upgradeable/contracts/governance/GovernorUpgradeable.sol";
import
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// | |/ _` | | / / _ \ | |__/ _` | '_ (_-<
// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/

pragma solidity ^0.8.20;
pragma solidity 0.8.20;

import
"lib/openzeppelin-contracts-upgradeable/contracts/governance/TimelockControllerUpgradeable.sol";
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol/contracts/L1/hooks/AssignmentHook.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// | |/ _` | | / / _ \ | |__/ _` | '_ (_-<
// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/

pragma solidity ^0.8.20;
pragma solidity 0.8.20;

import "lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol";
import "../../common/EssentialContract.sol";
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol/contracts/L1/hooks/IHook.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// | |/ _` | | / / _ \ | |__/ _` | '_ (_-<
// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/

pragma solidity ^0.8.20;
pragma solidity 0.8.20;

import "../TaikoData.sol";

Expand Down
2 changes: 1 addition & 1 deletion packages/protocol/contracts/L1/libs/LibDepositing.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// | |/ _` | | / / _ \ | |__/ _` | '_ (_-<
// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/

pragma solidity ^0.8.20;
pragma solidity 0.8.20;

import "../../common/AddressResolver.sol";
import "../../libs/LibAddress.sol";
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol/contracts/L1/libs/LibProposing.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// | |/ _` | | / / _ \ | |__/ _` | '_ (_-<
// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/

pragma solidity ^0.8.20;
pragma solidity 0.8.20;

import "lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol";
import "../../4844/IBlobHashReader.sol";
Expand Down
3 changes: 1 addition & 2 deletions packages/protocol/contracts/L1/libs/LibProving.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// | |/ _` | | / / _ \ | |__/ _` | '_ (_-<
// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/

pragma solidity ^0.8.20;
pragma solidity 0.8.20;

import "lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol";
import "../../common/AddressResolver.sol";
Expand Down Expand Up @@ -48,7 +48,6 @@ library LibProving {
error L1_INVALID_TIER();
error L1_INVALID_TRANSITION();
error L1_NOT_ASSIGNED_PROVER();
error L1_PROVING_PAUSED();
error L1_UNEXPECTED_TRANSITION_TIER();

function pauseProving(TaikoData.State storage state, bool pause) external {
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol/contracts/L1/libs/LibUtils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// | |/ _` | | / / _ \ | |__/ _` | '_ (_-<
// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/

pragma solidity ^0.8.20;
pragma solidity 0.8.20;

import "../../common/ICrossChainSync.sol";
import "../TaikoData.sol";
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol/contracts/L1/libs/LibVerifying.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// | |/ _` | | / / _ \ | |__/ _` | '_ (_-<
// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/

pragma solidity ^0.8.20;
pragma solidity 0.8.20;

import "lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol";
import "../../common/AddressResolver.sol";
Expand Down
9 changes: 4 additions & 5 deletions packages/protocol/contracts/L1/provers/GuardianProver.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
// | |/ _` | | / / _ \ | |__/ _` | '_ (_-<
// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/

pragma solidity ^0.8.20;
pragma solidity 0.8.20;

import "../tiers/ITierProvider.sol";
import "../ITaikoL1.sol";
import "./Guardians.sol";

/// @title GuardianProver
Expand Down Expand Up @@ -36,10 +37,8 @@ contract GuardianProver is Guardians {

if (approved) {
deleteApproval(hash);
bytes memory data = abi.encodeWithSignature(
"proveBlock(uint64,bytes)", meta.id, abi.encode(meta, tran, proof)
);

bytes memory data =
abi.encodeCall(ITaikoL1.proveBlock, (meta.id, abi.encode(meta, tran, proof)));
(bool success,) = resolve("taiko", false).call(data);
if (!success) revert PROVING_FAILED();
}
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol/contracts/L1/provers/Guardians.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// | |/ _` | | / / _ \ | |__/ _` | '_ (_-<
// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/

pragma solidity ^0.8.20;
pragma solidity 0.8.20;

import "../../common/EssentialContract.sol";
import "../TaikoData.sol";
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol/contracts/L1/tiers/ITierProvider.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// | |/ _` | | / / _ \ | |__/ _` | '_ (_-<
// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/

pragma solidity ^0.8.20;
pragma solidity 0.8.20;

/// @title ITierProvider
/// @notice Defines interface to return tier configuration.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// | |/ _` | | / / _ \ | |__/ _` | '_ (_-<
// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/

pragma solidity ^0.8.20;
pragma solidity 0.8.20;

import "../../common/EssentialContract.sol";
import "./ITierProvider.sol";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// | |/ _` | | / / _ \ | |__/ _` | '_ (_-<
// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/

pragma solidity ^0.8.20;
pragma solidity 0.8.20;

import "../../common/EssentialContract.sol";
import "../TaikoData.sol";
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol/contracts/L1/verifiers/IVerifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// | |/ _` | | / / _ \ | |__/ _` | '_ (_-<
// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/

pragma solidity ^0.8.20;
pragma solidity 0.8.20;

import "../TaikoData.sol";

Expand Down
2 changes: 1 addition & 1 deletion packages/protocol/contracts/L1/verifiers/PseZkVerifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// | |/ _` | | / / _ \ | |__/ _` | '_ (_-<
// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/

pragma solidity ^0.8.20;
pragma solidity 0.8.20;

import "../../4844/Lib4844.sol";
import "../../common/EssentialContract.sol";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// | |/ _` | | / / _ \ | |__/ _` | '_ (_-<
// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/

pragma solidity ^0.8.20;
pragma solidity 0.8.20;

import "../../common/EssentialContract.sol";
import "../../thirdparty/LibBytesUtils.sol";
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol/contracts/L1/verifiers/SgxVerifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// | |/ _` | | / / _ \ | |__/ _` | '_ (_-<
// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/

pragma solidity ^0.8.20;
pragma solidity 0.8.20;

import "lib/openzeppelin-contracts/contracts/utils/cryptography/ECDSA.sol";
import "../../common/EssentialContract.sol";
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol/contracts/L2/Lib1559Math.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// | |/ _` | | / / _ \ | |__/ _` | '_ (_-<
// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/

pragma solidity ^0.8.20;
pragma solidity 0.8.20;

import "../thirdparty/LibFixedPointMath.sol";

Expand Down
6 changes: 4 additions & 2 deletions packages/protocol/contracts/L2/TaikoL2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// | |/ _` | | / / _ \ | |__/ _` | '_ (_-<
// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/

pragma solidity ^0.8.20;
pragma solidity 0.8.20;

import "../common/EssentialContract.sol";
import "../common/ICrossChainSync.sol";
Expand Down Expand Up @@ -187,7 +187,9 @@ contract TaikoL2 is EssentialContract, TaikoL2Signer, ICrossChainSync {

/// @notice Tells if we need to validate basefee (for simulation).
/// @return Returns true to skip checking basefee mismatch.
function skipFeeCheck() public pure virtual returns (bool) { }
function skipFeeCheck() public pure virtual returns (bool) {
return false;
}

function _calcPublicInputHash(uint256 blockId)
private
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// | |/ _` | | / / _ \ | |__/ _` | '_ (_-<
// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/

pragma solidity ^0.8.20;
pragma solidity 0.8.20;

import "./TaikoL2.sol";

Expand Down
Loading
Loading