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 5 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
26 changes: 26 additions & 0 deletions packages/protocol/contracts/L1/ITaikoL1.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// SPDX-License-Identifier: MIT
// _____ _ _ _ _
// |_ _|_ _(_) |_____ | | __ _| |__ ___
// | |/ _` | | / / _ \ | |__/ _` | '_ (_-<
// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/

pragma solidity 0.8.20;

import "./TaikoData.sol";

interface ITaikoL1 {
function proposeBlock(
bytes calldata params,
bytes calldata txList
)
external
payable
returns (
TaikoData.BlockMetadata memory meta,
TaikoData.EthDeposit[] memory depositsProcessed
);

function proveBlock(uint64 blockId, bytes calldata input) external;

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
12 changes: 10 additions & 2 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 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
2 changes: 1 addition & 1 deletion packages/protocol/contracts/L2/TaikoL2Signer.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/LibUint512Math.sol";

Expand Down
3 changes: 1 addition & 2 deletions packages/protocol/contracts/bridge/Bridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// |_ _|_ _(_) |_____ | | __ _| |__ ___
// | |/ _` | | / / _ \ | |__/ _` | '_ (_-<
// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/
pragma solidity ^0.8.20;
pragma solidity 0.8.20;

import "../common/EssentialContract.sol";
import "../libs/LibAddress.sol";
Expand Down Expand Up @@ -42,7 +42,6 @@ contract Bridge is EssentialContract, IBridge {
error B_INVALID_CHAINID();
error B_INVALID_CONTEXT();
error B_INVALID_GAS_LIMIT();
error B_INVALID_SIGNAL();
error B_INVALID_USER();
error B_INVALID_VALUE();
error B_NON_RETRIABLE();
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol/contracts/bridge/IBridge.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 IBridge
/// @notice The bridge used in conjunction with the {ISignalService}.
Expand Down
4 changes: 2 additions & 2 deletions packages/protocol/contracts/common/AddressManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
// | |/ _` | | / / _ \ | |__/ _` | '_ (_-<
// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/

pragma solidity ^0.8.20;
pragma solidity 0.8.20;

import "./OwnerUUPSUpgradable.sol";

/// @title IAddressManager
/// @notice Specifies methods to manage address mappings for given chainId-name
/// pairs.

interface IAddressManager {
/// @notice Gets the address mapped to a specific chainId-name pair.
/// @dev Note that in production, this method shall be a pure function
Expand Down
Loading
Loading