Skip to content

Commit

Permalink
chore(protocol)!: enforce naming convention (#16168)
Browse files Browse the repository at this point in the history
Co-authored-by: d1onys1us <[email protected]>
  • Loading branch information
dantaik and dionysuzx authored Feb 29, 2024
1 parent 803b8b2 commit 1f6a8af
Show file tree
Hide file tree
Showing 64 changed files with 1,902 additions and 1,837 deletions.
29 changes: 13 additions & 16 deletions packages/protocol/contracts/L1/ITaikoL1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,28 @@ import "./TaikoData.sol";
/// @custom:security-contact [email protected]
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.
/// @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 deposits_ The Ether deposits processed.
function proposeBlock(
bytes calldata params,
bytes calldata txList
bytes calldata _params,
bytes calldata _txList
)
external
payable
returns (
TaikoData.BlockMetadata memory meta,
TaikoData.EthDeposit[] memory depositsProcessed
);
returns (TaikoData.BlockMetadata memory meta_, TaikoData.EthDeposit[] memory deposits_);

/// @notice Proves or contests a block transition.
/// @param blockId The index of the block to prove. This is also used to
/// @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;
/// @param _input An abi-encoded (TaikoData.BlockMetadata, TaikoData.Transition,
/// TaikoData.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;
/// @param _maxBlocksToVerify Max number of blocks to verify.
function verifyBlocks(uint64 _maxBlocksToVerify) external;

/// @notice Gets the configuration of the TaikoL1 contract.
/// @return Config struct containing configuration parameters.
Expand Down
83 changes: 40 additions & 43 deletions packages/protocol/contracts/L1/TaikoL1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,18 @@ contract TaikoL1 is EssentialContract, ITaikoL1, TaikoEvents, TaikoErrors {

/// @inheritdoc ITaikoL1
function proposeBlock(
bytes calldata params,
bytes calldata txList
bytes calldata _params,
bytes calldata _txList
)
external
payable
nonReentrant
whenNotPaused
returns (
TaikoData.BlockMetadata memory meta,
TaikoData.EthDeposit[] memory depositsProcessed
)
returns (TaikoData.BlockMetadata memory meta_, TaikoData.EthDeposit[] memory deposits_)
{
TaikoData.Config memory config = getConfig();

(meta, depositsProcessed) = LibProposing.proposeBlock(state, config, this, params, txList);
(meta_, deposits_) = LibProposing.proposeBlock(state, config, this, _params, _txList);

if (!state.slotB.provingPaused) {
LibVerifying.verifyBlocks(state, config, this, config.maxBlocksToVerifyPerProposal);
Expand All @@ -76,8 +73,8 @@ contract TaikoL1 is EssentialContract, ITaikoL1, TaikoEvents, TaikoErrors {

/// @inheritdoc ITaikoL1
function proveBlock(
uint64 blockId,
bytes calldata input
uint64 _blockId,
bytes calldata _input
)
external
nonReentrant
Expand All @@ -88,9 +85,9 @@ contract TaikoL1 is EssentialContract, ITaikoL1, TaikoEvents, TaikoErrors {
TaikoData.BlockMetadata memory meta,
TaikoData.Transition memory tran,
TaikoData.TierProof memory proof
) = abi.decode(input, (TaikoData.BlockMetadata, TaikoData.Transition, TaikoData.TierProof));
) = abi.decode(_input, (TaikoData.BlockMetadata, TaikoData.Transition, TaikoData.TierProof));

if (blockId != meta.id) revert L1_INVALID_BLOCK_ID();
if (_blockId != meta.id) revert L1_INVALID_BLOCK_ID();

TaikoData.Config memory config = getConfig();

Expand All @@ -100,27 +97,27 @@ contract TaikoL1 is EssentialContract, ITaikoL1, TaikoEvents, TaikoErrors {
}

/// @inheritdoc ITaikoL1
function verifyBlocks(uint64 maxBlocksToVerify)
function verifyBlocks(uint64 _maxBlocksToVerify)
external
nonReentrant
whenNotPaused
whenProvingNotPaused
{
LibVerifying.verifyBlocks(state, getConfig(), this, maxBlocksToVerify);
LibVerifying.verifyBlocks(state, getConfig(), this, _maxBlocksToVerify);
}

/// @notice Pause block proving.
/// @param pause True if paused.
function pauseProving(bool pause) external {
/// @param _pause True if paused.
function pauseProving(bool _pause) external {
_authorizePause(msg.sender);
LibProving.pauseProving(state, pause);
LibProving.pauseProving(state, _pause);
}

/// @notice Deposits Ether to Layer 2.
/// @param recipient Address of the recipient for the deposited Ether on
/// @param _recipient Address of the recipient for the deposited Ether on
/// Layer 2.
function depositEtherToL2(address recipient) external payable nonReentrant whenNotPaused {
LibDepositing.depositEtherToL2(state, getConfig(), this, recipient);
function depositEtherToL2(address _recipient) external payable nonReentrant whenNotPaused {
LibDepositing.depositEtherToL2(state, getConfig(), this, _recipient);
}

/// @inheritdoc EssentialContract
Expand All @@ -130,59 +127,59 @@ contract TaikoL1 is EssentialContract, ITaikoL1, TaikoEvents, TaikoErrors {
}

/// @notice Checks if Ether deposit is allowed for Layer 2.
/// @param amount Amount of Ether to be deposited.
/// @param _amount Amount of Ether to be deposited.
/// @return true if Ether deposit is allowed, false otherwise.
function canDepositEthToL2(uint256 amount) public view returns (bool) {
return LibDepositing.canDepositEthToL2(state, getConfig(), amount);
function canDepositEthToL2(uint256 _amount) public view returns (bool) {
return LibDepositing.canDepositEthToL2(state, getConfig(), _amount);
}

/// @notice See {LibProposing-isBlobReusable}.
function isBlobReusable(bytes32 blobHash) public view returns (bool) {
return LibProposing.isBlobReusable(state, getConfig(), blobHash);
function isBlobReusable(bytes32 _blobHash) public view returns (bool) {
return LibProposing.isBlobReusable(state, getConfig(), _blobHash);
}

/// @notice Gets the details of a block.
/// @param blockId Index of the block.
/// @return blk The block.
/// @return ts The transition used to verify this block.
function getBlock(uint64 blockId)
/// @param _blockId Index of the block.
/// @return blk_ The block.
/// @return ts_ The transition used to verify this block.
function getBlock(uint64 _blockId)
public
view
returns (TaikoData.Block memory blk, TaikoData.TransitionState memory ts)
returns (TaikoData.Block memory blk_, TaikoData.TransitionState memory ts_)
{
uint64 slot;
(blk, slot) = LibUtils.getBlock(state, getConfig(), blockId);
(blk_, slot) = LibUtils.getBlock(state, getConfig(), _blockId);

if (blk.verifiedTransitionId != 0) {
ts = state.transitions[slot][blk.verifiedTransitionId];
if (blk_.verifiedTransitionId != 0) {
ts_ = state.transitions[slot][blk_.verifiedTransitionId];
}
}

/// @notice Gets the state transition for a specific block.
/// @param blockId Index of the block.
/// @param parentHash Parent hash of the block.
/// @return TransitionState The state transition data of the block.
/// @param _blockId Index of the block.
/// @param _parentHash Parent hash of the block.
/// @return The state transition data of the block.
function getTransition(
uint64 blockId,
bytes32 parentHash
uint64 _blockId,
bytes32 _parentHash
)
public
view
returns (TaikoData.TransitionState memory)
{
return LibUtils.getTransition(state, getConfig(), blockId, parentHash);
return LibUtils.getTransition(state, getConfig(), _blockId, _parentHash);
}

/// @notice Gets the state variables of the TaikoL1 contract.
/// @return a State variables stored at SlotA.
/// @return b State variables stored at SlotB.
/// @return a_ State variables stored at SlotA.
/// @return b_ State variables stored at SlotB.
function getStateVariables()
public
view
returns (TaikoData.SlotA memory a, TaikoData.SlotB memory b)
returns (TaikoData.SlotA memory a_, TaikoData.SlotB memory b_)
{
a = state.slotA;
b = state.slotB;
a_ = state.slotA;
b_ = state.slotB;
}

/// @inheritdoc ITaikoL1
Expand Down
62 changes: 31 additions & 31 deletions packages/protocol/contracts/L1/TaikoToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ contract TaikoToken is EssentialContract, ERC20SnapshotUpgradeable, ERC20VotesUp
}

/// @notice Burns tokens from the specified address.
/// @param from The address to burn tokens from.
/// @param amount The amount of tokens to burn.
function burn(address from, uint256 amount) public onlyOwner {
_burn(from, amount);
/// @param _from The address to burn tokens from.
/// @param _amount The amount of tokens to burn.
function burn(address _from, uint256 _amount) public onlyOwner {
_burn(_from, _amount);
}

/// @notice Creates a new token snapshot.
Expand All @@ -54,71 +54,71 @@ contract TaikoToken is EssentialContract, ERC20SnapshotUpgradeable, ERC20VotesUp
}

/// @notice Transfers tokens to a specified address.
/// @param to The address to transfer tokens to.
/// @param amount The amount of tokens to transfer.
/// @param _to The address to transfer tokens to.
/// @param _amount The amount of tokens to transfer.
/// @return A boolean indicating whether the transfer was successful or not.
function transfer(address to, uint256 amount) public override returns (bool) {
if (to == address(this)) revert TKO_INVALID_ADDR();
return super.transfer(to, amount);
function transfer(address _to, uint256 _amount) public override returns (bool) {
if (_to == address(this)) revert TKO_INVALID_ADDR();
return super.transfer(_to, _amount);
}

/// @notice Transfers tokens from one address to another.
/// @param from The address to transfer tokens from.
/// @param to The address to transfer tokens to.
/// @param amount The amount of tokens to transfer.
/// @param _from The address to transfer tokens from.
/// @param _to The address to transfer tokens to.
/// @param _amount The amount of tokens to transfer.
/// @return A boolean indicating whether the transfer was successful or not.
function transferFrom(
address from,
address to,
uint256 amount
address _from,
address _to,
uint256 _amount
)
public
override
returns (bool)
{
if (to == address(this)) revert TKO_INVALID_ADDR();
return super.transferFrom(from, to, amount);
if (_to == address(this)) revert TKO_INVALID_ADDR();
return super.transferFrom(_from, _to, _amount);
}

function _beforeTokenTransfer(
address from,
address to,
uint256 amount
address _from,
address _to,
uint256 _amount
)
internal
override(ERC20Upgradeable, ERC20SnapshotUpgradeable)
{
super._beforeTokenTransfer(from, to, amount);
super._beforeTokenTransfer(_from, _to, _amount);
}

function _afterTokenTransfer(
address from,
address to,
uint256 amount
address _from,
address _to,
uint256 _amount
)
internal
override(ERC20Upgradeable, ERC20VotesUpgradeable)
{
super._afterTokenTransfer(from, to, amount);
super._afterTokenTransfer(_from, _to, _amount);
}

function _mint(
address to,
uint256 amount
address _to,
uint256 _amount
)
internal
override(ERC20Upgradeable, ERC20VotesUpgradeable)
{
super._mint(to, amount);
super._mint(_to, _amount);
}

function _burn(
address from,
uint256 amount
address _from,
uint256 _amount
)
internal
override(ERC20Upgradeable, ERC20VotesUpgradeable)
{
super._burn(from, amount);
super._burn(_from, _amount);
}
}
Loading

0 comments on commit 1f6a8af

Please sign in to comment.