diff --git a/src/assertionStakingPool/AbsBoldStakingPool.sol b/src/assertionStakingPool/AbsBoldStakingPool.sol index 404f0154..14d37c5e 100644 --- a/src/assertionStakingPool/AbsBoldStakingPool.sol +++ b/src/assertionStakingPool/AbsBoldStakingPool.sol @@ -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(); } @@ -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(); } diff --git a/src/assertionStakingPool/AssertionStakingPool.sol b/src/assertionStakingPool/AssertionStakingPool.sol index 0ee6c87b..72ed830c 100644 --- a/src/assertionStakingPool/AssertionStakingPool.sol +++ b/src/assertionStakingPool/AssertionStakingPool.sol @@ -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); diff --git a/src/assertionStakingPool/EdgeStakingPool.sol b/src/assertionStakingPool/EdgeStakingPool.sol index 08aeaaa8..5bc06478 100644 --- a/src/assertionStakingPool/EdgeStakingPool.sol +++ b/src/assertionStakingPool/EdgeStakingPool.sol @@ -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); diff --git a/src/assertionStakingPool/interfaces/IAbsBoldStakingPool.sol b/src/assertionStakingPool/interfaces/IAbsBoldStakingPool.sol index 778097fe..46a47872 100644 --- a/src/assertionStakingPool/interfaces/IAbsBoldStakingPool.sol +++ b/src/assertionStakingPool/interfaces/IAbsBoldStakingPool.sol @@ -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; @@ -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); } diff --git a/src/assertionStakingPool/interfaces/IAssertionStakingPool.sol b/src/assertionStakingPool/interfaces/IAssertionStakingPool.sol index 82e6b609..470f9677 100644 --- a/src/assertionStakingPool/interfaces/IAssertionStakingPool.sol +++ b/src/assertionStakingPool/interfaces/IAssertionStakingPool.sol @@ -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) diff --git a/src/assertionStakingPool/interfaces/IEdgeStakingPool.sol b/src/assertionStakingPool/interfaces/IEdgeStakingPool.sol index 60fd7954..fa2a40c3 100644 --- a/src/assertionStakingPool/interfaces/IEdgeStakingPool.sol +++ b/src/assertionStakingPool/interfaces/IEdgeStakingPool.sol @@ -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); diff --git a/src/bridge/AbsBridge.sol b/src/bridge/AbsBridge.sol index 568c0f0a..2979a760 100644 --- a/src/bridge/AbsBridge.sol +++ b/src/bridge/AbsBridge.sol @@ -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)); } @@ -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; } @@ -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); } @@ -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; } @@ -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, diff --git a/src/bridge/AbsInbox.sol b/src/bridge/AbsInbox.sol index 830111a6..95c0fbcf 100644 --- a/src/bridge/AbsInbox.sol +++ b/src/bridge/AbsInbox.sol @@ -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); @@ -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; } @@ -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(); } @@ -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 diff --git a/src/bridge/AbsOutbox.sol b/src/bridge/AbsOutbox.sol index 3de0d847..173b0a05 100644 --- a/src/bridge/AbsOutbox.sol +++ b/src/bridge/AbsOutbox.sol @@ -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 @@ -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); } @@ -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 diff --git a/src/bridge/Bridge.sol b/src/bridge/Bridge.sol index 87a87125..1688321f 100644 --- a/src/bridge/Bridge.sol +++ b/src/bridge/Bridge.sol @@ -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_; } @@ -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 } diff --git a/src/bridge/DelayBuffer.sol b/src/bridge/DelayBuffer.sol index c41a5326..a059e3e3 100644 --- a/src/bridge/DelayBuffer.sol +++ b/src/bridge/DelayBuffer.sol @@ -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; } diff --git a/src/bridge/ERC20Bridge.sol b/src/bridge/ERC20Bridge.sol index 4b14a157..559bd7b0 100644 --- a/src/bridge/ERC20Bridge.sol +++ b/src/bridge/ERC20Bridge.sol @@ -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); } diff --git a/src/bridge/ERC20Inbox.sol b/src/bridge/ERC20Inbox.sol index 911cf204..303397f2 100644 --- a/src/bridge/ERC20Inbox.sol +++ b/src/bridge/ERC20Inbox.sol @@ -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( @@ -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 @@ -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 diff --git a/src/bridge/ERC20Outbox.sol b/src/bridge/ERC20Outbox.sol index 5787468a..b8f82c57 100644 --- a/src/bridge/ERC20Outbox.sol +++ b/src/bridge/ERC20Outbox.sol @@ -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; } diff --git a/src/bridge/GasRefunder.sol b/src/bridge/GasRefunder.sol index 53c5f88d..2c29cba6 100644 --- a/src/bridge/GasRefunder.sol +++ b/src/bridge/GasRefunder.sol @@ -90,16 +90,22 @@ contract GasRefunder is IGasRefunder, Ownable { }); } - function setDisallower(address addr) external onlyOwner { + function setDisallower( + address addr + ) external onlyOwner { disallower = addr; emit DisallowerSet(addr); } - function allowContracts(address[] calldata addresses) external onlyOwner { + function allowContracts( + address[] calldata addresses + ) external onlyOwner { setContractsAllowedImpl(addresses, true); } - function disallowContracts(address[] calldata addresses) external { + function disallowContracts( + address[] calldata addresses + ) external { require(msg.sender == owner() || msg.sender == disallower, "NOT_AUTHORIZED"); setContractsAllowedImpl(addresses, false); } @@ -112,11 +118,15 @@ contract GasRefunder is IGasRefunder, Ownable { } } - function allowRefundees(address[] calldata addresses) external onlyOwner { + function allowRefundees( + address[] calldata addresses + ) external onlyOwner { setRefundeesAllowedImpl(addresses, true); } - function disallowRefundees(address[] calldata addresses) external { + function disallowRefundees( + address[] calldata addresses + ) external { require(msg.sender == owner() || msg.sender == disallower, "NOT_AUTHORIZED"); setRefundeesAllowedImpl(addresses, false); } @@ -129,32 +139,44 @@ contract GasRefunder is IGasRefunder, Ownable { } } - function setMaxRefundeeBalance(uint128 newValue) external onlyOwner { + function setMaxRefundeeBalance( + uint128 newValue + ) external onlyOwner { commonParams.maxRefundeeBalance = newValue; emit CommonParameterSet(CommonParameterKey.MAX_REFUNDEE_BALANCE, newValue); } - function setExtraGasMargin(uint32 newValue) external onlyOwner { + function setExtraGasMargin( + uint32 newValue + ) external onlyOwner { commonParams.extraGasMargin = newValue; emit CommonParameterSet(CommonParameterKey.EXTRA_GAS_MARGIN, newValue); } - function setCalldataCost(uint8 newValue) external onlyOwner { + function setCalldataCost( + uint8 newValue + ) external onlyOwner { commonParams.calldataCost = newValue; emit CommonParameterSet(CommonParameterKey.CALLDATA_COST, newValue); } - function setMaxGasTip(uint64 newValue) external onlyOwner { + function setMaxGasTip( + uint64 newValue + ) external onlyOwner { commonParams.maxGasTip = newValue; emit CommonParameterSet(CommonParameterKey.MAX_GAS_TIP, newValue); } - function setMaxGasCost(uint64 newValue) external onlyOwner { + function setMaxGasCost( + uint64 newValue + ) external onlyOwner { commonParams.maxGasCost = newValue; emit CommonParameterSet(CommonParameterKey.MAX_GAS_COST, newValue); } - function setMaxSingleGasUsage(uint32 newValue) external onlyOwner { + function setMaxSingleGasUsage( + uint32 newValue + ) external onlyOwner { commonParams.maxSingleGasUsage = newValue; emit CommonParameterSet(CommonParameterKey.MAX_SINGLE_GAS_USAGE, newValue); } diff --git a/src/bridge/IBridge.sol b/src/bridge/IBridge.sol index e301408e..3b2dcdc4 100644 --- a/src/bridge/IBridge.sol +++ b/src/bridge/IBridge.sol @@ -53,15 +53,23 @@ interface IBridge { event RollupUpdated(address rollup); - function allowedDelayedInboxList(uint256) external returns (address); + function allowedDelayedInboxList( + uint256 + ) external returns (address); - function allowedOutboxList(uint256) external returns (address); + function allowedOutboxList( + uint256 + ) external returns (address); /// @dev Accumulator for delayed inbox messages; tail represents hash of the current state; each element represents the inclusion of a new message. - function delayedInboxAccs(uint256) external view returns (bytes32); + function delayedInboxAccs( + uint256 + ) external view returns (bytes32); /// @dev Accumulator for sequencer inbox messages; tail represents hash of the current state; each element represents the inclusion of a new message. - function sequencerInboxAccs(uint256) external view returns (bytes32); + function sequencerInboxAccs( + uint256 + ) external view returns (bytes32); function rollup() external view returns (IOwnable); @@ -69,9 +77,13 @@ interface IBridge { function activeOutbox() external view returns (address); - function allowedDelayedInboxes(address inbox) external view returns (bool); + function allowedDelayedInboxes( + address inbox + ) external view returns (bool); - function allowedOutboxes(address outbox) external view returns (bool); + function allowedOutboxes( + address outbox + ) external view returns (bool); function sequencerReportedSubMessageCount() external view returns (uint256); @@ -109,11 +121,15 @@ interface IBridge { // ---------- onlyRollupOrOwner functions ---------- - function setSequencerInbox(address _sequencerInbox) external; + function setSequencerInbox( + address _sequencerInbox + ) external; function setDelayedInbox(address inbox, bool enabled) external; function setOutbox(address inbox, bool enabled) external; - function updateRollupAddress(IOwnable _rollup) external; + function updateRollupAddress( + IOwnable _rollup + ) external; } diff --git a/src/bridge/IERC20Inbox.sol b/src/bridge/IERC20Inbox.sol index d74185b5..d13f159d 100644 --- a/src/bridge/IERC20Inbox.sol +++ b/src/bridge/IERC20Inbox.sol @@ -14,7 +14,9 @@ interface IERC20Inbox is IInboxBase { * Look into retryable tickets if you are interested in this functionality. * @dev This function should not be called inside contract constructors */ - function depositERC20(uint256 amount) external returns (uint256); + function depositERC20( + uint256 amount + ) external returns (uint256); /** * @notice Put a message in the L2 inbox that can be reexecuted for some fixed amount of time if it reverts diff --git a/src/bridge/IEthBridge.sol b/src/bridge/IEthBridge.sol index d9115b0e..d1ea6b3b 100644 --- a/src/bridge/IEthBridge.sol +++ b/src/bridge/IEthBridge.sol @@ -22,5 +22,7 @@ interface IEthBridge is IBridge { // ---------- initializer ---------- - function initialize(IOwnable rollup_) external; + function initialize( + IOwnable rollup_ + ) external; } diff --git a/src/bridge/IInbox.sol b/src/bridge/IInbox.sol index c304f0c9..cea3bea3 100644 --- a/src/bridge/IInbox.sol +++ b/src/bridge/IInbox.sol @@ -129,5 +129,7 @@ interface IInbox is IInboxBase { * @dev function to be called one time during the inbox upgrade process * this is used to fix the storage slots */ - function postUpgradeInit(IBridge _bridge) external; + function postUpgradeInit( + IBridge _bridge + ) external; } diff --git a/src/bridge/IInboxBase.sol b/src/bridge/IInboxBase.sol index 211dd0fd..0c8b836b 100644 --- a/src/bridge/IInboxBase.sol +++ b/src/bridge/IInboxBase.sol @@ -17,14 +17,18 @@ interface IInboxBase is IDelayedMessageProvider { function maxDataSize() external view returns (uint256); /// @dev Deprecated due to EIP-3074 - function sendL2MessageFromOrigin(bytes calldata) external returns (uint256); + function sendL2MessageFromOrigin( + bytes calldata + ) external returns (uint256); /** * @notice Send a generic L2 message to the chain * @dev This method can be used to send any type of message that doesn't require L1 validation * @param messageData Data of the message being sent */ - function sendL2Message(bytes calldata messageData) external returns (uint256); + function sendL2Message( + bytes calldata messageData + ) external returns (uint256); function sendUnsignedTransaction( uint256 gasLimit, @@ -67,10 +71,14 @@ interface IInboxBase is IDelayedMessageProvider { function setAllowList(address[] memory user, bool[] memory val) external; /// @notice enable or disable allowList - function setAllowListEnabled(bool _allowListEnabled) external; + function setAllowListEnabled( + bool _allowListEnabled + ) external; /// @notice check if user is in allowList - function isAllowed(address user) external view returns (bool); + function isAllowed( + address user + ) external view returns (bool); /// @notice check if allowList is enabled function allowListEnabled() external view returns (bool); diff --git a/src/bridge/IOutbox.sol b/src/bridge/IOutbox.sol index 8605469c..0491159c 100644 --- a/src/bridge/IOutbox.sol +++ b/src/bridge/IOutbox.sol @@ -13,15 +13,21 @@ interface IOutbox { address indexed to, address indexed l2Sender, uint256 indexed zero, uint256 transactionIndex ); - function initialize(IBridge _bridge) external; + function initialize( + IBridge _bridge + ) external; function rollup() external view returns (address); // the rollup contract function bridge() external view returns (IBridge); // the bridge contract - function spent(uint256) external view returns (bytes32); // packed spent bitmap + function spent( + uint256 + ) external view returns (bytes32); // packed spent bitmap - function roots(bytes32) external view returns (bytes32); // maps root hashes => L2 block hash + function roots( + bytes32 + ) external view returns (bytes32); // maps root hashes => L2 block hash // solhint-disable-next-line func-name-mixedcase function OUTBOX_VERSION() external view returns (uint128); // the outbox version @@ -101,7 +107,9 @@ interface IOutbox { * @param index Merkle path to message * @return true if the message has been spent */ - function isSpent(uint256 index) external view returns (bool); + function isSpent( + uint256 index + ) external view returns (bool); function calculateItemHash( address l2Sender, diff --git a/src/bridge/ISequencerInbox.sol b/src/bridge/ISequencerInbox.sol index af725eae..291ee87f 100644 --- a/src/bridge/ISequencerInbox.sol +++ b/src/bridge/ISequencerInbox.sol @@ -115,9 +115,13 @@ interface ISequencerInbox is IDelayedMessageProvider { function rollup() external view returns (IOwnable); - function isBatchPoster(address) external view returns (bool); + function isBatchPoster( + address + ) external view returns (bool); - function isSequencer(address) external view returns (bool); + function isSequencer( + address + ) external view returns (bool); /// @notice True is the sequencer inbox is delay bufferable function isDelayBufferable() external view returns (bool); @@ -144,7 +148,9 @@ interface ISequencerInbox is IDelayedMessageProvider { uint256 futureSeconds ); - function dasKeySetInfo(bytes32) external view returns (bool, uint64); + function dasKeySetInfo( + bytes32 + ) external view returns (bool, uint64); /// @notice Remove force inclusion delay after a L1 chainId fork function removeDelayAfterFork() external; @@ -168,14 +174,20 @@ interface ISequencerInbox is IDelayedMessageProvider { bytes32 messageDataHash ) external; - function inboxAccs(uint256 index) external view returns (bytes32); + function inboxAccs( + uint256 index + ) external view returns (bytes32); function batchCount() external view returns (uint256); - function isValidKeysetHash(bytes32 ksHash) external view returns (bool); + function isValidKeysetHash( + bytes32 ksHash + ) external view returns (bool); /// @notice the creation block is intended to still be available after a keyset is deleted - function getKeysetCreationBlock(bytes32 ksHash) external view returns (uint256); + function getKeysetCreationBlock( + bytes32 ksHash + ) external view returns (uint256); /// @dev The delay buffer can change due to pending depletion/replenishment. /// This function applies pending buffer changes to proactively calculate the force inclusion deadline. @@ -266,7 +278,9 @@ interface ISequencerInbox is IDelayedMessageProvider { * @notice Set max delay for sequencer inbox * @param maxTimeVariation_ the maximum time variation parameters */ - function setMaxTimeVariation(MaxTimeVariation memory maxTimeVariation_) external; + function setMaxTimeVariation( + MaxTimeVariation memory maxTimeVariation_ + ) external; /** * @notice Updates whether an address is authorized to be a batch poster at the sequencer inbox @@ -279,13 +293,17 @@ interface ISequencerInbox is IDelayedMessageProvider { * @notice Makes Data Availability Service keyset valid * @param keysetBytes bytes of the serialized keyset */ - function setValidKeyset(bytes calldata keysetBytes) external; + function setValidKeyset( + bytes calldata keysetBytes + ) external; /** * @notice Invalidates a Data Availability Service keyset * @param ksHash hash of the keyset */ - function invalidateKeysetHash(bytes32 ksHash) external; + function invalidateKeysetHash( + bytes32 ksHash + ) external; /** * @notice Updates whether an address is authorized to be a sequencer. @@ -299,7 +317,9 @@ interface ISequencerInbox is IDelayedMessageProvider { * @notice Updates the batch poster manager, the address which has the ability to rotate batch poster keys * @param newBatchPosterManager The new batch poster manager to be set */ - function setBatchPosterManager(address newBatchPosterManager) external; + function setBatchPosterManager( + address newBatchPosterManager + ) external; /// @notice Allows the rollup owner to sync the rollup address function updateRollupAddress() external; diff --git a/src/bridge/Inbox.sol b/src/bridge/Inbox.sol index b3f3d3dd..8559bf21 100644 --- a/src/bridge/Inbox.sol +++ b/src/bridge/Inbox.sol @@ -27,7 +27,9 @@ import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol"; * to await inclusion in the SequencerInbox */ contract Inbox is AbsInbox, IInbox { - constructor(uint256 _maxDataSize) AbsInbox(_maxDataSize) {} + constructor( + uint256 _maxDataSize + ) AbsInbox(_maxDataSize) {} /// @inheritdoc IInboxBase function initialize( @@ -38,7 +40,9 @@ contract Inbox is AbsInbox, IInbox { } /// @inheritdoc IInbox - function postUpgradeInit(IBridge) external onlyDelegated onlyProxyOwner {} + function postUpgradeInit( + IBridge + ) external onlyDelegated onlyProxyOwner {} /// @inheritdoc IInbox function sendL1FundedUnsignedTransaction( @@ -207,7 +211,9 @@ contract Inbox is AbsInbox, IInbox { } /// @notice deprecated in favour of depositEth with no parameters - function depositEth(uint256) external payable whenNotPaused onlyAllowed returns (uint256) { + function depositEth( + uint256 + ) external payable whenNotPaused onlyAllowed returns (uint256) { return depositEth(); } @@ -317,7 +323,9 @@ contract Inbox is AbsInbox, IInbox { } /// @inheritdoc AbsInbox - function _fromNativeTo18Decimals(uint256 value) internal pure override returns (uint256) { + function _fromNativeTo18Decimals( + uint256 value + ) internal pure override returns (uint256) { return value; } } diff --git a/src/bridge/Messages.sol b/src/bridge/Messages.sol index 669e81ff..0067c353 100644 --- a/src/bridge/Messages.sol +++ b/src/bridge/Messages.sol @@ -17,7 +17,9 @@ library Messages { bytes32 messageDataHash; } - function messageHash(Message memory message) internal pure returns (bytes32) { + function messageHash( + Message memory message + ) internal pure returns (bytes32) { return messageHash( message.kind, message.sender, diff --git a/src/bridge/Outbox.sol b/src/bridge/Outbox.sol index 17d95445..8eade0da 100644 --- a/src/bridge/Outbox.sol +++ b/src/bridge/Outbox.sol @@ -15,12 +15,16 @@ contract Outbox is AbsOutbox { } /// @inheritdoc AbsOutbox - function _getAmountToUnlock(uint256 value) internal pure override returns (uint256) { + function _getAmountToUnlock( + uint256 value + ) internal pure override returns (uint256) { return value; } /// @inheritdoc AbsOutbox - function _amountToSetInContext(uint256) internal pure override returns (uint256) { + function _amountToSetInContext( + uint256 + ) internal pure override returns (uint256) { // In ETH-based chains withdrawal amount can be read from msg.value. For that reason // amount slot in context will never be accessed, we keep it as 0 all the time return 0; diff --git a/src/bridge/SequencerInbox.sol b/src/bridge/SequencerInbox.sol index 45785bff..808de701 100644 --- a/src/bridge/SequencerInbox.sol +++ b/src/bridge/SequencerInbox.sol @@ -543,7 +543,9 @@ contract SequencerInbox is DelegateCallAware, GasRefundEnabled, ISequencerInbox } } - function isDelayProofRequired(uint256 afterDelayedMessagesRead) internal view returns (bool) { + function isDelayProofRequired( + uint256 afterDelayedMessagesRead + ) internal view returns (bool) { // if no new delayed messages are read, no buffer updates can be applied, so no proof required // if the buffer is synced, the buffer cannot be depleted, so no proof is required return isDelayBufferable && afterDelayedMessagesRead > totalDelayedMessagesRead @@ -583,7 +585,9 @@ contract SequencerInbox is DelegateCallAware, GasRefundEnabled, ISequencerInbox /// therefore we restrict which flags can be provided as a header in this field /// This also safe guards unused flags for future use, as we know they would have been disallowed up until this point /// @param headerByte The first byte in the calldata - function isValidCallDataFlag(bytes1 headerByte) internal pure returns (bool) { + function isValidCallDataFlag( + bytes1 headerByte + ) internal pure returns (bool) { return headerByte == BROTLI_MESSAGE_HEADER_FLAG || headerByte == DAS_MESSAGE_HEADER_FLAG || (headerByte == (DAS_MESSAGE_HEADER_FLAG | TREE_DAS_MESSAGE_HEADER_FLAG)) || headerByte == ZERO_HEAVY_MESSAGE_HEADER_FLAG; @@ -704,7 +708,9 @@ contract SequencerInbox is DelegateCallAware, GasRefundEnabled, ISequencerInbox } } - function inboxAccs(uint256 index) external view returns (bytes32) { + function inboxAccs( + uint256 index + ) external view returns (bytes32) { return bridge.sequencerInboxAccs(index); } @@ -713,7 +719,9 @@ contract SequencerInbox is DelegateCallAware, GasRefundEnabled, ISequencerInbox } /// @inheritdoc ISequencerInbox - function forceInclusionDeadline(uint64 blockNumber) external view returns (uint64) { + function forceInclusionDeadline( + uint64 blockNumber + ) external view returns (uint64) { uint64 _delayBlocks = delayBlocks; if (isDelayBufferable) { uint64 _buffer = buffer.calcPendingBuffer(blockNumber); @@ -723,11 +731,15 @@ contract SequencerInbox is DelegateCallAware, GasRefundEnabled, ISequencerInbox } /// @notice Calculates the buffer dependent delay blocks - function delayBufferableBlocks(uint64 _buffer) internal view returns (uint64) { + function delayBufferableBlocks( + uint64 _buffer + ) internal view returns (uint64) { return _buffer < delayBlocks ? _buffer : delayBlocks; } - function _setBufferConfig(BufferConfig memory bufferConfig_) internal { + function _setBufferConfig( + BufferConfig memory bufferConfig_ + ) internal { if (!isDelayBufferable) revert NotDelayBufferable(); if (!DelayBuffer.isValidBufferConfig(bufferConfig_)) revert BadBufferConfig(); @@ -784,7 +796,9 @@ contract SequencerInbox is DelegateCallAware, GasRefundEnabled, ISequencerInbox } /// @inheritdoc ISequencerInbox - function setValidKeyset(bytes calldata keysetBytes) external onlyRollupOwner { + function setValidKeyset( + bytes calldata keysetBytes + ) external onlyRollupOwner { uint256 ksWord = uint256(keccak256(bytes.concat(hex"fe", keccak256(keysetBytes)))); bytes32 ksHash = bytes32(ksWord ^ (1 << 255)); if (keysetBytes.length >= 64 * 1024) revert KeysetTooLarge(); @@ -801,7 +815,9 @@ contract SequencerInbox is DelegateCallAware, GasRefundEnabled, ISequencerInbox } /// @inheritdoc ISequencerInbox - function invalidateKeysetHash(bytes32 ksHash) external onlyRollupOwner { + function invalidateKeysetHash( + bytes32 ksHash + ) external onlyRollupOwner { if (!dasKeySetInfo[ksHash].isValidKeyset) revert NoSuchKeyset(ksHash); // we don't delete the block creation value since its used to fetch the SetValidKeyset // event efficiently. The event provides the hash preimage of the key. @@ -822,23 +838,31 @@ contract SequencerInbox is DelegateCallAware, GasRefundEnabled, ISequencerInbox } /// @inheritdoc ISequencerInbox - function setBatchPosterManager(address newBatchPosterManager) external onlyRollupOwner { + function setBatchPosterManager( + address newBatchPosterManager + ) external onlyRollupOwner { batchPosterManager = newBatchPosterManager; emit BatchPosterManagerSet(newBatchPosterManager); emit OwnerFunctionCalled(5); } - function setBufferConfig(BufferConfig memory bufferConfig_) external onlyRollupOwner { + function setBufferConfig( + BufferConfig memory bufferConfig_ + ) external onlyRollupOwner { _setBufferConfig(bufferConfig_); emit BufferConfigSet(bufferConfig_); } - function isValidKeysetHash(bytes32 ksHash) external view returns (bool) { + function isValidKeysetHash( + bytes32 ksHash + ) external view returns (bool) { return dasKeySetInfo[ksHash].isValidKeyset; } /// @inheritdoc ISequencerInbox - function getKeysetCreationBlock(bytes32 ksHash) external view returns (uint256) { + function getKeysetCreationBlock( + bytes32 ksHash + ) external view returns (uint256) { DasKeySetInfo memory ksInfo = dasKeySetInfo[ksHash]; if (ksInfo.creationBlock == 0) revert NoSuchKeyset(ksHash); return uint256(ksInfo.creationBlock); diff --git a/src/chain/CacheManager.sol b/src/chain/CacheManager.sol index 23fe4ba4..beffbf3a 100644 --- a/src/chain/CacheManager.sol +++ b/src/chain/CacheManager.sol @@ -65,13 +65,17 @@ contract CacheManager is Initializable, DelegateCallAware { } /// @notice Sets the intended cache size. Note that the queue may temporarily be larger. - function setCacheSize(uint64 newSize) external onlyOwner { + function setCacheSize( + uint64 newSize + ) external onlyOwner { cacheSize = newSize; emit SetCacheSize(newSize); } /// @notice Sets the intended decay factor. Does not modify existing bids. - function setDecayRate(uint64 newDecay) external onlyOwner { + function setDecayRate( + uint64 newDecay + ) external onlyOwner { decay = newDecay; emit SetDecayRate(newDecay); } @@ -95,7 +99,9 @@ contract CacheManager is Initializable, DelegateCallAware { } /// @notice Evicts up to `count` programs from the cache. - function evictPrograms(uint256 count) public onlyOwner { + function evictPrograms( + uint256 count + ) public onlyOwner { while (bids.length() != 0 && count > 0) { (uint192 bid, uint64 index) = _getBid(bids.pop()); _deleteEntry(bid, index); @@ -110,7 +116,9 @@ contract CacheManager is Initializable, DelegateCallAware { /// @notice Returns the `k` smallest entries in the cache sorted in ascending order. /// If the cache have less than `k` entries, returns all entries. - function getSmallestEntries(uint256 k) public view returns (Entry[] memory result) { + function getSmallestEntries( + uint256 k + ) public view returns (Entry[] memory result) { if (bids.length() < k) { k = bids.length(); } @@ -124,7 +132,9 @@ contract CacheManager is Initializable, DelegateCallAware { /// @notice Returns the minimum bid required to cache a program of the given size. /// Value returned here is the minimum bid that you can send with msg.value - function getMinBid(uint64 size) public view returns (uint192 min) { + function getMinBid( + uint64 size + ) public view returns (uint192 min) { if (size > cacheSize) { revert AsmTooLarge(size, 0, cacheSize); } @@ -156,13 +166,17 @@ contract CacheManager is Initializable, DelegateCallAware { /// @notice Returns the minimum bid required to cache the program with given codehash. /// Value returned here is the minimum bid that you can send with msg.value - function getMinBid(bytes32 codehash) public view returns (uint192 min) { + function getMinBid( + bytes32 codehash + ) public view returns (uint192 min) { return getMinBid(_asmSize(codehash)); } /// @notice Returns the minimum bid required to cache the program at given address. /// Value returned here is the minimum bid that you can send with msg.value - function getMinBid(address program) external view returns (uint192 min) { + function getMinBid( + address program + ) external view returns (uint192 min) { return getMinBid(program.codehash); } @@ -179,7 +193,9 @@ contract CacheManager is Initializable, DelegateCallAware { } /// Places a bid, reverting if payment is insufficient. - function placeBid(address program) external payable { + function placeBid( + address program + ) external payable { if (isPaused) { revert BidsArePaused(); } @@ -196,7 +212,9 @@ contract CacheManager is Initializable, DelegateCallAware { /// @notice Evicts entries until enough space exists in the cache, reverting if payment is insufficient. /// Returns the new amount of space available on success. /// @dev Will revert for requests larger than 5Mb. Call repeatedly for more. - function makeSpace(uint64 size) external payable returns (uint64 space) { + function makeSpace( + uint64 size + ) external payable returns (uint64 space) { if (isPaused) { revert BidsArePaused(); } @@ -212,7 +230,9 @@ contract CacheManager is Initializable, DelegateCallAware { } /// @dev Converts a value to a bid by adding the time decay term. - function _toBid(uint256 value) internal view returns (uint192 bid) { + function _toBid( + uint256 value + ) internal view returns (uint192 bid) { uint256 _bid = value + _calcDecay(); if (_bid > type(uint192).max) { revert BidTooLarge(_bid); @@ -222,7 +242,9 @@ contract CacheManager is Initializable, DelegateCallAware { /// @dev Evicts entries until enough space exists in the cache, reverting if payment is insufficient. /// Returns the bid and the index to use for insertion. - function _makeSpace(uint64 size) internal returns (uint192 bid, uint64 index) { + function _makeSpace( + uint64 size + ) internal returns (uint192 bid, uint64 index) { // discount historical bids by the number of seconds bid = _toBid(msg.value); index = uint64(entries.length); @@ -273,7 +295,9 @@ contract CacheManager is Initializable, DelegateCallAware { } /// @dev Gets the bid and index from a packed bid item - function _getBid(uint256 info) internal pure returns (uint192 bid, uint64 index) { + function _getBid( + uint256 info + ) internal pure returns (uint192 bid, uint64 index) { bid = uint192(info >> 64); index = uint64(info); } @@ -284,13 +308,17 @@ contract CacheManager is Initializable, DelegateCallAware { } /// @dev Gets the size of the given program in bytes - function _asmSize(bytes32 codehash) internal view returns (uint64) { + function _asmSize( + bytes32 codehash + ) internal view returns (uint64) { uint32 size = ARB_WASM.codehashAsmSize(codehash); return uint64(size >= MIN_CODESIZE ? size : MIN_CODESIZE); // pretend it's at least 4Kb } /// @dev Determines whether a program is cached - function _isCached(bytes32 codehash) internal view returns (bool) { + function _isCached( + bytes32 codehash + ) internal view returns (bool) { return ARB_WASM_CACHE.codehashIsCached(codehash); } } diff --git a/src/challengeV2/EdgeChallengeManager.sol b/src/challengeV2/EdgeChallengeManager.sol index 2c40a4e5..42a6fb31 100644 --- a/src/challengeV2/EdgeChallengeManager.sol +++ b/src/challengeV2/EdgeChallengeManager.sol @@ -51,7 +51,9 @@ interface IEdgeChallengeManager { /// @notice Performs necessary checks and creates a new layer zero edge /// @param args Edge creation args - function createLayerZeroEdge(CreateEdgeArgs calldata args) external returns (bytes32); + function createLayerZeroEdge( + CreateEdgeArgs calldata args + ) external returns (bytes32); /// @notice Bisect an edge. This creates two child edges: /// lowerChild: has the same start root and height as this edge, but a different end root and height @@ -132,11 +134,15 @@ interface IEdgeChallengeManager { /// @notice When zero layer block edges are created a stake is also provided /// The stake on this edge can be refunded if the edge is confirme - function refundStake(bytes32 edgeId) external; + function refundStake( + bytes32 edgeId + ) external; /// @notice Zero layer edges have to be a fixed height. /// This function returns the end height for a given edge type - function getLayerZeroEndHeight(EdgeType eType) external view returns (uint256); + function getLayerZeroEndHeight( + EdgeType eType + ) external view returns (uint256); /// @notice Calculate the unique id of an edge /// @param level The level of the edge @@ -170,41 +176,59 @@ interface IEdgeChallengeManager { ) external pure returns (bytes32); /// @notice Has the edge already been stored in the manager - function edgeExists(bytes32 edgeId) external view returns (bool); + function edgeExists( + bytes32 edgeId + ) external view returns (bool); /// @notice Get full edge data for an edge - function getEdge(bytes32 edgeId) external view returns (ChallengeEdge memory); + function getEdge( + bytes32 edgeId + ) external view returns (ChallengeEdge memory); /// @notice The length of the edge, from start height to end height - function edgeLength(bytes32 edgeId) external view returns (uint256); + function edgeLength( + bytes32 edgeId + ) external view returns (uint256); /// @notice Does this edge currently have one or more rivals /// Rival edges share the same mutual id - function hasRival(bytes32 edgeId) external view returns (bool); + function hasRival( + bytes32 edgeId + ) external view returns (bool); /// @notice The confirmed rival of this mutual id /// Returns 0 if one does not exist - function confirmedRival(bytes32 mutualId) external view returns (bytes32); + function confirmedRival( + bytes32 mutualId + ) external view returns (bytes32); /// @notice Does the edge have at least one rival, and it has length one - function hasLengthOneRival(bytes32 edgeId) external view returns (bool); + function hasLengthOneRival( + bytes32 edgeId + ) external view returns (bool); /// @notice The amount of time this edge has spent without rivals /// This value is increasing whilst an edge is unrivaled, once a rival is created /// it is fixed. If an edge has rivals from the moment it is created then it will have /// a zero time unrivaled - function timeUnrivaled(bytes32 edgeId) external view returns (uint256); + function timeUnrivaled( + bytes32 edgeId + ) external view returns (uint256); /// @notice Get the id of the prev assertion that this edge is originates from /// @dev Uses the parent chain to traverse upwards SmallStep->BigStep->Block->Assertion /// until it gets to the origin assertion - function getPrevAssertionHash(bytes32 edgeId) external view returns (bytes32); + function getPrevAssertionHash( + bytes32 edgeId + ) external view returns (bytes32); /// @notice Fetch the raw first rival record for the given mutual id /// @dev Returns 0 if there is no edge with the given mutual id /// Returns a magic value if there is one edge but it is unrivaled /// Returns the id of the second edge created with the mutual id, if > 1 exists - function firstRival(bytes32 mutualId) external view returns (bytes32); + function firstRival( + bytes32 mutualId + ) external view returns (bytes32); /// @notice True if an account has made a layer zero edge with the given mutual id. /// This is only tracked when the validator whitelist is enabled @@ -394,7 +418,9 @@ contract EdgeChallengeManager is IEdgeChallengeManager, Initializable { ///////////////////////////// /// @inheritdoc IEdgeChallengeManager - function createLayerZeroEdge(CreateEdgeArgs calldata args) external returns (bytes32) { + function createLayerZeroEdge( + CreateEdgeArgs calldata args + ) external returns (bytes32) { // Check if whitelist is enabled in the Rollup // We only enforce whitelist in this function as it may exhaust resources bool whitelistEnabled = !assertionChain.validatorWhitelistDisabled(); @@ -622,7 +648,9 @@ contract EdgeChallengeManager is IEdgeChallengeManager, Initializable { } /// @inheritdoc IEdgeChallengeManager - function refundStake(bytes32 edgeId) public { + function refundStake( + bytes32 edgeId + ) public { ChallengeEdge storage edge = store.get(edgeId); // setting refunded also do checks that the edge cannot be refunded twice edge.setRefunded(); @@ -641,7 +669,9 @@ contract EdgeChallengeManager is IEdgeChallengeManager, Initializable { // VIEW ONLY SECTION // /////////////////////// /// @inheritdoc IEdgeChallengeManager - function getLayerZeroEndHeight(EdgeType eType) public view returns (uint256) { + function getLayerZeroEndHeight( + EdgeType eType + ) public view returns (uint256) { if (eType == EdgeType.Block) { return LAYERZERO_BLOCKEDGE_HEIGHT; } else if (eType == EdgeType.BigStep) { @@ -681,47 +711,65 @@ contract EdgeChallengeManager is IEdgeChallengeManager, Initializable { } /// @inheritdoc IEdgeChallengeManager - function edgeExists(bytes32 edgeId) public view returns (bool) { + function edgeExists( + bytes32 edgeId + ) public view returns (bool) { return store.edges[edgeId].exists(); } /// @inheritdoc IEdgeChallengeManager - function getEdge(bytes32 edgeId) public view returns (ChallengeEdge memory) { + function getEdge( + bytes32 edgeId + ) public view returns (ChallengeEdge memory) { return store.get(edgeId); } /// @inheritdoc IEdgeChallengeManager - function edgeLength(bytes32 edgeId) public view returns (uint256) { + function edgeLength( + bytes32 edgeId + ) public view returns (uint256) { return store.get(edgeId).length(); } /// @inheritdoc IEdgeChallengeManager - function hasRival(bytes32 edgeId) public view returns (bool) { + function hasRival( + bytes32 edgeId + ) public view returns (bool) { return store.hasRival(edgeId); } /// @inheritdoc IEdgeChallengeManager - function confirmedRival(bytes32 mutualId) public view returns (bytes32) { + function confirmedRival( + bytes32 mutualId + ) public view returns (bytes32) { return store.confirmedRivals[mutualId]; } /// @inheritdoc IEdgeChallengeManager - function hasLengthOneRival(bytes32 edgeId) public view returns (bool) { + function hasLengthOneRival( + bytes32 edgeId + ) public view returns (bool) { return store.hasLengthOneRival(edgeId); } /// @inheritdoc IEdgeChallengeManager - function timeUnrivaled(bytes32 edgeId) public view returns (uint256) { + function timeUnrivaled( + bytes32 edgeId + ) public view returns (uint256) { return store.timeUnrivaled(edgeId); } /// @inheritdoc IEdgeChallengeManager - function getPrevAssertionHash(bytes32 edgeId) public view returns (bytes32) { + function getPrevAssertionHash( + bytes32 edgeId + ) public view returns (bytes32) { return store.getPrevAssertionHash(edgeId); } /// @inheritdoc IEdgeChallengeManager - function firstRival(bytes32 mutualId) public view returns (bytes32) { + function firstRival( + bytes32 mutualId + ) public view returns (bytes32) { return store.firstRivals[mutualId]; } diff --git a/src/challengeV2/IAssertionChain.sol b/src/challengeV2/IAssertionChain.sol index f668b676..b21d4221 100644 --- a/src/challengeV2/IAssertionChain.sol +++ b/src/challengeV2/IAssertionChain.sol @@ -19,11 +19,21 @@ interface IAssertionChain { bytes32 inboxAcc ) external view; function validateConfig(bytes32 assertionHash, ConfigData calldata configData) external view; - function getFirstChildCreationBlock(bytes32 assertionHash) external view returns (uint64); - function getSecondChildCreationBlock(bytes32 assertionHash) external view returns (uint64); - function isFirstChild(bytes32 assertionHash) external view returns (bool); - function isPending(bytes32 assertionHash) external view returns (bool); - function isValidator(address) external view returns (bool); + function getFirstChildCreationBlock( + bytes32 assertionHash + ) external view returns (uint64); + function getSecondChildCreationBlock( + bytes32 assertionHash + ) external view returns (uint64); + function isFirstChild( + bytes32 assertionHash + ) external view returns (bool); + function isPending( + bytes32 assertionHash + ) external view returns (bool); + function isValidator( + address + ) external view returns (bool); function getValidators() external view returns (address[] memory); function validatorWhitelistDisabled() external view returns (bool); } diff --git a/src/challengeV2/libraries/ChallengeEdgeLib.sol b/src/challengeV2/libraries/ChallengeEdgeLib.sol index 7f6675f2..af4e9293 100644 --- a/src/challengeV2/libraries/ChallengeEdgeLib.sol +++ b/src/challengeV2/libraries/ChallengeEdgeLib.sol @@ -178,13 +178,17 @@ library ChallengeEdgeLib { /// Rivals have the same start height, start history root and end height. They also have the same origin id and level. /// The difference between rivals is that they have a different endHistoryRoot, so that information /// is not included in this hash. - function mutualId(ChallengeEdge storage ce) internal view returns (bytes32) { + function mutualId( + ChallengeEdge storage ce + ) internal view returns (bytes32) { return mutualIdComponent( ce.level, ce.originId, ce.startHeight, ce.startHistoryRoot, ce.endHeight ); } - function mutualIdMem(ChallengeEdge memory ce) internal pure returns (bytes32) { + function mutualIdMem( + ChallengeEdge memory ce + ) internal pure returns (bytes32) { return mutualIdComponent( ce.level, ce.originId, ce.startHeight, ce.startHistoryRoot, ce.endHeight ); @@ -211,7 +215,9 @@ library ChallengeEdgeLib { /// @dev This separate idMem method is to be explicit about when ChallengeEdges are copied into memory. It is /// possible to pass a storage edge to this method and the id be computed correctly, but that would load /// the whole struct into memory, so we're explicit here that this should be used for edges already in memory. - function idMem(ChallengeEdge memory edge) internal pure returns (bytes32) { + function idMem( + ChallengeEdge memory edge + ) internal pure returns (bytes32) { return idComponent( edge.level, edge.originId, @@ -223,7 +229,9 @@ library ChallengeEdgeLib { } /// @notice The id of an edge. Edges are uniquely identified by their id, and commit to the same information - function id(ChallengeEdge storage edge) internal view returns (bytes32) { + function id( + ChallengeEdge storage edge + ) internal view returns (bytes32) { return idComponent( edge.level, edge.originId, @@ -235,13 +243,17 @@ library ChallengeEdgeLib { } /// @notice Does this edge exist in storage - function exists(ChallengeEdge storage edge) internal view returns (bool) { + function exists( + ChallengeEdge storage edge + ) internal view returns (bool) { // All edges have a createdAtBlock number return edge.createdAtBlock != 0; } /// @notice The length of this edge - difference between the start and end heights - function length(ChallengeEdge storage edge) internal view returns (uint256) { + function length( + ChallengeEdge storage edge + ) internal view returns (uint256) { uint256 len = edge.endHeight - edge.startHeight; // It's impossible for a zero length edge to exist if (len == 0) { @@ -268,7 +280,9 @@ library ChallengeEdgeLib { /// @notice Set the status of an edge to Confirmed /// @dev Only Pending edges can be confirmed - function setConfirmed(ChallengeEdge storage edge) internal { + function setConfirmed( + ChallengeEdge storage edge + ) internal { if (edge.status != EdgeStatus.Pending) { revert EdgeNotPending(ChallengeEdgeLib.id(edge), edge.status); } @@ -277,13 +291,17 @@ library ChallengeEdgeLib { } /// @notice Is the edge a layer zero edge. - function isLayerZero(ChallengeEdge storage edge) internal view returns (bool) { + function isLayerZero( + ChallengeEdge storage edge + ) internal view returns (bool) { return edge.claimId != 0 && edge.staker != address(0); } /// @notice Set the refunded flag of an edge /// @dev Checks internally that edge is confirmed, layer zero edge and hasnt been refunded already - function setRefunded(ChallengeEdge storage edge) internal { + function setRefunded( + ChallengeEdge storage edge + ) internal { if (edge.status != EdgeStatus.Confirmed) { revert EdgeNotConfirmed(ChallengeEdgeLib.id(edge), edge.status); } diff --git a/src/challengeV2/libraries/EdgeChallengeManagerLib.sol b/src/challengeV2/libraries/EdgeChallengeManagerLib.sol index 3ff454b4..291fc195 100644 --- a/src/challengeV2/libraries/EdgeChallengeManagerLib.sol +++ b/src/challengeV2/libraries/EdgeChallengeManagerLib.sol @@ -337,7 +337,9 @@ library EdgeChallengeManagerLib { } /// @notice Check that a uint is a power of 2 - function isPowerOfTwo(uint256 x) internal pure returns (bool) { + function isPowerOfTwo( + uint256 x + ) internal pure returns (bool) { // zero is not a power of 2 if (x == 0) { return false; diff --git a/src/challengeV2/libraries/MerkleTreeLib.sol b/src/challengeV2/libraries/MerkleTreeLib.sol index a455bc62..c4a7e02d 100644 --- a/src/challengeV2/libraries/MerkleTreeLib.sol +++ b/src/challengeV2/libraries/MerkleTreeLib.sol @@ -107,7 +107,9 @@ library MerkleTreeLib { /// @dev The root of a tree is defined as the cumulative hashing of the /// roots of all of it's subtrees. Throws error for empty tree /// @param me The merkle expansion to calculate the root of - function root(bytes32[] memory me) internal pure returns (bytes32) { + function root( + bytes32[] memory me + ) internal pure returns (bytes32) { require(me.length > 0, "Empty merkle expansion"); require(me.length <= MAX_LEVEL, "Merkle expansion too large"); @@ -296,7 +298,9 @@ library MerkleTreeLib { /// @notice Calculate the full tree size represented by a merkle expansion /// @param me The merkle expansion to calculate the tree size of - function treeSize(bytes32[] memory me) internal pure returns (uint256) { + function treeSize( + bytes32[] memory me + ) internal pure returns (uint256) { uint256 sum = 0; for (uint256 i = 0; i < me.length; i++) { if (me[i] != 0) { diff --git a/src/challengeV2/libraries/UintUtilsLib.sol b/src/challengeV2/libraries/UintUtilsLib.sol index ad9d8433..840fcf44 100644 --- a/src/challengeV2/libraries/UintUtilsLib.sol +++ b/src/challengeV2/libraries/UintUtilsLib.sol @@ -11,7 +11,9 @@ library UintUtilsLib { /// @dev Zero indexed from the least sig bit. Eg 1010 => 1, 1100 => 2, 1001 => 0 /// Finds lsb in linear (uint size) time /// @param x Cannot be zero, since zero that has no signficant bits - function leastSignificantBit(uint256 x) internal pure returns (uint256 msb) { + function leastSignificantBit( + uint256 x + ) internal pure returns (uint256 msb) { require(x > 0, "Zero has no significant bits"); // isolate the least sig bit @@ -26,7 +28,9 @@ library UintUtilsLib { /// Taken from https://solidity-by-example.org/bitwise/ /// Finds msb in log (uint size) time /// @param x Cannot be zero, since zero has no sigificant bits - function mostSignificantBit(uint256 x) internal pure returns (uint256 msb) { + function mostSignificantBit( + uint256 x + ) internal pure returns (uint256 msb) { require(x != 0, "Zero has no significant bits"); // x >= 2 ** 128 diff --git a/src/libraries/AddressAliasHelper.sol b/src/libraries/AddressAliasHelper.sol index 9320fe3e..aede9b19 100644 --- a/src/libraries/AddressAliasHelper.sol +++ b/src/libraries/AddressAliasHelper.sol @@ -11,7 +11,9 @@ library AddressAliasHelper { /// the inbox to the msg.sender viewed in the L2 /// @param l1Address the address in the L1 that triggered the tx to L2 /// @return l2Address L2 address as viewed in msg.sender - function applyL1ToL2Alias(address l1Address) internal pure returns (address l2Address) { + function applyL1ToL2Alias( + address l1Address + ) internal pure returns (address l2Address) { unchecked { l2Address = address(uint160(l1Address) + OFFSET); } @@ -21,7 +23,9 @@ library AddressAliasHelper { /// address in the L1 that submitted a tx to the inbox /// @param l2Address L2 address as viewed in msg.sender /// @return l1Address the address in the L1 that triggered the tx to L2 - function undoL1ToL2Alias(address l2Address) internal pure returns (address l1Address) { + function undoL1ToL2Alias( + address l2Address + ) internal pure returns (address l1Address) { unchecked { l1Address = address(uint160(l2Address) - OFFSET); } diff --git a/src/libraries/AdminFallbackProxy.sol b/src/libraries/AdminFallbackProxy.sol index 8060ed8e..1888f610 100644 --- a/src/libraries/AdminFallbackProxy.sol +++ b/src/libraries/AdminFallbackProxy.sol @@ -34,7 +34,9 @@ abstract contract DoubleLogicERC1967Upgrade is ERC1967Upgrade { /** * @dev Stores a new address in the EIP1967 implementation slot. */ - function _setSecondaryImplementation(address newImplementation) private { + function _setSecondaryImplementation( + address newImplementation + ) private { require( Address.isContract(newImplementation), "ERC1967: new secondary implementation is not a contract" @@ -47,7 +49,9 @@ abstract contract DoubleLogicERC1967Upgrade is ERC1967Upgrade { * * Emits an {UpgradedSecondary} event. */ - function _upgradeSecondaryTo(address newImplementation) internal { + function _upgradeSecondaryTo( + address newImplementation + ) internal { _setSecondaryImplementation(newImplementation); emit UpgradedSecondary(newImplementation); } diff --git a/src/libraries/CryptographyPrimitives.sol b/src/libraries/CryptographyPrimitives.sol index 2b99bc33..93c46296 100644 --- a/src/libraries/CryptographyPrimitives.sol +++ b/src/libraries/CryptographyPrimitives.sol @@ -9,7 +9,9 @@ library CryptographyPrimitives { // WARNING: This function has the keccak state in a weird order. // If the normal Keccak state is [0, 1, 2, 3, 4, 5, 6, ..., 24] // this function has its state as [0, 5, 10, 15, 20, 1, 6, 11, ..., 24] - function keccakF(uint256[25] memory a) internal pure returns (uint256[25] memory) { + function keccakF( + uint256[25] memory a + ) internal pure returns (uint256[25] memory) { uint256[5] memory c; uint256[5] memory d; //uint D_0; uint D_1; uint D_2; uint D_3; uint D_4; diff --git a/src/libraries/DoubleLogicUUPSUpgradeable.sol b/src/libraries/DoubleLogicUUPSUpgradeable.sol index 0c0a21c0..a2536718 100644 --- a/src/libraries/DoubleLogicUUPSUpgradeable.sol +++ b/src/libraries/DoubleLogicUUPSUpgradeable.sol @@ -26,7 +26,9 @@ abstract contract DoubleLogicUUPSUpgradeable is UUPSUpgradeable, DoubleLogicERC1 * function _authorizeSecondaryUpgrade(address) internal override onlyOwner {} * ``` */ - function _authorizeSecondaryUpgrade(address newImplementation) internal virtual; + function _authorizeSecondaryUpgrade( + address newImplementation + ) internal virtual; /** * @dev Upgrade the secondary implementation of the proxy to `newImplementation`. @@ -35,7 +37,9 @@ abstract contract DoubleLogicUUPSUpgradeable is UUPSUpgradeable, DoubleLogicERC1 * * Emits an {UpgradedSecondary} event. */ - function upgradeSecondaryTo(address newImplementation) external onlyProxy { + function upgradeSecondaryTo( + address newImplementation + ) external onlyProxy { _authorizeSecondaryUpgrade(newImplementation); _upgradeSecondaryToAndCallUUPS(newImplementation, new bytes(0), false); } diff --git a/src/libraries/MerkleLib.sol b/src/libraries/MerkleLib.sol index e58b2ba3..6b7d29bc 100644 --- a/src/libraries/MerkleLib.sol +++ b/src/libraries/MerkleLib.sol @@ -7,7 +7,9 @@ pragma solidity ^0.8.4; import {MerkleProofTooLong} from "./Error.sol"; library MerkleLib { - function generateRoot(bytes32[] memory _hashes) internal pure returns (bytes32) { + function generateRoot( + bytes32[] memory _hashes + ) internal pure returns (bytes32) { bytes32[] memory prevLayer = _hashes; while (prevLayer.length > 1) { bytes32[] memory nextLayer = new bytes32[]((prevLayer.length + 1) / 2); diff --git a/src/mocks/BridgeStub.sol b/src/mocks/BridgeStub.sol index 74ce5505..3c449795 100644 --- a/src/mocks/BridgeStub.sol +++ b/src/mocks/BridgeStub.sol @@ -35,20 +35,28 @@ contract BridgeStub is IBridge, IEthBridge { address public nativeToken; uint8 public nativeTokenDecimals; - function setSequencerInbox(address _sequencerInbox) external override { + function setSequencerInbox( + address _sequencerInbox + ) external override { sequencerInbox = _sequencerInbox; emit SequencerInboxUpdated(_sequencerInbox); } - function allowedDelayedInboxes(address inbox) external view override returns (bool) { + function allowedDelayedInboxes( + address inbox + ) external view override returns (bool) { return allowedDelayedInboxesMap[inbox].allowed; } - function allowedOutboxes(address) external pure override returns (bool) { + function allowedOutboxes( + address + ) external pure override returns (bool) { revert("NOT_IMPLEMENTED"); } - function updateRollupAddress(IOwnable) external pure { + function updateRollupAddress( + IOwnable + ) external pure { revert("NOT_IMPLEMENTED"); } @@ -176,7 +184,9 @@ contract BridgeStub is IBridge, IEthBridge { function acceptFundsFromOldBridge() external payable {} - function initialize(IOwnable) external pure { + function initialize( + IOwnable + ) external pure { revert("NOT_IMPLEMENTED"); } } diff --git a/src/mocks/InboxStub.sol b/src/mocks/InboxStub.sol index cddc70d5..ca56de31 100644 --- a/src/mocks/InboxStub.sol +++ b/src/mocks/InboxStub.sol @@ -48,7 +48,9 @@ contract InboxStub is IInboxBase, IInbox { * @dev This method is an optimization to avoid having to emit the entirety of the messageData in a log. Instead validators are expected to be able to parse the data from the transaction's input * @param messageData Data of the message being sent */ - function sendL2MessageFromOrigin(bytes calldata messageData) external returns (uint256) { + function sendL2MessageFromOrigin( + bytes calldata messageData + ) external returns (uint256) { // solhint-disable-next-line avoid-tx-origin require(msg.sender == tx.origin, "origin only"); uint256 msgNum = deliverToBridge(L2_MSG, msg.sender, keccak256(messageData)); @@ -61,7 +63,9 @@ contract InboxStub is IInboxBase, IInbox { * @dev This method can be used to send any type of message that doesn't require L1 validation * @param messageData Data of the message being sent */ - function sendL2Message(bytes calldata messageData) external override returns (uint256) { + function sendL2Message( + bytes calldata messageData + ) external override returns (uint256) { uint256 msgNum = deliverToBridge(L2_MSG, msg.sender, keccak256(messageData)); emit InboxMessageDelivered(msgNum, messageData); return msgNum; @@ -178,7 +182,9 @@ contract InboxStub is IInboxBase, IInbox { revert("NOT_IMPLEMENTED"); } - function postUpgradeInit(IBridge _bridge) external {} + function postUpgradeInit( + IBridge _bridge + ) external {} function calculateRetryableSubmissionFee( uint256, @@ -191,11 +197,15 @@ contract InboxStub is IInboxBase, IInbox { revert("NOT_IMPLEMENTED"); } - function setAllowListEnabled(bool) external pure { + function setAllowListEnabled( + bool + ) external pure { revert("NOT_IMPLEMENTED"); } - function isAllowed(address) external pure returns (bool) { + function isAllowed( + address + ) external pure returns (bool) { revert("NOT_IMPLEMENTED"); } diff --git a/src/mocks/MerkleTreeAccess.sol b/src/mocks/MerkleTreeAccess.sol index 0ea2b7d1..d85ae8e9 100644 --- a/src/mocks/MerkleTreeAccess.sol +++ b/src/mocks/MerkleTreeAccess.sol @@ -8,15 +8,21 @@ import "../challengeV2/libraries/MerkleTreeLib.sol"; import "../challengeV2/libraries/UintUtilsLib.sol"; contract MerkleTreeAccess { - function mostSignificantBit(uint256 x) external pure returns (uint256) { + function mostSignificantBit( + uint256 x + ) external pure returns (uint256) { return UintUtilsLib.mostSignificantBit(x); } - function leastSignificantBit(uint256 x) external pure returns (uint256) { + function leastSignificantBit( + uint256 x + ) external pure returns (uint256) { return UintUtilsLib.leastSignificantBit(x); } - function root(bytes32[] memory me) external pure returns (bytes32) { + function root( + bytes32[] memory me + ) external pure returns (bytes32) { return MerkleTreeLib.root(me); } diff --git a/src/mocks/MockRollupEventInbox.sol b/src/mocks/MockRollupEventInbox.sol index 3f57dbc4..e3d0da31 100644 --- a/src/mocks/MockRollupEventInbox.sol +++ b/src/mocks/MockRollupEventInbox.sol @@ -25,7 +25,9 @@ contract MockRollupEventInbox is IRollupEventInbox, IDelayedMessageProvider, Del _; } - function initialize(IBridge _bridge) external override onlyDelegated { + function initialize( + IBridge _bridge + ) external override onlyDelegated { if (address(bridge) != address(0)) revert AlreadyInit(); if (address(_bridge) == address(0)) revert HadZeroInit(); bridge = _bridge; diff --git a/src/mocks/MultiCallTest.sol b/src/mocks/MultiCallTest.sol index f5cedd31..8b538c72 100644 --- a/src/mocks/MultiCallTest.sol +++ b/src/mocks/MultiCallTest.sol @@ -26,7 +26,9 @@ contract MultiCallTest { // solhint-disable reason-string // solhint-disable avoid-low-level-calls // solhint-disable-next-line prettier/prettier - fallback(bytes calldata input) external payable returns (bytes memory) { + fallback( + bytes calldata input + ) external payable returns (bytes memory) { require(input.length > 0); uint8 count = uint8(input[0]); input = input[1:]; diff --git a/src/mocks/PendingBlkTimeAndNrAdvanceCheck.sol b/src/mocks/PendingBlkTimeAndNrAdvanceCheck.sol index 0676845a..58dd966a 100644 --- a/src/mocks/PendingBlkTimeAndNrAdvanceCheck.sol +++ b/src/mocks/PendingBlkTimeAndNrAdvanceCheck.sol @@ -21,7 +21,9 @@ contract PendingBlkTimeAndNrAdvanceCheck { require(ARB_SYS.arbBlockNumber() > deployedAtBlock, "Block didn't advance"); } - function checkArbBlockHashReturnsLatest(bytes32 expected) external { + function checkArbBlockHashReturnsLatest( + bytes32 expected + ) external { bytes32 gotBlockHash = ARB_SYS.arbBlockHash(ARB_SYS.arbBlockNumber() - 1); require(gotBlockHash != bytes32(0), "ZERO_BLOCK_HASH"); require(gotBlockHash == expected, "WRONG_BLOCK_HASH"); diff --git a/src/mocks/Program.sol b/src/mocks/Program.sol index 9a1eb9d2..ea674679 100644 --- a/src/mocks/Program.sol +++ b/src/mocks/Program.sol @@ -101,7 +101,9 @@ contract ProgramTest { return result; } - function mathTest(address program) external { + function mathTest( + address program + ) external { uint256 value = 0xeddecf107b5740cef7f5a01e3ea7e287665c4e75a8eb6afae2fda2e3d4367786; value = mulmod( value, diff --git a/src/mocks/SequencerInboxStub.sol b/src/mocks/SequencerInboxStub.sol index 40af7f29..43b143cb 100644 --- a/src/mocks/SequencerInboxStub.sol +++ b/src/mocks/SequencerInboxStub.sol @@ -27,7 +27,9 @@ contract SequencerInboxStub is SequencerInbox { isBatchPoster[sequencer_] = true; } - function addInitMessage(uint256 chainId) external { + function addInitMessage( + uint256 chainId + ) external { bytes memory initMsg = abi.encodePacked(chainId); uint256 num = IEthBridge(address(bridge)).enqueueDelayedMessage( INITIALIZATION_MSG_TYPE, address(0), keccak256(initMsg) diff --git a/src/mocks/Simple.sol b/src/mocks/Simple.sol index b753b955..b8b4c680 100644 --- a/src/mocks/Simple.sol +++ b/src/mocks/Simple.sol @@ -21,7 +21,9 @@ contract Simple { counter++; } - function logAndIncrement(uint256 expected) external { + function logAndIncrement( + uint256 expected + ) external { emit LogAndIncrementCalled(expected, counter); counter++; } diff --git a/src/mocks/SimpleCacheManager.sol b/src/mocks/SimpleCacheManager.sol index c49b5fdd..20d5e30f 100644 --- a/src/mocks/SimpleCacheManager.sol +++ b/src/mocks/SimpleCacheManager.sol @@ -7,15 +7,21 @@ pragma solidity ^0.8.0; import "../precompiles/ArbWasmCache.sol"; contract SimpleCacheManager { - function cacheProgram(address program) external { + function cacheProgram( + address program + ) external { ArbWasmCache(address(0x72)).cacheProgram(program); } - function evictProgram(address program) external { + function evictProgram( + address program + ) external { ArbWasmCache(address(0x72)).evictCodehash(codehash(program)); } - function codehash(address program) internal view returns (bytes32 hash) { + function codehash( + address program + ) internal view returns (bytes32 hash) { assembly { hash := extcodehash(program) } diff --git a/src/mocks/SimpleProxy.sol b/src/mocks/SimpleProxy.sol index e69f891c..4e46e96c 100644 --- a/src/mocks/SimpleProxy.sol +++ b/src/mocks/SimpleProxy.sol @@ -9,7 +9,9 @@ import "@openzeppelin/contracts/proxy/Proxy.sol"; contract SimpleProxy is Proxy { address private immutable impl; - constructor(address impl_) { + constructor( + address impl_ + ) { impl = impl_; } diff --git a/src/mocks/TestWETH9.sol b/src/mocks/TestWETH9.sol index 3c52e430..d4ff18cb 100644 --- a/src/mocks/TestWETH9.sol +++ b/src/mocks/TestWETH9.sol @@ -9,7 +9,9 @@ import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; interface IWETH9 { function deposit() external payable; - function withdraw(uint256 _amount) external; + function withdraw( + uint256 _amount + ) external; } contract TestWETH9 is ERC20, IWETH9 { @@ -19,7 +21,9 @@ contract TestWETH9 is ERC20, IWETH9 { _mint(msg.sender, msg.value); } - function withdraw(uint256 _amount) external override { + function withdraw( + uint256 _amount + ) external override { _burn(msg.sender, _amount); payable(address(msg.sender)).transfer(_amount); } diff --git a/src/node-interface/NodeInterface.sol b/src/node-interface/NodeInterface.sol index 64c7c4bb..c1c692e2 100644 --- a/src/node-interface/NodeInterface.sol +++ b/src/node-interface/NodeInterface.sol @@ -54,7 +54,9 @@ interface NodeInterface { * @param blockNum The L2 block being queried * @return batch The sequencer batch number containing the requested L2 block */ - function findBatchContainingBlock(uint64 blockNum) external view returns (uint64 batch); + function findBatchContainingBlock( + uint64 blockNum + ) external view returns (uint64 batch); /** * @notice Gets the number of L1 confirmations of the sequencer batch producing the requested L2 block @@ -65,7 +67,9 @@ interface NodeInterface { * @param blockHash The hash of the L2 block being queried * @return confirmations The number of L1 confirmations the sequencer batch has. Returns 0 if block not yet included in an L1 batch. */ - function getL1Confirmations(bytes32 blockHash) external view returns (uint64 confirmations); + function getL1Confirmations( + bytes32 blockHash + ) external view returns (uint64 confirmations); /** * @notice Same as native gas estimation, but with additional info on the l1 costs. @@ -154,7 +158,9 @@ interface NodeInterface { // @notice Returns the L1 block number of the L2 block // @return l1BlockNum The L1 block number - function blockL1Num(uint64 l2BlockNum) external view returns (uint64 l1BlockNum); + function blockL1Num( + uint64 l2BlockNum + ) external view returns (uint64 l1BlockNum); /** * @notice Finds the L2 block number range that has the given L1 block number diff --git a/src/node-interface/NodeInterfaceDebug.sol b/src/node-interface/NodeInterfaceDebug.sol index 11de8db2..13d6ae96 100644 --- a/src/node-interface/NodeInterfaceDebug.sol +++ b/src/node-interface/NodeInterfaceDebug.sol @@ -26,5 +26,7 @@ interface NodeInterfaceDebug { * @param ticket the retryable's id * @return retryable the serialized retryable */ - function getRetryable(bytes32 ticket) external view returns (RetryableInfo memory retryable); + function getRetryable( + bytes32 ticket + ) external view returns (RetryableInfo memory retryable); } diff --git a/src/osp/IOneStepProofEntry.sol b/src/osp/IOneStepProofEntry.sol index bd566446..2c4b62cc 100644 --- a/src/osp/IOneStepProofEntry.sol +++ b/src/osp/IOneStepProofEntry.sol @@ -29,5 +29,7 @@ interface IOneStepProofEntry { bytes calldata proof ) external view returns (bytes32 afterHash); - function getMachineHash(ExecutionState calldata execState) external pure returns (bytes32); + function getMachineHash( + ExecutionState calldata execState + ) external pure returns (bytes32); } diff --git a/src/osp/OneStepProver0.sol b/src/osp/OneStepProver0.sol index 7af513d4..d94381ba 100644 --- a/src/osp/OneStepProver0.sol +++ b/src/osp/OneStepProver0.sol @@ -94,7 +94,9 @@ contract OneStepProver0 is IOneStepProver { mach.setPc(frame.returnPc); } - function createReturnValue(Machine memory mach) internal pure returns (Value memory) { + function createReturnValue( + Machine memory mach + ) internal pure returns (Value memory) { return ValueLib.newPc(mach.functionPc, mach.functionIdx, mach.moduleIdx); } diff --git a/src/osp/OneStepProverHostIo.sol b/src/osp/OneStepProverHostIo.sol index 98d9a451..d98865cf 100644 --- a/src/osp/OneStepProverHostIo.sol +++ b/src/osp/OneStepProverHostIo.sol @@ -363,7 +363,9 @@ contract OneStepProverHostIo is IOneStepProver { mach.status = MachineStatus.FINISHED; } - function isPowerOfTwo(uint256 value) internal pure returns (bool) { + function isPowerOfTwo( + uint256 value + ) internal pure returns (bool) { return value != 0 && (value & (value - 1) == 0); } diff --git a/src/osp/OneStepProverMath.sol b/src/osp/OneStepProverMath.sol index 7d0bd385..67fed107 100644 --- a/src/osp/OneStepProverMath.sol +++ b/src/osp/OneStepProverMath.sol @@ -39,7 +39,9 @@ contract OneStepProverMath is IOneStepProver { mach.valueStack.push(ValueLib.newI32(output)); } - function signExtend(uint32 a) internal pure returns (uint64) { + function signExtend( + uint32 a + ) internal pure returns (uint64) { if (a & (1 << 31) != 0) { return uint64(a) | uint64(0xffffffff00000000); } diff --git a/src/precompiles/ArbAddressTable.sol b/src/precompiles/ArbAddressTable.sol index 82072a2b..3803cebc 100644 --- a/src/precompiles/ArbAddressTable.sol +++ b/src/precompiles/ArbAddressTable.sol @@ -14,14 +14,18 @@ interface ArbAddressTable { * @param addr address to check for presence in table * @return true if address is in table */ - function addressExists(address addr) external view returns (bool); + function addressExists( + address addr + ) external view returns (bool); /** * @notice compress an address and return the result * @param addr address to compress * @return compressed address bytes */ - function compress(address addr) external returns (bytes memory); + function compress( + address addr + ) external returns (bytes memory); /** * @notice read a compressed address from a bytes buffer @@ -38,20 +42,26 @@ interface ArbAddressTable { * @param addr address to lookup * @return index of an address in the address table (revert if address isn't in the table) */ - function lookup(address addr) external view returns (uint256); + function lookup( + address addr + ) external view returns (uint256); /** * @param index index to lookup address * @return address at a given index in address table (revert if index is beyond end of table) */ - function lookupIndex(uint256 index) external view returns (address); + function lookupIndex( + uint256 index + ) external view returns (address); /** * @notice Register an address in the address table * @param addr address to register * @return index of the address (existing index, or newly created index if not already registered) */ - function register(address addr) external returns (uint256); + function register( + address addr + ) external returns (uint256); /** * @return size of address table (= first unused index) diff --git a/src/precompiles/ArbAggregator.sol b/src/precompiles/ArbAggregator.sol index c37af3ba..03dd42da 100644 --- a/src/precompiles/ArbAggregator.sol +++ b/src/precompiles/ArbAggregator.sol @@ -11,7 +11,9 @@ interface ArbAggregator { /// @notice Get the address of an arbitrarily chosen batch poster. /// @param addr ignored /// @return (batchPosterAddress, true) - function getPreferredAggregator(address addr) external view returns (address, bool); + function getPreferredAggregator( + address addr + ) external view returns (address, bool); /// @notice Deprecated, there is no longer a single preferred aggregator, use getBatchPosters instead /// @notice Get default aggregator. @@ -24,12 +26,16 @@ interface ArbAggregator { /// @notice Adds newBatchPoster as a batch poster /// This reverts unless called by a chain owner /// @param newBatchPoster New batch poster - function addBatchPoster(address newBatchPoster) external; + function addBatchPoster( + address newBatchPoster + ) external; /// @notice Get the address where fees to batchPoster are sent. /// @param batchPoster The batch poster to get the fee collector for /// @return The fee collectors address. This will sometimes but not always be the same as the batch poster's address. - function getFeeCollector(address batchPoster) external view returns (address); + function getFeeCollector( + address batchPoster + ) external view returns (address); /// @notice Set the address where fees to batchPoster are sent. /// This reverts unless called by the batch poster, its fee collector, or a chain owner @@ -40,7 +46,9 @@ interface ArbAggregator { /// @notice Deprecated, always returns zero /// @notice Get the tx base fee (in approximate L1 gas) for aggregator /// @param aggregator The aggregator to get the base fee for - function getTxBaseFee(address aggregator) external view returns (uint256); + function getTxBaseFee( + address aggregator + ) external view returns (uint256); /// @notice Deprecated, is now a no-op /// @notice Set the tx base fee (in approximate L1 gas) for aggregator diff --git a/src/precompiles/ArbDebug.sol b/src/precompiles/ArbDebug.sol index 8cbcc9c1..66a92974 100644 --- a/src/precompiles/ArbDebug.sol +++ b/src/precompiles/ArbDebug.sol @@ -27,7 +27,9 @@ interface ArbDebug { bool indexed flag, address indexed field, uint24 number, bytes32 value, bytes store ); - function customRevert(uint64 number) external pure; + function customRevert( + uint64 number + ) external pure; function panic() external; diff --git a/src/precompiles/ArbFunctionTable.sol b/src/precompiles/ArbFunctionTable.sol index 0b61c5c0..be2b30e5 100644 --- a/src/precompiles/ArbFunctionTable.sol +++ b/src/precompiles/ArbFunctionTable.sol @@ -12,10 +12,14 @@ pragma solidity >=0.4.21 <0.9.0; /// Precompiled contract that exists in every Arbitrum chain at 0x0000000000000000000000000000000000000068. interface ArbFunctionTable { /// @notice Reverts since the table is empty - function upload(bytes calldata buf) external; + function upload( + bytes calldata buf + ) external; /// @notice Returns the empty table's size, which is 0 - function size(address addr) external view returns (uint256); + function size( + address addr + ) external view returns (uint256); /// @notice No-op function get(address addr, uint256 index) external view returns (uint256, bool, uint256); diff --git a/src/precompiles/ArbInfo.sol b/src/precompiles/ArbInfo.sol index ab7e7294..49e95725 100644 --- a/src/precompiles/ArbInfo.sol +++ b/src/precompiles/ArbInfo.sol @@ -8,8 +8,12 @@ pragma solidity >=0.4.21 <0.9.0; /// @notice Precompiled contract that exists in every Arbitrum chain at 0x0000000000000000000000000000000000000065. interface ArbInfo { /// @notice Retrieves an account's balance - function getBalance(address account) external view returns (uint256); + function getBalance( + address account + ) external view returns (uint256); /// @notice Retrieves a contract's deployed code - function getCode(address account) external view returns (bytes memory); + function getCode( + address account + ) external view returns (bytes memory); } diff --git a/src/precompiles/ArbOwner.sol b/src/precompiles/ArbOwner.sol index 0f5b4a97..938170f5 100644 --- a/src/precompiles/ArbOwner.sol +++ b/src/precompiles/ArbOwner.sol @@ -16,37 +16,57 @@ pragma solidity >=0.4.21 <0.9.0; */ interface ArbOwner { /// @notice Add account as a chain owner - function addChainOwner(address newOwner) external; + function addChainOwner( + address newOwner + ) external; /// @notice Remove account from the list of chain owners - function removeChainOwner(address ownerToRemove) external; + function removeChainOwner( + address ownerToRemove + ) external; /// @notice See if the user is a chain owner - function isChainOwner(address addr) external view returns (bool); + function isChainOwner( + address addr + ) external view returns (bool); /// @notice Retrieves the list of chain owners function getAllChainOwners() external view returns (address[] memory); /// @notice Set how slowly ArbOS updates its estimate of the L1 basefee - function setL1BaseFeeEstimateInertia(uint64 inertia) external; + function setL1BaseFeeEstimateInertia( + uint64 inertia + ) external; /// @notice Set the L2 basefee directly, bypassing the pool calculus - function setL2BaseFee(uint256 priceInWei) external; + function setL2BaseFee( + uint256 priceInWei + ) external; /// @notice Set the minimum basefee needed for a transaction to succeed - function setMinimumL2BaseFee(uint256 priceInWei) external; + function setMinimumL2BaseFee( + uint256 priceInWei + ) external; /// @notice Set the computational speed limit for the chain - function setSpeedLimit(uint64 limit) external; + function setSpeedLimit( + uint64 limit + ) external; /// @notice Set the maximum size a tx (and block) can be - function setMaxTxGasLimit(uint64 limit) external; + function setMaxTxGasLimit( + uint64 limit + ) external; /// @notice Set the L2 gas pricing inertia - function setL2GasPricingInertia(uint64 sec) external; + function setL2GasPricingInertia( + uint64 sec + ) external; /// @notice Set the L2 gas backlog tolerance - function setL2GasBacklogTolerance(uint64 sec) external; + function setL2GasBacklogTolerance( + uint64 sec + ) external; /// @notice Get the network fee collector function getNetworkFeeAccount() external view returns (address); @@ -55,59 +75,91 @@ interface ArbOwner { function getInfraFeeAccount() external view returns (address); /// @notice Set the network fee collector - function setNetworkFeeAccount(address newNetworkFeeAccount) external; + function setNetworkFeeAccount( + address newNetworkFeeAccount + ) external; /// @notice Set the infrastructure fee collector - function setInfraFeeAccount(address newInfraFeeAccount) external; + function setInfraFeeAccount( + address newInfraFeeAccount + ) external; /// @notice Upgrades ArbOS to the requested version at the requested timestamp function scheduleArbOSUpgrade(uint64 newVersion, uint64 timestamp) external; /// @notice Sets equilibration units parameter for L1 price adjustment algorithm - function setL1PricingEquilibrationUnits(uint256 equilibrationUnits) external; + function setL1PricingEquilibrationUnits( + uint256 equilibrationUnits + ) external; /// @notice Sets inertia parameter for L1 price adjustment algorithm - function setL1PricingInertia(uint64 inertia) external; + function setL1PricingInertia( + uint64 inertia + ) external; /// @notice Sets reward recipient address for L1 price adjustment algorithm - function setL1PricingRewardRecipient(address recipient) external; + function setL1PricingRewardRecipient( + address recipient + ) external; /// @notice Sets reward amount for L1 price adjustment algorithm, in wei per unit - function setL1PricingRewardRate(uint64 weiPerUnit) external; + function setL1PricingRewardRate( + uint64 weiPerUnit + ) external; /// @notice Set how much ArbOS charges per L1 gas spent on transaction data. - function setL1PricePerUnit(uint256 pricePerUnit) external; + function setL1PricePerUnit( + uint256 pricePerUnit + ) external; /// @notice Sets the base charge (in L1 gas) attributed to each data batch in the calldata pricer - function setPerBatchGasCharge(int64 cost) external; + function setPerBatchGasCharge( + int64 cost + ) external; /** * @notice Sets the Brotli compression level used for fast compression * Available in ArbOS version 12 with default level as 1 */ - function setBrotliCompressionLevel(uint64 level) external; + function setBrotliCompressionLevel( + uint64 level + ) external; /// @notice Sets the cost amortization cap in basis points - function setAmortizedCostCapBips(uint64 cap) external; + function setAmortizedCostCapBips( + uint64 cap + ) external; /// @notice Releases surplus funds from L1PricerFundsPoolAddress for use - function releaseL1PricerSurplusFunds(uint256 maxWeiToRelease) external returns (uint256); + function releaseL1PricerSurplusFunds( + uint256 maxWeiToRelease + ) external returns (uint256); /// @notice Sets the amount of ink 1 gas buys /// @param price the conversion rate (must fit in a uint24) - function setInkPrice(uint32 price) external; + function setInkPrice( + uint32 price + ) external; /// @notice Sets the maximum depth (in wasm words) a wasm stack may grow - function setWasmMaxStackDepth(uint32 depth) external; + function setWasmMaxStackDepth( + uint32 depth + ) external; /// @notice Sets the number of free wasm pages a tx gets - function setWasmFreePages(uint16 pages) external; + function setWasmFreePages( + uint16 pages + ) external; /// @notice Sets the base cost of each additional wasm page - function setWasmPageGas(uint16 gas) external; + function setWasmPageGas( + uint16 gas + ) external; /// @notice Sets the maximum number of pages a wasm may allocate - function setWasmPageLimit(uint16 limit) external; + function setWasmPageLimit( + uint16 limit + ) external; /// @notice Sets the minimum costs to invoke a program /// @param gas amount of gas paid in increments of 256 when not the program is not cached @@ -116,25 +168,39 @@ interface ArbOwner { /// @notice Sets the linear adjustment made to program init costs. /// @param percent the adjustment (100% = no adjustment). - function setWasmInitCostScalar(uint64 percent) external; + function setWasmInitCostScalar( + uint64 percent + ) external; /// @notice Sets the number of days after which programs deactivate - function setWasmExpiryDays(uint16 _days) external; + function setWasmExpiryDays( + uint16 _days + ) external; /// @notice Sets the age a program must be to perform a keepalive - function setWasmKeepaliveDays(uint16 _days) external; + function setWasmKeepaliveDays( + uint16 _days + ) external; /// @notice Sets the number of extra programs ArbOS caches during a given block - function setWasmBlockCacheSize(uint16 count) external; + function setWasmBlockCacheSize( + uint16 count + ) external; /// @notice Adds account as a wasm cache manager - function addWasmCacheManager(address manager) external; + function addWasmCacheManager( + address manager + ) external; /// @notice Removes account from the list of wasm cache managers - function removeWasmCacheManager(address manager) external; + function removeWasmCacheManager( + address manager + ) external; /// @notice Sets serialized chain config in ArbOS state - function setChainConfig(string calldata chainConfig) external; + function setChainConfig( + string calldata chainConfig + ) external; /// Emitted when a successful call is made to this precompile event OwnerActs(bytes4 indexed method, address indexed owner, bytes data); diff --git a/src/precompiles/ArbOwnerPublic.sol b/src/precompiles/ArbOwnerPublic.sol index 0de57ce6..5b28fff3 100644 --- a/src/precompiles/ArbOwnerPublic.sol +++ b/src/precompiles/ArbOwnerPublic.sol @@ -8,14 +8,18 @@ pragma solidity >=0.4.21 <0.9.0; /// @notice Precompiled contract that exists in every Arbitrum chain at 0x000000000000000000000000000000000000006b. interface ArbOwnerPublic { /// @notice See if the user is a chain owner - function isChainOwner(address addr) external view returns (bool); + function isChainOwner( + address addr + ) external view returns (bool); /** * @notice Rectify the list of chain owners * If successful, emits ChainOwnerRectified event * Available in ArbOS version 11 */ - function rectifyChainOwner(address ownerToRectify) external; + function rectifyChainOwner( + address ownerToRectify + ) external; /// @notice Retrieves the list of chain owners function getAllChainOwners() external view returns (address[] memory); diff --git a/src/precompiles/ArbRetryableTx.sol b/src/precompiles/ArbRetryableTx.sol index 0600f651..454a55bf 100644 --- a/src/precompiles/ArbRetryableTx.sol +++ b/src/precompiles/ArbRetryableTx.sol @@ -15,7 +15,9 @@ interface ArbRetryableTx { * @param ticketId unique identifier of retryable message: keccak256(keccak256(ArbchainId, inbox-sequence-number), uint(0) ) * @return txId that the redeem attempt will have */ - function redeem(bytes32 ticketId) external returns (bytes32); + function redeem( + bytes32 ticketId + ) external returns (bytes32); /** * @notice Return the minimum lifetime of redeemable txn. @@ -28,7 +30,9 @@ interface ArbRetryableTx { * @param ticketId unique ticket identifier * @return timestamp for ticket's deadline */ - function getTimeout(bytes32 ticketId) external view returns (uint256); + function getTimeout( + bytes32 ticketId + ) external view returns (uint256); /** * @notice Adds one lifetime period to the life of ticketId. @@ -38,7 +42,9 @@ interface ArbRetryableTx { * @param ticketId unique ticket identifier * @return new timeout of ticketId */ - function keepalive(bytes32 ticketId) external returns (uint256); + function keepalive( + bytes32 ticketId + ) external returns (uint256); /** * @notice Return the beneficiary of ticketId. @@ -46,14 +52,18 @@ interface ArbRetryableTx { * @param ticketId unique ticket identifier * @return address of beneficiary for ticket */ - function getBeneficiary(bytes32 ticketId) external view returns (address); + function getBeneficiary( + bytes32 ticketId + ) external view returns (address); /** * @notice Cancel ticketId and refund its callvalue to its beneficiary. * Revert if ticketId doesn't exist, or if called by anyone other than ticketId's beneficiary. * @param ticketId unique ticket identifier */ - function cancel(bytes32 ticketId) external; + function cancel( + bytes32 ticketId + ) external; /** * @notice Gets the redeemer of the current retryable redeem attempt. diff --git a/src/precompiles/ArbSys.sol b/src/precompiles/ArbSys.sol index 520a9cf6..5d28aa10 100644 --- a/src/precompiles/ArbSys.sol +++ b/src/precompiles/ArbSys.sol @@ -20,7 +20,9 @@ interface ArbSys { * @notice Get Arbitrum block hash (reverts unless currentBlockNum-256 <= arbBlockNum < currentBlockNum) * @return block hash */ - function arbBlockHash(uint256 arbBlockNum) external view returns (bytes32); + function arbBlockHash( + uint256 arbBlockNum + ) external view returns (bytes32); /** * @notice Gets the rollup's unique chain identifier @@ -76,7 +78,9 @@ interface ArbSys { * @param destination recipient address on L1 * @return unique identifier for this L2-to-L1 transaction. */ - function withdrawEth(address destination) external payable returns (uint256); + function withdrawEth( + address destination + ) external payable returns (uint256); /** * @notice Send a transaction to L1 diff --git a/src/precompiles/ArbWasm.sol b/src/precompiles/ArbWasm.sol index ba4621fc..e5e6e1b5 100644 --- a/src/precompiles/ArbWasm.sol +++ b/src/precompiles/ArbWasm.sol @@ -23,20 +23,28 @@ interface ArbWasm { /// @notice Gets the stylus version the program with codehash was most recently activated against /// @return version the program version (reverts for EVM contracts) - function codehashVersion(bytes32 codehash) external view returns (uint16 version); + function codehashVersion( + bytes32 codehash + ) external view returns (uint16 version); /// @notice Extends a program's expiration date. /// Reverts if too soon or if the program is not up to date. - function codehashKeepalive(bytes32 codehash) external payable; + function codehashKeepalive( + bytes32 codehash + ) external payable; /// @notice Gets a program's asm size. /// Reverts if program is not active. /// @return size the size in bytes - function codehashAsmSize(bytes32 codehash) external view returns (uint32 size); + function codehashAsmSize( + bytes32 codehash + ) external view returns (uint32 size); /// @notice Gets the stylus version the program was most recently activated against /// @return version the program version (reverts for EVM contracts) - function programVersion(address program) external view returns (uint16 version); + function programVersion( + address program + ) external view returns (uint16 version); /// @notice Gets the cost to invoke the program /// @return gas the amount of gas @@ -47,11 +55,15 @@ interface ArbWasm { /// @notice Gets the memory footprint of the program at the given address in pages /// @return footprint the memory footprint of program in pages (reverts for EVM contracts) - function programMemoryFootprint(address program) external view returns (uint16 footprint); + function programMemoryFootprint( + address program + ) external view returns (uint16 footprint); /// @notice Gets the amount of time remaining until the program expires /// @return _secs the time left in seconds (reverts for EVM contracts) - function programTimeLeft(address program) external view returns (uint64 _secs); + function programTimeLeft( + address program + ) external view returns (uint64 _secs); /// @notice Gets the conversion rate between gas and ink /// @return price the amount of ink 1 gas buys diff --git a/src/precompiles/ArbWasmCache.sol b/src/precompiles/ArbWasmCache.sol index bc5b199f..fc22ac24 100644 --- a/src/precompiles/ArbWasmCache.sol +++ b/src/precompiles/ArbWasmCache.sol @@ -10,27 +10,37 @@ pragma solidity >=0.4.21 <0.9.0; */ interface ArbWasmCache { /// @notice See if the user is a cache manager. - function isCacheManager(address manager) external view returns (bool); + function isCacheManager( + address manager + ) external view returns (bool); /// @notice Retrieve all address managers. /// @return managers the list of managers. function allCacheManagers() external view returns (address[] memory managers); /// @dev Deprecated, replaced with cacheProgram - function cacheCodehash(bytes32 codehash) external; + function cacheCodehash( + bytes32 codehash + ) external; /// @notice Caches all programs with a codehash equal to the given address. /// @notice Reverts if the programs have expired. /// @notice Caller must be a cache manager or chain owner. /// @notice If you're looking for how to bid for position, interact with the chain's cache manager contract. - function cacheProgram(address addr) external; + function cacheProgram( + address addr + ) external; /// @notice Evicts all programs with the given codehash. /// @notice Caller must be a cache manager or chain owner. - function evictCodehash(bytes32 codehash) external; + function evictCodehash( + bytes32 codehash + ) external; /// @notice Gets whether a program is cached. Note that the program may be expired. - function codehashIsCached(bytes32 codehash) external view returns (bool); + function codehashIsCached( + bytes32 codehash + ) external view returns (bool); event UpdateProgramCache(address indexed manager, bytes32 indexed codehash, bool cached); } diff --git a/src/precompiles/ArbosTest.sol b/src/precompiles/ArbosTest.sol index b766fd01..e1c1ce90 100644 --- a/src/precompiles/ArbosTest.sol +++ b/src/precompiles/ArbosTest.sol @@ -10,5 +10,7 @@ pragma solidity >=0.4.21 <0.9.0; /// Precompiled contract that exists in every Arbitrum chain at 0x0000000000000000000000000000000000000069. interface ArbosTest { /// @notice Unproductively burns the amount of L2 ArbGas - function burnArbGas(uint256 gasAmount) external pure; + function burnArbGas( + uint256 gasAmount + ) external pure; } diff --git a/src/rollup/AbsRollupEventInbox.sol b/src/rollup/AbsRollupEventInbox.sol index fd75c782..b98254ef 100644 --- a/src/rollup/AbsRollupEventInbox.sol +++ b/src/rollup/AbsRollupEventInbox.sol @@ -29,7 +29,9 @@ abstract contract AbsRollupEventInbox is _; } - function initialize(IBridge _bridge) external override onlyDelegated { + function initialize( + IBridge _bridge + ) external override onlyDelegated { if (address(bridge) != address(0)) revert AlreadyInit(); if (address(_bridge) == address(0)) revert HadZeroInit(); bridge = _bridge; @@ -59,7 +61,9 @@ abstract contract AbsRollupEventInbox is emit InboxMessageDelivered(num, initMsg); } - function _enqueueInitializationMsg(bytes memory initMsg) internal virtual returns (uint256); + function _enqueueInitializationMsg( + bytes memory initMsg + ) internal virtual returns (uint256); function _currentDataCostToReport() internal virtual returns (uint256); } diff --git a/src/rollup/Assertion.sol b/src/rollup/Assertion.sol index fd92cf77..89705653 100644 --- a/src/rollup/Assertion.sol +++ b/src/rollup/Assertion.sol @@ -82,7 +82,9 @@ library AssertionNodeLib { /** * @notice Update child properties */ - function childCreated(AssertionNode storage self) internal { + function childCreated( + AssertionNode storage self + ) internal { if (self.firstChildBlock == 0) { self.firstChildBlock = uint64(block.number); } else if (self.secondChildBlock == 0) { @@ -90,7 +92,9 @@ library AssertionNodeLib { } } - function requireExists(AssertionNode memory self) internal pure { + function requireExists( + AssertionNode memory self + ) internal pure { require(self.status != AssertionStatus.NoAssertion, "ASSERTION_NOT_EXIST"); } } diff --git a/src/rollup/AssertionState.sol b/src/rollup/AssertionState.sol index 1319e984..0177ecc2 100644 --- a/src/rollup/AssertionState.sol +++ b/src/rollup/AssertionState.sol @@ -21,7 +21,9 @@ library AssertionStateLib { return ExecutionState(state.globalState, state.machineStatus); } - function hash(AssertionState memory state) internal pure returns (bytes32) { + function hash( + AssertionState memory state + ) internal pure returns (bytes32) { return keccak256(abi.encode(state)); } } diff --git a/src/rollup/BOLDUpgradeAction.sol b/src/rollup/BOLDUpgradeAction.sol index e57b0508..2af1e91f 100644 --- a/src/rollup/BOLDUpgradeAction.sol +++ b/src/rollup/BOLDUpgradeAction.sol @@ -66,23 +66,35 @@ interface IOldRollup { function wasmModuleRoot() external view returns (bytes32); function latestConfirmed() external view returns (uint64); - function getNode(uint64 nodeNum) external view returns (Node memory); - function getStakerAddress(uint64 stakerNum) external view returns (address); + function getNode( + uint64 nodeNum + ) external view returns (Node memory); + function getStakerAddress( + uint64 stakerNum + ) external view returns (address); function stakerCount() external view returns (uint64); - function getStaker(address staker) external view returns (OldStaker memory); - function isValidator(address validator) external view returns (bool); + function getStaker( + address staker + ) external view returns (OldStaker memory); + function isValidator( + address validator + ) external view returns (bool); function validatorWalletCreator() external view returns (address); function anyTrustFastConfirmer() external view returns (address); } interface IOldRollupAdmin { - function forceRefundStaker(address[] memory stacker) external; + function forceRefundStaker( + address[] memory stacker + ) external; function pause() external; function resume() external; } interface ISeqInboxPostUpgradeInit { - function postUpgradeInit(BufferConfig memory bufferConfig_) external; + function postUpgradeInit( + BufferConfig memory bufferConfig_ + ) external; } /// @title Provides pre-images to a state hash @@ -132,7 +144,9 @@ contract StateHashPreImageLookup { contract RollupReader is IOldRollup { IOldRollup public immutable rollup; - constructor(IOldRollup _rollup) { + constructor( + IOldRollup _rollup + ) { rollup = _rollup; } @@ -144,11 +158,15 @@ contract RollupReader is IOldRollup { return rollup.latestConfirmed(); } - function getNode(uint64 nodeNum) external view returns (Node memory) { + function getNode( + uint64 nodeNum + ) external view returns (Node memory) { return rollup.getNode(nodeNum); } - function getStakerAddress(uint64 stakerNum) external view returns (address) { + function getStakerAddress( + uint64 stakerNum + ) external view returns (address) { return rollup.getStakerAddress(stakerNum); } @@ -156,11 +174,15 @@ contract RollupReader is IOldRollup { return rollup.stakerCount(); } - function getStaker(address staker) external view returns (OldStaker memory) { + function getStaker( + address staker + ) external view returns (OldStaker memory) { return rollup.getStaker(staker); } - function isValidator(address validator) external view returns (bool) { + function isValidator( + address validator + ) external view returns (bool) { return rollup.isValidator(validator); } @@ -179,7 +201,9 @@ contract RollupReader is IOldRollup { contract ConstantArrayStorage { uint256[] internal _array; - constructor(uint256[] memory __array) { + constructor( + uint256[] memory __array + ) { _array = __array; } @@ -426,7 +450,9 @@ contract BOLDUpgradeAction { }); } - function upgradeSurroundingContracts(address newRollupAddress) private { + function upgradeSurroundingContracts( + address newRollupAddress + ) private { // upgrade each of these contracts to an implementation that allows // the rollup address to be set to the new rollup address @@ -513,7 +539,9 @@ contract BOLDUpgradeAction { ISequencerInbox(SEQ_INBOX).updateRollupAddress(); } - function perform(address[] memory validators) external { + function perform( + address[] memory validators + ) external { // tidy up the old rollup - pause it and refund stakes cleanupOldRollup(); diff --git a/src/rollup/BridgeCreator.sol b/src/rollup/BridgeCreator.sol index 10fe0b9b..bb375e43 100644 --- a/src/rollup/BridgeCreator.sol +++ b/src/rollup/BridgeCreator.sol @@ -50,12 +50,16 @@ contract BridgeCreator is Ownable { erc20BasedTemplates = _erc20BasedTemplates; } - function updateTemplates(BridgeTemplates calldata _newTemplates) external onlyOwner { + function updateTemplates( + BridgeTemplates calldata _newTemplates + ) external onlyOwner { ethBasedTemplates = _newTemplates; emit TemplatesUpdated(); } - function updateERC20Templates(BridgeTemplates calldata _newTemplates) external onlyOwner { + function updateERC20Templates( + BridgeTemplates calldata _newTemplates + ) external onlyOwner { erc20BasedTemplates = _newTemplates; emit ERC20TemplatesUpdated(); } diff --git a/src/rollup/ERC20RollupEventInbox.sol b/src/rollup/ERC20RollupEventInbox.sol index 7ba853c2..dba8bd75 100644 --- a/src/rollup/ERC20RollupEventInbox.sol +++ b/src/rollup/ERC20RollupEventInbox.sol @@ -14,7 +14,9 @@ import {INITIALIZATION_MSG_TYPE} from "../libraries/MessageTypes.sol"; contract ERC20RollupEventInbox is AbsRollupEventInbox { constructor() AbsRollupEventInbox() {} - function _enqueueInitializationMsg(bytes memory initMsg) internal override returns (uint256) { + function _enqueueInitializationMsg( + bytes memory initMsg + ) internal override returns (uint256) { uint256 tokenAmount = 0; return IERC20Bridge(address(bridge)).enqueueDelayedMessage( INITIALIZATION_MSG_TYPE, address(0), keccak256(initMsg), tokenAmount diff --git a/src/rollup/FactoryDeployerHelper.sol b/src/rollup/FactoryDeployerHelper.sol index 32dfd45e..727095b3 100644 --- a/src/rollup/FactoryDeployerHelper.sol +++ b/src/rollup/FactoryDeployerHelper.sol @@ -10,7 +10,9 @@ contract FactoryDeployerHelper { address public constant DEPLOY_HELPER = address(0x90D68B056c411015eaE3EC0b98AD94E2C91419F1); uint256 public constant MAX_FEE_PER_GAS = 100_000_000; - function deploy(address inbox) external { + function deploy( + address inbox + ) external { deploy(inbox, MAX_FEE_PER_GAS); } diff --git a/src/rollup/IRollupAdmin.sol b/src/rollup/IRollupAdmin.sol index 2a2cced4..6d3be8d9 100644 --- a/src/rollup/IRollupAdmin.sol +++ b/src/rollup/IRollupAdmin.sol @@ -74,13 +74,17 @@ interface IRollupAdmin { * @notice Add a contract authorized to put messages into this rollup's inbox * @param _outbox Outbox contract to add */ - function setOutbox(IOutbox _outbox) external; + function setOutbox( + IOutbox _outbox + ) external; /** * @notice Disable an old outbox from interacting with the bridge * @param _outbox Outbox contract to remove */ - function removeOldOutbox(address _outbox) external; + function removeOldOutbox( + address _outbox + ) external; /** * @notice Enable or disable an inbox contract @@ -112,13 +116,17 @@ interface IRollupAdmin { * @notice Set a new owner address for the rollup proxy * @param newOwner address of new rollup owner */ - function setOwner(address newOwner) external; + function setOwner( + address newOwner + ) external; /** * @notice Set minimum assertion period for the rollup * @param newPeriod new minimum period for assertions */ - function setMinimumAssertionPeriod(uint256 newPeriod) external; + function setMinimumAssertionPeriod( + uint256 newPeriod + ) external; /** * @notice Set validator afk blocks for the rollup @@ -129,21 +137,29 @@ interface IRollupAdmin { * to confirm an assertion via the normal method. Therefore we need it to be greater * than max(2* confirmPeriod, 2 * challengePeriod) with some additional margin. */ - function setValidatorAfkBlocks(uint64 newAfkBlocks) external; + function setValidatorAfkBlocks( + uint64 newAfkBlocks + ) external; /** * @notice Set number of blocks until a assertion is considered confirmed * @param newConfirmPeriod new number of blocks until a assertion is confirmed */ - function setConfirmPeriodBlocks(uint64 newConfirmPeriod) external; + function setConfirmPeriodBlocks( + uint64 newConfirmPeriod + ) external; /** * @notice Set base stake required for an assertion * @param newBaseStake maximum avmgas to be used per block */ - function setBaseStake(uint256 newBaseStake) external; + function setBaseStake( + uint256 newBaseStake + ) external; - function forceRefundStaker(address[] memory stacker) external; + function forceRefundStaker( + address[] memory stacker + ) external; function forceCreateAssertion( bytes32 prevAssertionHash, @@ -158,35 +174,47 @@ interface IRollupAdmin { bytes32 inboxAcc ) external; - function setLoserStakeEscrow(address newLoserStakerEscrow) external; + function setLoserStakeEscrow( + address newLoserStakerEscrow + ) external; /** * @notice Set the proving WASM module root * @param newWasmModuleRoot new module root */ - function setWasmModuleRoot(bytes32 newWasmModuleRoot) external; + function setWasmModuleRoot( + bytes32 newWasmModuleRoot + ) external; /** * @notice set a new sequencer inbox contract * @param _sequencerInbox new address of sequencer inbox */ - function setSequencerInbox(address _sequencerInbox) external; + function setSequencerInbox( + address _sequencerInbox + ) external; /** * @notice set the validatorWhitelistDisabled flag * @param _validatorWhitelistDisabled new value of validatorWhitelistDisabled, i.e. true = disabled */ - function setValidatorWhitelistDisabled(bool _validatorWhitelistDisabled) external; + function setValidatorWhitelistDisabled( + bool _validatorWhitelistDisabled + ) external; /** * @notice set the anyTrustFastConfirmer address * @param _anyTrustFastConfirmer new value of anyTrustFastConfirmer */ - function setAnyTrustFastConfirmer(address _anyTrustFastConfirmer) external; + function setAnyTrustFastConfirmer( + address _anyTrustFastConfirmer + ) external; /** * @notice set a new challengeManager contract * @param _challengeManager new value of challengeManager */ - function setChallengeManager(address _challengeManager) external; + function setChallengeManager( + address _challengeManager + ) external; } diff --git a/src/rollup/IRollupCore.sol b/src/rollup/IRollupCore.sol index ba1e1f76..c0c1405f 100644 --- a/src/rollup/IRollupCore.sol +++ b/src/rollup/IRollupCore.sol @@ -86,7 +86,9 @@ interface IRollupCore is IAssertionChain { /** * @notice Get the Assertion for the given id. */ - function getAssertion(bytes32 assertionHash) external view returns (AssertionNode memory); + function getAssertion( + bytes32 assertionHash + ) external view returns (AssertionNode memory); /** * @notice Returns the block in which the given assertion was created for looking up its creation event. @@ -104,49 +106,63 @@ interface IRollupCore is IAssertionChain { * @param stakerNum Index of the staker * @return Address of the staker */ - function getStakerAddress(uint64 stakerNum) external view returns (address); + function getStakerAddress( + uint64 stakerNum + ) external view returns (address); /** * @notice Check whether the given staker is staked * @param staker Staker address to check * @return True or False for whether the staker was staked */ - function isStaked(address staker) external view returns (bool); + function isStaked( + address staker + ) external view returns (bool); /** * @notice Get the latest staked assertion of the given staker * @param staker Staker address to lookup * @return Latest assertion staked of the staker */ - function latestStakedAssertion(address staker) external view returns (bytes32); + function latestStakedAssertion( + address staker + ) external view returns (bytes32); /** * @notice Get the amount staked of the given staker * @param staker Staker address to lookup * @return Amount staked of the staker */ - function amountStaked(address staker) external view returns (uint256); + function amountStaked( + address staker + ) external view returns (uint256); /** * @notice Get the withdrawal address of the given staker * @param staker Staker address to lookup * @return Withdrawal address of the staker */ - function withdrawalAddress(address staker) external view returns (address); + function withdrawalAddress( + address staker + ) external view returns (address); /** * @notice Retrieves stored information about a requested staker * @param staker Staker address to retrieve * @return A structure with information about the requested staker */ - function getStaker(address staker) external view returns (Staker memory); + function getStaker( + address staker + ) external view returns (Staker memory); /** * @notice Get the amount of funds withdrawable by the given address * @param owner Address to check the funds of * @return Amount of funds withdrawable by owner */ - function withdrawableFunds(address owner) external view returns (uint256); + function withdrawableFunds( + address owner + ) external view returns (uint256); /// @return Hash of the latest confirmed assertion function latestConfirmed() external view returns (bytes32); diff --git a/src/rollup/IRollupEventInbox.sol b/src/rollup/IRollupEventInbox.sol index 2e79f7e6..8110f436 100644 --- a/src/rollup/IRollupEventInbox.sol +++ b/src/rollup/IRollupEventInbox.sol @@ -9,7 +9,9 @@ import "../bridge/IBridge.sol"; interface IRollupEventInbox { function bridge() external view returns (IBridge); - function initialize(IBridge _bridge) external; + function initialize( + IBridge _bridge + ) external; function rollup() external view returns (address); diff --git a/src/rollup/IRollupLogic.sol b/src/rollup/IRollupLogic.sol index 0bf7ed20..b3f825fd 100644 --- a/src/rollup/IRollupLogic.sol +++ b/src/rollup/IRollupLogic.sol @@ -12,7 +12,9 @@ import "../bridge/IOwnable.sol"; interface IRollupUser is IRollupCore, IOwnable { /// @dev the user logic just validated configuration and shouldn't write to state during init /// this allows the admin logic to ensure consistency on parameters. - function initialize(address stakeToken) external view; + function initialize( + address stakeToken + ) external view; function removeWhitelistAfterFork() external; @@ -34,9 +36,13 @@ interface IRollupUser is IRollupCore, IOwnable { function returnOldDeposit() external; - function returnOldDepositFor(address stakerAddress) external; + function returnOldDepositFor( + address stakerAddress + ) external; - function reduceDeposit(uint256 target) external; + function reduceDeposit( + uint256 target + ) external; function withdrawStakerFunds() external returns (uint256); diff --git a/src/rollup/RollupAdminLogic.sol b/src/rollup/RollupAdminLogic.sol index 93ac12b6..ecdbe927 100644 --- a/src/rollup/RollupAdminLogic.sol +++ b/src/rollup/RollupAdminLogic.sol @@ -123,7 +123,9 @@ contract RollupAdminLogic is RollupCore, IRollupAdmin, DoubleLogicUUPSUpgradeabl * @notice Add a contract authorized to put messages into this rollup's inbox * @param _outbox Outbox contract to add */ - function setOutbox(IOutbox _outbox) external override { + function setOutbox( + IOutbox _outbox + ) external override { outbox = _outbox; bridge.setOutbox(address(_outbox), true); emit OutboxSet(address(_outbox)); @@ -134,7 +136,9 @@ contract RollupAdminLogic is RollupCore, IRollupAdmin, DoubleLogicUUPSUpgradeabl * @notice Disable an old outbox from interacting with the bridge * @param _outbox Outbox contract to remove */ - function removeOldOutbox(address _outbox) external override { + function removeOldOutbox( + address _outbox + ) external override { require(_outbox != address(outbox), "CUR_OUTBOX"); bridge.setOutbox(_outbox, false); emit OldOutboxRemoved(address(_outbox)); @@ -175,12 +179,16 @@ contract RollupAdminLogic is RollupCore, IRollupAdmin, DoubleLogicUUPSUpgradeabl /// @notice allows the admin to upgrade the primary logic contract (ie rollup admin logic, aka this) /// @dev this function doesn't revert as this primary logic contract is only /// reachable by the proxy's admin - function _authorizeUpgrade(address newImplementation) internal override {} + function _authorizeUpgrade( + address newImplementation + ) internal override {} /// @notice allows the admin to upgrade the secondary logic contract (ie rollup user logic) /// @dev this function doesn't revert as this primary logic contract is only /// reachable by the proxy's admin - function _authorizeSecondaryUpgrade(address newImplementation) internal override {} + function _authorizeSecondaryUpgrade( + address newImplementation + ) internal override {} /** * @notice Set the addresses of the validator whitelist @@ -207,7 +215,9 @@ contract RollupAdminLogic is RollupCore, IRollupAdmin, DoubleLogicUUPSUpgradeabl * @dev it is expected that only the rollup admin can use this facet to set a new owner * @param newOwner address of new rollup owner */ - function setOwner(address newOwner) external override { + function setOwner( + address newOwner + ) external override { _changeAdmin(newOwner); // previously: emit OwnerFunctionCalled(7); } @@ -216,7 +226,9 @@ contract RollupAdminLogic is RollupCore, IRollupAdmin, DoubleLogicUUPSUpgradeabl * @notice Set minimum assertion period for the rollup * @param newPeriod new minimum period for assertions */ - function setMinimumAssertionPeriod(uint256 newPeriod) external override { + function setMinimumAssertionPeriod( + uint256 newPeriod + ) external override { minimumAssertionPeriod = newPeriod; emit MinimumAssertionPeriodSet(newPeriod); // previously: emit OwnerFunctionCalled(8); @@ -231,7 +243,9 @@ contract RollupAdminLogic is RollupCore, IRollupAdmin, DoubleLogicUUPSUpgradeabl * to confirm an assertion via the normal method. Therefore we need it to be greater * than max(2* confirmPeriod, 2 * challengePeriod) with some additional margin. */ - function setValidatorAfkBlocks(uint64 newAfkBlocks) external override { + function setValidatorAfkBlocks( + uint64 newAfkBlocks + ) external override { validatorAfkBlocks = newAfkBlocks; emit ValidatorAfkBlocksSet(newAfkBlocks); } @@ -240,7 +254,9 @@ contract RollupAdminLogic is RollupCore, IRollupAdmin, DoubleLogicUUPSUpgradeabl * @notice Set number of blocks until a assertion is considered confirmed * @param newConfirmPeriod new number of blocks */ - function setConfirmPeriodBlocks(uint64 newConfirmPeriod) external override { + function setConfirmPeriodBlocks( + uint64 newConfirmPeriod + ) external override { require(newConfirmPeriod > 0, "INVALID_CONFIRM_PERIOD"); confirmPeriodBlocks = newConfirmPeriod; emit ConfirmPeriodBlocksSet(newConfirmPeriod); @@ -251,7 +267,9 @@ contract RollupAdminLogic is RollupCore, IRollupAdmin, DoubleLogicUUPSUpgradeabl * @notice Set base stake required for an assertion * @param newBaseStake minimum amount of stake required */ - function setBaseStake(uint256 newBaseStake) external override { + function setBaseStake( + uint256 newBaseStake + ) external override { // we do not currently allow base stake to be reduced since as doing so might allow a malicious party // to withdraw some (up to the difference between baseStake and newBaseStake) honest funds from this contract // The sequence of events is as follows: @@ -265,7 +283,9 @@ contract RollupAdminLogic is RollupCore, IRollupAdmin, DoubleLogicUUPSUpgradeabl // previously: emit OwnerFunctionCalled(12); } - function forceRefundStaker(address[] calldata staker) external override whenPaused { + function forceRefundStaker( + address[] calldata staker + ) external override whenPaused { require(staker.length > 0, "EMPTY_ARRAY"); for (uint256 i = 0; i < staker.length; i++) { requireInactiveStaker(staker[i]); @@ -309,7 +329,9 @@ contract RollupAdminLogic is RollupCore, IRollupAdmin, DoubleLogicUUPSUpgradeabl // previously: emit OwnerFunctionCalled(24); } - function setLoserStakeEscrow(address newLoserStakerEscrow) external override { + function setLoserStakeEscrow( + address newLoserStakerEscrow + ) external override { // loser stake is now sent directly to loserStakeEscrow, it must not // be address(0) because some token do not allow transfers to address(0) require(newLoserStakerEscrow != address(0), "INVALID_ESCROW_0"); @@ -322,7 +344,9 @@ contract RollupAdminLogic is RollupCore, IRollupAdmin, DoubleLogicUUPSUpgradeabl * @notice Set the proving WASM module root * @param newWasmModuleRoot new module root */ - function setWasmModuleRoot(bytes32 newWasmModuleRoot) external override { + function setWasmModuleRoot( + bytes32 newWasmModuleRoot + ) external override { wasmModuleRoot = newWasmModuleRoot; emit WasmModuleRootSet(newWasmModuleRoot); // previously: emit OwnerFunctionCalled(26); @@ -332,7 +356,9 @@ contract RollupAdminLogic is RollupCore, IRollupAdmin, DoubleLogicUUPSUpgradeabl * @notice set a new sequencer inbox contract * @param _sequencerInbox new address of sequencer inbox */ - function setSequencerInbox(address _sequencerInbox) external override { + function setSequencerInbox( + address _sequencerInbox + ) external override { bridge.setSequencerInbox(_sequencerInbox); emit SequencerInboxSet(_sequencerInbox); // previously: emit OwnerFunctionCalled(27); @@ -342,7 +368,9 @@ contract RollupAdminLogic is RollupCore, IRollupAdmin, DoubleLogicUUPSUpgradeabl * @notice sets the rollup's inbox reference. Does not update the bridge's view. * @param newInbox new address of inbox */ - function setInbox(IInboxBase newInbox) external { + function setInbox( + IInboxBase newInbox + ) external { inbox = newInbox; emit InboxSet(address(newInbox)); // previously: emit OwnerFunctionCalled(28); @@ -352,7 +380,9 @@ contract RollupAdminLogic is RollupCore, IRollupAdmin, DoubleLogicUUPSUpgradeabl * @notice set the validatorWhitelistDisabled flag * @param _validatorWhitelistDisabled new value of validatorWhitelistDisabled, i.e. true = disabled */ - function setValidatorWhitelistDisabled(bool _validatorWhitelistDisabled) external { + function setValidatorWhitelistDisabled( + bool _validatorWhitelistDisabled + ) external { validatorWhitelistDisabled = _validatorWhitelistDisabled; emit ValidatorWhitelistDisabledSet(_validatorWhitelistDisabled); // previously: emit OwnerFunctionCalled(30); @@ -362,7 +392,9 @@ contract RollupAdminLogic is RollupCore, IRollupAdmin, DoubleLogicUUPSUpgradeabl * @notice set the anyTrustFastConfirmer address * @param _anyTrustFastConfirmer new value of anyTrustFastConfirmer */ - function setAnyTrustFastConfirmer(address _anyTrustFastConfirmer) external { + function setAnyTrustFastConfirmer( + address _anyTrustFastConfirmer + ) external { anyTrustFastConfirmer = _anyTrustFastConfirmer; emit AnyTrustFastConfirmerSet(_anyTrustFastConfirmer); // previously: emit OwnerFunctionCalled(31); @@ -372,7 +404,9 @@ contract RollupAdminLogic is RollupCore, IRollupAdmin, DoubleLogicUUPSUpgradeabl * @notice set a new challengeManager contract * @param _challengeManager new value of challengeManager */ - function setChallengeManager(address _challengeManager) external { + function setChallengeManager( + address _challengeManager + ) external { challengeManager = IEdgeChallengeManager(_challengeManager); emit ChallengeManagerSet(_challengeManager); // previously: emit OwnerFunctionCalled(32); diff --git a/src/rollup/RollupCore.sol b/src/rollup/RollupCore.sol index fbd4221b..4ee6715c 100644 --- a/src/rollup/RollupCore.sol +++ b/src/rollup/RollupCore.sol @@ -169,7 +169,9 @@ abstract contract RollupCore is IRollupCore, PausableUpgradeable { * @param stakerNum Index of the staker * @return Address of the staker */ - function getStakerAddress(uint64 stakerNum) external view override returns (address) { + function getStakerAddress( + uint64 stakerNum + ) external view override returns (address) { return _stakerList[stakerNum]; } @@ -178,7 +180,9 @@ abstract contract RollupCore is IRollupCore, PausableUpgradeable { * @param staker Staker address to check * @return True or False for whether the staker was staked */ - function isStaked(address staker) public view override returns (bool) { + function isStaked( + address staker + ) public view override returns (bool) { return _stakerMap[staker].isStaked; } @@ -187,7 +191,9 @@ abstract contract RollupCore is IRollupCore, PausableUpgradeable { * @param staker Staker address to lookup * @return Latest assertion staked of the staker */ - function latestStakedAssertion(address staker) public view override returns (bytes32) { + function latestStakedAssertion( + address staker + ) public view override returns (bytes32) { return _stakerMap[staker].latestStakedAssertion; } @@ -196,7 +202,9 @@ abstract contract RollupCore is IRollupCore, PausableUpgradeable { * @param staker Staker address to lookup * @return Amount staked of the staker */ - function amountStaked(address staker) public view override returns (uint256) { + function amountStaked( + address staker + ) public view override returns (uint256) { return _stakerMap[staker].amountStaked; } @@ -205,7 +213,9 @@ abstract contract RollupCore is IRollupCore, PausableUpgradeable { * @param staker Staker address to lookup * @return Withdrawal address of the staker */ - function withdrawalAddress(address staker) public view override returns (address) { + function withdrawalAddress( + address staker + ) public view override returns (address) { return _stakerMap[staker].withdrawalAddress; } @@ -214,7 +224,9 @@ abstract contract RollupCore is IRollupCore, PausableUpgradeable { * @param staker Staker address to retrieve * @return A structure with information about the requested staker */ - function getStaker(address staker) external view override returns (Staker memory) { + function getStaker( + address staker + ) external view override returns (Staker memory) { return _stakerMap[staker]; } @@ -223,7 +235,9 @@ abstract contract RollupCore is IRollupCore, PausableUpgradeable { * @param user Address to check the funds of * @return Amount of funds withdrawable by user */ - function withdrawableFunds(address user) external view override returns (uint256) { + function withdrawableFunds( + address user + ) external view override returns (uint256) { return _withdrawableFunds[user]; } @@ -341,7 +355,9 @@ abstract contract RollupCore is IRollupCore, PausableUpgradeable { * This should only be called when the staker is inactive * @param stakerAddress Address of the staker withdrawing their stake */ - function withdrawStaker(address stakerAddress) internal { + function withdrawStaker( + address stakerAddress + ) internal { Staker storage staker = _stakerMap[stakerAddress]; address _withdrawalAddress = staker.withdrawalAddress; uint256 initialStaked = staker.amountStaked; @@ -355,7 +371,9 @@ abstract contract RollupCore is IRollupCore, PausableUpgradeable { * @param account Address of the account to remove funds from * @return Amount of funds removed from account */ - function withdrawFunds(address account) internal returns (uint256) { + function withdrawFunds( + address account + ) internal returns (uint256) { uint256 amount = _withdrawableFunds[account]; _withdrawableFunds[account] = 0; totalWithdrawableFunds -= amount; @@ -379,7 +397,9 @@ abstract contract RollupCore is IRollupCore, PausableUpgradeable { * @notice Remove the given staker * @param stakerAddress Address of the staker to remove */ - function deleteStaker(address stakerAddress) private { + function deleteStaker( + address stakerAddress + ) private { Staker storage staker = _stakerMap[stakerAddress]; require(staker.isStaked, "NOT_STAKED"); uint64 stakerIndex = staker.index; @@ -569,11 +589,15 @@ abstract contract RollupCore is IRollupCore, PausableUpgradeable { }); } - function getFirstChildCreationBlock(bytes32 assertionHash) external view returns (uint64) { + function getFirstChildCreationBlock( + bytes32 assertionHash + ) external view returns (uint64) { return getAssertionStorage(assertionHash).firstChildBlock; } - function getSecondChildCreationBlock(bytes32 assertionHash) external view returns (uint64) { + function getSecondChildCreationBlock( + bytes32 assertionHash + ) external view returns (uint64) { return getAssertionStorage(assertionHash).secondChildBlock; } @@ -593,11 +617,15 @@ abstract contract RollupCore is IRollupCore, PausableUpgradeable { RollupLib.validateConfigHash(configData, getAssertionStorage(assertionHash).configHash); } - function isFirstChild(bytes32 assertionHash) external view returns (bool) { + function isFirstChild( + bytes32 assertionHash + ) external view returns (bool) { return getAssertionStorage(assertionHash).isFirstChild; } - function isPending(bytes32 assertionHash) external view returns (bool) { + function isPending( + bytes32 assertionHash + ) external view returns (bool) { return getAssertionStorage(assertionHash).status == AssertionStatus.Pending; } @@ -605,7 +633,9 @@ abstract contract RollupCore is IRollupCore, PausableUpgradeable { return validators.values(); } - function isValidator(address validator) external view returns (bool) { + function isValidator( + address validator + ) external view returns (bool) { return validators.contains(validator); } @@ -613,7 +643,9 @@ abstract contract RollupCore is IRollupCore, PausableUpgradeable { * @notice Verify that the given staker is not active * @param stakerAddress Address to check */ - function requireInactiveStaker(address stakerAddress) internal view { + function requireInactiveStaker( + address stakerAddress + ) internal view { require(isStaked(stakerAddress), "NOT_STAKED"); // A staker is inactive if // a) their last staked assertion is the latest confirmed assertion diff --git a/src/rollup/RollupEventInbox.sol b/src/rollup/RollupEventInbox.sol index e3d00c61..24fb1d36 100644 --- a/src/rollup/RollupEventInbox.sol +++ b/src/rollup/RollupEventInbox.sol @@ -14,7 +14,9 @@ import {INITIALIZATION_MSG_TYPE} from "../libraries/MessageTypes.sol"; contract RollupEventInbox is AbsRollupEventInbox { constructor() AbsRollupEventInbox() {} - function _enqueueInitializationMsg(bytes memory initMsg) internal override returns (uint256) { + function _enqueueInitializationMsg( + bytes memory initMsg + ) internal override returns (uint256) { return IEthBridge(address(bridge)).enqueueDelayedMessage( INITIALIZATION_MSG_TYPE, address(0), keccak256(initMsg) ); diff --git a/src/rollup/RollupUserLogic.sol b/src/rollup/RollupUserLogic.sol index 8c27cd57..73e758b7 100644 --- a/src/rollup/RollupUserLogic.sol +++ b/src/rollup/RollupUserLogic.sol @@ -17,14 +17,18 @@ contract RollupUserLogic is RollupCore, UUPSNotUpgradeable, IRollupUser { using SafeERC20 for IERC20; using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet; - modifier onlyValidator(address account) { + modifier onlyValidator( + address account + ) { require(validators.contains(account) || validatorWhitelistDisabled, "NOT_VALIDATOR"); _; } /// @dev the user logic just validated configuration and shouldn't write to state during init /// this allows the admin logic to ensure consistency on parameters. - function initialize(address _stakeToken) external view override onlyProxy { + function initialize( + address _stakeToken + ) external view override onlyProxy { require(_stakeToken != address(0), "NEED_STAKE_TOKEN"); } @@ -237,7 +241,9 @@ contract RollupUserLogic is RollupCore, UUPSNotUpgradeable, IRollupUser { /** * @dev Require that the staker is inactive and withdraw their stake */ - function _requireInactiveAndWithdrawStaker(address stakerAddress) internal { + function _requireInactiveAndWithdrawStaker( + address stakerAddress + ) internal { requireInactiveStaker(stakerAddress); withdrawStaker(stakerAddress); } @@ -264,7 +270,9 @@ contract RollupUserLogic is RollupCore, UUPSNotUpgradeable, IRollupUser { * @notice Reduce the amount staked for the sender (difference between initial amount staked and target is creditted back to the sender). * @param target Target amount of stake for the staker. */ - function reduceDeposit(uint256 target) external onlyValidator(msg.sender) whenNotPaused { + function reduceDeposit( + uint256 target + ) external onlyValidator(msg.sender) whenNotPaused { requireInactiveStaker(msg.sender); // amount will be checked when creating an assertion reduceStakeTo(msg.sender, target); @@ -412,7 +420,9 @@ contract RollupUserLogic is RollupCore, UUPSNotUpgradeable, IRollupUser { return amount; } - function receiveTokens(uint256 tokenAmount) private { + function receiveTokens( + uint256 tokenAmount + ) private { IERC20(stakeToken).safeTransferFrom(msg.sender, address(this), tokenAmount); } } diff --git a/src/rollup/ValidatorWallet.sol b/src/rollup/ValidatorWallet.sol index 4066cb55..cea2ea87 100644 --- a/src/rollup/ValidatorWallet.sol +++ b/src/rollup/ValidatorWallet.sol @@ -94,7 +94,9 @@ contract ValidatorWallet is OwnableUpgradeable, DelegateCallAware, GasRefundEnab } /// @dev reverts if the current function can't be called - function validateExecuteTransaction(address destination) public view { + function validateExecuteTransaction( + address destination + ) public view { if (!allowedExecutorDestinations[destination] && owner() != _msgSender()) { revert OnlyOwnerDestination(owner(), _msgSender(), destination); } diff --git a/src/rollup/ValidatorWalletCreator.sol b/src/rollup/ValidatorWalletCreator.sol index b3814d43..18e59b74 100644 --- a/src/rollup/ValidatorWalletCreator.sol +++ b/src/rollup/ValidatorWalletCreator.sol @@ -25,7 +25,9 @@ contract ValidatorWalletCreator is Ownable { template = address(new ValidatorWallet()); } - function setTemplate(address _template) external onlyOwner { + function setTemplate( + address _template + ) external onlyOwner { template = _template; emit TemplateUpdated(); } diff --git a/src/state/GlobalState.sol b/src/state/GlobalState.sol index 892957e4..fb450530 100644 --- a/src/state/GlobalState.sol +++ b/src/state/GlobalState.sol @@ -15,7 +15,9 @@ library GlobalStateLib { uint16 internal constant BYTES32_VALS_NUM = 2; uint16 internal constant U64_VALS_NUM = 2; - function hash(GlobalState memory state) internal pure returns (bytes32) { + function hash( + GlobalState memory state + ) internal pure returns (bytes32) { return keccak256( abi.encodePacked( "Global state:", @@ -27,23 +29,33 @@ library GlobalStateLib { ); } - function getBlockHash(GlobalState memory state) internal pure returns (bytes32) { + function getBlockHash( + GlobalState memory state + ) internal pure returns (bytes32) { return state.bytes32Vals[0]; } - function getSendRoot(GlobalState memory state) internal pure returns (bytes32) { + function getSendRoot( + GlobalState memory state + ) internal pure returns (bytes32) { return state.bytes32Vals[1]; } - function getInboxPosition(GlobalState memory state) internal pure returns (uint64) { + function getInboxPosition( + GlobalState memory state + ) internal pure returns (uint64) { return state.u64Vals[0]; } - function getPositionInMessage(GlobalState memory state) internal pure returns (uint64) { + function getPositionInMessage( + GlobalState memory state + ) internal pure returns (uint64) { return state.u64Vals[1]; } - function isEmpty(GlobalState calldata state) internal pure returns (bool) { + function isEmpty( + GlobalState calldata state + ) internal pure returns (bool) { return ( state.bytes32Vals[0] == bytes32(0) && state.bytes32Vals[1] == bytes32(0) && state.u64Vals[0] == 0 && state.u64Vals[1] == 0 diff --git a/src/state/Instructions.sol b/src/state/Instructions.sol index 990fc8ae..080407a8 100644 --- a/src/state/Instructions.sol +++ b/src/state/Instructions.sol @@ -155,7 +155,9 @@ library Instructions { uint256 internal constant INBOX_INDEX_SEQUENCER = 0; uint256 internal constant INBOX_INDEX_DELAYED = 1; - function hash(Instruction[] memory code) internal pure returns (bytes32) { + function hash( + Instruction[] memory code + ) internal pure returns (bytes32) { // To avoid quadratic expense, we declare a `bytes` early and populate its contents. bytes memory data = new bytes(13 + 1 + 34 * code.length); assembly { diff --git a/src/state/Machine.sol b/src/state/Machine.sol index ea0820ca..3f1c7aa6 100644 --- a/src/state/Machine.sol +++ b/src/state/Machine.sol @@ -37,7 +37,9 @@ library MachineLib { bytes32 internal constant NO_RECOVERY_PC = ~bytes32(0); - function hash(Machine memory mach) internal pure returns (bytes32) { + function hash( + Machine memory mach + ) internal pure returns (bytes32) { // Warning: the non-running hashes are replicated in Challenge if (mach.status == MachineStatus.RUNNING) { bytes32 valueMultiHash = @@ -66,7 +68,9 @@ library MachineLib { } } - function switchCoThreadStacks(Machine memory mach) internal pure { + function switchCoThreadStacks( + Machine memory mach + ) internal pure { bytes32 newActiveValue = mach.valueMultiStack.inactiveStackHash; bytes32 newActiveFrame = mach.frameMultiStack.inactiveStackHash; if ( @@ -93,7 +97,9 @@ library MachineLib { return true; } - function setPcFromRecovery(Machine memory mach) internal pure returns (bool) { + function setPcFromRecovery( + Machine memory mach + ) internal pure returns (bool) { if (!setPcFromData(mach, uint256(mach.recoveryPc))) { return false; } diff --git a/src/state/Module.sol b/src/state/Module.sol index ebbaec33..35ea9306 100644 --- a/src/state/Module.sol +++ b/src/state/Module.sol @@ -18,7 +18,9 @@ struct Module { library ModuleLib { using ModuleMemoryCompactLib for ModuleMemory; - function hash(Module memory mod) internal pure returns (bytes32) { + function hash( + Module memory mod + ) internal pure returns (bytes32) { return keccak256( abi.encodePacked( "Module:", diff --git a/src/state/ModuleMemory.sol b/src/state/ModuleMemory.sol index 25734b16..57158c54 100644 --- a/src/state/ModuleMemory.sol +++ b/src/state/ModuleMemory.sol @@ -13,7 +13,9 @@ library ModuleMemoryLib { uint256 private constant LEAF_SIZE = 32; - function hash(ModuleMemory memory mem) internal pure returns (bytes32) { + function hash( + ModuleMemory memory mem + ) internal pure returns (bytes32) { return ModuleMemoryCompactLib.hash(mem); } diff --git a/src/state/ModuleMemoryCompact.sol b/src/state/ModuleMemoryCompact.sol index 62715477..80c2fe09 100644 --- a/src/state/ModuleMemoryCompact.sol +++ b/src/state/ModuleMemoryCompact.sol @@ -11,7 +11,9 @@ struct ModuleMemory { } library ModuleMemoryCompactLib { - function hash(ModuleMemory memory mem) internal pure returns (bytes32) { + function hash( + ModuleMemory memory mem + ) internal pure returns (bytes32) { return keccak256(abi.encodePacked("Memory:", mem.size, mem.maxSize, mem.merkleRoot)); } } diff --git a/src/state/MultiStack.sol b/src/state/MultiStack.sol index 5252b334..f56b1c59 100644 --- a/src/state/MultiStack.sol +++ b/src/state/MultiStack.sol @@ -34,12 +34,16 @@ library MultiStackLib { } } - function setEmpty(MultiStack memory multi) internal pure { + function setEmpty( + MultiStack memory multi + ) internal pure { multi.inactiveStackHash = NO_STACK_HASH; multi.remainingHash = 0; } - function pushNew(MultiStack memory multi) internal pure { + function pushNew( + MultiStack memory multi + ) internal pure { if (multi.inactiveStackHash != NO_STACK_HASH) { multi.remainingHash = keccak256( abi.encodePacked("cothread:", multi.inactiveStackHash, multi.remainingHash) diff --git a/src/state/PcArray.sol b/src/state/PcArray.sol index 71cae379..2688d5bd 100644 --- a/src/state/PcArray.sol +++ b/src/state/PcArray.sol @@ -17,7 +17,9 @@ library PcArrayLib { arr.inner[index] = val; } - function length(PcArray memory arr) internal pure returns (uint256) { + function length( + PcArray memory arr + ) internal pure returns (uint256) { return arr.inner.length; } @@ -30,7 +32,9 @@ library PcArrayLib { arr.inner = newInner; } - function pop(PcArray memory arr) internal pure returns (uint32 popped) { + function pop( + PcArray memory arr + ) internal pure returns (uint32 popped) { popped = arr.inner[arr.inner.length - 1]; uint32[] memory newInner = new uint32[](arr.inner.length - 1); for (uint256 i = 0; i < newInner.length; i++) { diff --git a/src/state/StackFrame.sol b/src/state/StackFrame.sol index bf617400..e97e5c6d 100644 --- a/src/state/StackFrame.sol +++ b/src/state/StackFrame.sol @@ -21,7 +21,9 @@ struct StackFrameWindow { library StackFrameLib { using ValueLib for Value; - function hash(StackFrame memory frame) internal pure returns (bytes32) { + function hash( + StackFrame memory frame + ) internal pure returns (bytes32) { return keccak256( abi.encodePacked( "Stack frame:", @@ -33,19 +35,25 @@ library StackFrameLib { ); } - function hash(StackFrameWindow memory window) internal pure returns (bytes32 h) { + function hash( + StackFrameWindow memory window + ) internal pure returns (bytes32 h) { h = window.remainingHash; for (uint256 i = 0; i < window.proved.length; i++) { h = keccak256(abi.encodePacked("Stack frame stack:", hash(window.proved[i]), h)); } } - function peek(StackFrameWindow memory window) internal pure returns (StackFrame memory) { + function peek( + StackFrameWindow memory window + ) internal pure returns (StackFrame memory) { require(window.proved.length == 1, "BAD_WINDOW_LENGTH"); return window.proved[0]; } - function pop(StackFrameWindow memory window) internal pure returns (StackFrame memory frame) { + function pop( + StackFrameWindow memory window + ) internal pure returns (StackFrame memory frame) { require(window.proved.length == 1, "BAD_WINDOW_LENGTH"); frame = window.proved[0]; window.proved = new StackFrame[](0); diff --git a/src/state/Value.sol b/src/state/Value.sol index ca1b1a19..9f558da7 100644 --- a/src/state/Value.sol +++ b/src/state/Value.sol @@ -20,7 +20,9 @@ struct Value { } library ValueLib { - function hash(Value memory val) internal pure returns (bytes32) { + function hash( + Value memory val + ) internal pure returns (bytes32) { return keccak256(abi.encodePacked("Value:", val.valueType, val.contents)); } @@ -28,14 +30,18 @@ library ValueLib { return ValueType.INTERNAL_REF; } - function assumeI32(Value memory val) internal pure returns (uint32) { + function assumeI32( + Value memory val + ) internal pure returns (uint32) { uint256 uintval = uint256(val.contents); require(val.valueType == ValueType.I32, "NOT_I32"); require(uintval < (1 << 32), "BAD_I32"); return uint32(uintval); } - function assumeI64(Value memory val) internal pure returns (uint64) { + function assumeI64( + Value memory val + ) internal pure returns (uint64) { uint256 uintval = uint256(val.contents); require(val.valueType == ValueType.I64, "NOT_I64"); require(uintval < (1 << 64), "BAD_I64"); @@ -46,15 +52,21 @@ library ValueLib { return Value({valueType: ValueType.REF_NULL, contents: 0}); } - function newI32(uint32 x) internal pure returns (Value memory) { + function newI32( + uint32 x + ) internal pure returns (Value memory) { return Value({valueType: ValueType.I32, contents: uint256(x)}); } - function newI64(uint64 x) internal pure returns (Value memory) { + function newI64( + uint64 x + ) internal pure returns (Value memory) { return Value({valueType: ValueType.I64, contents: uint256(x)}); } - function newBoolean(bool x) internal pure returns (Value memory) { + function newBoolean( + bool x + ) internal pure returns (Value memory) { if (x) { return newI32(uint32(1)); } else { diff --git a/src/state/ValueArray.sol b/src/state/ValueArray.sol index 1eb5a511..db30c34c 100644 --- a/src/state/ValueArray.sol +++ b/src/state/ValueArray.sol @@ -19,7 +19,9 @@ library ValueArrayLib { arr.inner[index] = val; } - function length(ValueArray memory arr) internal pure returns (uint256) { + function length( + ValueArray memory arr + ) internal pure returns (uint256) { return arr.inner.length; } @@ -32,7 +34,9 @@ library ValueArrayLib { arr.inner = newInner; } - function pop(ValueArray memory arr) internal pure returns (Value memory popped) { + function pop( + ValueArray memory arr + ) internal pure returns (Value memory popped) { popped = arr.inner[arr.inner.length - 1]; Value[] memory newInner = new Value[](arr.inner.length - 1); for (uint256 i = 0; i < newInner.length; i++) { diff --git a/src/state/ValueStack.sol b/src/state/ValueStack.sol index 4ba135fb..7fe625ff 100644 --- a/src/state/ValueStack.sol +++ b/src/state/ValueStack.sol @@ -16,7 +16,9 @@ library ValueStackLib { using ValueLib for Value; using ValueArrayLib for ValueArray; - function hash(ValueStack memory stack) internal pure returns (bytes32 h) { + function hash( + ValueStack memory stack + ) internal pure returns (bytes32 h) { h = stack.remainingHash; uint256 len = stack.proved.length(); for (uint256 i = 0; i < len; i++) { @@ -24,12 +26,16 @@ library ValueStackLib { } } - function peek(ValueStack memory stack) internal pure returns (Value memory) { + function peek( + ValueStack memory stack + ) internal pure returns (Value memory) { uint256 len = stack.proved.length(); return stack.proved.get(len - 1); } - function pop(ValueStack memory stack) internal pure returns (Value memory) { + function pop( + ValueStack memory stack + ) internal pure returns (Value memory) { return stack.proved.pop(); } diff --git a/src/test-helpers/BridgeTester.sol b/src/test-helpers/BridgeTester.sol index 6c484598..15bff13b 100644 --- a/src/test-helpers/BridgeTester.sol +++ b/src/test-helpers/BridgeTester.sol @@ -59,7 +59,9 @@ contract BridgeTester is Initializable, DelegateCallAware, IBridge, IEthBridge { _; } - function setSequencerInbox(address _sequencerInbox) external override onlyRollupOrOwner { + function setSequencerInbox( + address _sequencerInbox + ) external override onlyRollupOrOwner { sequencerInbox = _sequencerInbox; emit SequencerInboxUpdated(_sequencerInbox); } @@ -72,12 +74,16 @@ contract BridgeTester is Initializable, DelegateCallAware, IBridge, IEthBridge { address private constant EMPTY_ACTIVEOUTBOX = address(type(uint160).max); - function initialize(IOwnable rollup_) external initializer { + function initialize( + IOwnable rollup_ + ) external initializer { _activeOutbox = EMPTY_ACTIVEOUTBOX; rollup = rollup_; } - function updateRollupAddress(IOwnable _rollup) external { + function updateRollupAddress( + IOwnable _rollup + ) external { rollup = _rollup; } @@ -86,11 +92,15 @@ contract BridgeTester is Initializable, DelegateCallAware, IBridge, IEthBridge { return _activeOutbox; } - function allowedDelayedInboxes(address inbox) external view override returns (bool) { + function allowedDelayedInboxes( + address inbox + ) external view override returns (bool) { return allowedInboxesMap[inbox].allowed; } - function allowedOutboxes(address outbox) external view override returns (bool) { + function allowedOutboxes( + address outbox + ) external view override returns (bool) { return allowedOutboxesMap[outbox].allowed; } diff --git a/src/test-helpers/CryptographyPrimitivesTester.sol b/src/test-helpers/CryptographyPrimitivesTester.sol index 35f9eb75..65f5665a 100644 --- a/src/test-helpers/CryptographyPrimitivesTester.sol +++ b/src/test-helpers/CryptographyPrimitivesTester.sol @@ -7,7 +7,9 @@ pragma solidity ^0.8.0; import "../libraries/CryptographyPrimitives.sol"; library CryptographyPrimitivesTester { - function keccakF(uint256[25] memory input) public pure returns (uint256[25] memory) { + function keccakF( + uint256[25] memory input + ) public pure returns (uint256[25] memory) { return CryptographyPrimitives.keccakF(input); } diff --git a/src/test-helpers/EthVault.sol b/src/test-helpers/EthVault.sol index 20b9b0f0..e73f8b76 100644 --- a/src/test-helpers/EthVault.sol +++ b/src/test-helpers/EthVault.sol @@ -10,7 +10,9 @@ pragma solidity ^0.8.0; contract EthVault { uint256 public version = 0; - function setVersion(uint256 _version) external payable { + function setVersion( + uint256 _version + ) external payable { version = _version; } diff --git a/src/test-helpers/OutboxWithoutOptTester.sol b/src/test-helpers/OutboxWithoutOptTester.sol index b43fe447..9ec93b56 100644 --- a/src/test-helpers/OutboxWithoutOptTester.sol +++ b/src/test-helpers/OutboxWithoutOptTester.sol @@ -22,7 +22,9 @@ contract OutboxWithoutOptTester is DelegateCallAware, IOutbox { address public rollup; // the rollup contract IBridge public bridge; // the bridge contract - function spent(uint256) external pure override returns (bytes32) { + function spent( + uint256 + ) external pure override returns (bytes32) { revert("NOT_IMPLEMETED"); } @@ -43,7 +45,9 @@ contract OutboxWithoutOptTester is DelegateCallAware, IOutbox { L2ToL1Context internal context; uint128 public constant OUTBOX_VERSION = 2; - function initialize(IBridge _bridge) external { + function initialize( + IBridge _bridge + ) external { if (address(bridge) != address(0)) revert AlreadyInit(); bridge = _bridge; rollup = address(_bridge.rollup()); diff --git a/src/test-helpers/RollupMock.sol b/src/test-helpers/RollupMock.sol index 00aed3cf..0284e57a 100644 --- a/src/test-helpers/RollupMock.sol +++ b/src/test-helpers/RollupMock.sol @@ -10,7 +10,9 @@ contract RollupMock { address public owner; - constructor(address _owner) { + constructor( + address _owner + ) { owner = _owner; } diff --git a/src/test-helpers/TestToken.sol b/src/test-helpers/TestToken.sol index 5fdc091a..60911893 100644 --- a/src/test-helpers/TestToken.sol +++ b/src/test-helpers/TestToken.sol @@ -10,7 +10,9 @@ import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; * Basic ERC20 token */ contract TestToken is ERC20 { - constructor(uint256 initialSupply) ERC20("TestToken", "TT") { + constructor( + uint256 initialSupply + ) ERC20("TestToken", "TT") { _mint(msg.sender, initialSupply); } } diff --git a/test/MockAssertionChain.sol b/test/MockAssertionChain.sol index 10652612..766cad81 100644 --- a/test/MockAssertionChain.sol +++ b/test/MockAssertionChain.sol @@ -31,7 +31,9 @@ contract MockAssertionChain is IAssertionChain { bool public validatorWhitelistDisabled; mapping(address => bool) public isValidator; - function assertionExists(bytes32 assertionHash) public view returns (bool) { + function assertionExists( + bytes32 assertionHash + ) public view returns (bool) { return assertions[assertionHash].height != 0; } @@ -53,12 +55,16 @@ contract MockAssertionChain is IAssertionChain { ); } - function getFirstChildCreationBlock(bytes32 assertionHash) external view returns (uint64) { + function getFirstChildCreationBlock( + bytes32 assertionHash + ) external view returns (uint64) { require(assertionExists(assertionHash), "Assertion does not exist"); return assertions[assertionHash].firstChildCreationBlock; } - function getSecondChildCreationBlock(bytes32 assertionHash) external view returns (uint64) { + function getSecondChildCreationBlock( + bytes32 assertionHash + ) external view returns (uint64) { require(assertionExists(assertionHash), "Assertion does not exist"); return assertions[assertionHash].secondChildCreationBlock; } @@ -76,12 +82,16 @@ contract MockAssertionChain is IAssertionChain { ); } - function isFirstChild(bytes32 assertionHash) external view returns (bool) { + function isFirstChild( + bytes32 assertionHash + ) external view returns (bool) { require(assertionExists(assertionHash), "Assertion does not exist"); return assertions[assertionHash].isFirstChild; } - function isPending(bytes32 assertionHash) external view returns (bool) { + function isPending( + bytes32 assertionHash + ) external view returns (bool) { require(assertionExists(assertionHash), "Assertion does not exist"); return assertions[assertionHash].isPending; } @@ -97,7 +107,9 @@ contract MockAssertionChain is IAssertionChain { }); } - function childCreated(bytes32 assertionHash) internal { + function childCreated( + bytes32 assertionHash + ) internal { if (assertions[assertionHash].firstChildCreationBlock == 0) { assertions[assertionHash].firstChildCreationBlock = uint64(block.number); } else if (assertions[assertionHash].secondChildCreationBlock == 0) { @@ -157,7 +169,9 @@ contract MockAssertionChain is IAssertionChain { ); } - function setValidatorWhitelistDisabled(bool x) external { + function setValidatorWhitelistDisabled( + bool x + ) external { validatorWhitelistDisabled = x; } diff --git a/test/Rollup.t.sol b/test/Rollup.t.sol index 9f08acb8..e0aea1d6 100644 --- a/test/Rollup.t.sol +++ b/test/Rollup.t.sol @@ -929,7 +929,9 @@ contract RollupTest is Test { userRollup.removeWhitelistAfterValidatorAfk(); } - function testSuccessSetValidatorAfk(uint32 x) public { + function testSuccessSetValidatorAfk( + uint32 x + ) public { vm.assume(x > 0); (bytes32 assertionHash,,) = testSuccessConfirmUnchallengedAssertions(); vm.prank(upgradeExecutorAddr); diff --git a/test/challengeV2/ChallengeEdgeLib.t.sol b/test/challengeV2/ChallengeEdgeLib.t.sol index ccd781ca..71834457 100644 --- a/test/challengeV2/ChallengeEdgeLib.t.sol +++ b/test/challengeV2/ChallengeEdgeLib.t.sol @@ -24,7 +24,9 @@ contract ChallengeEdgeLibAccess { return storageEdge; } - function setChallengeEdge(ChallengeEdge memory edge) public { + function setChallengeEdge( + ChallengeEdge memory edge + ) public { storageEdge = edge; } @@ -95,7 +97,9 @@ contract ChallengeEdgeLibAccess { return ChallengeEdgeLib.mutualId(storageEdge); } - function mutualIdMem(ChallengeEdge memory ce) public pure returns (bytes32) { + function mutualIdMem( + ChallengeEdge memory ce + ) public pure returns (bytes32) { return ChallengeEdgeLib.mutualIdMem(ce); } @@ -112,7 +116,9 @@ contract ChallengeEdgeLibAccess { ); } - function idMem(ChallengeEdge memory edge) public pure returns (bytes32) { + function idMem( + ChallengeEdge memory edge + ) public pure returns (bytes32) { return ChallengeEdgeLib.idMem(edge); } diff --git a/test/challengeV2/EdgeChallengeManager.t.sol b/test/challengeV2/EdgeChallengeManager.t.sol index ebf49e13..1631e143 100644 --- a/test/challengeV2/EdgeChallengeManager.t.sol +++ b/test/challengeV2/EdgeChallengeManager.t.sol @@ -2344,7 +2344,9 @@ contract EdgeChallengeManagerTest is Test { } } - function _safeVmRoll(uint256 target) internal { + function _safeVmRoll( + uint256 target + ) internal { require(target >= block.number, "BACKWARD_VMROLL"); vm.roll(target); } diff --git a/test/challengeV2/EdgeChallengeManagerLib.t.sol b/test/challengeV2/EdgeChallengeManagerLib.t.sol index f9981923..06e7fc89 100644 --- a/test/challengeV2/EdgeChallengeManagerLib.t.sol +++ b/test/challengeV2/EdgeChallengeManagerLib.t.sol @@ -12,7 +12,9 @@ import "./Utils.sol"; contract MockOneStepProofEntry is IOneStepProofEntry { using GlobalStateLib for GlobalState; - constructor(uint256 _testMachineStep) { + constructor( + uint256 _testMachineStep + ) { testMachineStep = _testMachineStep; } @@ -49,23 +51,33 @@ contract EdgeChallengeManagerLibAccess { EdgeStore private store; - function exists(bytes32 edgeId) public view returns (bool) { + function exists( + bytes32 edgeId + ) public view returns (bool) { return store.get(edgeId).exists(); } - function get(bytes32 edgeId) public view returns (ChallengeEdge memory) { + function get( + bytes32 edgeId + ) public view returns (ChallengeEdge memory) { return store.get(edgeId); } - function getNoCheck(bytes32 edgeId) public view returns (ChallengeEdge memory) { + function getNoCheck( + bytes32 edgeId + ) public view returns (ChallengeEdge memory) { return store.getNoCheck(edgeId); } - function add(ChallengeEdge memory edge) public returns (EdgeAddedData memory) { + function add( + ChallengeEdge memory edge + ) public returns (EdgeAddedData memory) { return store.add(edge); } - function isPowerOfTwo(uint256 x) public pure returns (bool) { + function isPowerOfTwo( + uint256 x + ) public pure returns (bool) { return EdgeChallengeManagerLib.isPowerOfTwo(x); } @@ -82,11 +94,15 @@ contract EdgeChallengeManagerLibAccess { ); } - function getPrevAssertionHash(bytes32 edgeId) public view returns (bytes32) { + function getPrevAssertionHash( + bytes32 edgeId + ) public view returns (bytes32) { return store.getPrevAssertionHash(edgeId); } - function hasRival(bytes32 edgeId) public view returns (bool) { + function hasRival( + bytes32 edgeId + ) public view returns (bool) { return store.hasRival(edgeId); } @@ -94,15 +110,21 @@ contract EdgeChallengeManagerLibAccess { store.firstRivals[edgeId] = firstRival; } - function hasLengthOneRival(bytes32 edgeId) public view returns (bool) { + function hasLengthOneRival( + bytes32 edgeId + ) public view returns (bool) { return store.hasLengthOneRival(edgeId); } - function timeUnrivaled(bytes32 edgeId) public view returns (uint256) { + function timeUnrivaled( + bytes32 edgeId + ) public view returns (uint256) { return store.timeUnrivaled(edgeId); } - function timeUnrivaledTotal(bytes32 edgeId) public view returns (uint256) { + function timeUnrivaledTotal( + bytes32 edgeId + ) public view returns (uint256) { return store.timeUnrivaledTotal(edgeId); } @@ -122,11 +144,15 @@ contract EdgeChallengeManagerLibAccess { return store.bisectEdge(edgeId, bisectionHistoryRoot, prefixProof); } - function setConfirmed(bytes32 id) public { + function setConfirmed( + bytes32 id + ) public { store.get(id).setConfirmed(); } - function setConfirmedRival(bytes32 edgeId) public { + function setConfirmedRival( + bytes32 edgeId + ) public { return EdgeChallengeManagerLib.setConfirmedRival(store, edgeId); } @@ -134,7 +160,9 @@ contract EdgeChallengeManagerLibAccess { store.get(edgeId).claimId = claimId; } - function getConfirmedRival(bytes32 mutualId) public view returns (bytes32) { + function getConfirmedRival( + bytes32 mutualId + ) public view returns (bytes32) { return store.confirmedRivals[mutualId]; } @@ -146,7 +174,9 @@ contract EdgeChallengeManagerLibAccess { return EdgeChallengeManagerLib.nextEdgeLevel(level, numBigStepLevel); } - function firstRivals(bytes32 mutualId) public view returns (bytes32) { + function firstRivals( + bytes32 mutualId + ) public view returns (bytes32) { return store.firstRivals[mutualId]; } @@ -158,11 +188,15 @@ contract EdgeChallengeManagerLibAccess { store.hasMadeLayerZeroRival[account][mutualId] = x; } - function remove(bytes32 edgeId) public { + function remove( + bytes32 edgeId + ) public { delete store.edges[edgeId]; } - function confirmedRivals(bytes32 mutualId) public view returns (bytes32) { + function confirmedRivals( + bytes32 mutualId + ) public view returns (bytes32) { return store.confirmedRivals[mutualId]; } @@ -619,7 +653,9 @@ contract EdgeChallengeManagerLibTest is Test { assertEq(store.mandatoryBisectionHeight(765273563, 10898783768364), 8796093022208); } - function getExpansion(uint256 leafCount) internal returns (bytes32[] memory) { + function getExpansion( + uint256 leafCount + ) internal returns (bytes32[] memory) { bytes32[] memory hashes = rand.hashes(leafCount); bytes32[] memory expansion = ProofUtils.expansionFromLeaves(hashes, 0, leafCount); return expansion; @@ -862,7 +898,9 @@ contract EdgeChallengeManagerLibTest is Test { assertFalse(store.hasRival(store.get(edge2.idMem()).upperChildId), "Upper child rival"); } - function bisectMergeEdge(uint256 agree) internal { + function bisectMergeEdge( + uint256 agree + ) internal { uint256 start = 3; uint256 end = 11; uint256 bisectionPoint = store.mandatoryBisectionHeight(start, end); @@ -1326,7 +1364,9 @@ contract EdgeChallengeManagerLibTest is Test { return stepSize; } - function confirmByOneStep(uint256 flag) internal { + function confirmByOneStep( + uint256 flag + ) internal { uint256 startHeight = rand.unsignedInt(SMALLSTEPHEIGHT); (bytes32[] memory states1, bytes32[] memory states2) = rivalStates(startHeight, startHeight, startHeight + 1); @@ -1549,7 +1589,9 @@ contract EdgeChallengeManagerLibTest is Test { bytes32 machineHash; } - function randomAssertionState(IOneStepProofEntry os) private returns (ExecStateVars memory) { + function randomAssertionState( + IOneStepProofEntry os + ) private returns (ExecStateVars memory) { AssertionState memory assertionState = AssertionState( GlobalState( [rand.hash(), rand.hash()], @@ -1563,7 +1605,9 @@ contract EdgeChallengeManagerLibTest is Test { return ExecStateVars(assertionState, machineHash); } - function createZeroBlockEdge(uint256 mode) internal returns (EdgeAddedData memory) { + function createZeroBlockEdge( + uint256 mode + ) internal returns (EdgeAddedData memory) { return createZeroBlockEdge(mode, ""); } @@ -1801,7 +1845,9 @@ contract EdgeChallengeManagerLibTest is Test { AssertionReferenceData emptyArd; } - function createSmallStepEdge(uint256 mode) internal { + function createSmallStepEdge( + uint256 mode + ) internal { CreateSmallStepEdgeData memory vars; vars.claimStartHeight = 4; diff --git a/test/challengeV2/MerkleTreeLib.t.sol b/test/challengeV2/MerkleTreeLib.t.sol index 64d0350d..7229d846 100644 --- a/test/challengeV2/MerkleTreeLib.t.sol +++ b/test/challengeV2/MerkleTreeLib.t.sol @@ -12,7 +12,9 @@ import "./Utils.sol"; contract MerkleTreeLibTest is Test { Random random = new Random(); - function clone(bytes32[] memory arr) internal pure returns (bytes32[] memory) { + function clone( + bytes32[] memory arr + ) internal pure returns (bytes32[] memory) { bytes32[] memory newArr = new bytes32[](arr.length); for (uint256 i = 0; i < arr.length; i++) { newArr[i] = arr[i]; @@ -94,7 +96,9 @@ contract MerkleTreeLibTest is Test { proveVerify(20, 7052); } - function testRoot(uint256 size) public { + function testRoot( + uint256 size + ) public { vm.assume(size > 0); vm.assume(size < 257); bytes32[] memory hashes = random.hashes(size); @@ -108,7 +112,9 @@ contract MerkleTreeLibTest is Test { assertEq(root, expRoot, "Roots"); } - function getExpansion(uint256 leafCount) internal returns (bytes32[] memory) { + function getExpansion( + uint256 leafCount + ) internal returns (bytes32[] memory) { bytes32[] memory hashes = random.hashes(leafCount); bytes32[] memory expansion = ProofUtils.expansionFromLeaves(hashes, 0, leafCount); return expansion; @@ -195,7 +201,9 @@ contract MerkleTreeLibTest is Test { MerkleTreeLib.root(expansion); } - function testAppendCS(uint256 treeSize) public { + function testAppendCS( + uint256 treeSize + ) public { vm.assume(treeSize > 0); vm.assume(treeSize < 16); @@ -232,7 +240,9 @@ contract MerkleTreeLibTest is Test { } } - function plainAppend(uint256 level) internal { + function plainAppend( + uint256 level + ) internal { bytes32[] memory pre = getExpansion(44); bytes32 rand = random.hash(); diff --git a/test/challengeV2/StateTools.sol b/test/challengeV2/StateTools.sol index bea72b94..26aac4f5 100644 --- a/test/challengeV2/StateTools.sol +++ b/test/challengeV2/StateTools.sol @@ -26,11 +26,15 @@ library StateToolsLib { return AssertionState({globalState: gs, machineStatus: ms, endHistoryRoot: bytes32(0)}); } - function hash(AssertionState memory s) internal pure returns (bytes32) { + function hash( + AssertionState memory s + ) internal pure returns (bytes32) { return s.globalState.hash(); } - function mockMachineHash(AssertionState memory s) internal pure returns (bytes32) { + function mockMachineHash( + AssertionState memory s + ) internal pure returns (bytes32) { return s.globalState.hash(); } } diff --git a/test/challengeV2/Utils.sol b/test/challengeV2/Utils.sol index 2fa17530..d5674c89 100644 --- a/test/challengeV2/Utils.sol +++ b/test/challengeV2/Utils.sol @@ -17,7 +17,9 @@ contract Random { return seed; } - function hashes(uint256 count) public returns (bytes32[] memory) { + function hashes( + uint256 count + ) public returns (bytes32[] memory) { bytes32[] memory h = new bytes32[](count); for (uint256 i = 0; i < h.length; i++) { h[i] = hash(); @@ -30,7 +32,9 @@ contract Random { return address(bytes20(seed)); } - function unsignedInt(uint256 max) public returns (uint256) { + function unsignedInt( + uint256 max + ) public returns (uint256) { bytes32 h = hash(); return uint256(h) % max; } @@ -131,7 +135,9 @@ library ProofUtils { return proof; } - function fullTree(bytes32[] memory leaves) internal pure returns (bytes32[][] memory) { + function fullTree( + bytes32[] memory leaves + ) internal pure returns (bytes32[][] memory) { uint256 msb = UintUtilsLib.mostSignificantBit(leaves.length); uint256 lsb = UintUtilsLib.leastSignificantBit(leaves.length); @@ -159,7 +165,9 @@ library ProofUtils { return layers; } - function rehashed(bytes32[] memory arr) internal pure returns (bytes32[] memory) { + function rehashed( + bytes32[] memory arr + ) internal pure returns (bytes32[] memory) { bytes32[] memory arr2 = new bytes32[](arr.length); for (uint256 i = 0; i < arr.length; i++) { arr2[i] = keccak256(abi.encodePacked(arr[i])); diff --git a/test/foundry/CacheManager.t.sol b/test/foundry/CacheManager.t.sol index 17767164..7d276094 100644 --- a/test/foundry/CacheManager.t.sol +++ b/test/foundry/CacheManager.t.sol @@ -179,7 +179,9 @@ contract ArbOwnerPublicMock { } // pretend all smart contracts are chain owners - function isChainOwner(address addr) external view returns (bool) { + function isChainOwner( + address addr + ) external view returns (bool) { uint256 codeSize; assembly { codeSize := extcodesize(addr) @@ -190,7 +192,9 @@ contract ArbOwnerPublicMock { contract ArbWasmMock { // returns a non-uniform distribution of mock code sizes - function codehashAsmSize(bytes32 codehash) external pure returns (uint64) { + function codehashAsmSize( + bytes32 codehash + ) external pure returns (uint64) { return uint64(uint256(keccak256(abi.encodePacked(codehash))) % 65_536); } } @@ -200,7 +204,9 @@ contract ArbWasmCacheMock { uint256 public numCached; uint256 public uselessCalls; - function cacheProgram(address addr) external { + function cacheProgram( + address addr + ) external { bytes32 codehash = addr.codehash; if (codehashIsCached[codehash]) { uselessCalls++; @@ -210,7 +216,9 @@ contract ArbWasmCacheMock { numCached++; } - function evictCodehash(bytes32 codehash) external { + function evictCodehash( + bytes32 codehash + ) external { if (!codehashIsCached[codehash]) { uselessCalls++; return; diff --git a/test/foundry/DelayBuffer.t.sol b/test/foundry/DelayBuffer.t.sol index 5592db6d..cb38466e 100644 --- a/test/foundry/DelayBuffer.t.sol +++ b/test/foundry/DelayBuffer.t.sol @@ -156,7 +156,9 @@ contract DelayBufferableTest is Test { assertEq(buffer, 9); } - function testUpdateDepleteAndReplenish(BufferConfig memory _config) public { + function testUpdateDepleteAndReplenish( + BufferConfig memory _config + ) public { vm.assume(DelayBuffer.isValidBufferConfig(_config)); // set config diff --git a/test/foundry/ERC20Bridge.t.sol b/test/foundry/ERC20Bridge.t.sol index d36eb8eb..036b4e1a 100644 --- a/test/foundry/ERC20Bridge.t.sol +++ b/test/foundry/ERC20Bridge.t.sol @@ -399,7 +399,9 @@ contract ERC20BridgeTest is AbsBridgeTest { contract MockBridgedToken is ERC20 { address public gateway; - constructor(address _gateway) ERC20("MockBridgedToken", "TT") { + constructor( + address _gateway + ) ERC20("MockBridgedToken", "TT") { gateway = _gateway; _mint(msg.sender, 1_000_000 ether); } diff --git a/test/foundry/ERC20Outbox.t.sol b/test/foundry/ERC20Outbox.t.sol index c9b96c55..1322501d 100644 --- a/test/foundry/ERC20Outbox.t.sol +++ b/test/foundry/ERC20Outbox.t.sol @@ -479,7 +479,9 @@ contract ERC20L2ToL1Target { withdrawalAmount = ERC20Outbox(outbox).l2ToL1WithdrawalAmount(); } - function setOutbox(address _outbox) external { + function setOutbox( + address _outbox + ) external { outbox = _outbox; } } diff --git a/test/foundry/Outbox.t.sol b/test/foundry/Outbox.t.sol index ed70ca6a..924b92f9 100644 --- a/test/foundry/Outbox.t.sol +++ b/test/foundry/Outbox.t.sol @@ -130,7 +130,9 @@ contract L2ToL1Target { withdrawalAmount = msg.value; } - function setOutbox(address _outbox) external { + function setOutbox( + address _outbox + ) external { outbox = _outbox; } } diff --git a/test/foundry/RollupCreator.t.sol b/test/foundry/RollupCreator.t.sol index 11b4d08a..7e2af3de 100644 --- a/test/foundry/RollupCreator.t.sol +++ b/test/foundry/RollupCreator.t.sol @@ -520,22 +520,30 @@ contract RollupCreatorTest is Test { return (ospEntry, challengeManager, rollupAdminLogic, rollupUserLogic); } - function _getProxyAdmin(address proxy) internal view returns (address) { + function _getProxyAdmin( + address proxy + ) internal view returns (address) { bytes32 adminSlot = bytes32(uint256(keccak256("eip1967.proxy.admin")) - 1); return address(uint160(uint256(vm.load(proxy, adminSlot)))); } - function _getImpl(address proxy) internal view returns (address) { + function _getImpl( + address proxy + ) internal view returns (address) { bytes32 implSlot = bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1); return address(uint160(uint256(vm.load(proxy, implSlot)))); } - function _getPrimary(address proxy) internal view returns (address) { + function _getPrimary( + address proxy + ) internal view returns (address) { bytes32 primarySlot = bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1); return address(uint160(uint256(vm.load(proxy, primarySlot)))); } - function _getSecondary(address proxy) internal view returns (address) { + function _getSecondary( + address proxy + ) internal view returns (address) { bytes32 secondarySlot = bytes32(uint256(keccak256("eip1967.proxy.implementation.secondary")) - 1); return address(uint160(uint256(vm.load(proxy, secondarySlot)))); diff --git a/test/foundry/SequencerInbox.t.sol b/test/foundry/SequencerInbox.t.sol index 2a36a22d..17a89e98 100644 --- a/test/foundry/SequencerInbox.t.sol +++ b/test/foundry/SequencerInbox.t.sol @@ -11,7 +11,9 @@ import "@openzeppelin/contracts/token/ERC20/presets/ERC20PresetMinterPauser.sol" contract RollupMock { address public immutable owner; - constructor(address _owner) { + constructor( + address _owner + ) { owner = _owner; } } @@ -222,7 +224,9 @@ contract SequencerInboxTest is Test { bytes biggerData = hex"00a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890a4567890"; - function testAddSequencerL2BatchFromOrigin(BufferConfig memory bufferConfig) public { + function testAddSequencerL2BatchFromOrigin( + BufferConfig memory bufferConfig + ) public { (SequencerInbox seqInbox, Bridge bridge) = deployRollup(false, false, bufferConfig); address delayedInboxSender = address(140); uint8 delayedInboxKind = 3; @@ -274,7 +278,9 @@ contract SequencerInboxTest is Test { assertEq(seqInboxProxyFeeToken.isUsingFeeToken(), true, "Invalid isUsingFeeToken"); } - function testInitialize(BufferConfig memory bufferConfig) public { + function testInitialize( + BufferConfig memory bufferConfig + ) public { Bridge _bridge = Bridge(address(new TransparentUpgradeableProxy(address(new Bridge()), proxyAdmin, ""))); _bridge.initialize(IOwnable(address(new RollupMock(rollupOwner)))); @@ -289,7 +295,9 @@ contract SequencerInboxTest is Test { assertEq(address(seqInboxProxy.rollup()), address(_bridge.rollup()), "Invalid rollup"); } - function testInitialize_FeeTokenBased(BufferConfig memory bufferConfig) public { + function testInitialize_FeeTokenBased( + BufferConfig memory bufferConfig + ) public { ERC20Bridge _bridge = ERC20Bridge( address(new TransparentUpgradeableProxy(address(new ERC20Bridge()), proxyAdmin, "")) ); @@ -512,7 +520,9 @@ contract SequencerInboxTest is Test { return (seqInbox, seqInboxImpl); } - function testPostUpgradeInitBuffer(BufferConfig memory bufferConfig) public { + function testPostUpgradeInitBuffer( + BufferConfig memory bufferConfig + ) public { vm.assume(DelayBuffer.isValidBufferConfig(bufferConfig)); (SequencerInbox seqInbox, SequencerInbox seqInboxImpl) = @@ -578,14 +588,18 @@ contract SequencerInboxTest is Test { ); } - function testSetBufferConfig(BufferConfig memory bufferConfig) public { + function testSetBufferConfig( + BufferConfig memory bufferConfig + ) public { vm.assume(DelayBuffer.isValidBufferConfig(bufferConfig)); (SequencerInbox seqInbox,) = deployRollup(false, true, bufferConfig); vm.prank(rollupOwner); seqInbox.setBufferConfig(bufferConfig); } - function testSetBufferConfigInvalid(BufferConfig memory bufferConfigInvalid) public { + function testSetBufferConfigInvalid( + BufferConfig memory bufferConfigInvalid + ) public { vm.assume(!DelayBuffer.isValidBufferConfig(bufferConfigInvalid)); (SequencerInbox seqInbox,) = deployRollup(false, true, bufferConfigDefault); vm.expectRevert(abi.encodeWithSelector(BadBufferConfig.selector)); diff --git a/test/foundry/util/TestUtil.sol b/test/foundry/util/TestUtil.sol index def8120c..f4230026 100644 --- a/test/foundry/util/TestUtil.sol +++ b/test/foundry/util/TestUtil.sol @@ -5,7 +5,9 @@ import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.so import "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol"; library TestUtil { - function deployProxy(address logic) public returns (address) { + function deployProxy( + address logic + ) public returns (address) { ProxyAdmin pa = new ProxyAdmin(); return address(new TransparentUpgradeableProxy(address(logic), address(pa), "")); } @@ -19,7 +21,9 @@ contract Random { return seed; } - function Bytes(uint256 length) public returns (bytes memory) { + function Bytes( + uint256 length + ) public returns (bytes memory) { require(length > 0, "Length must be greater than 0"); bytes memory randomBytes = new bytes(length); diff --git a/test/stakingPool/EdgeStakingPool.t.sol b/test/stakingPool/EdgeStakingPool.t.sol index af312c4d..fff7da06 100644 --- a/test/stakingPool/EdgeStakingPool.t.sol +++ b/test/stakingPool/EdgeStakingPool.t.sol @@ -11,11 +11,15 @@ contract MockChallengeManager { event EdgeCreated(CreateEdgeArgs args); - constructor(IERC20 _token) { + constructor( + IERC20 _token + ) { stakeToken = _token; } - function createLayerZeroEdge(CreateEdgeArgs calldata args) external returns (bytes32) { + function createLayerZeroEdge( + CreateEdgeArgs calldata args + ) external returns (bytes32) { stakeToken.transferFrom(msg.sender, address(this), stakeAmounts(args.level)); emit EdgeCreated(args); @@ -23,7 +27,9 @@ contract MockChallengeManager { return keccak256(abi.encode(args)); } - function stakeAmounts(uint256 lvl) public pure returns (uint256) { + function stakeAmounts( + uint256 lvl + ) public pure returns (uint256) { return 100 * (lvl + 1); } } @@ -41,7 +47,9 @@ contract EdgeStakingPoolTest is Test { stakingPoolCreator = new EdgeStakingPoolCreator(); } - function testProperInitialization(bytes32 edgeId) public { + function testProperInitialization( + bytes32 edgeId + ) public { vm.assume(edgeId != bytes32(0)); IEdgeStakingPool stakingPool = stakingPoolCreator.createPool(address(challengeManager), edgeId); @@ -61,7 +69,9 @@ contract EdgeStakingPoolTest is Test { stakingPoolCreator.createPool(address(challengeManager), bytes32(0)); } - function testCreateEdge(CreateEdgeArgs memory args) public { + function testCreateEdge( + CreateEdgeArgs memory args + ) public { uint256 requiredStake = challengeManager.stakeAmounts(args.level); bytes32 realEdgeId = keccak256(abi.encode(args)); IEdgeStakingPool stakingPool =