@arbitrum/nitro-contracts 1.0.0-beta.1
Sign up to get free protection for your applications and to get access to all the features.
- package/.prettierrc +5 -0
- package/.solhint.json +18 -0
- package/deploy/BridgeStubCreator.js +10 -0
- package/deploy/HashProofHelper.js +13 -0
- package/deploy/InboxStubCreator.js +17 -0
- package/deploy/OneStepProofEntryCreator.js +19 -0
- package/deploy/OneStepProver0Creator.js +14 -0
- package/deploy/OneStepProverHostIoCreator.js +14 -0
- package/deploy/OneStepProverMathCreator.js +14 -0
- package/deploy/OneStepProverMemoryCreator.js +14 -0
- package/deploy/SequencerInboxStubCreator.js +13 -0
- package/deploy/ValueArrayTesterCreator.js +13 -0
- package/hardhat.config.ts +47 -0
- package/hardhat.prod-config.js +18 -0
- package/package.json +49 -0
- package/scripts/build.bash +5 -0
- package/src/bridge/Bridge.sol +168 -0
- package/src/bridge/IBridge.sol +68 -0
- package/src/bridge/IInbox.sol +80 -0
- package/src/bridge/IMessageProvider.sol +11 -0
- package/src/bridge/IOutbox.sol +52 -0
- package/src/bridge/ISequencerInbox.sol +85 -0
- package/src/bridge/Inbox.sol +414 -0
- package/src/bridge/Messages.sol +38 -0
- package/src/bridge/Outbox.sol +188 -0
- package/src/bridge/SequencerInbox.sol +274 -0
- package/src/challenge/ChallengeLib.sol +135 -0
- package/src/challenge/ChallengeManager.sol +367 -0
- package/src/challenge/IChallengeManager.sol +75 -0
- package/src/challenge/IChallengeResultReceiver.sol +13 -0
- package/src/libraries/AddressAliasHelper.sol +29 -0
- package/src/libraries/AdminFallbackProxy.sol +153 -0
- package/src/libraries/ArbitrumProxy.sol +20 -0
- package/src/libraries/Constants.sol +10 -0
- package/src/libraries/CryptographyPrimitives.sol +323 -0
- package/src/libraries/DelegateCallAware.sol +44 -0
- package/src/libraries/Error.sol +38 -0
- package/src/libraries/IGasRefunder.sol +35 -0
- package/src/libraries/MerkleLib.sol +46 -0
- package/src/libraries/MessageTypes.sol +14 -0
- package/src/libraries/SecondaryLogicUUPSUpgradeable.sol +58 -0
- package/src/libraries/UUPSNotUpgradeable.sol +56 -0
- package/src/mocks/BridgeStub.sol +115 -0
- package/src/mocks/Counter.sol +13 -0
- package/src/mocks/ExecutionManager.sol +41 -0
- package/src/mocks/InboxStub.sol +131 -0
- package/src/mocks/MockResultReceiver.sol +59 -0
- package/src/mocks/SequencerInboxStub.sol +42 -0
- package/src/mocks/SimpleProxy.sol +19 -0
- package/src/node-interface/NodeInterface.sol +50 -0
- package/src/osp/HashProofHelper.sol +154 -0
- package/src/osp/IOneStepProofEntry.sol +20 -0
- package/src/osp/IOneStepProver.sol +27 -0
- package/src/osp/OneStepProofEntry.sol +129 -0
- package/src/osp/OneStepProver0.sol +566 -0
- package/src/osp/OneStepProverHostIo.sol +357 -0
- package/src/osp/OneStepProverMath.sol +514 -0
- package/src/osp/OneStepProverMemory.sol +313 -0
- package/src/precompiles/ArbAddressTable.sol +60 -0
- package/src/precompiles/ArbAggregator.sol +62 -0
- package/src/precompiles/ArbBLS.sol +53 -0
- package/src/precompiles/ArbDebug.sol +39 -0
- package/src/precompiles/ArbFunctionTable.sol +29 -0
- package/src/precompiles/ArbGasInfo.sol +121 -0
- package/src/precompiles/ArbInfo.sol +15 -0
- package/src/precompiles/ArbOwner.sol +65 -0
- package/src/precompiles/ArbOwnerPublic.sol +18 -0
- package/src/precompiles/ArbRetryableTx.sol +89 -0
- package/src/precompiles/ArbStatistics.sol +29 -0
- package/src/precompiles/ArbSys.sol +134 -0
- package/src/precompiles/ArbosActs.sol +41 -0
- package/src/precompiles/ArbosTest.sol +14 -0
- package/src/rollup/BridgeCreator.sol +120 -0
- package/src/rollup/IRollupCore.sol +152 -0
- package/src/rollup/IRollupLogic.sol +183 -0
- package/src/rollup/Node.sol +99 -0
- package/src/rollup/RollupAdminLogic.sol +322 -0
- package/src/rollup/RollupCore.sol +627 -0
- package/src/rollup/RollupCreator.sol +133 -0
- package/src/rollup/RollupEventBridge.sol +46 -0
- package/src/rollup/RollupLib.sol +135 -0
- package/src/rollup/RollupUserLogic.sol +712 -0
- package/src/rollup/ValidatorUtils.sol +243 -0
- package/src/rollup/ValidatorWallet.sol +76 -0
- package/src/rollup/ValidatorWalletCreator.sol +43 -0
- package/src/state/Deserialize.sol +321 -0
- package/src/state/GlobalState.sol +44 -0
- package/src/state/Instructions.sol +159 -0
- package/src/state/Machine.sol +65 -0
- package/src/state/MerkleProof.sol +99 -0
- package/src/state/Module.sol +33 -0
- package/src/state/ModuleMemory.sol +42 -0
- package/src/state/PcArray.sol +45 -0
- package/src/state/PcStack.sol +32 -0
- package/src/state/StackFrame.sol +63 -0
- package/src/state/Value.sol +65 -0
- package/src/state/ValueArray.sol +47 -0
- package/src/state/ValueStack.sol +39 -0
- package/src/test-helpers/CryptographyPrimitivesTester.sol +27 -0
- package/src/test-helpers/MessageTester.sol +34 -0
- package/src/test-helpers/ValueArrayTester.sol +34 -0
- package/test/contract/arbRollup.spec.ts +869 -0
- package/test/contract/common/challengeLib.ts +43 -0
- package/test/contract/common/globalStateLib.ts +17 -0
- package/test/contract/common/rolluplib.ts +259 -0
- package/test/contract/cryptographyPrimitives.spec.ts +82 -0
- package/test/contract/sequencerInboxForceInclude.spec.ts +516 -0
- package/test/contract/utils.ts +40 -0
- package/test/prover/hash-proofs.ts +75 -0
- package/test/prover/one-step-proof.ts +93 -0
- package/test/prover/proofs/.gitkeep +0 -0
- package/test/prover/value-arrays.ts +11 -0
- package/tsconfig.json +13 -0
@@ -0,0 +1,15 @@
|
|
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.4.21 <0.9.0;
|
6
|
+
|
7
|
+
/// @title Lookup for basic info about accounts and contracts.
|
8
|
+
/// @notice Precompiled contract that exists in every Arbitrum chain at 0x0000000000000000000000000000000000000065.
|
9
|
+
interface ArbInfo {
|
10
|
+
/// @notice Retrieves an account's balance
|
11
|
+
function getBalance(address account) external view returns (uint256);
|
12
|
+
|
13
|
+
/// @notice Retrieves a contract's deployed code
|
14
|
+
function getCode(address account) external view returns (bytes memory);
|
15
|
+
}
|
@@ -0,0 +1,65 @@
|
|
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.4.21 <0.9.0;
|
6
|
+
|
7
|
+
/// @title Provides owners with tools for managing the rollup.
|
8
|
+
/// @notice Calls by non-owners will always revert.
|
9
|
+
/// Most of Arbitrum Classic's owner methods have been removed since they no longer make sense in Nitro:
|
10
|
+
/// - What were once chain parameters are now parts of ArbOS's state, and those that remain are set at genesis.
|
11
|
+
/// - ArbOS upgrades happen with the rest of the system rather than being independent
|
12
|
+
/// - Exemptions to address aliasing are no longer offered. Exemptions were intended to support backward compatibility for contracts deployed before aliasing was introduced, but no exemptions were ever requested.
|
13
|
+
/// Precompiled contract that exists in every Arbitrum chain at 0x0000000000000000000000000000000000000070.
|
14
|
+
interface ArbOwner {
|
15
|
+
/// @notice Add account as a chain owner
|
16
|
+
function addChainOwner(address newOwner) external;
|
17
|
+
|
18
|
+
/// @notice Remove account from the list of chain owners
|
19
|
+
function removeChainOwner(address ownerToRemove) external;
|
20
|
+
|
21
|
+
/// @notice See if the user is a chain owner
|
22
|
+
function isChainOwner(address addr) external view returns (bool);
|
23
|
+
|
24
|
+
/// @notice Retrieves the list of chain owners
|
25
|
+
function getAllChainOwners() external view returns (address[] memory);
|
26
|
+
|
27
|
+
/// @notice Set the L1 basefee estimate directly, bypassing the autoregression
|
28
|
+
function setL1BaseFeeEstimate(uint256 priceInWei) external;
|
29
|
+
|
30
|
+
/// @notice Set how slowly ArbOS updates its estimate of the L1 basefee
|
31
|
+
function setL1BaseFeeEstimateInertia(uint64 inertia) external;
|
32
|
+
|
33
|
+
/// @notice Set the L2 basefee directly, bypassing the pool calculus
|
34
|
+
function setL2BaseFee(uint256 priceInWei) external;
|
35
|
+
|
36
|
+
/// @notice Set the minimum basefee needed for a transaction to succeed
|
37
|
+
function setMinimumL2BaseFee(uint256 priceInWei) external;
|
38
|
+
|
39
|
+
/// @notice Set the computational speed limit for the chain
|
40
|
+
function setSpeedLimit(uint64 limit) external;
|
41
|
+
|
42
|
+
/// @notice Set the number of seconds worth of the speed limit the gas pool contains
|
43
|
+
function setGasPoolSeconds(uint64 factor) external;
|
44
|
+
|
45
|
+
/// @notice Set the target fullness in bips the pricing model will try to keep the pool at
|
46
|
+
function setGasPoolTarget(uint64 target) external;
|
47
|
+
|
48
|
+
/// @notice Set the extent in bips to which the pricing model favors filling the pool over increasing speeds
|
49
|
+
function setGasPoolWeight(uint64 weight) external;
|
50
|
+
|
51
|
+
/// @notice Set how slowly ArbOS updates its estimate the amount of gas being burnt per second
|
52
|
+
function setRateEstimateInertia(uint64 inertia) external;
|
53
|
+
|
54
|
+
/// @notice Set the maximum size a tx (and block) can be
|
55
|
+
function setMaxTxGasLimit(uint64 limit) external;
|
56
|
+
|
57
|
+
/// @notice Get the network fee collector
|
58
|
+
function getNetworkFeeAccount() external view returns (address);
|
59
|
+
|
60
|
+
/// @notice Set the network fee collector
|
61
|
+
function setNetworkFeeAccount(address newNetworkFeeAccount) external;
|
62
|
+
|
63
|
+
// Emitted when a successful call is made to this precompile
|
64
|
+
event OwnerActs(bytes4 indexed method, address indexed owner, bytes data);
|
65
|
+
}
|
@@ -0,0 +1,18 @@
|
|
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.4.21 <0.9.0;
|
6
|
+
|
7
|
+
/// @title Provides non-owners with info about the current chain owners.
|
8
|
+
/// @notice Precompiled contract that exists in every Arbitrum chain at 0x000000000000000000000000000000000000006b.
|
9
|
+
interface ArbOwnerPublic {
|
10
|
+
/// @notice See if the user is a chain owner
|
11
|
+
function isChainOwner(address addr) external view returns (bool);
|
12
|
+
|
13
|
+
/// @notice Retrieves the list of chain owners
|
14
|
+
function getAllChainOwners() external view returns (address[] memory);
|
15
|
+
|
16
|
+
/// @notice Gets the network fee collector
|
17
|
+
function getNetworkFeeAccount() external view returns (address);
|
18
|
+
}
|
@@ -0,0 +1,89 @@
|
|
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.4.21 <0.9.0;
|
6
|
+
|
7
|
+
/**
|
8
|
+
* @title Methods for managing retryables.
|
9
|
+
* @notice Precompiled contract in every Arbitrum chain for retryable transaction related data retrieval and interactions. Exists at 0x000000000000000000000000000000000000006e
|
10
|
+
*/
|
11
|
+
interface ArbRetryableTx {
|
12
|
+
/**
|
13
|
+
* @notice Schedule an attempt to redeem a redeemable tx, donating all of the call's gas to the redeem.
|
14
|
+
* Revert if ticketId does not exist.
|
15
|
+
* @param ticketId unique identifier of retryable message: keccak256(keccak256(ArbchainId, inbox-sequence-number), uint(0) )
|
16
|
+
* @return txId that the redeem attempt will have
|
17
|
+
*/
|
18
|
+
function redeem(bytes32 ticketId) external returns (bytes32);
|
19
|
+
|
20
|
+
/**
|
21
|
+
* @notice Return the minimum lifetime of redeemable txn.
|
22
|
+
* @return lifetime in seconds
|
23
|
+
*/
|
24
|
+
function getLifetime() external view returns (uint256);
|
25
|
+
|
26
|
+
/**
|
27
|
+
* @notice Return the timestamp when ticketId will age out, reverting if it does not exist
|
28
|
+
* @param ticketId unique ticket identifier
|
29
|
+
* @return timestamp for ticket's deadline
|
30
|
+
*/
|
31
|
+
function getTimeout(bytes32 ticketId) external view returns (uint256);
|
32
|
+
|
33
|
+
/**
|
34
|
+
* @notice Adds one lifetime period to the life of ticketId.
|
35
|
+
* Donate gas to pay for the lifetime extension.
|
36
|
+
* If successful, emits LifetimeExtended event.
|
37
|
+
* Revert if ticketId does not exist, or if the timeout of ticketId is already at least one lifetime period in the future.
|
38
|
+
* @param ticketId unique ticket identifier
|
39
|
+
* @return new timeout of ticketId
|
40
|
+
*/
|
41
|
+
function keepalive(bytes32 ticketId) external returns (uint256);
|
42
|
+
|
43
|
+
/**
|
44
|
+
* @notice Return the beneficiary of ticketId.
|
45
|
+
* Revert if ticketId doesn't exist.
|
46
|
+
* @param ticketId unique ticket identifier
|
47
|
+
* @return address of beneficiary for ticket
|
48
|
+
*/
|
49
|
+
function getBeneficiary(bytes32 ticketId) external view returns (address);
|
50
|
+
|
51
|
+
/**
|
52
|
+
* @notice Cancel ticketId and refund its callvalue to its beneficiary.
|
53
|
+
* Revert if ticketId doesn't exist, or if called by anyone other than ticketId's beneficiary.
|
54
|
+
* @param ticketId unique ticket identifier
|
55
|
+
*/
|
56
|
+
function cancel(bytes32 ticketId) external;
|
57
|
+
|
58
|
+
/**
|
59
|
+
* @notice Do not call. This method represents a retryable submission to aid explorers.
|
60
|
+
* Calling it will always revert.
|
61
|
+
*/
|
62
|
+
function submitRetryable(
|
63
|
+
bytes32 requestId,
|
64
|
+
uint256 l1BaseFee,
|
65
|
+
uint256 deposit,
|
66
|
+
uint256 callvalue,
|
67
|
+
uint256 gasFeeCap,
|
68
|
+
uint64 gasLimit,
|
69
|
+
uint256 maxSubmissionFee,
|
70
|
+
address feeRefundAddress,
|
71
|
+
address beneficiary,
|
72
|
+
address retryTo,
|
73
|
+
bytes calldata retryData
|
74
|
+
) external;
|
75
|
+
|
76
|
+
event TicketCreated(bytes32 indexed ticketId);
|
77
|
+
event LifetimeExtended(bytes32 indexed ticketId, uint256 newTimeout);
|
78
|
+
event RedeemScheduled(
|
79
|
+
bytes32 indexed ticketId,
|
80
|
+
bytes32 indexed retryTxHash,
|
81
|
+
uint64 indexed sequenceNum,
|
82
|
+
uint64 donatedGas,
|
83
|
+
address gasDonor
|
84
|
+
);
|
85
|
+
event Canceled(bytes32 indexed ticketId);
|
86
|
+
|
87
|
+
error NoTicketWithID();
|
88
|
+
error NotCallable();
|
89
|
+
}
|
@@ -0,0 +1,29 @@
|
|
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.4.21 <0.9.0;
|
6
|
+
|
7
|
+
/// @title Deprecated - Info about the rollup just prior to the Nitro upgrade
|
8
|
+
/// @notice Precompiled contract in every Arbitrum chain for retryable transaction related data retrieval and interactions. Exists at 0x000000000000000000000000000000000000006f
|
9
|
+
interface ArbStatistics {
|
10
|
+
/// @notice Get Arbitrum block number and other statistics as they were right before the Nitro upgrade.
|
11
|
+
/// @return (
|
12
|
+
/// Number of accounts,
|
13
|
+
/// Total storage allocated (includes storage that was later deallocated),
|
14
|
+
/// Total ArbGas used,
|
15
|
+
/// Number of transaction receipt issued,
|
16
|
+
/// Number of contracts created,
|
17
|
+
/// )
|
18
|
+
function getStats()
|
19
|
+
external
|
20
|
+
view
|
21
|
+
returns (
|
22
|
+
uint256,
|
23
|
+
uint256,
|
24
|
+
uint256,
|
25
|
+
uint256,
|
26
|
+
uint256,
|
27
|
+
uint256
|
28
|
+
);
|
29
|
+
}
|
@@ -0,0 +1,134 @@
|
|
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.4.21 <0.9.0;
|
6
|
+
|
7
|
+
/**
|
8
|
+
* @title System level functionality
|
9
|
+
* @notice For use by contracts to interact with core L2-specific functionality.
|
10
|
+
* Precompiled contract that exists in every Arbitrum chain at address(100), 0x0000000000000000000000000000000000000064.
|
11
|
+
*/
|
12
|
+
interface ArbSys {
|
13
|
+
/**
|
14
|
+
* @notice Get Arbitrum block number (distinct from L1 block number; Arbitrum genesis block has block number 0)
|
15
|
+
* @return block number as int
|
16
|
+
*/
|
17
|
+
function arbBlockNumber() external view returns (uint256);
|
18
|
+
|
19
|
+
/**
|
20
|
+
* @notice Get Arbitrum block hash (reverts unless currentBlockNum-256 <= arbBlockNum < currentBlockNum)
|
21
|
+
* @return block hash
|
22
|
+
*/
|
23
|
+
function arbBlockHash(uint256 arbBlockNum) external view returns (bytes32);
|
24
|
+
|
25
|
+
/**
|
26
|
+
* @notice Gets the rollup's unique chain identifier
|
27
|
+
* @return Chain identifier as int
|
28
|
+
*/
|
29
|
+
function arbChainID() external view returns (uint256);
|
30
|
+
|
31
|
+
/**
|
32
|
+
* @notice Get internal version number identifying an ArbOS build
|
33
|
+
* @return version number as int
|
34
|
+
*/
|
35
|
+
function arbOSVersion() external view returns (uint256);
|
36
|
+
|
37
|
+
/**
|
38
|
+
* @notice Returns 0 since Nitro has no concept of storage gas
|
39
|
+
* @return int 0
|
40
|
+
*/
|
41
|
+
function getStorageGasAvailable() external returns (uint256);
|
42
|
+
|
43
|
+
/**
|
44
|
+
* @notice check if current call is coming from l1
|
45
|
+
* @return true if the caller of this was called directly from L1
|
46
|
+
*/
|
47
|
+
function isTopLevelCall() external view returns (bool);
|
48
|
+
|
49
|
+
/**
|
50
|
+
* @notice map L1 sender contract address to its L2 alias
|
51
|
+
* @param sender sender address
|
52
|
+
* @param unused argument no longer used
|
53
|
+
* @return aliased sender address
|
54
|
+
*/
|
55
|
+
function mapL1SenderContractAddressToL2Alias(address sender, address unused)
|
56
|
+
external
|
57
|
+
pure
|
58
|
+
returns (address);
|
59
|
+
|
60
|
+
/**
|
61
|
+
* @notice check if the caller (of this caller of this) is an aliased L1 contract address
|
62
|
+
* @return true iff the caller's address is an alias for an L1 contract address
|
63
|
+
*/
|
64
|
+
function wasMyCallersAddressAliased() external view returns (bool);
|
65
|
+
|
66
|
+
/**
|
67
|
+
* @notice return the address of the caller (of this caller of this), without applying L1 contract address aliasing
|
68
|
+
* @return address of the caller's caller, without applying L1 contract address aliasing
|
69
|
+
*/
|
70
|
+
function myCallersAddressWithoutAliasing() external view returns (address);
|
71
|
+
|
72
|
+
/**
|
73
|
+
* @notice Send given amount of Eth to dest from sender.
|
74
|
+
* This is a convenience function, which is equivalent to calling sendTxToL1 with empty data.
|
75
|
+
* @param destination recipient address on L1
|
76
|
+
* @return unique identifier for this L2-to-L1 transaction.
|
77
|
+
*/
|
78
|
+
function withdrawEth(address destination) external payable returns (uint256);
|
79
|
+
|
80
|
+
/**
|
81
|
+
* @notice Send a transaction to L1
|
82
|
+
* @param destination recipient address on L1
|
83
|
+
* @param data (optional) calldata for L1 contract call
|
84
|
+
* @return a unique identifier for this L2-to-L1 transaction.
|
85
|
+
*/
|
86
|
+
function sendTxToL1(address destination, bytes calldata data)
|
87
|
+
external
|
88
|
+
payable
|
89
|
+
returns (uint256);
|
90
|
+
|
91
|
+
/**
|
92
|
+
* @notice Get send Merkle tree state
|
93
|
+
* @return size number of sends in the history
|
94
|
+
* @return root root hash of the send history
|
95
|
+
* @return partials hashes of partial subtrees in the send history tree
|
96
|
+
*/
|
97
|
+
function sendMerkleTreeState()
|
98
|
+
external
|
99
|
+
view
|
100
|
+
returns (
|
101
|
+
uint256 size,
|
102
|
+
bytes32 root,
|
103
|
+
bytes32[] memory partials
|
104
|
+
);
|
105
|
+
|
106
|
+
/**
|
107
|
+
* @notice creates a send txn from L2 to L1
|
108
|
+
* @param position = (level << 192) + leaf = (0 << 192) + leaf = leaf
|
109
|
+
*/
|
110
|
+
event L2ToL1Transaction(
|
111
|
+
address caller,
|
112
|
+
address indexed destination,
|
113
|
+
uint256 indexed hash,
|
114
|
+
uint256 indexed position,
|
115
|
+
uint256 indexInBatch,
|
116
|
+
uint256 arbBlockNum,
|
117
|
+
uint256 ethBlockNum,
|
118
|
+
uint256 timestamp,
|
119
|
+
uint256 callvalue,
|
120
|
+
bytes data
|
121
|
+
);
|
122
|
+
|
123
|
+
/**
|
124
|
+
* @notice logs a merkle branch for proof sythesis
|
125
|
+
* @param reserved an index meant only to align the 4th index with L2ToL1Transaction's 4th event
|
126
|
+
* @param hash the merkle hash
|
127
|
+
* @param position = (level << 192) + leaf
|
128
|
+
*/
|
129
|
+
event SendMerkleUpdate(
|
130
|
+
uint256 indexed reserved,
|
131
|
+
bytes32 indexed hash,
|
132
|
+
uint256 indexed position
|
133
|
+
);
|
134
|
+
}
|
@@ -0,0 +1,41 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
|
3
|
+
/*
|
4
|
+
* Copyright 2020, Offchain Labs, Inc.
|
5
|
+
*
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
* you may not use this file except in compliance with the License.
|
8
|
+
* You may obtain a copy of the License at
|
9
|
+
*
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
*
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
* See the License for the specific language governing permissions and
|
16
|
+
* limitations under the License.
|
17
|
+
*/
|
18
|
+
|
19
|
+
pragma solidity >=0.4.21 <0.9.0;
|
20
|
+
|
21
|
+
/**
|
22
|
+
* @title This precompile represents ArbOS's internal actions as calls it makes to itself
|
23
|
+
* @notice Calling this precompile will always revert and should not be done.
|
24
|
+
*/
|
25
|
+
interface ArbosActs {
|
26
|
+
/**
|
27
|
+
* @notice ArbOS "calls" this when starting a block
|
28
|
+
* @param l1BaseFee the L1 BaseFee
|
29
|
+
* @param l2BaseFeeLastBlock the L2 BaseFee in the last block's header
|
30
|
+
* @param l1BlockNumber the L1 block number
|
31
|
+
* @param timePassed number of seconds since the last block
|
32
|
+
*/
|
33
|
+
function startBlock(
|
34
|
+
uint256 l1BaseFee,
|
35
|
+
uint256 l2BaseFeeLastBlock,
|
36
|
+
uint64 l1BlockNumber,
|
37
|
+
uint64 timePassed
|
38
|
+
) external;
|
39
|
+
|
40
|
+
error CallerNotArbOS();
|
41
|
+
}
|
@@ -0,0 +1,14 @@
|
|
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.4.21 <0.9.0;
|
6
|
+
|
7
|
+
/// @title Deprecated - Provides a method of burning arbitrary amounts of gas,
|
8
|
+
/// @notice This exists for historical reasons. Pre-Nitro, `ArbosTest` had additional methods only the zero address could call.
|
9
|
+
/// These have been removed since users don't use them and calls to missing methods revert.
|
10
|
+
/// Precompiled contract that exists in every Arbitrum chain at 0x0000000000000000000000000000000000000069.
|
11
|
+
interface ArbosTest {
|
12
|
+
/// @notice Unproductively burns the amount of L2 ArbGas
|
13
|
+
function burnArbGas(uint256 gasAmount) external pure;
|
14
|
+
}
|
@@ -0,0 +1,120 @@
|
|
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 "../bridge/Bridge.sol";
|
8
|
+
import "../bridge/SequencerInbox.sol";
|
9
|
+
import "../bridge/ISequencerInbox.sol";
|
10
|
+
import "../bridge/Inbox.sol";
|
11
|
+
import "../bridge/Outbox.sol";
|
12
|
+
import "./RollupEventBridge.sol";
|
13
|
+
|
14
|
+
import "../bridge/IBridge.sol";
|
15
|
+
import "@openzeppelin/contracts/access/Ownable.sol";
|
16
|
+
import "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol";
|
17
|
+
|
18
|
+
contract BridgeCreator is Ownable {
|
19
|
+
Bridge public delayedBridgeTemplate;
|
20
|
+
SequencerInbox public sequencerInboxTemplate;
|
21
|
+
Inbox public inboxTemplate;
|
22
|
+
RollupEventBridge public rollupEventBridgeTemplate;
|
23
|
+
Outbox public outboxTemplate;
|
24
|
+
|
25
|
+
event TemplatesUpdated();
|
26
|
+
|
27
|
+
constructor() Ownable() {
|
28
|
+
delayedBridgeTemplate = new Bridge();
|
29
|
+
sequencerInboxTemplate = new SequencerInbox();
|
30
|
+
inboxTemplate = new Inbox();
|
31
|
+
rollupEventBridgeTemplate = new RollupEventBridge();
|
32
|
+
outboxTemplate = new Outbox();
|
33
|
+
}
|
34
|
+
|
35
|
+
function updateTemplates(
|
36
|
+
address _delayedBridgeTemplate,
|
37
|
+
address _sequencerInboxTemplate,
|
38
|
+
address _inboxTemplate,
|
39
|
+
address _rollupEventBridgeTemplate,
|
40
|
+
address _outboxTemplate
|
41
|
+
) external onlyOwner {
|
42
|
+
delayedBridgeTemplate = Bridge(_delayedBridgeTemplate);
|
43
|
+
sequencerInboxTemplate = SequencerInbox(_sequencerInboxTemplate);
|
44
|
+
inboxTemplate = Inbox(_inboxTemplate);
|
45
|
+
rollupEventBridgeTemplate = RollupEventBridge(_rollupEventBridgeTemplate);
|
46
|
+
outboxTemplate = Outbox(_outboxTemplate);
|
47
|
+
|
48
|
+
emit TemplatesUpdated();
|
49
|
+
}
|
50
|
+
|
51
|
+
struct CreateBridgeFrame {
|
52
|
+
ProxyAdmin admin;
|
53
|
+
Bridge delayedBridge;
|
54
|
+
SequencerInbox sequencerInbox;
|
55
|
+
Inbox inbox;
|
56
|
+
RollupEventBridge rollupEventBridge;
|
57
|
+
Outbox outbox;
|
58
|
+
}
|
59
|
+
|
60
|
+
function createBridge(
|
61
|
+
address adminProxy,
|
62
|
+
address rollup,
|
63
|
+
ISequencerInbox.MaxTimeVariation memory maxTimeVariation
|
64
|
+
)
|
65
|
+
external
|
66
|
+
returns (
|
67
|
+
Bridge,
|
68
|
+
SequencerInbox,
|
69
|
+
Inbox,
|
70
|
+
RollupEventBridge,
|
71
|
+
Outbox
|
72
|
+
)
|
73
|
+
{
|
74
|
+
CreateBridgeFrame memory frame;
|
75
|
+
{
|
76
|
+
frame.delayedBridge = Bridge(
|
77
|
+
address(
|
78
|
+
new TransparentUpgradeableProxy(address(delayedBridgeTemplate), adminProxy, "")
|
79
|
+
)
|
80
|
+
);
|
81
|
+
frame.sequencerInbox = SequencerInbox(
|
82
|
+
address(
|
83
|
+
new TransparentUpgradeableProxy(address(sequencerInboxTemplate), adminProxy, "")
|
84
|
+
)
|
85
|
+
);
|
86
|
+
frame.inbox = Inbox(
|
87
|
+
address(new TransparentUpgradeableProxy(address(inboxTemplate), adminProxy, ""))
|
88
|
+
);
|
89
|
+
frame.rollupEventBridge = RollupEventBridge(
|
90
|
+
address(
|
91
|
+
new TransparentUpgradeableProxy(
|
92
|
+
address(rollupEventBridgeTemplate),
|
93
|
+
adminProxy,
|
94
|
+
""
|
95
|
+
)
|
96
|
+
)
|
97
|
+
);
|
98
|
+
frame.outbox = Outbox(
|
99
|
+
address(new TransparentUpgradeableProxy(address(outboxTemplate), adminProxy, ""))
|
100
|
+
);
|
101
|
+
}
|
102
|
+
|
103
|
+
frame.delayedBridge.initialize();
|
104
|
+
frame.sequencerInbox.initialize(IBridge(frame.delayedBridge), rollup, maxTimeVariation);
|
105
|
+
frame.inbox.initialize(IBridge(frame.delayedBridge));
|
106
|
+
frame.rollupEventBridge.initialize(address(frame.delayedBridge), rollup);
|
107
|
+
frame.outbox.initialize(rollup, IBridge(frame.delayedBridge));
|
108
|
+
|
109
|
+
frame.delayedBridge.setInbox(address(frame.inbox), true);
|
110
|
+
frame.delayedBridge.transferOwnership(rollup);
|
111
|
+
|
112
|
+
return (
|
113
|
+
frame.delayedBridge,
|
114
|
+
frame.sequencerInbox,
|
115
|
+
frame.inbox,
|
116
|
+
frame.rollupEventBridge,
|
117
|
+
frame.outbox
|
118
|
+
);
|
119
|
+
}
|
120
|
+
}
|
@@ -0,0 +1,152 @@
|
|
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 "./Node.sol";
|
8
|
+
import "./RollupLib.sol";
|
9
|
+
|
10
|
+
import "../osp/IOneStepProofEntry.sol";
|
11
|
+
|
12
|
+
interface IRollupCore {
|
13
|
+
struct Staker {
|
14
|
+
uint256 amountStaked;
|
15
|
+
uint64 index;
|
16
|
+
uint64 latestStakedNode;
|
17
|
+
// currentChallenge is 0 if staker is not in a challenge
|
18
|
+
uint64 currentChallenge;
|
19
|
+
bool isStaked;
|
20
|
+
}
|
21
|
+
|
22
|
+
event RollupInitialized(bytes32 machineHash, uint256 chainId);
|
23
|
+
|
24
|
+
event NodeCreated(
|
25
|
+
uint64 indexed nodeNum,
|
26
|
+
bytes32 indexed parentNodeHash,
|
27
|
+
bytes32 indexed nodeHash,
|
28
|
+
bytes32 executionHash,
|
29
|
+
RollupLib.Assertion assertion,
|
30
|
+
bytes32 afterInboxBatchAcc,
|
31
|
+
bytes32 wasmModuleRoot,
|
32
|
+
uint256 inboxMaxCount
|
33
|
+
);
|
34
|
+
|
35
|
+
event NodeConfirmed(uint64 indexed nodeNum, bytes32 blockHash, bytes32 sendRoot);
|
36
|
+
|
37
|
+
event NodeRejected(uint64 indexed nodeNum);
|
38
|
+
|
39
|
+
event RollupChallengeStarted(
|
40
|
+
uint64 indexed challengeIndex,
|
41
|
+
address asserter,
|
42
|
+
address challenger,
|
43
|
+
uint64 challengedNode
|
44
|
+
);
|
45
|
+
|
46
|
+
event UserStakeUpdated(address indexed user, uint256 initialBalance, uint256 finalBalance);
|
47
|
+
|
48
|
+
event UserWithdrawableFundsUpdated(
|
49
|
+
address indexed user,
|
50
|
+
uint256 initialBalance,
|
51
|
+
uint256 finalBalance
|
52
|
+
);
|
53
|
+
|
54
|
+
function challengeManager() external view returns (IChallengeManager);
|
55
|
+
|
56
|
+
/**
|
57
|
+
* @notice Get the Node for the given index.
|
58
|
+
*/
|
59
|
+
function getNode(uint64 nodeNum) external view returns (Node memory);
|
60
|
+
|
61
|
+
/**
|
62
|
+
* @notice Check if the specified node has been staked on by the provided staker.
|
63
|
+
* Only accurate at the latest confirmed node and afterwards.
|
64
|
+
*/
|
65
|
+
function nodeHasStaker(uint64 nodeNum, address staker) external view returns (bool);
|
66
|
+
|
67
|
+
/**
|
68
|
+
* @notice Get the address of the staker at the given index
|
69
|
+
* @param stakerNum Index of the staker
|
70
|
+
* @return Address of the staker
|
71
|
+
*/
|
72
|
+
function getStakerAddress(uint64 stakerNum) external view returns (address);
|
73
|
+
|
74
|
+
/**
|
75
|
+
* @notice Check whether the given staker is staked
|
76
|
+
* @param staker Staker address to check
|
77
|
+
* @return True or False for whether the staker was staked
|
78
|
+
*/
|
79
|
+
function isStaked(address staker) external view returns (bool);
|
80
|
+
|
81
|
+
/**
|
82
|
+
* @notice Get the latest staked node of the given staker
|
83
|
+
* @param staker Staker address to lookup
|
84
|
+
* @return Latest node staked of the staker
|
85
|
+
*/
|
86
|
+
function latestStakedNode(address staker) external view returns (uint64);
|
87
|
+
|
88
|
+
/**
|
89
|
+
* @notice Get the current challenge of the given staker
|
90
|
+
* @param staker Staker address to lookup
|
91
|
+
* @return Current challenge of the staker
|
92
|
+
*/
|
93
|
+
function currentChallenge(address staker) external view returns (uint64);
|
94
|
+
|
95
|
+
/**
|
96
|
+
* @notice Get the amount staked of the given staker
|
97
|
+
* @param staker Staker address to lookup
|
98
|
+
* @return Amount staked of the staker
|
99
|
+
*/
|
100
|
+
function amountStaked(address staker) external view returns (uint256);
|
101
|
+
|
102
|
+
/**
|
103
|
+
* @notice Retrieves stored information about a requested staker
|
104
|
+
* @param staker Staker address to retrieve
|
105
|
+
* @return A structure with information about the requested staker
|
106
|
+
*/
|
107
|
+
function getStaker(address staker) external view returns (Staker memory);
|
108
|
+
|
109
|
+
/**
|
110
|
+
* @notice Get the original staker address of the zombie at the given index
|
111
|
+
* @param zombieNum Index of the zombie to lookup
|
112
|
+
* @return Original staker address of the zombie
|
113
|
+
*/
|
114
|
+
function zombieAddress(uint256 zombieNum) external view returns (address);
|
115
|
+
|
116
|
+
/**
|
117
|
+
* @notice Get Latest node that the given zombie at the given index is staked on
|
118
|
+
* @param zombieNum Index of the zombie to lookup
|
119
|
+
* @return Latest node that the given zombie is staked on
|
120
|
+
*/
|
121
|
+
function zombieLatestStakedNode(uint256 zombieNum) external view returns (uint64);
|
122
|
+
|
123
|
+
/// @return Current number of un-removed zombies
|
124
|
+
function zombieCount() external view returns (uint256);
|
125
|
+
|
126
|
+
function isZombie(address staker) external view returns (bool);
|
127
|
+
|
128
|
+
/**
|
129
|
+
* @notice Get the amount of funds withdrawable by the given address
|
130
|
+
* @param owner Address to check the funds of
|
131
|
+
* @return Amount of funds withdrawable by owner
|
132
|
+
*/
|
133
|
+
function withdrawableFunds(address owner) external view returns (uint256);
|
134
|
+
|
135
|
+
/**
|
136
|
+
* @return Index of the first unresolved node
|
137
|
+
* @dev If all nodes have been resolved, this will be latestNodeCreated + 1
|
138
|
+
*/
|
139
|
+
function firstUnresolvedNode() external view returns (uint64);
|
140
|
+
|
141
|
+
/// @return Index of the latest confirmed node
|
142
|
+
function latestConfirmed() external view returns (uint64);
|
143
|
+
|
144
|
+
/// @return Index of the latest rollup node created
|
145
|
+
function latestNodeCreated() external view returns (uint64);
|
146
|
+
|
147
|
+
/// @return Ethereum block that the most recent stake was created
|
148
|
+
function lastStakeBlock() external view returns (uint64);
|
149
|
+
|
150
|
+
/// @return Number of active stakers currently staked
|
151
|
+
function stakerCount() external view returns (uint64);
|
152
|
+
}
|