Skip to content

Commit 98026d1

Browse files
authored
Merge pull request #52 from EspressoSystems/sync-v2.1.3
Sync v2.1.1 to v2.1.3
2 parents cff556b + a34bf4e commit 98026d1

30 files changed

+380
-40
lines changed

audit-ci.jsonc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@
6565
// Server-Side Request Forgery in axios
6666
"GHSA-8hc4-vh64-cxmj",
6767
// Regular Expression Denial of Service (ReDoS) in micromatch
68-
"GHSA-952p-6rrq-rcjv"
68+
"GHSA-952p-6rrq-rcjv",
69+
// cookie accepts cookie name, path, and domain with out of bounds characters
70+
"GHSA-pxg6-pf52-xh8x"
6971
]
7072
}

deploy/ExpressLaneAuction.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
module.exports = async hre => {
2+
const { deployments, getNamedAccounts } = hre
3+
const { deploy } = deployments
4+
const { deployer } = await getNamedAccounts()
5+
6+
await deploy('ExpressLaneAuction', {
7+
from: deployer,
8+
args: [],
9+
proxy: {
10+
proxyContract: 'TransparentUpgradeableProxy',
11+
execute: {
12+
init: {
13+
methodName: 'initialize',
14+
args: [{
15+
_auctioneer: "0xeee584DA928A94950E177235EcB9A99bb655c7A0",
16+
_biddingToken: "0x980B62Da83eFf3D4576C647993b0c1D7faf17c73", // WETH
17+
_beneficiary: "0xeee584DA928A94950E177235EcB9A99bb655c7A0",
18+
_roundTimingInfo: {
19+
offsetTimestamp: 1727870000,
20+
roundDurationSeconds: 60,
21+
auctionClosingSeconds: 15,
22+
reserveSubmissionSeconds: 15
23+
},
24+
_minReservePrice: ethers.utils.parseEther("0.00001"),
25+
_auctioneerAdmin: "0xeee584DA928A94950E177235EcB9A99bb655c7A0",
26+
_minReservePriceSetter: "0xeee584DA928A94950E177235EcB9A99bb655c7A0",
27+
_reservePriceSetter: "0xeee584DA928A94950E177235EcB9A99bb655c7A0",
28+
_reservePriceSetterAdmin: "0xeee584DA928A94950E177235EcB9A99bb655c7A0",
29+
_beneficiarySetter: "0xeee584DA928A94950E177235EcB9A99bb655c7A0",
30+
_roundTimingSetter: "0xeee584DA928A94950E177235EcB9A99bb655c7A0",
31+
_masterAdmin: "0xeee584DA928A94950E177235EcB9A99bb655c7A0"
32+
}],
33+
},
34+
},
35+
owner: deployer,
36+
},
37+
})
38+
}
39+
40+
module.exports.tags = ['ExpressLaneAuction']
41+
module.exports.dependencies = []

foundry.toml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,30 @@ src = 'src/'
33
out = 'out'
44
libs = ['node_modules', 'lib']
55
test = 'test/foundry'
6-
cache_path = 'forge-cache/sol'
6+
cache_path = 'forge-cache/sol'
77
optimizer = true
88
optimizer_runs = 1
9+
allow_internal_expect_revert = true
910
via_ir = true
1011
solc_version = '0.8.25'
1112
evm_version = 'cancun'
12-
fs_permissions = [{ access = "read", path = "./"}]
13-
remappings = ['ds-test/=lib/forge-std/lib/ds-test/src/',
14-
'forge-std/=lib/forge-std/src/',
15-
'@openzeppelin/contracts/=node_modules/@openzeppelin/contracts/',
16-
'@openzeppelin/contracts-upgradeable/=node_modules/@openzeppelin/contracts-upgradeable/']
13+
fs_permissions = [{ access = "read", path = "./" }]
14+
remappings = [
15+
'ds-test/=lib/forge-std/lib/ds-test/src/',
16+
'forge-std/=lib/forge-std/src/',
17+
'@openzeppelin/contracts/=node_modules/@openzeppelin/contracts/',
18+
'@openzeppelin/contracts-upgradeable/=node_modules/@openzeppelin/contracts-upgradeable/',
19+
]
1720

