@arbitrum/nitro-contracts 1.1.1 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (217) hide show
  1. package/LICENSE.md +1 -0
  2. package/README.md +2 -4
  3. package/build/contracts/@openzeppelin/contracts/access/Ownable.sol/Ownable.dbg.json +1 -1
  4. package/build/contracts/@openzeppelin/contracts/interfaces/draft-IERC1822.sol/IERC1822Proxiable.dbg.json +1 -1
  5. package/build/contracts/@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol/ERC1967Proxy.dbg.json +1 -1
  6. package/build/contracts/@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol/ERC1967Upgrade.dbg.json +1 -1
  7. package/build/contracts/@openzeppelin/contracts/proxy/Proxy.sol/Proxy.dbg.json +1 -1
  8. package/build/contracts/@openzeppelin/contracts/proxy/beacon/IBeacon.sol/IBeacon.dbg.json +1 -1
  9. package/build/contracts/@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol/UpgradeableBeacon.dbg.json +1 -1
  10. package/build/contracts/@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol/ProxyAdmin.dbg.json +1 -1
  11. package/build/contracts/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol/TransparentUpgradeableProxy.dbg.json +1 -1
  12. package/build/contracts/@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol/UUPSUpgradeable.dbg.json +1 -1
  13. package/build/contracts/@openzeppelin/contracts/security/ReentrancyGuard.sol/ReentrancyGuard.dbg.json +1 -1
  14. package/build/contracts/@openzeppelin/contracts/token/ERC20/ERC20.sol/ERC20.dbg.json +1 -1
  15. package/build/contracts/@openzeppelin/contracts/token/ERC20/IERC20.sol/IERC20.dbg.json +1 -1
  16. package/build/contracts/@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol/IERC20Metadata.dbg.json +1 -1
  17. package/build/contracts/@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol/SafeERC20.dbg.json +1 -1
  18. package/build/contracts/@openzeppelin/contracts/utils/Address.sol/Address.dbg.json +1 -1
  19. package/build/contracts/@openzeppelin/contracts/utils/Context.sol/Context.dbg.json +1 -1
  20. package/build/contracts/@openzeppelin/contracts/utils/StorageSlot.sol/StorageSlot.dbg.json +1 -1
  21. package/build/contracts/@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol/AccessControlUpgradeable.dbg.json +1 -1
  22. package/build/contracts/@openzeppelin/contracts-upgradeable/access/IAccessControlUpgradeable.sol/IAccessControlUpgradeable.dbg.json +1 -1
  23. package/build/contracts/@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol/OwnableUpgradeable.dbg.json +1 -1
  24. package/build/contracts/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol/Initializable.dbg.json +1 -1
  25. package/build/contracts/@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol/PausableUpgradeable.dbg.json +1 -1
  26. package/build/contracts/@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol/IERC20Upgradeable.dbg.json +1 -1
  27. package/build/contracts/@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol/AddressUpgradeable.dbg.json +1 -1
  28. package/build/contracts/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol/ContextUpgradeable.dbg.json +1 -1
  29. package/build/contracts/@openzeppelin/contracts-upgradeable/utils/StorageSlotUpgradeable.sol/StorageSlotUpgradeable.dbg.json +1 -1
  30. package/build/contracts/@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol/StringsUpgradeable.dbg.json +1 -1
  31. package/build/contracts/@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol/ERC165Upgradeable.dbg.json +1 -1
  32. package/build/contracts/@openzeppelin/contracts-upgradeable/utils/introspection/IERC165Upgradeable.sol/IERC165Upgradeable.dbg.json +1 -1
  33. package/build/contracts/src/bridge/AbsBridge.sol/AbsBridge.dbg.json +1 -1
  34. package/build/contracts/src/bridge/AbsInbox.sol/AbsInbox.dbg.json +1 -1
  35. package/build/contracts/src/bridge/AbsOutbox.sol/AbsOutbox.dbg.json +1 -1
  36. package/build/contracts/src/bridge/Bridge.sol/Bridge.dbg.json +1 -1
  37. package/build/contracts/src/bridge/Bridge.sol/Bridge.json +2 -2
  38. package/build/contracts/src/bridge/ERC20Bridge.sol/ERC20Bridge.dbg.json +1 -1
  39. package/build/contracts/src/bridge/ERC20Bridge.sol/ERC20Bridge.json +2 -2
  40. package/build/contracts/src/bridge/ERC20Inbox.sol/ERC20Inbox.dbg.json +1 -1
  41. package/build/contracts/src/bridge/ERC20Inbox.sol/ERC20Inbox.json +2 -2
  42. package/build/contracts/src/bridge/ERC20Outbox.sol/ERC20Outbox.dbg.json +1 -1
  43. package/build/contracts/src/bridge/ERC20Outbox.sol/ERC20Outbox.json +2 -2
  44. package/build/contracts/src/bridge/GasRefunder.sol/GasRefunder.dbg.json +1 -1
  45. package/build/contracts/src/bridge/GasRefunder.sol/GasRefunder.json +2 -2
  46. package/build/contracts/src/bridge/IBridge.sol/IBridge.dbg.json +1 -1
  47. package/build/contracts/src/bridge/IDelayedMessageProvider.sol/IDelayedMessageProvider.dbg.json +1 -1
  48. package/build/contracts/src/bridge/IERC20Bridge.sol/IERC20Bridge.dbg.json +1 -1
  49. package/build/contracts/src/bridge/IERC20Inbox.sol/IERC20Inbox.dbg.json +1 -1
  50. package/build/contracts/src/bridge/IEthBridge.sol/IEthBridge.dbg.json +1 -1
  51. package/build/contracts/src/bridge/IInbox.sol/IInbox.dbg.json +1 -1
  52. package/build/contracts/src/bridge/IInboxBase.sol/IInboxBase.dbg.json +1 -1
  53. package/build/contracts/src/bridge/IOutbox.sol/IOutbox.dbg.json +1 -1
  54. package/build/contracts/src/bridge/IOwnable.sol/IOwnable.dbg.json +1 -1
  55. package/build/contracts/src/bridge/ISequencerInbox.sol/ISequencerInbox.dbg.json +1 -1
  56. package/build/contracts/src/bridge/ISequencerInbox.sol/ISequencerInbox.json +168 -6
  57. package/build/contracts/src/bridge/Inbox.sol/Inbox.dbg.json +1 -1
  58. package/build/contracts/src/bridge/Inbox.sol/Inbox.json +2 -2
  59. package/build/contracts/src/bridge/Messages.sol/Messages.dbg.json +1 -1
  60. package/build/contracts/src/bridge/Outbox.sol/Outbox.dbg.json +1 -1
  61. package/build/contracts/src/bridge/Outbox.sol/Outbox.json +2 -2
  62. package/build/contracts/src/bridge/SequencerInbox.sol/SequencerInbox.dbg.json +1 -1
  63. package/build/contracts/src/bridge/SequencerInbox.sol/SequencerInbox.json +238 -13
  64. package/build/contracts/src/challenge/ChallengeLib.sol/ChallengeLib.dbg.json +1 -1
  65. package/build/contracts/src/challenge/ChallengeManager.sol/ChallengeManager.dbg.json +1 -1
  66. package/build/contracts/src/challenge/ChallengeManager.sol/ChallengeManager.json +31 -2
  67. package/build/contracts/src/challenge/IChallengeManager.sol/IChallengeManager.dbg.json +1 -1
  68. package/build/contracts/src/challenge/IChallengeResultReceiver.sol/IChallengeResultReceiver.dbg.json +1 -1
  69. package/build/contracts/src/libraries/AddressAliasHelper.sol/AddressAliasHelper.dbg.json +1 -1
  70. package/build/contracts/src/libraries/AdminFallbackProxy.sol/AdminFallbackProxy.dbg.json +1 -1
  71. package/build/contracts/src/libraries/AdminFallbackProxy.sol/DoubleLogicERC1967Upgrade.dbg.json +1 -1
  72. package/build/contracts/src/libraries/ArbitrumChecker.sol/ArbitrumChecker.dbg.json +1 -1
  73. package/build/contracts/src/libraries/CryptographyPrimitives.sol/CryptographyPrimitives.dbg.json +1 -1
  74. package/build/contracts/src/libraries/DelegateCallAware.sol/DelegateCallAware.dbg.json +1 -1
  75. package/build/contracts/src/libraries/DoubleLogicUUPSUpgradeable.sol/DoubleLogicUUPSUpgradeable.dbg.json +1 -1
  76. package/build/contracts/src/libraries/GasRefundEnabled.sol/GasRefundEnabled.dbg.json +4 -0
  77. package/build/contracts/src/libraries/{IGasRefunder.sol → GasRefundEnabled.sol}/GasRefundEnabled.json +1 -1
  78. package/build/contracts/src/libraries/IGasRefunder.sol/IGasRefunder.dbg.json +1 -1
  79. package/build/contracts/src/libraries/IReader4844.sol/IReader4844.dbg.json +4 -0
  80. package/build/contracts/src/libraries/IReader4844.sol/IReader4844.json +37 -0
  81. package/build/contracts/src/libraries/MerkleLib.sol/MerkleLib.dbg.json +1 -1
  82. package/build/contracts/src/libraries/MerkleLib.sol/MerkleLib.json +2 -2
  83. package/build/contracts/src/libraries/UUPSNotUpgradeable.sol/UUPSNotUpgradeable.dbg.json +1 -1
  84. package/build/contracts/src/mocks/BridgeStub.sol/BridgeStub.dbg.json +1 -1
  85. package/build/contracts/src/mocks/BridgeStub.sol/BridgeStub.json +2 -2
  86. package/build/contracts/src/mocks/BridgeUnproxied.sol/BridgeUnproxied.dbg.json +1 -1
  87. package/build/contracts/src/mocks/BridgeUnproxied.sol/BridgeUnproxied.json +2 -2
  88. package/build/contracts/src/mocks/InboxStub.sol/InboxStub.dbg.json +1 -1
  89. package/build/contracts/src/mocks/InboxStub.sol/InboxStub.json +4 -4
  90. package/build/contracts/src/mocks/MockResultReceiver.sol/MockResultReceiver.dbg.json +1 -1
  91. package/build/contracts/src/mocks/MockResultReceiver.sol/MockResultReceiver.json +2 -2
  92. package/build/contracts/src/mocks/ProxyAdminForBinding.sol/ProxyAdminForBinding.dbg.json +1 -1
  93. package/build/contracts/src/mocks/SequencerInboxStub.sol/SequencerInboxStub.dbg.json +1 -1
  94. package/build/contracts/src/mocks/SequencerInboxStub.sol/SequencerInboxStub.json +238 -13
  95. package/build/contracts/src/mocks/Simple.sol/Simple.dbg.json +1 -1
  96. package/build/contracts/src/mocks/Simple.sol/Simple.json +45 -2
  97. package/build/contracts/src/mocks/SimpleProxy.sol/SimpleProxy.dbg.json +1 -1
  98. package/build/contracts/src/mocks/SingleExecutionChallenge.sol/SingleExecutionChallenge.dbg.json +1 -1
  99. package/build/contracts/src/mocks/SingleExecutionChallenge.sol/SingleExecutionChallenge.json +31 -2
  100. package/build/contracts/src/mocks/TimedOutChallengeManager.sol/TimedOutChallengeManager.dbg.json +1 -1
  101. package/build/contracts/src/mocks/TimedOutChallengeManager.sol/TimedOutChallengeManager.json +31 -2
  102. package/build/contracts/src/mocks/UpgradeExecutorMock.sol/UpgradeExecutorMock.dbg.json +1 -1
  103. package/build/contracts/src/node-interface/NodeInterface.sol/NodeInterface.dbg.json +1 -1
  104. package/build/contracts/src/node-interface/NodeInterfaceDebug.sol/NodeInterfaceDebug.dbg.json +1 -1
  105. package/build/contracts/src/osp/HashProofHelper.sol/HashProofHelper.dbg.json +1 -1
  106. package/build/contracts/src/osp/IOneStepProofEntry.sol/IOneStepProofEntry.dbg.json +1 -1
  107. package/build/contracts/src/osp/IOneStepProofEntry.sol/OneStepProofEntryLib.dbg.json +1 -1
  108. package/build/contracts/src/osp/IOneStepProofEntry.sol/OneStepProofEntryLib.json +2 -2
  109. package/build/contracts/src/osp/IOneStepProver.sol/IOneStepProver.dbg.json +1 -1
  110. package/build/contracts/src/osp/OneStepProofEntry.sol/OneStepProofEntry.dbg.json +1 -1
  111. package/build/contracts/src/osp/OneStepProofEntry.sol/OneStepProofEntry.json +2 -2
  112. package/build/contracts/src/osp/OneStepProver0.sol/OneStepProver0.dbg.json +1 -1
  113. package/build/contracts/src/osp/OneStepProver0.sol/OneStepProver0.json +2 -2
  114. package/build/contracts/src/osp/OneStepProverHostIo.sol/OneStepProverHostIo.dbg.json +1 -1
  115. package/build/contracts/src/osp/OneStepProverHostIo.sol/OneStepProverHostIo.json +2 -2
  116. package/build/contracts/src/osp/OneStepProverMath.sol/OneStepProverMath.dbg.json +1 -1
  117. package/build/contracts/src/osp/OneStepProverMath.sol/OneStepProverMath.json +2 -2
  118. package/build/contracts/src/osp/OneStepProverMemory.sol/OneStepProverMemory.dbg.json +1 -1
  119. package/build/contracts/src/osp/OneStepProverMemory.sol/OneStepProverMemory.json +2 -2
  120. package/build/contracts/src/precompiles/ArbAddressTable.sol/ArbAddressTable.dbg.json +1 -1
  121. package/build/contracts/src/precompiles/ArbAggregator.sol/ArbAggregator.dbg.json +1 -1
  122. package/build/contracts/src/precompiles/ArbBLS.sol/ArbBLS.dbg.json +1 -1
  123. package/build/contracts/src/precompiles/ArbDebug.sol/ArbDebug.dbg.json +1 -1
  124. package/build/contracts/src/precompiles/ArbFunctionTable.sol/ArbFunctionTable.dbg.json +1 -1
  125. package/build/contracts/src/precompiles/ArbGasInfo.sol/ArbGasInfo.dbg.json +1 -1
  126. package/build/contracts/src/precompiles/ArbGasInfo.sol/ArbGasInfo.json +65 -0
  127. package/build/contracts/src/precompiles/ArbInfo.sol/ArbInfo.dbg.json +1 -1
  128. package/build/contracts/src/precompiles/ArbOwner.sol/ArbOwner.dbg.json +1 -1
  129. package/build/contracts/src/precompiles/ArbOwnerPublic.sol/ArbOwnerPublic.dbg.json +1 -1
  130. package/build/contracts/src/precompiles/ArbOwnerPublic.sol/ArbOwnerPublic.json +18 -0
  131. package/build/contracts/src/precompiles/ArbRetryableTx.sol/ArbRetryableTx.dbg.json +1 -1
  132. package/build/contracts/src/precompiles/ArbStatistics.sol/ArbStatistics.dbg.json +1 -1
  133. package/build/contracts/src/precompiles/ArbSys.sol/ArbSys.dbg.json +1 -1
  134. package/build/contracts/src/precompiles/ArbosActs.sol/ArbosActs.dbg.json +1 -1
  135. package/build/contracts/src/precompiles/ArbosTest.sol/ArbosTest.dbg.json +1 -1
  136. package/build/contracts/src/rollup/AbsRollupEventInbox.sol/AbsRollupEventInbox.dbg.json +1 -1
  137. package/build/contracts/src/rollup/BridgeCreator.sol/BridgeCreator.dbg.json +1 -1
  138. package/build/contracts/src/rollup/BridgeCreator.sol/BridgeCreator.json +2 -2
  139. package/build/contracts/src/rollup/DeployHelper.sol/DeployHelper.dbg.json +1 -1
  140. package/build/contracts/src/rollup/DeployHelper.sol/DeployHelper.json +2 -2
  141. package/build/contracts/src/rollup/ERC20RollupEventInbox.sol/ERC20RollupEventInbox.dbg.json +1 -1
  142. package/build/contracts/src/rollup/ERC20RollupEventInbox.sol/ERC20RollupEventInbox.json +2 -2
  143. package/build/contracts/src/rollup/IRollupAdmin.sol/IRollupAdmin.dbg.json +1 -1
  144. package/build/contracts/src/rollup/IRollupCore.sol/IRollupCore.dbg.json +1 -1
  145. package/build/contracts/src/rollup/IRollupEventInbox.sol/IRollupEventInbox.dbg.json +1 -1
  146. package/build/contracts/src/rollup/IRollupLogic.sol/IRollupUser.dbg.json +1 -1
  147. package/build/contracts/src/rollup/IRollupLogic.sol/IRollupUserAbs.dbg.json +1 -1
  148. package/build/contracts/src/rollup/IRollupLogic.sol/IRollupUserERC20.dbg.json +1 -1
  149. package/build/contracts/src/rollup/Node.sol/NodeLib.dbg.json +1 -1
  150. package/build/contracts/src/rollup/RollupAdminLogic.sol/RollupAdminLogic.dbg.json +1 -1
  151. package/build/contracts/src/rollup/RollupAdminLogic.sol/RollupAdminLogic.json +2 -2
  152. package/build/contracts/src/rollup/RollupCore.sol/RollupCore.dbg.json +1 -1
  153. package/build/contracts/src/rollup/RollupCreator.sol/RollupCreator.dbg.json +1 -1
  154. package/build/contracts/src/rollup/RollupCreator.sol/RollupCreator.json +12 -7
  155. package/build/contracts/src/rollup/RollupEventInbox.sol/RollupEventInbox.dbg.json +1 -1
  156. package/build/contracts/src/rollup/RollupEventInbox.sol/RollupEventInbox.json +2 -2
  157. package/build/contracts/src/rollup/RollupLib.sol/RollupLib.dbg.json +1 -1
  158. package/build/contracts/src/rollup/RollupLib.sol/RollupLib.json +2 -2
  159. package/build/contracts/src/rollup/RollupProxy.sol/RollupProxy.dbg.json +1 -1
  160. package/build/contracts/src/rollup/RollupProxy.sol/RollupProxy.json +2 -2
  161. package/build/contracts/src/rollup/RollupUserLogic.sol/AbsRollupUserLogic.dbg.json +1 -1
  162. package/build/contracts/src/rollup/RollupUserLogic.sol/ERC20RollupUserLogic.dbg.json +1 -1
  163. package/build/contracts/src/rollup/RollupUserLogic.sol/ERC20RollupUserLogic.json +2 -2
  164. package/build/contracts/src/rollup/RollupUserLogic.sol/RollupUserLogic.dbg.json +1 -1
  165. package/build/contracts/src/rollup/RollupUserLogic.sol/RollupUserLogic.json +2 -2
  166. package/build/contracts/src/rollup/ValidatorUtils.sol/ValidatorUtils.dbg.json +1 -1
  167. package/build/contracts/src/rollup/ValidatorUtils.sol/ValidatorUtils.json +2 -2
  168. package/build/contracts/src/rollup/ValidatorWallet.sol/ValidatorWallet.dbg.json +1 -1
  169. package/build/contracts/src/rollup/ValidatorWallet.sol/ValidatorWallet.json +2 -2
  170. package/build/contracts/src/rollup/ValidatorWalletCreator.sol/ValidatorWalletCreator.dbg.json +1 -1
  171. package/build/contracts/src/rollup/ValidatorWalletCreator.sol/ValidatorWalletCreator.json +2 -2
  172. package/build/contracts/src/state/Deserialize.sol/Deserialize.dbg.json +1 -1
  173. package/build/contracts/src/state/GlobalState.sol/GlobalStateLib.dbg.json +1 -1
  174. package/build/contracts/src/state/Instructions.sol/Instructions.dbg.json +1 -1
  175. package/build/contracts/src/state/Machine.sol/MachineLib.dbg.json +1 -1
  176. package/build/contracts/src/state/MerkleProof.sol/MerkleProofLib.dbg.json +1 -1
  177. package/build/contracts/src/state/Module.sol/ModuleLib.dbg.json +1 -1
  178. package/build/contracts/src/state/ModuleMemory.sol/ModuleMemoryLib.dbg.json +1 -1
  179. package/build/contracts/src/state/ModuleMemoryCompact.sol/ModuleMemoryCompactLib.dbg.json +1 -1
  180. package/build/contracts/src/state/PcArray.sol/PcArrayLib.dbg.json +1 -1
  181. package/build/contracts/src/state/StackFrame.sol/StackFrameLib.dbg.json +1 -1
  182. package/build/contracts/src/state/Value.sol/ValueLib.dbg.json +1 -1
  183. package/build/contracts/src/state/ValueArray.sol/ValueArrayLib.dbg.json +1 -1
  184. package/build/contracts/src/state/ValueStack.sol/ValueStackLib.dbg.json +1 -1
  185. package/build/contracts/src/test-helpers/BridgeTester.sol/BridgeTester.dbg.json +1 -1
  186. package/build/contracts/src/test-helpers/BridgeTester.sol/BridgeTester.json +2 -2
  187. package/build/contracts/src/test-helpers/CryptographyPrimitivesTester.sol/CryptographyPrimitivesTester.dbg.json +1 -1
  188. package/build/contracts/src/test-helpers/EthVault.sol/EthVault.dbg.json +1 -1
  189. package/build/contracts/src/test-helpers/MessageTester.sol/MessageTester.dbg.json +1 -1
  190. package/build/contracts/src/test-helpers/OutboxWithoutOptTester.sol/OutboxWithoutOptTester.dbg.json +1 -1
  191. package/build/contracts/src/test-helpers/OutboxWithoutOptTester.sol/OutboxWithoutOptTester.json +2 -2
  192. package/build/contracts/src/test-helpers/RollupMock.sol/RollupMock.dbg.json +1 -1
  193. package/build/contracts/src/test-helpers/RollupMock.sol/RollupMock.json +26 -2
  194. package/build/contracts/src/test-helpers/TestToken.sol/TestToken.dbg.json +1 -1
  195. package/build/contracts/src/test-helpers/ValueArrayTester.sol/ValueArrayTester.dbg.json +1 -1
  196. package/out/yul/Reader4844.yul/Reader4844.json +1 -0
  197. package/package.json +13 -4
  198. package/src/bridge/GasRefunder.sol +2 -0
  199. package/src/bridge/IBridge.sol +22 -0
  200. package/src/bridge/ISequencerInbox.sol +69 -22
  201. package/src/bridge/SequencerInbox.sol +436 -142
  202. package/src/challenge/ChallengeManager.sol +6 -0
  203. package/src/libraries/Error.sol +24 -3
  204. package/src/libraries/GasRefundEnabled.sol +52 -0
  205. package/src/libraries/IGasRefunder.sol +0 -25
  206. package/src/libraries/IReader4844.sol +13 -0
  207. package/src/mocks/InboxStub.sol +2 -2
  208. package/src/mocks/SequencerInboxStub.sol +11 -6
  209. package/src/mocks/Simple.sol +31 -1
  210. package/src/osp/OneStepProverHostIo.sol +100 -7
  211. package/src/precompiles/ArbGasInfo.sol +20 -0
  212. package/src/precompiles/ArbOwnerPublic.sol +8 -0
  213. package/src/rollup/BridgeCreator.sol +1 -1
  214. package/src/rollup/RollupCreator.sol +31 -19
  215. package/src/rollup/ValidatorWallet.sol +4 -3
  216. package/src/test-helpers/RollupMock.sol +6 -0
  217. package/build/contracts/src/libraries/IGasRefunder.sol/GasRefundEnabled.dbg.json +0 -4
