Skip to content

Commit

Permalink
chore: latest nitro-contracts develop 5e9673f
Browse files Browse the repository at this point in the history
  • Loading branch information
gzeoneth committed Aug 2, 2023
1 parent ee975f0 commit 895405e
Show file tree
Hide file tree
Showing 96 changed files with 203 additions and 201 deletions.
2 changes: 1 addition & 1 deletion contracts/src/bridge/Bridge.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright 2021-2022, Offchain Labs, Inc.
// For license information, see https://github.com/nitro/blob/master/LICENSE
// For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE
// SPDX-License-Identifier: BUSL-1.1

pragma solidity ^0.8.4;
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/bridge/IBridge.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright 2021-2022, Offchain Labs, Inc.
// For license information, see https://github.com/nitro/blob/master/LICENSE
// For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE
// SPDX-License-Identifier: BUSL-1.1

// solhint-disable-next-line compiler-version
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/bridge/IDelayedMessageProvider.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright 2021-2022, Offchain Labs, Inc.
// For license information, see https://github.com/nitro/blob/master/LICENSE
// For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE
// SPDX-License-Identifier: BUSL-1.1

// solhint-disable-next-line compiler-version
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/bridge/IInbox.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright 2021-2022, Offchain Labs, Inc.
// For license information, see https://github.com/nitro/blob/master/LICENSE
// For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE
// SPDX-License-Identifier: BUSL-1.1

// solhint-disable-next-line compiler-version
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/bridge/IOutbox.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright 2021-2022, Offchain Labs, Inc.
// For license information, see https://github.com/nitro/blob/master/LICENSE
// For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE
// SPDX-License-Identifier: BUSL-1.1

// solhint-disable-next-line compiler-version
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/bridge/IOwnable.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright 2021-2022, Offchain Labs, Inc.
// For license information, see https://github.com/nitro/blob/master/LICENSE
// For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE
// SPDX-License-Identifier: BUSL-1.1

// solhint-disable-next-line compiler-version
Expand Down
16 changes: 12 additions & 4 deletions contracts/src/bridge/ISequencerInbox.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright 2021-2022, Offchain Labs, Inc.
// For license information, see https://github.com/nitro/blob/master/LICENSE
// For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE
// SPDX-License-Identifier: BUSL-1.1

// solhint-disable-next-line compiler-version
Expand Down Expand Up @@ -76,9 +76,17 @@ interface ISequencerInbox is IDelayedMessageProvider {
uint64 creationBlock;
}

// https://github.com/ethereum/solidity/issues/11826
// function maxTimeVariation() external view returns (MaxTimeVariation calldata);
// function dasKeySetInfo(bytes32) external view returns (DasKeySetInfo calldata);
function maxTimeVariation()
external
view
returns (
uint256,
uint256,
uint256,
uint256
);

function dasKeySetInfo(bytes32) external view returns (bool, uint64);

/// @notice Remove force inclusion delay after a L1 chainId fork
function removeDelayAfterFork() external;
Expand Down
82 changes: 2 additions & 80 deletions contracts/src/bridge/Inbox.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright 2021-2022, Offchain Labs, Inc.
// For license information, see https://github.com/nitro/blob/master/LICENSE
// For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE
// SPDX-License-Identifier: BUSL-1.1

pragma solidity ^0.8.4;
Expand Down Expand Up @@ -35,7 +35,7 @@ import {
L2MessageType_unsignedEOATx,
L2MessageType_unsignedContractTx
} from "../libraries/MessageTypes.sol";
import {MAX_DATA_SIZE, UNISWAP_L1_TIMELOCK, UNISWAP_L2_FACTORY} from "../libraries/Constants.sol";
import {MAX_DATA_SIZE} from "../libraries/Constants.sol";
import "../precompiles/ArbSys.sol";

import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol";
Expand Down Expand Up @@ -527,84 +527,6 @@ contract Inbox is DelegateCallAware, PausableUpgradeable, IInbox {
);
}

