@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,313 @@
|
|
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/Value.sol";
|
8
|
+
import "../state/Machine.sol";
|
9
|
+
import "../state/Deserialize.sol";
|
10
|
+
import "./IOneStepProver.sol";
|
11
|
+
|
12
|
+
contract OneStepProverMemory is IOneStepProver {
|
13
|
+
using MerkleProofLib for MerkleProof;
|
14
|
+
using ModuleMemoryLib for ModuleMemory;
|
15
|
+
using ValueLib for Value;
|
16
|
+
using ValueStackLib for ValueStack;
|
17
|
+
|
18
|
+
uint256 private constant LEAF_SIZE = 32;
|
19
|
+
uint64 private constant PAGE_SIZE = 65536;
|
20
|
+
|
21
|
+
function pullLeafByte(bytes32 leaf, uint256 idx) internal pure returns (uint8) {
|
22
|
+
require(idx < LEAF_SIZE, "BAD_PULL_LEAF_BYTE_IDX");
|
23
|
+
// Take into account that we are casting the leaf to a big-endian integer
|
24
|
+
uint256 leafShift = (LEAF_SIZE - 1 - idx) * 8;
|
25
|
+
return uint8(uint256(leaf) >> leafShift);
|
26
|
+
}
|
27
|
+
|
28
|
+
function setLeafByte(
|
29
|
+
bytes32 oldLeaf,
|
30
|
+
uint256 idx,
|
31
|
+
uint8 val
|
32
|
+
) internal pure returns (bytes32) {
|
33
|
+
require(idx < LEAF_SIZE, "BAD_SET_LEAF_BYTE_IDX");
|
34
|
+
// Take into account that we are casting the leaf to a big-endian integer
|
35
|
+
uint256 leafShift = (LEAF_SIZE - 1 - idx) * 8;
|
36
|
+
uint256 newLeaf = uint256(oldLeaf);
|
37
|
+
newLeaf &= ~(0xFF << leafShift);
|
38
|
+
newLeaf |= uint256(val) << leafShift;
|
39
|
+
return bytes32(newLeaf);
|
40
|
+
}
|
41
|
+
|
42
|
+
function executeMemoryLoad(
|
43
|
+
Machine memory mach,
|
44
|
+
Module memory mod,
|
45
|
+
Instruction calldata inst,
|
46
|
+
bytes calldata proof
|
47
|
+
) internal pure {
|
48
|
+
ValueType ty;
|
49
|
+
uint256 readBytes;
|
50
|
+
bool signed;
|
51
|
+
if (inst.opcode == Instructions.I32_LOAD) {
|
52
|
+
ty = ValueType.I32;
|
53
|
+
readBytes = 4;
|
54
|
+
signed = false;
|
55
|
+
} else if (inst.opcode == Instructions.I64_LOAD) {
|
56
|
+
ty = ValueType.I64;
|
57
|
+
readBytes = 8;
|
58
|
+
signed = false;
|
59
|
+
} else if (inst.opcode == Instructions.F32_LOAD) {
|
60
|
+
ty = ValueType.F32;
|
61
|
+
readBytes = 4;
|
62
|
+
signed = false;
|
63
|
+
} else if (inst.opcode == Instructions.F64_LOAD) {
|
64
|
+
ty = ValueType.F64;
|
65
|
+
readBytes = 8;
|
66
|
+
signed = false;
|
67
|
+
} else if (inst.opcode == Instructions.I32_LOAD8_S) {
|
68
|
+
ty = ValueType.I32;
|
69
|
+
readBytes = 1;
|
70
|
+
signed = true;
|
71
|
+
} else if (inst.opcode == Instructions.I32_LOAD8_U) {
|
72
|
+
ty = ValueType.I32;
|
73
|
+
readBytes = 1;
|
74
|
+
signed = false;
|
75
|
+
} else if (inst.opcode == Instructions.I32_LOAD16_S) {
|
76
|
+
ty = ValueType.I32;
|
77
|
+
readBytes = 2;
|
78
|
+
signed = true;
|
79
|
+
} else if (inst.opcode == Instructions.I32_LOAD16_U) {
|
80
|
+
ty = ValueType.I32;
|
81
|
+
readBytes = 2;
|
82
|
+
signed = false;
|
83
|
+
} else if (inst.opcode == Instructions.I64_LOAD8_S) {
|
84
|
+
ty = ValueType.I64;
|
85
|
+
readBytes = 1;
|
86
|
+
signed = true;
|
87
|
+
} else if (inst.opcode == Instructions.I64_LOAD8_U) {
|
88
|
+
ty = ValueType.I64;
|
89
|
+
readBytes = 1;
|
90
|
+
signed = false;
|
91
|
+
} else if (inst.opcode == Instructions.I64_LOAD16_S) {
|
92
|
+
ty = ValueType.I64;
|
93
|
+
readBytes = 2;
|
94
|
+
signed = true;
|
95
|
+
} else if (inst.opcode == Instructions.I64_LOAD16_U) {
|
96
|
+
ty = ValueType.I64;
|
97
|
+
readBytes = 2;
|
98
|
+
signed = false;
|
99
|
+
} else if (inst.opcode == Instructions.I64_LOAD32_S) {
|
100
|
+
ty = ValueType.I64;
|
101
|
+
readBytes = 4;
|
102
|
+
signed = true;
|
103
|
+
} else if (inst.opcode == Instructions.I64_LOAD32_U) {
|
104
|
+
ty = ValueType.I64;
|
105
|
+
readBytes = 4;
|
106
|
+
signed = false;
|
107
|
+
} else {
|
108
|
+
revert("INVALID_MEMORY_LOAD_OPCODE");
|
109
|
+
}
|
110
|
+
|
111
|
+
// Neither of these can overflow as they're computed with much less than 256 bit integers.
|
112
|
+
uint256 startIdx = inst.argumentData + mach.valueStack.pop().assumeI32();
|
113
|
+
if (startIdx + readBytes > mod.moduleMemory.size) {
|
114
|
+
mach.status = MachineStatus.ERRORED;
|
115
|
+
return;
|
116
|
+
}
|
117
|
+
|
118
|
+
uint256 proofOffset = 0;
|
119
|
+
uint256 lastProvedLeafIdx = ~uint256(0);
|
120
|
+
bytes32 lastProvedLeafContents;
|
121
|
+
uint64 readValue;
|
122
|
+
for (uint256 i = 0; i < readBytes; i++) {
|
123
|
+
uint256 idx = startIdx + i;
|
124
|
+
uint256 leafIdx = idx / LEAF_SIZE;
|
125
|
+
if (leafIdx != lastProvedLeafIdx) {
|
126
|
+
// This hits the stack size if we phrase it as mod.moduleMemory.proveLeaf(...)
|
127
|
+
(lastProvedLeafContents, proofOffset, ) = ModuleMemoryLib.proveLeaf(
|
128
|
+
mod.moduleMemory,
|
129
|
+
leafIdx,
|
130
|
+
proof,
|
131
|
+
proofOffset
|
132
|
+
);
|
133
|
+
lastProvedLeafIdx = leafIdx;
|
134
|
+
}
|
135
|
+
uint256 indexWithinLeaf = idx % LEAF_SIZE;
|
136
|
+
readValue |=
|
137
|
+
uint64(pullLeafByte(lastProvedLeafContents, indexWithinLeaf)) <<
|
138
|
+
uint64(i * 8);
|
139
|
+
}
|
140
|
+
|
141
|
+
if (signed) {
|
142
|
+
// Go down to the original uint size, change to signed, go up to correct size, convert back to unsigned
|
143
|
+
if (readBytes == 1 && ty == ValueType.I32) {
|
144
|
+
readValue = uint32(int32(int8(uint8(readValue))));
|
145
|
+
} else if (readBytes == 1 && ty == ValueType.I64) {
|
146
|
+
readValue = uint64(int64(int8(uint8(readValue))));
|
147
|
+
} else if (readBytes == 2 && ty == ValueType.I32) {
|
148
|
+
readValue = uint32(int32(int16(uint16(readValue))));
|
149
|
+
} else if (readBytes == 2 && ty == ValueType.I64) {
|
150
|
+
readValue = uint64(int64(int16(uint16(readValue))));
|
151
|
+
} else if (readBytes == 4 && ty == ValueType.I64) {
|
152
|
+
readValue = uint64(int64(int32(uint32(readValue))));
|
153
|
+
} else {
|
154
|
+
revert("BAD_READ_BYTES_SIGNED");
|
155
|
+
}
|
156
|
+
}
|
157
|
+
|
158
|
+
mach.valueStack.push(Value({valueType: ty, contents: readValue}));
|
159
|
+
}
|
160
|
+
|
161
|
+
function executeMemoryStore(
|
162
|
+
Machine memory mach,
|
163
|
+
Module memory mod,
|
164
|
+
Instruction calldata inst,
|
165
|
+
bytes calldata proof
|
166
|
+
) internal pure {
|
167
|
+
uint64 writeBytes;
|
168
|
+
uint64 toWrite;
|
169
|
+
{
|
170
|
+
ValueType ty;
|
171
|
+
if (inst.opcode == Instructions.I32_STORE) {
|
172
|
+
ty = ValueType.I32;
|
173
|
+
writeBytes = 4;
|
174
|
+
} else if (inst.opcode == Instructions.I64_STORE) {
|
175
|
+
ty = ValueType.I64;
|
176
|
+
writeBytes = 8;
|
177
|
+
} else if (inst.opcode == Instructions.F32_STORE) {
|
178
|
+
ty = ValueType.F32;
|
179
|
+
writeBytes = 4;
|
180
|
+
} else if (inst.opcode == Instructions.F64_STORE) {
|
181
|
+
ty = ValueType.F64;
|
182
|
+
writeBytes = 8;
|
183
|
+
} else if (inst.opcode == Instructions.I32_STORE8) {
|
184
|
+
ty = ValueType.I32;
|
185
|
+
writeBytes = 1;
|
186
|
+
} else if (inst.opcode == Instructions.I32_STORE16) {
|
187
|
+
ty = ValueType.I32;
|
188
|
+
writeBytes = 2;
|
189
|
+
} else if (inst.opcode == Instructions.I64_STORE8) {
|
190
|
+
ty = ValueType.I64;
|
191
|
+
writeBytes = 1;
|
192
|
+
} else if (inst.opcode == Instructions.I64_STORE16) {
|
193
|
+
ty = ValueType.I64;
|
194
|
+
writeBytes = 2;
|
195
|
+
} else if (inst.opcode == Instructions.I64_STORE32) {
|
196
|
+
ty = ValueType.I64;
|
197
|
+
writeBytes = 4;
|
198
|
+
} else {
|
199
|
+
revert("INVALID_MEMORY_STORE_OPCODE");
|
200
|
+
}
|
201
|
+
|
202
|
+
Value memory writingVal = mach.valueStack.pop();
|
203
|
+
require(writingVal.valueType == ty, "BAD_STORE_TYPE");
|
204
|
+
toWrite = uint64(writingVal.contents);
|
205
|
+
if (writeBytes < 8) {
|
206
|
+
toWrite &= (uint64(1) << (writeBytes * 8)) - 1;
|
207
|
+
}
|
208
|
+
}
|
209
|
+
|
210
|
+
// Neither of these can overflow as they're computed with much less than 256 bit integers.
|
211
|
+
uint256 startIdx = inst.argumentData + mach.valueStack.pop().assumeI32();
|
212
|
+
if (startIdx + writeBytes > mod.moduleMemory.size) {
|
213
|
+
mach.status = MachineStatus.ERRORED;
|
214
|
+
return;
|
215
|
+
}
|
216
|
+
|
217
|
+
uint256 proofOffset = 0;
|
218
|
+
uint256 lastProvedLeafIdx = ~uint256(0);
|
219
|
+
MerkleProof memory lastProvedMerkle;
|
220
|
+
bytes32 lastProvedLeafContents;
|
221
|
+
for (uint256 i = 0; i < writeBytes; i++) {
|
222
|
+
uint256 idx = startIdx + i;
|
223
|
+
uint256 leafIdx = idx / LEAF_SIZE;
|
224
|
+
if (leafIdx != lastProvedLeafIdx) {
|
225
|
+
if (lastProvedLeafIdx != ~uint256(0)) {
|
226
|
+
// Apply the last leaf update
|
227
|
+
mod.moduleMemory.merkleRoot = lastProvedMerkle.computeRootFromMemory(
|
228
|
+
lastProvedLeafIdx,
|
229
|
+
lastProvedLeafContents
|
230
|
+
);
|
231
|
+
}
|
232
|
+
// This hits the stack size if we phrase it as mod.moduleMemory.proveLeaf(...)
|
233
|
+
(lastProvedLeafContents, proofOffset, lastProvedMerkle) = ModuleMemoryLib.proveLeaf(
|
234
|
+
mod.moduleMemory,
|
235
|
+
leafIdx,
|
236
|
+
proof,
|
237
|
+
proofOffset
|
238
|
+
);
|
239
|
+
lastProvedLeafIdx = leafIdx;
|
240
|
+
}
|
241
|
+
uint256 indexWithinLeaf = idx % LEAF_SIZE;
|
242
|
+
lastProvedLeafContents = setLeafByte(
|
243
|
+
lastProvedLeafContents,
|
244
|
+
indexWithinLeaf,
|
245
|
+
uint8(toWrite)
|
246
|
+
);
|
247
|
+
toWrite >>= 8;
|
248
|
+
}
|
249
|
+
mod.moduleMemory.merkleRoot = lastProvedMerkle.computeRootFromMemory(
|
250
|
+
lastProvedLeafIdx,
|
251
|
+
lastProvedLeafContents
|
252
|
+
);
|
253
|
+
}
|
254
|
+
|
255
|
+
function executeMemorySize(
|
256
|
+
Machine memory mach,
|
257
|
+
Module memory mod,
|
258
|
+
Instruction calldata,
|
259
|
+
bytes calldata
|
260
|
+
) internal pure {
|
261
|
+
uint32 pages = uint32(mod.moduleMemory.size / PAGE_SIZE);
|
262
|
+
mach.valueStack.push(ValueLib.newI32(pages));
|
263
|
+
}
|
264
|
+
|
265
|
+
function executeMemoryGrow(
|
266
|
+
Machine memory mach,
|
267
|
+
Module memory mod,
|
268
|
+
Instruction calldata,
|
269
|
+
bytes calldata
|
270
|
+
) internal pure {
|
271
|
+
uint32 oldPages = uint32(mod.moduleMemory.size / PAGE_SIZE);
|
272
|
+
uint32 growingPages = mach.valueStack.pop().assumeI32();
|
273
|
+
// Safe as the input integers are too small to overflow a uint256
|
274
|
+
uint256 newSize = (uint256(oldPages) + uint256(growingPages)) * PAGE_SIZE;
|
275
|
+
// Note: we require the size remain *below* 2^32, meaning the actual limit is 2^32-PAGE_SIZE
|
276
|
+
if (newSize < (1 << 32)) {
|
277
|
+
mod.moduleMemory.size = uint64(newSize);
|
278
|
+
mach.valueStack.push(ValueLib.newI32(oldPages));
|
279
|
+
} else {
|
280
|
+
mach.valueStack.push(ValueLib.newI32(~uint32(0)));
|
281
|
+
}
|
282
|
+
}
|
283
|
+
|
284
|
+
function executeOneStep(
|
285
|
+
ExecutionContext calldata,
|
286
|
+
Machine calldata startMach,
|
287
|
+
Module calldata startMod,
|
288
|
+
Instruction calldata inst,
|
289
|
+
bytes calldata proof
|
290
|
+
) external pure override returns (Machine memory mach, Module memory mod) {
|
291
|
+
mach = startMach;
|
292
|
+
mod = startMod;
|
293
|
+
|
294
|
+
uint16 opcode = inst.opcode;
|
295
|
+
|
296
|
+
function(Machine memory, Module memory, Instruction calldata, bytes calldata)
|
297
|
+
internal
|
298
|
+
pure impl;
|
299
|
+
if (opcode >= Instructions.I32_LOAD && opcode <= Instructions.I64_LOAD32_U) {
|
300
|
+
impl = executeMemoryLoad;
|
301
|
+
} else if (opcode >= Instructions.I32_STORE && opcode <= Instructions.I64_STORE32) {
|
302
|
+
impl = executeMemoryStore;
|
303
|
+
} else if (opcode == Instructions.MEMORY_SIZE) {
|
304
|
+
impl = executeMemorySize;
|
305
|
+
} else if (opcode == Instructions.MEMORY_GROW) {
|
306
|
+
impl = executeMemoryGrow;
|
307
|
+
} else {
|
308
|
+
revert("INVALID_MEMORY_OPCODE");
|
309
|
+
}
|
310
|
+
|
311
|
+
impl(mach, mod, inst, proof);
|
312
|
+
}
|
313
|
+
}
|
@@ -0,0 +1,60 @@
|
|
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 Allows registering / retrieving addresses at uint indices, saving calldata.
|
9
|
+
* @notice Precompiled contract that exists in every Arbitrum chain at 0x0000000000000000000000000000000000000066.
|
10
|
+
*/
|
11
|
+
interface ArbAddressTable {
|
12
|
+
/**
|
13
|
+
* @notice Check whether an address exists in the address table
|
14
|
+
* @param addr address to check for presence in table
|
15
|
+
* @return true if address is in table
|
16
|
+
*/
|
17
|
+
function addressExists(address addr) external view returns (bool);
|
18
|
+
|
19
|
+
/**
|
20
|
+
* @notice compress an address and return the result
|
21
|
+
* @param addr address to compress
|
22
|
+
* @return compressed address bytes
|
23
|
+
*/
|
24
|
+
function compress(address addr) external returns (bytes memory);
|
25
|
+
|
26
|
+
/**
|
27
|
+
* @notice read a compressed address from a bytes buffer
|
28
|
+
* @param buf bytes buffer containing an address
|
29
|
+
* @param offset offset of target address
|
30
|
+
* @return resulting address and updated offset into the buffer (revert if buffer is too short)
|
31
|
+
*/
|
32
|
+
function decompress(bytes calldata buf, uint256 offset)
|
33
|
+
external
|
34
|
+
view
|
35
|
+
returns (address, uint256);
|
36
|
+
|
37
|
+
/**
|
38
|
+
* @param addr address to lookup
|
39
|
+
* @return index of an address in the address table (revert if address isn't in the table)
|
40
|
+
*/
|
41
|
+
function lookup(address addr) external view returns (uint256);
|
42
|
+
|
43
|
+
/**
|
44
|
+
* @param index index to lookup address
|
45
|
+
* @return address at a given index in address table (revert if index is beyond end of table)
|
46
|
+
*/
|
47
|
+
function lookupIndex(uint256 index) external view returns (address);
|
48
|
+
|
49
|
+
/**
|
50
|
+
* @notice Register an address in the address table
|
51
|
+
* @param addr address to register
|
52
|
+
* @return index of the address (existing index, or newly created index if not already registered)
|
53
|
+
*/
|
54
|
+
function register(address addr) external returns (uint256);
|
55
|
+
|
56
|
+
/**
|
57
|
+
* @return size of address table (= first unused index)
|
58
|
+
*/
|
59
|
+
function size() external view returns (uint256);
|
60
|
+
}
|
@@ -0,0 +1,62 @@
|
|
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 aggregators and their users methods for configuring how they participate in L1 aggregation.
|
8
|
+
/// @notice Precompiled contract that exists in every Arbitrum chain at 0x000000000000000000000000000000000000006d
|
9
|
+
interface ArbAggregator {
|
10
|
+
/// @notice Get the preferred aggregator for an address.
|
11
|
+
/// @param addr The address to fetch aggregator for
|
12
|
+
/// @return (preferredAggregatorAddress, isDefault)
|
13
|
+
/// isDefault is true if addr is set to prefer the default aggregator
|
14
|
+
function getPreferredAggregator(address addr) external view returns (address, bool);
|
15
|
+
|
16
|
+
/// @notice Set the caller's preferred aggregator.
|
17
|
+
/// @param prefAgg If prefAgg is zero, this sets the caller to prefer the default aggregator
|
18
|
+
function setPreferredAggregator(address prefAgg) external;
|
19
|
+
|
20
|
+
/// @notice Get default aggregator.
|
21
|
+
function getDefaultAggregator() external view returns (address);
|
22
|
+
|
23
|
+
/// @notice Set the preferred aggregator.
|
24
|
+
/// This reverts unless called by the aggregator, its fee collector, or a chain owner
|
25
|
+
/// @param newDefault New default aggregator
|
26
|
+
function setDefaultAggregator(address newDefault) external;
|
27
|
+
|
28
|
+
/// @notice Get the aggregator's compression ratio
|
29
|
+
/// @param aggregator The aggregator to fetch the compression ratio for
|
30
|
+
/// @return The compression ratio, measured in basis points
|
31
|
+
function getCompressionRatio(address aggregator) external view returns (uint64);
|
32
|
+
|
33
|
+
/// @notice Set the aggregator's compression ratio
|
34
|
+
/// This reverts unless called by the aggregator, its fee collector, or a chain owner
|
35
|
+
/// @param aggregator The aggregator to set the compression ratio for
|
36
|
+
/// @param ratio The compression ratio, measured in basis points
|
37
|
+
function setCompressionRatio(address aggregator, uint64 ratio) external;
|
38
|
+
|
39
|
+
/// @notice Get the address where fees to aggregator are sent.
|
40
|
+
/// @param aggregator The aggregator to get the fee collector for
|
41
|
+
/// @return The fee collectors address. This will often but not always be the same as the aggregator's address.
|
42
|
+
function getFeeCollector(address aggregator) external view returns (address);
|
43
|
+
|
44
|
+
/// @notice Set the address where fees to aggregator are sent.
|
45
|
+
/// This reverts unless called by the aggregator, its fee collector, or a chain owner
|
46
|
+
/// @param aggregator The aggregator to set the fee collector for
|
47
|
+
/// @param newFeeCollector The new fee collector to set
|
48
|
+
function setFeeCollector(address aggregator, address newFeeCollector) external;
|
49
|
+
|
50
|
+
/// @notice Deprecated, always returns zero
|
51
|
+
/// @notice Get the tx base fee (in approximate L1 gas) for aggregator
|
52
|
+
/// @param aggregator The aggregator to get the base fee for
|
53
|
+
function getTxBaseFee(address aggregator) external view returns (uint256);
|
54
|
+
|
55
|
+
/// @notice Deprecated, is now a no-op
|
56
|
+
/// @notice Set the tx base fee (in approximate L1 gas) for aggregator
|
57
|
+
/// Revert unless called by aggregator or the chain owner
|
58
|
+
/// Revert if feeInL1Gas is outside the chain's allowed bounds
|
59
|
+
/// @param aggregator The aggregator to set the fee for
|
60
|
+
/// @param feeInL1Gas The base fee in L1 gas
|
61
|
+
function setTxBaseFee(address aggregator, uint256 feeInL1Gas) external;
|
62
|
+
}
|
@@ -0,0 +1,53 @@
|
|
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 a registry of BLS public keys for accounts.
|
8
|
+
/// @notice Precompiled contract that exists in every Arbitrum chain at 0x0000000000000000000000000000000000000067.
|
9
|
+
interface ArbBLS {
|
10
|
+
/// @notice Deprecated -- equivalent to registerAltBN128
|
11
|
+
function register(
|
12
|
+
uint256 x0,
|
13
|
+
uint256 x1,
|
14
|
+
uint256 y0,
|
15
|
+
uint256 y1
|
16
|
+
) external; // DEPRECATED
|
17
|
+
|
18
|
+
/// @notice Deprecated -- equivalent to getAltBN128
|
19
|
+
function getPublicKey(address addr)
|
20
|
+
external
|
21
|
+
view
|
22
|
+
returns (
|
23
|
+
uint256,
|
24
|
+
uint256,
|
25
|
+
uint256,
|
26
|
+
uint256
|
27
|
+
); // DEPRECATED
|
28
|
+
|
29
|
+
/// @notice Associate an AltBN128 public key with the caller's address
|
30
|
+
function registerAltBN128(
|
31
|
+
uint256 x0,
|
32
|
+
uint256 x1,
|
33
|
+
uint256 y0,
|
34
|
+
uint256 y1
|
35
|
+
) external;
|
36
|
+
|
37
|
+
/// @notice Get the AltBN128 public key associated with an address (revert if there isn't one)
|
38
|
+
function getAltBN128(address addr)
|
39
|
+
external
|
40
|
+
view
|
41
|
+
returns (
|
42
|
+
uint256,
|
43
|
+
uint256,
|
44
|
+
uint256,
|
45
|
+
uint256
|
46
|
+
);
|
47
|
+
|
48
|
+
/// @notice Associate a BLS 12-381 public key with the caller's address
|
49
|
+
function registerBLS12381(bytes calldata key) external;
|
50
|
+
|
51
|
+
/// @notice Get the BLS 12-381 public key associated with an address (revert if there isn't one)
|
52
|
+
function getBLS12381(address addr) external view returns (bytes memory);
|
53
|
+
}
|
@@ -0,0 +1,39 @@
|
|
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 A test contract whose methods are only accessible in debug mode
|
9
|
+
* @notice Precompiled contract that exists in every Arbitrum chain at 0x00000000000000000000000000000000000000ff.
|
10
|
+
*/
|
11
|
+
interface ArbDebug {
|
12
|
+
/// @notice Caller becomes a chain owner
|
13
|
+
function becomeChainOwner() external;
|
14
|
+
|
15
|
+
/// @notice Emit events with values based on the args provided
|
16
|
+
function events(bool flag, bytes32 value) external payable returns (address, uint256);
|
17
|
+
|
18
|
+
// Events that exist for testing log creation and pricing
|
19
|
+
event Basic(bool flag, bytes32 indexed value);
|
20
|
+
event Mixed(
|
21
|
+
bool indexed flag,
|
22
|
+
bool not,
|
23
|
+
bytes32 indexed value,
|
24
|
+
address conn,
|
25
|
+
address indexed caller
|
26
|
+
);
|
27
|
+
event Store(
|
28
|
+
bool indexed flag,
|
29
|
+
address indexed field,
|
30
|
+
uint24 number,
|
31
|
+
bytes32 value,
|
32
|
+
bytes store
|
33
|
+
);
|
34
|
+
|
35
|
+
function customRevert(uint64 number) external pure;
|
36
|
+
|
37
|
+
error Custom(uint64, string, bool);
|
38
|
+
error Unused();
|
39
|
+
}
|
@@ -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 - Provided aggregator's the ability to manage function tables,
|
8
|
+
// this enables one form of transaction compression.
|
9
|
+
/// @notice The Nitro aggregator implementation does not use these,
|
10
|
+
// so these methods have been stubbed and their effects disabled.
|
11
|
+
/// They are kept for backwards compatibility.
|
12
|
+
/// Precompiled contract that exists in every Arbitrum chain at 0x0000000000000000000000000000000000000068.
|
13
|
+
interface ArbFunctionTable {
|
14
|
+
/// @notice Reverts since the table is empty
|
15
|
+
function upload(bytes calldata buf) external;
|
16
|
+
|
17
|
+
/// @notice Returns the empty table's size, which is 0
|
18
|
+
function size(address addr) external view returns (uint256);
|
19
|
+
|
20
|
+
/// @notice No-op
|
21
|
+
function get(address addr, uint256 index)
|
22
|
+
external
|
23
|
+
view
|
24
|
+
returns (
|
25
|
+
uint256,
|
26
|
+
bool,
|
27
|
+
uint256
|
28
|
+
);
|
29
|
+
}
|
@@ -0,0 +1,121 @@
|
|
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 insight into the cost of using the chain.
|
8
|
+
/// @notice These methods have been adjusted to account for Nitro's heavy use of calldata compression.
|
9
|
+
/// Of note to end-users, we no longer make a distinction between non-zero and zero-valued calldata bytes.
|
10
|
+
/// Precompiled contract that exists in every Arbitrum chain at 0x000000000000000000000000000000000000006c.
|
11
|
+
interface ArbGasInfo {
|
12
|
+
/// @notice Get gas prices for a provided aggregator
|
13
|
+
/// @return return gas prices in wei
|
14
|
+
/// (
|
15
|
+
/// per L2 tx,
|
16
|
+
/// per L1 calldata unit, (a byte, non-zero or otherwise, is 16 units)
|
17
|
+
/// per storage allocation,
|
18
|
+
/// per ArbGas base,
|
19
|
+
/// per ArbGas congestion,
|
20
|
+
/// per ArbGas total
|
21
|
+
/// )
|
22
|
+
function getPricesInWeiWithAggregator(address aggregator)
|
23
|
+
external
|
24
|
+
view
|
25
|
+
returns (
|
26
|
+
uint256,
|
27
|
+
uint256,
|
28
|
+
uint256,
|
29
|
+
uint256,
|
30
|
+
uint256,
|
31
|
+
uint256
|
32
|
+
);
|
33
|
+
|
34
|
+
/// @notice Get gas prices. Uses the caller's preferred aggregator, or the default if the caller doesn't have a preferred one.
|
35
|
+
/// @return return gas prices in wei
|
36
|
+
/// (
|
37
|
+
/// per L2 tx,
|
38
|
+
/// per L1 calldata unit, (a byte, non-zero or otherwise, is 16 units)
|
39
|
+
/// per storage allocation,
|
40
|
+
/// per ArbGas base,
|
41
|
+
/// per ArbGas congestion,
|
42
|
+
/// per ArbGas total
|
43
|
+
/// )
|
44
|
+
function getPricesInWei()
|
45
|
+
external
|
46
|
+
view
|
47
|
+
returns (
|
48
|
+
uint256,
|
49
|
+
uint256,
|
50
|
+
uint256,
|
51
|
+
uint256,
|
52
|
+
uint256,
|
53
|
+
uint256
|
54
|
+
);
|
55
|
+
|
56
|
+
/// @notice Get prices in ArbGas for the supplied aggregator
|
57
|
+
/// @return (per L2 tx, per L1 calldata unit, per storage allocation)
|
58
|
+
function getPricesInArbGasWithAggregator(address aggregator)
|
59
|
+
external
|
60
|
+
view
|
61
|
+
returns (
|
62
|
+
uint256,
|
63
|
+
uint256,
|
64
|
+
uint256
|
65
|
+
);
|
66
|
+
|
67
|
+
/// @notice Get prices in ArbGas. Assumes the callers preferred validator, or the default if caller doesn't have a preferred one.
|
68
|
+
/// @return (per L2 tx, per L1 calldata unit, per storage allocation)
|
69
|
+
function getPricesInArbGas()
|
70
|
+
external
|
71
|
+
view
|
72
|
+
returns (
|
73
|
+
uint256,
|
74
|
+
uint256,
|
75
|
+
uint256
|
76
|
+
);
|
77
|
+
|
78
|
+
/// @notice Get the gas accounting parameters
|
79
|
+
/// @return (speedLimitPerSecond, gasPoolMax, maxTxGasLimit)
|
80
|
+
function getGasAccountingParams()
|
81
|
+
external
|
82
|
+
view
|
83
|
+
returns (
|
84
|
+
uint256,
|
85
|
+
uint256,
|
86
|
+
uint256
|
87
|
+
);
|
88
|
+
|
89
|
+
/// @notice Get the minimum gas price needed for a tx to succeed
|
90
|
+
function getMinimumGasPrice() external view returns (uint256);
|
91
|
+
|
92
|
+
/// @notice Get the number of seconds worth of the speed limit the gas pool contains
|
93
|
+
function getGasPoolSeconds() external view returns (uint64);
|
94
|
+
|
95
|
+
/// @notice Get the target fullness in bips the pricing model will try to keep the pool at
|
96
|
+
function getGasPoolTarget() external view returns (uint64);
|
97
|
+
|
98
|
+
/// @notice Get the extent in bips to which the pricing model favors filling the pool over increasing speeds
|
99
|
+
function getGasPoolWeight() external view returns (uint64);
|
100
|
+
|
101
|
+
/// @notice Get ArbOS's estimate of the amount of gas being burnt per second
|
102
|
+
function getRateEstimate() external view returns (uint64);
|
103
|
+
|
104
|
+
/// @notice Get how slowly ArbOS updates its estimate the amount of gas being burnt per second
|
105
|
+
function getRateEstimateInertia() external view returns (uint64);
|
106
|
+
|
107
|
+
/// @notice Get ArbOS's estimate of the L1 basefee in wei
|
108
|
+
function getL1BaseFeeEstimate() external view returns (uint256);
|
109
|
+
|
110
|
+
/// @notice Get how slowly ArbOS updates its estimate of the L1 basefee
|
111
|
+
function getL1BaseFeeEstimateInertia() external view returns (uint64);
|
112
|
+
|
113
|
+
/// @notice Deprecated -- Same as getL1BaseFeeEstimate()
|
114
|
+
function getL1GasPriceEstimate() external view returns (uint256);
|
115
|
+
|
116
|
+
/// @notice Get L1 gas fees paid by the current transaction
|
117
|
+
function getCurrentTxL1GasFees() external view returns (uint256);
|
118
|
+
|
119
|
+
/// @notice Get the amount of gas remaining in the gas pool
|
120
|
+
function getGasPool() external view returns (int64);
|
121
|
+
}
|