@arbitrum/nitro-contracts 1.1.0-alpha.1 → 1.1.0-alpha.3
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE +114 -0
- package/README.md +2 -2
- package/build/types/@openzeppelin/contracts/access/Ownable.ts +175 -0
- package/build/types/@openzeppelin/contracts/access/index.ts +4 -0
- package/build/types/@openzeppelin/contracts/index.ts +11 -0
- package/build/types/@openzeppelin/contracts/interfaces/draft-IERC1822.sol/IERC1822Proxiable.ts +87 -0
- package/build/types/@openzeppelin/contracts/interfaces/draft-IERC1822.sol/index.ts +4 -0
- package/build/types/@openzeppelin/contracts/interfaces/index.ts +5 -0
- package/build/types/@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.ts +108 -0
- package/build/types/@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.ts +108 -0
- package/build/types/@openzeppelin/contracts/proxy/ERC1967/index.ts +5 -0
- package/build/types/@openzeppelin/contracts/proxy/Proxy.ts +55 -0
- package/build/types/@openzeppelin/contracts/proxy/beacon/IBeacon.ts +87 -0
- package/build/types/@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.ts +239 -0
- package/build/types/@openzeppelin/contracts/proxy/beacon/index.ts +5 -0
- package/build/types/@openzeppelin/contracts/proxy/index.ts +12 -0
- package/build/types/@openzeppelin/contracts/proxy/transparent/ProxyAdmin.ts +359 -0
- package/build/types/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.ts +278 -0
- package/build/types/@openzeppelin/contracts/proxy/transparent/index.ts +5 -0
- package/build/types/@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.ts +216 -0
- package/build/types/@openzeppelin/contracts/proxy/utils/index.ts +4 -0
- package/build/types/@openzeppelin/contracts/token/ERC20/ERC20.ts +444 -0
- package/build/types/@openzeppelin/contracts/token/ERC20/IERC20.ts +322 -0
- package/build/types/@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.ts +507 -0
- package/build/types/@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.ts +364 -0
- package/build/types/@openzeppelin/contracts/token/ERC20/extensions/index.ts +5 -0
- package/build/types/@openzeppelin/contracts/token/ERC20/index.ts +9 -0
- package/build/types/@openzeppelin/contracts/token/ERC20/presets/ERC20PresetFixedSupply.ts +507 -0
- package/build/types/@openzeppelin/contracts/token/ERC20/presets/index.ts +4 -0
- package/build/types/@openzeppelin/contracts/token/index.ts +5 -0
- package/build/types/@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.ts +175 -0
- package/build/types/@openzeppelin/contracts-upgradeable/access/index.ts +4 -0
- package/build/types/@openzeppelin/contracts-upgradeable/index.ts +9 -0
- package/build/types/@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.ts +111 -0
- package/build/types/@openzeppelin/contracts-upgradeable/security/index.ts +4 -0
- package/build/types/@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.ts +322 -0
- package/build/types/@openzeppelin/contracts-upgradeable/token/ERC20/index.ts +4 -0
- package/build/types/@openzeppelin/contracts-upgradeable/token/index.ts +5 -0
- package/build/types/@openzeppelin/index.ts +7 -0
- package/build/types/common.ts +44 -0
- package/build/types/factories/@openzeppelin/contracts/access/Ownable__factory.ts +78 -0
- package/build/types/factories/@openzeppelin/contracts/access/index.ts +4 -0
- package/build/types/factories/@openzeppelin/contracts/index.ts +7 -0
- package/build/types/factories/@openzeppelin/contracts/interfaces/draft-IERC1822.sol/IERC1822Proxiable__factory.ts +39 -0
- package/build/types/factories/@openzeppelin/contracts/interfaces/draft-IERC1822.sol/index.ts +4 -0
- package/build/types/factories/@openzeppelin/contracts/interfaces/index.ts +4 -0
- package/build/types/factories/@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy__factory.ts +146 -0
- package/build/types/factories/@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade__factory.ts +71 -0
- package/build/types/factories/@openzeppelin/contracts/proxy/ERC1967/index.ts +5 -0
- package/build/types/factories/@openzeppelin/contracts/proxy/Proxy__factory.ts +31 -0
- package/build/types/factories/@openzeppelin/contracts/proxy/beacon/IBeacon__factory.ts +39 -0
- package/build/types/factories/@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon__factory.ts +169 -0
- package/build/types/factories/@openzeppelin/contracts/proxy/beacon/index.ts +5 -0
- package/build/types/factories/@openzeppelin/contracts/proxy/index.ts +8 -0
- package/build/types/factories/@openzeppelin/contracts/proxy/transparent/ProxyAdmin__factory.ts +211 -0
- package/build/types/factories/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy__factory.ts +228 -0
- package/build/types/factories/@openzeppelin/contracts/proxy/transparent/index.ts +5 -0
- package/build/types/factories/@openzeppelin/contracts/proxy/utils/UUPSUpgradeable__factory.ts +115 -0
- package/build/types/factories/@openzeppelin/contracts/proxy/utils/index.ts +4 -0
- package/build/types/factories/@openzeppelin/contracts/token/ERC20/ERC20__factory.ts +349 -0
- package/build/types/factories/@openzeppelin/contracts/token/ERC20/IERC20__factory.ts +206 -0
- package/build/types/factories/@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable__factory.ts +327 -0
- package/build/types/factories/@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata__factory.ts +248 -0
- package/build/types/factories/@openzeppelin/contracts/token/ERC20/extensions/index.ts +5 -0
- package/build/types/factories/@openzeppelin/contracts/token/ERC20/index.ts +7 -0
- package/build/types/factories/@openzeppelin/contracts/token/ERC20/presets/ERC20PresetFixedSupply__factory.ts +420 -0
- package/build/types/factories/@openzeppelin/contracts/token/ERC20/presets/index.ts +4 -0
- package/build/types/factories/@openzeppelin/contracts/token/index.ts +4 -0
- package/build/types/factories/@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable__factory.ts +78 -0
- package/build/types/factories/@openzeppelin/contracts-upgradeable/access/index.ts +4 -0
- package/build/types/factories/@openzeppelin/contracts-upgradeable/index.ts +6 -0
- package/build/types/factories/@openzeppelin/contracts-upgradeable/security/PausableUpgradeable__factory.ts +65 -0
- package/build/types/factories/@openzeppelin/contracts-upgradeable/security/index.ts +4 -0
- package/build/types/factories/@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable__factory.ts +209 -0
- package/build/types/factories/@openzeppelin/contracts-upgradeable/token/ERC20/index.ts +4 -0
- package/build/types/factories/@openzeppelin/contracts-upgradeable/token/index.ts +4 -0
- package/build/types/factories/@openzeppelin/index.ts +5 -0
- package/build/types/factories/index.ts +5 -0
- package/build/types/factories/src/bridge/AbsBridge__factory.ts +612 -0
- package/build/types/factories/src/bridge/AbsInbox__factory.ts +455 -0
- package/build/types/factories/src/bridge/AbsOutbox__factory.ts +561 -0
- package/build/types/factories/src/bridge/Bridge__factory.ts +695 -0
- package/build/types/factories/src/bridge/ERC20Bridge__factory.ts +746 -0
- package/build/types/factories/src/bridge/ERC20Inbox__factory.ts +719 -0
- package/build/types/factories/src/bridge/ERC20Outbox__factory.ts +610 -0
- package/build/types/factories/src/bridge/IBridge__factory.ts +508 -0
- package/build/types/factories/src/bridge/IDelayedMessageProvider__factory.ts +62 -0
- package/build/types/factories/src/bridge/IERC20Bridge__factory.ts +576 -0
- package/build/types/factories/src/bridge/IERC20Inbox__factory.ts +461 -0
- package/build/types/factories/src/bridge/IEthBridge__factory.ts +553 -0
- package/build/types/factories/src/bridge/IEthInbox__factory.ts +653 -0
- package/build/types/factories/src/bridge/IInbox__factory.ts +318 -0
- package/build/types/factories/src/bridge/IOutbox__factory.ts +431 -0
- package/build/types/factories/src/bridge/IOwnable__factory.ts +36 -0
- package/build/types/factories/src/bridge/ISequencerInbox__factory.ts +666 -0
- package/build/types/factories/src/bridge/Inbox__factory.ts +999 -0
- package/build/types/factories/src/bridge/Outbox__factory.ts +591 -0
- package/build/types/factories/src/bridge/SequencerInbox__factory.ts +865 -0
- package/build/types/factories/src/bridge/index.ts +23 -0
- package/build/types/factories/src/challenge/ChallengeManager__factory.ts +720 -0
- package/build/types/factories/src/challenge/IChallengeManager__factory.ts +401 -0
- package/build/types/factories/src/challenge/IChallengeResultReceiver__factory.ts +53 -0
- package/build/types/factories/src/challenge/index.ts +6 -0
- package/build/types/factories/src/index.ts +12 -0
- package/build/types/factories/src/libraries/AdminFallbackProxy.sol/AdminFallbackProxy__factory.ts +128 -0
- package/build/types/factories/src/libraries/AdminFallbackProxy.sol/DoubleLogicERC1967Upgrade__factory.ts +88 -0
- package/build/types/factories/src/libraries/AdminFallbackProxy.sol/index.ts +5 -0
- package/build/types/factories/src/libraries/DoubleLogicUUPSUpgradeable__factory.ts +163 -0
- package/build/types/factories/src/libraries/IGasRefunder__factory.ts +55 -0
- package/build/types/factories/src/libraries/UUPSNotUpgradeable__factory.ts +97 -0
- package/build/types/factories/src/libraries/index.ts +7 -0
- package/build/types/factories/src/mocks/BridgeStub__factory.ts +612 -0
- package/build/types/factories/src/mocks/BridgeUnproxied__factory.ts +706 -0
- package/build/types/factories/src/mocks/InboxStub__factory.ts +702 -0
- package/build/types/factories/src/mocks/MockResultReceiver__factory.ts +244 -0
- package/build/types/factories/src/mocks/ProxyAdminForBinding__factory.ts +215 -0
- package/build/types/factories/src/mocks/SequencerInboxStub__factory.ts +938 -0
- package/build/types/factories/src/mocks/SimpleProxy__factory.ts +83 -0
- package/build/types/factories/src/mocks/Simple__factory.ts +287 -0
- package/build/types/factories/src/mocks/SingleExecutionChallenge__factory.ts +823 -0
- package/build/types/factories/src/mocks/TimedOutChallengeManager__factory.ts +724 -0
- package/build/types/factories/src/mocks/index.ts +13 -0
- package/build/types/factories/src/node-interface/NodeInterfaceDebug__factory.ts +82 -0
- package/build/types/factories/src/node-interface/NodeInterface__factory.ts +301 -0
- package/build/types/factories/src/node-interface/index.ts +5 -0
- package/build/types/factories/src/osp/HashProofHelper__factory.ts +216 -0
- package/build/types/factories/src/osp/IOneStepProofEntry__factory.ts +72 -0
- package/build/types/factories/src/osp/IOneStepProver__factory.ts +492 -0
- package/build/types/factories/src/osp/OneStepProofEntry__factory.ts +206 -0
- package/build/types/factories/src/osp/OneStepProver0__factory.ts +528 -0
- package/build/types/factories/src/osp/OneStepProverHostIo__factory.ts +528 -0
- package/build/types/factories/src/osp/OneStepProverMath__factory.ts +528 -0
- package/build/types/factories/src/osp/OneStepProverMemory__factory.ts +528 -0
- package/build/types/factories/src/osp/index.ts +11 -0
- package/build/types/factories/src/precompiles/ArbAddressTable__factory.ts +163 -0
- package/build/types/factories/src/precompiles/ArbAggregator__factory.ts +163 -0
- package/build/types/factories/src/precompiles/ArbDebug__factory.ts +208 -0
- package/build/types/factories/src/precompiles/ArbFunctionTable__factory.ts +92 -0
- package/build/types/factories/src/precompiles/ArbGasInfo__factory.ts +339 -0
- package/build/types/factories/src/precompiles/ArbInfo__factory.ts +64 -0
- package/build/types/factories/src/precompiles/ArbOwnerPublic__factory.ts +84 -0
- package/build/types/factories/src/precompiles/ArbOwner__factory.ts +393 -0
- package/build/types/factories/src/precompiles/ArbRetryableTx__factory.ts +321 -0
- package/build/types/factories/src/precompiles/ArbStatistics__factory.ts +64 -0
- package/build/types/factories/src/precompiles/ArbSys__factory.ts +389 -0
- package/build/types/factories/src/precompiles/ArbosActs__factory.ts +92 -0
- package/build/types/factories/src/precompiles/ArbosTest__factory.ts +39 -0
- package/build/types/factories/src/precompiles/index.ts +16 -0
- package/build/types/factories/src/rollup/AbsBridgeCreator__factory.ts +182 -0
- package/build/types/factories/src/rollup/AbsRollupCreator__factory.ts +285 -0
- package/build/types/factories/src/rollup/AbsRollupEventInbox__factory.ts +125 -0
- package/build/types/factories/src/rollup/BridgeCreator__factory.ts +294 -0
- package/build/types/factories/src/rollup/ERC20BridgeCreator__factory.ts +299 -0
- package/build/types/factories/src/rollup/ERC20RollupCreator__factory.ts +439 -0
- package/build/types/factories/src/rollup/ERC20RollupEventInbox__factory.ts +170 -0
- package/build/types/factories/src/rollup/IBridgeCreator.sol/IBridgeCreator__factory.ts +124 -0
- package/build/types/factories/src/rollup/IBridgeCreator.sol/IERC20BridgeCreator__factory.ts +200 -0
- package/build/types/factories/src/rollup/IBridgeCreator.sol/IEthBridgeCreator__factory.ts +195 -0
- package/build/types/factories/src/rollup/IBridgeCreator.sol/index.ts +6 -0
- package/build/types/factories/src/rollup/IRollupAdmin__factory.ts +559 -0
- package/build/types/factories/src/rollup/IRollupCore__factory.ts +904 -0
- package/build/types/factories/src/rollup/IRollupCreator.sol/IERC20RollupCreator__factory.ts +182 -0
- package/build/types/factories/src/rollup/IRollupCreator.sol/IEthRollupCreator__factory.ts +177 -0
- package/build/types/factories/src/rollup/IRollupCreator.sol/IRollupCreator__factory.ts +69 -0
- package/build/types/factories/src/rollup/IRollupCreator.sol/index.ts +6 -0
- package/build/types/factories/src/rollup/IRollupEventInbox__factory.ts +83 -0
- package/build/types/factories/src/rollup/IRollupLogic.sol/IRollupUserAbs__factory.ts +1324 -0
- package/build/types/factories/src/rollup/IRollupLogic.sol/IRollupUserERC20__factory.ts +1458 -0
- package/build/types/factories/src/rollup/IRollupLogic.sol/IRollupUser__factory.ts +1443 -0
- package/build/types/factories/src/rollup/IRollupLogic.sol/index.ts +6 -0
- package/build/types/factories/src/rollup/RollupAdminLogic__factory.ts +1859 -0
- package/build/types/factories/src/rollup/RollupCore__factory.ts +1066 -0
- package/build/types/factories/src/rollup/RollupCreator__factory.ts +434 -0
- package/build/types/factories/src/rollup/RollupEventInbox__factory.ts +166 -0
- package/build/types/factories/src/rollup/RollupProxy__factory.ts +277 -0
- package/build/types/factories/src/rollup/RollupUserLogic.sol/AbsRollupUserLogic__factory.ts +1593 -0
- package/build/types/factories/src/rollup/RollupUserLogic.sol/ERC20RollupUserLogic__factory.ts +1767 -0
- package/build/types/factories/src/rollup/RollupUserLogic.sol/RollupUserLogic__factory.ts +1748 -0
- package/build/types/factories/src/rollup/RollupUserLogic.sol/index.ts +6 -0
- package/build/types/factories/src/rollup/ValidatorUtils__factory.ts +430 -0
- package/build/types/factories/src/rollup/ValidatorWalletCreator__factory.ts +205 -0
- package/build/types/factories/src/rollup/ValidatorWallet__factory.ts +486 -0
- package/build/types/factories/src/rollup/index.ts +25 -0
- package/build/types/factories/src/test-helpers/BridgeTester__factory.ts +654 -0
- package/build/types/factories/src/test-helpers/CryptographyPrimitivesTester__factory.ts +111 -0
- package/build/types/factories/src/test-helpers/EthVault__factory.ts +95 -0
- package/build/types/factories/src/test-helpers/MessageTester__factory.ts +135 -0
- package/build/types/factories/src/test-helpers/OutboxWithoutOptTester__factory.ts +575 -0
- package/build/types/factories/src/test-helpers/RollupMock__factory.ts +100 -0
- package/build/types/factories/src/test-helpers/ValueArrayTester__factory.ts +69 -0
- package/build/types/factories/src/test-helpers/index.ts +10 -0
- package/build/types/index.ts +240 -0
- package/build/types/src/bridge/AbsBridge.ts +863 -0
- package/build/types/src/bridge/AbsInbox.ts +664 -0
- package/build/types/src/bridge/AbsOutbox.ts +700 -0
- package/build/types/src/bridge/Bridge.ts +934 -0
- package/build/types/src/bridge/ERC20Bridge.ts +970 -0
- package/build/types/src/bridge/ERC20Inbox.ts +869 -0
- package/build/types/src/bridge/ERC20Outbox.ts +722 -0
- package/build/types/src/bridge/IBridge.ts +799 -0
- package/build/types/src/bridge/IDelayedMessageProvider.ts +108 -0
- package/build/types/src/bridge/IERC20Bridge.ts +914 -0
- package/build/types/src/bridge/IERC20Inbox.ts +788 -0
- package/build/types/src/bridge/IEthBridge.ts +871 -0
- package/build/types/src/bridge/IEthInbox.ts +1081 -0
- package/build/types/src/bridge/IInbox.ts +583 -0
- package/build/types/src/bridge/IOutbox.ts +654 -0
- package/build/types/src/bridge/IOwnable.ts +81 -0
- package/build/types/src/bridge/ISequencerInbox.ts +1038 -0
- package/build/types/src/bridge/Inbox.ts +1279 -0
- package/build/types/src/bridge/Outbox.ts +700 -0
- package/build/types/src/bridge/SequencerInbox.ts +1138 -0
- package/build/types/src/bridge/index.ts +23 -0
- package/build/types/src/challenge/ChallengeManager.ts +889 -0
- package/build/types/src/challenge/IChallengeManager.ts +543 -0
- package/build/types/src/challenge/IChallengeResultReceiver.ts +115 -0
- package/build/types/src/challenge/index.ts +6 -0
- package/build/types/src/index.ts +21 -0
- package/build/types/src/libraries/AdminFallbackProxy.sol/AdminFallbackProxy.ts +128 -0
- package/build/types/src/libraries/AdminFallbackProxy.sol/DoubleLogicERC1967Upgrade.ts +128 -0
- package/build/types/src/libraries/AdminFallbackProxy.sol/index.ts +5 -0
- package/build/types/src/libraries/DoubleLogicUUPSUpgradeable.ts +314 -0
- package/build/types/src/libraries/IGasRefunder.ts +112 -0
- package/build/types/src/libraries/UUPSNotUpgradeable.ts +164 -0
- package/build/types/src/libraries/index.ts +8 -0
- package/build/types/src/mocks/BridgeStub.ts +887 -0
- package/build/types/src/mocks/BridgeUnproxied.ts +934 -0
- package/build/types/src/mocks/InboxStub.ts +1076 -0
- package/build/types/src/mocks/MockResultReceiver.ts +301 -0
- package/build/types/src/mocks/ProxyAdminForBinding.ts +359 -0
- package/build/types/src/mocks/SequencerInboxStub.ts +1173 -0
- package/build/types/src/mocks/Simple.ts +514 -0
- package/build/types/src/mocks/SimpleProxy.ts +55 -0
- package/build/types/src/mocks/SingleExecutionChallenge.ts +889 -0
- package/build/types/src/mocks/TimedOutChallengeManager.ts +883 -0
- package/build/types/src/mocks/index.ts +13 -0
- package/build/types/src/node-interface/NodeInterface.ts +502 -0
- package/build/types/src/node-interface/NodeInterfaceDebug.ts +137 -0
- package/build/types/src/node-interface/index.ts +5 -0
- package/build/types/src/osp/HashProofHelper.ts +308 -0
- package/build/types/src/osp/IOneStepProofEntry.ts +128 -0
- package/build/types/src/osp/IOneStepProver.ts +284 -0
- package/build/types/src/osp/OneStepProofEntry.ts +196 -0
- package/build/types/src/osp/OneStepProver0.ts +284 -0
- package/build/types/src/osp/OneStepProverHostIo.ts +284 -0
- package/build/types/src/osp/OneStepProverMath.ts +284 -0
- package/build/types/src/osp/OneStepProverMemory.ts +284 -0
- package/build/types/src/osp/index.ts +11 -0
- package/build/types/src/precompiles/ArbAddressTable.ts +248 -0
- package/build/types/src/precompiles/ArbAggregator.ts +335 -0
- package/build/types/src/precompiles/ArbDebug.ts +292 -0
- package/build/types/src/precompiles/ArbFunctionTable.ts +150 -0
- package/build/types/src/precompiles/ArbGasInfo.ts +494 -0
- package/build/types/src/precompiles/ArbInfo.ts +105 -0
- package/build/types/src/precompiles/ArbOwner.ts +928 -0
- package/build/types/src/precompiles/ArbOwnerPublic.ts +157 -0
- package/build/types/src/precompiles/ArbRetryableTx.ts +467 -0
- package/build/types/src/precompiles/ArbStatistics.ts +93 -0
- package/build/types/src/precompiles/ArbSys.ts +553 -0
- package/build/types/src/precompiles/ArbosActs.ts +173 -0
- package/build/types/src/precompiles/ArbosTest.ts +97 -0
- package/build/types/src/precompiles/index.ts +16 -0
- package/build/types/src/rollup/AbsBridgeCreator.ts +348 -0
- package/build/types/src/rollup/AbsRollupCreator.ts +449 -0
- package/build/types/src/rollup/AbsRollupEventInbox.ts +218 -0
- package/build/types/src/rollup/BridgeCreator.ts +415 -0
- package/build/types/src/rollup/ERC20BridgeCreator.ts +420 -0
- package/build/types/src/rollup/ERC20RollupCreator.ts +561 -0
- package/build/types/src/rollup/ERC20RollupEventInbox.ts +218 -0
- package/build/types/src/rollup/IBridgeCreator.sol/IBridgeCreator.ts +231 -0
- package/build/types/src/rollup/IBridgeCreator.sol/IERC20BridgeCreator.ts +303 -0
- package/build/types/src/rollup/IBridgeCreator.sol/IEthBridgeCreator.ts +298 -0
- package/build/types/src/rollup/IBridgeCreator.sol/index.ts +6 -0
- package/build/types/src/rollup/IRollupAdmin.ts +1003 -0
- package/build/types/src/rollup/IRollupCore.ts +1183 -0
- package/build/types/src/rollup/IRollupCreator.sol/IERC20RollupCreator.ts +247 -0
- package/build/types/src/rollup/IRollupCreator.sol/IEthRollupCreator.ts +242 -0
- package/build/types/src/rollup/IRollupCreator.sol/IRollupCreator.ts +134 -0
- package/build/types/src/rollup/IRollupCreator.sol/index.ts +6 -0
- package/build/types/src/rollup/IRollupEventInbox.ts +167 -0
- package/build/types/src/rollup/IRollupLogic.sol/IRollupUser.ts +2022 -0
- package/build/types/src/rollup/IRollupLogic.sol/IRollupUserAbs.ts +1901 -0
- package/build/types/src/rollup/IRollupLogic.sol/IRollupUserERC20.ts +2036 -0
- package/build/types/src/rollup/IRollupLogic.sol/index.ts +6 -0
- package/build/types/src/rollup/RollupAdminLogic.ts +2593 -0
- package/build/types/src/rollup/RollupCore.ts +1406 -0
- package/build/types/src/rollup/RollupCreator.ts +556 -0
- package/build/types/src/rollup/RollupEventInbox.ts +218 -0
- package/build/types/src/rollup/RollupProxy.ts +285 -0
- package/build/types/src/rollup/RollupUserLogic.sol/AbsRollupUserLogic.ts +2282 -0
- package/build/types/src/rollup/RollupUserLogic.sol/ERC20RollupUserLogic.ts +2417 -0
- package/build/types/src/rollup/RollupUserLogic.sol/RollupUserLogic.ts +2403 -0
- package/build/types/src/rollup/RollupUserLogic.sol/index.ts +6 -0
- package/build/types/src/rollup/ValidatorUtils.ts +561 -0
- package/build/types/src/rollup/ValidatorWallet.ts +751 -0
- package/build/types/src/rollup/ValidatorWalletCreator.ts +294 -0
- package/build/types/src/rollup/index.ts +29 -0
- package/build/types/src/test-helpers/BridgeTester.ts +899 -0
- package/build/types/src/test-helpers/CryptographyPrimitivesTester.ts +141 -0
- package/build/types/src/test-helpers/EthVault.ts +141 -0
- package/build/types/src/test-helpers/MessageTester.ts +182 -0
- package/build/types/src/test-helpers/OutboxWithoutOptTester.ts +700 -0
- package/build/types/src/test-helpers/RollupMock.ts +164 -0
- package/build/types/src/test-helpers/ValueArrayTester.ts +81 -0
- package/build/types/src/test-helpers/index.ts +10 -0
- package/package.json +9 -3
- package/src/bridge/AbsBridge.sol +302 -0
- package/src/bridge/AbsInbox.sol +335 -0
- package/src/bridge/AbsOutbox.sol +295 -0
- package/src/bridge/Bridge.sol +15 -244
- package/src/bridge/ERC20Bridge.sol +74 -0
- package/src/bridge/ERC20Inbox.sol +141 -0
- package/src/bridge/ERC20Outbox.sol +27 -0
- package/src/bridge/IBridge.sol +1 -16
- package/src/bridge/IDelayedMessageProvider.sol +1 -1
- package/src/bridge/IERC20Bridge.sol +35 -0
- package/src/bridge/IERC20Inbox.sol +75 -0
- package/src/bridge/IEthBridge.sol +26 -0
- package/src/bridge/IEthInbox.sol +133 -0
- package/src/bridge/IInbox.sol +13 -123
- package/src/bridge/IOutbox.sol +1 -1
- package/src/bridge/IOwnable.sol +1 -1
- package/src/bridge/ISequencerInbox.sol +12 -4
- package/src/bridge/Inbox.sol +46 -333
- package/src/bridge/Messages.sol +1 -1
- package/src/bridge/Outbox.sol +8 -265
- package/src/bridge/SequencerInbox.sol +29 -8
- package/src/challenge/ChallengeLib.sol +1 -1
- package/src/challenge/ChallengeManager.sol +1 -1
- package/src/challenge/IChallengeManager.sol +1 -1
- package/src/challenge/IChallengeResultReceiver.sol +1 -1
- package/src/libraries/AddressAliasHelper.sol +1 -1
- package/src/libraries/AdminFallbackProxy.sol +1 -1
- package/src/libraries/ArbitrumChecker.sol +16 -0
- package/src/libraries/Constants.sol +1 -4
- package/src/libraries/CryptographyPrimitives.sol +1 -1
- package/src/libraries/DelegateCallAware.sol +1 -1
- package/src/libraries/DoubleLogicUUPSUpgradeable.sol +1 -1
- package/src/libraries/Error.sol +9 -1
- package/src/libraries/IGasRefunder.sol +1 -1
- package/src/libraries/MerkleLib.sol +1 -1
- package/src/libraries/MessageTypes.sol +1 -1
- package/src/mocks/BridgeStub.sol +3 -2
- package/src/mocks/BridgeUnproxied.sol +1 -1
- package/src/mocks/InboxStub.sol +28 -5
- package/src/mocks/MockResultReceiver.sol +1 -1
- package/src/mocks/ProxyAdminForBinding.sol +1 -1
- package/src/mocks/SequencerInboxStub.sol +3 -2
- package/src/mocks/Simple.sol +3 -1
- package/src/mocks/SimpleProxy.sol +1 -1
- package/src/mocks/SingleExecutionChallenge.sol +1 -1
- package/src/mocks/TimedOutChallengeManager.sol +1 -1
- package/src/node-interface/NodeInterface.sol +1 -1
- package/src/node-interface/NodeInterfaceDebug.sol +1 -1
- package/src/osp/HashProofHelper.sol +1 -1
- package/src/osp/IOneStepProofEntry.sol +1 -1
- package/src/osp/IOneStepProver.sol +2 -1
- package/src/osp/OneStepProofEntry.sol +1 -1
- package/src/osp/OneStepProver0.sol +1 -1
- package/src/osp/OneStepProverHostIo.sol +2 -1
- package/src/osp/OneStepProverMath.sol +1 -1
- package/src/osp/OneStepProverMemory.sol +2 -1
- package/src/precompiles/ArbAddressTable.sol +1 -1
- package/src/precompiles/ArbAggregator.sol +1 -1
- package/src/precompiles/ArbBLS.sol +1 -1
- package/src/precompiles/ArbDebug.sol +1 -1
- package/src/precompiles/ArbFunctionTable.sol +1 -1
- package/src/precompiles/ArbGasInfo.sol +1 -1
- package/src/precompiles/ArbInfo.sol +1 -1
- package/src/precompiles/ArbOwner.sol +1 -1
- package/src/precompiles/ArbOwnerPublic.sol +1 -1
- package/src/precompiles/ArbRetryableTx.sol +1 -1
- package/src/precompiles/ArbStatistics.sol +1 -1
- package/src/precompiles/ArbSys.sol +1 -1
- package/src/precompiles/ArbosTest.sol +1 -1
- package/src/rollup/AbsBridgeCreator.sol +117 -0
- package/src/rollup/AbsRollupCreator.sol +164 -0
- package/src/rollup/AbsRollupEventInbox.sol +62 -0
- package/src/rollup/BridgeCreator.sol +17 -88
- package/src/rollup/Config.sol +43 -0
- package/src/rollup/ERC20BridgeCreator.sol +48 -0
- package/src/rollup/ERC20RollupCreator.sol +48 -0
- package/src/rollup/ERC20RollupEventInbox.sol +26 -0
- package/src/rollup/IBridgeCreator.sol +64 -0
- package/src/rollup/IRollupAdmin.sol +138 -0
- package/src/rollup/IRollupCore.sol +7 -3
- package/src/rollup/IRollupCreator.sol +40 -0
- package/src/rollup/IRollupEventInbox.sol +1 -1
- package/src/rollup/IRollupLogic.sol +4 -132
- package/src/rollup/Node.sol +15 -1
- package/src/rollup/RollupAdminLogic.sol +6 -8
- package/src/rollup/RollupCore.sol +4 -11
- package/src/rollup/RollupCreator.sol +22 -97
- package/src/rollup/RollupEventInbox.sol +12 -35
- package/src/rollup/RollupLib.sol +2 -41
- package/src/rollup/RollupProxy.sol +3 -2
- package/src/rollup/RollupUserLogic.sol +6 -4
- package/src/rollup/ValidatorUtils.sol +2 -1
- package/src/rollup/ValidatorWallet.sol +1 -1
- package/src/rollup/ValidatorWalletCreator.sol +1 -1
- package/src/state/Deserialize.sol +2 -2
- package/src/state/GlobalState.sol +1 -1
- package/src/state/Instructions.sol +1 -1
- package/src/state/Machine.sol +1 -1
- package/src/state/MerkleProof.sol +1 -1
- package/src/state/Module.sol +3 -3
- package/src/state/ModuleMemory.sol +3 -8
- package/src/state/ModuleMemoryCompact.sol +17 -0
- package/src/state/PcArray.sol +1 -1
- package/src/state/StackFrame.sol +1 -1
- package/src/state/Value.sol +1 -1
- package/src/state/ValueArray.sol +1 -1
- package/src/state/ValueStack.sol +1 -1
- package/src/test-helpers/BridgeTester.sol +3 -2
- package/src/test-helpers/CryptographyPrimitivesTester.sol +1 -1
- package/src/test-helpers/EthVault.sol +20 -0
- package/src/test-helpers/InterfaceCompatibilityTester.sol +1 -1
- package/src/test-helpers/MessageTester.sol +1 -1
- package/src/test-helpers/OutboxWithoutOptTester.sol +1 -1
- package/src/test-helpers/RollupMock.sol +1 -1
- package/src/test-helpers/ValueArrayTester.sol +1 -1
- package/hardhat.config.ts +0 -164
package/src/bridge/Bridge.sol
CHANGED
@@ -1,22 +1,13 @@
|
|
1
1
|
// Copyright 2021-2022, Offchain Labs, Inc.
|
2
|
-
// For license information, see https://github.com/nitro/blob/
|
2
|
+
// For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE
|
3
3
|
// SPDX-License-Identifier: BUSL-1.1
|
4
4
|
|
5
5
|
pragma solidity ^0.8.4;
|
6
6
|
|
7
7
|
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
|
8
8
|
import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol";
|
9
|
-
|
10
|
-
import
|
11
|
-
NotContract,
|
12
|
-
NotRollupOrOwner,
|
13
|
-
NotDelayedInbox,
|
14
|
-
NotSequencerInbox,
|
15
|
-
NotOutbox,
|
16
|
-
InvalidOutboxSet,
|
17
|
-
BadSequencerMessageNumber
|
18
|
-
} from "../libraries/Error.sol";
|
19
|
-
import "./IBridge.sol";
|
9
|
+
import "./AbsBridge.sol";
|
10
|
+
import "./IEthBridge.sol";
|
20
11
|
import "./Messages.sol";
|
21
12
|
import "../libraries/DelegateCallAware.sol";
|
22
13
|
|
@@ -24,260 +15,40 @@ import {L1MessageType_batchPostingReport} from "../libraries/MessageTypes.sol";
|
|
24
15
|
|
25
16
|
/**
|
26
17
|
* @title Staging ground for incoming and outgoing messages
|
27
|
-
* @notice
|
28
|
-
* It is also the ETH escrow for value sent with these messages.
|
29
|
-
* Since the escrow is held here, this contract also contains a list of allowed
|
30
|
-
* outboxes that can make calls from here and withdraw this escrow.
|
18
|
+
* @notice It is also the ETH escrow for value sent with these messages.
|
31
19
|
*/
|
32
|
-
contract Bridge is
|
20
|
+
contract Bridge is AbsBridge, IEthBridge {
|
33
21
|
using AddressUpgradeable for address;
|
34
22
|
|
35
|
-
|
36
|
-
uint256 index;
|
37
|
-
bool allowed;
|
38
|
-
}
|
39
|
-
|
40
|
-
mapping(address => InOutInfo) private allowedDelayedInboxesMap;
|
41
|
-
mapping(address => InOutInfo) private allowedOutboxesMap;
|
42
|
-
|
43
|
-
address[] public allowedDelayedInboxList;
|
44
|
-
address[] public allowedOutboxList;
|
45
|
-
|
46
|
-
address internal _activeOutbox;
|
47
|
-
|
48
|
-
/// @inheritdoc IBridge
|
49
|
-
bytes32[] public delayedInboxAccs;
|
50
|
-
|
51
|
-
/// @inheritdoc IBridge
|
52
|
-
bytes32[] public sequencerInboxAccs;
|
53
|
-
|
54
|
-
IOwnable public rollup;
|
55
|
-
address public sequencerInbox;
|
56
|
-
|
57
|
-
uint256 public override sequencerReportedSubMessageCount;
|
58
|
-
|
59
|
-
address internal constant EMPTY_ACTIVEOUTBOX = address(type(uint160).max);
|
60
|
-
|
23
|
+
/// @inheritdoc IEthBridge
|
61
24
|
function initialize(IOwnable rollup_) external initializer onlyDelegated {
|
62
25
|
_activeOutbox = EMPTY_ACTIVEOUTBOX;
|
63
26
|
rollup = rollup_;
|
64
27
|
}
|
65
28
|
|
66
|
-
|
67
|
-
if (msg.sender != address(rollup)) {
|
68
|
-
address rollupOwner = rollup.owner();
|
69
|
-
if (msg.sender != rollupOwner) {
|
70
|
-
revert NotRollupOrOwner(msg.sender, address(rollup), rollupOwner);
|
71
|
-
}
|
72
|
-
}
|
73
|
-
_;
|
74
|
-
}
|
75
|
-
|
76
|
-
/// @dev returns the address of current active Outbox, or zero if no outbox is active
|
77
|
-
function activeOutbox() public view returns (address) {
|
78
|
-
address outbox = _activeOutbox;
|
79
|
-
// address zero is returned if no outbox is set, but the value used in storage
|
80
|
-
// is non-zero to save users some gas (as storage refunds are usually maxed out)
|
81
|
-
// EIP-1153 would help here.
|
82
|
-
// we don't return `EMPTY_ACTIVEOUTBOX` to avoid a breaking change on the current api
|
83
|
-
if (outbox == EMPTY_ACTIVEOUTBOX) return address(0);
|
84
|
-
return outbox;
|
85
|
-
}
|
86
|
-
|
87
|
-
function allowedDelayedInboxes(address inbox) external view returns (bool) {
|
88
|
-
return allowedDelayedInboxesMap[inbox].allowed;
|
89
|
-
}
|
90
|
-
|
91
|
-
function allowedOutboxes(address outbox) external view returns (bool) {
|
92
|
-
return allowedOutboxesMap[outbox].allowed;
|
93
|
-
}
|
94
|
-
|
95
|
-
modifier onlySequencerInbox() {
|
96
|
-
if (msg.sender != sequencerInbox) revert NotSequencerInbox(msg.sender);
|
97
|
-
_;
|
98
|
-
}
|
99
|
-
|
100
|
-
function enqueueSequencerMessage(
|
101
|
-
bytes32 dataHash,
|
102
|
-
uint256 afterDelayedMessagesRead,
|
103
|
-
uint256 prevMessageCount,
|
104
|
-
uint256 newMessageCount
|
105
|
-
)
|
106
|
-
external
|
107
|
-
onlySequencerInbox
|
108
|
-
returns (
|
109
|
-
uint256 seqMessageIndex,
|
110
|
-
bytes32 beforeAcc,
|
111
|
-
bytes32 delayedAcc,
|
112
|
-
bytes32 acc
|
113
|
-
)
|
114
|
-
{
|
115
|
-
if (
|
116
|
-
sequencerReportedSubMessageCount != prevMessageCount &&
|
117
|
-
prevMessageCount != 0 &&
|
118
|
-
sequencerReportedSubMessageCount != 0
|
119
|
-
) {
|
120
|
-
revert BadSequencerMessageNumber(sequencerReportedSubMessageCount, prevMessageCount);
|
121
|
-
}
|
122
|
-
sequencerReportedSubMessageCount = newMessageCount;
|
123
|
-
seqMessageIndex = sequencerInboxAccs.length;
|
124
|
-
if (sequencerInboxAccs.length > 0) {
|
125
|
-
beforeAcc = sequencerInboxAccs[sequencerInboxAccs.length - 1];
|
126
|
-
}
|
127
|
-
if (afterDelayedMessagesRead > 0) {
|
128
|
-
delayedAcc = delayedInboxAccs[afterDelayedMessagesRead - 1];
|
129
|
-
}
|
130
|
-
acc = keccak256(abi.encodePacked(beforeAcc, dataHash, delayedAcc));
|
131
|
-
sequencerInboxAccs.push(acc);
|
132
|
-
}
|
133
|
-
|
134
|
-
/// @inheritdoc IBridge
|
135
|
-
function submitBatchSpendingReport(address sender, bytes32 messageDataHash)
|
136
|
-
external
|
137
|
-
onlySequencerInbox
|
138
|
-
returns (uint256)
|
139
|
-
{
|
140
|
-
return
|
141
|
-
addMessageToDelayedAccumulator(
|
142
|
-
L1MessageType_batchPostingReport,
|
143
|
-
sender,
|
144
|
-
uint64(block.number),
|
145
|
-
uint64(block.timestamp), // solhint-disable-line not-rely-on-time,
|
146
|
-
block.basefee,
|
147
|
-
messageDataHash
|
148
|
-
);
|
149
|
-
}
|
150
|
-
|
151
|
-
/// @inheritdoc IBridge
|
29
|
+
/// @inheritdoc IEthBridge
|
152
30
|
function enqueueDelayedMessage(
|
153
31
|
uint8 kind,
|
154
32
|
address sender,
|
155
33
|
bytes32 messageDataHash
|
156
34
|
) external payable returns (uint256) {
|
157
|
-
|
158
|
-
return
|
159
|
-
addMessageToDelayedAccumulator(
|
160
|
-
kind,
|
161
|
-
sender,
|
162
|
-
uint64(block.number),
|
163
|
-
uint64(block.timestamp), // solhint-disable-line not-rely-on-time
|
164
|
-
block.basefee,
|
165
|
-
messageDataHash
|
166
|
-
);
|
35
|
+
return _enqueueDelayedMessage(kind, sender, messageDataHash, msg.value);
|
167
36
|
}
|
168
37
|
|
169
|
-
function
|
170
|
-
|
171
|
-
address sender,
|
172
|
-
uint64 blockNumber,
|
173
|
-
uint64 blockTimestamp,
|
174
|
-
uint256 baseFeeL1,
|
175
|
-
bytes32 messageDataHash
|
176
|
-
) internal returns (uint256) {
|
177
|
-
uint256 count = delayedInboxAccs.length;
|
178
|
-
bytes32 messageHash = Messages.messageHash(
|
179
|
-
kind,
|
180
|
-
sender,
|
181
|
-
blockNumber,
|
182
|
-
blockTimestamp,
|
183
|
-
count,
|
184
|
-
baseFeeL1,
|
185
|
-
messageDataHash
|
186
|
-
);
|
187
|
-
bytes32 prevAcc = 0;
|
188
|
-
if (count > 0) {
|
189
|
-
prevAcc = delayedInboxAccs[count - 1];
|
190
|
-
}
|
191
|
-
delayedInboxAccs.push(Messages.accumulateInboxMessage(prevAcc, messageHash));
|
192
|
-
emit MessageDelivered(
|
193
|
-
count,
|
194
|
-
prevAcc,
|
195
|
-
msg.sender,
|
196
|
-
kind,
|
197
|
-
sender,
|
198
|
-
messageDataHash,
|
199
|
-
baseFeeL1,
|
200
|
-
blockTimestamp
|
201
|
-
);
|
202
|
-
return count;
|
38
|
+
function _transferFunds(uint256) internal override {
|
39
|
+
// do nothing as Eth transfer is part of TX execution
|
203
40
|
}
|
204
41
|
|
205
|
-
function
|
42
|
+
function _executeLowLevelCall(
|
206
43
|
address to,
|
207
44
|
uint256 value,
|
208
|
-
bytes
|
209
|
-
)
|
210
|
-
if (!allowedOutboxesMap[msg.sender].allowed) revert NotOutbox(msg.sender);
|
211
|
-
if (data.length > 0 && !to.isContract()) revert NotContract(to);
|
212
|
-
address prevOutbox = _activeOutbox;
|
213
|
-
_activeOutbox = msg.sender;
|
214
|
-
// We set and reset active outbox around external call so activeOutbox remains valid during call
|
215
|
-
|
216
|
-
// We use a low level call here since we want to bubble up whether it succeeded or failed to the caller
|
217
|
-
// rather than reverting on failure as well as allow contract and non-contract calls
|
45
|
+
bytes memory data
|
46
|
+
) internal override returns (bool success, bytes memory returnData) {
|
218
47
|
// solhint-disable-next-line avoid-low-level-calls
|
219
48
|
(success, returnData) = to.call{value: value}(data);
|
220
|
-
_activeOutbox = prevOutbox;
|
221
|
-
emit BridgeCallTriggered(msg.sender, to, value, data);
|
222
|
-
}
|
223
|
-
|
224
|
-
function setSequencerInbox(address _sequencerInbox) external onlyRollupOrOwner {
|
225
|
-
sequencerInbox = _sequencerInbox;
|
226
|
-
emit SequencerInboxUpdated(_sequencerInbox);
|
227
49
|
}
|
228
50
|
|
229
|
-
function
|
230
|
-
|
231
|
-
bool alreadyEnabled = info.allowed;
|
232
|
-
emit InboxToggle(inbox, enabled);
|
233
|
-
if (alreadyEnabled == enabled) {
|
234
|
-
return;
|
235
|
-
}
|
236
|
-
if (enabled) {
|
237
|
-
allowedDelayedInboxesMap[inbox] = InOutInfo(allowedDelayedInboxList.length, true);
|
238
|
-
allowedDelayedInboxList.push(inbox);
|
239
|
-
} else {
|
240
|
-
allowedDelayedInboxList[info.index] = allowedDelayedInboxList[
|
241
|
-
allowedDelayedInboxList.length - 1
|
242
|
-
];
|
243
|
-
allowedDelayedInboxesMap[allowedDelayedInboxList[info.index]].index = info.index;
|
244
|
-
allowedDelayedInboxList.pop();
|
245
|
-
delete allowedDelayedInboxesMap[inbox];
|
246
|
-
}
|
51
|
+
function _baseFeeToReport() internal view override returns (uint256) {
|
52
|
+
return block.basefee;
|
247
53
|
}
|
248
|
-
|
249
|
-
function setOutbox(address outbox, bool enabled) external onlyRollupOrOwner {
|
250
|
-
if (outbox == EMPTY_ACTIVEOUTBOX) revert InvalidOutboxSet(outbox);
|
251
|
-
|
252
|
-
InOutInfo storage info = allowedOutboxesMap[outbox];
|
253
|
-
bool alreadyEnabled = info.allowed;
|
254
|
-
emit OutboxToggle(outbox, enabled);
|
255
|
-
if (alreadyEnabled == enabled) {
|
256
|
-
return;
|
257
|
-
}
|
258
|
-
if (enabled) {
|
259
|
-
allowedOutboxesMap[outbox] = InOutInfo(allowedOutboxList.length, true);
|
260
|
-
allowedOutboxList.push(outbox);
|
261
|
-
} else {
|
262
|
-
allowedOutboxList[info.index] = allowedOutboxList[allowedOutboxList.length - 1];
|
263
|
-
allowedOutboxesMap[allowedOutboxList[info.index]].index = info.index;
|
264
|
-
allowedOutboxList.pop();
|
265
|
-
delete allowedOutboxesMap[outbox];
|
266
|
-
}
|
267
|
-
}
|
268
|
-
|
269
|
-
function setSequencerReportedSubMessageCount(uint256 newMsgCount) external onlyRollupOrOwner {
|
270
|
-
sequencerReportedSubMessageCount = newMsgCount;
|
271
|
-
}
|
272
|
-
|
273
|
-
function delayedMessageCount() external view override returns (uint256) {
|
274
|
-
return delayedInboxAccs.length;
|
275
|
-
}
|
276
|
-
|
277
|
-
function sequencerMessageCount() external view returns (uint256) {
|
278
|
-
return sequencerInboxAccs.length;
|
279
|
-
}
|
280
|
-
|
281
|
-
/// @dev For the classic -> nitro migration. TODO: remove post-migration.
|
282
|
-
function acceptFundsFromOldBridge() external payable {}
|
283
54
|
}
|
@@ -0,0 +1,74 @@
|
|
1
|
+
// Copyright 2021-2022, Offchain Labs, Inc.
|
2
|
+
// For license information, see https://github.com/nitro/blob/master/LICENSE
|
3
|
+
// SPDX-License-Identifier: BUSL-1.1
|
4
|
+
|
5
|
+
pragma solidity ^0.8.4;
|
6
|
+
|
7
|
+
import "./AbsBridge.sol";
|
8
|
+
import "./IERC20Bridge.sol";
|
9
|
+
import "../libraries/AddressAliasHelper.sol";
|
10
|
+
import {InvalidTokenSet, CallTargetNotAllowed} from "../libraries/Error.sol";
|
11
|
+
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
12
|
+
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
|
13
|
+
|
14
|
+
/**
|
15
|
+
* @title Staging ground for incoming and outgoing messages
|
16
|
+
* @notice Unlike the standard Eth bridge, native token bridge escrows the custom ERC20 token which is
|
17
|
+
* used as native currency on L2.
|
18
|
+
*/
|
19
|
+
contract ERC20Bridge is AbsBridge, IERC20Bridge {
|
20
|
+
using SafeERC20 for IERC20;
|
21
|
+
|
22
|
+
/// @inheritdoc IERC20Bridge
|
23
|
+
address public nativeToken;
|
24
|
+
|
25
|
+
/// @inheritdoc IERC20Bridge
|
26
|
+
function initialize(IOwnable rollup_, address nativeToken_) external initializer onlyDelegated {
|
27
|
+
if (nativeToken_ == address(0)) revert InvalidTokenSet(nativeToken_);
|
28
|
+
nativeToken = nativeToken_;
|
29
|
+
_activeOutbox = EMPTY_ACTIVEOUTBOX;
|
30
|
+
rollup = rollup_;
|
31
|
+
}
|
32
|
+
|
33
|
+
/// @inheritdoc IERC20Bridge
|
34
|
+
function enqueueDelayedMessage(
|
35
|
+
uint8 kind,
|
36
|
+
address sender,
|
37
|
+
bytes32 messageDataHash,
|
38
|
+
uint256 tokenFeeAmount
|
39
|
+
) external returns (uint256) {
|
40
|
+
return _enqueueDelayedMessage(kind, sender, messageDataHash, tokenFeeAmount);
|
41
|
+
}
|
42
|
+
|
43
|
+
function _transferFunds(uint256 amount) internal override {
|
44
|
+
// fetch native token from Inbox
|
45
|
+
IERC20(nativeToken).safeTransferFrom(msg.sender, address(this), amount);
|
46
|
+
}
|
47
|
+
|
48
|
+
function _executeLowLevelCall(
|
49
|
+
address to,
|
50
|
+
uint256 value,
|
51
|
+
bytes memory data
|
52
|
+
) internal override returns (bool success, bytes memory returnData) {
|
53
|
+
if (to == nativeToken) {
|
54
|
+
revert CallTargetNotAllowed(nativeToken);
|
55
|
+
}
|
56
|
+
|
57
|
+
// first release native token
|
58
|
+
IERC20(nativeToken).safeTransfer(to, value);
|
59
|
+
success = true;
|
60
|
+
|
61
|
+
// if there's data do additional contract call
|
62
|
+
if (data.length > 0) {
|
63
|
+
// solhint-disable-next-line avoid-low-level-calls
|
64
|
+
(success, returnData) = to.call(data);
|
65
|
+
}
|
66
|
+
}
|
67
|
+
|
68
|
+
function _baseFeeToReport() internal pure override returns (uint256) {
|
69
|
+
// ArbOs uses formula 'l1BaseFee * (1400 + 6 * calldataLengthInBytes)' to calculate retryable ticket's
|
70
|
+
// submission fee. When custom ERC20 token is used to pay for fees, submission fee shall be 0. That's
|
71
|
+
// why baseFee is reported as 0 here.
|
72
|
+
return 0;
|
73
|
+
}
|
74
|
+
}
|
@@ -0,0 +1,141 @@
|
|
1
|
+
// Copyright 2021-2022, Offchain Labs, Inc.
|
2
|
+
// For license information, see https://github.com/nitro/blob/master/LICENSE
|
3
|
+
// SPDX-License-Identifier: BUSL-1.1
|
4
|
+
|
5
|
+
pragma solidity ^0.8.4;
|
6
|
+
|
7
|
+
import "./AbsInbox.sol";
|
8
|
+
import "./IERC20Inbox.sol";
|
9
|
+
import "./IERC20Bridge.sol";
|
10
|
+
import "../libraries/AddressAliasHelper.sol";
|
11
|
+
import {L1MessageType_ethDeposit} from "../libraries/MessageTypes.sol";
|
12
|
+
import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol";
|
13
|
+
import {IERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
|
14
|
+
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
|
15
|
+
|
16
|
+
/**
|
17
|
+
* @title Inbox for user and contract originated messages
|
18
|
+
* @notice Messages created via this inbox are enqueued in the delayed accumulator
|
19
|
+
* to await inclusion in the SequencerInbox
|
20
|
+
*/
|
21
|
+
contract ERC20Inbox is AbsInbox, IERC20Inbox {
|
22
|
+
using SafeERC20 for IERC20;
|
23
|
+
|
24
|
+
/// @inheritdoc IInbox
|
25
|
+
function initialize(IBridge _bridge, ISequencerInbox _sequencerInbox)
|
26
|
+
external
|
27
|
+
initializer
|
28
|
+
onlyDelegated
|
29
|
+
{
|
30
|
+
__AbsInbox_init(_bridge, _sequencerInbox);
|
31
|
+
|
32
|
+
// inbox holds native token in transit used to pay for retryable tickets, approve bridge to use it
|
33
|
+
address nativeToken = IERC20Bridge(address(bridge)).nativeToken();
|
34
|
+
IERC20(nativeToken).approve(address(bridge), type(uint256).max);
|
35
|
+
}
|
36
|
+
|
37
|
+
/// @inheritdoc IERC20Inbox
|
38
|
+
function depositERC20(uint256 amount) public whenNotPaused onlyAllowed returns (uint256) {
|
39
|
+
address dest = msg.sender;
|
40
|
+
|
41
|
+
// solhint-disable-next-line avoid-tx-origin
|
42
|
+
if (AddressUpgradeable.isContract(msg.sender) || tx.origin != msg.sender) {
|
43
|
+
// isContract check fails if this function is called during a contract's constructor.
|
44
|
+
dest = AddressAliasHelper.applyL1ToL2Alias(msg.sender);
|
45
|
+
}
|
46
|
+
|
47
|
+
return
|
48
|
+
_deliverMessage(
|
49
|
+
L1MessageType_ethDeposit,
|
50
|
+
msg.sender,
|
51
|
+
abi.encodePacked(dest, amount),
|
52
|
+
amount
|
53
|
+
);
|
54
|
+
}
|
55
|
+
|
56
|
+
/// @inheritdoc IERC20Inbox
|
57
|
+
function createRetryableTicket(
|
58
|
+
address to,
|
59
|
+
uint256 l2CallValue,
|
60
|
+
uint256 maxSubmissionCost,
|
61
|
+
address excessFeeRefundAddress,
|
62
|
+
address callValueRefundAddress,
|
63
|
+
uint256 gasLimit,
|
64
|
+
uint256 maxFeePerGas,
|
65
|
+
uint256 tokenTotalFeeAmount,
|
66
|
+
bytes calldata data
|
67
|
+
) external whenNotPaused onlyAllowed returns (uint256) {
|
68
|
+
return
|
69
|
+
_createRetryableTicket(
|
70
|
+
to,
|
71
|
+
l2CallValue,
|
72
|
+
maxSubmissionCost,
|
73
|
+
excessFeeRefundAddress,
|
74
|
+
callValueRefundAddress,
|
75
|
+
gasLimit,
|
76
|
+
maxFeePerGas,
|
77
|
+
tokenTotalFeeAmount,
|
78
|
+
data
|
79
|
+
);
|
80
|
+
}
|
81
|
+
|
82
|
+
/// @inheritdoc IERC20Inbox
|
83
|
+
function unsafeCreateRetryableTicket(
|
84
|
+
address to,
|
85
|
+
uint256 l2CallValue,
|
86
|
+
uint256 maxSubmissionCost,
|
87
|
+
address excessFeeRefundAddress,
|
88
|
+
address callValueRefundAddress,
|
89
|
+
uint256 gasLimit,
|
90
|
+
uint256 maxFeePerGas,
|
91
|
+
uint256 tokenTotalFeeAmount,
|
92
|
+
bytes calldata data
|
93
|
+
) public whenNotPaused onlyAllowed returns (uint256) {
|
94
|
+
return
|
95
|
+
_unsafeCreateRetryableTicket(
|
96
|
+
to,
|
97
|
+
l2CallValue,
|
98
|
+
maxSubmissionCost,
|
99
|
+
excessFeeRefundAddress,
|
100
|
+
callValueRefundAddress,
|
101
|
+
gasLimit,
|
102
|
+
maxFeePerGas,
|
103
|
+
tokenTotalFeeAmount,
|
104
|
+
data
|
105
|
+
);
|
106
|
+
}
|
107
|
+
|
108
|
+
/// @inheritdoc IInbox
|
109
|
+
function calculateRetryableSubmissionFee(uint256, uint256)
|
110
|
+
public
|
111
|
+
pure
|
112
|
+
override(AbsInbox, IInbox)
|
113
|
+
returns (uint256)
|
114
|
+
{
|
115
|
+
// retryable ticket's submission fee is not charged when ERC20 token is used to pay for fees
|
116
|
+
return 0;
|
117
|
+
}
|
118
|
+
|
119
|
+
function _deliverToBridge(
|
120
|
+
uint8 kind,
|
121
|
+
address sender,
|
122
|
+
bytes32 messageDataHash,
|
123
|
+
uint256 tokenAmount
|
124
|
+
) internal override returns (uint256) {
|
125
|
+
// fetch native token from sender if inbox doesn't already hold enough tokens to pay for fees
|
126
|
+
address nativeToken = IERC20Bridge(address(bridge)).nativeToken();
|
127
|
+
uint256 inboxNativeTokenBalance = IERC20(nativeToken).balanceOf(address(this));
|
128
|
+
if (inboxNativeTokenBalance < tokenAmount) {
|
129
|
+
uint256 diff = tokenAmount - inboxNativeTokenBalance;
|
130
|
+
IERC20(nativeToken).safeTransferFrom(msg.sender, address(this), diff);
|
131
|
+
}
|
132
|
+
|
133
|
+
return
|
134
|
+
IERC20Bridge(address(bridge)).enqueueDelayedMessage(
|
135
|
+
kind,
|
136
|
+
AddressAliasHelper.applyL1ToL2Alias(sender),
|
137
|
+
messageDataHash,
|
138
|
+
tokenAmount
|
139
|
+
);
|
140
|
+
}
|
141
|
+
}
|
@@ -0,0 +1,27 @@
|
|
1
|
+
// Copyright 2021-2022, Offchain Labs, Inc.
|
2
|
+
// For license information, see https://github.com/nitro/blob/master/LICENSE
|
3
|
+
// SPDX-License-Identifier: BUSL-1.1
|
4
|
+
|
5
|
+
pragma solidity ^0.8.4;
|
6
|
+
|
7
|
+
import "./AbsOutbox.sol";
|
8
|
+
|
9
|
+
contract ERC20Outbox is AbsOutbox {
|
10
|
+
uint256 private constant AMOUNT_DEFAULT_CONTEXT = type(uint256).max;
|
11
|
+
|
12
|
+
function l2ToL1WithdrawalAmount() external view returns (uint256) {
|
13
|
+
uint256 amount = context.withdrawalAmount;
|
14
|
+
if (amount == AMOUNT_DEFAULT_CONTEXT) return 0;
|
15
|
+
return amount;
|
16
|
+
}
|
17
|
+
|
18
|
+
/// @inheritdoc AbsOutbox
|
19
|
+
function _defaultContextAmount() internal pure override returns (uint256) {
|
20
|
+
return AMOUNT_DEFAULT_CONTEXT;
|
21
|
+
}
|
22
|
+
|
23
|
+
/// @inheritdoc AbsOutbox
|
24
|
+
function _amountToSetInContext(uint256 value) internal pure override returns (uint256) {
|
25
|
+
return value;
|
26
|
+
}
|
27
|
+
}
|
package/src/bridge/IBridge.sol
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
// Copyright 2021-2022, Offchain Labs, Inc.
|
2
|
-
// For license information, see https://github.com/nitro/blob/
|
2
|
+
// For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE
|
3
3
|
// SPDX-License-Identifier: BUSL-1.1
|
4
4
|
|
5
5
|
// solhint-disable-next-line compiler-version
|
@@ -54,17 +54,6 @@ interface IBridge {
|
|
54
54
|
|
55
55
|
function sequencerReportedSubMessageCount() external view returns (uint256);
|
56
56
|
|
57
|
-
/**
|
58
|
-
* @dev Enqueue a message in the delayed inbox accumulator.
|
59
|
-
* These messages are later sequenced in the SequencerInbox, either
|
60
|
-
* by the sequencer as part of a normal batch, or by force inclusion.
|
61
|
-
*/
|
62
|
-
function enqueueDelayedMessage(
|
63
|
-
uint8 kind,
|
64
|
-
address sender,
|
65
|
-
bytes32 messageDataHash
|
66
|
-
) external payable returns (uint256);
|
67
|
-
|
68
57
|
function executeCall(
|
69
58
|
address to,
|
70
59
|
uint256 value,
|
@@ -108,8 +97,4 @@ interface IBridge {
|
|
108
97
|
function setDelayedInbox(address inbox, bool enabled) external;
|
109
98
|
|
110
99
|
function setOutbox(address inbox, bool enabled) external;
|
111
|
-
|
112
|
-
// ---------- initializer ----------
|
113
|
-
|
114
|
-
function initialize(IOwnable rollup_) external;
|
115
100
|
}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
// Copyright 2021-2022, Offchain Labs, Inc.
|
2
|
-
// For license information, see https://github.com/nitro/blob/
|
2
|
+
// For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE
|
3
3
|
// SPDX-License-Identifier: BUSL-1.1
|
4
4
|
|
5
5
|
// solhint-disable-next-line compiler-version
|
@@ -0,0 +1,35 @@
|
|
1
|
+
// Copyright 2021-2022, Offchain Labs, Inc.
|
2
|
+
// For license information, see https://github.com/nitro/blob/master/LICENSE
|
3
|
+
// SPDX-License-Identifier: BUSL-1.1
|
4
|
+
|
5
|
+
// solhint-disable-next-line compiler-version
|
6
|
+
pragma solidity >=0.6.9 <0.9.0;
|
7
|
+
|
8
|
+
import "./IOwnable.sol";
|
9
|
+
import "./IBridge.sol";
|
10
|
+
|
11
|
+
interface IERC20Bridge is IBridge {
|
12
|
+
/**
|
13
|
+
* @dev token that is escrowed in bridge on L1 side and minted on L2 as native currency.
|
14
|
+
* Also fees are paid in this token. ERC777, fee on transfer tokens and rebasing tokens
|
15
|
+
* are not supported to be used as chain's native token, as they can break collateralization
|
16
|
+
* invariants.
|
17
|
+
*/
|
18
|
+
function nativeToken() external returns (address);
|
19
|
+
|
20
|
+
/**
|
21
|
+
* @dev Enqueue a message in the delayed inbox accumulator.
|
22
|
+
* These messages are later sequenced in the SequencerInbox, either
|
23
|
+
* by the sequencer as part of a normal batch, or by force inclusion.
|
24
|
+
*/
|
25
|
+
function enqueueDelayedMessage(
|
26
|
+
uint8 kind,
|
27
|
+
address sender,
|
28
|
+
bytes32 messageDataHash,
|
29
|
+
uint256 tokenFeeAmount
|
30
|
+
) external returns (uint256);
|
31
|
+
|
32
|
+
// ---------- initializer ----------
|
33
|
+
|
34
|
+
function initialize(IOwnable rollup_, address nativeToken_) external;
|
35
|
+
}
|