/// @notice This is an one-time-exception to resolve a misconfiguration of Uniswap Arbitrum deployment
/// Only the Uniswap L1 Timelock may call this function and it is allowed to create a crosschain
/// retryable ticket without address aliasing. More info here:
/// https://gov.uniswap.org/t/consensus-check-fix-the-cross-chain-messaging-bridge-on-arbitrum/18547
/// @dev This function will be removed in future releases
function uniswapCreateRetryableTicket(
address to,
uint256 l2CallValue,
uint256 maxSubmissionCost,
address excessFeeRefundAddress,
address callValueRefundAddress,
uint256 gasLimit,
uint256 maxFeePerGas,
bytes calldata data
) external payable whenNotPaused onlyAllowed returns (uint256) {
// this can only be called by UNISWAP_L1_TIMELOCK
require(msg.sender == UNISWAP_L1_TIMELOCK, "NOT_UNISWAP_L1_TIMELOCK");
// the retryable can only call UNISWAP_L2_FACTORY
require(to == UNISWAP_L2_FACTORY, "NOT_TO_UNISWAP_L2_FACTORY");

// ensure the user's deposit alone will make submission succeed
if (msg.value < (maxSubmissionCost + l2CallValue + gasLimit * maxFeePerGas)) {
revert InsufficientValue(
maxSubmissionCost + l2CallValue + gasLimit * maxFeePerGas,
msg.value
);
}

// if a refund address is a contract, we apply the alias to it
// so that it can access its funds on the L2
// since the beneficiary and other refund addresses don't get rewritten by arb-os
if (AddressUpgradeable.isContract(excessFeeRefundAddress)) {
excessFeeRefundAddress = AddressAliasHelper.applyL1ToL2Alias(excessFeeRefundAddress);
}
if (AddressUpgradeable.isContract(callValueRefundAddress)) {
// this is the beneficiary. be careful since this is the address that can cancel the retryable in the L2
callValueRefundAddress = AddressAliasHelper.applyL1ToL2Alias(callValueRefundAddress);
}

// gas price and limit of 1 should never be a valid input, so instead they are used as
// magic values to trigger a revert in eth calls that surface data without requiring a tx trace
if (gasLimit == 1 || maxFeePerGas == 1)
revert RetryableData(
msg.sender,
to,
l2CallValue,
msg.value,
maxSubmissionCost,
excessFeeRefundAddress,
callValueRefundAddress,
gasLimit,
maxFeePerGas,
data
);

uint256 submissionFee = calculateRetryableSubmissionFee(data.length, block.basefee);
if (maxSubmissionCost < submissionFee)
revert InsufficientSubmissionCost(submissionFee, maxSubmissionCost);

return
_deliverMessage(
L1MessageType_submitRetryableTx,
AddressAliasHelper.undoL1ToL2Alias(msg.sender),
abi.encodePacked(
uint256(uint160(to)),
l2CallValue,
msg.value,
maxSubmissionCost,
uint256(uint160(excessFeeRefundAddress)),
uint256(uint160(callValueRefundAddress)),
gasLimit,
maxFeePerGas,
data.length,
data
)
);
}

