@arbitrum/nitro-contracts 1.2.1 → 2.0.0-beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (300) hide show
  1. package/README.md +1 -1
  2. package/build/contracts/@openzeppelin/contracts/access/Ownable.sol/Ownable.dbg.json +1 -1
  3. package/build/contracts/@openzeppelin/contracts/interfaces/draft-IERC1822.sol/IERC1822Proxiable.dbg.json +1 -1
  4. package/build/contracts/@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol/ERC1967Proxy.dbg.json +1 -1
  5. package/build/contracts/@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol/ERC1967Upgrade.dbg.json +1 -1
  6. package/build/contracts/@openzeppelin/contracts/proxy/Proxy.sol/Proxy.dbg.json +1 -1
  7. package/build/contracts/@openzeppelin/contracts/proxy/beacon/IBeacon.sol/IBeacon.dbg.json +1 -1
  8. package/build/contracts/@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol/UpgradeableBeacon.dbg.json +1 -1
  9. package/build/contracts/@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol/ProxyAdmin.dbg.json +1 -1
  10. package/build/contracts/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol/TransparentUpgradeableProxy.dbg.json +1 -1
  11. package/build/contracts/@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol/UUPSUpgradeable.dbg.json +1 -1
  12. package/build/contracts/@openzeppelin/contracts/security/ReentrancyGuard.sol/ReentrancyGuard.dbg.json +1 -1
  13. package/build/contracts/@openzeppelin/contracts/token/ERC20/ERC20.sol/ERC20.dbg.json +1 -1
  14. package/build/contracts/@openzeppelin/contracts/token/ERC20/IERC20.sol/IERC20.dbg.json +1 -1
  15. package/build/contracts/@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol/IERC20Metadata.dbg.json +1 -1
  16. package/build/contracts/@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol/SafeERC20.dbg.json +1 -1
  17. package/build/contracts/@openzeppelin/contracts/utils/Address.sol/Address.dbg.json +1 -1
  18. package/build/contracts/@openzeppelin/contracts/utils/Context.sol/Context.dbg.json +1 -1
  19. package/build/contracts/@openzeppelin/contracts/utils/StorageSlot.sol/StorageSlot.dbg.json +1 -1
  20. package/build/contracts/@openzeppelin/contracts/utils/Strings.sol/Strings.dbg.json +4 -0
  21. package/build/contracts/@openzeppelin/contracts/utils/Strings.sol/Strings.json +10 -0
  22. package/build/contracts/@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol/AccessControlUpgradeable.dbg.json +1 -1
  23. package/build/contracts/@openzeppelin/contracts-upgradeable/access/IAccessControlUpgradeable.sol/IAccessControlUpgradeable.dbg.json +1 -1
  24. package/build/contracts/@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol/OwnableUpgradeable.dbg.json +1 -1
  25. package/build/contracts/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol/Initializable.dbg.json +1 -1
  26. package/build/contracts/@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol/PausableUpgradeable.dbg.json +1 -1
  27. package/build/contracts/@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol/IERC20Upgradeable.dbg.json +1 -1
  28. package/build/contracts/@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol/AddressUpgradeable.dbg.json +1 -1
  29. package/build/contracts/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol/ContextUpgradeable.dbg.json +1 -1
  30. package/build/contracts/@openzeppelin/contracts-upgradeable/utils/StorageSlotUpgradeable.sol/StorageSlotUpgradeable.dbg.json +1 -1
  31. package/build/contracts/@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol/StringsUpgradeable.dbg.json +1 -1
  32. package/build/contracts/@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol/ERC165Upgradeable.dbg.json +1 -1
  33. package/build/contracts/@openzeppelin/contracts-upgradeable/utils/introspection/IERC165Upgradeable.sol/IERC165Upgradeable.dbg.json +1 -1
  34. package/build/contracts/src/bridge/AbsBridge.sol/AbsBridge.dbg.json +1 -1
  35. package/build/contracts/src/bridge/AbsInbox.sol/AbsInbox.dbg.json +1 -1
  36. package/build/contracts/src/bridge/AbsOutbox.sol/AbsOutbox.dbg.json +1 -1
  37. package/build/contracts/src/bridge/Bridge.sol/Bridge.dbg.json +1 -1
  38. package/build/contracts/src/bridge/Bridge.sol/Bridge.json +2 -2
  39. package/build/contracts/src/bridge/ERC20Bridge.sol/ERC20Bridge.dbg.json +1 -1
  40. package/build/contracts/src/bridge/ERC20Bridge.sol/ERC20Bridge.json +26 -2
  41. package/build/contracts/src/bridge/ERC20Inbox.sol/ERC20Inbox.dbg.json +1 -1
  42. package/build/contracts/src/bridge/ERC20Inbox.sol/ERC20Inbox.json +13 -2
  43. package/build/contracts/src/bridge/ERC20Outbox.sol/ERC20Outbox.dbg.json +1 -1
  44. package/build/contracts/src/bridge/ERC20Outbox.sol/ERC20Outbox.json +2 -2
  45. package/build/contracts/src/bridge/GasRefunder.sol/GasRefunder.dbg.json +1 -1
  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/IERC20Bridge.sol/IERC20Bridge.json +13 -0
  50. package/build/contracts/src/bridge/IERC20Inbox.sol/IERC20Inbox.dbg.json +1 -1
  51. package/build/contracts/src/bridge/IEthBridge.sol/IEthBridge.dbg.json +1 -1
  52. package/build/contracts/src/bridge/IInbox.sol/IInbox.dbg.json +1 -1
  53. package/build/contracts/src/bridge/IInboxBase.sol/IInboxBase.dbg.json +1 -1
  54. package/build/contracts/src/bridge/IOutbox.sol/IOutbox.dbg.json +1 -1
  55. package/build/contracts/src/bridge/IOwnable.sol/IOwnable.dbg.json +1 -1
  56. package/build/contracts/src/bridge/ISequencerInbox.sol/ISequencerInbox.dbg.json +1 -1
  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 +2 -2
  64. package/build/contracts/src/chain/CacheManager.sol/CacheManager.dbg.json +4 -0
  65. package/build/contracts/src/chain/CacheManager.sol/CacheManager.json +517 -0
  66. package/build/contracts/src/challenge/ChallengeLib.sol/ChallengeLib.dbg.json +1 -1
  67. package/build/contracts/src/challenge/ChallengeLib.sol/ChallengeLib.json +2 -2
  68. package/build/contracts/src/challenge/ChallengeManager.sol/ChallengeManager.dbg.json +1 -1
  69. package/build/contracts/src/challenge/ChallengeManager.sol/ChallengeManager.json +50 -2
  70. package/build/contracts/src/challenge/IChallengeManager.sol/IChallengeManager.dbg.json +1 -1
  71. package/build/contracts/src/challenge/IChallengeManager.sol/IChallengeManager.json +55 -0
  72. package/build/contracts/src/challenge/IChallengeResultReceiver.sol/IChallengeResultReceiver.dbg.json +1 -1
  73. package/build/contracts/src/libraries/AddressAliasHelper.sol/AddressAliasHelper.dbg.json +1 -1
  74. package/build/contracts/src/libraries/AdminFallbackProxy.sol/AdminFallbackProxy.dbg.json +1 -1
  75. package/build/contracts/src/libraries/AdminFallbackProxy.sol/DoubleLogicERC1967Upgrade.dbg.json +1 -1
  76. package/build/contracts/src/libraries/ArbitrumChecker.sol/ArbitrumChecker.dbg.json +1 -1
  77. package/build/contracts/src/libraries/CryptographyPrimitives.sol/CryptographyPrimitives.dbg.json +1 -1
  78. package/build/contracts/src/libraries/DecimalsConverterHelper.sol/DecimalsConverterHelper.dbg.json +4 -0
  79. package/build/contracts/src/libraries/DecimalsConverterHelper.sol/DecimalsConverterHelper.json +10 -0
  80. package/build/contracts/src/libraries/DelegateCallAware.sol/DelegateCallAware.dbg.json +1 -1
  81. package/build/contracts/src/libraries/DoubleLogicUUPSUpgradeable.sol/DoubleLogicUUPSUpgradeable.dbg.json +1 -1
  82. package/build/contracts/src/libraries/GasRefundEnabled.sol/GasRefundEnabled.dbg.json +1 -1
  83. package/build/contracts/src/libraries/IGasRefunder.sol/IGasRefunder.dbg.json +1 -1
  84. package/build/contracts/src/libraries/IReader4844.sol/IReader4844.dbg.json +1 -1
  85. package/build/contracts/src/libraries/MerkleLib.sol/MerkleLib.dbg.json +1 -1
  86. package/build/contracts/src/libraries/MerkleLib.sol/MerkleLib.json +2 -2
  87. package/build/contracts/src/libraries/UUPSNotUpgradeable.sol/UUPSNotUpgradeable.dbg.json +1 -1
  88. package/build/contracts/src/mocks/Benchmarks.sol/Benchmarks.dbg.json +4 -0
  89. package/build/contracts/src/mocks/Benchmarks.sol/Benchmarks.json +46 -0
  90. package/build/contracts/src/mocks/BridgeStub.sol/BridgeStub.dbg.json +1 -1
  91. package/build/contracts/src/mocks/BridgeStub.sol/BridgeStub.json +28 -2
  92. package/build/contracts/src/mocks/BridgeUnproxied.sol/BridgeUnproxied.dbg.json +1 -1
  93. package/build/contracts/src/mocks/BridgeUnproxied.sol/BridgeUnproxied.json +2 -2
  94. package/build/contracts/src/mocks/InboxStub.sol/InboxStub.dbg.json +1 -1
  95. package/build/contracts/src/mocks/InboxStub.sol/InboxStub.json +2 -2
  96. package/build/contracts/src/mocks/MockResultReceiver.sol/MockResultReceiver.dbg.json +1 -1
  97. package/build/contracts/src/mocks/MockResultReceiver.sol/MockResultReceiver.json +2 -2
  98. package/build/contracts/src/mocks/MultiCallTest.sol/MultiCallTest.dbg.json +4 -0
  99. package/build/contracts/src/mocks/MultiCallTest.sol/MultiCallTest.json +71 -0
  100. package/build/contracts/src/mocks/PendingBlkTimeAndNrAdvanceCheck.sol/PendingBlkTimeAndNrAdvanceCheck.dbg.json +4 -0
  101. package/build/contracts/src/mocks/PendingBlkTimeAndNrAdvanceCheck.sol/PendingBlkTimeAndNrAdvanceCheck.json +36 -0
  102. package/build/contracts/src/mocks/Program.sol/ProgramTest.dbg.json +4 -0
  103. package/build/contracts/src/mocks/Program.sol/ProgramTest.json +142 -0
  104. package/build/contracts/src/mocks/ProxyAdminForBinding.sol/ProxyAdminForBinding.dbg.json +1 -1
  105. package/build/contracts/src/mocks/SdkStorage.sol/SdkStorage.dbg.json +4 -0
  106. package/build/contracts/src/mocks/SdkStorage.sol/SdkStorage.json +25 -0
  107. package/build/contracts/src/mocks/SequencerInboxStub.sol/SequencerInboxStub.dbg.json +1 -1
  108. package/build/contracts/src/mocks/SequencerInboxStub.sol/SequencerInboxStub.json +2 -2
  109. package/build/contracts/src/mocks/Simple.sol/Simple.dbg.json +1 -1
  110. package/build/contracts/src/mocks/SimpleCacheManager.sol/SimpleCacheManager.dbg.json +4 -0
  111. package/build/contracts/src/mocks/SimpleCacheManager.sol/SimpleCacheManager.json +37 -0
  112. package/build/contracts/src/mocks/SimpleProxy.sol/SimpleProxy.dbg.json +1 -1
  113. package/build/contracts/src/mocks/SingleExecutionChallenge.sol/SingleExecutionChallenge.dbg.json +1 -1
  114. package/build/contracts/src/mocks/SingleExecutionChallenge.sol/SingleExecutionChallenge.json +50 -2
  115. package/build/contracts/src/mocks/TimedOutChallengeManager.sol/TimedOutChallengeManager.dbg.json +1 -1
  116. package/build/contracts/src/mocks/TimedOutChallengeManager.sol/TimedOutChallengeManager.json +50 -2
  117. package/build/contracts/src/mocks/UpgradeExecutorMock.sol/UpgradeExecutorMock.dbg.json +1 -1
  118. package/build/contracts/src/node-interface/NodeInterface.sol/NodeInterface.dbg.json +1 -1
  119. package/build/contracts/src/node-interface/NodeInterfaceDebug.sol/NodeInterfaceDebug.dbg.json +1 -1
  120. package/build/contracts/src/osp/HashProofHelper.sol/HashProofHelper.dbg.json +1 -1
  121. package/build/contracts/src/osp/IOneStepProofEntry.sol/IOneStepProofEntry.dbg.json +1 -1
  122. package/build/contracts/src/osp/IOneStepProofEntry.sol/IOneStepProofEntry.json +48 -0
  123. package/build/contracts/src/osp/IOneStepProofEntry.sol/OneStepProofEntryLib.dbg.json +1 -1
  124. package/build/contracts/src/osp/IOneStepProofEntry.sol/OneStepProofEntryLib.json +2 -2
  125. package/build/contracts/src/osp/IOneStepProver.sol/IOneStepProver.dbg.json +1 -1
  126. package/build/contracts/src/osp/IOneStepProver.sol/IOneStepProver.json +88 -0
  127. package/build/contracts/src/osp/OneStepProofEntry.sol/OneStepProofEntry.dbg.json +1 -1
  128. package/build/contracts/src/osp/OneStepProofEntry.sol/OneStepProofEntry.json +50 -2
  129. package/build/contracts/src/osp/OneStepProver0.sol/OneStepProver0.dbg.json +1 -1
  130. package/build/contracts/src/osp/OneStepProver0.sol/OneStepProver0.json +90 -2
  131. package/build/contracts/src/osp/OneStepProverHostIo.sol/OneStepProverHostIo.dbg.json +1 -1
  132. package/build/contracts/src/osp/OneStepProverHostIo.sol/OneStepProverHostIo.json +90 -2
  133. package/build/contracts/src/osp/OneStepProverMath.sol/OneStepProverMath.dbg.json +1 -1
  134. package/build/contracts/src/osp/OneStepProverMath.sol/OneStepProverMath.json +90 -2
  135. package/build/contracts/src/osp/OneStepProverMemory.sol/OneStepProverMemory.dbg.json +1 -1
  136. package/build/contracts/src/osp/OneStepProverMemory.sol/OneStepProverMemory.json +90 -2
  137. package/build/contracts/src/precompiles/ArbAddressTable.sol/ArbAddressTable.dbg.json +1 -1
  138. package/build/contracts/src/precompiles/ArbAggregator.sol/ArbAggregator.dbg.json +1 -1
  139. package/build/contracts/src/precompiles/ArbBLS.sol/ArbBLS.dbg.json +1 -1
  140. package/build/contracts/src/precompiles/ArbDebug.sol/ArbDebug.dbg.json +1 -1
  141. package/build/contracts/src/precompiles/ArbDebug.sol/ArbDebug.json +7 -0
  142. package/build/contracts/src/precompiles/ArbFunctionTable.sol/ArbFunctionTable.dbg.json +1 -1
  143. package/build/contracts/src/precompiles/ArbGasInfo.sol/ArbGasInfo.dbg.json +1 -1
  144. package/build/contracts/src/precompiles/ArbInfo.sol/ArbInfo.dbg.json +1 -1
  145. package/build/contracts/src/precompiles/ArbOwner.sol/ArbOwner.dbg.json +1 -1
  146. package/build/contracts/src/precompiles/ArbOwner.sol/ArbOwner.json +161 -0
  147. package/build/contracts/src/precompiles/ArbOwnerPublic.sol/ArbOwnerPublic.dbg.json +1 -1
  148. package/build/contracts/src/precompiles/ArbRetryableTx.sol/ArbRetryableTx.dbg.json +1 -1
  149. package/build/contracts/src/precompiles/ArbStatistics.sol/ArbStatistics.dbg.json +1 -1
  150. package/build/contracts/src/precompiles/ArbSys.sol/ArbSys.dbg.json +1 -1
  151. package/build/contracts/src/precompiles/ArbWasm.sol/ArbWasm.dbg.json +4 -0
  152. package/build/contracts/src/precompiles/ArbWasm.sol/ArbWasm.json +453 -0
  153. package/build/contracts/src/precompiles/ArbWasmCache.sol/ArbWasmCache.dbg.json +4 -0
  154. package/build/contracts/src/precompiles/ArbWasmCache.sol/ArbWasmCache.json +126 -0
  155. package/build/contracts/src/precompiles/ArbosActs.sol/ArbosActs.dbg.json +1 -1
  156. package/build/contracts/src/precompiles/ArbosTest.sol/ArbosTest.dbg.json +1 -1
  157. package/build/contracts/src/rollup/AbsRollupEventInbox.sol/AbsRollupEventInbox.dbg.json +1 -1
  158. package/build/contracts/src/rollup/BridgeCreator.sol/BridgeCreator.dbg.json +1 -1
  159. package/build/contracts/src/rollup/BridgeCreator.sol/BridgeCreator.json +2 -2
  160. package/build/contracts/src/rollup/DeployHelper.sol/DeployHelper.dbg.json +1 -1
  161. package/build/contracts/src/rollup/DeployHelper.sol/DeployHelper.json +2 -2
  162. package/build/contracts/src/rollup/ERC20RollupEventInbox.sol/ERC20RollupEventInbox.dbg.json +1 -1
  163. package/build/contracts/src/rollup/ERC20RollupEventInbox.sol/ERC20RollupEventInbox.json +2 -2
  164. package/build/contracts/src/rollup/FactoryDeployerHelper.sol/FactoryDeployerHelper.dbg.json +4 -0
  165. package/build/contracts/src/rollup/FactoryDeployerHelper.sol/FactoryDeployerHelper.json +68 -0
  166. package/build/contracts/src/rollup/FactoryDeployerHelper.sol/IDeployHelper.dbg.json +4 -0
  167. package/build/contracts/src/rollup/FactoryDeployerHelper.sol/IDeployHelper.json +58 -0
  168. package/build/contracts/src/rollup/FactoryDeployerHelper.sol/IERC20.dbg.json +4 -0
  169. package/build/contracts/src/rollup/FactoryDeployerHelper.sol/IERC20.json +40 -0
  170. package/build/contracts/src/rollup/FactoryDeployerHelper.sol/IERC20Bridge.dbg.json +4 -0
  171. package/build/contracts/src/rollup/FactoryDeployerHelper.sol/IERC20Bridge.json +24 -0
  172. package/build/contracts/src/rollup/FactoryDeployerHelper.sol/IInboxBase.dbg.json +4 -0
  173. package/build/contracts/src/rollup/FactoryDeployerHelper.sol/IInboxBase.json +24 -0
  174. package/build/contracts/src/rollup/IRollupAdmin.sol/IRollupAdmin.dbg.json +1 -1
  175. package/build/contracts/src/rollup/IRollupCore.sol/IRollupCore.dbg.json +1 -1
  176. package/build/contracts/src/rollup/IRollupEventInbox.sol/IRollupEventInbox.dbg.json +1 -1
  177. package/build/contracts/src/rollup/IRollupLogic.sol/IRollupUser.dbg.json +1 -1
  178. package/build/contracts/src/rollup/IRollupLogic.sol/IRollupUser.json +18 -0
  179. package/build/contracts/src/rollup/IRollupLogic.sol/IRollupUserAbs.dbg.json +1 -1
  180. package/build/contracts/src/rollup/IRollupLogic.sol/IRollupUserAbs.json +18 -0
  181. package/build/contracts/src/rollup/IRollupLogic.sol/IRollupUserERC20.dbg.json +1 -1
  182. package/build/contracts/src/rollup/IRollupLogic.sol/IRollupUserERC20.json +18 -0
  183. package/build/contracts/src/rollup/Node.sol/NodeLib.dbg.json +1 -1
  184. package/build/contracts/src/rollup/Node.sol/NodeLib.json +2 -2
  185. package/build/contracts/src/rollup/RollupAdminLogic.sol/RollupAdminLogic.dbg.json +1 -1
  186. package/build/contracts/src/rollup/RollupAdminLogic.sol/RollupAdminLogic.json +28 -2
  187. package/build/contracts/src/rollup/RollupCore.sol/RollupCore.dbg.json +1 -1
  188. package/build/contracts/src/rollup/RollupCore.sol/RollupCore.json +13 -0
  189. package/build/contracts/src/rollup/RollupCreator.sol/RollupCreator.dbg.json +1 -1
  190. package/build/contracts/src/rollup/RollupCreator.sol/RollupCreator.json +2 -2
  191. package/build/contracts/src/rollup/RollupEventInbox.sol/RollupEventInbox.dbg.json +1 -1
  192. package/build/contracts/src/rollup/RollupEventInbox.sol/RollupEventInbox.json +2 -2
  193. package/build/contracts/src/rollup/RollupLib.sol/RollupLib.dbg.json +1 -1
  194. package/build/contracts/src/rollup/RollupLib.sol/RollupLib.json +2 -2
  195. package/build/contracts/src/rollup/RollupProxy.sol/RollupProxy.dbg.json +1 -1
  196. package/build/contracts/src/rollup/RollupProxy.sol/RollupProxy.json +2 -2
  197. package/build/contracts/src/rollup/RollupUserLogic.sol/AbsRollupUserLogic.dbg.json +1 -1
  198. package/build/contracts/src/rollup/RollupUserLogic.sol/AbsRollupUserLogic.json +31 -0
  199. package/build/contracts/src/rollup/RollupUserLogic.sol/ERC20RollupUserLogic.dbg.json +1 -1
  200. package/build/contracts/src/rollup/RollupUserLogic.sol/ERC20RollupUserLogic.json +33 -2
  201. package/build/contracts/src/rollup/RollupUserLogic.sol/RollupUserLogic.dbg.json +1 -1
  202. package/build/contracts/src/rollup/RollupUserLogic.sol/RollupUserLogic.json +33 -2
  203. package/build/contracts/src/rollup/ValidatorUtils.sol/ValidatorUtils.dbg.json +1 -1
  204. package/build/contracts/src/rollup/ValidatorUtils.sol/ValidatorUtils.json +2 -2
  205. package/build/contracts/src/rollup/ValidatorWallet.sol/ValidatorWallet.dbg.json +1 -1
  206. package/build/contracts/src/rollup/ValidatorWallet.sol/ValidatorWallet.json +2 -2
  207. package/build/contracts/src/rollup/ValidatorWalletCreator.sol/ValidatorWalletCreator.dbg.json +1 -1
  208. package/build/contracts/src/rollup/ValidatorWalletCreator.sol/ValidatorWalletCreator.json +2 -2
  209. package/build/contracts/src/state/Deserialize.sol/Deserialize.dbg.json +1 -1
  210. package/build/contracts/src/state/Deserialize.sol/Deserialize.json +2 -2
  211. package/build/contracts/src/state/GlobalState.sol/GlobalStateLib.dbg.json +1 -1
  212. package/build/contracts/src/state/Instructions.sol/Instructions.dbg.json +1 -1
  213. package/build/contracts/src/state/Instructions.sol/Instructions.json +2 -2
  214. package/build/contracts/src/state/Machine.sol/MachineLib.dbg.json +1 -1
  215. package/build/contracts/src/state/Machine.sol/MachineLib.json +2 -2
  216. package/build/contracts/src/state/MerkleProof.sol/MerkleProofLib.dbg.json +1 -1
  217. package/build/contracts/src/state/MerkleProof.sol/MerkleProofLib.json +2 -2
  218. package/build/contracts/src/state/Module.sol/ModuleLib.dbg.json +1 -1
  219. package/build/contracts/src/state/Module.sol/ModuleLib.json +2 -2
  220. package/build/contracts/src/state/ModuleMemory.sol/ModuleMemoryLib.dbg.json +1 -1
  221. package/build/contracts/src/state/ModuleMemory.sol/ModuleMemoryLib.json +2 -2
  222. package/build/contracts/src/state/ModuleMemoryCompact.sol/ModuleMemoryCompactLib.dbg.json +1 -1
  223. package/build/contracts/src/state/MultiStack.sol/MultiStackLib.dbg.json +4 -0
  224. package/build/contracts/src/state/MultiStack.sol/MultiStackLib.json +10 -0
  225. package/build/contracts/src/state/PcArray.sol/PcArrayLib.dbg.json +1 -1
  226. package/build/contracts/src/state/StackFrame.sol/StackFrameLib.dbg.json +1 -1
  227. package/build/contracts/src/state/StackFrame.sol/StackFrameLib.json +2 -2
  228. package/build/contracts/src/state/Value.sol/ValueLib.dbg.json +1 -1
  229. package/build/contracts/src/state/Value.sol/ValueLib.json +2 -2
  230. package/build/contracts/src/state/ValueArray.sol/ValueArrayLib.dbg.json +1 -1
  231. package/build/contracts/src/state/ValueArray.sol/ValueArrayLib.json +2 -2
  232. package/build/contracts/src/state/ValueStack.sol/ValueStackLib.dbg.json +1 -1
  233. package/build/contracts/src/state/ValueStack.sol/ValueStackLib.json +2 -2
  234. package/build/contracts/src/test-helpers/BridgeTester.sol/BridgeTester.dbg.json +1 -1
  235. package/build/contracts/src/test-helpers/BridgeTester.sol/BridgeTester.json +28 -2
  236. package/build/contracts/src/test-helpers/CryptographyPrimitivesTester.sol/CryptographyPrimitivesTester.dbg.json +1 -1
  237. package/build/contracts/src/test-helpers/EthVault.sol/EthVault.dbg.json +1 -1
  238. package/build/contracts/src/test-helpers/MessageTester.sol/MessageTester.dbg.json +1 -1
  239. package/build/contracts/src/test-helpers/OutboxWithoutOptTester.sol/OutboxWithoutOptTester.dbg.json +1 -1
  240. package/build/contracts/src/test-helpers/OutboxWithoutOptTester.sol/OutboxWithoutOptTester.json +2 -2
  241. package/build/contracts/src/test-helpers/RollupMock.sol/RollupMock.dbg.json +1 -1
  242. package/build/contracts/src/test-helpers/TestToken.sol/TestToken.dbg.json +1 -1
  243. package/build/contracts/src/test-helpers/ValueArrayTester.sol/ValueArrayTester.dbg.json +1 -1
  244. package/build/contracts/src/test-helpers/ValueArrayTester.sol/ValueArrayTester.json +2 -2
  245. package/package.json +17 -8
  246. package/src/bridge/AbsInbox.sol +16 -4
  247. package/src/bridge/AbsOutbox.sol +11 -2
  248. package/src/bridge/ERC20Bridge.sol +30 -3
  249. package/src/bridge/ERC20Inbox.sol +28 -4
  250. package/src/bridge/ERC20Outbox.sol +10 -1
  251. package/src/bridge/IERC20Bridge.sol +7 -0
  252. package/src/bridge/IERC20Inbox.sol +4 -3
  253. package/src/bridge/IInbox.sol +3 -3
  254. package/src/bridge/Inbox.sol +6 -1
  255. package/src/bridge/Outbox.sol +5 -0
  256. package/src/chain/CacheManager.sol +293 -0
  257. package/src/challenge/ChallengeLib.sol +0 -45
  258. package/src/challenge/ChallengeManager.sol +24 -9
  259. package/src/challenge/IChallengeManager.sol +13 -0
  260. package/src/libraries/Constants.sol +11 -0
  261. package/src/libraries/DecimalsConverterHelper.sol +33 -0
  262. package/src/libraries/Error.sol +6 -0
  263. package/src/mocks/Benchmarks.sol +52 -0
  264. package/src/mocks/BridgeStub.sol +3 -0
  265. package/src/mocks/MultiCallTest.sol +117 -0
  266. package/src/mocks/PendingBlkTimeAndNrAdvanceCheck.sol +29 -0
  267. package/src/mocks/Program.sol +126 -0
  268. package/src/mocks/SdkStorage.sol +176 -0
  269. package/src/mocks/SimpleCacheManager.sol +22 -0
  270. package/src/node-interface/NodeInterface.sol +1 -1
  271. package/src/osp/IOneStepProofEntry.sol +10 -0
  272. package/src/osp/OneStepProofEntry.sol +81 -7
  273. package/src/osp/OneStepProver0.sol +64 -20
  274. package/src/osp/OneStepProverHostIo.sol +201 -2
  275. package/src/osp/OneStepProverMemory.sol +4 -33
  276. package/src/precompiles/ArbDebug.sol +2 -0
  277. package/src/precompiles/ArbOwner.sol +51 -9
  278. package/src/precompiles/ArbWasm.sol +119 -0
  279. package/src/precompiles/ArbWasmCache.sol +36 -0
  280. package/src/rollup/AbsRollupEventInbox.sol +3 -4
  281. package/src/rollup/DeployHelper.sol +22 -11
  282. package/src/rollup/ERC20RollupEventInbox.sol +5 -0
  283. package/src/rollup/FactoryDeployerHelper.sol +54 -0
  284. package/src/rollup/IRollupLogic.sol +2 -0
  285. package/src/rollup/RollupAdminLogic.sol +11 -0
  286. package/src/rollup/RollupCore.sol +1 -0
  287. package/src/rollup/RollupCreator.sol +49 -1
  288. package/src/rollup/RollupEventInbox.sol +8 -0
  289. package/src/rollup/RollupUserLogic.sol +35 -13
  290. package/src/state/Deserialize.sol +88 -47
  291. package/src/state/Instructions.sol +38 -3
  292. package/src/state/Machine.sol +92 -15
  293. package/src/state/MerkleProof.sol +22 -4
  294. package/src/state/Module.sol +3 -1
  295. package/src/state/ModuleMemory.sol +54 -0
  296. package/src/state/MultiStack.sol +58 -0
  297. package/src/state/StackFrame.sol +6 -1
  298. package/src/state/Value.sol +13 -1
  299. package/src/state/ValueStack.sol +6 -1
  300. package/src/test-helpers/BridgeTester.sol +3 -0
