Skip to content

Commit

Permalink
chore: refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
shotaronowhere committed Apr 10, 2024
1 parent 103ed98 commit deec15a
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/bridge/SequencerInbox.sol
Original file line number Diff line number Diff line change
Expand Up @@ -304,14 +304,14 @@ contract SequencerInbox is DelegateCallAware, GasRefundEnabled, ISequencerInbox
messageDataHash
);

uint256 delayBlocks_ = delayBlocks;

if (isDelayBufferable) {
// proactively apply any pending delay buffer updates before the force included message l1BlockAndTime
buffer.update(l1BlockAndTime[0]);
delayBlocks_ = delayBufferableBlocks(buffer.bufferBlocks);
emit BufferUpdated(buffer.bufferBlocks);
}
uint256 delayBlocks_ = isDelayBufferable && buffer.bufferBlocks < delayBlocks
? buffer.bufferBlocks
: delayBlocks;
// Can only force-include after the Sequencer-only window has expired.
if (l1BlockAndTime[0] + delayBlocks_ >= block.number) revert ForceIncludeBlockTooSoon();

Expand Down Expand Up @@ -836,21 +836,24 @@ contract SequencerInbox is DelegateCallAware, GasRefundEnabled, ISequencerInbox
uint64 _delayBlocks = delayBlocks;
if (isDelayBufferable) {
uint64 _buffer = buffer.pendingBufferUpdate(blockNumber);
if (_buffer < _delayBlocks) {
_delayBlocks = _buffer;
}
_delayBlocks = delayBufferableBlocks(_buffer);
}
return blockNumber + _delayBlocks;
}

/// @notice Calculates the buffer dependent delay blocks
function delayBufferableBlocks(uint64 _buffer) internal view returns (uint64) {
return _buffer < delayBlocks ? _buffer : delayBlocks;
}

function _setBufferConfig(BufferConfig memory bufferConfig_) internal {
if (!isDelayBufferable) revert NotDelayBufferable();
if (!DelayBuffer.isValidBufferConfig(bufferConfig_)) revert BadBufferConfig();

if (buffer.bufferBlocks == 0 || buffer.bufferBlocks > bufferConfig_.max) {
buffer.bufferBlocks = bufferConfig_.max;
}
if (buffer.bufferBlocks < bufferConfig_.threshold){
if (buffer.bufferBlocks < bufferConfig_.threshold) {
buffer.bufferBlocks = bufferConfig_.threshold;
}
buffer.max = bufferConfig_.max;
Expand Down

0 comments on commit deec15a

Please sign in to comment.