@arbitrum/nitro-contracts 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/hardhat.prod-config.js +4 -4
- package/package.json +14 -4
- package/src/bridge/Inbox.sol +79 -1
- package/src/libraries/Constants.sol +3 -0
package/README.md
CHANGED
@@ -5,8 +5,8 @@ It includes the rollup and fraud proof smart contracts, as well as interfaces fo
|
|
5
5
|
|
6
6
|
For more information see https://developer.arbitrum.io/docs/public_nitro_devnet
|
7
7
|
|
8
|
-
|
9
8
|
Compile the contracts locally by running
|
9
|
+
|
10
10
|
```bash
|
11
11
|
git clone https://github.com/offchainlabs/nitro
|
12
12
|
cd nitro/contracts
|
package/hardhat.prod-config.js
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
*/
|
4
4
|
module.exports = {
|
5
5
|
solidity: {
|
6
|
-
version:
|
6
|
+
version: '0.8.9',
|
7
7
|
settings: {
|
8
8
|
optimizer: {
|
9
9
|
enabled: true,
|
@@ -12,7 +12,7 @@ module.exports = {
|
|
12
12
|
},
|
13
13
|
},
|
14
14
|
paths: {
|
15
|
-
sources:
|
16
|
-
artifacts:
|
15
|
+
sources: './src',
|
16
|
+
artifacts: 'build/contracts',
|
17
17
|
},
|
18
|
-
}
|
18
|
+
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@arbitrum/nitro-contracts",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.1",
|
4
4
|
"description": "Layer 2 precompiles and rollup for Arbitrum Nitro",
|
5
5
|
"author": "Offchain Labs, Inc.",
|
6
6
|
"license": "BUSL-1.1",
|
@@ -19,8 +19,10 @@
|
|
19
19
|
},
|
20
20
|
"scripts": {
|
21
21
|
"build": "./scripts/build.bash",
|
22
|
+
"lint:test": "eslint ./test",
|
22
23
|
"solhint": "solhint -f table src/**/*.sol",
|
23
24
|
"prettier:solidity": "prettier --write src/**/*.sol",
|
25
|
+
"format": "prettier './**/*.{js,json,md,ts,yml,sol}' --write && yarn run lint:test --fix",
|
24
26
|
"hardhat:prod": "hardhat --config hardhat.prod-config.js",
|
25
27
|
"build:0.6": "INTERFACE_TESTER_SOLC_VERSION=0.6.9 yarn run build",
|
26
28
|
"build:0.7": "INTERFACE_TESTER_SOLC_VERSION=0.7.0 yarn run build",
|
@@ -31,7 +33,8 @@
|
|
31
33
|
"dependencies": {
|
32
34
|
"@openzeppelin/contracts": "4.5.0",
|
33
35
|
"@openzeppelin/contracts-upgradeable": "4.5.2",
|
34
|
-
"hardhat": "^2.6.6"
|
36
|
+
"hardhat": "^2.6.6",
|
37
|
+
"patch-package": "^6.4.7"
|
35
38
|
},
|
36
39
|
"private": false,
|
37
40
|
"devDependencies": {
|
@@ -43,23 +46,30 @@
|
|
43
46
|
"@types/chai": "^4.3.0",
|
44
47
|
"@types/mocha": "^9.0.0",
|
45
48
|
"@types/node": "^17.0.5",
|
49
|
+
"@typescript-eslint/eslint-plugin": "^5.14.0",
|
50
|
+
"@typescript-eslint/eslint-plugin-tslint": "^5.27.1",
|
51
|
+
"@typescript-eslint/parser": "^5.14.0",
|
46
52
|
"chai": "^4.3.4",
|
53
|
+
"eslint": "^8.23.1",
|
54
|
+
"eslint-config-prettier": "^8.3.0",
|
55
|
+
"eslint-plugin-mocha": "^9.0.0",
|
56
|
+
"eslint-plugin-prettier": "^4.0.0",
|
47
57
|
"ethereum-waffle": "^3.4.0",
|
48
58
|
"ethers": "^5.5.2",
|
49
59
|
"hardhat-deploy": "^0.11.4",
|
50
60
|
"hardhat-gas-reporter": "^1.0.8",
|
51
|
-
"patch-package": "^6.4.7",
|
52
61
|
"postinstall-postinstall": "^2.1.0",
|
53
62
|
"prettier": "^2.5.1",
|
54
63
|
"prettier-plugin-solidity": "^1.0.0-beta.19",
|
55
64
|
"solhint": "^3.3.7",
|
56
65
|
"solhint-plugin-prettier": "^0.0.5",
|
57
66
|
"solidity-coverage": "^0.7.20",
|
67
|
+
"tslint": "^6.1.3",
|
58
68
|
"ts-node": "^10.4.0",
|
59
69
|
"typechain": "^8.0.0",
|
60
70
|
"typescript": "^4.5.4"
|
61
71
|
},
|
62
|
-
"optionalDependencies":{
|
72
|
+
"optionalDependencies": {
|
63
73
|
"sol2uml": "2.2.0"
|
64
74
|
}
|
65
75
|
}
|
package/src/bridge/Inbox.sol
CHANGED
@@ -35,7 +35,7 @@ import {
|
|
35
35
|
L2MessageType_unsignedEOATx,
|
36
36
|
L2MessageType_unsignedContractTx
|
37
37
|
} from "../libraries/MessageTypes.sol";
|
38
|
-
import {MAX_DATA_SIZE} from "../libraries/Constants.sol";
|
38
|
+
import {MAX_DATA_SIZE, UNISWAP_L1_TIMELOCK, UNISWAP_L2_FACTORY} from "../libraries/Constants.sol";
|
39
39
|
import "../precompiles/ArbSys.sol";
|
40
40
|
|
41
41
|
import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol";
|
@@ -527,6 +527,84 @@ contract Inbox is DelegateCallAware, PausableUpgradeable, IInbox {
|
|
527
527
|
);
|
528
528
|
}
|
529
529
|
|
530
|
+
/// @notice This is an one-time-exception to resolve a misconfiguration of Uniswap Arbitrum deployment
|
531
|
+
/// Only the Uniswap L1 Timelock may call this function and it is allowed to create a crosschain
|
532
|
+
/// retryable ticket without address aliasing. More info here:
|
533
|
+
/// https://gov.uniswap.org/t/consensus-check-fix-the-cross-chain-messaging-bridge-on-arbitrum/18547
|
534
|
+
/// @dev This function will be removed in future releases
|
535
|
+
function uniswapCreateRetryableTicket(
|
536
|
+
address to,
|
537
|
+
uint256 l2CallValue,
|
538
|
+
uint256 maxSubmissionCost,
|
539
|
+
address excessFeeRefundAddress,
|
540
|
+
address callValueRefundAddress,
|
541
|
+
uint256 gasLimit,
|
542
|
+
uint256 maxFeePerGas,
|
543
|
+
bytes calldata data
|
544
|
+
) external payable whenNotPaused onlyAllowed returns (uint256) {
|
545
|
+
// this can only be called by UNISWAP_L1_TIMELOCK
|
546
|
+
require(msg.sender == UNISWAP_L1_TIMELOCK, "NOT_UNISWAP_L1_TIMELOCK");
|
547
|
+
// the retryable can only call UNISWAP_L2_FACTORY
|
548
|
+
require(to == UNISWAP_L2_FACTORY, "NOT_TO_UNISWAP_L2_FACTORY");
|
549
|
+
|
550
|
+
// ensure the user's deposit alone will make submission succeed
|
551
|
+
if (msg.value < (maxSubmissionCost + l2CallValue + gasLimit * maxFeePerGas)) {
|
552
|
+
revert InsufficientValue(
|
553
|
+
maxSubmissionCost + l2CallValue + gasLimit * maxFeePerGas,
|
554
|
+
msg.value
|
555
|
+
);
|
556
|
+
}
|
557
|
+
|
558
|
+
// if a refund address is a contract, we apply the alias to it
|
559
|
+
// so that it can access its funds on the L2
|
560
|
+
// since the beneficiary and other refund addresses don't get rewritten by arb-os
|
561
|
+
if (AddressUpgradeable.isContract(excessFeeRefundAddress)) {
|
562
|
+
excessFeeRefundAddress = AddressAliasHelper.applyL1ToL2Alias(excessFeeRefundAddress);
|
563
|
+
}
|
564
|
+
if (AddressUpgradeable.isContract(callValueRefundAddress)) {
|
565
|
+
// this is the beneficiary. be careful since this is the address that can cancel the retryable in the L2
|
566
|
+
callValueRefundAddress = AddressAliasHelper.applyL1ToL2Alias(callValueRefundAddress);
|
567
|
+
}
|
568
|
+
|
569
|
+
// gas price and limit of 1 should never be a valid input, so instead they are used as
|
570
|
+
// magic values to trigger a revert in eth calls that surface data without requiring a tx trace
|
571
|
+
if (gasLimit == 1 || maxFeePerGas == 1)
|
572
|
+
revert RetryableData(
|
573
|
+
msg.sender,
|
574
|
+
to,
|
575
|
+
l2CallValue,
|
576
|
+
msg.value,
|
577
|
+
maxSubmissionCost,
|
578
|
+
excessFeeRefundAddress,
|
579
|
+
callValueRefundAddress,
|
580
|
+
gasLimit,
|
581
|
+
maxFeePerGas,
|
582
|
+
data
|
583
|
+
);
|
584
|
+
|
585
|
+
uint256 submissionFee = calculateRetryableSubmissionFee(data.length, block.basefee);
|
586
|
+
if (maxSubmissionCost < submissionFee)
|
587
|
+
revert InsufficientSubmissionCost(submissionFee, maxSubmissionCost);
|
588
|
+
|
589
|
+
return
|
590
|
+
_deliverMessage(
|
591
|
+
L1MessageType_submitRetryableTx,
|
592
|
+
AddressAliasHelper.undoL1ToL2Alias(msg.sender),
|
593
|
+
abi.encodePacked(
|
594
|
+
uint256(uint160(to)),
|
595
|
+
l2CallValue,
|
596
|
+
msg.value,
|
597
|
+
maxSubmissionCost,
|
598
|
+
uint256(uint160(excessFeeRefundAddress)),
|
599
|
+
uint256(uint160(callValueRefundAddress)),
|
600
|
+
gasLimit,
|
601
|
+
maxFeePerGas,
|
602
|
+
data.length,
|
603
|
+
data
|
604
|
+
)
|
605
|
+
);
|
606
|
+
}
|
607
|
+
|
530
608
|
function _deliverMessage(
|
531
609
|
uint8 _kind,
|
532
610
|
address _sender,
|
@@ -11,3 +11,6 @@ uint64 constant NO_CHAL_INDEX = 0;
|
|
11
11
|
|
12
12
|
// Expected seconds per block in Ethereum PoS
|
13
13
|
uint256 constant ETH_POS_BLOCK_TIME = 12;
|
14
|
+
|
15
|
+
address constant UNISWAP_L1_TIMELOCK = 0x1a9C8182C09F50C8318d769245beA52c32BE35BC;
|
16
|
+
address constant UNISWAP_L2_FACTORY = 0x1F98431c8aD98523631AE4a59f267346ea31F984;
|