@@ -0,0 +1,293 @@
1
+ // Copyright 2022-2024, 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 "../precompiles/ArbOwnerPublic.sol";
8
+ import "../precompiles/ArbWasm.sol";
9
+ import "../precompiles/ArbWasmCache.sol";
10
+ import "../libraries/DelegateCallAware.sol";
11
+ import "solady/src/utils/MinHeapLib.sol";
12
+ import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
13
+
14
+ contract CacheManager is Initializable, DelegateCallAware {
15
+ using MinHeapLib for MinHeapLib.Heap;
16
+
17
+ ArbOwnerPublic internal constant ARB_OWNER_PUBLIC = ArbOwnerPublic(address(0x6b));
18
+ ArbWasm internal constant ARB_WASM = ArbWasm(address(0x71));
19
+ ArbWasmCache internal constant ARB_WASM_CACHE = ArbWasmCache(address(0x72));
20
+ uint64 internal constant MAX_MAKE_SPACE = 5 * 1024 * 1024;
21
+ uint64 internal constant MIN_CODESIZE = 4096;
22
+
23
+ MinHeapLib.Heap internal bids;
24
+ Entry[] public entries;
25
+
26
+ uint64 public cacheSize;
27
+ uint64 public queueSize;
28
+ uint64 public decay;
29
+ bool public isPaused;
30
+
31
+ error NotChainOwner(address sender);
32
+ error AsmTooLarge(uint256 asm, uint256 queueSize, uint256 cacheSize);
33
+ error AlreadyCached(bytes32 codehash);
34
+ error BidTooLarge(uint256 bid);
35
+ error BidTooSmall(uint192 bid, uint192 min);
36
+ error BidsArePaused();
37
+ error MakeSpaceTooLarge(uint64 size, uint64 limit);
38
+
39
+ event InsertBid(bytes32 indexed codehash, address program, uint192 bid, uint64 size);
40
+ event DeleteBid(bytes32 indexed codehash, uint192 bid, uint64 size);
41
+ event SetCacheSize(uint64 size);
42
+ event SetDecayRate(uint64 decay);
43
+ event Pause();
44
+ event Unpause();
45
+
46
+ struct Entry {
47
+ bytes32 code;
48
+ uint64 size;
49
+ uint192 bid;
50
+ }
51
+
52
+ function initialize(uint64 initCacheSize, uint64 initDecay) external initializer onlyDelegated {
53
+ cacheSize = initCacheSize;
54
+ decay = initDecay;
55
+ }
56
+
57
+ modifier onlyOwner() {
58
+ if (!ARB_OWNER_PUBLIC.isChainOwner(msg.sender)) {
59
+ revert NotChainOwner(msg.sender);
60
+ }
61
+ _;
62
+ }
63
+
64
+ /// @notice Sets the intended cache size. Note that the queue may temporarily be larger.
65
+ function setCacheSize(uint64 newSize) external onlyOwner {
66
+ cacheSize = newSize;
67
+ emit SetCacheSize(newSize);
68
+ }
69
+
70
+ /// @notice Sets the intended decay factor. Does not modify existing bids.
71
+ function setDecayRate(uint64 newDecay) external onlyOwner {
72
+ decay = newDecay;
73
+ emit SetDecayRate(newDecay);
74
+ }
75
+
76
+ /// @notice Disable new bids.
77
+ function paused() external onlyOwner {
78
+ isPaused = true;
79
+ emit Pause();
80
+ }
81
+
82
+ /// @notice Enable new bids.
83
+ function unpause() external onlyOwner {
84
+ isPaused = false;
85
+ emit Unpause();
86
+ }
87
+
88
+ /// @notice Evicts all programs in the cache.
89
+ function evictAll() external onlyOwner {
90
+ evictPrograms(type(uint256).max);
91
+ delete entries;
92
+ }
93
+
94
+ /// @notice Evicts up to `count` programs from the cache.
95
+ function evictPrograms(uint256 count) public onlyOwner {
96
+ while (bids.length() != 0 && count > 0) {
97
+ (uint192 bid, uint64 index) = _getBid(bids.pop());
98
+ _deleteEntry(bid, index);
99
+ count -= 1;
100
+ }
101
+ }
102
+
103
+ /// @notice Returns all entries in the cache. Might revert if the cache is too large.
104
+ function getEntries() external view returns (Entry[] memory) {
105
+ return entries;
106
+ }
107
+
108
+ /// @notice Returns the `k` smallest entries in the cache sorted in ascending order.
109
+ /// If the cache have less than `k` entries, returns all entries.
110
+ function getSmallestEntries(uint256 k) public view returns (Entry[] memory result) {
111
+ if (bids.length() < k) {
112
+ k = bids.length();
113
+ }
114
+ uint256[] memory kbids = bids.smallest(k);
115
+ result = new Entry[](kbids.length);
116
+ for (uint256 i = 0; i < kbids.length; i++) {
117
+ (, uint64 index) = _getBid(kbids[i]);
118
+ result[i] = entries[index];
119
+ }
120
+ }
121
+
122
+ /// @notice Returns the minimum bid required to cache a program of the given size.
123
+ /// Value returned here is the minimum bid that you can send with msg.value
124
+ function getMinBid(uint64 size) public view returns (uint192 min) {
125
+ if (size > cacheSize) {
126
+ revert AsmTooLarge(size, 0, cacheSize);
127
+ }
128
+
129
+ size = size >= MIN_CODESIZE ? size : MIN_CODESIZE;
130
+ uint256 totalSize = queueSize + size;
131
+ if (totalSize <= cacheSize) {
132
+ return 0;
133
+ }
134
+ uint256 needToFree = totalSize - cacheSize;
135
+
136
+ // size is at least MIN_CODESIZE, and vary no more than 10x right now, so we can safely assume
137
+ // for a given size, we need at most need to clear roundUp(size/MIN_CODESIZE) entries to make space
138
+ uint256 k = (needToFree + MIN_CODESIZE - 1) / MIN_CODESIZE;
139
+ Entry[] memory smallest = getSmallestEntries(k);
140
+ for (uint256 i = 0; i < smallest.length; i++) {
141
+ if (needToFree <= smallest[i].size) {
142
+ min = smallest[i].bid;
143
+ break;
144
+ }
145
+ needToFree -= smallest[i].size;
146
+ }
147
+ uint256 currentDecay = _calcDecay();
148
+ if (min < currentDecay) {
149
+ return 0;
150
+ }
151
+ min = min - uint192(currentDecay);
152
+ }
153
+
154
+ /// @notice Returns the minimum bid required to cache the program with given codehash.
155
+ /// Value returned here is the minimum bid that you can send with msg.value
156
+ function getMinBid(bytes32 codehash) public view returns (uint192 min) {
157
+ return getMinBid(_asmSize(codehash));
158
+ }
159
+
160
+ /// @notice Returns the minimum bid required to cache the program at given address.
161
+ /// Value returned here is the minimum bid that you can send with msg.value
162
+ function getMinBid(address program) external view returns (uint192 min) {
163
+ return getMinBid(program.codehash);
164
+ }
165
+
166
+ /// @notice Sends all revenue to the network fee account.
167
+ function sweepFunds() external {
168
+ (bool success, bytes memory data) = ARB_OWNER_PUBLIC.getNetworkFeeAccount().call{
169
+ value: address(this).balance
170
+ }("");
171
+ if (!success) {
172
+ assembly {
173
+ revert(add(data, 32), mload(data))
174
+ }
175
+ }
176
+ }
177
+
178
+ /// Places a bid, reverting if payment is insufficient.
179
+ function placeBid(address program) external payable {
180
+ if (isPaused) {
181
+ revert BidsArePaused();
182
+ }
183
+ bytes32 codehash = program.codehash;
184
+ if (_isCached(codehash)) {
185
+ revert AlreadyCached(codehash);
186
+ }
187
+
188
+ uint64 asm = _asmSize(codehash);
189
+ (uint192 bid, uint64 index) = _makeSpace(asm);
190
+ return _addBid(bid, program, codehash, asm, index);
191
+ }
192
+
193
+ /// @notice Evicts entries until enough space exists in the cache, reverting if payment is insufficient.
194
+ /// Returns the new amount of space available on success.
195
+ /// @dev Will revert for requests larger than 5Mb. Call repeatedly for more.
196
+ function makeSpace(uint64 size) external payable returns (uint64 space) {
197
+ if (isPaused) {
198
+ revert BidsArePaused();
199
+ }
200
+ if (size > MAX_MAKE_SPACE) {
201
+ revert MakeSpaceTooLarge(size, MAX_MAKE_SPACE);
202
+ }
203
+ _makeSpace(size);
204
+ return cacheSize - queueSize;
205
+ }
206
+
207
+ function _calcDecay() internal view returns (uint256) {
208
+ return block.timestamp * decay;
209
+ }
210
+
211
+ /// @dev Converts a value to a bid by adding the time decay term.
212
+ function _toBid(uint256 value) internal view returns (uint192 bid) {
213
+ uint256 _bid = value + _calcDecay();
214
+ if (_bid > type(uint192).max) {
215
+ revert BidTooLarge(_bid);
216
+ }
217
+ return uint192(_bid);
218
+ }
219
+
220
+ /// @dev Evicts entries until enough space exists in the cache, reverting if payment is insufficient.
221
+ /// Returns the bid and the index to use for insertion.
222
+ function _makeSpace(uint64 size) internal returns (uint192 bid, uint64 index) {
223
+ // discount historical bids by the number of seconds
224
+ bid = _toBid(msg.value);
225
+ index = uint64(entries.length);
226
+
227
+ uint192 min;
228
+ uint64 limit = cacheSize;
229
+ while (queueSize + size > limit) {
230
+ (min, index) = _getBid(bids.pop());
231
+ _deleteEntry(min, index);
232
+ }
233
+ // if the new bid equals to the minimum bid, a random entry with minimum bid will be evicted
234
+ if (bid < min) {
235
+ revert BidTooSmall(bid, min);
236
+ }
237
+ }
238
+
239
+ /// @dev Adds a bid
240
+ function _addBid(
241
+ uint192 bid,
242
+ address program,
243
+ bytes32 code,
244
+ uint64 size,
245
+ uint64 index
246
+ ) internal {
247
+ if (queueSize + size > cacheSize) {
248
+ revert AsmTooLarge(size, queueSize, cacheSize);
249
+ }
250
+
251
+ Entry memory entry = Entry({size: size, code: code, bid: bid});
252
+ ARB_WASM_CACHE.cacheProgram(program);
253
+ bids.push(_packBid(bid, index));
254
+ queueSize += size;
255
+ if (index == entries.length) {
256
+ entries.push(entry);
257
+ } else {
258
+ entries[index] = entry;
259
+ }
260
+ emit InsertBid(code, program, bid, size);
261
+ }
262
+
263
+ /// @dev Clears the entry at the given index
264
+ function _deleteEntry(uint192 bid, uint64 index) internal {
265
+ Entry memory entry = entries[index];
266
+ ARB_WASM_CACHE.evictCodehash(entry.code);
267
+ queueSize -= entry.size;
268
+ emit DeleteBid(entry.code, bid, entry.size);
269
+ delete entries[index];
270
+ }
271
+
272
+ /// @dev Gets the bid and index from a packed bid item
273
+ function _getBid(uint256 info) internal pure returns (uint192 bid, uint64 index) {
274
+ bid = uint192(info >> 64);
275
+ index = uint64(info);
276
+ }
277
+
278
+ /// @dev Creates a packed bid item
279
+ function _packBid(uint192 bid, uint64 index) internal pure returns (uint256) {
280
+ return (uint256(bid) << 64) | uint256(index);
281
+ }
282
+
283
+ /// @dev Gets the size of the given program in bytes
284
+ function _asmSize(bytes32 codehash) internal view returns (uint64) {
285
+ uint32 size = ARB_WASM.codehashAsmSize(codehash);
286
+ return uint64(size >= MIN_CODESIZE ? size : MIN_CODESIZE); // pretend it's at least 4Kb
287
+ }
288
+
289
+ /// @dev Determines whether a program is cached
290
+ function _isCached(bytes32 codehash) internal view returns (bool) {
291
+ return ARB_WASM_CACHE.codehashIsCached(codehash);
292
+ }
293
+ }
@@ -48,51 +48,6 @@ library ChallengeLib {
48
48
  return challenge.timeUsedSinceLastMove() > challenge.current.timeLeft;
49
49
  }