1821
[profile.yul]
1922
src = 'yul'
2023
out = 'out/yul'
2124
libs = ['node_modules', 'lib']
22-
cache_path = 'forge-cache/yul'
25+
cache_path = 'forge-cache/yul'
2326
remappings = []
2427
auto_detect_remappings = false
2528

2629
[fmt]
2730
number_underscore = 'thousands'
2831
line_length = 100
29-
# See more config options https://github.com/foundry-rs/foundry/tree/master/config
32+
# See more config options https://github.com/foundry-rs/foundry/tree/master/config

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@espressosystems/nitro-contracts",
3-
"version": "2.1.1-beta.0",
3+
"version": "2.1.3",
44
"description": "Layer 2 precompiles and rollup for Arbitrum Nitro",
55
"author": "Offchain Labs, Inc.",
66
"license": "BUSL-1.1",
@@ -99,4 +99,4 @@
9999
"typescript": "^4.5.4",
100100
"yarn-audit-fix": "^10.0.7"
101101
}
102-
}
102+
}

slither.db.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

src/bridge/AbsInbox.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@ import {
1111
InsufficientSubmissionCost,
1212
L1Forked,
1313
NotAllowedOrigin,
14-
NotOrigin,
14+
NotCodelessOrigin,
1515
NotRollupOrOwner,
1616
RetryableData
1717
} from "../libraries/Error.sol";
1818
import "./IInboxBase.sol";
1919
import "./ISequencerInbox.sol";
2020
import "./IBridge.sol";
2121
import "../libraries/AddressAliasHelper.sol";
22+
import "../libraries/CallerChecker.sol";
2223
import "../libraries/DelegateCallAware.sol";
2324
import {
2425
L1MessageType_submitRetryableTx,
@@ -138,8 +139,7 @@ abstract contract AbsInbox is DelegateCallAware, PausableUpgradeable, IInboxBase
138139
returns (uint256)
139140
{
140141
if (_chainIdChanged()) revert L1Forked();
141-
// solhint-disable-next-line avoid-tx-origin
142-
if (msg.sender != tx.origin) revert NotOrigin();
142+
if (!CallerChecker.isCallerCodelessOrigin()) revert NotCodelessOrigin();
143143
if (messageData.length > maxDataSize) revert DataTooLarge(messageData.length, maxDataSize);
144144
uint256 msgNum = _deliverToBridge(L2_MSG, msg.sender, keccak256(messageData), 0);
145145
emit InboxMessageDeliveredFromOrigin(msgNum);

src/bridge/ERC20Bridge.sol

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,15 @@ contract ERC20Bridge is AbsBridge, IERC20Bridge {
6262
}
6363
}
6464

65+
/// @notice When upgrading a custom fee chain from v1.x.x to v2.1.2, nativeTokenDecimals must be set to 18.
66+
/// This is because v1.x.x contracts assume 18 decimals, but the ERC20Bridge does not have the decimals set in storage.
67+
function postUpgradeInit() external onlyDelegated onlyProxyOwner {
68+
// this zero check might save you from accidentally upgrading from v2.x.x to v2.1.2
69+
// it will not save you if your native token is supposed to have 0 decimals
70+
require(nativeTokenDecimals == 0, "NONZERO_NATIVE_TOKEN_DECIMALS");
71+
nativeTokenDecimals = 18;
72+
}
73+
6574
/// @inheritdoc IERC20Bridge
6675
function enqueueDelayedMessage(
6776
uint8 kind,

src/bridge/Inbox.sol

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ contract Inbox is AbsInbox, IInbox {
118118
if (!_chainIdChanged()) revert NotForked();
119119
// solhint-disable-next-line avoid-tx-origin
120120
if (msg.sender != tx.origin) revert NotOrigin();
121+
// no code size check required because we only want to know if msg.sender is an EOA to undo alias
121122
// arbos will discard unsigned tx with gas limit too large
122123
if (gasLimit > type(uint64).max) {
123124
revert GasLimitTooLarge();
@@ -152,6 +153,7 @@ contract Inbox is AbsInbox, IInbox {
152153
if (!_chainIdChanged()) revert NotForked();
153154
// solhint-disable-next-line avoid-tx-origin
154155
if (msg.sender != tx.origin) revert NotOrigin();
156+
// no code size check required because we only want to know if msg.sender is an EOA to undo alias
155157
// arbos will discard unsigned tx with gas limit too large
156158
if (gasLimit > type(uint64).max) {
157159
revert GasLimitTooLarge();
@@ -185,6 +187,7 @@ contract Inbox is AbsInbox, IInbox {
185187
if (!_chainIdChanged()) revert NotForked();
186188
// solhint-disable-next-line avoid-tx-origin
187189
if (msg.sender != tx.origin) revert NotOrigin();
190+
// no code size check required because we only want to know if msg.sender is an EOA to undo alias
188191
// arbos will discard unsigned tx with gas limit too large
189192
if (gasLimit > type(uint64).max) {
190193
revert GasLimitTooLarge();

src/bridge/SequencerInbox.sol

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
NoSuchKeyset,
2222
NotForked,
2323
NotBatchPosterManager,
24+
NotCodelessOrigin,
2425
RollupNotChanged,
2526
DataBlobsNotSupported,
2627
InitParamZero,
@@ -38,6 +39,7 @@ import "../rollup/IRollupLogic.sol";
3839
import "./Messages.sol";
3940
import "../precompiles/ArbGasInfo.sol";
4041
import "../precompiles/ArbSys.sol";
42+
import "../libraries/CallerChecker.sol";
4143
import "../libraries/IReader4844.sol";
4244

4345
import {L1MessageType_batchPostingReport} from "../libraries/MessageTypes.sol";
@@ -370,8 +372,7 @@ contract SequencerInbox is DelegateCallAware, GasRefundEnabled, ISequencerInbox
370372
uint256 newMessageCount,
371373
bytes memory quote
372374
) external refundsGas(gasRefunder, IReader4844(address(0))) {
373-
// solhint-disable-next-line avoid-tx-origin
374-
if (msg.sender != tx.origin) revert NotOrigin();
375+
if (!CallerChecker.isCallerCodelessOrigin()) revert NotCodelessOrigin();
375376
if (!isBatchPoster[msg.sender]) revert NotBatchPoster();
376377

377378
// take keccak2256 hash of all the function arguments except the quote
@@ -483,10 +484,9 @@ contract SequencerInbox is DelegateCallAware, GasRefundEnabled, ISequencerInbox
483484
if (hostChainIsArbitrum) revert DataBlobsNotSupported();
484485

485486
// submit a batch spending report to refund the entity that produced the blob batch data
486-
// same as using calldata, we only submit spending report if the caller is the origin of the tx
487+
// same as using calldata, we only submit spending report if the caller is the origin and is codeless
487488
// such that one cannot "double-claim" batch posting refund in the same tx
488-
// solhint-disable-next-line avoid-tx-origin
489-
if (msg.sender == tx.origin && !isUsingFeeToken) {
489+
if (CallerChecker.isCallerCodelessOrigin() && !isUsingFeeToken) {
490490
submitBatchSpendingReport(dataHash, seqMessageIndex, block.basefee, blobGas);
491491
}
492492
}

src/libraries/CallerChecker.sol

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright 2021-2024, Offchain Labs, Inc.
2+
// For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE
3+
// SPDX-License-Identifier: BUSL-1.1
4+
5+
pragma solidity ^0.8.0;
6+
7+
library CallerChecker {
8+
/**
9+
* @notice A EIP-7702 safe check to ensure the caller is the origin and is codeless
10+
* @return bool true if the caller is the origin and is codeless, false otherwise
11+
* @dev If the caller is the origin and is codeless, then msg.data is guaranteed to be same as tx.data
12+
* It also mean the caller would not be able to call a contract multiple times with the same transaction
13+
*/
14+
function isCallerCodelessOrigin() internal view returns (bool) {
15+
// solhint-disable-next-line avoid-tx-origin
16+
return msg.sender == tx.origin && msg.sender.code.length == 0;
17+
}
18+
}

0 commit comments

Comments
 (0)