Skip to content

Commit

Permalink
test: add foundry unit test coverage for token bridge factory (#64)
Browse files Browse the repository at this point in the history
* Draft implementation of constructor bytecode getter

* Add function for getting the constructor bytecode

* Check constructor size and throw error if unexpected one

* Add constructor check rationale

* Refactor

* Add to CI

* Check CI will fail if constructor is modified

* Revert "Check CI will fail if constructor is modified"

This reverts commit 6389b4a.

* Clean up

* Change _creationCodeFor so that it uses the same constructor as the one compiler would generate

This will enable source code verification of the deployed token bridge contracts on the child chain

* Init logic contract

* Make deployment test more complete

* Remove comment

* Add deployment script

* Calculate properly canonical address of L1 router

* feat: remove canonicalL2FactoryAddress dependency

* docs: explain

* format: fix

* Extract code creation function to lib

* fix: remove create1 import

* fix: fmt

* feat: add create1 util

* feat: remove logic salt

* fix: interface name

* Verify creation code generation

* feat: cache and store deployment

* refactor: lower contract size

* feat: getTokenBridgeDeployment

* Use chai test format

* Add aeWETH/UpgradeExecutor constructor size check

* feat: add e2e tests to CI (#18)

* Add e2e tests to CI

* Use custom testnode branch

* Set testnode ref

* Set correct ref

* Specify main

* Update comment

Co-authored-by: gzeon <[email protected]>

* Remove intermediary function

* Update out-of-date comments

* feat: disable template update

* chore: rename error

* ci: wait-for-l3

* ci: switch back to main

* Test canonical address for multicall, beacon proxy and proxy admin are correct

* refactor: _deployProxyWithSalt

* fix: remove Create1 lib and use empty salt instead

* fix: beacon deploy

* Update local deployment scripts

* Add test info

* Refactor test to support latest contract changes

* Fetch rollup owner from logs

* Update prod deployment script

* Remove unnecessary structs

* refactor: inline internal methods

* refactor: flatten more

* refactor: _computeAddressAtNonce0

* refactor: remove return val

* refactor: separate l1 l2 deployment

* feat: add deployment setter

* fix: l2 multicall template

* Bring deployment and test scripts up to date

* docs: sendRetryable

* fix: remove some redundent logic

* Run e2e tests on chain that uses fee token

* Change action name

* fix: remove getCanonicalL1RouterAddress

* fix: do not set weth when isUsingFeeToken

* docs: add more comments

* docs: _computeAddressAtNonce0

* refactor: trycatch

* rename: event OrbitTokenBridgeDeploymentSet

* feat: L1AtomicTokenBridgeCreator_AlreadyCreated

* Remove unused error

* Add L1AtomicTokenBridgeCreator init tests

* Test setTemplates

* refactor: calc salt in deploySeedProxy

* refactor: inline oneline methods

* Add L1AtomicTokenBridgeCreator init tests

* Test setTemplates

* Update nitro-contracts ref for testing

* Add createTokenBridge tests

* Add more L1 creator tests

* Test ERC20 chain

* Add skeleton for L2AtomicTokenBridgeFactory tests

* Add more checks for L2 factory

* fix: unsalted deployment

* Complete L2 factory tests

* Add init check for StandardArbERC20 logic

* Fix L2 multicall address prediction

* test: AtomicTokenBridgeCreator in foundry

* test: deployment fail case

* feat: allow retry

* fix: typo

* test: fix new test

* docs: more comments

* docs: explain more

* refactor: rename to resend

* If rollupOwner is a contract, alias its address when sending to L2

* Move aliasing rollupOwner to L1 creator

* Add more L1 factory tests

* Add missing L1 factory tests

* refactor: scope chainId to reduce stack size

* Stack too deep fix

* Adapt tests

---------

Co-authored-by: gzeon <[email protected]>
Co-authored-by: gzeon <[email protected]>
  • Loading branch information
3 people authored Dec 21, 2023
1 parent 63fce94 commit 17908eb
Show file tree
Hide file tree
Showing 5 changed files with 1,381 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
[submodule "lib/nitro-contracts"]
path = lib/nitro-contracts
url = [email protected]:OffchainLabs/nitro-contracts.git
branch = feature-orbit-bridge
branch = v1.1.0
2 changes: 1 addition & 1 deletion lib/nitro-contracts
Submodule nitro-contracts updated 56 files
+1 −1 .github/workflows/contract-tests.yml
+2 −0 .prettierignore
+1 −1 deploy/SequencerInbox.js
+1 −1 deploy/SequencerInboxStubCreator.js
+16 −0 hardhat.config.ts
+9 −8 package.json
+4 −0 scripts/config.ts.example
+3 −6 scripts/createERC20Rollup.ts
+65 −36 scripts/deployment.ts
+39 −5 scripts/rollupCreation.ts
+11 −9 scripts/testSetup.ts
+7 −1 src/bridge/AbsBridge.sol
+27 −6 src/bridge/AbsInbox.sol
+32 −1 src/bridge/AbsOutbox.sol
+20 −5 src/bridge/ERC20Bridge.sol
+2 −0 src/bridge/ERC20Inbox.sol
+255 −0 src/bridge/GasRefunder.sol
+4 −0 src/bridge/IBridge.sol
+5 −3 src/bridge/IERC20Bridge.sol
+5 −0 src/bridge/IInboxBase.sol
+10 −0 src/bridge/IOutbox.sol
+4 −0 src/bridge/ISequencerInbox.sol
+2 −1 src/bridge/Inbox.sol
+19 −5 src/bridge/SequencerInbox.sol
+0 −3 src/libraries/Constants.sol
+10 −1 src/libraries/Error.sol
+4 −0 src/mocks/BridgeStub.sol
+9 −0 src/mocks/InboxStub.sol
+3 −2 src/mocks/SequencerInboxStub.sol
+2 −1 src/mocks/Simple.sol
+82 −0 src/mocks/UpgradeExecutorMock.sol
+16 −0 src/node-interface/NodeInterface.sol
+6 −0 src/precompiles/ArbOwner.sol
+3 −0 src/precompiles/ArbOwnerPublic.sol
+10 −1 src/rollup/AbsRollupEventInbox.sol
+51 −159 src/rollup/BridgeCreator.sol
+149 −0 src/rollup/DeployHelper.sol
+0 −64 src/rollup/IBridgeCreator.sol
+2 −0 src/rollup/IRollupEventInbox.sol
+143 −45 src/rollup/RollupCreator.sol
+26 −4 src/rollup/RollupUserLogic.sol
+4 −0 src/test-helpers/BridgeTester.sol
+6 −0 src/test-helpers/OutboxWithoutOptTester.sol
+16 −0 src/test-helpers/TestToken.sol
+265 −63 test/contract/arbRollup.spec.ts
+2 −2 test/contract/sequencerInboxForceInclude.spec.ts
+22 −34 test/foundry/AbsInbox.t.sol
+118 −77 test/foundry/BridgeCreator.t.sol
+57 −21 test/foundry/ERC20Bridge.t.sol
+5 −6 test/foundry/ERC20Inbox.t.sol
+5 −5 test/foundry/Inbox.t.sol
+272 −16 test/foundry/RollupCreator.t.sol
+3 −3 test/storage/Bridge.dot
+6 −3 test/storage/Inbox.dot
+5 −2 test/storage/Outbox.dot
+765 −822 yarn.lock
Loading

0 comments on commit 17908eb

Please sign in to comment.