50
50
 
51
- function getStartMachineHash(bytes32 globalStateHash, bytes32 wasmModuleRoot)
52
- internal
53
- pure
54
- returns (bytes32)
55
- {
56
- // Start the value stack with the function call ABI for the entrypoint
57
- Value[] memory startingValues = new Value[](3);
58
- startingValues[0] = ValueLib.newRefNull();
59
- startingValues[1] = ValueLib.newI32(0);
60
- startingValues[2] = ValueLib.newI32(0);
61
- ValueArray memory valuesArray = ValueArray({inner: startingValues});
62
- ValueStack memory values = ValueStack({proved: valuesArray, remainingHash: 0});
63
- ValueStack memory internalStack;
64
- StackFrameWindow memory frameStack;
65
-
66
- Machine memory mach = Machine({
67
- status: MachineStatus.RUNNING,
68
- valueStack: values,
69
- internalStack: internalStack,
70
- frameStack: frameStack,
71
- globalStateHash: globalStateHash,
72
- moduleIdx: 0,
73
- functionIdx: 0,
74
- functionPc: 0,
75
- modulesRoot: wasmModuleRoot
76
- });
77
- return mach.hash();
78
- }
79
-
80
- function getEndMachineHash(MachineStatus status, bytes32 globalStateHash)
81
- internal
82
- pure
83
- returns (bytes32)
84
- {
85
- if (status == MachineStatus.FINISHED) {
86
- return keccak256(abi.encodePacked("Machine finished:", globalStateHash));
87
- } else if (status == MachineStatus.ERRORED) {
88
- return keccak256(abi.encodePacked("Machine errored:"));
89
- } else if (status == MachineStatus.TOO_FAR) {
90
- return keccak256(abi.encodePacked("Machine too far:"));
91
- } else {
92
- revert("BAD_BLOCK_STATUS");
93
- }
94
- }
95
-
96
51
  function extractChallengeSegment(SegmentSelection calldata selection)
