Skip to content

Commit f67e899

Browse files
committed
breaks
1 parent 321c7fc commit f67e899

File tree

6 files changed

+36
-42
lines changed

6 files changed

+36
-42
lines changed

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

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,8 @@ library LibProposing {
5757
public
5858
returns (TaikoData.BlockMetadataV2[] memory metas_)
5959
{
60-
require(
61-
_paramsArr.length != 0 && _paramsArr.length == _txListArr.length, L1_INVALID_PARAMS()
62-
);
60+
require(_paramsArr.length != 0, L1_INVALID_PARAMS());
61+
require(_paramsArr.length == _txListArr.length, L1_INVALID_PARAMS());
6362

6463
metas_ = new TaikoData.BlockMetadataV2[](_paramsArr.length);
6564

@@ -149,22 +148,22 @@ library LibProposing {
149148
// The other constraint is that the L1 block number needs to be larger than or equal
150149
// the one in the previous L2 block.
151150
require(
152-
local.params.anchorBlockId + _config.maxAnchorHeightOffset >= block.number //
153-
&& local.params.anchorBlockId < block.number
154-
&& local.params.anchorBlockId >= parentBlk.proposedIn,
151+
local.params.anchorBlockId + _config.maxAnchorHeightOffset >= block.number,
155152
L1_INVALID_ANCHOR_BLOCK()
156153
);
154+
require(local.params.anchorBlockId < block.number, L1_INVALID_ANCHOR_BLOCK());
155+
require(local.params.anchorBlockId >= parentBlk.proposedIn, L1_INVALID_ANCHOR_BLOCK());
157156

158157
// Verify the passed in timestamp.
159158
// We only allow the timestamp to be 2 epochs old.
160159
// The other constraint is that the timestamp needs to be larger than or equal the
161160
// one in the previous L2 block.
162161
require(
163-
local.params.timestamp + _config.maxAnchorHeightOffset * 12 >= block.timestamp
164-
&& local.params.timestamp <= block.timestamp
165-
&& local.params.timestamp >= parentBlk.proposedAt,
162+
local.params.timestamp + _config.maxAnchorHeightOffset * 12 >= block.timestamp,
166163
L1_INVALID_TIMESTAMP()
167164
);
165+
require(local.params.timestamp <= block.timestamp, L1_INVALID_TIMESTAMP());
166+
require(local.params.timestamp >= parentBlk.proposedAt, L1_INVALID_TIMESTAMP());
168167

169168
// Check if parent block has the right meta hash. This is to allow the proposer to make
170169
// sure the block builds on the expected latest chain state.

packages/protocol/contracts/L1/libs/LibProving.sol

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ library LibProving {
115115
)
116116
public
117117
{
118-
require(_blockIds.length != 0 && _blockIds.length == _inputs.length, L1_INVALID_PARAMS());
118+
require(_blockIds.length != 0, L1_INVALID_PARAMS());
119+
require(_blockIds.length == _inputs.length, L1_INVALID_PARAMS());
119120

120121
TaikoData.TierProof memory batchProof;
121122
if (_batchProof.length != 0) {
@@ -206,16 +207,13 @@ library LibProving {
206207
// Make sure parentHash is not zero
207208
// To contest an existing transition, simply use any non-zero value as
208209
// the blockHash and stateRoot.
209-
require(
210-
ctx_.tran.parentHash != 0 && ctx_.tran.blockHash != 0 && ctx_.tran.stateRoot != 0,
211-
L1_INVALID_TRANSITION()
212-
);
210+
require(ctx_.tran.parentHash != 0, L1_INVALID_TRANSITION());
211+
require(ctx_.tran.blockHash != 0, L1_INVALID_TRANSITION());
212+
require(ctx_.tran.stateRoot != 0, L1_INVALID_TRANSITION());
213213

214214
// Check that the block has been proposed but has not yet been verified.
215-
require(
216-
local.meta.id > local.b.lastVerifiedBlockId && local.meta.id < local.b.numBlocks,
217-
LibUtils.L1_INVALID_BLOCK_ID()
218-
);
215+
require(local.meta.id > local.b.lastVerifiedBlockId, LibUtils.L1_INVALID_BLOCK_ID());
216+
require(local.meta.id < local.b.numBlocks, LibUtils.L1_INVALID_BLOCK_ID());
219217

220218
local.slot = local.meta.id % _config.blockRingBufferSize;
221219
TaikoData.BlockV2 storage blk = _state.blocks[local.slot];
@@ -254,11 +252,9 @@ library LibProving {
254252

255253
// The new proof must meet or exceed the minimum tier required by the
256254
// block or the previous proof; it cannot be on a lower tier.
257-
require(
258-
local.proof.tier != 0 && local.proof.tier >= local.meta.minTier
259-
&& local.proof.tier >= ts.tier,
260-
L1_INVALID_TIER()
261-
);
255+
require(local.proof.tier != 0, L1_INVALID_TIER());
256+
require(local.proof.tier >= local.meta.minTier, L1_INVALID_TIER());
257+
require(local.proof.tier >= ts.tier, L1_INVALID_TIER());
262258

263259
// Retrieve the tier configurations. If the tier is not supported, the
264260
// subsequent action will result in a revert.

packages/protocol/contracts/L1/libs/LibUtils.sol

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@ library LibUtils {
128128
{
129129
(TaikoData.BlockV2 storage blk, uint64 slot) = getBlock(_state, _config, _blockId);
130130

131-
require(_tid != 0 && _tid < blk.nextTransitionId, L1_TRANSITION_NOT_FOUND());
131+
require(_tid != 0, L1_TRANSITION_NOT_FOUND());
132+
require(_tid < blk.nextTransitionId, L1_TRANSITION_NOT_FOUND());
132133
return _state.transitions[slot][_tid];
133134
}
134135

packages/protocol/contracts/L1/provers/GuardianProver.sol

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,16 +110,13 @@ contract GuardianProver is IVerifier, EssentialContract {
110110
onlyOwner
111111
{
112112
// We need at most 255 guardians (so the approval bits fit in a uint256)
113-
require(
114-
_newGuardians.length != 0 && _newGuardians.length <= type(uint8).max,
115-
GP_INVALID_GUARDIAN_SET()
116-
);
113+
require(_newGuardians.length != 0, GP_INVALID_GUARDIAN_SET());
114+
require(_newGuardians.length <= type(uint8).max, GP_INVALID_GUARDIAN_SET());
117115

118116
// Minimum number of guardians to approve is at least equal or greater than half the
119117
// guardians (rounded up) and less or equal than the total number of guardians
120-
require(
121-
_minGuardians != 0 && _minGuardians <= _newGuardians.length, GP_INVALID_MIN_GUARDIANS()
122-
);
118+
require(_minGuardians != 0, GP_INVALID_MIN_GUARDIANS());
119+
require(_minGuardians <= _newGuardians.length, GP_INVALID_MIN_GUARDIANS());
123120

124121
// Delete the current guardians
125122
for (uint256 i; i < guardians.length; ++i) {
@@ -201,7 +198,6 @@ contract GuardianProver is IVerifier, EssentialContract {
201198
/// @notice Pauses chain proving and verification.
202199
function pauseTaikoProving() external whenNotPaused {
203200
require(guardianIds[msg.sender] != 0, GP_INVALID_GUARDIAN());
204-
205201
require(address(this) == resolve(LibStrings.B_CHAIN_WATCHDOG, true), GV_PERMISSION_DENIED());
206202

207203
ITaikoL1(resolve(LibStrings.B_TAIKO, false)).pauseProving(true);

packages/protocol/contracts/L2/DelegateOwner.sol

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ contract DelegateOwner is EssentialContract, IMessageInvocable {
5656
error DO_PERMISSION_DENIED();
5757

5858
modifier onlyAdminOrRemoteOwner() {
59-
if (!_isAdminOrRemoteOwner(msg.sender)) revert DO_PERMISSION_DENIED();
59+
require(_isAdminOrRemoteOwner(msg.sender), DO_PERMISSION_DENIED());
6060
_;
6161
}
6262

@@ -78,9 +78,9 @@ contract DelegateOwner is EssentialContract, IMessageInvocable {
7878
// This contract's owner will be itself.
7979
__Essential_init(address(this), _sharedAddressManager);
8080

81-
if (_remoteOwner == address(0) || _remoteChainId == 0 || _remoteChainId == block.chainid) {
82-
revert DO_INVALID_PARAM();
83-
}
81+
require(_remoteOwner != address(0), DO_INVALID_PARAM());
82+
require(_remoteChainId != 0, DO_INVALID_PARAM());
83+
require(_remoteChainId != block.chainid, DO_INVALID_PARAM());
8484

8585
remoteChainId = _remoteChainId;
8686
remoteOwner = _remoteOwner;
@@ -104,7 +104,7 @@ contract DelegateOwner is EssentialContract, IMessageInvocable {
104104
/// @dev Updates the admin address.
105105
/// @param _admin The new admin address.
106106
function setAdmin(address _admin) external nonReentrant onlyOwner {
107-
if (_admin == admin || _admin == address(this)) revert DO_INVALID_PARAM();
107+
require(_admin != admin && _admin != address(this), DO_INVALID_PARAM());
108108

109109
emit AdminUpdated(admin, _admin);
110110
admin = _admin;
@@ -125,14 +125,14 @@ contract DelegateOwner is EssentialContract, IMessageInvocable {
125125

126126
if (call.txId == 0) {
127127
call.txId = nextTxId;
128-
} else if (_verifyTxId && call.txId != nextTxId) {
129-
revert DO_INVALID_TX_ID();
128+
} else {
129+
require(!_verifyTxId || call.txId == nextTxId, DO_INVALID_TX_ID());
130130
}
131131

132132
nextTxId += 1;
133133

134134
// By design, the target must be a contract address if the txdata is not empty
135-
if (call.txdata.length != 0 && !Address.isContract(call.target)) revert DO_INVALID_TARGET();
135+
require(call.txdata.length == 0 || Address.isContract(call.target), DO_INVALID_TARGET());
136136

137137
(bool success, bytes memory result) = call.isDelegateCall //
138138
? call.target.delegatecall(call.txdata)

packages/protocol/contracts/L2/TaikoL2.sol

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,10 @@ contract TaikoL2 is EssentialContract {
8484
{
8585
__Essential_init(_owner, _rollupAddressManager);
8686

87-
require(_l1ChainId != 0 && _l1ChainId != block.chainid, L2_INVALID_L1_CHAIN_ID());
88-
require(block.chainid > 1 && block.chainid <= type(uint64).max, L2_INVALID_L2_CHAIN_ID());
87+
require(_l1ChainId != 0, L2_INVALID_L1_CHAIN_ID());
88+
require(_l1ChainId != block.chainid, L2_INVALID_L1_CHAIN_ID());
89+
require(block.chainid > 1, L2_INVALID_L2_CHAIN_ID());
90+
require(block.chainid <= type(uint64).max, L2_INVALID_L2_CHAIN_ID());
8991

9092
if (block.number == 0) {
9193
// This is the case in real L2 genesis

0 commit comments

Comments
 (0)