function _deliverMessage(
uint8 _kind,
address _sender,
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/bridge/Messages.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright 2021-2022, Offchain Labs, Inc.
// For license information, see https://github.com/nitro/blob/master/LICENSE
// For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE
// SPDX-License-Identifier: BUSL-1.1

pragma solidity ^0.8.0;
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/bridge/Outbox.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright 2021-2022, Offchain Labs, Inc.
// For license information, see https://github.com/nitro/blob/master/LICENSE
// For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE
// SPDX-License-Identifier: BUSL-1.1

pragma solidity ^0.8.4;
Expand Down
37 changes: 29 additions & 8 deletions contracts/src/bridge/SequencerInbox.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright 2021-2022, Offchain Labs, Inc.
// For license information, see https://github.com/nitro/blob/master/LICENSE
// For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE
// SPDX-License-Identifier: BUSL-1.1

pragma solidity ^0.8.0;
Expand Down Expand Up @@ -27,10 +27,12 @@ import "./IInbox.sol";
import "./ISequencerInbox.sol";
import "../rollup/IRollupLogic.sol";
import "./Messages.sol";
import "../precompiles/ArbGasInfo.sol";

import {L1MessageType_batchPostingReport} from "../libraries/MessageTypes.sol";
import {GasRefundEnabled, IGasRefunder} from "../libraries/IGasRefunder.sol";
import "../libraries/DelegateCallAware.sol";
import "../libraries/ArbitrumChecker.sol";
import {MAX_DATA_SIZE} from "../libraries/Constants.sol";

/**
Expand Down Expand Up @@ -66,6 +68,9 @@ contract SequencerInbox is DelegateCallAware, GasRefundEnabled, ISequencerInbox

mapping(address => bool) public isSequencer;

// If the chain this SequencerInbox is deployed on is an Arbitrum chain.
bool internal immutable hostChainIsArbitrum = ArbitrumChecker.runningOnArbitrum();

function _chainIdChanged() internal view returns (bool) {
return deployTimeChainId != block.chainid;
}
Expand Down Expand Up @@ -387,13 +392,29 @@ contract SequencerInbox is DelegateCallAware, GasRefundEnabled, ISequencerInbox
// this msg isn't included in the current sequencer batch, but instead added to
// the delayed messages queue that is yet to be included
address batchPoster = msg.sender;
bytes memory spendingReportMsg = abi.encodePacked(
block.timestamp,
batchPoster,
dataHash,
seqMessageIndex,
block.basefee
);
bytes memory spendingReportMsg;
if (hostChainIsArbitrum) {
// Include extra gas for the host chain's L1 gas charging
uint256 l1Fees = ArbGasInfo(address(0x6c)).getCurrentTxL1GasFees();
uint256 extraGas = l1Fees / block.basefee;
require(extraGas <= type(uint64).max, "L1_GAS_NOT_UINT64");
spendingReportMsg = abi.encodePacked(
block.timestamp,
batchPoster,
dataHash,
seqMessageIndex,
block.basefee,
uint64(extraGas)
);
} else {
spendingReportMsg = abi.encodePacked(
block.timestamp,
batchPoster,
dataHash,
seqMessageIndex,
block.basefee
);
}
uint256 msgNum = bridge.submitBatchSpendingReport(
batchPoster,
keccak256(spendingReportMsg)
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/challenge/ChallengeLib.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright 2021-2022, Offchain Labs, Inc.
// For license information, see https://github.com/nitro/blob/master/LICENSE
// For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE
// SPDX-License-Identifier: BUSL-1.1

pragma solidity ^0.8.0;
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/challenge/ChallengeManager.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright 2021-2022, Offchain Labs, Inc.
// For license information, see https://github.com/nitro/blob/master/LICENSE
// For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE
// SPDX-License-Identifier: BUSL-1.1

pragma solidity ^0.8.0;
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/challenge/IChallengeManager.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright 2021-2022, Offchain Labs, Inc.
// For license information, see https://github.com/nitro/blob/master/LICENSE
// For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE
// SPDX-License-Identifier: BUSL-1.1

pragma solidity ^0.8.0;
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/challenge/IChallengeResultReceiver.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright 2021-2022, Offchain Labs, Inc.
// For license information, see https://github.com/nitro/blob/master/LICENSE
// For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE
// SPDX-License-Identifier: BUSL-1.1

pragma solidity ^0.8.0;
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/libraries/AddressAliasHelper.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright 2021-2022, Offchain Labs, Inc.
// For license information, see https://github.com/nitro/blob/master/LICENSE
// For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE
// SPDX-License-Identifier: BUSL-1.1

pragma solidity ^0.8.0;
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/libraries/AdminFallbackProxy.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright 2021-2022, Offchain Labs, Inc.
// For license information, see https://github.com/nitro/blob/master/LICENSE
// For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE
// SPDX-License-Identifier: BUSL-1.1

pragma solidity ^0.8.0;
Expand Down
16 changes: 16 additions & 0 deletions contracts/src/libraries/ArbitrumChecker.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright 2021-2022, Offchain Labs, Inc.
// For license information, see https://github.com/nitro/blob/master/LICENSE
// SPDX-License-Identifier: BUSL-1.1

pragma solidity ^0.8.0;

import "../precompiles/ArbSys.sol";

library ArbitrumChecker {
function runningOnArbitrum() internal view returns (bool) {
(bool ok, bytes memory data) = address(100).staticcall(
abi.encodeWithSelector(ArbSys.arbOSVersion.selector)
);
return ok && data.length == 32;
}
}
5 changes: 1 addition & 4 deletions contracts/src/libraries/Constants.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright 2021-2022, Offchain Labs, Inc.
// For license information, see https://github.com/nitro/blob/master/LICENSE
// For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE
// SPDX-License-Identifier: BUSL-1.1

pragma solidity ^0.8.4;
Expand All @@ -11,6 +11,3 @@ uint64 constant NO_CHAL_INDEX = 0;

// Expected seconds per block in Ethereum PoS
uint256 constant ETH_POS_BLOCK_TIME = 12;

address constant UNISWAP_L1_TIMELOCK = 0x1a9C8182C09F50C8318d769245beA52c32BE35BC;
address constant UNISWAP_L2_FACTORY = 0x1F98431c8aD98523631AE4a59f267346ea31F984;
2 changes: 1 addition & 1 deletion contracts/src/libraries/CryptographyPrimitives.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright 2021-2022, Offchain Labs, Inc.
// For license information, see https://github.com/nitro/blob/master/LICENSE
// For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE
// SPDX-License-Identifier: BUSL-1.1

pragma solidity ^0.8.0;
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/libraries/DelegateCallAware.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright 2021-2022, Offchain Labs, Inc.
// For license information, see https://github.com/nitro/blob/master/LICENSE
// For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE
// SPDX-License-Identifier: BUSL-1.1

pragma solidity ^0.8.0;
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/libraries/DoubleLogicUUPSUpgradeable.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright 2021-2022, Offchain Labs, Inc.
// For license information, see https://github.com/nitro/blob/master/LICENSE
// For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE
// SPDX-License-Identifier: BUSL-1.1

pragma solidity ^0.8.0;
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/libraries/Error.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright 2021-2022, Offchain Labs, Inc.
// For license information, see https://github.com/nitro/blob/master/LICENSE
// For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE
// SPDX-License-Identifier: BUSL-1.1

pragma solidity ^0.8.4;
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/libraries/IGasRefunder.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright 2021-2022, Offchain Labs, Inc.
// For license information, see https://github.com/nitro/blob/master/LICENSE
// For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE
// SPDX-License-Identifier: BUSL-1.1

// solhint-disable-next-line compiler-version
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/libraries/MerkleLib.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright 2021-2022, Offchain Labs, Inc.
// For license information, see https://github.com/nitro/blob/master/LICENSE
// For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE
// SPDX-License-Identifier: BUSL-1.1

pragma solidity ^0.8.4;
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/libraries/MessageTypes.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright 2021-2022, Offchain Labs, Inc.
// For license information, see https://github.com/nitro/blob/master/LICENSE
// For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE
// SPDX-License-Identifier: BUSL-1.1

pragma solidity ^0.8.4;
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/mocks/BridgeStub.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright 2021-2022, Offchain Labs, Inc.
// For license information, see https://github.com/nitro/blob/master/LICENSE
// For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE
// SPDX-License-Identifier: BUSL-1.1

pragma solidity ^0.8.0;
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/mocks/BridgeUnproxied.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright 2021-2022, Offchain Labs, Inc.
// For license information, see https://github.com/nitro/blob/master/LICENSE
// For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE
// SPDX-License-Identifier: BUSL-1.1

pragma solidity ^0.8.0;
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/mocks/InboxStub.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright 2021-2022, Offchain Labs, Inc.
// For license information, see https://github.com/nitro/blob/master/LICENSE
// For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE
// SPDX-License-Identifier: BUSL-1.1

pragma solidity ^0.8.0;
Expand Down
Loading

0 comments on commit 895405e

Please sign in to comment.