97
52
  internal
98
53
  pure
@@ -35,6 +35,7 @@ contract ChallengeManager is DelegateCallAware, IChallengeManager {
35
35
  ISequencerInbox public sequencerInbox;
36
36
  IBridge public bridge;
37
37
  IOneStepProofEntry public osp;
38
+ mapping(bytes32 => IOneStepProofEntry) public ospCond;
38
39
 
39
40
  function challengeInfo(uint64 challengeIndex)
40
41
  external
@@ -110,12 +111,28 @@ contract ChallengeManager is DelegateCallAware, IChallengeManager {
110
111
  osp = osp_;
111
112
  }
112
113
 
113
- function postUpgradeInit(IOneStepProofEntry osp_) external onlyDelegated onlyProxyOwner {
114
- // when updating to 4844 we need to create new osp contracts and set them here
115
- // on the challenge manager
114
+ /// @dev A osp breaking change is introduced as part of Stylus upgrade, where the new osp would not support
115
+ /// pre-Stylus legacy wasmModuleRoot. To ensure that the new osp is not used for legacy wasmModuleRoot,
116
+ /// we introduce a conditional OSP where condRoot should be set to the pre-Stylus root and condOsp should
117
+ /// be set to the pre-Stylus osp. The correct value should be handled by the upgrade action contract.
118
+ function postUpgradeInit(
119
+ IOneStepProofEntry osp_,
120
+ bytes32 condRoot,
121
+ IOneStepProofEntry condOsp
122
+ ) external onlyDelegated onlyProxyOwner {
123
+ ospCond[condRoot] = condOsp;
116
124
  osp = osp_;
117
125
  }
118
126
 
127
+ function getOsp(bytes32 wasmModuleRoot) public view returns (IOneStepProofEntry) {
128
+ IOneStepProofEntry t = ospCond[wasmModuleRoot];
129
+ if (address(t) == address(0)) {
130
+ return osp;
131
+ } else {
132
+ return t;
133
+ }
134
+ }
135
+
119
136
  function createChallenge(
120
137
  bytes32 wasmModuleRoot_,
121
138
  MachineStatus[2] calldata startAndEndMachineStatuses_,
@@ -233,11 +250,9 @@ contract ChallengeManager is DelegateCallAware, IChallengeManager {
233
250
  }
234
251
 
235
252
  bytes32[] memory segments = new bytes32[](2);
236
- segments[0] = ChallengeLib.getStartMachineHash(
237
- globalStateHashes[0],
238
- challenge.wasmModuleRoot
239
- );
240
- segments[1] = ChallengeLib.getEndMachineHash(machineStatuses[1], globalStateHashes[1]);
253
+ IOneStepProofEntry _osp = getOsp(challenge.wasmModuleRoot);
254
+ segments[0] = _osp.getStartMachineHash(globalStateHashes[0], challenge.wasmModuleRoot);
255
+ segments[1] = _osp.getEndMachineHash(machineStatuses[1], globalStateHashes[1]);
241
256
 
242
257
  challenge.mode = ChallengeLib.ChallengeMode.EXECUTION;
243
258
 
@@ -259,7 +274,7 @@ contract ChallengeManager is DelegateCallAware, IChallengeManager {
259
274
  require(challengeLength == 1, "TOO_LONG");
260
275
  }
261
276
 
262
- bytes32 afterHash = osp.proveOneStep(
277
+ bytes32 afterHash = getOsp(challenge.wasmModuleRoot).proveOneStep(
263
278
  ExecutionContext({maxInboxMessagesRead: challenge.maxInboxMessages, bridge: bridge}),
264
279
  challengeStart,
265
280
  selection.oldSegments[selection.challengePosition],
@@ -47,6 +47,19 @@ interface IChallengeManager {
47
47
  IOneStepProofEntry osp_
48
48
  ) external;
49
49
 
50
+ function postUpgradeInit(
51
+ IOneStepProofEntry osp_,
52
+ bytes32 condRoot,
53
+ IOneStepProofEntry condOsp
54
+ ) external;
55
+
56
+ /// @notice Get the default osp, which is used for all wasm module roots that don't have a conditional OSP set
57
+ /// Use getOsp(wasmModuleRoot) to get the OSP for a specific wasm module root
58
+ function osp() external view returns (IOneStepProofEntry);
59
+
60
+ /// @notice Get the OSP for a given wasm module root
61
+ function getOsp(bytes32 wasmModuleRoot) external view returns (IOneStepProofEntry);
62
+
50
63
  function createChallenge(
51
64
  bytes32 wasmModuleRoot_,
52
65
  MachineStatus[2] calldata startAndEndMachineStatuses_,
@@ -8,3 +8,14 @@ uint64 constant NO_CHAL_INDEX = 0;
8
8
 
9
9
  // Expected seconds per block in Ethereum PoS
10
10
  uint256 constant ETH_POS_BLOCK_TIME = 12;
11
+
12
+ /// @dev If nativeTokenDecimals is different than 18 decimals, bridge will inflate or deflate token amounts
13
+ /// when depositing to child chain to match 18 decimal denomination. Opposite process happens when
14
+ /// amount is withdrawn back to parent chain. In order to avoid uint256 overflows we restrict max number
15
+ /// of decimals to 36 which should be enough for most practical use-cases.
16
+ uint8 constant MAX_ALLOWED_NATIVE_TOKEN_DECIMALS = uint8(36);
17
+
18
+ /// @dev Max amount of erc20 native token that can deposit when upscaling is required (i.e. < 18 decimals)
19
+ /// Amounts higher than this would risk uint256 overflows when adjusting decimals. Considering
20
+ /// 18 decimals are 60 bits, we choose 2^192 as the limit which equals to ~6.3*10^57 weis of token
21
+ uint256 constant MAX_UPSCALE_AMOUNT = type(uint192).max;
@@ -0,0 +1,33 @@
1
+ // Copyright 2021-2022, Offchain Labs, Inc.
2
+ // For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE
3
+ // SPDX-License-Identifier: BUSL-1.1
4
+
5
+ pragma solidity ^0.8.0;
6
+
7
+ import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
8
+
9
+ library DecimalsConverterHelper {
10
+ /// @notice generic function for mapping amount from one decimal denomination to another
11
+ /// @dev Ie. let's say amount is 752. If token has 16 decimals and is being adjusted to
12
+ /// 18 decimals then amount will be 75200. If token has 20 decimals adjusted amount
13
+ /// is 7. If token uses no decimals converted amount is 752*10^18.
14
+ /// When amount is adjusted from 18 decimals back to native token decimals, opposite
15
+ /// process is performed.
16
+ /// @param amount amount to convert
17
+ /// @param decimalsIn current decimals
18
+ /// @param decimalsOut target decimals
19
+ /// @return amount converted to 'decimalsOut' decimals
20
+ function adjustDecimals(
21
+ uint256 amount,
22
+ uint8 decimalsIn,
23
+ uint8 decimalsOut
24
+ ) internal pure returns (uint256) {
25
+ if (decimalsIn == decimalsOut) {
26
+ return amount;
27
+ } else if (decimalsIn < decimalsOut) {
28
+ return amount * 10**(decimalsOut - decimalsIn);
29
+ } else {
30
+ return amount / 10**(decimalsIn - decimalsOut);
31
+ }
32
+ }
33
+ }
@@ -119,6 +119,12 @@ error NotForked();
119
119
  /// @dev The provided gasLimit is larger than uint64
120
120
  error GasLimitTooLarge();
121
121
 
122
+ /// @dev The provided amount cannot be adjusted to 18 decimals due to overflow
123
+ error AmountTooLarge(uint256 amount);
124
+
125
+ /// @dev Number of native token's decimals is restricted to enable conversions to 18 decimals
126
+ error NativeTokenDecimalsTooLarge(uint256 decimals);
127
+
122
128
  // Outbox Errors
123
129
 
124
130
  /// @dev The provided proof was too long
@@ -0,0 +1,52 @@
1
+ // Copyright 2022-2023, 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
+ contract Benchmarks {
8
+ function fillBlockRecover() external payable {
9
+ bytes32 bridgeToNova = 0xeddecf107b5740cef7f5a01e3ea7e287665c4e75a8eb6afae2fda2e3d4367786;
10
+ address cryptoIsCute = 0x361594F5429D23ECE0A88E4fBE529E1c49D524d8;
11
+ uint8 v = 27;
12
+ bytes32 r = 0xc6178c2de1078cd36c3bd302cde755340d7f17fcb3fcc0b9c333ba03b217029f;
13
+ bytes32 s = 0x5fdbcefe2675e96219cdae57a7894280bf80fd40d44ce146a35e169ea6a78fd3;
14
+ while (true) {
15
+ require(ecrecover(bridgeToNova, v, r, s) == cryptoIsCute, "WRONG_ARBINAUT");
16
+ }
17
+ }
18
+
19
+ function fillBlockMulMod() external payable {
20
+ uint256 value = 0xeddecf107b5740cef7f5a01e3ea7e287665c4e75a8eb6afae2fda2e3d4367786;
21
+ while (true) {
22
+ value = mulmod(
23
+ value,
24
+ 0xc6178c2de1078cd36c3bd302cde755340d7f17fcb3fcc0b9c333ba03b217029f,
25
+ 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f
26
+ );
27
+ }
28
+ }
29
+
30
+ function fillBlockHash() external payable {
31
+ bytes32 hash = 0xeddecf107b5740cef7f5a01e3ea7e287665c4e75a8eb6afae2fda2e3d4367786;
32
+ while (true) {
33
+ hash = keccak256(abi.encodePacked(hash));
34
+ }
35
+ }
36
+
37
+ function fillBlockAdd() external payable {
38
+ uint256 value = 0;
39
+ while (true) {
40
+ unchecked {
41
+ value += 0xeddecf107b5740cef7f5a01e3ea7e287665c4e75a8eb6afae2fda2e3d4367786;
42
+ }
43
+ }
44
+ }
45
+
46
+ function fillBlockQuickStep() external payable {
47
+ uint256 value = 0;
48
+ while (true) {
49
+ value = msg.value;
50
+ }
51
+ }
52
+ }
@@ -32,6 +32,9 @@ contract BridgeStub is IBridge, IEthBridge {
32
32
  address public sequencerInbox;
33
33
  uint256 public override sequencerReportedSubMessageCount;
34
34
 
35
+ address public nativeToken;
36
+ uint8 public nativeTokenDecimals;
37
+
35
38
  function setSequencerInbox(address _sequencerInbox) external override {
36
39
  sequencerInbox = _sequencerInbox;
37
40
  emit SequencerInboxUpdated(_sequencerInbox);
@@ -0,0 +1,117 @@
1
+ // Copyright 2024, 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
+ /*
8
+ * this contract is the solidity equivalent of stylus multicall test contract
9
+ * it should only be used for stylus tests, and it ignores good solidity good practices
10
+ */
11
+
12
+ contract MultiCallTest {
13
+ event Called(address addr, uint8 count, bool success, bytes returnData);
14
+ event Storage(bytes32 slot, bytes32 data, bool write);
15
+
16
+ function getBE(bytes calldata data, uint8 numBytes) internal pure returns (uint256) {
17
+ uint256 res = 0;
18
+ for (uint8 i = 0; i < numBytes; i++) {
19
+ res = res << 8;
20
+ res = res | uint8(data[i]);
21
+ }
22
+ return res;
23
+ }
24
+
25
+ // solhint-disable no-complex-fallback
26
+ // solhint-disable reason-string
27
+ // solhint-disable avoid-low-level-calls
28
+ // solhint-disable-next-line prettier/prettier
29
+ fallback(bytes calldata input) external payable returns (bytes memory) {
30
+ require(input.length > 0);
31
+ uint8 count = uint8(input[0]);
32
+ input = input[1:];
33
+
34
+ // combined output of all calls
35
+ bytes memory output;
36
+
37
+ for (uint8 i = 0; i < count; i++) {
38
+ uint32 length = uint32(getBE(input, 4));
39
+ input = input[4:];
40
+
41
+ bytes calldata curr = input[:length];
42
+ input = input[length:];
43
+
44
+ uint8 kind = uint8(curr[0]);
45
+ curr = curr[1:];
46
+
47
+ if (kind & 0xf0 == 0x0) {
48
+ // call
49
+ uint256 value;
50
+ if (kind & 0x3 == 0) {
51
+ value = getBE(curr, 32);
52
+ curr = curr[32:];
53
+ }
54
+
55
+ address addr = address(bytes20(curr[:20]));
56
+ bytes calldata data = curr[20:];
57
+ bytes memory out;
58
+ bool success;
59
+
60
+ if (kind & 0x3 == 0) {
61
+ (success, out) = addr.call{value: value}(data);
62
+ } else if (kind & 0x3 == 1) {
63
+ (success, out) = addr.delegatecall(data);
64
+ } else if (kind & 0x3 == 2) {
65
+ (success, out) = addr.staticcall(data);
66
+ } else {
67
+ revert("unknown call kind");
68
+ }
69
+ if (!success) {
70
+ if (kind & 0x4 == 0) {
71
+ uint256 len = out.length;
72
+ if (len > 0) {
73
+ assembly {
74
+ revert(add(out, 32), len)
75
+ }
76
+ } else {
77
+ revert();
78
+ }
79
+ }
80
+ out = "";
81
+ }
82
+ if (kind & 0x8 != 0) {
83
+ emit Called(addr, count, success, out);
84
+ }
85
+ output = bytes.concat(output, out);
86
+ } else if (kind & 0xf0 == 0x10) {
87
+ // storage
88
+ bytes32 slot = bytes32(curr[:32]);
89
+ curr = curr[32:];
90
+ bytes32 data;
91
+ bool write;
92
+ if (kind & 0x3 == 0) {
93
+ data = bytes32(curr[:32]);
94
+ write = true;
95
+ assembly {
96
+ sstore(slot, data)
97
+ }
98
+ } else if (kind & 0x3 == 1) {
99
+ write = false;
100
+ assembly {
101
+ data := sload(slot)
102
+ }
103
+ output = bytes.concat(output, data);
104
+ } else {
105
+ revert("unknown storage kind");
106
+ }
107
+ if (kind & 0x8 != 0) {
108
+ emit Storage(slot, data, write);
109
+ }
110
+ } else {
111
+ revert("unknown command");
112
+ }
113
+ }
114
+
115
+ return output;
116
+ }
117
+ }