Skip to content

Commit 007877b

Browse files
committed
chore: nitro-contracts 2aacfaa with refactoring
1 parent fce78e2 commit 007877b

27 files changed

+379
-259
lines changed

contracts/src/bridge/Inbox.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ contract Inbox is DelegateCallAware, PausableUpgradeable, IInbox {
352352
nonce,
353353
uint256(uint160(address(100))), // ArbSys address
354354
value,
355-
abi.encode(ArbSys.withdrawEth.selector, withdrawTo)
355+
abi.encodeWithSelector(ArbSys.withdrawEth.selector, withdrawTo)
356356
)
357357
);
358358
}

contracts/src/libraries/AdminFallbackProxy.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,13 @@ contract AdminFallbackProxy is Proxy, DoubleLogicERC1967Upgrade {
107107
* Only the `adminAddr` is able to use the `adminLogic` functions
108108
* All other addresses can interact with the `userLogic` functions
109109
*/
110-
constructor(
110+
function _initialize(
111111
address adminLogic,
112112
bytes memory adminData,
113113
address userLogic,
114114
bytes memory userData,
115115
address adminAddr
116-
) payable {
116+
) internal {
117117
assert(_ADMIN_SLOT == bytes32(uint256(keccak256("eip1967.proxy.admin")) - 1));
118118
assert(
119119
_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1)

contracts/src/mocks/InboxStub.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ contract InboxStub is IInbox {
151151
address,
152152
uint256,
153153
bytes calldata
154-
) external returns (uint256) {
154+
) external pure returns (uint256) {
155155
revert("NOT_IMPLEMENTED");
156156
}
157157

@@ -161,7 +161,7 @@ contract InboxStub is IInbox {
161161
uint256,
162162
uint256,
163163
address
164-
) external returns (uint256) {
164+
) external pure returns (uint256) {
165165
revert("NOT_IMPLEMENTED");
166166
}
167167

contracts/src/mocks/Simple.sol

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ contract Simple {
4343
return block.number;
4444
}
4545

46+
function getBlockDifficulty() external view returns (uint256) {
47+
return block.difficulty;
48+
}
49+
4650
function noop() external pure {}
4751

4852
function pleaseRevert() external pure {
@@ -113,7 +117,9 @@ contract Simple {
113117

114118
function checkGasUsed(address to, bytes calldata input) external view returns (uint256) {
115119
uint256 before = gasleft();
116-
to.staticcall{gas: before - 10000}(input);
120+
// The inner call may revert, but we still want to return the amount of gas used,
121+
// so we ignore the result of this call.
122+
(to.staticcall{gas: before - 10000}(input));
117123
return before - gasleft();
118124
}
119125
}

contracts/src/node-interface/NodeInterface.sol

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,10 @@ interface NodeInterface {
9898
/**
9999
* @notice Estimates a transaction's l1 costs.
100100
* @dev Use eth_call to call.
101-
* This method is exactly like gasEstimateComponents, but doesn't include the l2 component
101+
* This method is similar to gasEstimateComponents, but doesn't include the l2 component
102102
* so that the l1 component can be known even when the tx may fail.
103+
* This method also doesn't pad the estimate as gas estimation normally does.
104+
* If using this value to submit a transaction, we'd recommend first padding it by 10%.
103105
* @param data the tx's calldata. Everything else like "From" and "Gas" are copied over
104106
* @param to the tx's "To" (ignored when contractCreation is true)
105107
* @param contractCreation whether "To" is omitted

contracts/src/osp/IOneStepProver.sol

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ pragma solidity ^0.8.0;
77
import "../state/Machine.sol";
88
import "../state/Module.sol";
99
import "../state/Instructions.sol";
10+
import "../state/GlobalState.sol";
1011
import "../bridge/ISequencerInbox.sol";
1112
import "../bridge/IBridge.sol";
1213

contracts/src/osp/OneStepProverHostIo.sol

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ pragma solidity ^0.8.0;
77
import "../state/Value.sol";
88
import "../state/Machine.sol";
99
import "../state/Deserialize.sol";
10+
import "../state/ModuleMemory.sol";
1011
import "./IOneStepProver.sol";
1112
import "../bridge/Messages.sol";
1213
import "../bridge/IBridge.sol";

contracts/src/osp/OneStepProverMemory.sol

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ pragma solidity ^0.8.0;
77
import "../state/Value.sol";
88
import "../state/Machine.sol";
99
import "../state/Deserialize.sol";
10+
import "../state/ModuleMemory.sol";
1011
import "./IOneStepProver.sol";
1112

1213
contract OneStepProverMemory is IOneStepProver {

contracts/src/precompiles/ArbOwner.sol

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ interface ArbOwner {
8484
/// @notice Releases surplus funds from L1PricerFundsPoolAddress for use
8585
function releaseL1PricerSurplusFunds(uint256 maxWeiToRelease) external returns (uint256);
8686

87+
/// @notice Sets serialized chain config in ArbOS state
88+
function setChainConfig(string calldata chainConfig) external;
89+
8790
// Emitted when a successful call is made to this precompile
8891
event OwnerActs(bytes4 indexed method, address indexed owner, bytes data);
8992
}

contracts/src/rollup/Config.sol

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Copyright 2021-2022, Offchain Labs, Inc.
2+
// For license information, see https://github.com/nitro/blob/master/LICENSE
3+
// SPDX-License-Identifier: BUSL-1.1
4+
5+
pragma solidity ^0.8.0;
6+
7+
import "../state/GlobalState.sol";
8+
import "../state/Machine.sol";
9+
import "../bridge/ISequencerInbox.sol";
10+
import "../bridge/IBridge.sol";
11+
import "../bridge/IOutbox.sol";
12+
import "../bridge/IInbox.sol";
13+
import "./IRollupEventInbox.sol";
14+
import "./IRollupLogic.sol";
15+
import "../challenge/IChallengeManager.sol";
16+
17+
struct Config {
18+
uint64 confirmPeriodBlocks;
19+
uint64 extraChallengeTimeBlocks;
20+
address stakeToken;
21+
uint256 baseStake;
22+
bytes32 wasmModuleRoot;
23+
address owner;
24+
address loserStakeEscrow;
25+
uint256 chainId;
26+
string chainConfig;
27+
uint64 genesisBlockNum;
28+
ISequencerInbox.MaxTimeVariation sequencerInboxMaxTimeVariation;
29+
}
30+
31+
struct ContractDependencies {
32+
IBridge bridge;
33+
ISequencerInbox sequencerInbox;
34+
IInbox inbox;
35+
IOutbox outbox;
36+
IRollupEventInbox rollupEventInbox;
37+
IChallengeManager challengeManager;
38+
address rollupAdminLogic;
39+
IRollupUser rollupUserLogic;
40+
// misc contracts that are useful when interacting with the rollup
41+
address validatorUtils;
42+
address validatorWalletCreator;
43+
}

contracts/src/rollup/IRollupAdmin.sol

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
// Copyright 2021-2022, Offchain Labs, Inc.
2+
// For license information, see https://github.com/nitro/blob/master/LICENSE
3+
// SPDX-License-Identifier: BUSL-1.1
4+
5+
pragma solidity ^0.8.0;
6+
7+
import "./IRollupCore.sol";
8+
import "../bridge/ISequencerInbox.sol";
9+
import "../bridge/IOutbox.sol";
10+
import "../bridge/IOwnable.sol";
11+
import "./Config.sol";
12+
13+
interface IRollupAdmin {
14+
event OwnerFunctionCalled(uint256 indexed id);
15+
16+
function initialize(Config calldata config, ContractDependencies calldata connectedContracts)
17+
external;
18+
19+
/**
20+
* @notice Add a contract authorized to put messages into this rollup's inbox
21+
* @param _outbox Outbox contract to add
22+
*/
23+
function setOutbox(IOutbox _outbox) external;
24+
25+
/**
26+
* @notice Disable an old outbox from interacting with the bridge
27+
* @param _outbox Outbox contract to remove
28+
*/
29+
function removeOldOutbox(address _outbox) external;
30+
31+
/**
32+
* @notice Enable or disable an inbox contract
33+
* @param _inbox Inbox contract to add or remove
34+
* @param _enabled New status of inbox
35+
*/
36+
function setDelayedInbox(address _inbox, bool _enabled) external;
37+
38+
/**
39+
* @notice Pause interaction with the rollup contract
40+
*/
41+
function pause() external;
42+
43+
/**
44+
* @notice Resume interaction with the rollup contract
45+
*/
46+
function resume() external;
47+
48+
/**
49+
* @notice Set the addresses of the validator whitelist
50+
* @dev It is expected that both arrays are same length, and validator at
51+
* position i corresponds to the value at position i
52+
* @param _validator addresses to set in the whitelist
53+
* @param _val value to set in the whitelist for corresponding address
54+
*/
55+
function setValidator(address[] memory _validator, bool[] memory _val) external;
56+
57+
/**
58+
* @notice Set a new owner address for the rollup proxy
59+
* @param newOwner address of new rollup owner
60+
*/
61+
function setOwner(address newOwner) external;
62+
63+
/**
64+
* @notice Set minimum assertion period for the rollup
65+
* @param newPeriod new minimum period for assertions
66+
*/
67+
function setMinimumAssertionPeriod(uint256 newPeriod) external;
68+
69+
/**
70+
* @notice Set number of blocks until a node is considered confirmed
71+
* @param newConfirmPeriod new number of blocks until a node is confirmed
72+
*/
73+
function setConfirmPeriodBlocks(uint64 newConfirmPeriod) external;
74+
75+
/**
76+
* @notice Set number of extra blocks after a challenge
77+
* @param newExtraTimeBlocks new number of blocks
78+
*/
79+
function setExtraChallengeTimeBlocks(uint64 newExtraTimeBlocks) external;
80+
81+
/**
82+
* @notice Set base stake required for an assertion
83+
* @param newBaseStake maximum avmgas to be used per block
84+
*/
85+
function setBaseStake(uint256 newBaseStake) external;
86+
87+
/**
88+
* @notice Set the token used for stake, where address(0) == eth
89+
* @dev Before changing the base stake token, you might need to change the
90+
* implementation of the Rollup User logic!
91+
* @param newStakeToken address of token used for staking
92+
*/
93+
function setStakeToken(address newStakeToken) external;
94+
95+
/**
96+
* @notice Upgrades the implementation of a beacon controlled by the rollup
97+
* @param beacon address of beacon to be upgraded
98+
* @param newImplementation new address of implementation
99+
*/
100+
function upgradeBeacon(address beacon, address newImplementation) external;
101+
102+
function forceResolveChallenge(address[] memory stackerA, address[] memory stackerB) external;
103+
104+
function forceRefundStaker(address[] memory stacker) external;
105+
106+
function forceCreateNode(
107+
uint64 prevNode,
108+
uint256 prevNodeInboxMaxCount,
109+
Assertion memory assertion,
110+
bytes32 expectedNodeHash
111+
) external;
112+
113+
function forceConfirmNode(
114+
uint64 nodeNum,
115+
bytes32 blockHash,
116+
bytes32 sendRoot
117+
) external;
118+
119+
function setLoserStakeEscrow(address newLoserStakerEscrow) external;
120+
121+
/**
122+
* @notice Set the proving WASM module root
123+
* @param newWasmModuleRoot new module root
124+
*/
125+
function setWasmModuleRoot(bytes32 newWasmModuleRoot) external;
126+
127+
/**
128+
* @notice set a new sequencer inbox contract
129+
* @param _sequencerInbox new address of sequencer inbox
130+
*/
131+
function setSequencerInbox(address _sequencerInbox) external;
132+
133+
/**
134+
* @notice set the validatorWhitelistDisabled flag
135+
* @param _validatorWhitelistDisabled new value of validatorWhitelistDisabled, i.e. true = disabled
136+
*/
137+
function setValidatorWhitelistDisabled(bool _validatorWhitelistDisabled) external;
138+
}

contracts/src/rollup/IRollupCore.sol

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55
pragma solidity ^0.8.0;
66

77
import "./Node.sol";
8-
import "./RollupLib.sol";
8+
import "../bridge/IBridge.sol";
9+
import "../bridge/IOutbox.sol";
10+
import "../bridge/IInbox.sol";
11+
import "./IRollupEventInbox.sol";
12+
import "../challenge/IChallengeManager.sol";
913

1014
interface IRollupCore {
1115
struct Staker {
@@ -24,7 +28,7 @@ interface IRollupCore {
2428
bytes32 indexed parentNodeHash,
2529
bytes32 indexed nodeHash,
2630
bytes32 executionHash,
27-
RollupLib.Assertion assertion,
31+
Assertion assertion,
2832
bytes32 afterInboxBatchAcc,
2933
bytes32 wasmModuleRoot,
3034
uint256 inboxMaxCount
@@ -84,6 +88,15 @@ interface IRollupCore {
8488
*/
8589
function getNode(uint64 nodeNum) external view returns (Node memory);
8690

91+
/**
92+
* @notice Returns the block in which the given node was created for looking up its creation event.
93+
* Unlike the Node's createdAtBlock field, this will be the ArbSys blockNumber if the host chain is an Arbitrum chain.
94+
* That means that the block number returned for this is usable for event queries.
95+
* This function will revert if the given node number does not exist.
96+
* @dev This function is meant for internal use only and has no stability guarantees.
97+
*/
98+
function getNodeCreationBlockForLogLookup(uint64 nodeNum) external view returns (uint256);
99+
87100
/**
88101
* @notice Check if the specified node has been staked on by the provided staker.
89102
* Only accurate at the latest confirmed node and afterwards.

contracts/src/rollup/IRollupEventInbox.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ interface IRollupEventInbox {
1313

1414
function rollup() external view returns (address);
1515

16-
function rollupInitialized(uint256 chainId) external;
16+
function rollupInitialized(uint256 chainId, string calldata chainConfig) external;
1717
}

0 commit comments

Comments
 (0)