Skip to content

Commit

Permalink
format: reformat due to foundry update
Browse files Browse the repository at this point in the history
  • Loading branch information
gzeoneth committed Sep 3, 2024
1 parent 0ab11d6 commit ae75f0b
Show file tree
Hide file tree
Showing 120 changed files with 1,395 additions and 465 deletions.
12 changes: 9 additions & 3 deletions src/assertionStakingPool/AbsBoldStakingPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,16 @@ abstract contract AbsBoldStakingPool is IAbsBoldStakingPool {
/// @inheritdoc IAbsBoldStakingPool
mapping(address => uint256) public depositBalance;

constructor(address _stakeToken) {
constructor(
address _stakeToken
) {
stakeToken = _stakeToken;
}

/// @inheritdoc IAbsBoldStakingPool
function depositIntoPool(uint256 amount) external {
function depositIntoPool(
uint256 amount
) external {
if (amount == 0) {
revert ZeroAmount();
}
Expand All @@ -38,7 +42,9 @@ abstract contract AbsBoldStakingPool is IAbsBoldStakingPool {
}

/// @inheritdoc IAbsBoldStakingPool
function withdrawFromPool(uint256 amount) public {
function withdrawFromPool(
uint256 amount
) public {
if (amount == 0) {
revert ZeroAmount();
}
Expand Down
4 changes: 3 additions & 1 deletion src/assertionStakingPool/AssertionStakingPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ contract AssertionStakingPool is AbsBoldStakingPool, IAssertionStakingPool {
}

/// @inheritdoc IAssertionStakingPool
function createAssertion(AssertionInputs calldata assertionInputs) external {
function createAssertion(
AssertionInputs calldata assertionInputs
) external {
uint256 requiredStake = assertionInputs.beforeStateData.configData.requiredStake;
// approve spending from rollup for newStakeOnNewAssertion call
IERC20(stakeToken).safeIncreaseAllowance(rollup, requiredStake);
Expand Down
4 changes: 3 additions & 1 deletion src/assertionStakingPool/EdgeStakingPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ contract EdgeStakingPool is AbsBoldStakingPool, IEdgeStakingPool {
}

/// @inheritdoc IEdgeStakingPool
function createEdge(CreateEdgeArgs calldata args) external {
function createEdge(
CreateEdgeArgs calldata args
) external {
uint256 requiredStake = EdgeChallengeManager(challengeManager).stakeAmounts(args.level);
IERC20(stakeToken).safeIncreaseAllowance(address(challengeManager), requiredStake);
bytes32 newEdgeId = EdgeChallengeManager(challengeManager).createLayerZeroEdge(args);
Expand Down
12 changes: 9 additions & 3 deletions src/assertionStakingPool/interfaces/IAbsBoldStakingPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,15 @@ interface IAbsBoldStakingPool {

/// @notice Deposit stake into pool contract.
/// @param amount amount of stake token to deposit
function depositIntoPool(uint256 amount) external;
function depositIntoPool(
uint256 amount
) external;

/// @notice Send supplied amount of stake from this contract back to its depositor.
/// @param amount stake amount to withdraw
function withdrawFromPool(uint256 amount) external;
function withdrawFromPool(
uint256 amount
) external;

/// @notice Send full balance of stake from this contract back to its depositor.
function withdrawFromPool() external;
Expand All @@ -31,5 +35,7 @@ interface IAbsBoldStakingPool {

/// @notice The balance of the given account
/// @param account The account to check the balance of
function depositBalance(address account) external view returns (uint256);
function depositBalance(
address account
) external view returns (uint256);
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ interface IAssertionStakingPool is IAbsBoldStakingPool {
error EmptyAssertionId();

/// @notice Create assertion. Callable only if required stake has been reached and assertion has not been asserted yet.
function createAssertion(AssertionInputs calldata assertionInputs) external;
function createAssertion(
AssertionInputs calldata assertionInputs
) external;

/// @notice Make stake withdrawable.
/// @dev Separate call from withdrawStakeBackIntoPool since returnOldDeposit reverts with 0 balance (in e.g., case of admin forceRefundStaker)
Expand Down
4 changes: 3 additions & 1 deletion src/assertionStakingPool/interfaces/IEdgeStakingPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ interface IEdgeStakingPool is IAbsBoldStakingPool {
error EmptyEdgeId();

/// @notice Create the edge. Callable only if required stake has been reached and edge has not been created yet.
function createEdge(CreateEdgeArgs calldata args) external;
function createEdge(
CreateEdgeArgs calldata args
) external;

/// @notice The targeted challenge manager contract
function challengeManager() external view returns (address);
Expand Down
24 changes: 18 additions & 6 deletions src/bridge/AbsBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ abstract contract AbsBridge is Initializable, DelegateCallAware, IBridge {
}

/// @notice Allows the rollup owner to set another rollup address
function updateRollupAddress(IOwnable _rollup) external onlyRollupOrOwner {
function updateRollupAddress(
IOwnable _rollup
) external onlyRollupOrOwner {
rollup = _rollup;
emit RollupUpdated(address(_rollup));
}
Expand All @@ -84,11 +86,15 @@ abstract contract AbsBridge is Initializable, DelegateCallAware, IBridge {
return outbox;
}

function allowedDelayedInboxes(address inbox) public view returns (bool) {
function allowedDelayedInboxes(
address inbox
) public view returns (bool) {
return allowedDelayedInboxesMap[inbox].allowed;
}

function allowedOutboxes(address outbox) public view returns (bool) {
function allowedOutboxes(
address outbox
) public view returns (bool) {
return allowedOutboxesMap[outbox].allowed;
}

Expand Down Expand Up @@ -205,7 +211,9 @@ abstract contract AbsBridge is Initializable, DelegateCallAware, IBridge {
emit BridgeCallTriggered(msg.sender, to, value, data);
}

function setSequencerInbox(address _sequencerInbox) external onlyRollupOrOwner {
function setSequencerInbox(
address _sequencerInbox
) external onlyRollupOrOwner {
sequencerInbox = _sequencerInbox;
emit SequencerInboxUpdated(_sequencerInbox);
}
Expand Down Expand Up @@ -249,7 +257,9 @@ abstract contract AbsBridge is Initializable, DelegateCallAware, IBridge {
}
}

function setSequencerReportedSubMessageCount(uint256 newMsgCount) external onlyRollupOrOwner {
function setSequencerReportedSubMessageCount(
uint256 newMsgCount
) external onlyRollupOrOwner {
sequencerReportedSubMessageCount = newMsgCount;
}

Expand All @@ -265,7 +275,9 @@ abstract contract AbsBridge is Initializable, DelegateCallAware, IBridge {
function acceptFundsFromOldBridge() external payable {}

/// @dev transfer funds provided to pay for crosschain msg
function _transferFunds(uint256 amount) internal virtual;
function _transferFunds(
uint256 amount
) internal virtual;

function _executeLowLevelCall(
address to,
Expand Down
16 changes: 12 additions & 4 deletions src/bridge/AbsInbox.sol
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ abstract contract AbsInbox is DelegateCallAware, PausableUpgradeable, IInboxBase
}

/// @inheritdoc IInboxBase
function setAllowListEnabled(bool _allowListEnabled) external onlyRollupOrOwner {
function setAllowListEnabled(
bool _allowListEnabled
) external onlyRollupOrOwner {
require(_allowListEnabled != allowListEnabled, "ALREADY_SET");
allowListEnabled = _allowListEnabled;
emit AllowListEnabledUpdated(_allowListEnabled);
Expand Down Expand Up @@ -101,7 +103,9 @@ abstract contract AbsInbox is DelegateCallAware, PausableUpgradeable, IInboxBase
uint256 public immutable maxDataSize;
uint256 internal immutable deployTimeChainId = block.chainid;

constructor(uint256 _maxDataSize) {
constructor(
uint256 _maxDataSize
) {
maxDataSize = _maxDataSize;
}

Expand Down Expand Up @@ -131,7 +135,9 @@ abstract contract AbsInbox is DelegateCallAware, PausableUpgradeable, IInboxBase
}

/// @inheritdoc IInboxBase
function sendL2MessageFromOrigin(bytes calldata) external pure returns (uint256) {
function sendL2MessageFromOrigin(
bytes calldata
) external pure returns (uint256) {
revert Deprecated();
}

Expand Down Expand Up @@ -340,7 +346,9 @@ abstract contract AbsInbox is DelegateCallAware, PausableUpgradeable, IInboxBase
/// decimals used for native currency on child chain.
/// @dev provided value has to be less than 'type(uint256).max/10**(18-decimalsIn)'
/// or otherwise it will overflow.
function _fromNativeTo18Decimals(uint256 value) internal view virtual returns (uint256);
function _fromNativeTo18Decimals(
uint256 value
) internal view virtual returns (uint256);

/**
* @dev This empty reserved space is put in place to allow future versions to add new
Expand Down
16 changes: 12 additions & 4 deletions src/bridge/AbsOutbox.sol
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ abstract contract AbsOutbox is DelegateCallAware, IOutbox {

uint128 public constant OUTBOX_VERSION = 2;

function initialize(IBridge _bridge) external onlyDelegated {
function initialize(
IBridge _bridge
) external onlyDelegated {
if (address(_bridge) == address(0)) revert HadZeroInit();
if (address(bridge) != address(0)) revert AlreadyInit();
// address zero is returned if no context is set, but the values used in storage
Expand Down Expand Up @@ -235,7 +237,9 @@ abstract contract AbsOutbox is DelegateCallAware, IOutbox {
}

/// @inheritdoc IOutbox
function isSpent(uint256 index) external view returns (bool) {
function isSpent(
uint256 index
) external view returns (bool) {
(, uint256 bitOffset, bytes32 replay) = _calcSpentIndexOffset(index);
return _isSpent(bitOffset, replay);
}
Expand Down Expand Up @@ -296,13 +300,17 @@ abstract contract AbsOutbox is DelegateCallAware, IOutbox {
/// @notice based on provided value, get amount of ETH/token to unlock. In case of ETH-based rollup this amount
/// will always equal the provided value. In case of ERC20-based rollup, amount will be re-adjusted to
/// reflect the number of decimals used by native token, in case it is different than 18.
function _getAmountToUnlock(uint256 value) internal view virtual returns (uint256);
function _getAmountToUnlock(
uint256 value
) internal view virtual returns (uint256);

/// @notice value to be set for 'amount' field in L2ToL1Context during L2 to L1 transaction execution.
/// In case of ERC20-based rollup this is the amount of native token being withdrawn. In case of standard ETH-based
/// rollup this amount shall always be 0, because amount of ETH being withdrawn can be read from msg.value.
/// @return amount of native token being withdrawn in case of ERC20-based rollup, or 0 in case of ETH-based rollup
function _amountToSetInContext(uint256 value) internal pure virtual returns (uint256);
function _amountToSetInContext(
uint256 value
) internal pure virtual returns (uint256);

/**
* @dev This empty reserved space is put in place to allow future versions to add new
Expand Down
8 changes: 6 additions & 2 deletions src/bridge/Bridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ contract Bridge is AbsBridge, IEthBridge {
using AddressUpgradeable for address;

/// @inheritdoc IEthBridge
function initialize(IOwnable rollup_) external initializer onlyDelegated {
function initialize(
IOwnable rollup_
) external initializer onlyDelegated {
_activeOutbox = EMPTY_ACTIVEOUTBOX;
rollup = rollup_;
}
Expand All @@ -33,7 +35,9 @@ contract Bridge is AbsBridge, IEthBridge {
return _enqueueDelayedMessage(kind, sender, messageDataHash, msg.value);
}

function _transferFunds(uint256) internal override {
function _transferFunds(
uint256
) internal override {
// do nothing as Eth transfer is part of TX execution
}

Expand Down
12 changes: 9 additions & 3 deletions src/bridge/DelayBuffer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -99,18 +99,24 @@ library DelayBuffer {

/// @dev This is the `sync validity window` during which no proofs are required.
/// @notice Returns true if the inbox is in a synced state (no unexpected delays are possible)
function isSynced(BufferData storage self) internal view returns (bool) {
function isSynced(
BufferData storage self
) internal view returns (bool) {
return block.number - self.prevBlockNumber <= self.threshold;
}

function isUpdatable(BufferData storage self) internal view returns (bool) {
function isUpdatable(
BufferData storage self
) internal view returns (bool) {
// if synced, the buffer can't be depleted
// if full, the buffer can't be replenished
// if neither synced nor full, the buffer updatable (depletable / replenishable)
return !isSynced(self) || self.bufferBlocks < self.max;
}

function isValidBufferConfig(BufferConfig memory config) internal pure returns (bool) {
function isValidBufferConfig(
BufferConfig memory config
) internal pure returns (bool) {
return config.threshold != 0 && config.max != 0 && config.replenishRateInBasis <= BASIS
&& config.threshold <= config.max;
}
Expand Down
4 changes: 3 additions & 1 deletion src/bridge/ERC20Bridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ contract ERC20Bridge is AbsBridge, IERC20Bridge {
return _enqueueDelayedMessage(kind, sender, messageDataHash, tokenFeeAmount);
}

function _transferFunds(uint256 amount) internal override {
function _transferFunds(
uint256 amount
) internal override {
// fetch native token from Inbox
IERC20(nativeToken).safeTransferFrom(msg.sender, address(this), amount);
}
Expand Down
12 changes: 9 additions & 3 deletions src/bridge/ERC20Inbox.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol
contract ERC20Inbox is AbsInbox, IERC20Inbox {
using SafeERC20 for IERC20;

constructor(uint256 _maxDataSize) AbsInbox(_maxDataSize) {}
constructor(
uint256 _maxDataSize
) AbsInbox(_maxDataSize) {}

/// @inheritdoc IInboxBase
function initialize(
Expand All @@ -41,7 +43,9 @@ contract ERC20Inbox is AbsInbox, IERC20Inbox {
}

/// @inheritdoc IERC20Inbox
function depositERC20(uint256 amount) public whenNotPaused onlyAllowed returns (uint256) {
function depositERC20(
uint256 amount
) public whenNotPaused onlyAllowed returns (uint256) {
address dest = msg.sender;

// solhint-disable-next-line avoid-tx-origin
Expand Down Expand Up @@ -136,7 +140,9 @@ contract ERC20Inbox is AbsInbox, IERC20Inbox {
}

/// @inheritdoc AbsInbox
function _fromNativeTo18Decimals(uint256 value) internal view override returns (uint256) {
function _fromNativeTo18Decimals(
uint256 value
) internal view override returns (uint256) {
// In order to keep compatibility of child chain's native currency with external 3rd party tooling we
// expect 18 decimals to be always used for native currency. If native token uses different number of
// decimals then here it will be normalized to 18. Keep in mind, when withdrawing from child chain back
Expand Down
8 changes: 6 additions & 2 deletions src/bridge/ERC20Outbox.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,18 @@ contract ERC20Outbox is AbsOutbox {
}

/// @inheritdoc AbsOutbox
function _getAmountToUnlock(uint256 value) internal view override returns (uint256) {
function _getAmountToUnlock(
uint256 value
) internal view override returns (uint256) {
uint8 nativeTokenDecimals = IERC20Bridge(address(bridge)).nativeTokenDecimals();
// this might revert due to overflow, but we assume the token supply is less than 2^256
return DecimalsConverterHelper.adjustDecimals(value, 18, nativeTokenDecimals);
}

/// @inheritdoc AbsOutbox
function _amountToSetInContext(uint256 value) internal pure override returns (uint256) {
function _amountToSetInContext(
uint256 value
) internal pure override returns (uint256) {
// native token withdrawal amount which can be fetched from context
return value;
}
Expand Down
Loading

0 comments on commit ae75f0b

Please sign in to comment.