@@ -7,9 +7,9 @@ pragma solidity ^0.8.0;
7
7
  import {
8
8
  AlreadyInit,
9
9
  HadZeroInit,
10
+ BadPostUpgradeInit,
10
11
  NotOrigin,
11
12
  DataTooLarge,
12
- NotRollup,
13
13
  DelayedBackwards,
14
14
  DelayedTooFar,
15
15
  ForceIncludeBlockTooSoon,
@@ -17,11 +17,19 @@ import {
17
17
  IncorrectMessagePreimage,
18
18
  NotBatchPoster,
19
19
  BadSequencerNumber,
20
- DataNotAuthenticated,
21
20
  AlreadyValidDASKeyset,
22
21
  NoSuchKeyset,
23
22
  NotForked,
24
- RollupNotChanged
23
+ NotBatchPosterManager,
24
+ RollupNotChanged,
25
+ DataBlobsNotSupported,
26
+ InitParamZero,
27
+ MissingDataHashes,
28
+ NotOwner,
29
+ InvalidHeaderFlag,
30
+ NativeTokenMismatch,
31
+ BadMaxTimeVariation,
32
+ Deprecated
25
33
  } from "../libraries/Error.sol";
26
34
  import "./IBridge.sol";
27
35
  import "./IInboxBase.sol";
@@ -30,18 +38,21 @@ import "../rollup/IRollupLogic.sol";
30
38
  import "./Messages.sol";
31
39
  import "../precompiles/ArbGasInfo.sol";
32
40
  import "../precompiles/ArbSys.sol";
41
+ import "../libraries/IReader4844.sol";
33
42
 
34
43
  import {L1MessageType_batchPostingReport} from "../libraries/MessageTypes.sol";
35
- import {GasRefundEnabled, IGasRefunder} from "../libraries/IGasRefunder.sol";
36
44
  import "../libraries/DelegateCallAware.sol";
45
+ import {IGasRefunder} from "../libraries/IGasRefunder.sol";
46
+ import {GasRefundEnabled} from "../libraries/GasRefundEnabled.sol";
37
47
  import "../libraries/ArbitrumChecker.sol";
48
+ import {IERC20Bridge} from "./IERC20Bridge.sol";
38
49
 
39
50
  /**
40
- * @title Accepts batches from the sequencer and adds them to the rollup inbox.
51
+ * @title Accepts batches from the sequencer and adds them to the rollup inbox.
41
52
  * @notice Contains the inbox accumulator which is the ordering of all data and transactions to be processed by the rollup.
42
- * As part of submitting a batch the sequencer is also expected to include items enqueued
43
- * in the delayed inbox (Bridge.sol). If items in the delayed inbox are not included by a
44
- * sequencer within a time limit they can be force included into the rollup inbox by anyone.
53
+ * As part of submitting a batch the sequencer is also expected to include items enqueued
54
+ * in the delayed inbox (Bridge.sol). If items in the delayed inbox are not included by a
55
+ * sequencer within a time limit they can be force included into the rollup inbox by anyone.
45
56
  */
46
57
  contract SequencerInbox is DelegateCallAware, GasRefundEnabled, ISequencerInbox {
47
58
  uint256 public totalDelayedMessagesRead;
@@ -54,42 +65,140 @@ contract SequencerInbox is DelegateCallAware, GasRefundEnabled, ISequencerInbox
54
65
  /// @inheritdoc ISequencerInbox
55
66
  bytes1 public constant DATA_AUTHENTICATED_FLAG = 0x40;
56
67
 
68
+ /// @inheritdoc ISequencerInbox
69
+ bytes1 public constant DATA_BLOB_HEADER_FLAG = DATA_AUTHENTICATED_FLAG | 0x10;
70
+
71
+ /// @inheritdoc ISequencerInbox
72
+ bytes1 public constant DAS_MESSAGE_HEADER_FLAG = 0x80;
73
+
74
+ /// @inheritdoc ISequencerInbox
75
+ bytes1 public constant TREE_DAS_MESSAGE_HEADER_FLAG = 0x08;
76
+
77
+ /// @inheritdoc ISequencerInbox
78
+ bytes1 public constant BROTLI_MESSAGE_HEADER_FLAG = 0x00;
79
+
80
+ /// @inheritdoc ISequencerInbox
81
+ bytes1 public constant ZERO_HEAVY_MESSAGE_HEADER_FLAG = 0x20;
82
+
83
+ // GAS_PER_BLOB from EIP-4844
84
+ uint256 internal constant GAS_PER_BLOB = 1 << 17;
85
+
57
86
  IOwnable public rollup;
87
+
58
88
  mapping(address => bool) public isBatchPoster;
59
- ISequencerInbox.MaxTimeVariation public maxTimeVariation;
89
+
90
+ // we previously stored the max time variation in a (uint,uint,uint,uint) struct here
91
+ // solhint-disable-next-line var-name-mixedcase
92
+ ISequencerInbox.MaxTimeVariation private __LEGACY_MAX_TIME_VARIATION;
60
93
 
61
94
  mapping(bytes32 => DasKeySetInfo) public dasKeySetInfo;
62
95
 
63
96
  modifier onlyRollupOwner() {
64
- if (msg.sender != rollup.owner()) revert NotOwner(msg.sender, address(rollup));
97
+ if (msg.sender != rollup.owner()) revert NotOwner(msg.sender, rollup.owner());
98
+ _;
99
+ }
100
+
101
+ modifier onlyRollupOwnerOrBatchPosterManager() {
102
+ if (msg.sender != rollup.owner() && msg.sender != batchPosterManager) {
103
+ revert NotBatchPosterManager(msg.sender);
104
+ }
65
105
  _;
66
106
  }
67
107
 
68
108
  mapping(address => bool) public isSequencer;
109
+ IReader4844 public immutable reader4844;
110
+
111
+ // see ISequencerInbox.MaxTimeVariation
112
+ uint64 internal delayBlocks;
113
+ uint64 internal futureBlocks;
114
+ uint64 internal delaySeconds;
115
+ uint64 internal futureSeconds;
116
+
117
+ /// @inheritdoc ISequencerInbox
118
+ address public batchPosterManager;
69
119
 
70
120
  // On L1 this should be set to 117964: 90% of Geth's 128KB tx size limit, leaving ~13KB for proving
71
121
  uint256 public immutable maxDataSize;
72
122
  uint256 internal immutable deployTimeChainId = block.chainid;
73
123
  // If the chain this SequencerInbox is deployed on is an Arbitrum chain.
74
124
  bool internal immutable hostChainIsArbitrum = ArbitrumChecker.runningOnArbitrum();
75
-
76
- constructor(uint256 _maxDataSize) {
125
+ // True if the chain this SequencerInbox is deployed on uses custom fee token
126
+ bool public immutable isUsingFeeToken;
127
+
128
+ constructor(
129
+ uint256 _maxDataSize,
130
+ IReader4844 reader4844_,
131
+ bool _isUsingFeeToken
132
+ ) {
77
133
  maxDataSize = _maxDataSize;
134
+ if (hostChainIsArbitrum) {
135
+ if (reader4844_ != IReader4844(address(0))) revert DataBlobsNotSupported();
136
+ } else {
137
+ if (reader4844_ == IReader4844(address(0))) revert InitParamZero("Reader4844");
138
+ }
139
+ reader4844 = reader4844_;
140
+ isUsingFeeToken = _isUsingFeeToken;
78
141
  }
79
142
 
80
143
  function _chainIdChanged() internal view returns (bool) {
81
144
  return deployTimeChainId != block.chainid;
82
145
  }
83
146
 
147
+ function postUpgradeInit() external onlyDelegated onlyProxyOwner {
148
+ // Assuming we would not upgrade from a version that have MaxTimeVariation all set to zero
149
+ // If that is the case, postUpgradeInit do not need to be called
150
+ if (
151
+ __LEGACY_MAX_TIME_VARIATION.delayBlocks == 0 &&
152
+ __LEGACY_MAX_TIME_VARIATION.futureBlocks == 0 &&
153
+ __LEGACY_MAX_TIME_VARIATION.delaySeconds == 0 &&
154
+ __LEGACY_MAX_TIME_VARIATION.futureSeconds == 0
155
+ ) {
156
+ revert AlreadyInit();
157
+ }
158
+
159
+ if (
160
+ __LEGACY_MAX_TIME_VARIATION.delayBlocks > type(uint64).max ||
161
+ __LEGACY_MAX_TIME_VARIATION.futureBlocks > type(uint64).max ||
162
+ __LEGACY_MAX_TIME_VARIATION.delaySeconds > type(uint64).max ||
163
+ __LEGACY_MAX_TIME_VARIATION.futureSeconds > type(uint64).max
164
+ ) {
165
+ revert BadPostUpgradeInit();
166
+ }
167
+
168
+ delayBlocks = uint64(__LEGACY_MAX_TIME_VARIATION.delayBlocks);
169
+ futureBlocks = uint64(__LEGACY_MAX_TIME_VARIATION.futureBlocks);
170
+ delaySeconds = uint64(__LEGACY_MAX_TIME_VARIATION.delaySeconds);
171
+ futureSeconds = uint64(__LEGACY_MAX_TIME_VARIATION.futureSeconds);
172
+
173
+ __LEGACY_MAX_TIME_VARIATION.delayBlocks = 0;
174
+ __LEGACY_MAX_TIME_VARIATION.futureBlocks = 0;
175
+ __LEGACY_MAX_TIME_VARIATION.delaySeconds = 0;
176
+ __LEGACY_MAX_TIME_VARIATION.futureSeconds = 0;
177
+ }
178
+
84
179
  function initialize(
85
180
  IBridge bridge_,
86
181
  ISequencerInbox.MaxTimeVariation calldata maxTimeVariation_
87
182
  ) external onlyDelegated {
88
183
  if (bridge != IBridge(address(0))) revert AlreadyInit();
89
184
  if (bridge_ == IBridge(address(0))) revert HadZeroInit();
185
+
186
+ // Make sure logic contract was created by proper value for 'isUsingFeeToken'.
187
+ // Bridge in ETH based chains doesn't implement nativeToken(). In future it might implement it and return address(0)
188
+ bool actualIsUsingFeeToken = false;
189
+ try IERC20Bridge(address(bridge_)).nativeToken() returns (address feeToken) {
190
+ if (feeToken != address(0)) {
191
+ actualIsUsingFeeToken = true;
192
+ }
193
+ } catch {}
194
+ if (isUsingFeeToken != actualIsUsingFeeToken) {
195
+ revert NativeTokenMismatch();
196
+ }
197
+
90
198
  bridge = bridge_;
91
199
  rollup = bridge_.rollup();
92
- maxTimeVariation = maxTimeVariation_;
200
+
201
+ _setMaxTimeVariation(maxTimeVariation_);
93
202
  }
94
203
 
95
204
  /// @notice Allows the rollup owner to sync the rollup address
@@ -101,28 +210,74 @@ contract SequencerInbox is DelegateCallAware, GasRefundEnabled, ISequencerInbox
101
210
  rollup = newRollup;
102
211
  }
103
212
 
104
- function getTimeBounds() internal view virtual returns (TimeBounds memory) {
105
- TimeBounds memory bounds;
106
- if (block.timestamp > maxTimeVariation.delaySeconds) {
107
- bounds.minTimestamp = uint64(block.timestamp - maxTimeVariation.delaySeconds);
213
+ function getTimeBounds() internal view virtual returns (IBridge.TimeBounds memory) {
214
+ IBridge.TimeBounds memory bounds;
215
+ (
216
+ uint64 delayBlocks_,
217
+ uint64 futureBlocks_,
218
+ uint64 delaySeconds_,
219
+ uint64 futureSeconds_
220
+ ) = maxTimeVariationInternal();
221
+ if (block.timestamp > delaySeconds_) {
222
+ bounds.minTimestamp = uint64(block.timestamp) - delaySeconds_;
108
223
  }
109
- bounds.maxTimestamp = uint64(block.timestamp + maxTimeVariation.futureSeconds);
110
- if (block.number > maxTimeVariation.delayBlocks) {
111
- bounds.minBlockNumber = uint64(block.number - maxTimeVariation.delayBlocks);
224
+ bounds.maxTimestamp = uint64(block.timestamp) + futureSeconds_;
225
+ if (block.number > delayBlocks_) {
226
+ bounds.minBlockNumber = uint64(block.number) - delayBlocks_;
112
227
  }
113
- bounds.maxBlockNumber = uint64(block.number + maxTimeVariation.futureBlocks);
228
+ bounds.maxBlockNumber = uint64(block.number) + futureBlocks_;
114
229
  return bounds;
115
230
  }
116
231
 
117
232
  /// @inheritdoc ISequencerInbox
118
233
  function removeDelayAfterFork() external {
119
234
  if (!_chainIdChanged()) revert NotForked();
120
- maxTimeVariation = ISequencerInbox.MaxTimeVariation({
121
- delayBlocks: 1,
122
- futureBlocks: 1,
123
- delaySeconds: 1,
124
- futureSeconds: 1
125
- });
235
+ delayBlocks = 1;
236
+ futureBlocks = 1;
237
+ delaySeconds = 1;
238
+ futureSeconds = 1;
239
+ }
240
+
241
+ function maxTimeVariation()
242
+ external
243
+ view
244
+ returns (
245
+ uint256,
246
+ uint256,
247
+ uint256,
248
+ uint256
249
+ )
250
+ {
251
+ (
252
+ uint64 delayBlocks_,
253
+ uint64 futureBlocks_,
254
+ uint64 delaySeconds_,
255
+ uint64 futureSeconds_
256
+ ) = maxTimeVariationInternal();
257
+
258
+ return (
259
+ uint256(delayBlocks_),
260
+ uint256(futureBlocks_),
261
+ uint256(delaySeconds_),
262
+ uint256(futureSeconds_)
263
+ );
264
+ }
265
+
266
+ function maxTimeVariationInternal()
267
+ internal
268
+ view
269
+ returns (
270
+ uint64,
271
+ uint64,
272
+ uint64,
273
+ uint64
274
+ )
275
+ {
276
+ if (_chainIdChanged()) {
277
+ return (1, 1, 1, 1);
278
+ } else {
279
+ return (delayBlocks, futureBlocks, delaySeconds, futureSeconds);
280
+ }
126
281
  }
127
282
 
128
283
  /// @inheritdoc ISequencerInbox
@@ -145,10 +300,8 @@ contract SequencerInbox is DelegateCallAware, GasRefundEnabled, ISequencerInbox
145
300
  messageDataHash
146
301
  );
147
302
  // Can only force-include after the Sequencer-only window has expired.
148
- if (l1BlockAndTime[0] + maxTimeVariation.delayBlocks >= block.number)
149
- revert ForceIncludeBlockTooSoon();
150
- if (l1BlockAndTime[1] + maxTimeVariation.delaySeconds >= block.timestamp)
151
- revert ForceIncludeTimeTooSoon();
303
+ if (l1BlockAndTime[0] + delayBlocks >= block.number) revert ForceIncludeBlockTooSoon();
304
+ if (l1BlockAndTime[1] + delaySeconds >= block.timestamp) revert ForceIncludeTimeTooSoon();
152
305
 
153
306
  // Verify that message hash represents the last message sequence of delayed message to be included
154
307
  bytes32 prevDelayedAcc = 0;
@@ -160,14 +313,12 @@ contract SequencerInbox is DelegateCallAware, GasRefundEnabled, ISequencerInbox
160
313
  Messages.accumulateInboxMessage(prevDelayedAcc, messageHash)
161
314
  ) revert IncorrectMessagePreimage();
162
315
 
163
- (bytes32 dataHash, TimeBounds memory timeBounds) = formEmptyDataHash(
316
+ (bytes32 dataHash, IBridge.TimeBounds memory timeBounds) = formEmptyDataHash(
164
317
  _totalDelayedMessagesRead
165
318
  );
166
319
  uint256 __totalDelayedMessagesRead = _totalDelayedMessagesRead;
167
320
  uint256 prevSeqMsgCount = bridge.sequencerReportedSubMessageCount();
168
- uint256 newSeqMsgCount = prevSeqMsgCount +
169
- _totalDelayedMessagesRead -
170
- totalDelayedMessagesRead;
321
+ uint256 newSeqMsgCount = prevSeqMsgCount; // force inclusion should not modify sequencer message count
171
322
  (
172
323
  uint256 seqMessageIndex,
173
324
  bytes32 beforeAcc,
@@ -187,42 +338,18 @@ contract SequencerInbox is DelegateCallAware, GasRefundEnabled, ISequencerInbox
187
338
  delayedAcc,
188
339
  totalDelayedMessagesRead,
189
340
  timeBounds,
190
- BatchDataLocation.NoData
341
+ IBridge.BatchDataLocation.NoData
191
342
  );
192
343
  }
193
344
 
194
- /// @dev Deprecated in favor of the variant specifying message counts for consistency
345
+ /// @dev Deprecated, kept for abi generation and will be removed in the future
195
346
  function addSequencerL2BatchFromOrigin(
196
- uint256 sequenceNumber,
197
- bytes calldata data,
198
- uint256 afterDelayedMessagesRead,
199
- IGasRefunder gasRefunder
200
- ) external refundsGas(gasRefunder) {
201
- // solhint-disable-next-line avoid-tx-origin
202
- if (msg.sender != tx.origin) revert NotOrigin();
203
- if (!isBatchPoster[msg.sender]) revert NotBatchPoster();
204
-
205
- (bytes32 dataHash, TimeBounds memory timeBounds) = formDataHash(
206
- data,
207
- afterDelayedMessagesRead
208
- );
209
- (
210
- uint256 seqMessageIndex,
211
- bytes32 beforeAcc,
212
- bytes32 delayedAcc,
213
- bytes32 afterAcc
214
- ) = addSequencerL2BatchImpl(dataHash, afterDelayedMessagesRead, data.length, 0, 0);
215
- if (seqMessageIndex != sequenceNumber)
216
- revert BadSequencerNumber(seqMessageIndex, sequenceNumber);
217
- emit SequencerBatchDelivered(
218
- sequenceNumber,
219
- beforeAcc,
220
- afterAcc,
221
- delayedAcc,
222
- totalDelayedMessagesRead,
223
- timeBounds,
224
- BatchDataLocation.TxInput
225
- );
347
+ uint256,
348
+ bytes calldata,
349
+ uint256,
350
+ IGasRefunder
351
+ ) external pure {
352
+ revert Deprecated();
226
353
  }
227
354
 
228
355
  function addSequencerL2BatchFromOrigin(
@@ -232,17 +359,17 @@ contract SequencerInbox is DelegateCallAware, GasRefundEnabled, ISequencerInbox
232
359
  IGasRefunder gasRefunder,
233
360
  uint256 prevMessageCount,
234
361
  uint256 newMessageCount
235
- ) external refundsGas(gasRefunder) {
362
+ ) external refundsGas(gasRefunder, IReader4844(address(0))) {
236
363
  // solhint-disable-next-line avoid-tx-origin
237
364
  if (msg.sender != tx.origin) revert NotOrigin();
238
365
  if (!isBatchPoster[msg.sender]) revert NotBatchPoster();
239
- (bytes32 dataHash, TimeBounds memory timeBounds) = formDataHash(
366
+ (bytes32 dataHash, IBridge.TimeBounds memory timeBounds) = formCallDataHash(
240
367
  data,
241
368
  afterDelayedMessagesRead
242
369
  );
243
370
  // Reformat the stack to prevent "Stack too deep"
244
371
  uint256 sequenceNumber_ = sequenceNumber;
245
- TimeBounds memory timeBounds_ = timeBounds;
372
+ IBridge.TimeBounds memory timeBounds_ = timeBounds;
246
373
  bytes32 dataHash_ = dataHash;
247
374
  uint256 dataLength = data.length;
248
375
  uint256 afterDelayedMessagesRead_ = afterDelayedMessagesRead;
@@ -260,8 +387,12 @@ contract SequencerInbox is DelegateCallAware, GasRefundEnabled, ISequencerInbox
260
387
  prevMessageCount_,
261
388
  newMessageCount_
262
389
  );
263
- if (seqMessageIndex != sequenceNumber_ && sequenceNumber_ != ~uint256(0))
390
+
391
+ // ~uint256(0) is type(uint256).max, but ever so slightly cheaper
392
+ if (seqMessageIndex != sequenceNumber_ && sequenceNumber_ != ~uint256(0)) {
264
393
  revert BadSequencerNumber(seqMessageIndex, sequenceNumber_);
394
+ }
395
+
265
396
  emit SequencerBatchDelivered(
266
397
  seqMessageIndex,
267
398
  beforeAcc,
@@ -269,8 +400,69 @@ contract SequencerInbox is DelegateCallAware, GasRefundEnabled, ISequencerInbox
269
400
  delayedAcc,
270
401
  totalDelayedMessagesRead,
271
402
  timeBounds_,
272
- BatchDataLocation.TxInput
403
+ IBridge.BatchDataLocation.TxInput
404
+ );
405
+ }
406
+
407
+ function addSequencerL2BatchFromBlobs(
408
+ uint256 sequenceNumber,
409
+ uint256 afterDelayedMessagesRead,
410
+ IGasRefunder gasRefunder,
411
+ uint256 prevMessageCount,
412
+ uint256 newMessageCount
413
+ ) external refundsGas(gasRefunder, reader4844) {
414
+ if (!isBatchPoster[msg.sender]) revert NotBatchPoster();
415
+ (
416
+ bytes32 dataHash,
417
+ IBridge.TimeBounds memory timeBounds,
418
+ uint256 blobGas
419
+ ) = formBlobDataHash(afterDelayedMessagesRead);
420
+
421
+ // we use addSequencerL2BatchImpl for submitting the message
422
+ // normally this would also submit a batch spending report but that is skipped if we pass
423
+ // an empty call data size, then we submit a separate batch spending report later
424
+ (
425
+ uint256 seqMessageIndex,
426
+ bytes32 beforeAcc,
427
+ bytes32 delayedAcc,
428
+ bytes32 afterAcc
429
+ ) = addSequencerL2BatchImpl(
430
+ dataHash,
431
+ afterDelayedMessagesRead,
432
+ 0,
433
+ prevMessageCount,
434
+ newMessageCount
435
+ );
436
+
437
+ uint256 _sequenceNumber = sequenceNumber; // stack workaround
438
+
439
+ // ~uint256(0) is type(uint256).max, but ever so slightly cheaper
440
+ if (seqMessageIndex != _sequenceNumber && _sequenceNumber != ~uint256(0)) {
441
+ revert BadSequencerNumber(seqMessageIndex, _sequenceNumber);
442
+ }
443
+
444
+ emit SequencerBatchDelivered(
445
+ _sequenceNumber,
446
+ beforeAcc,
447
+ afterAcc,
448
+ delayedAcc,
449
+ totalDelayedMessagesRead,
450
+ timeBounds,
451
+ IBridge.BatchDataLocation.Blob
273
452
  );
453
+
454
+ // blobs are currently not supported on host arbitrum chains, when support is added it may
455
+ // consume gas in a different way to L1, so explicitly block host arb chains so that if support for blobs
456
+ // on arb is added it will need to explicitly turned on in the sequencer inbox
457
+ if (hostChainIsArbitrum) revert DataBlobsNotSupported();
458
+
459
+ // submit a batch spending report to refund the entity that produced the blob batch data
460
+ // same as using calldata, we only submit spending report if the caller is the origin of the tx
461
+ // such that one cannot "double-claim" batch posting refund in the same tx
462
+ // solhint-disable-next-line avoid-tx-origin
463
+ if (msg.sender == tx.origin && !isUsingFeeToken) {
464
+ submitBatchSpendingReport(dataHash, seqMessageIndex, block.basefee, blobGas);
465
+ }
274
466
  }
275
467
 
276
468
  function addSequencerL2Batch(
@@ -280,9 +472,9 @@ contract SequencerInbox is DelegateCallAware, GasRefundEnabled, ISequencerInbox
280
472
  IGasRefunder gasRefunder,
281
473
  uint256 prevMessageCount,
282
474
  uint256 newMessageCount
283
- ) external override refundsGas(gasRefunder) {
475
+ ) external override refundsGas(gasRefunder, IReader4844(address(0))) {
284
476
  if (!isBatchPoster[msg.sender] && msg.sender != address(rollup)) revert NotBatchPoster();
285
- (bytes32 dataHash, TimeBounds memory timeBounds) = formDataHash(
477
+ (bytes32 dataHash, IBridge.TimeBounds memory timeBounds) = formCallDataHash(
286
478
  data,
287
479
  afterDelayedMessagesRead
288
480
  );
@@ -290,7 +482,7 @@ contract SequencerInbox is DelegateCallAware, GasRefundEnabled, ISequencerInbox
290
482
  {
291
483
  // Reformat the stack to prevent "Stack too deep"
292
484
  uint256 sequenceNumber_ = sequenceNumber;
293
- TimeBounds memory timeBounds_ = timeBounds;
485
+ IBridge.TimeBounds memory timeBounds_ = timeBounds;
294
486
  bytes32 dataHash_ = dataHash;
295
487
  uint256 afterDelayedMessagesRead_ = afterDelayedMessagesRead;
296
488
  uint256 prevMessageCount_ = prevMessageCount;
@@ -307,8 +499,12 @@ contract SequencerInbox is DelegateCallAware, GasRefundEnabled, ISequencerInbox
307
499
  prevMessageCount_,
308
500
  newMessageCount_
309
501
  );
310
- if (seqMessageIndex != sequenceNumber_ && sequenceNumber_ != ~uint256(0))
502
+
503
+ // ~uint256(0) is type(uint256).max, but ever so slightly cheaper
504
+ if (seqMessageIndex != sequenceNumber_ && sequenceNumber_ != ~uint256(0)) {
311
505
  revert BadSequencerNumber(seqMessageIndex, sequenceNumber_);
506
+ }
507
+
312
508
  emit SequencerBatchDelivered(
313
509
  seqMessageIndex,
314
510
  beforeAcc,
@@ -316,34 +512,18 @@ contract SequencerInbox is DelegateCallAware, GasRefundEnabled, ISequencerInbox
316
512
  delayedAcc,
317
513
  totalDelayedMessagesRead,
318
514
  timeBounds_,
319
- BatchDataLocation.SeparateBatchEvent
515
+ IBridge.BatchDataLocation.SeparateBatchEvent
320
516
  );
321
517
  }
322
518
  emit SequencerBatchData(seqMessageIndex, data);
323
519
  }
324
520
 
325
- modifier validateBatchData(bytes calldata data) {
326
- uint256 fullDataLen = HEADER_LENGTH + data.length;
327
- if (fullDataLen > maxDataSize) revert DataTooLarge(fullDataLen, maxDataSize);
328
- if (data.length > 0 && (data[0] & DATA_AUTHENTICATED_FLAG) == DATA_AUTHENTICATED_FLAG) {
329
- revert DataNotAuthenticated();
330
- }
331
- // the first byte is used to identify the type of batch data
332
- // das batches expect to have the type byte set, followed by the keyset (so they should have at least 33 bytes)
333
- if (data.length >= 33 && data[0] & 0x80 != 0) {
334
- // we skip the first byte, then read the next 32 bytes for the keyset
335
- bytes32 dasKeysetHash = bytes32(data[1:33]);
336
- if (!dasKeySetInfo[dasKeysetHash].isValidKeyset) revert NoSuchKeyset(dasKeysetHash);
337
- }
338
- _;
339
- }
340
-
341
521
  function packHeader(uint256 afterDelayedMessagesRead)
342
522
  internal
343
523
  view
344
- returns (bytes memory, TimeBounds memory)
524
+ returns (bytes memory, IBridge.TimeBounds memory)
345
525
  {
346
- TimeBounds memory timeBounds = getTimeBounds();
526
+ IBridge.TimeBounds memory timeBounds = getTimeBounds();
347
527
  bytes memory header = abi.encodePacked(
348
528
  timeBounds.minTimestamp,
349
529
  timeBounds.maxTimestamp,
@@ -356,24 +536,139 @@ contract SequencerInbox is DelegateCallAware, GasRefundEnabled, ISequencerInbox
356
536
  return (header, timeBounds);
357
537
  }
358
538
 
359
- function formDataHash(bytes calldata data, uint256 afterDelayedMessagesRead)
539
+ /// @dev Form a hash for a sequencer message with no batch data
540
+ /// @param afterDelayedMessagesRead The delayed messages count read up to
541
+ /// @return The data hash
542
+ /// @return The timebounds within which the message should be processed
543
+ function formEmptyDataHash(uint256 afterDelayedMessagesRead)
360
544
  internal
361
545
  view
362
- validateBatchData(data)
363
- returns (bytes32, TimeBounds memory)
546
+ returns (bytes32, IBridge.TimeBounds memory)
364
547
  {
365
- (bytes memory header, TimeBounds memory timeBounds) = packHeader(afterDelayedMessagesRead);
366
- bytes32 dataHash = keccak256(bytes.concat(header, data));
367
- return (dataHash, timeBounds);
548
+ (bytes memory header, IBridge.TimeBounds memory timeBounds) = packHeader(
549
+ afterDelayedMessagesRead
550
+ );
551
+ return (keccak256(header), timeBounds);
368
552
  }
369
553
 
370
- function formEmptyDataHash(uint256 afterDelayedMessagesRead)
554
+ /// @dev Since the data is supplied from calldata, the batch poster can choose the data type
555
+ /// We need to ensure that this data cannot cause a collision with data supplied via another method (eg blobs)
556
+ /// therefore we restrict which flags can be provided as a header in this field
557
+ /// This also safe guards unused flags for future use, as we know they would have been disallowed up until this point
558
+ /// @param headerByte The first byte in the calldata
559
+ function isValidCallDataFlag(bytes1 headerByte) internal pure returns (bool) {
560
+ return
561
+ headerByte == BROTLI_MESSAGE_HEADER_FLAG ||
562
+ headerByte == DAS_MESSAGE_HEADER_FLAG ||
563
+ (headerByte == (DAS_MESSAGE_HEADER_FLAG | TREE_DAS_MESSAGE_HEADER_FLAG)) ||
564
+ headerByte == ZERO_HEAVY_MESSAGE_HEADER_FLAG;
565
+ }
566
+
567
+ /// @dev Form a hash of the data taken from the calldata
568
+ /// @param data The calldata to be hashed
569
+ /// @param afterDelayedMessagesRead The delayed messages count read up to
570
+ /// @return The data hash
571
+ /// @return The timebounds within which the message should be processed
572
+ function formCallDataHash(bytes calldata data, uint256 afterDelayedMessagesRead)
371
573
  internal
372
574
  view
373
- returns (bytes32, TimeBounds memory)
575
+ returns (bytes32, IBridge.TimeBounds memory)
374
576
  {
375
- (bytes memory header, TimeBounds memory timeBounds) = packHeader(afterDelayedMessagesRead);
376
- return (keccak256(header), timeBounds);
577
+ uint256 fullDataLen = HEADER_LENGTH + data.length;
578
+ if (fullDataLen > maxDataSize) revert DataTooLarge(fullDataLen, maxDataSize);
579
+
580
+ (bytes memory header, IBridge.TimeBounds memory timeBounds) = packHeader(
581
+ afterDelayedMessagesRead
582
+ );
583
+
584
+ // the batch poster is allowed to submit an empty batch, they can use this to progress the
585
+ // delayed inbox without providing extra batch data
586
+ if (data.length > 0) {
587
+ // The first data byte cannot be the same as any that have been set via other methods (eg 4844 blob header) as this
588
+ // would allow the supplier of the data to spoof an incorrect 4844 data batch
589
+ if (!isValidCallDataFlag(data[0])) revert InvalidHeaderFlag(data[0]);
590
+
591
+ // the first byte is used to identify the type of batch data
592
+ // das batches expect to have the type byte set, followed by the keyset (so they should have at least 33 bytes)
593
+ // if invalid data is supplied here the state transition function will process it as an empty block
594
+ // however we can provide a nice additional check here for the batch poster
595
+ if (data[0] & DAS_MESSAGE_HEADER_FLAG != 0 && data.length >= 33) {
596
+ // we skip the first byte, then read the next 32 bytes for the keyset
597
+ bytes32 dasKeysetHash = bytes32(data[1:33]);
598
+ if (!dasKeySetInfo[dasKeysetHash].isValidKeyset) revert NoSuchKeyset(dasKeysetHash);
599
+ }
600
+ }
601
+ return (keccak256(bytes.concat(header, data)), timeBounds);
602
+ }
603
+
604
+ /// @dev Form a hash of the data being provided in 4844 data blobs
605
+ /// @param afterDelayedMessagesRead The delayed messages count read up to
606
+ /// @return The data hash
607
+ /// @return The timebounds within which the message should be processed
608
+ /// @return The normalized amount of gas used for blob posting
609
+ function formBlobDataHash(uint256 afterDelayedMessagesRead)
610
+ internal
611
+ view
612
+ returns (
613
+ bytes32,
614
+ IBridge.TimeBounds memory,
615
+ uint256
616
+ )
617
+ {
618
+ bytes32[] memory dataHashes = reader4844.getDataHashes();
619
+ if (dataHashes.length == 0) revert MissingDataHashes();
620
+
621
+ (bytes memory header, IBridge.TimeBounds memory timeBounds) = packHeader(
622
+ afterDelayedMessagesRead
623
+ );
624
+
625
+ uint256 blobCost = reader4844.getBlobBaseFee() * GAS_PER_BLOB * dataHashes.length;
626
+ return (
627
+ keccak256(bytes.concat(header, DATA_BLOB_HEADER_FLAG, abi.encodePacked(dataHashes))),
628
+ timeBounds,
629
+ block.basefee > 0 ? blobCost / block.basefee : 0
630
+ );
631
+ }
632
+
633
+ /// @dev Submit a batch spending report message so that the batch poster can be reimbursed on the rollup
634
+ /// This function expect msg.sender is tx.origin, and will always record tx.origin as the spender
635
+ /// @param dataHash The hash of the message the spending report is being submitted for
636
+ /// @param seqMessageIndex The index of the message to submit the spending report for
637
+ /// @param gasPrice The gas price that was paid for the data (standard gas or data gas)
638
+ function submitBatchSpendingReport(
639
+ bytes32 dataHash,
640
+ uint256 seqMessageIndex,
641
+ uint256 gasPrice,
642
+ uint256 extraGas
643
+ ) internal {
644
+ // report the account who paid the gas (tx.origin) for the tx as batch poster
645
+ // if msg.sender is used and is a contract, it might not be able to spend the refund on l2
646
+ // solhint-disable-next-line avoid-tx-origin
647
+ address batchPoster = tx.origin;
648
+
649
+ // this msg isn't included in the current sequencer batch, but instead added to
650
+ // the delayed messages queue that is yet to be included
651
+ if (hostChainIsArbitrum) {
652
+ // Include extra gas for the host chain's L1 gas charging
653
+ uint256 l1Fees = ArbGasInfo(address(0x6c)).getCurrentTxL1GasFees();
654
+ extraGas += l1Fees / block.basefee;
655
+ }
656
+ require(extraGas <= type(uint64).max, "EXTRA_GAS_NOT_UINT64");
657
+ bytes memory spendingReportMsg = abi.encodePacked(
658
+ block.timestamp,
659
+ batchPoster,
660
+ dataHash,
661
+ seqMessageIndex,
662
+ gasPrice,
663
+ uint64(extraGas)
664
+ );
665
+
666
+ uint256 msgNum = bridge.submitBatchSpendingReport(
667
+ batchPoster,
668
+ keccak256(spendingReportMsg)
669
+ );
670
+ // this is the same event used by Inbox.sol after including a message to the delayed message accumulator
671
+ emit InboxMessageDelivered(msgNum, spendingReportMsg);
377
672
  }
378
673
 
379
674
  function addSequencerL2BatchImpl(
@@ -403,39 +698,9 @@ contract SequencerInbox is DelegateCallAware, GasRefundEnabled, ISequencerInbox
403
698
 
404
699
  totalDelayedMessagesRead = afterDelayedMessagesRead;
405
700
 
406
- if (calldataLengthPosted > 0) {
407
- // this msg isn't included in the current sequencer batch, but instead added to
408
- // the delayed messages queue that is yet to be included
409
- address batchPoster = msg.sender;
410
- bytes memory spendingReportMsg;
411
- if (hostChainIsArbitrum) {
412
- // Include extra gas for the host chain's L1 gas charging
413
- uint256 l1Fees = ArbGasInfo(address(0x6c)).getCurrentTxL1GasFees();
414
- uint256 extraGas = l1Fees / block.basefee;
415
- require(extraGas <= type(uint64).max, "L1_GAS_NOT_UINT64");
416
- spendingReportMsg = abi.encodePacked(
417
- block.timestamp,
418
- batchPoster,
419
- dataHash,
420
- seqMessageIndex,
421
- block.basefee,
422
- uint64(extraGas)
423
- );
424
- } else {
425
- spendingReportMsg = abi.encodePacked(
426
- block.timestamp,
427
- batchPoster,
428
- dataHash,
429
- seqMessageIndex,
430
- block.basefee
431
- );
432
- }
433
- uint256 msgNum = bridge.submitBatchSpendingReport(
434
- batchPoster,
435
- keccak256(spendingReportMsg)
436
- );
437
- // this is the same event used by Inbox.sol after including a message to the delayed message accumulator
438
- emit InboxMessageDelivered(msgNum, spendingReportMsg);
701
+ if (calldataLengthPosted > 0 && !isUsingFeeToken) {
702
+ // only report batch poster spendings if chain is using ETH as native currency
703
+ submitBatchSpendingReport(dataHash, seqMessageIndex, block.basefee, 0);
439
704
  }
440
705
  }
441
706
 
@@ -447,17 +712,37 @@ contract SequencerInbox is DelegateCallAware, GasRefundEnabled, ISequencerInbox
447
712
  return bridge.sequencerMessageCount();
448
713
  }
449
714
 
715
+ function _setMaxTimeVariation(ISequencerInbox.MaxTimeVariation memory maxTimeVariation_)
716
+ internal
717
+ {
718
+ if (
719
+ maxTimeVariation_.delayBlocks > type(uint64).max ||
720
+ maxTimeVariation_.futureBlocks > type(uint64).max ||
721
+ maxTimeVariation_.delaySeconds > type(uint64).max ||
722
+ maxTimeVariation_.futureSeconds > type(uint64).max
723
+ ) {
724
+ revert BadMaxTimeVariation();
725
+ }
726
+ delayBlocks = uint64(maxTimeVariation_.delayBlocks);
727
+ futureBlocks = uint64(maxTimeVariation_.futureBlocks);
728
+ delaySeconds = uint64(maxTimeVariation_.delaySeconds);
729
+ futureSeconds = uint64(maxTimeVariation_.futureSeconds);
730
+ }
731
+
450
732
  /// @inheritdoc ISequencerInbox
451
733
  function setMaxTimeVariation(ISequencerInbox.MaxTimeVariation memory maxTimeVariation_)
452
734
  external
453
735
  onlyRollupOwner
454
736
  {
455
- maxTimeVariation = maxTimeVariation_;
737
+ _setMaxTimeVariation(maxTimeVariation_);
456
738
  emit OwnerFunctionCalled(0);
457
739
  }
458
740
 
459
741
  /// @inheritdoc ISequencerInbox
460
- function setIsBatchPoster(address addr, bool isBatchPoster_) external onlyRollupOwner {
742
+ function setIsBatchPoster(address addr, bool isBatchPoster_)
743
+ external
744
+ onlyRollupOwnerOrBatchPosterManager
745
+ {
461
746
  isBatchPoster[addr] = isBatchPoster_;
462
747
  emit OwnerFunctionCalled(1);
463
748
  }
@@ -493,9 +778,18 @@ contract SequencerInbox is DelegateCallAware, GasRefundEnabled, ISequencerInbox
493
778
  }
494
779
 
495
780
  /// @inheritdoc ISequencerInbox
496
- function setIsSequencer(address addr, bool isSequencer_) external onlyRollupOwner {
781
+ function setIsSequencer(address addr, bool isSequencer_)
782
+ external
783
+ onlyRollupOwnerOrBatchPosterManager
784
+ {
497
785
  isSequencer[addr] = isSequencer_;
498
- emit OwnerFunctionCalled(4);
786
+ emit OwnerFunctionCalled(4); // Owner in this context can also be batch poster manager
787
+ }
788
+
789
+ /// @inheritdoc ISequencerInbox
790
+ function setBatchPosterManager(address newBatchPosterManager) external onlyRollupOwner {
791
+ batchPosterManager = newBatchPosterManager;
792
+ emit OwnerFunctionCalled(5);
499
793
  }
500
794
 
501
795
  function isValidKeysetHash(bytes32 ksHash) external view returns (bool) {