diff --git a/.github/workflows/protocol.yml b/.github/workflows/protocol.yml index c27a94d479e..2340a2d9be9 100644 --- a/.github/workflows/protocol.yml +++ b/.github/workflows/protocol.yml @@ -34,24 +34,16 @@ jobs: - name: Unit tests working-directory: ./packages/protocol - run: pnpm clean && pnpm test - - - name: Format solidity && update contract layout table - working-directory: ./packages/protocol - run: pnpm layout && forge fmt + run: pnpm clean && forge fmt && pnpm test:l1 && pnpm layout:l1 && pnpm test:l2 && pnpm layout:l2 - name: Commit contract layout table uses: stefanzweifel/git-auto-commit-action@v5 with: - commit_message: "forge fmt & update contract layout table" + commit_message: "forge fmt & update contract layout tables" - name: Generate genesis working-directory: ./packages/protocol - run: pnpm test:genesis - - - name: Run snapshot (Foundry) - working-directory: ./packages/protocol - run: pnpm snapshot + run: pnpm genesis:test - name: Deploy L1 contracts working-directory: ./packages/protocol @@ -60,4 +52,4 @@ jobs: while ! nc -z localhost 8545; do sleep 1 done - pnpm test:deploy + pnpm test:deploy:l1 diff --git a/.gitignore b/.gitignore index 86e934589eb..0d0cf5a22b0 100644 --- a/.gitignore +++ b/.gitignore @@ -116,7 +116,6 @@ __pycache__/ # VSCode .vscode/launch.json -packages/protocol/config.js .vercel # Idea diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 6106d8ce7c8..607076805a4 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -5,7 +5,7 @@ "packages/fork-diff": "0.6.0", "packages/guardian-prover-health-check": "0.1.0", "packages/guardian-prover-health-check-ui": "0.2.0", - "packages/protocol": "1.9.0", + "packages/protocol": "1.8.0", "packages/relayer": "0.12.0", "packages/snaefell-ui": "1.1.0", "packages/supplementary-contracts": "1.0.0", diff --git a/_typos.toml b/_typos.toml index 950bca673d7..e0ba4825a7b 100644 --- a/_typos.toml +++ b/_typos.toml @@ -18,9 +18,7 @@ extend-exclude = [ "go.mod", "CHANGELOG.md", "packages/protocol/audit/code4rena-2024-03-taiko-final-report.md", - "packages/protocol/contracts/automata-attestation/**", - "packages/protocol/contracts/thirdparty/**", - "packages/protocol/contracts/compiled/**", + "packages/protocol/contracts/layer1/automata-attestation/**", "packages/protocol/deployments/**", # TODO: fix typos and remove these "packages/taiko-client/**", diff --git a/packages/protocol/.eslintignore b/packages/protocol/.eslintignore index dcdd38e4805..1ed07294289 100644 --- a/packages/protocol/.eslintignore +++ b/packages/protocol/.eslintignore @@ -3,5 +3,6 @@ artifacts cache coverage lib -contracts/test/thirdparty/ -contracts/automata-attestation/ \ No newline at end of file +test/shared/thirdparty/ +contracts/layer1/automata-attestation/ +monitors/ \ No newline at end of file diff --git a/packages/protocol/.gitignore b/packages/protocol/.gitignore index 736dd497a49..610554964aa 100644 --- a/packages/protocol/.gitignore +++ b/packages/protocol/.gitignore @@ -14,6 +14,7 @@ yarn-error.log* package-lock.json npm-debug.log* typechain-types +test/genesis/generate/data # Hardhat files cache diff --git a/packages/protocol/.solhint.json b/packages/protocol/.solhint.json index cd602639ace..ee0c7f96812 100644 --- a/packages/protocol/.solhint.json +++ b/packages/protocol/.solhint.json @@ -3,7 +3,7 @@ "rules": { "avoid-low-level-calls": "off", "avoid-tx-origin": "off", - "compiler-version": ["error", "0.8.27"], + "compiler-version": ["error", "^0.8.24"], "func-name-mixedcase": "off", "func-visibility": ["error", { "ignoreConstructors": true }], "max-line-length": ["error", 120], diff --git a/packages/protocol/.solhintignore b/packages/protocol/.solhintignore index 9597bc92c5d..b0045ae5f33 100644 --- a/packages/protocol/.solhintignore +++ b/packages/protocol/.solhintignore @@ -1,8 +1,4 @@ node_modules/ lib/ -contracts/test/TestLibRLPReader.sol -**/contracts/thirdparty/**/*.sol -/contracts/automata-attestation/ -test/thirdparty/ -test/GasComparison.t.sol -test/TestLn.sol \ No newline at end of file +contracts/layer1/automata-attestation/ +test/shared/thirdparty/ diff --git a/packages/protocol/CHANGELOG.md b/packages/protocol/CHANGELOG.md index 0631c10da15..02a6798bdcf 100644 --- a/packages/protocol/CHANGELOG.md +++ b/packages/protocol/CHANGELOG.md @@ -1,120 +1,5 @@ # Changelog -## [1.9.0](https://github.com/taikoxyz/taiko-mono/compare/protocol-v1.8.0...protocol-v1.9.0) (2024-09-09) - - -### Features - -* **protocol:** add `DevnetTaikoL1` ([#17900](https://github.com/taikoxyz/taiko-mono/issues/17900)) ([d864cea](https://github.com/taikoxyz/taiko-mono/commit/d864cea2eb8346127992acfbd9012e675a3400cc)) -* **protocol:** add `proveBlocks` method to `ProverSet` ([#18025](https://github.com/taikoxyz/taiko-mono/issues/18025)) ([36a2ae5](https://github.com/taikoxyz/taiko-mono/commit/36a2ae51c21a2359179755457a8933a346ccd8b3)) -* **protocol:** add `proveBlocks` to TaikoL1.sol ([fe687b3](https://github.com/taikoxyz/taiko-mono/commit/fe687b378fcb440184fd423088432dc63cf5989e)) -* **protocol:** add `TIER_ZKVM_RISC0` tier and `HeklaTierProvider` ([#17913](https://github.com/taikoxyz/taiko-mono/issues/17913)) ([64ed666](https://github.com/taikoxyz/taiko-mono/commit/64ed66628a18cb1b3fff2c4ab5d3c0149288dfe6)) -* **protocol:** add a batch proposing block function ([#17864](https://github.com/taikoxyz/taiko-mono/issues/17864)) ([3649785](https://github.com/taikoxyz/taiko-mono/commit/36497857dd3d5edb718a5cb0057327f3cde39c02)) -* **protocol:** add ComposeVerifier, TeeAnyVerifier, and ZkAnyVerifier ([ee464ca](https://github.com/taikoxyz/taiko-mono/commit/ee464caef68fdec325aa22758bb69e17dd039794)) -* **protocol:** add EIP-2612 (permit extension) to bridged ERC20 tokens ([#17818](https://github.com/taikoxyz/taiko-mono/issues/17818)) ([185ef91](https://github.com/taikoxyz/taiko-mono/commit/185ef91d8debb0c3a88734f2552ca396c8d23a66)) -* **protocol:** add preconfirmation support based on https://github.com/taikoxyz/taiko-mono/pull/17654 (with some renaming) (https://github.com/taikoxyz/taiko-mono/issues/14793) ([17d67d7](https://github.com/taikoxyz/taiko-mono/commit/17d67d74c511bc11c2b7d821d8a381f74ef7b6a1)) -* **protocol:** add proposeBlock2 in TaikoL1.sol and approve2 in GuardianProver.sol ([17d67d7](https://github.com/taikoxyz/taiko-mono/commit/17d67d74c511bc11c2b7d821d8a381f74ef7b6a1)) -* **protocol:** add proposer address to getMinTier func ([#17919](https://github.com/taikoxyz/taiko-mono/issues/17919)) ([d6ea6f3](https://github.com/taikoxyz/taiko-mono/commit/d6ea6f33d6bf54cba3bd6ab153e38d09abf19912)) -* **protocol:** add SP1 verification support ([#17861](https://github.com/taikoxyz/taiko-mono/issues/17861)) ([2936312](https://github.com/taikoxyz/taiko-mono/commit/29363123233f9d2d749eb626095d0c645801e384)) -* **protocol:** add withdraw eth function to proverset ([#17800](https://github.com/taikoxyz/taiko-mono/issues/17800)) ([bb2abc5](https://github.com/taikoxyz/taiko-mono/commit/bb2abc510c98e62c89e0bfd9382c11720fb9edc7)) -* **protocol:** adjust gas excess once the gas target has changed ([a1e217e](https://github.com/taikoxyz/taiko-mono/commit/a1e217e457546d63a89da0b02135b3b63b22d19e)) -* **protocol:** allow a grace period (4h) to defer proof submission to reduce cost ([fe687b3](https://github.com/taikoxyz/taiko-mono/commit/fe687b378fcb440184fd423088432dc63cf5989e)) -* **protocol:** allow any address to withdraw token to the recipient address ([#17843](https://github.com/taikoxyz/taiko-mono/issues/17843)) ([3d89d24](https://github.com/taikoxyz/taiko-mono/commit/3d89d24b14fea7b9e59659e689c3011fbcf4b852)) -* **protocol:** allow contract proposers to use calldata for DA ([17d67d7](https://github.com/taikoxyz/taiko-mono/commit/17d67d74c511bc11c2b7d821d8a381f74ef7b6a1)) -* **protocol:** allow msg.sender to customize block proposer addresses ([#18048](https://github.com/taikoxyz/taiko-mono/issues/18048)) ([22055cc](https://github.com/taikoxyz/taiko-mono/commit/22055cc95e51d07b6b57ab5cb2e4ccd9a97d594a)) -* **protocol:** enhance nextTxId logics in DelegateOwner ([#17718](https://github.com/taikoxyz/taiko-mono/issues/17718)) ([85b2cad](https://github.com/taikoxyz/taiko-mono/commit/85b2cad6216d93e3811bc3523ab8b3200cdfbdd3)) -* **protocol:** improve L2 basefee calculation ([920bd68](https://github.com/taikoxyz/taiko-mono/commit/920bd6873d3e9e1bbb00751fb9c0056ac85b8554)) -* **protocol:** introduce risc0 proof ([#17877](https://github.com/taikoxyz/taiko-mono/issues/17877)) ([bcb57cb](https://github.com/taikoxyz/taiko-mono/commit/bcb57cb81d12d0c09656582ad9140b38015b3a58)) -* **protocol:** protocol monitors ([#18002](https://github.com/taikoxyz/taiko-mono/issues/18002)) ([45b2087](https://github.com/taikoxyz/taiko-mono/commit/45b2087495d4f9e20083ebe2c61ecfe8d252e4b2)) -* **protocol:** relocate L2 base fee parameters to L1 configuration ([17d67d7](https://github.com/taikoxyz/taiko-mono/commit/17d67d74c511bc11c2b7d821d8a381f74ef7b6a1)) -* **protocol:** return verification timestamp in getLastVerifiedBlock ([#17868](https://github.com/taikoxyz/taiko-mono/issues/17868)) ([1998288](https://github.com/taikoxyz/taiko-mono/commit/19982889f7f4c073d182a6076633c5e2c892c73a)) -* **protocol:** revert removing time as input for L2 base fee calculation ([a1e217e](https://github.com/taikoxyz/taiko-mono/commit/a1e217e457546d63a89da0b02135b3b63b22d19e)) -* **protocol:** script of `UpgradeRisc0Verifier` ([#17949](https://github.com/taikoxyz/taiko-mono/issues/17949)) ([fc12e04](https://github.com/taikoxyz/taiko-mono/commit/fc12e040c391e0f37c906b270743d3b57710f69d)) -* **protocol:** support backward-compatible batch-proof verification ([#17968](https://github.com/taikoxyz/taiko-mono/issues/17968)) ([c476aab](https://github.com/taikoxyz/taiko-mono/commit/c476aabe130d151f5678cd35fab99f258997f629)) -* **protocol:** update `HeklaTierProvider` to introduce sp1 proof ([#18022](https://github.com/taikoxyz/taiko-mono/issues/18022)) ([76b6514](https://github.com/taikoxyz/taiko-mono/commit/76b6514fd42ba7fa2124b44443728fa32304c324)) -* **protocol:** update `ontakeForkHeight` to Sep 24, 2024 ([#18046](https://github.com/taikoxyz/taiko-mono/issues/18046)) ([30c9316](https://github.com/taikoxyz/taiko-mono/commit/30c9316aea083d187617f5342fb4a955e604226b)) -* **protocol:** update Hekla `ontakeForkHeight` ([#17983](https://github.com/taikoxyz/taiko-mono/issues/17983)) ([8819e3a](https://github.com/taikoxyz/taiko-mono/commit/8819e3a5a59675dcc6a1f333620ce6e75b7d2887)) -* **protocol:** update Hekla deployment ([#17795](https://github.com/taikoxyz/taiko-mono/issues/17795)) ([cadaef8](https://github.com/taikoxyz/taiko-mono/commit/cadaef882c0751496809c88ee03ff818e49c4b4a)) -* **protocol:** update risc0 verifier contract to release-1.0 ([#17776](https://github.com/taikoxyz/taiko-mono/issues/17776)) ([2dd30ab](https://github.com/taikoxyz/taiko-mono/commit/2dd30ab2dc92b25105f19a4bcc1ddf7b40886039)) -* **protocol:** update script of deploying sp1 ([#18019](https://github.com/taikoxyz/taiko-mono/issues/18019)) ([9464967](https://github.com/taikoxyz/taiko-mono/commit/94649671bdf0304d96bf83d7d18dcbe21eff6067)) -* **protocol:** use SP1 1.2.0-rc with more proof verification tests ([#18001](https://github.com/taikoxyz/taiko-mono/issues/18001)) ([f7bcf1d](https://github.com/taikoxyz/taiko-mono/commit/f7bcf1d63d19b641ac6b9e0e972a7f6e2ec5b38f)) - - -### Bug Fixes - -* **protocol:** fix `chainId` in `HeklaTaikoL1` ([#17912](https://github.com/taikoxyz/taiko-mono/issues/17912)) ([8f31dd0](https://github.com/taikoxyz/taiko-mono/commit/8f31dd0ed519809f0ea0797b1e6b5937ee087108)) -* **protocol:** fix BridgedERC20V2.sol initializer logic ([#17823](https://github.com/taikoxyz/taiko-mono/issues/17823)) ([d538d99](https://github.com/taikoxyz/taiko-mono/commit/d538d99f9542852821d958008d913c028629bbef)) -* **protocol:** fix bug in adjustExcess ([920bd68](https://github.com/taikoxyz/taiko-mono/commit/920bd6873d3e9e1bbb00751fb9c0056ac85b8554)) -* **protocol:** fix tier id conflicts ([#18004](https://github.com/taikoxyz/taiko-mono/issues/18004)) ([0df1ad4](https://github.com/taikoxyz/taiko-mono/commit/0df1ad4274e6ebc3db79acbbdaedbe2d519262d6)) -* **protocol:** make sure new instance is not zero address in SgxVerifier ([#17918](https://github.com/taikoxyz/taiko-mono/issues/17918)) ([d559ce8](https://github.com/taikoxyz/taiko-mono/commit/d559ce80c1314e9ddbe02798f1c61a2e8349da6e)) -* **protocol:** reduce MainnetTaikoL1 code size ([#17792](https://github.com/taikoxyz/taiko-mono/issues/17792)) ([45281b8](https://github.com/taikoxyz/taiko-mono/commit/45281b848f3ef3c45487bfcd1bfd38b382eff4d0)) -* **protocol:** use block header's extraData for `basefeeSharingPctg` ([#17889](https://github.com/taikoxyz/taiko-mono/issues/17889)) ([5f3cbc9](https://github.com/taikoxyz/taiko-mono/commit/5f3cbc97cbe2636314c4a2945fdf01ef641702e7)) - - -### Chores - -* **main:** release protocol 1.9.0 ([#17783](https://github.com/taikoxyz/taiko-mono/issues/17783)) ([7bfd28a](https://github.com/taikoxyz/taiko-mono/commit/7bfd28a2b332c927cd8b6358623551814260f94e)) -* **protocol:** make two state variables in TaikoL2.sol public and add `adjustExcess` ([#17891](https://github.com/taikoxyz/taiko-mono/issues/17891)) ([ba21f68](https://github.com/taikoxyz/taiko-mono/commit/ba21f6836845ea0227116b701e701815f210d56d)) -* **protocol:** move two files to simplify folder structure ([#17929](https://github.com/taikoxyz/taiko-mono/issues/17929)) ([9dca4fa](https://github.com/taikoxyz/taiko-mono/commit/9dca4faa43ad938880c8e1ac54236ab292bcce6e)) -* **protocol:** revert `TAIKO_TOKEN` name changes in `DeployOnL1` ([#17927](https://github.com/taikoxyz/taiko-mono/issues/17927)) ([cf1a15f](https://github.com/taikoxyz/taiko-mono/commit/cf1a15f46344e60448c5fdcbcae02521fb5b7c04)) -* **protocol:** revert releasing protocol 1.9.0 ([#17783](https://github.com/taikoxyz/taiko-mono/issues/17783)) ([#18049](https://github.com/taikoxyz/taiko-mono/issues/18049)) ([c033810](https://github.com/taikoxyz/taiko-mono/commit/c033810ecc4c80a4581a95b06ab5127747efd191)) - - -### Documentation - -* **docs-site:** address docs and scripts friction points ([#17815](https://github.com/taikoxyz/taiko-mono/issues/17815)) ([c74968b](https://github.com/taikoxyz/taiko-mono/commit/c74968b61828babf218fbc8e8ded001a853a93c3)) -* **protocol:** add L2 `DelegateOwner` address in Hekla deployment docs ([#17925](https://github.com/taikoxyz/taiko-mono/issues/17925)) ([fdec8db](https://github.com/taikoxyz/taiko-mono/commit/fdec8dbe8c8aef21f71c9c4ca2213944880c1a47)) -* **protocol:** update `tier_router`with compatibility modifications ([#18028](https://github.com/taikoxyz/taiko-mono/issues/18028)) ([c43cb0c](https://github.com/taikoxyz/taiko-mono/commit/c43cb0c05f7cbba281076568f4e72033ebbcd0f3)) -* **protocol:** update hekla change log about `tier_router` ([#18023](https://github.com/taikoxyz/taiko-mono/issues/18023)) ([11e27d6](https://github.com/taikoxyz/taiko-mono/commit/11e27d60b3da9a34e07bfafadb8ec3d3223867d2)) -* **protocol:** update hekla change log about sp1 ([#18020](https://github.com/taikoxyz/taiko-mono/issues/18020)) ([434bf3c](https://github.com/taikoxyz/taiko-mono/commit/434bf3ccc1715171b8cd4e7581b282f85744ebe3)) -* **protocol:** update Hekla deployment ([#17845](https://github.com/taikoxyz/taiko-mono/issues/17845)) ([d95cc36](https://github.com/taikoxyz/taiko-mono/commit/d95cc36260ee4bf2aaf69181fa6444f419cc44af)) -* **protocol:** update Hekla deployment ([#17924](https://github.com/taikoxyz/taiko-mono/issues/17924)) ([46a3e00](https://github.com/taikoxyz/taiko-mono/commit/46a3e00659534a715fb315859463bd05bbdb65a9)) -* **protocol:** update Hekla deployments ([#17975](https://github.com/taikoxyz/taiko-mono/issues/17975)) ([c96627f](https://github.com/taikoxyz/taiko-mono/commit/c96627fcdd9ba91f26eeea2b329f0eb96dd36660)) -* **protocol:** update L1 deployment ([#17789](https://github.com/taikoxyz/taiko-mono/issues/17789)) ([a889f1a](https://github.com/taikoxyz/taiko-mono/commit/a889f1a3e6c27b6758e873572c371ac9399a3d9a)) -* **protocol:** update L1 deployment ([#17804](https://github.com/taikoxyz/taiko-mono/issues/17804)) ([25ace9b](https://github.com/taikoxyz/taiko-mono/commit/25ace9bd2b18d91cbf165968cc27d34ccbd7067a)) -* **protocol:** update L1 deployment ([#17812](https://github.com/taikoxyz/taiko-mono/issues/17812)) ([5b43df1](https://github.com/taikoxyz/taiko-mono/commit/5b43df170b6f97cb89360e2d210d4a768d9247c3)) -* **protocol:** update L1 deployment ([#17817](https://github.com/taikoxyz/taiko-mono/issues/17817)) ([311c948](https://github.com/taikoxyz/taiko-mono/commit/311c948850e8b4d46218fd4aba92d03bc6349445)) -* **protocol:** update mainnet deployment ([#17846](https://github.com/taikoxyz/taiko-mono/issues/17846)) ([ba6bf94](https://github.com/taikoxyz/taiko-mono/commit/ba6bf942213468310c6233051a90356268dea70f)) -* **protocol:** update mainnet deployment ([#17847](https://github.com/taikoxyz/taiko-mono/issues/17847)) ([92344df](https://github.com/taikoxyz/taiko-mono/commit/92344dfb8c97bae370d722f887fb2c603f96c480)) -* **protocol:** upgrade sp1 verifier in hekla ([#18027](https://github.com/taikoxyz/taiko-mono/issues/18027)) ([de27e6e](https://github.com/taikoxyz/taiko-mono/commit/de27e6e586e14410c309e68ce6b81504b9ba9a5b)) - - -### Code Refactoring - -* **protocol:** add MainnetGuardianProver ([#17805](https://github.com/taikoxyz/taiko-mono/issues/17805)) ([6f68316](https://github.com/taikoxyz/taiko-mono/commit/6f68316e89373670cf2c58bde5e64de196b9c139)) -* **protocol:** add MainnetSgxVerifier ([#17803](https://github.com/taikoxyz/taiko-mono/issues/17803)) ([a4be247](https://github.com/taikoxyz/taiko-mono/commit/a4be247e181861300d79af6454b3fd3776100b48)) -* **protocol:** added cached version of the bridge and vaults ([#17801](https://github.com/taikoxyz/taiko-mono/issues/17801)) ([b70cc57](https://github.com/taikoxyz/taiko-mono/commit/b70cc57704d750081a62a7e8e44f68f32efdc4c1)) -* **protocol:** avoid writing `livenessBond`, `proposedAt`, and `proposedIn` to storage ([17d67d7](https://github.com/taikoxyz/taiko-mono/commit/17d67d74c511bc11c2b7d821d8a381f74ef7b6a1)) -* **protocol:** convert metadata from V2 to V1 only once ([#17842](https://github.com/taikoxyz/taiko-mono/issues/17842)) ([55ced31](https://github.com/taikoxyz/taiko-mono/commit/55ced319d68fe40fe82d1c7e0a268735c3545923)) -* **protocol:** delete packages/protocol/contracts/compiled ([#17849](https://github.com/taikoxyz/taiko-mono/issues/17849)) ([1fd907c](https://github.com/taikoxyz/taiko-mono/commit/1fd907cc81807027e730c0e27e258230670522df)) -* **protocol:** extract an IBlockHash interface from TaikoL2 ([#18045](https://github.com/taikoxyz/taiko-mono/issues/18045)) ([bff481e](https://github.com/taikoxyz/taiko-mono/commit/bff481e8a2898fab8396d368de84f8f343c532f0)) -* **protocol:** improve mainnet gas efficiency with addresses cached ([#17791](https://github.com/taikoxyz/taiko-mono/issues/17791)) ([b12227d](https://github.com/taikoxyz/taiko-mono/commit/b12227d4d2b2636fb80e04ee7ebc2dec3c17faa8)) -* **protocol:** improve MainnetSgxVerifier ([#17811](https://github.com/taikoxyz/taiko-mono/issues/17811)) ([4e7a421](https://github.com/taikoxyz/taiko-mono/commit/4e7a421967a4cea897f1ffbeeae254fbcad27117)) -* **protocol:** introduce BlockV2 for client-side compability ([#17935](https://github.com/taikoxyz/taiko-mono/issues/17935)) ([e46cf29](https://github.com/taikoxyz/taiko-mono/commit/e46cf294862c293b73b817574669115b85e973a7)) -* **protocol:** name address manager param clearer ([#17806](https://github.com/taikoxyz/taiko-mono/issues/17806)) ([1d5a6ff](https://github.com/taikoxyz/taiko-mono/commit/1d5a6ff191e8457ee12c96cb73c074560c556a2a)) -* **protocol:** refactor TierProvider implementations ([ee464ca](https://github.com/taikoxyz/taiko-mono/commit/ee464caef68fdec325aa22758bb69e17dd039794)) -* **protocol:** remove ProposerAccess for easier composability ([#17994](https://github.com/taikoxyz/taiko-mono/issues/17994)) ([80176a1](https://github.com/taikoxyz/taiko-mono/commit/80176a1525c374039256c779f4a2408971759d22)) -* **protocol:** remove the receive function from TaikoL1.sol ([#17865](https://github.com/taikoxyz/taiko-mono/issues/17865)) ([3542420](https://github.com/taikoxyz/taiko-mono/commit/35424204d9f41d49f4a12869ed4410b6de7f577e)) -* **protocol:** remove uncessary init2() from TaikoL2 ([#17973](https://github.com/taikoxyz/taiko-mono/issues/17973)) ([4e08881](https://github.com/taikoxyz/taiko-mono/commit/4e0888190e172c950dc5e81a5115ee0fb6df3f11)) -* **protocol:** simplify mainnet address caching ([ee464ca](https://github.com/taikoxyz/taiko-mono/commit/ee464caef68fdec325aa22758bb69e17dd039794)) -* **protocol:** use npm to manage third-party solidity dependency ([#17881](https://github.com/taikoxyz/taiko-mono/issues/17881)) ([d524e69](https://github.com/taikoxyz/taiko-mono/commit/d524e693449de9d65154471786fa4f5e8c45a381)) - - -### Tests - -* **protocol:** add test case of risc0 groth16 ([#17904](https://github.com/taikoxyz/taiko-mono/issues/17904)) ([90bc01d](https://github.com/taikoxyz/taiko-mono/commit/90bc01dfbef1129be1bd94e85c9ecd7c7b28b1da)) -* **taiko-client:** use env names which defined in flag configs ([#17921](https://github.com/taikoxyz/taiko-mono/issues/17921)) ([196b74e](https://github.com/taikoxyz/taiko-mono/commit/196b74eb2b4498bc3e6511915e011a885fcc530f)) - - -### Workflow - -* **protocol:** upgrade to use solc 0.8.27 ([#18037](https://github.com/taikoxyz/taiko-mono/issues/18037)) ([3a56b57](https://github.com/taikoxyz/taiko-mono/commit/3a56b5788b3e2473381429e5fddfaac2f10fa174)) - - -### Build - -* **deps:** bump merkletreejs from 0.3.11 to 0.4.0 ([#17942](https://github.com/taikoxyz/taiko-mono/issues/17942)) ([1624b71](https://github.com/taikoxyz/taiko-mono/commit/1624b711e3fe1862f000e1d2970d6aee1b8990c9)) - ## [1.8.0](https://github.com/taikoxyz/taiko-mono/compare/protocol-v1.7.0...protocol-v1.8.0) (2024-07-11) diff --git a/packages/protocol/README.md b/packages/protocol/README.md index 371e99b6972..547fa503d66 100644 --- a/packages/protocol/README.md +++ b/packages/protocol/README.md @@ -1,139 +1,145 @@ # Taiko Protocol -This package contains rollup contracts on both L1 and L2, along with other assisting code. Taiko L2's chain ID is [167](https://github.com/ethereum-lists/chains/pull/1611). +This repository contains the Taiko Based Contestable Rollup (BCR) protocol and supporting tools. The project is managed using `pnpm` and `foundry`. -## Getting Started +## Prerequisites -Before compiling smart contracts, ensure all necessary dependencies are installed: +Before compiling the smart contracts, ensure the following are installed and up to date: -```sh -pnpm install +- [Foundry](https://book.getfoundry.sh/) +- [pnpm](https://pnpm.io/) + +To install dependencies: + +```bash +foundryup && pnpm install ``` -Then, compile the smart contracts: +## Compilation and Testing -```sh -pnpm compile +Taiko’s protocol is split between Layer 1 (L1) and Layer 2 (L2). The smart contracts need to be compiled and tested separately for each layer: + +### Layer 1 (Ethereum, Duncan Hardfork) + +To compile, run tests, and generate the storage layout for L1: + +```bash +pnpm compile:l1 +pnpm test:l1 +pnpm layout:l1 ``` -If you run into `Error: Unknown version provided`, you should upgrade your foundry installation by running `curl -L https://foundry.paradigm.xyz | bash`. +### Layer 2 (Taiko, Shanghai Hardfork) -## Style Guide +Similarly, for L2: + +```bash +pnpm compile:l2 +pnpm test:l2 +pnpm layout:l2 +``` + +### Compile and Test for Both Layers + +To compile and test contracts for both L1 and L2 at once: + +```bash +pnpm compile +pnpm test +pnpm layout +``` -Please see [CONTRIBUTING.md](../../CONTRIBUTING.md) for the source code style guidelines to adhere to. +## Layer 2 Genesis Block -## Generate L2 Genesis JSON's `alloc` Field +### Generating a Dummy Genesis Block -Create a `config.js` with the following structure: +To generate dummy data for the L2 genesis block, create a configuration file at `./test/genesis/data/genesis_config.js` with the following content: ```javascript module.exports = { - // Owner address of the pre-deployed L2 contracts. contractOwner: "0xDf08F82De32B8d460adbE8D72043E3a7e25A3B39", - // Chain ID of the Taiko L2 network. chainId: 167, - // Account address and pre-mint ETH amount as key-value pairs. seedAccounts: [ { "0xDf08F82De32B8d460adbE8D72043E3a7e25A3B39": 1024 }, { "0x79fcdef22feed20eddacbb2587640e45491b757f": 1024 }, ], - // Owner Chain ID, Security Council, and Timelock Controller l1ChainId: 31337, ownerSecurityCouncil: "0xDf08F82De32B8d460adbE8D72043E3a7e25A3B39", ownerTimelockController: "0xDf08F82De32B8d460adbE8D72043E3a7e25A3B39", - // L2 EIP-1559 baseFee calculation related fields. param1559: { gasExcess: 1, }, - // Option to pre-deploy an ERC-20 token. predeployERC20: true, }; ``` -Then, execute the generation script: +Then compile the L2 contracts and generate the genesis block: -```sh -pnpm compile && pnpm generate:genesis config.js +```bash +pnpm compile:l2 +pnpm genesis:gen ``` -The script will output two JSON files under `./deployments`: - -- `l2_genesis_alloc.json`: the `alloc` field which will be used in L2 genesis JSON file -- `l2_genesis_storage_layout.json`: the storage layout of those pre-deployed contracts - -## Using Foundry +This generates the following JSON files in `./test/genesis/data/`: -This project also integrates with Foundry for building and testing contracts. +- `l2_genesis_alloc.json`: Contains the `alloc` field for the L2 genesis block. Use this in a `geth` or `taiko-geth` genesis block following [this guide](https://geth.ethereum.org/docs/fundamentals/private-network#creating-genesis-block). +- `l2_genesis_storage_layout.json`: Displays the storage layout of the pre-deployed contracts. -- To compile using foundry: `forge build` or `pnpm compile` -- To run foundry tests: `forge test --gas-report -vvv` or `pnpm test:foundry` +To validate the genesis data: -## Generating and Running the L2 Genesis Block - -The generation of the L2 genesis block and obtaining its hash involves a series of steps, including constructing the genesis JSON, followed by the actual generation and retrieval of the genesis block hash. A test can be executed to comprehend this process. - -### Testing Genesis Block Creation - -To understand how the `genesis.json` is built from deployment files and how to generate the genesis block and its hash, you can use the `test:genesis` command. This test serves as a learning tool: - -```sh -pnpm test:genesis +```bash +pnpm genesis:test ``` -This test, defined in `./genesis/generate_genesis.test.sh`, compiles the contracts, generates the genesis JSON, and initiates a Geth node using Docker to simulate the deployment of the genesis block. Reviewing this script and its output can help you grasp the steps required to create and initiate a genesis block for the Taiko Protocol. - -### Generating the Actual Genesis Block - -After understanding the process from the test, proceed to generate the actual `genesis.json` and the genesis block: - -1. **Build the Genesis JSON:** Use the information learned from the `test:genesis` to build the `genesis.json` file from the files in the `/deployments/` directory. The `generate_genesis.test.sh` script contains the necessary commands to create this file. - -2. **Run Geth to Generate the Genesis Block:** You can use Geth to initialize and run a private network with the genesis block. You can start Geth with the following commands: +This runs tests using Docker and `taiko-geth` to simulate the L2 genesis block deployment, and generates a `genesis.json` file in `./test/genesis/data/`. - ```sh - geth --datadir ~/taiko-l2-network/node init /deployments/genesis.json - geth --datadir ~/taiko-l2-network/node --networkid 167 --http --http.addr 127.0.0.1 --http.port 8552 --http.corsdomain "*" - ``` +### Generating an Actual Genesis Block - For details refer to the Geth documentation on [creating a genesis block](https://geth.ethereum.org/docs/fundamentals/private-network#creating-genesis-block). +To generate the actual L2 genesis block, create a `genesis.json` file based on `l2_genesis_alloc.json`, following [this guide](https://geth.ethereum.org/docs/fundamentals/private-network#creating-genesis-block). -3. **Retrieve the Genesis Block Hash:** Connect to the Geth node using the command: +Next, initialize `taiko-geth` with the generated `genesis.json`: - ```sh - geth attach ~/taiko-l2-network/node/geth.ipc - ``` +```bash +geth --datadir ~/taiko-l2-network/node init test/layer2/genesis/data/genesis.json +geth --datadir ~/taiko-l2-network/node --networkid 167 --http --http.addr 127.0.0.1 --http.port 8552 --http.corsdomain "*" +``` - In the Geth console, use `eth.getBlock(0)` to obtain the hash of the genesis block. +You can retrieve the genesis block hash by attaching to the `geth` instance: -4. **Update `test_deploy_on_l1.sh` File:** Update the `L2_GENESIS_HASH` variable in the `test_deploy_on_l1.sh` script with the obtained genesis block hash. +```bash +geth attach ~/taiko-l2-network/node/geth.ipc +``` -By following these steps, you will successfully generate the L2 genesis block for the Taiko Protocol, retrieve its hash, and prepare for the L1 contract deployment. +Then run: -## Deploying the L1 Contracts +```bash +eth.getBlock(0) +``` -To deploy L1 contracts for Taiko Protocol, you can use any Ethereum network. This guide illustrates the process using a Hardhat local network, but it's adaptable to others. The deployment relies on `script/test_deploy_on_l1.sh`, which targets a node at `http://localhost:8545` by default. +Copy the genesis block hash and replace the `L2_GENESIS_HASH` variable in `deploy_protocol_on_l1.sh` with this value. -Here’s how you can proceed: +### Deploying Taiko BCR on Layer 1 -1. **Ensure Sufficient ETH:** Check that the address associated with the private key in `script/test_deploy_on_l1.sh` has enough ETH for deploying contracts on the Hardhat network. +To deploy Taiko BCR on L1, start a local L1 network: -2. **Update Contract Addresses:** After running the genesis block generation script (`pnpm test:genesis`), you will receive a list of pre-computed contract addresses. These addresses need to be added to the `test_deploy_on_l1.sh` file. Make sure to update this file with the correct contract addresses before proceeding with the deployment. +```bash +anvil --hardfork cancun +``` -3. **Start a Local Development Network:** While this guide uses Hardhat as an example, you can use any Ethereum network. If you choose to use Hardhat, start a local Ethereum network for development and testing: +Make sure you have sufficient ether for transactions, then deploy the contracts: -```sh -pnpm hardhat node +```bash +pnpm test:deploy:l1 ``` -4. **Deploy Contracts Using Foundry:** Once your network is running, open a new terminal window and execute the deployment scripts using Foundry: +This command runs the deployment script located at `script/deploy_protocol_on_l1.sh`, assuming L1 is accessible at `http://localhost:8545`. -```sh -pnpm test:deploy -``` +## Style Guide -This command will deploy the L1 contracts using the settings and addresses you’ve provided in the `test_deploy_on_l1.sh` script. +Refer to [CONTRIBUTING.md](https://www.notion.so/CONTRIBUTING.md) for code style guidelines. -## Running slither +Before committing code, format and lint it using: -1. Install the latest [slither](https://github.com/crytic/slither?tab=readme-ov-file#how-to-install). -2. From `protocol/`, execute `slither . --checklist > checklist.md` to re-generate the checklist. +```bash +pnpm fmt:sol +``` diff --git a/packages/protocol/contract_layout_layer1.md b/packages/protocol/contract_layout_layer1.md index 45b2f5ce7dd..f1ff0bd4fbf 100644 --- a/packages/protocol/contract_layout_layer1.md +++ b/packages/protocol/contract_layout_layer1.md @@ -1,6 +1,6 @@ ## ERC1155Vault -| Name | Type | Slot | Offset | Bytes | Contract | -|--------------------|------------------------------------------------------|------|--------|-------|----------------------------------------------------| +| Name | Type | Slot | Offset | Bytes | Contract | +|--------------------|------------------------------------------------------|------|--------|-------|-----------------------------------------------------------| | _initialized | uint8 | 0 | 0 | 1 | ERC1155Vault | | _initializing | bool | 0 | 1 | 1 | ERC1155Vault | | __gap | uint256[50] | 1 | 0 | 1600 | ERC1155Vault | @@ -23,8 +23,8 @@ | __gap | uint256[50] | 451 | 0 | 1600 | ERC1155Vault | ## ERC20Vault -| Name | Type | Slot | Offset | Bytes | Contract | -|--------------------|------------------------------------------------------|------|--------|-------|------------------------------------------------| +| Name | Type | Slot | Offset | Bytes | Contract | +|--------------------|------------------------------------------------------|------|--------|-------|-------------------------------------------------------| | _initialized | uint8 | 0 | 0 | 1 | ERC20Vault | | _initializing | bool | 0 | 1 | 1 | ERC20Vault | | __gap | uint256[50] | 1 | 0 | 1600 | ERC20Vault | @@ -46,8 +46,8 @@ | __gap | uint256[46] | 305 | 0 | 1472 | ERC20Vault | ## ERC721Vault -| Name | Type | Slot | Offset | Bytes | Contract | -|--------------------|------------------------------------------------------|------|--------|-------|--------------------------------------------------| +| Name | Type | Slot | Offset | Bytes | Contract | +|--------------------|------------------------------------------------------|------|--------|-------|---------------------------------------------------------| | _initialized | uint8 | 0 | 0 | 1 | ERC721Vault | | _initializing | bool | 0 | 1 | 1 | ERC721Vault | | __gap | uint256[50] | 1 | 0 | 1600 | ERC721Vault | @@ -68,8 +68,8 @@ | __gap | uint256[50] | 351 | 0 | 1600 | ERC721Vault | ## BridgedERC20 -| Name | Type | Slot | Offset | Bytes | Contract | -|------------------|-------------------------------------------------|------|--------|-------|----------------------------------------------------| +| Name | Type | Slot | Offset | Bytes | Contract | +|------------------|-------------------------------------------------|------|--------|-------|-----------------------------------------------------------| | _initialized | uint8 | 0 | 0 | 1 | BridgedERC20 | | _initializing | bool | 0 | 1 | 1 | BridgedERC20 | | __gap | uint256[50] | 1 | 0 | 1600 | BridgedERC20 | @@ -97,8 +97,8 @@ | __gap | uint256[47] | 304 | 0 | 1504 | BridgedERC20 | ## BridgedERC20V2 -| Name | Type | Slot | Offset | Bytes | Contract | -|------------------|--------------------------------------------------------|------|--------|-------|--------------------------------------------------------| +| Name | Type | Slot | Offset | Bytes | Contract | +|------------------|--------------------------------------------------------|------|--------|-------|---------------------------------------------------------------| | _initialized | uint8 | 0 | 0 | 1 | BridgedERC20V2 | | _initializing | bool | 0 | 1 | 1 | BridgedERC20V2 | | __gap | uint256[50] | 1 | 0 | 1600 | BridgedERC20V2 | @@ -133,8 +133,8 @@ | __gap | uint256[49] | 404 | 0 | 1568 | BridgedERC20V2 | ## BridgedERC721 -| Name | Type | Slot | Offset | Bytes | Contract | -|--------------------|----------------------------------------------|------|--------|-------|------------------------------------------------------| +| Name | Type | Slot | Offset | Bytes | Contract | +|--------------------|----------------------------------------------|------|--------|-------|-------------------------------------------------------------| | _initialized | uint8 | 0 | 0 | 1 | BridgedERC721 | | _initializing | bool | 0 | 1 | 1 | BridgedERC721 | | __gap | uint256[50] | 1 | 0 | 1600 | BridgedERC721 | @@ -161,8 +161,8 @@ | __gap | uint256[48] | 353 | 0 | 1536 | BridgedERC721 | ## BridgedERC1155 -| Name | Type | Slot | Offset | Bytes | Contract | -|--------------------|-------------------------------------------------|------|--------|-------|--------------------------------------------------------| +| Name | Type | Slot | Offset | Bytes | Contract | +|--------------------|-------------------------------------------------|------|--------|-------|---------------------------------------------------------------| | _initialized | uint8 | 0 | 0 | 1 | BridgedERC1155 | | _initializing | bool | 0 | 1 | 1 | BridgedERC1155 | | __gap | uint256[50] | 1 | 0 | 1600 | BridgedERC1155 | @@ -188,8 +188,8 @@ | __gap | uint256[46] | 355 | 0 | 1472 | BridgedERC1155 | ## Bridge -| Name | Type | Slot | Offset | Bytes | Contract | -|----------------|-----------------------------------------|------|--------|-------|------------------------------------| +| Name | Type | Slot | Offset | Bytes | Contract | +|----------------|-----------------------------------------|------|--------|-------|-------------------------------------------| | _initialized | uint8 | 0 | 0 | 1 | Bridge | | _initializing | bool | 0 | 1 | 1 | Bridge | | __gap | uint256[50] | 1 | 0 | 1600 | Bridge | @@ -212,8 +212,8 @@ | __gap | uint256[44] | 257 | 0 | 1408 | Bridge | ## QuotaManager -| Name | Type | Slot | Offset | Bytes | Contract | -|----------------|-----------------------------------------------|------|--------|-------|------------------------------------------------| +| Name | Type | Slot | Offset | Bytes | Contract | +|----------------|-----------------------------------------------|------|--------|-------|-------------------------------------------------------| | _initialized | uint8 | 0 | 0 | 1 | QuotaManager | | _initializing | bool | 0 | 1 | 1 | QuotaManager | | __gap | uint256[50] | 1 | 0 | 1600 | QuotaManager | @@ -232,8 +232,8 @@ | __gap | uint256[48] | 253 | 0 | 1536 | QuotaManager | ## AddressManager -| Name | Type | Slot | Offset | Bytes | Contract | -|----------------|-------------------------------------------------|------|--------|-------|----------------------------------------------------| +| Name | Type | Slot | Offset | Bytes | Contract | +|----------------|-------------------------------------------------|------|--------|-------|-----------------------------------------------------------| | _initialized | uint8 | 0 | 0 | 1 | AddressManager | | _initializing | bool | 0 | 1 | 1 | AddressManager | | __gap | uint256[50] | 1 | 0 | 1600 | AddressManager | @@ -251,16 +251,16 @@ | __gap | uint256[49] | 252 | 0 | 1568 | AddressManager | ## AddressResolver -| Name | Type | Slot | Offset | Bytes | Contract | -|----------------|-------------|------|--------|-------|------------------------------------------------------| +| Name | Type | Slot | Offset | Bytes | Contract | +|----------------|-------------|------|--------|-------|-------------------------------------------------------------| | _initialized | uint8 | 0 | 0 | 1 | AddressResolver | | _initializing | bool | 0 | 1 | 1 | AddressResolver | | addressManager | address | 0 | 2 | 20 | AddressResolver | | __gap | uint256[49] | 1 | 0 | 1568 | AddressResolver | ## EssentialContract -| Name | Type | Slot | Offset | Bytes | Contract | -|----------------|-------------|------|--------|-------|----------------------------------------------------------| +| Name | Type | Slot | Offset | Bytes | Contract | +|----------------|-------------|------|--------|-------|-----------------------------------------------------------------| | _initialized | uint8 | 0 | 0 | 1 | EssentialContract | | _initializing | bool | 0 | 1 | 1 | EssentialContract | | __gap | uint256[50] | 1 | 0 | 1600 | EssentialContract | @@ -276,8 +276,8 @@ | __gap | uint256[49] | 202 | 0 | 1568 | EssentialContract | ## SignalService -| Name | Type | Slot | Offset | Bytes | Contract | -|----------------|-----------------------------------------------|------|--------|-------|--------------------------------------------------| +| Name | Type | Slot | Offset | Bytes | Contract | +|----------------|-----------------------------------------------|------|--------|-------|---------------------------------------------------------| | _initialized | uint8 | 0 | 0 | 1 | SignalService | | _initializing | bool | 0 | 1 | 1 | SignalService | | __gap | uint256[50] | 1 | 0 | 1600 | SignalService | @@ -296,8 +296,8 @@ | __gap | uint256[48] | 253 | 0 | 1536 | SignalService | ## TaikoToken -| Name | Type | Slot | Offset | Bytes | Contract | -|-----------------------------------------------------|---------------------------------------------------------------|------|--------|-------|-----------------------------------------| +| Name | Type | Slot | Offset | Bytes | Contract | +|-----------------------------------------------------|---------------------------------------------------------------|------|--------|-------|--------------------------------------------------| | _initialized | uint8 | 0 | 0 | 1 | TaikoToken | | _initializing | bool | 0 | 1 | 1 | TaikoToken | | __gap | uint256[50] | 1 | 0 | 1600 | TaikoToken | @@ -333,8 +333,8 @@ | __gap | uint256[50] | 504 | 0 | 1600 | TaikoToken | ## ComposeVerifier -| Name | Type | Slot | Offset | Bytes | Contract | -|----------------|-------------|------|--------|-------|-----------------------------------------------------------------| +| Name | Type | Slot | Offset | Bytes | Contract | +|----------------|-------------|------|--------|-------|------------------------------------------------------------------------| | _initialized | uint8 | 0 | 0 | 1 | ComposeVerifier | | _initializing | bool | 0 | 1 | 1 | ComposeVerifier | | __gap | uint256[50] | 1 | 0 | 1600 | ComposeVerifier | @@ -351,8 +351,8 @@ | __gap | uint256[50] | 251 | 0 | 1600 | ComposeVerifier | ## TeeAnyVerifier -| Name | Type | Slot | Offset | Bytes | Contract | -|----------------|-------------|------|--------|-------|---------------------------------------------------------------| +| Name | Type | Slot | Offset | Bytes | Contract | +|----------------|-------------|------|--------|-------|----------------------------------------------------------------------| | _initialized | uint8 | 0 | 0 | 1 | TeeAnyVerifier | | _initializing | bool | 0 | 1 | 1 | TeeAnyVerifier | | __gap | uint256[50] | 1 | 0 | 1600 | TeeAnyVerifier | @@ -370,8 +370,8 @@ | __gap | uint256[50] | 301 | 0 | 1600 | TeeAnyVerifier | ## ZkAndTeeVerifier -| Name | Type | Slot | Offset | Bytes | Contract | -|----------------|-------------|------|--------|-------|-------------------------------------------------------------------| +| Name | Type | Slot | Offset | Bytes | Contract | +|----------------|-------------|------|--------|-------|--------------------------------------------------------------------------| | _initialized | uint8 | 0 | 0 | 1 | ZkAndTeeVerifier | | _initializing | bool | 0 | 1 | 1 | ZkAndTeeVerifier | | __gap | uint256[50] | 1 | 0 | 1600 | ZkAndTeeVerifier | @@ -389,8 +389,8 @@ | __gap | uint256[50] | 301 | 0 | 1600 | ZkAndTeeVerifier | ## ZkAnyVerifier -| Name | Type | Slot | Offset | Bytes | Contract | -|----------------|-------------|------|--------|-------|-------------------------------------------------------------| +| Name | Type | Slot | Offset | Bytes | Contract | +|----------------|-------------|------|--------|-------|--------------------------------------------------------------------| | _initialized | uint8 | 0 | 0 | 1 | ZkAnyVerifier | | _initializing | bool | 0 | 1 | 1 | ZkAnyVerifier | | __gap | uint256[50] | 1 | 0 | 1600 | ZkAnyVerifier | @@ -408,8 +408,8 @@ | __gap | uint256[50] | 301 | 0 | 1600 | ZkAnyVerifier | ## Risc0Verifier -| Name | Type | Slot | Offset | Bytes | Contract | -|----------------|--------------------------|------|--------|-------|-----------------------------------------------------| +| Name | Type | Slot | Offset | Bytes | Contract | +|----------------|--------------------------|------|--------|-------|------------------------------------------------------------| | _initialized | uint8 | 0 | 0 | 1 | Risc0Verifier | | _initializing | bool | 0 | 1 | 1 | Risc0Verifier | | __gap | uint256[50] | 1 | 0 | 1600 | Risc0Verifier | @@ -427,8 +427,8 @@ | __gap | uint256[49] | 252 | 0 | 1568 | Risc0Verifier | ## SP1Verifier -| Name | Type | Slot | Offset | Bytes | Contract | -|------------------|--------------------------|------|--------|-------|-------------------------------------------------| +| Name | Type | Slot | Offset | Bytes | Contract | +|------------------|--------------------------|------|--------|-------|--------------------------------------------------------| | _initialized | uint8 | 0 | 0 | 1 | SP1Verifier | | _initializing | bool | 0 | 1 | 1 | SP1Verifier | | __gap | uint256[50] | 1 | 0 | 1600 | SP1Verifier | @@ -446,8 +446,8 @@ | __gap | uint256[49] | 252 | 0 | 1568 | SP1Verifier | ## SgxVerifier -| Name | Type | Slot | Offset | Bytes | Contract | -|-------------------|-------------------------------------------------|------|--------|-------|-------------------------------------------------| +| Name | Type | Slot | Offset | Bytes | Contract | +|-------------------|-------------------------------------------------|------|--------|-------|--------------------------------------------------------| | _initialized | uint8 | 0 | 0 | 1 | SgxVerifier | | _initializing | bool | 0 | 1 | 1 | SgxVerifier | | __gap | uint256[50] | 1 | 0 | 1600 | SgxVerifier | @@ -467,8 +467,8 @@ | __gap | uint256[47] | 254 | 0 | 1504 | SgxVerifier | ## AutomataDcapV3Attestation -| Name | Type | Slot | Offset | Bytes | Contract | -|-------------------------|-------------------------------------------------|------|--------|-------|----------------------------------------------------------------------------------------| +| Name | Type | Slot | Offset | Bytes | Contract | +|-------------------------|-------------------------------------------------|------|--------|-------|-----------------------------------------------------------------------------------------------| | _initialized | uint8 | 0 | 0 | 1 | AutomataDcapV3Attestation | | _initializing | bool | 0 | 1 | 1 | AutomataDcapV3Attestation | | __gap | uint256[50] | 1 | 0 | 1600 | AutomataDcapV3Attestation | @@ -493,8 +493,8 @@ | __gap | uint256[39] | 261 | 0 | 1248 | AutomataDcapV3Attestation | ## TaikoL1 -| Name | Type | Slot | Offset | Bytes | Contract | -|----------------|------------------------|------|--------|-------|----------------------------------| +| Name | Type | Slot | Offset | Bytes | Contract | +|----------------|------------------------|------|--------|-------|--------------------------------------------| | _initialized | uint8 | 0 | 0 | 1 | TaikoL1 | | _initializing | bool | 0 | 1 | 1 | TaikoL1 | | __gap | uint256[50] | 1 | 0 | 1600 | TaikoL1 | @@ -516,8 +516,8 @@ |------|------|------|--------|-------|----------| ## HeklaTaikoL1 -| Name | Type | Slot | Offset | Bytes | Contract | -|----------------|------------------------|------|--------|-------|-----------------------------------------------| +| Name | Type | Slot | Offset | Bytes | Contract | +|----------------|------------------------|------|--------|-------|------------------------------------------------------| | _initialized | uint8 | 0 | 0 | 1 | HeklaTaikoL1 | | _initializing | bool | 0 | 1 | 1 | HeklaTaikoL1 | | __gap | uint256[50] | 1 | 0 | 1600 | HeklaTaikoL1 | @@ -539,8 +539,8 @@ |------|------|------|--------|-------|----------| ## MainnetBridge -| Name | Type | Slot | Offset | Bytes | Contract | -|----------------|-----------------------------------------|------|--------|-------|----------------------------------------------------------| +| Name | Type | Slot | Offset | Bytes | Contract | +|----------------|-----------------------------------------|------|--------|-------|----------------------------------------------------------------------| | _initialized | uint8 | 0 | 0 | 1 | MainnetBridge | | _initializing | bool | 0 | 1 | 1 | MainnetBridge | | __gap | uint256[50] | 1 | 0 | 1600 | MainnetBridge | @@ -563,8 +563,8 @@ | __gap | uint256[44] | 257 | 0 | 1408 | MainnetBridge | ## MainnetSignalService -| Name | Type | Slot | Offset | Bytes | Contract | -|----------------|-----------------------------------------------|------|--------|-------|------------------------------------------------------------------------| +| Name | Type | Slot | Offset | Bytes | Contract | +|----------------|-----------------------------------------------|------|--------|-------|------------------------------------------------------------------------------------| | _initialized | uint8 | 0 | 0 | 1 | MainnetSignalService | | _initializing | bool | 0 | 1 | 1 | MainnetSignalService | | __gap | uint256[50] | 1 | 0 | 1600 | MainnetSignalService | @@ -583,8 +583,8 @@ | __gap | uint256[48] | 253 | 0 | 1536 | MainnetSignalService | ## MainnetERC20Vault -| Name | Type | Slot | Offset | Bytes | Contract | -|--------------------|------------------------------------------------------|------|--------|-------|------------------------------------------------------------------| +| Name | Type | Slot | Offset | Bytes | Contract | +|--------------------|------------------------------------------------------|------|--------|-------|------------------------------------------------------------------------------| | _initialized | uint8 | 0 | 0 | 1 | MainnetERC20Vault | | _initializing | bool | 0 | 1 | 1 | MainnetERC20Vault | | __gap | uint256[50] | 1 | 0 | 1600 | MainnetERC20Vault | @@ -606,8 +606,8 @@ | __gap | uint256[46] | 305 | 0 | 1472 | MainnetERC20Vault | ## MainnetERC1155Vault -| Name | Type | Slot | Offset | Bytes | Contract | -|--------------------|------------------------------------------------------|------|--------|-------|----------------------------------------------------------------------| +| Name | Type | Slot | Offset | Bytes | Contract | +|--------------------|------------------------------------------------------|------|--------|-------|----------------------------------------------------------------------------------| | _initialized | uint8 | 0 | 0 | 1 | MainnetERC1155Vault | | _initializing | bool | 0 | 1 | 1 | MainnetERC1155Vault | | __gap | uint256[50] | 1 | 0 | 1600 | MainnetERC1155Vault | @@ -630,8 +630,8 @@ | __gap | uint256[50] | 451 | 0 | 1600 | MainnetERC1155Vault | ## MainnetERC721Vault -| Name | Type | Slot | Offset | Bytes | Contract | -|--------------------|------------------------------------------------------|------|--------|-------|--------------------------------------------------------------------| +| Name | Type | Slot | Offset | Bytes | Contract | +|--------------------|------------------------------------------------------|------|--------|-------|--------------------------------------------------------------------------------| | _initialized | uint8 | 0 | 0 | 1 | MainnetERC721Vault | | _initializing | bool | 0 | 1 | 1 | MainnetERC721Vault | | __gap | uint256[50] | 1 | 0 | 1600 | MainnetERC721Vault | @@ -652,8 +652,8 @@ | __gap | uint256[50] | 351 | 0 | 1600 | MainnetERC721Vault | ## MainnetSharedAddressManager -| Name | Type | Slot | Offset | Bytes | Contract | -|----------------|-------------------------------------------------|------|--------|-------|--------------------------------------------------------------------------------------| +| Name | Type | Slot | Offset | Bytes | Contract | +|----------------|-------------------------------------------------|------|--------|-------|--------------------------------------------------------------------------------------------------| | _initialized | uint8 | 0 | 0 | 1 | MainnetSharedAddressManager | | _initializing | bool | 0 | 1 | 1 | MainnetSharedAddressManager | | __gap | uint256[50] | 1 | 0 | 1600 | MainnetSharedAddressManager | @@ -683,8 +683,8 @@ |------|------|------|--------|-------|----------| ## MainnetSgxVerifier -| Name | Type | Slot | Offset | Bytes | Contract | -|-------------------|-------------------------------------------------|------|--------|-------|------------------------------------------------------------------------------| +| Name | Type | Slot | Offset | Bytes | Contract | +|-------------------|-------------------------------------------------|------|--------|-------|-------------------------------------------------------------------------------------| | _initialized | uint8 | 0 | 0 | 1 | MainnetSgxVerifier | | _initializing | bool | 0 | 1 | 1 | MainnetSgxVerifier | | __gap | uint256[50] | 1 | 0 | 1600 | MainnetSgxVerifier | @@ -704,8 +704,8 @@ | __gap | uint256[47] | 254 | 0 | 1504 | MainnetSgxVerifier | ## MainnetSP1Verifier -| Name | Type | Slot | Offset | Bytes | Contract | -|------------------|--------------------------|------|--------|-------|------------------------------------------------------------------------------| +| Name | Type | Slot | Offset | Bytes | Contract | +|------------------|--------------------------|------|--------|-------|-------------------------------------------------------------------------------------| | _initialized | uint8 | 0 | 0 | 1 | MainnetSP1Verifier | | _initializing | bool | 0 | 1 | 1 | MainnetSP1Verifier | | __gap | uint256[50] | 1 | 0 | 1600 | MainnetSP1Verifier | @@ -723,8 +723,8 @@ | __gap | uint256[49] | 252 | 0 | 1568 | MainnetSP1Verifier | ## MainnetZkAnyVerifier -| Name | Type | Slot | Offset | Bytes | Contract | -|----------------|-------------|------|--------|-------|----------------------------------------------------------------------------------| +| Name | Type | Slot | Offset | Bytes | Contract | +|----------------|-------------|------|--------|-------|-----------------------------------------------------------------------------------------| | _initialized | uint8 | 0 | 0 | 1 | MainnetZkAnyVerifier | | _initializing | bool | 0 | 1 | 1 | MainnetZkAnyVerifier | | __gap | uint256[50] | 1 | 0 | 1600 | MainnetZkAnyVerifier | @@ -742,8 +742,8 @@ | __gap | uint256[50] | 301 | 0 | 1600 | MainnetZkAnyVerifier | ## MainnetRisc0Verifier -| Name | Type | Slot | Offset | Bytes | Contract | -|----------------|--------------------------|------|--------|-------|----------------------------------------------------------------------------------| +| Name | Type | Slot | Offset | Bytes | Contract | +|----------------|--------------------------|------|--------|-------|-----------------------------------------------------------------------------------------| | _initialized | uint8 | 0 | 0 | 1 | MainnetRisc0Verifier | | _initializing | bool | 0 | 1 | 1 | MainnetRisc0Verifier | | __gap | uint256[50] | 1 | 0 | 1600 | MainnetRisc0Verifier | @@ -761,8 +761,8 @@ | __gap | uint256[49] | 252 | 0 | 1568 | MainnetRisc0Verifier | ## MainnetZkAndTeeVerifier -| Name | Type | Slot | Offset | Bytes | Contract | -|----------------|-------------|------|--------|-------|----------------------------------------------------------------------------------------| +| Name | Type | Slot | Offset | Bytes | Contract | +|----------------|-------------|------|--------|-------|-----------------------------------------------------------------------------------------------| | _initialized | uint8 | 0 | 0 | 1 | MainnetZkAndTeeVerifier | | _initializing | bool | 0 | 1 | 1 | MainnetZkAndTeeVerifier | | __gap | uint256[50] | 1 | 0 | 1600 | MainnetZkAndTeeVerifier | @@ -780,8 +780,8 @@ | __gap | uint256[50] | 301 | 0 | 1600 | MainnetZkAndTeeVerifier | ## MainnetTeeAnyVerifier -| Name | Type | Slot | Offset | Bytes | Contract | -|----------------|-------------|------|--------|-------|------------------------------------------------------------------------------------| +| Name | Type | Slot | Offset | Bytes | Contract | +|----------------|-------------|------|--------|-------|-------------------------------------------------------------------------------------------| | _initialized | uint8 | 0 | 0 | 1 | MainnetTeeAnyVerifier | | _initializing | bool | 0 | 1 | 1 | MainnetTeeAnyVerifier | | __gap | uint256[50] | 1 | 0 | 1600 | MainnetTeeAnyVerifier | @@ -799,8 +799,8 @@ | __gap | uint256[50] | 301 | 0 | 1600 | MainnetTeeAnyVerifier | ## MainnetGuardianProver -| Name | Type | Slot | Offset | Bytes | Contract | -|-------------------------|-------------------------------------------------|------|--------|-------|--------------------------------------------------------------------------| +| Name | Type | Slot | Offset | Bytes | Contract | +|-------------------------|-------------------------------------------------|------|--------|-------|---------------------------------------------------------------------------------| | _initialized | uint8 | 0 | 0 | 1 | MainnetGuardianProver | | _initializing | bool | 0 | 1 | 1 | MainnetGuardianProver | | __gap | uint256[50] | 1 | 0 | 1600 | MainnetGuardianProver | @@ -824,8 +824,8 @@ | __gap | uint256[45] | 256 | 0 | 1440 | MainnetGuardianProver | ## MainnetTaikoL1 -| Name | Type | Slot | Offset | Bytes | Contract | -|----------------|------------------------|------|--------|-------|------------------------------------------------------------| +| Name | Type | Slot | Offset | Bytes | Contract | +|----------------|------------------------|------|--------|-------|-------------------------------------------------------------------| | _initialized | uint8 | 0 | 0 | 1 | MainnetTaikoL1 | | _initializing | bool | 0 | 1 | 1 | MainnetTaikoL1 | | __gap | uint256[50] | 1 | 0 | 1600 | MainnetTaikoL1 | @@ -843,8 +843,8 @@ | __gap | uint256[50] | 301 | 0 | 1600 | MainnetTaikoL1 | ## MainnetRollupAddressManager -| Name | Type | Slot | Offset | Bytes | Contract | -|----------------|-------------------------------------------------|------|--------|-------|--------------------------------------------------------------------------------------| +| Name | Type | Slot | Offset | Bytes | Contract | +|----------------|-------------------------------------------------|------|--------|-------|---------------------------------------------------------------------------------------------| | _initialized | uint8 | 0 | 0 | 1 | MainnetRollupAddressManager | | _initializing | bool | 0 | 1 | 1 | MainnetRollupAddressManager | | __gap | uint256[50] | 1 | 0 | 1600 | MainnetRollupAddressManager | @@ -866,8 +866,8 @@ |------|------|------|--------|-------|----------| ## MainnetProverSet -| Name | Type | Slot | Offset | Bytes | Contract | -|----------------|--------------------------|------|--------|-------|----------------------------------------------------------------| +| Name | Type | Slot | Offset | Bytes | Contract | +|----------------|--------------------------|------|--------|-------|-----------------------------------------------------------------------| | _initialized | uint8 | 0 | 0 | 1 | MainnetProverSet | | _initializing | bool | 0 | 1 | 1 | MainnetProverSet | | __gap | uint256[50] | 1 | 0 | 1600 | MainnetProverSet | @@ -886,8 +886,8 @@ | __gap | uint256[48] | 253 | 0 | 1536 | MainnetProverSet | ## TokenUnlock -| Name | Type | Slot | Offset | Bytes | Contract | -|----------------|--------------------------|------|--------|-------|--------------------------------------------------------| +| Name | Type | Slot | Offset | Bytes | Contract | +|----------------|--------------------------|------|--------|-------|---------------------------------------------------------------| | _initialized | uint8 | 0 | 0 | 1 | TokenUnlock | | _initializing | bool | 0 | 1 | 1 | TokenUnlock | | __gap | uint256[50] | 1 | 0 | 1600 | TokenUnlock | @@ -908,8 +908,8 @@ | __gap | uint256[47] | 254 | 0 | 1504 | TokenUnlock | ## ProverSet -| Name | Type | Slot | Offset | Bytes | Contract | -|----------------|--------------------------|------|--------|-------|------------------------------------------------| +| Name | Type | Slot | Offset | Bytes | Contract | +|----------------|--------------------------|------|--------|-------|--------------------------------------------------| | _initialized | uint8 | 0 | 0 | 1 | ProverSet | | _initializing | bool | 0 | 1 | 1 | ProverSet | | __gap | uint256[50] | 1 | 0 | 1600 | ProverSet | @@ -928,8 +928,8 @@ | __gap | uint256[48] | 253 | 0 | 1536 | ProverSet | ## GuardianProver -| Name | Type | Slot | Offset | Bytes | Contract | -|-------------------------|-------------------------------------------------|------|--------|-------|--------------------------------------------------------| +| Name | Type | Slot | Offset | Bytes | Contract | +|-------------------------|-------------------------------------------------|------|--------|-------|------------------------------------------------------------| | _initialized | uint8 | 0 | 0 | 1 | GuardianProver | | _initializing | bool | 0 | 1 | 1 | GuardianProver | | __gap | uint256[50] | 1 | 0 | 1600 | GuardianProver | diff --git a/packages/protocol/contract_layout_layer2.md b/packages/protocol/contract_layout_layer2.md index c412e161389..4c9776da7d2 100644 --- a/packages/protocol/contract_layout_layer2.md +++ b/packages/protocol/contract_layout_layer2.md @@ -1,6 +1,6 @@ ## ERC1155Vault -| Name | Type | Slot | Offset | Bytes | Contract | -|--------------------|------------------------------------------------------|------|--------|-------|----------------------------------------------------| +| Name | Type | Slot | Offset | Bytes | Contract | +|--------------------|------------------------------------------------------|------|--------|-------|-----------------------------------------------------------| | _initialized | uint8 | 0 | 0 | 1 | ERC1155Vault | | _initializing | bool | 0 | 1 | 1 | ERC1155Vault | | __gap | uint256[50] | 1 | 0 | 1600 | ERC1155Vault | @@ -23,8 +23,8 @@ | __gap | uint256[50] | 451 | 0 | 1600 | ERC1155Vault | ## ERC20Vault -| Name | Type | Slot | Offset | Bytes | Contract | -|--------------------|------------------------------------------------------|------|--------|-------|------------------------------------------------| +| Name | Type | Slot | Offset | Bytes | Contract | +|--------------------|------------------------------------------------------|------|--------|-------|-------------------------------------------------------| | _initialized | uint8 | 0 | 0 | 1 | ERC20Vault | | _initializing | bool | 0 | 1 | 1 | ERC20Vault | | __gap | uint256[50] | 1 | 0 | 1600 | ERC20Vault | @@ -46,8 +46,8 @@ | __gap | uint256[46] | 305 | 0 | 1472 | ERC20Vault | ## ERC721Vault -| Name | Type | Slot | Offset | Bytes | Contract | -|--------------------|------------------------------------------------------|------|--------|-------|--------------------------------------------------| +| Name | Type | Slot | Offset | Bytes | Contract | +|--------------------|------------------------------------------------------|------|--------|-------|---------------------------------------------------------| | _initialized | uint8 | 0 | 0 | 1 | ERC721Vault | | _initializing | bool | 0 | 1 | 1 | ERC721Vault | | __gap | uint256[50] | 1 | 0 | 1600 | ERC721Vault | @@ -68,8 +68,8 @@ | __gap | uint256[50] | 351 | 0 | 1600 | ERC721Vault | ## BridgedERC20 -| Name | Type | Slot | Offset | Bytes | Contract | -|------------------|-------------------------------------------------|------|--------|-------|----------------------------------------------------| +| Name | Type | Slot | Offset | Bytes | Contract | +|------------------|-------------------------------------------------|------|--------|-------|-----------------------------------------------------------| | _initialized | uint8 | 0 | 0 | 1 | BridgedERC20 | | _initializing | bool | 0 | 1 | 1 | BridgedERC20 | | __gap | uint256[50] | 1 | 0 | 1600 | BridgedERC20 | @@ -97,8 +97,8 @@ | __gap | uint256[47] | 304 | 0 | 1504 | BridgedERC20 | ## BridgedERC20V2 -| Name | Type | Slot | Offset | Bytes | Contract | -|------------------|--------------------------------------------------------|------|--------|-------|--------------------------------------------------------| +| Name | Type | Slot | Offset | Bytes | Contract | +|------------------|--------------------------------------------------------|------|--------|-------|---------------------------------------------------------------| | _initialized | uint8 | 0 | 0 | 1 | BridgedERC20V2 | | _initializing | bool | 0 | 1 | 1 | BridgedERC20V2 | | __gap | uint256[50] | 1 | 0 | 1600 | BridgedERC20V2 | @@ -133,8 +133,8 @@ | __gap | uint256[49] | 404 | 0 | 1568 | BridgedERC20V2 | ## BridgedERC721 -| Name | Type | Slot | Offset | Bytes | Contract | -|--------------------|----------------------------------------------|------|--------|-------|------------------------------------------------------| +| Name | Type | Slot | Offset | Bytes | Contract | +|--------------------|----------------------------------------------|------|--------|-------|-------------------------------------------------------------| | _initialized | uint8 | 0 | 0 | 1 | BridgedERC721 | | _initializing | bool | 0 | 1 | 1 | BridgedERC721 | | __gap | uint256[50] | 1 | 0 | 1600 | BridgedERC721 | @@ -161,8 +161,8 @@ | __gap | uint256[48] | 353 | 0 | 1536 | BridgedERC721 | ## BridgedERC1155 -| Name | Type | Slot | Offset | Bytes | Contract | -|--------------------|-------------------------------------------------|------|--------|-------|--------------------------------------------------------| +| Name | Type | Slot | Offset | Bytes | Contract | +|--------------------|-------------------------------------------------|------|--------|-------|---------------------------------------------------------------| | _initialized | uint8 | 0 | 0 | 1 | BridgedERC1155 | | _initializing | bool | 0 | 1 | 1 | BridgedERC1155 | | __gap | uint256[50] | 1 | 0 | 1600 | BridgedERC1155 | @@ -188,8 +188,8 @@ | __gap | uint256[46] | 355 | 0 | 1472 | BridgedERC1155 | ## Bridge -| Name | Type | Slot | Offset | Bytes | Contract | -|----------------|-----------------------------------------|------|--------|-------|------------------------------------| +| Name | Type | Slot | Offset | Bytes | Contract | +|----------------|-----------------------------------------|------|--------|-------|-------------------------------------------| | _initialized | uint8 | 0 | 0 | 1 | Bridge | | _initializing | bool | 0 | 1 | 1 | Bridge | | __gap | uint256[50] | 1 | 0 | 1600 | Bridge | @@ -212,8 +212,8 @@ | __gap | uint256[44] | 257 | 0 | 1408 | Bridge | ## QuotaManager -| Name | Type | Slot | Offset | Bytes | Contract | -|----------------|-----------------------------------------------|------|--------|-------|------------------------------------------------| +| Name | Type | Slot | Offset | Bytes | Contract | +|----------------|-----------------------------------------------|------|--------|-------|-------------------------------------------------------| | _initialized | uint8 | 0 | 0 | 1 | QuotaManager | | _initializing | bool | 0 | 1 | 1 | QuotaManager | | __gap | uint256[50] | 1 | 0 | 1600 | QuotaManager | @@ -232,8 +232,8 @@ | __gap | uint256[48] | 253 | 0 | 1536 | QuotaManager | ## AddressManager -| Name | Type | Slot | Offset | Bytes | Contract | -|----------------|-------------------------------------------------|------|--------|-------|----------------------------------------------------| +| Name | Type | Slot | Offset | Bytes | Contract | +|----------------|-------------------------------------------------|------|--------|-------|-----------------------------------------------------------| | _initialized | uint8 | 0 | 0 | 1 | AddressManager | | _initializing | bool | 0 | 1 | 1 | AddressManager | | __gap | uint256[50] | 1 | 0 | 1600 | AddressManager | @@ -251,16 +251,16 @@ | __gap | uint256[49] | 252 | 0 | 1568 | AddressManager | ## AddressResolver -| Name | Type | Slot | Offset | Bytes | Contract | -|----------------|-------------|------|--------|-------|------------------------------------------------------| +| Name | Type | Slot | Offset | Bytes | Contract | +|----------------|-------------|------|--------|-------|-------------------------------------------------------------| | _initialized | uint8 | 0 | 0 | 1 | AddressResolver | | _initializing | bool | 0 | 1 | 1 | AddressResolver | | addressManager | address | 0 | 2 | 20 | AddressResolver | | __gap | uint256[49] | 1 | 0 | 1568 | AddressResolver | ## EssentialContract -| Name | Type | Slot | Offset | Bytes | Contract | -|----------------|-------------|------|--------|-------|----------------------------------------------------------| +| Name | Type | Slot | Offset | Bytes | Contract | +|----------------|-------------|------|--------|-------|-----------------------------------------------------------------| | _initialized | uint8 | 0 | 0 | 1 | EssentialContract | | _initializing | bool | 0 | 1 | 1 | EssentialContract | | __gap | uint256[50] | 1 | 0 | 1600 | EssentialContract | @@ -276,8 +276,8 @@ | __gap | uint256[49] | 202 | 0 | 1568 | EssentialContract | ## SignalService -| Name | Type | Slot | Offset | Bytes | Contract | -|----------------|-----------------------------------------------|------|--------|-------|--------------------------------------------------| +| Name | Type | Slot | Offset | Bytes | Contract | +|----------------|-----------------------------------------------|------|--------|-------|---------------------------------------------------------| | _initialized | uint8 | 0 | 0 | 1 | SignalService | | _initializing | bool | 0 | 1 | 1 | SignalService | | __gap | uint256[50] | 1 | 0 | 1600 | SignalService | @@ -296,8 +296,8 @@ | __gap | uint256[48] | 253 | 0 | 1536 | SignalService | ## BridgedTaikoToken -| Name | Type | Slot | Offset | Bytes | Contract | -|-----------------------------------------------------|---------------------------------------------------------------|------|--------|-------|-------------------------------------------------------| +| Name | Type | Slot | Offset | Bytes | Contract | +|-----------------------------------------------------|---------------------------------------------------------------|------|--------|-------|----------------------------------------------------------------| | _initialized | uint8 | 0 | 0 | 1 | BridgedTaikoToken | | _initializing | bool | 0 | 1 | 1 | BridgedTaikoToken | | __gap | uint256[50] | 1 | 0 | 1600 | BridgedTaikoToken | @@ -333,8 +333,8 @@ | __gap | uint256[50] | 504 | 0 | 1600 | BridgedTaikoToken | ## DelegateOwner -| Name | Type | Slot | Offset | Bytes | Contract | -|----------------|-------------|------|--------|-------|----------------------------------------------| +| Name | Type | Slot | Offset | Bytes | Contract | +|----------------|-------------|------|--------|-------|--------------------------------------------------| | _initialized | uint8 | 0 | 0 | 1 | DelegateOwner | | _initializing | bool | 0 | 1 | 1 | DelegateOwner | | __gap | uint256[50] | 1 | 0 | 1600 | DelegateOwner | @@ -355,8 +355,8 @@ | __gap | uint256[48] | 253 | 0 | 1536 | DelegateOwner | ## TaikoL2 -| Name | Type | Slot | Offset | Bytes | Contract | -|-----------------|-----------------------------|------|--------|-------|----------------------------------| +| Name | Type | Slot | Offset | Bytes | Contract | +|-----------------|-----------------------------|------|--------|-------|--------------------------------------------| | _initialized | uint8 | 0 | 0 | 1 | TaikoL2 | | _initializing | bool | 0 | 1 | 1 | TaikoL2 | | __gap | uint256[50] | 1 | 0 | 1600 | TaikoL2 | @@ -380,8 +380,8 @@ | __gap | uint256[46] | 255 | 0 | 1472 | TaikoL2 | ## HeklaTaikoL2 -| Name | Type | Slot | Offset | Bytes | Contract | -|-----------------|-----------------------------|------|--------|-------|-----------------------------------------------| +| Name | Type | Slot | Offset | Bytes | Contract | +|-----------------|-----------------------------|------|--------|-------|------------------------------------------------------| | _initialized | uint8 | 0 | 0 | 1 | HeklaTaikoL2 | | _initializing | bool | 0 | 1 | 1 | HeklaTaikoL2 | | __gap | uint256[50] | 1 | 0 | 1600 | HeklaTaikoL2 | diff --git a/packages/protocol/contracts/automata-attestation/AutomataDcapV3Attestation.sol b/packages/protocol/contracts/layer1/automata-attestation/AutomataDcapV3Attestation.sol similarity index 99% rename from packages/protocol/contracts/automata-attestation/AutomataDcapV3Attestation.sol rename to packages/protocol/contracts/layer1/automata-attestation/AutomataDcapV3Attestation.sol index 87086e5c0cf..aec2b13ccc3 100644 --- a/packages/protocol/contracts/automata-attestation/AutomataDcapV3Attestation.sol +++ b/packages/protocol/contracts/layer1/automata-attestation/AutomataDcapV3Attestation.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import { V3Struct } from "./lib/QuoteV3Auth/V3Struct.sol"; import { V3Parser } from "./lib/QuoteV3Auth/V3Parser.sol"; @@ -17,7 +17,7 @@ import { BytesUtils } from "./utils/BytesUtils.sol"; // External Libraries import { ISigVerifyLib } from "./interfaces/ISigVerifyLib.sol"; -import { EssentialContract } from "../common/EssentialContract.sol"; +import { EssentialContract } from "../../shared/common/EssentialContract.sol"; /// @title AutomataDcapV3Attestation /// @custom:security-contact security@taiko.xyz diff --git a/packages/protocol/contracts/automata-attestation/README.md b/packages/protocol/contracts/layer1/automata-attestation/README.md similarity index 100% rename from packages/protocol/contracts/automata-attestation/README.md rename to packages/protocol/contracts/layer1/automata-attestation/README.md diff --git a/packages/protocol/contracts/automata-attestation/interfaces/IAttestation.sol b/packages/protocol/contracts/layer1/automata-attestation/interfaces/IAttestation.sol similarity index 94% rename from packages/protocol/contracts/automata-attestation/interfaces/IAttestation.sol rename to packages/protocol/contracts/layer1/automata-attestation/interfaces/IAttestation.sol index f2975aa415c..e5a960a4af8 100644 --- a/packages/protocol/contracts/automata-attestation/interfaces/IAttestation.sol +++ b/packages/protocol/contracts/layer1/automata-attestation/interfaces/IAttestation.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import { V3Struct } from "../lib/QuoteV3Auth/V3Struct.sol"; diff --git a/packages/protocol/contracts/automata-attestation/interfaces/ISigVerifyLib.sol b/packages/protocol/contracts/layer1/automata-attestation/interfaces/ISigVerifyLib.sol similarity index 92% rename from packages/protocol/contracts/automata-attestation/interfaces/ISigVerifyLib.sol rename to packages/protocol/contracts/layer1/automata-attestation/interfaces/ISigVerifyLib.sol index cc59c170e85..3170d0649a9 100644 --- a/packages/protocol/contracts/automata-attestation/interfaces/ISigVerifyLib.sol +++ b/packages/protocol/contracts/layer1/automata-attestation/interfaces/ISigVerifyLib.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; /// @title ISigVerifyLib /// @custom:security-contact security@taiko.xyz diff --git a/packages/protocol/contracts/automata-attestation/lib/EnclaveIdStruct.sol b/packages/protocol/contracts/layer1/automata-attestation/lib/EnclaveIdStruct.sol similarity index 96% rename from packages/protocol/contracts/automata-attestation/lib/EnclaveIdStruct.sol rename to packages/protocol/contracts/layer1/automata-attestation/lib/EnclaveIdStruct.sol index c810cae2aed..d41be6d9671 100644 --- a/packages/protocol/contracts/automata-attestation/lib/EnclaveIdStruct.sol +++ b/packages/protocol/contracts/layer1/automata-attestation/lib/EnclaveIdStruct.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; /// @title EnclaveIdStruct /// @custom:security-contact security@taiko.xyz diff --git a/packages/protocol/contracts/automata-attestation/lib/PEMCertChainLib.sol b/packages/protocol/contracts/layer1/automata-attestation/lib/PEMCertChainLib.sol similarity index 99% rename from packages/protocol/contracts/automata-attestation/lib/PEMCertChainLib.sol rename to packages/protocol/contracts/layer1/automata-attestation/lib/PEMCertChainLib.sol index 0b282f331e5..0fcc99f0a39 100644 --- a/packages/protocol/contracts/automata-attestation/lib/PEMCertChainLib.sol +++ b/packages/protocol/contracts/layer1/automata-attestation/lib/PEMCertChainLib.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import { LibString } from "solady/src/utils/LibString.sol"; import { Asn1Decode, NodePtr } from "../utils/Asn1Decode.sol"; diff --git a/packages/protocol/contracts/automata-attestation/lib/QuoteV3Auth/V3Parser.sol b/packages/protocol/contracts/layer1/automata-attestation/lib/QuoteV3Auth/V3Parser.sol similarity index 99% rename from packages/protocol/contracts/automata-attestation/lib/QuoteV3Auth/V3Parser.sol rename to packages/protocol/contracts/layer1/automata-attestation/lib/QuoteV3Auth/V3Parser.sol index d4fa7ed4265..59e95ef1f40 100644 --- a/packages/protocol/contracts/automata-attestation/lib/QuoteV3Auth/V3Parser.sol +++ b/packages/protocol/contracts/layer1/automata-attestation/lib/QuoteV3Auth/V3Parser.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import { Base64 } from "solady/src/utils/Base64.sol"; import { BytesUtils } from "../../utils/BytesUtils.sol"; diff --git a/packages/protocol/contracts/automata-attestation/lib/QuoteV3Auth/V3Struct.sol b/packages/protocol/contracts/layer1/automata-attestation/lib/QuoteV3Auth/V3Struct.sol similarity index 98% rename from packages/protocol/contracts/automata-attestation/lib/QuoteV3Auth/V3Struct.sol rename to packages/protocol/contracts/layer1/automata-attestation/lib/QuoteV3Auth/V3Struct.sol index 06f975a1542..9ecb7572947 100644 --- a/packages/protocol/contracts/automata-attestation/lib/QuoteV3Auth/V3Struct.sol +++ b/packages/protocol/contracts/layer1/automata-attestation/lib/QuoteV3Auth/V3Struct.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; /// @title V3Struct /// @custom:security-contact security@taiko.xyz diff --git a/packages/protocol/contracts/automata-attestation/lib/TCBInfoStruct.sol b/packages/protocol/contracts/layer1/automata-attestation/lib/TCBInfoStruct.sol similarity index 96% rename from packages/protocol/contracts/automata-attestation/lib/TCBInfoStruct.sol rename to packages/protocol/contracts/layer1/automata-attestation/lib/TCBInfoStruct.sol index dc51e8fb011..b450853c5b4 100644 --- a/packages/protocol/contracts/automata-attestation/lib/TCBInfoStruct.sol +++ b/packages/protocol/contracts/layer1/automata-attestation/lib/TCBInfoStruct.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; /// @title TCBInfoStruct /// @custom:security-contact security@taiko.xyz diff --git a/packages/protocol/contracts/automata-attestation/lib/interfaces/IPEMCertChainLib.sol b/packages/protocol/contracts/layer1/automata-attestation/lib/interfaces/IPEMCertChainLib.sol similarity index 97% rename from packages/protocol/contracts/automata-attestation/lib/interfaces/IPEMCertChainLib.sol rename to packages/protocol/contracts/layer1/automata-attestation/lib/interfaces/IPEMCertChainLib.sol index 233a2b55efd..eeca3b92947 100644 --- a/packages/protocol/contracts/automata-attestation/lib/interfaces/IPEMCertChainLib.sol +++ b/packages/protocol/contracts/layer1/automata-attestation/lib/interfaces/IPEMCertChainLib.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; /// @title IPEMCertChainLib /// @custom:security-contact security@taiko.xyz diff --git a/packages/protocol/contracts/automata-attestation/utils/Asn1Decode.sol b/packages/protocol/contracts/layer1/automata-attestation/utils/Asn1Decode.sol similarity index 99% rename from packages/protocol/contracts/automata-attestation/utils/Asn1Decode.sol rename to packages/protocol/contracts/layer1/automata-attestation/utils/Asn1Decode.sol index 1f1abd2c845..30edd958e7f 100644 --- a/packages/protocol/contracts/automata-attestation/utils/Asn1Decode.sol +++ b/packages/protocol/contracts/layer1/automata-attestation/utils/Asn1Decode.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT // Original source: https://github.com/JonahGroendal/asn1-decode -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; // Inspired by PufferFinance/rave - Apache-2.0 license // https://github.com/JonahGroendal/asn1-decode/blob/5c2d1469fc678513753786acb441e597969192ec/contracts/Asn1Decode.sol diff --git a/packages/protocol/contracts/automata-attestation/utils/BytesUtils.sol b/packages/protocol/contracts/layer1/automata-attestation/utils/BytesUtils.sol similarity index 99% rename from packages/protocol/contracts/automata-attestation/utils/BytesUtils.sol rename to packages/protocol/contracts/layer1/automata-attestation/utils/BytesUtils.sol index bc5fdd1da77..22469685e0d 100644 --- a/packages/protocol/contracts/automata-attestation/utils/BytesUtils.sol +++ b/packages/protocol/contracts/layer1/automata-attestation/utils/BytesUtils.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD 2-Clause License -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; // Inspired by ensdomains/dnssec-oracle - BSD-2-Clause license // https://github.com/ensdomains/dnssec-oracle/blob/master/contracts/BytesUtils.sol diff --git a/packages/protocol/contracts/automata-attestation/utils/SHA1.sol b/packages/protocol/contracts/layer1/automata-attestation/utils/SHA1.sol similarity index 99% rename from packages/protocol/contracts/automata-attestation/utils/SHA1.sol rename to packages/protocol/contracts/layer1/automata-attestation/utils/SHA1.sol index a9b2beba50c..6c39a7d25dc 100644 --- a/packages/protocol/contracts/automata-attestation/utils/SHA1.sol +++ b/packages/protocol/contracts/layer1/automata-attestation/utils/SHA1.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: BSD 2-Clause License -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; // Inspired by ensdomains/solsha1 - BSD 2-Clause License // https://github.com/ensdomains/solsha1/blob/master/contracts/SHA1.sol diff --git a/packages/protocol/contracts/automata-attestation/utils/SigVerifyLib.sol b/packages/protocol/contracts/layer1/automata-attestation/utils/SigVerifyLib.sol similarity index 98% rename from packages/protocol/contracts/automata-attestation/utils/SigVerifyLib.sol rename to packages/protocol/contracts/layer1/automata-attestation/utils/SigVerifyLib.sol index 752d757232b..85bae00b99d 100644 --- a/packages/protocol/contracts/automata-attestation/utils/SigVerifyLib.sol +++ b/packages/protocol/contracts/layer1/automata-attestation/utils/SigVerifyLib.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-3.0 -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "../interfaces/ISigVerifyLib.sol"; import "./BytesUtils.sol"; diff --git a/packages/protocol/contracts/automata-attestation/utils/X509DateUtils.sol b/packages/protocol/contracts/layer1/automata-attestation/utils/X509DateUtils.sol similarity index 99% rename from packages/protocol/contracts/automata-attestation/utils/X509DateUtils.sol rename to packages/protocol/contracts/layer1/automata-attestation/utils/X509DateUtils.sol index 333084b5abd..ac7ef6bc961 100644 --- a/packages/protocol/contracts/automata-attestation/utils/X509DateUtils.sol +++ b/packages/protocol/contracts/layer1/automata-attestation/utils/X509DateUtils.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; /// @title X509DateUtils /// @custom:security-contact security@taiko.xyz diff --git a/packages/protocol/contracts/L1/ITaikoL1.sol b/packages/protocol/contracts/layer1/based/ITaikoL1.sol similarity index 99% rename from packages/protocol/contracts/L1/ITaikoL1.sol rename to packages/protocol/contracts/layer1/based/ITaikoL1.sol index 3e3598b85ac..56cc51107d2 100644 --- a/packages/protocol/contracts/L1/ITaikoL1.sol +++ b/packages/protocol/contracts/layer1/based/ITaikoL1.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "./TaikoData.sol"; diff --git a/packages/protocol/contracts/L1/libs/LibBonds.sol b/packages/protocol/contracts/layer1/based/LibBonds.sol similarity index 95% rename from packages/protocol/contracts/L1/libs/LibBonds.sol rename to packages/protocol/contracts/layer1/based/LibBonds.sol index 02246f68aaf..e80da12b8e9 100644 --- a/packages/protocol/contracts/L1/libs/LibBonds.sol +++ b/packages/protocol/contracts/layer1/based/LibBonds.sol @@ -1,11 +1,11 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; -import "../../common/IAddressResolver.sol"; -import "../../common/LibStrings.sol"; -import "../TaikoData.sol"; +import "../../shared/common/IAddressResolver.sol"; +import "../../shared/common/LibStrings.sol"; +import "./TaikoData.sol"; /// @title LibBonds /// @notice A library that offers helper functions to handle bonds. diff --git a/packages/protocol/contracts/L1/libs/LibData.sol b/packages/protocol/contracts/layer1/based/LibData.sol similarity index 95% rename from packages/protocol/contracts/L1/libs/LibData.sol rename to packages/protocol/contracts/layer1/based/LibData.sol index 20cd2f87b69..242c1417904 100644 --- a/packages/protocol/contracts/L1/libs/LibData.sol +++ b/packages/protocol/contracts/layer1/based/LibData.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; -import "../TaikoData.sol"; -import "../../verifiers/IVerifier.sol"; +import "../verifiers/IVerifier.sol"; +import "./TaikoData.sol"; /// @title LibData /// @notice A library that offers helper functions. @@ -77,7 +77,7 @@ library LibData { blobTxListOffset: 0, blobTxListLength: 0, blobIndex: 0, - baseFeeConfig: TaikoData.BaseFeeConfig(0, 0, 0, 0, 0) + baseFeeConfig: LibSharedData.BaseFeeConfig(0, 0, 0, 0, 0) }); } diff --git a/packages/protocol/contracts/L1/libs/LibProposing.sol b/packages/protocol/contracts/layer1/based/LibProposing.sol similarity index 96% rename from packages/protocol/contracts/L1/libs/LibProposing.sol rename to packages/protocol/contracts/layer1/based/LibProposing.sol index 063e1192618..dab7077aba4 100644 --- a/packages/protocol/contracts/L1/libs/LibProposing.sol +++ b/packages/protocol/contracts/layer1/based/LibProposing.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; -import "../../libs/LibAddress.sol"; -import "../../libs/LibNetwork.sol"; +import "../../shared/common/LibAddress.sol"; +import "../../shared/common/LibNetwork.sol"; import "./LibBonds.sol"; import "./LibData.sol"; import "./LibUtils.sol"; @@ -152,7 +152,7 @@ library LibProposing { address permittedProposer = _resolver.resolve(LibStrings.B_BLOCK_PROPOSER, true); if (permittedProposer != address(0)) { - require(permittedProposer == msg.sender, L1_INVALID_PROPOSER()); + if (permittedProposer != msg.sender) revert L1_INVALID_PROPOSER(); local.allowCustomProposer = true; } @@ -169,10 +169,9 @@ library LibProposing { if (local.params.proposer == address(0)) { local.params.proposer = msg.sender; } else { - require( - local.params.proposer == msg.sender || local.allowCustomProposer, - L1_INVALID_CUSTOM_PROPOSER() - ); + if (local.params.proposer != msg.sender && !local.allowCustomProposer) { + revert L1_INVALID_CUSTOM_PROPOSER(); + } } if (local.params.coinbase == address(0)) { @@ -331,7 +330,7 @@ library LibProposing { } } - function _encodeBaseFeeConfig(TaikoData.BaseFeeConfig memory _baseFeeConfig) + function _encodeBaseFeeConfig(LibSharedData.BaseFeeConfig memory _baseFeeConfig) private pure returns (bytes32) diff --git a/packages/protocol/contracts/L1/libs/LibProving.sol b/packages/protocol/contracts/layer1/based/LibProving.sol similarity index 99% rename from packages/protocol/contracts/L1/libs/LibProving.sol rename to packages/protocol/contracts/layer1/based/LibProving.sol index 049a78e4fef..753fa6f097b 100644 --- a/packages/protocol/contracts/L1/libs/LibProving.sol +++ b/packages/protocol/contracts/layer1/based/LibProving.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; -import "../../verifiers/IVerifier.sol"; +import "../verifiers/IVerifier.sol"; import "./LibBonds.sol"; import "./LibData.sol"; import "./LibUtils.sol"; diff --git a/packages/protocol/contracts/L1/libs/LibUtils.sol b/packages/protocol/contracts/layer1/based/LibUtils.sol similarity index 98% rename from packages/protocol/contracts/L1/libs/LibUtils.sol rename to packages/protocol/contracts/layer1/based/LibUtils.sol index e7520ea3d6f..d302a7b31d6 100644 --- a/packages/protocol/contracts/L1/libs/LibUtils.sol +++ b/packages/protocol/contracts/layer1/based/LibUtils.sol @@ -1,14 +1,14 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; -import "../../common/IAddressResolver.sol"; -import "../../common/LibStrings.sol"; -import "../../libs/LibMath.sol"; +import "../../shared/common/IAddressResolver.sol"; +import "../../shared/common/LibStrings.sol"; +import "../../shared/common/LibMath.sol"; import "../tiers/ITierProvider.sol"; import "../tiers/ITierRouter.sol"; -import "../TaikoData.sol"; +import "./TaikoData.sol"; /// @title LibUtils /// @notice A library that offers helper functions. diff --git a/packages/protocol/contracts/L1/libs/LibVerifying.sol b/packages/protocol/contracts/layer1/based/LibVerifying.sol similarity index 99% rename from packages/protocol/contracts/L1/libs/LibVerifying.sol rename to packages/protocol/contracts/layer1/based/LibVerifying.sol index 4ac11652fc6..0c744c249d1 100644 --- a/packages/protocol/contracts/L1/libs/LibVerifying.sol +++ b/packages/protocol/contracts/layer1/based/LibVerifying.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; -import "../../signal/ISignalService.sol"; +import "../../shared/signal/ISignalService.sol"; import "./LibBonds.sol"; import "./LibUtils.sol"; diff --git a/packages/protocol/contracts/L1/TaikoData.sol b/packages/protocol/contracts/layer1/based/TaikoData.sol similarity index 96% rename from packages/protocol/contracts/L1/TaikoData.sol rename to packages/protocol/contracts/layer1/based/TaikoData.sol index 035be119737..895a8d841cf 100644 --- a/packages/protocol/contracts/L1/TaikoData.sol +++ b/packages/protocol/contracts/layer1/based/TaikoData.sol @@ -1,20 +1,13 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; + +import "../../shared/data/LibSharedData.sol"; /// @title TaikoData /// @notice This library defines various data structures used in the Taiko /// protocol. /// @custom:security-contact security@taiko.xyz library TaikoData { - /// @dev Struct that represents L2 basefee configurations - struct BaseFeeConfig { - uint8 adjustmentQuotient; - uint8 sharingPctg; - uint32 gasIssuancePerSecond; - uint64 minGasExcess; - uint32 maxGasIssuancePerBlock; - } - /// @dev Struct holding Taiko configuration parameters. See {TaikoConfig}. struct Config { // --------------------------------------------------------------------- @@ -48,7 +41,7 @@ library TaikoData { // --------------------------------------------------------------------- // Group 5: Previous configs in TaikoL2 // --------------------------------------------------------------------- - BaseFeeConfig baseFeeConfig; + LibSharedData.BaseFeeConfig baseFeeConfig; // --------------------------------------------------------------------- // Group 6: Others // --------------------------------------------------------------------- @@ -131,7 +124,7 @@ library TaikoData { uint32 blobTxListOffset; uint32 blobTxListLength; uint8 blobIndex; - BaseFeeConfig baseFeeConfig; + LibSharedData.BaseFeeConfig baseFeeConfig; } /// @dev Struct representing transition to be proven. diff --git a/packages/protocol/contracts/L1/TaikoEvents.sol b/packages/protocol/contracts/layer1/based/TaikoEvents.sol similarity index 99% rename from packages/protocol/contracts/L1/TaikoEvents.sol rename to packages/protocol/contracts/layer1/based/TaikoEvents.sol index 9c8c886a644..32bae8634b4 100644 --- a/packages/protocol/contracts/L1/TaikoEvents.sol +++ b/packages/protocol/contracts/layer1/based/TaikoEvents.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "./TaikoData.sol"; diff --git a/packages/protocol/contracts/L1/TaikoL1.sol b/packages/protocol/contracts/layer1/based/TaikoL1.sol similarity index 97% rename from packages/protocol/contracts/L1/TaikoL1.sol rename to packages/protocol/contracts/layer1/based/TaikoL1.sol index cd2bdfe3a3a..d15f655cf79 100644 --- a/packages/protocol/contracts/L1/TaikoL1.sol +++ b/packages/protocol/contracts/layer1/based/TaikoL1.sol @@ -1,11 +1,11 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; -import "../common/EssentialContract.sol"; -import "./libs/LibData.sol"; -import "./libs/LibProposing.sol"; -import "./libs/LibProving.sol"; -import "./libs/LibVerifying.sol"; +import "../../shared/common/EssentialContract.sol"; +import "./LibData.sol"; +import "./LibProposing.sol"; +import "./LibProving.sol"; +import "./LibVerifying.sol"; import "./TaikoEvents.sol"; import "./ITaikoL1.sol"; @@ -284,7 +284,7 @@ contract TaikoL1 is EssentialContract, ITaikoL1, TaikoEvents { livenessBond: 125e18, // 125 Taiko token stateRootSyncInternal: 16, maxAnchorHeightOffset: 64, - baseFeeConfig: TaikoData.BaseFeeConfig({ + baseFeeConfig: LibSharedData.BaseFeeConfig({ adjustmentQuotient: 8, sharingPctg: 75, gasIssuancePerSecond: 5_000_000, diff --git a/packages/protocol/contracts/devnet/DevnetTaikoL1.sol b/packages/protocol/contracts/layer1/devnet/DevnetTaikoL1.sol similarity index 89% rename from packages/protocol/contracts/devnet/DevnetTaikoL1.sol rename to packages/protocol/contracts/layer1/devnet/DevnetTaikoL1.sol index 366a2886033..c256e1500a0 100644 --- a/packages/protocol/contracts/devnet/DevnetTaikoL1.sol +++ b/packages/protocol/contracts/layer1/devnet/DevnetTaikoL1.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; -import "../L1/TaikoL1.sol"; +import "../based/TaikoL1.sol"; /// @title DevnetTaikoL1 /// @dev Labeled in AddressResolver as "taiko" @@ -18,7 +18,7 @@ contract DevnetTaikoL1 is TaikoL1 { livenessBond: 125e18, // 125 Taiko token stateRootSyncInternal: 16, maxAnchorHeightOffset: 64, - baseFeeConfig: TaikoData.BaseFeeConfig({ + baseFeeConfig: LibSharedData.BaseFeeConfig({ adjustmentQuotient: 8, sharingPctg: 75, gasIssuancePerSecond: 5_000_000, diff --git a/packages/protocol/contracts/L1/tiers/DevnetTierProvider.sol b/packages/protocol/contracts/layer1/devnet/DevnetTierProvider.sol similarity index 88% rename from packages/protocol/contracts/L1/tiers/DevnetTierProvider.sol rename to packages/protocol/contracts/layer1/devnet/DevnetTierProvider.sol index d32d65efea9..0b842926633 100644 --- a/packages/protocol/contracts/L1/tiers/DevnetTierProvider.sol +++ b/packages/protocol/contracts/layer1/devnet/DevnetTierProvider.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; -import "./TierProviderBase.sol"; -import "./ITierRouter.sol"; +import "../tiers/TierProviderBase.sol"; +import "../tiers/ITierRouter.sol"; /// @title DevnetTierProvider /// @custom:security-contact security@taiko.xyz diff --git a/packages/protocol/contracts/hekla/HeklaTaikoL1.sol b/packages/protocol/contracts/layer1/hekla/HeklaTaikoL1.sol similarity index 90% rename from packages/protocol/contracts/hekla/HeklaTaikoL1.sol rename to packages/protocol/contracts/layer1/hekla/HeklaTaikoL1.sol index f8446ba9813..162ca9e930c 100644 --- a/packages/protocol/contracts/hekla/HeklaTaikoL1.sol +++ b/packages/protocol/contracts/layer1/hekla/HeklaTaikoL1.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; -import "../L1/TaikoL1.sol"; +import "../based/TaikoL1.sol"; /// @title HeklaTaikoL1 /// @dev Labeled in AddressResolver as "taiko" @@ -20,7 +20,7 @@ contract HeklaTaikoL1 is TaikoL1 { livenessBond: 125e18, // 125 Taiko token stateRootSyncInternal: 16, maxAnchorHeightOffset: 64, - baseFeeConfig: TaikoData.BaseFeeConfig({ + baseFeeConfig: LibSharedData.BaseFeeConfig({ adjustmentQuotient: 8, sharingPctg: 75, gasIssuancePerSecond: 5_000_000, diff --git a/packages/protocol/contracts/hekla/HeklaTierProvider.sol b/packages/protocol/contracts/layer1/hekla/HeklaTierProvider.sol similarity index 93% rename from packages/protocol/contracts/hekla/HeklaTierProvider.sol rename to packages/protocol/contracts/layer1/hekla/HeklaTierProvider.sol index 336220889d5..0876e367d5d 100644 --- a/packages/protocol/contracts/hekla/HeklaTierProvider.sol +++ b/packages/protocol/contracts/layer1/hekla/HeklaTierProvider.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; -import "../L1/tiers/TierProviderBase.sol"; -import "../L1/tiers/ITierRouter.sol"; +import "../tiers/TierProviderBase.sol"; +import "../tiers/ITierRouter.sol"; /// @title HeklaTierProvider /// @custom:security-contact security@taiko.xyz diff --git a/packages/protocol/contracts/mainnet/README.md b/packages/protocol/contracts/layer1/mainnet/README.md similarity index 100% rename from packages/protocol/contracts/mainnet/README.md rename to packages/protocol/contracts/layer1/mainnet/README.md diff --git a/packages/protocol/contracts/mainnet/addrcache/AddressCache.sol b/packages/protocol/contracts/layer1/mainnet/addrcache/AddressCache.sol similarity index 98% rename from packages/protocol/contracts/mainnet/addrcache/AddressCache.sol rename to packages/protocol/contracts/layer1/mainnet/addrcache/AddressCache.sol index 7fad12dbee7..6dfc98aae8e 100644 --- a/packages/protocol/contracts/mainnet/addrcache/AddressCache.sol +++ b/packages/protocol/contracts/layer1/mainnet/addrcache/AddressCache.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; /// @title AddressCache /// @custom:security-contact security@taiko.xyz diff --git a/packages/protocol/contracts/mainnet/addrcache/RollupAddressCache.sol b/packages/protocol/contracts/layer1/mainnet/addrcache/RollupAddressCache.sol similarity index 94% rename from packages/protocol/contracts/mainnet/addrcache/RollupAddressCache.sol rename to packages/protocol/contracts/layer1/mainnet/addrcache/RollupAddressCache.sol index f6d62db597d..ad0a567f6e6 100644 --- a/packages/protocol/contracts/mainnet/addrcache/RollupAddressCache.sol +++ b/packages/protocol/contracts/layer1/mainnet/addrcache/RollupAddressCache.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; -import "../../common/LibStrings.sol"; -import "../../libs/LibNetwork.sol"; +import "../../../shared/common/LibStrings.sol"; +import "../../../shared/common/LibNetwork.sol"; import "./AddressCache.sol"; /// @title RollupAddressCache diff --git a/packages/protocol/contracts/mainnet/addrcache/SharedAddressCache.sol b/packages/protocol/contracts/layer1/mainnet/addrcache/SharedAddressCache.sol similarity index 95% rename from packages/protocol/contracts/mainnet/addrcache/SharedAddressCache.sol rename to packages/protocol/contracts/layer1/mainnet/addrcache/SharedAddressCache.sol index 33be40f9180..57dd9f6e4b8 100644 --- a/packages/protocol/contracts/mainnet/addrcache/SharedAddressCache.sol +++ b/packages/protocol/contracts/layer1/mainnet/addrcache/SharedAddressCache.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; -import "../../common/LibStrings.sol"; -import "../../libs/LibNetwork.sol"; +import "../../../shared/common/LibStrings.sol"; +import "../../../shared/common/LibNetwork.sol"; import "./AddressCache.sol"; /// @title SharedAddressCache diff --git a/packages/protocol/contracts/layer1/mainnet/multirollup/MainnetBridge.sol b/packages/protocol/contracts/layer1/mainnet/multirollup/MainnetBridge.sol new file mode 100644 index 00000000000..f737e2903c8 --- /dev/null +++ b/packages/protocol/contracts/layer1/mainnet/multirollup/MainnetBridge.sol @@ -0,0 +1,53 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.24; + +import "../../../shared/bridge/Bridge.sol"; +import "../addrcache/SharedAddressCache.sol"; +import "../reentrylock/LibFasterReentryLock.sol"; + +/// @title MainnetBridge +/// @dev This contract shall be deployed to replace its parent contract on Ethereum for Taiko +/// mainnet to reduce gas cost. In theory, the contract can also be deplyed on Taiko L2 but this is +/// not well testee nor necessary. +/// @notice See the documentation in {Bridge}. +/// @custom:security-contact security@taiko.xyz +contract MainnetBridge is Bridge, SharedAddressCache { + /// @dev The slot in transient storage of the call context. This is the keccak256 hash + /// of "bridge.ctx_slot" + bytes32 private constant _CTX_SLOT = + 0xe4ece82196de19aabe639620d7f716c433d1348f96ce727c9989a982dbadc2b9; + + function _getAddress(uint64 _chainId, bytes32 _name) internal view override returns (address) { + return getAddress(_chainId, _name, super._getAddress); + } + + function _storeReentryLock(uint8 _reentry) internal override { + LibFasterReentryLock.storeReentryLock(_reentry); + } + + function _loadReentryLock() internal view override returns (uint8) { + return LibFasterReentryLock.loadReentryLock(); + } + + /// @inheritdoc Bridge + function _storeContext(bytes32 _msgHash, address _from, uint64 _srcChainId) internal override { + assembly { + tstore(_CTX_SLOT, _msgHash) + tstore(add(_CTX_SLOT, 1), _from) + tstore(add(_CTX_SLOT, 2), _srcChainId) + } + } + + /// @inheritdoc Bridge + function _loadContext() internal view override returns (Context memory) { + bytes32 msgHash; + address from; + uint64 srcChainId; + assembly { + msgHash := tload(_CTX_SLOT) + from := tload(add(_CTX_SLOT, 1)) + srcChainId := tload(add(_CTX_SLOT, 2)) + } + return Context(msgHash, from, srcChainId); + } +} diff --git a/packages/protocol/contracts/mainnet/shared/MainnetERC1155Vault.sol b/packages/protocol/contracts/layer1/mainnet/multirollup/MainnetERC1155Vault.sol similarity index 63% rename from packages/protocol/contracts/mainnet/shared/MainnetERC1155Vault.sol rename to packages/protocol/contracts/layer1/mainnet/multirollup/MainnetERC1155Vault.sol index d96720844f4..2fe0eec1e7b 100644 --- a/packages/protocol/contracts/mainnet/shared/MainnetERC1155Vault.sol +++ b/packages/protocol/contracts/layer1/mainnet/multirollup/MainnetERC1155Vault.sol @@ -1,8 +1,9 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; -import "../../tokenvault/ERC1155Vault.sol"; +import "../../../shared/tokenvault/ERC1155Vault.sol"; import "../addrcache/SharedAddressCache.sol"; +import "../reentrylock/LibFasterReentryLock.sol"; /// @title MainnetERC1155Vault /// @dev This contract shall be deployed to replace its parent contract on Ethereum for Taiko @@ -14,4 +15,12 @@ contract MainnetERC1155Vault is ERC1155Vault, SharedAddressCache { function _getAddress(uint64 _chainId, bytes32 _name) internal view override returns (address) { return getAddress(_chainId, _name, super._getAddress); } + + function _storeReentryLock(uint8 _reentry) internal override { + LibFasterReentryLock.storeReentryLock(_reentry); + } + + function _loadReentryLock() internal view override returns (uint8) { + return LibFasterReentryLock.loadReentryLock(); + } } diff --git a/packages/protocol/contracts/mainnet/shared/MainnetERC20Vault.sol b/packages/protocol/contracts/layer1/mainnet/multirollup/MainnetERC20Vault.sol similarity index 63% rename from packages/protocol/contracts/mainnet/shared/MainnetERC20Vault.sol rename to packages/protocol/contracts/layer1/mainnet/multirollup/MainnetERC20Vault.sol index 68a3e889e64..e9688517710 100644 --- a/packages/protocol/contracts/mainnet/shared/MainnetERC20Vault.sol +++ b/packages/protocol/contracts/layer1/mainnet/multirollup/MainnetERC20Vault.sol @@ -1,8 +1,9 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; -import "../../tokenvault/ERC20Vault.sol"; +import "../../../shared/tokenvault/ERC20Vault.sol"; import "../addrcache/SharedAddressCache.sol"; +import "../reentrylock/LibFasterReentryLock.sol"; /// @title MainnetERC20Vault /// @dev This contract shall be deployed to replace its parent contract on Ethereum for Taiko @@ -14,4 +15,12 @@ contract MainnetERC20Vault is ERC20Vault, SharedAddressCache { function _getAddress(uint64 _chainId, bytes32 _name) internal view override returns (address) { return getAddress(_chainId, _name, super._getAddress); } + + function _storeReentryLock(uint8 _reentry) internal override { + LibFasterReentryLock.storeReentryLock(_reentry); + } + + function _loadReentryLock() internal view override returns (uint8) { + return LibFasterReentryLock.loadReentryLock(); + } } diff --git a/packages/protocol/contracts/mainnet/shared/MainnetERC721Vault.sol b/packages/protocol/contracts/layer1/mainnet/multirollup/MainnetERC721Vault.sol similarity index 63% rename from packages/protocol/contracts/mainnet/shared/MainnetERC721Vault.sol rename to packages/protocol/contracts/layer1/mainnet/multirollup/MainnetERC721Vault.sol index 9568de8a0f0..416bc813194 100644 --- a/packages/protocol/contracts/mainnet/shared/MainnetERC721Vault.sol +++ b/packages/protocol/contracts/layer1/mainnet/multirollup/MainnetERC721Vault.sol @@ -1,8 +1,9 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; -import "../../tokenvault/ERC721Vault.sol"; +import "../../../shared/tokenvault/ERC721Vault.sol"; import "../addrcache/SharedAddressCache.sol"; +import "../reentrylock/LibFasterReentryLock.sol"; /// @title MainnetERC721Vault /// @dev This contract shall be deployed to replace its parent contract on Ethereum for Taiko @@ -14,4 +15,12 @@ contract MainnetERC721Vault is ERC721Vault, SharedAddressCache { function _getAddress(uint64 _chainId, bytes32 _name) internal view override returns (address) { return getAddress(_chainId, _name, super._getAddress); } + + function _storeReentryLock(uint8 _reentry) internal override { + LibFasterReentryLock.storeReentryLock(_reentry); + } + + function _loadReentryLock() internal view override returns (uint8) { + return LibFasterReentryLock.loadReentryLock(); + } } diff --git a/packages/protocol/contracts/mainnet/shared/MainnetSharedAddressManager.sol b/packages/protocol/contracts/layer1/mainnet/multirollup/MainnetSharedAddressManager.sol similarity index 57% rename from packages/protocol/contracts/mainnet/shared/MainnetSharedAddressManager.sol rename to packages/protocol/contracts/layer1/mainnet/multirollup/MainnetSharedAddressManager.sol index 60e2d0dff6f..a0d26ff9d83 100644 --- a/packages/protocol/contracts/mainnet/shared/MainnetSharedAddressManager.sol +++ b/packages/protocol/contracts/layer1/mainnet/multirollup/MainnetSharedAddressManager.sol @@ -1,9 +1,10 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; -import "../../common/AddressManager.sol"; -import "../../common/LibStrings.sol"; +import "../../../shared/common/AddressManager.sol"; +import "../../../shared/common/LibStrings.sol"; import "../addrcache/SharedAddressCache.sol"; +import "../reentrylock/LibFasterReentryLock.sol"; /// @title MainnetSharedAddressManager /// @dev This contract shall be deployed to replace its parent contract on Ethereum for Taiko @@ -14,4 +15,12 @@ contract MainnetSharedAddressManager is AddressManager, SharedAddressCache { function _getAddress(uint64 _chainId, bytes32 _name) internal view override returns (address) { return getAddress(_chainId, _name, super._getAddress); } + + function _storeReentryLock(uint8 _reentry) internal override { + LibFasterReentryLock.storeReentryLock(_reentry); + } + + function _loadReentryLock() internal view override returns (uint8) { + return LibFasterReentryLock.loadReentryLock(); + } } diff --git a/packages/protocol/contracts/mainnet/shared/MainnetSignalService.sol b/packages/protocol/contracts/layer1/mainnet/multirollup/MainnetSignalService.sol similarity index 63% rename from packages/protocol/contracts/mainnet/shared/MainnetSignalService.sol rename to packages/protocol/contracts/layer1/mainnet/multirollup/MainnetSignalService.sol index c07f51d7550..2d10595702b 100644 --- a/packages/protocol/contracts/mainnet/shared/MainnetSignalService.sol +++ b/packages/protocol/contracts/layer1/mainnet/multirollup/MainnetSignalService.sol @@ -1,8 +1,9 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; -import "../../signal/SignalService.sol"; +import "../../../shared/signal/SignalService.sol"; import "../addrcache/SharedAddressCache.sol"; +import "../reentrylock/LibFasterReentryLock.sol"; /// @title MainnetSignalService /// @dev This contract shall be deployed to replace its parent contract on Ethereum for Taiko @@ -14,4 +15,12 @@ contract MainnetSignalService is SignalService, SharedAddressCache { function _getAddress(uint64 _chainId, bytes32 _name) internal view override returns (address) { return getAddress(_chainId, _name, super._getAddress); } + + function _storeReentryLock(uint8 _reentry) internal override { + LibFasterReentryLock.storeReentryLock(_reentry); + } + + function _loadReentryLock() internal view override returns (uint8) { + return LibFasterReentryLock.loadReentryLock(); + } } diff --git a/packages/protocol/contracts/layer1/mainnet/reentrylock/LibFasterReentryLock.sol b/packages/protocol/contracts/layer1/mainnet/reentrylock/LibFasterReentryLock.sol new file mode 100644 index 00000000000..cfa3d7c066e --- /dev/null +++ b/packages/protocol/contracts/layer1/mainnet/reentrylock/LibFasterReentryLock.sol @@ -0,0 +1,26 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.24; + +/// @title LibFasterReentryLock +/// @custom:security-contact security@taiko.xyz +library LibFasterReentryLock { + /// @dev The slot in transient storage of the reentry lock. + /// This is the result of keccak256("ownerUUPS.reentry_slot") plus 1. The addition aims to + /// prevent hash collisions with slots defined in EIP-1967, where slots are derived by + /// keccak256("something") - 1, and with slots in SignalService, calculated directly with + /// keccak256("something"). + bytes32 private constant _REENTRY_SLOT = + 0xa5054f728453d3dbe953bdc43e4d0cb97e662ea32d7958190f3dc2da31d9721b; + + function storeReentryLock(uint8 _reentry) internal { + assembly { + tstore(_REENTRY_SLOT, _reentry) + } + } + + function loadReentryLock() internal view returns (uint8 reentry_) { + assembly { + reentry_ := tload(_REENTRY_SLOT) + } + } +} diff --git a/packages/protocol/contracts/mainnet/rollup/MainnetGuardianProver.sol b/packages/protocol/contracts/layer1/mainnet/rollup/MainnetGuardianProver.sol similarity index 59% rename from packages/protocol/contracts/mainnet/rollup/MainnetGuardianProver.sol rename to packages/protocol/contracts/layer1/mainnet/rollup/MainnetGuardianProver.sol index c017e092802..0fa50684a8c 100644 --- a/packages/protocol/contracts/mainnet/rollup/MainnetGuardianProver.sol +++ b/packages/protocol/contracts/layer1/mainnet/rollup/MainnetGuardianProver.sol @@ -1,16 +1,25 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; -import "../../L1/provers/GuardianProver.sol"; +import "../../../layer1/provers/GuardianProver.sol"; import "../addrcache/RollupAddressCache.sol"; - +import "../reentrylock/LibFasterReentryLock.sol"; /// @title MainnetGuardianProver /// @dev This contract shall be deployed to replace its parent contract on Ethereum for Taiko /// mainnet to reduce gas cost. /// @notice See the documentation in {GuardianProver}. /// @custom:security-contact security@taiko.xyz + contract MainnetGuardianProver is GuardianProver, RollupAddressCache { function _getAddress(uint64 _chainId, bytes32 _name) internal view override returns (address) { return getAddress(_chainId, _name, super._getAddress); } + + function _storeReentryLock(uint8 _reentry) internal override { + LibFasterReentryLock.storeReentryLock(_reentry); + } + + function _loadReentryLock() internal view override returns (uint8) { + return LibFasterReentryLock.loadReentryLock(); + } } diff --git a/packages/protocol/contracts/mainnet/rollup/MainnetProverSet.sol b/packages/protocol/contracts/layer1/mainnet/rollup/MainnetProverSet.sol similarity index 63% rename from packages/protocol/contracts/mainnet/rollup/MainnetProverSet.sol rename to packages/protocol/contracts/layer1/mainnet/rollup/MainnetProverSet.sol index 51a7cb35f02..b6c06184c02 100644 --- a/packages/protocol/contracts/mainnet/rollup/MainnetProverSet.sol +++ b/packages/protocol/contracts/layer1/mainnet/rollup/MainnetProverSet.sol @@ -1,8 +1,9 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; -import "../../team/proving/ProverSet.sol"; +import "../../provers/ProverSet.sol"; import "../addrcache/RollupAddressCache.sol"; +import "../reentrylock/LibFasterReentryLock.sol"; /// @title MainnetProverSet /// @dev This contract shall be deployed to replace its parent contract on Ethereum for Taiko @@ -14,4 +15,12 @@ contract MainnetProverSet is ProverSet, RollupAddressCache { function _getAddress(uint64 _chainId, bytes32 _name) internal view override returns (address) { return getAddress(_chainId, _name, super._getAddress); } + + function _storeReentryLock(uint8 _reentry) internal override { + LibFasterReentryLock.storeReentryLock(_reentry); + } + + function _loadReentryLock() internal view override returns (uint8) { + return LibFasterReentryLock.loadReentryLock(); + } } diff --git a/packages/protocol/contracts/mainnet/rollup/MainnetRollupAddressManager.sol b/packages/protocol/contracts/layer1/mainnet/rollup/MainnetRollupAddressManager.sol similarity index 57% rename from packages/protocol/contracts/mainnet/rollup/MainnetRollupAddressManager.sol rename to packages/protocol/contracts/layer1/mainnet/rollup/MainnetRollupAddressManager.sol index 7d193a61c39..1a09738d144 100644 --- a/packages/protocol/contracts/mainnet/rollup/MainnetRollupAddressManager.sol +++ b/packages/protocol/contracts/layer1/mainnet/rollup/MainnetRollupAddressManager.sol @@ -1,9 +1,10 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; -import "../../common/AddressManager.sol"; -import "../../common/LibStrings.sol"; +import "../../../shared/common/AddressManager.sol"; +import "../../../shared/common/LibStrings.sol"; import "../addrcache/RollupAddressCache.sol"; +import "../reentrylock/LibFasterReentryLock.sol"; /// @title MainnetRollupAddressManager /// @dev This contract shall be deployed to replace its parent contract on Ethereum for Taiko @@ -14,4 +15,12 @@ contract MainnetRollupAddressManager is AddressManager, RollupAddressCache { function _getAddress(uint64 _chainId, bytes32 _name) internal view override returns (address) { return getAddress(_chainId, _name, super._getAddress); } + + function _storeReentryLock(uint8 _reentry) internal override { + LibFasterReentryLock.storeReentryLock(_reentry); + } + + function _loadReentryLock() internal view override returns (uint8) { + return LibFasterReentryLock.loadReentryLock(); + } } diff --git a/packages/protocol/contracts/mainnet/rollup/MainnetTaikoL1.sol b/packages/protocol/contracts/layer1/mainnet/rollup/MainnetTaikoL1.sol similarity index 82% rename from packages/protocol/contracts/mainnet/rollup/MainnetTaikoL1.sol rename to packages/protocol/contracts/layer1/mainnet/rollup/MainnetTaikoL1.sol index 4ab964d883c..02eade089df 100644 --- a/packages/protocol/contracts/mainnet/rollup/MainnetTaikoL1.sol +++ b/packages/protocol/contracts/layer1/mainnet/rollup/MainnetTaikoL1.sol @@ -1,8 +1,9 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; -import "../../L1/TaikoL1.sol"; +import "../../based/TaikoL1.sol"; import "../addrcache/RollupAddressCache.sol"; +import "../reentrylock/LibFasterReentryLock.sol"; /// @title MainnetTaikoL1 /// @dev This contract shall be deployed to replace its parent contract on Ethereum for Taiko @@ -30,7 +31,7 @@ contract MainnetTaikoL1 is TaikoL1, RollupAddressCache { livenessBond: 125e18, // 125 Taiko token stateRootSyncInternal: 16, maxAnchorHeightOffset: 64, - baseFeeConfig: TaikoData.BaseFeeConfig({ + baseFeeConfig: LibSharedData.BaseFeeConfig({ adjustmentQuotient: 8, sharingPctg: 75, gasIssuancePerSecond: 5_000_000, @@ -44,4 +45,12 @@ contract MainnetTaikoL1 is TaikoL1, RollupAddressCache { function _getAddress(uint64 _chainId, bytes32 _name) internal view override returns (address) { return getAddress(_chainId, _name, super._getAddress); } + + function _storeReentryLock(uint8 _reentry) internal override { + LibFasterReentryLock.storeReentryLock(_reentry); + } + + function _loadReentryLock() internal view override returns (uint8) { + return LibFasterReentryLock.loadReentryLock(); + } } diff --git a/packages/protocol/contracts/mainnet/rollup/MainnetTierRouter.sol b/packages/protocol/contracts/layer1/mainnet/rollup/MainnetTierRouter.sol similarity index 85% rename from packages/protocol/contracts/mainnet/rollup/MainnetTierRouter.sol rename to packages/protocol/contracts/layer1/mainnet/rollup/MainnetTierRouter.sol index 89365dfb606..f5ec759520b 100644 --- a/packages/protocol/contracts/mainnet/rollup/MainnetTierRouter.sol +++ b/packages/protocol/contracts/layer1/mainnet/rollup/MainnetTierRouter.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; -import "../../L1/tiers/ITierRouter.sol"; +import "../../tiers/ITierRouter.sol"; /// @title MainnetTierRouter /// @dev Labeled in AddressResolver as "tier_router" diff --git a/packages/protocol/contracts/mainnet/rollup/verifiers/MainnetRisc0Verifier.sol b/packages/protocol/contracts/layer1/mainnet/rollup/verifiers/MainnetRisc0Verifier.sol similarity index 65% rename from packages/protocol/contracts/mainnet/rollup/verifiers/MainnetRisc0Verifier.sol rename to packages/protocol/contracts/layer1/mainnet/rollup/verifiers/MainnetRisc0Verifier.sol index 5a758ef0e8a..480e6912140 100644 --- a/packages/protocol/contracts/mainnet/rollup/verifiers/MainnetRisc0Verifier.sol +++ b/packages/protocol/contracts/layer1/mainnet/rollup/verifiers/MainnetRisc0Verifier.sol @@ -1,8 +1,9 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "../../../verifiers/Risc0Verifier.sol"; import "../../addrcache/RollupAddressCache.sol"; +import "../../reentrylock/LibFasterReentryLock.sol"; /// @title MainnetRisc0Verifier /// @dev This contract shall be deployed to replace its parent contract on Ethereum for Taiko @@ -14,7 +15,11 @@ contract MainnetRisc0Verifier is Risc0Verifier, RollupAddressCache { return getAddress(_chainId, _name, super._getAddress); } - function taikoChainId() internal pure override returns (uint64) { - return LibNetwork.TAIKO_MAINNET; + function _storeReentryLock(uint8 _reentry) internal override { + LibFasterReentryLock.storeReentryLock(_reentry); + } + + function _loadReentryLock() internal view override returns (uint8) { + return LibFasterReentryLock.loadReentryLock(); } } diff --git a/packages/protocol/contracts/mainnet/rollup/verifiers/MainnetSP1Verifier.sol b/packages/protocol/contracts/layer1/mainnet/rollup/verifiers/MainnetSP1Verifier.sol similarity index 68% rename from packages/protocol/contracts/mainnet/rollup/verifiers/MainnetSP1Verifier.sol rename to packages/protocol/contracts/layer1/mainnet/rollup/verifiers/MainnetSP1Verifier.sol index 7e327319490..e9cc9230a1b 100644 --- a/packages/protocol/contracts/mainnet/rollup/verifiers/MainnetSP1Verifier.sol +++ b/packages/protocol/contracts/layer1/mainnet/rollup/verifiers/MainnetSP1Verifier.sol @@ -1,8 +1,9 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "../../../verifiers/SP1Verifier.sol"; import "../../addrcache/RollupAddressCache.sol"; +import "../../reentrylock/LibFasterReentryLock.sol"; /// @title MainnetSP1Verifier /// @dev This contract shall be deployed to replace its parent contract on Ethereum for Taiko @@ -14,6 +15,14 @@ contract MainnetSP1Verifier is SP1Verifier, RollupAddressCache { return getAddress(_chainId, _name, super._getAddress); } + function _storeReentryLock(uint8 _reentry) internal override { + LibFasterReentryLock.storeReentryLock(_reentry); + } + + function _loadReentryLock() internal view override returns (uint8) { + return LibFasterReentryLock.loadReentryLock(); + } + function taikoChainId() internal pure override returns (uint64) { return LibNetwork.TAIKO_MAINNET; } diff --git a/packages/protocol/contracts/mainnet/rollup/verifiers/MainnetSgxVerifier.sol b/packages/protocol/contracts/layer1/mainnet/rollup/verifiers/MainnetSgxVerifier.sol similarity index 65% rename from packages/protocol/contracts/mainnet/rollup/verifiers/MainnetSgxVerifier.sol rename to packages/protocol/contracts/layer1/mainnet/rollup/verifiers/MainnetSgxVerifier.sol index 1fd01b89399..c4583e58c96 100644 --- a/packages/protocol/contracts/mainnet/rollup/verifiers/MainnetSgxVerifier.sol +++ b/packages/protocol/contracts/layer1/mainnet/rollup/verifiers/MainnetSgxVerifier.sol @@ -1,8 +1,9 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "../../../verifiers/SgxVerifier.sol"; import "../../addrcache/RollupAddressCache.sol"; +import "../../reentrylock/LibFasterReentryLock.sol"; /// @title MainnetSgxVerifier /// @dev This contract shall be deployed to replace its parent contract on Ethereum for Taiko @@ -14,7 +15,11 @@ contract MainnetSgxVerifier is SgxVerifier, RollupAddressCache { return getAddress(_chainId, _name, super._getAddress); } - function taikoChainId() internal pure override returns (uint64) { - return LibNetwork.TAIKO_MAINNET; + function _storeReentryLock(uint8 _reentry) internal override { + LibFasterReentryLock.storeReentryLock(_reentry); + } + + function _loadReentryLock() internal view override returns (uint8) { + return LibFasterReentryLock.loadReentryLock(); } } diff --git a/packages/protocol/contracts/mainnet/rollup/verifiers/MainnetTeeAnyVerifier.sol b/packages/protocol/contracts/layer1/mainnet/rollup/verifiers/MainnetTeeAnyVerifier.sol similarity index 63% rename from packages/protocol/contracts/mainnet/rollup/verifiers/MainnetTeeAnyVerifier.sol rename to packages/protocol/contracts/layer1/mainnet/rollup/verifiers/MainnetTeeAnyVerifier.sol index 3f558d12600..28599c0a5d3 100644 --- a/packages/protocol/contracts/mainnet/rollup/verifiers/MainnetTeeAnyVerifier.sol +++ b/packages/protocol/contracts/layer1/mainnet/rollup/verifiers/MainnetTeeAnyVerifier.sol @@ -1,8 +1,9 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "../../../verifiers/compose/TeeAnyVerifier.sol"; import "../../addrcache/RollupAddressCache.sol"; +import "../../reentrylock/LibFasterReentryLock.sol"; /// @title MainnetTeeAnyVerifier /// @dev This contract shall be deployed to replace its parent contract on Ethereum for Taiko @@ -12,4 +13,12 @@ contract MainnetTeeAnyVerifier is TeeAnyVerifier, RollupAddressCache { function _getAddress(uint64 _chainId, bytes32 _name) internal view override returns (address) { return getAddress(_chainId, _name, super._getAddress); } + + function _storeReentryLock(uint8 _reentry) internal override { + LibFasterReentryLock.storeReentryLock(_reentry); + } + + function _loadReentryLock() internal view override returns (uint8) { + return LibFasterReentryLock.loadReentryLock(); + } } diff --git a/packages/protocol/contracts/mainnet/rollup/verifiers/MainnetZkAndTeeVerifier.sol b/packages/protocol/contracts/layer1/mainnet/rollup/verifiers/MainnetZkAndTeeVerifier.sol similarity index 63% rename from packages/protocol/contracts/mainnet/rollup/verifiers/MainnetZkAndTeeVerifier.sol rename to packages/protocol/contracts/layer1/mainnet/rollup/verifiers/MainnetZkAndTeeVerifier.sol index 5155cf0851d..67e58d8af1e 100644 --- a/packages/protocol/contracts/mainnet/rollup/verifiers/MainnetZkAndTeeVerifier.sol +++ b/packages/protocol/contracts/layer1/mainnet/rollup/verifiers/MainnetZkAndTeeVerifier.sol @@ -1,8 +1,9 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "../../../verifiers/compose/ZkAndTeeVerifier.sol"; import "../../addrcache/RollupAddressCache.sol"; +import "../../reentrylock/LibFasterReentryLock.sol"; /// @title MainnetZkAndTeeVerifier /// @dev This contract shall be deployed to replace its parent contract on Ethereum for Taiko @@ -12,4 +13,12 @@ contract MainnetZkAndTeeVerifier is ZkAndTeeVerifier, RollupAddressCache { function _getAddress(uint64 _chainId, bytes32 _name) internal view override returns (address) { return getAddress(_chainId, _name, super._getAddress); } + + function _storeReentryLock(uint8 _reentry) internal override { + LibFasterReentryLock.storeReentryLock(_reentry); + } + + function _loadReentryLock() internal view override returns (uint8) { + return LibFasterReentryLock.loadReentryLock(); + } } diff --git a/packages/protocol/contracts/mainnet/rollup/verifiers/MainnetZkAnyVerifier.sol b/packages/protocol/contracts/layer1/mainnet/rollup/verifiers/MainnetZkAnyVerifier.sol similarity index 62% rename from packages/protocol/contracts/mainnet/rollup/verifiers/MainnetZkAnyVerifier.sol rename to packages/protocol/contracts/layer1/mainnet/rollup/verifiers/MainnetZkAnyVerifier.sol index 97f19faa7b3..8ac59cd0378 100644 --- a/packages/protocol/contracts/mainnet/rollup/verifiers/MainnetZkAnyVerifier.sol +++ b/packages/protocol/contracts/layer1/mainnet/rollup/verifiers/MainnetZkAnyVerifier.sol @@ -1,8 +1,9 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "../../../verifiers/compose/ZkAnyVerifier.sol"; import "../../addrcache/RollupAddressCache.sol"; +import "../../reentrylock/LibFasterReentryLock.sol"; /// @title MainnetZkAnyVerifier /// @dev This contract shall be deployed to replace its parent contract on Ethereum for Taiko @@ -12,4 +13,12 @@ contract MainnetZkAnyVerifier is ZkAnyVerifier, RollupAddressCache { function _getAddress(uint64 _chainId, bytes32 _name) internal view override returns (address) { return getAddress(_chainId, _name, super._getAddress); } + + function _storeReentryLock(uint8 _reentry) internal override { + LibFasterReentryLock.storeReentryLock(_reentry); + } + + function _loadReentryLock() internal view override returns (uint8) { + return LibFasterReentryLock.loadReentryLock(); + } } diff --git a/packages/protocol/contracts/L1/provers/GuardianProver.sol b/packages/protocol/contracts/layer1/provers/GuardianProver.sol similarity index 98% rename from packages/protocol/contracts/L1/provers/GuardianProver.sol rename to packages/protocol/contracts/layer1/provers/GuardianProver.sol index 747be2f498b..aa21dd9b294 100644 --- a/packages/protocol/contracts/L1/provers/GuardianProver.sol +++ b/packages/protocol/contracts/layer1/provers/GuardianProver.sol @@ -1,12 +1,12 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; -import "../../common/EssentialContract.sol"; -import "../../common/LibStrings.sol"; -import "../../verifiers/IVerifier.sol"; -import "../ITaikoL1.sol"; +import "../../shared/common/EssentialContract.sol"; +import "../../shared/common/LibStrings.sol"; +import "../verifiers/IVerifier.sol"; +import "../based/ITaikoL1.sol"; /// @title GuardianProver /// This prover uses itself as the verifier. diff --git a/packages/protocol/contracts/team/proving/ProverSet.sol b/packages/protocol/contracts/layer1/provers/ProverSet.sol similarity index 96% rename from packages/protocol/contracts/team/proving/ProverSet.sol rename to packages/protocol/contracts/layer1/provers/ProverSet.sol index 3806895007b..7c642037598 100644 --- a/packages/protocol/contracts/team/proving/ProverSet.sol +++ b/packages/protocol/contracts/layer1/provers/ProverSet.sol @@ -1,14 +1,14 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20VotesUpgradeable.sol"; import "@openzeppelin/contracts/interfaces/IERC1271.sol"; import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; -import "../../common/EssentialContract.sol"; -import "../../common/LibStrings.sol"; -import "../../libs/LibAddress.sol"; -import "../../L1/ITaikoL1.sol"; +import "../../shared/common/EssentialContract.sol"; +import "../../shared/common/LibStrings.sol"; +import "../../shared/common/LibAddress.sol"; +import "../based/ITaikoL1.sol"; interface IHasRecipient { function recipient() external view returns (address); diff --git a/packages/protocol/contracts/team/airdrop/ERC20Airdrop.sol b/packages/protocol/contracts/layer1/team/airdrop/ERC20Airdrop.sol similarity index 98% rename from packages/protocol/contracts/team/airdrop/ERC20Airdrop.sol rename to packages/protocol/contracts/layer1/team/airdrop/ERC20Airdrop.sol index 9867f983300..469a0618e51 100644 --- a/packages/protocol/contracts/team/airdrop/ERC20Airdrop.sol +++ b/packages/protocol/contracts/layer1/team/airdrop/ERC20Airdrop.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; diff --git a/packages/protocol/contracts/team/airdrop/MerkleClaimable.sol b/packages/protocol/contracts/layer1/team/airdrop/MerkleClaimable.sol similarity index 97% rename from packages/protocol/contracts/team/airdrop/MerkleClaimable.sol rename to packages/protocol/contracts/layer1/team/airdrop/MerkleClaimable.sol index 63fe1f9a3dc..f3c945446aa 100644 --- a/packages/protocol/contracts/team/airdrop/MerkleClaimable.sol +++ b/packages/protocol/contracts/layer1/team/airdrop/MerkleClaimable.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol"; -import "../../common/EssentialContract.sol"; +import "../../../shared/common/EssentialContract.sol"; /// @title MerkleClaimable /// @notice Contract for managing Taiko token airdrop for eligible users diff --git a/packages/protocol/contracts/team/tokenunlock/TokenUnlock.sol b/packages/protocol/contracts/layer1/team/tokenunlock/TokenUnlock.sol similarity index 97% rename from packages/protocol/contracts/team/tokenunlock/TokenUnlock.sol rename to packages/protocol/contracts/layer1/team/tokenunlock/TokenUnlock.sol index f7f764049d1..8b1250d49ac 100644 --- a/packages/protocol/contracts/team/tokenunlock/TokenUnlock.sol +++ b/packages/protocol/contracts/layer1/team/tokenunlock/TokenUnlock.sol @@ -1,15 +1,15 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "@openzeppelin/contracts-upgradeable/utils/introspection/IERC165Upgradeable.sol"; import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; -import "../../common/EssentialContract.sol"; -import "../../common/LibStrings.sol"; -import "../../libs/LibMath.sol"; -import "../proving/ProverSet.sol"; +import "../../../shared/common/EssentialContract.sol"; +import "../../../shared/common/LibStrings.sol"; +import "../../../shared/common/LibMath.sol"; +import "../../provers/ProverSet.sol"; /// @title TokenUnlock /// @notice Manages the linear unlocking of Taiko tokens over a four-year period. diff --git a/packages/protocol/contracts/L1/tiers/ITierProvider.sol b/packages/protocol/contracts/layer1/tiers/ITierProvider.sol similarity index 98% rename from packages/protocol/contracts/L1/tiers/ITierProvider.sol rename to packages/protocol/contracts/layer1/tiers/ITierProvider.sol index a49976e24ce..1e74dbcf25d 100644 --- a/packages/protocol/contracts/L1/tiers/ITierProvider.sol +++ b/packages/protocol/contracts/layer1/tiers/ITierProvider.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; /// @title ITierProvider /// @notice Defines interface to return tier configuration. diff --git a/packages/protocol/contracts/L1/tiers/ITierRouter.sol b/packages/protocol/contracts/layer1/tiers/ITierRouter.sol similarity index 94% rename from packages/protocol/contracts/L1/tiers/ITierRouter.sol rename to packages/protocol/contracts/layer1/tiers/ITierRouter.sol index 409e45f126b..3b8863a021a 100644 --- a/packages/protocol/contracts/L1/tiers/ITierRouter.sol +++ b/packages/protocol/contracts/layer1/tiers/ITierRouter.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; /// @title ITierRouter /// @notice Defines interface to return an ITierProvider diff --git a/packages/protocol/contracts/L1/tiers/LibTiers.sol b/packages/protocol/contracts/layer1/tiers/LibTiers.sol similarity index 97% rename from packages/protocol/contracts/L1/tiers/LibTiers.sol rename to packages/protocol/contracts/layer1/tiers/LibTiers.sol index fc46e37765d..fd70d7eaf04 100644 --- a/packages/protocol/contracts/L1/tiers/LibTiers.sol +++ b/packages/protocol/contracts/layer1/tiers/LibTiers.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; /// @title LibTiers /// @dev Tier ID cannot be zero and must be unique. diff --git a/packages/protocol/contracts/L1/tiers/TierProviderBase.sol b/packages/protocol/contracts/layer1/tiers/TierProviderBase.sol similarity index 98% rename from packages/protocol/contracts/L1/tiers/TierProviderBase.sol rename to packages/protocol/contracts/layer1/tiers/TierProviderBase.sol index 95d9c207a1f..c6d4f6baa32 100644 --- a/packages/protocol/contracts/L1/tiers/TierProviderBase.sol +++ b/packages/protocol/contracts/layer1/tiers/TierProviderBase.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; -import "../../common/LibStrings.sol"; +import "../../shared/common/LibStrings.sol"; import "./ITierProvider.sol"; import "./LibTiers.sol"; diff --git a/packages/protocol/contracts/L1/tiers/TierProviderV2.sol b/packages/protocol/contracts/layer1/tiers/TierProviderV2.sol similarity index 96% rename from packages/protocol/contracts/L1/tiers/TierProviderV2.sol rename to packages/protocol/contracts/layer1/tiers/TierProviderV2.sol index 9bb113f1c57..69f1541bf14 100644 --- a/packages/protocol/contracts/L1/tiers/TierProviderV2.sol +++ b/packages/protocol/contracts/layer1/tiers/TierProviderV2.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "./TierProviderBase.sol"; diff --git a/packages/protocol/contracts/tko/TaikoToken.sol b/packages/protocol/contracts/layer1/token/TaikoToken.sol similarity index 96% rename from packages/protocol/contracts/tko/TaikoToken.sol rename to packages/protocol/contracts/layer1/token/TaikoToken.sol index 27b1cb97532..3804f7714d5 100644 --- a/packages/protocol/contracts/tko/TaikoToken.sol +++ b/packages/protocol/contracts/layer1/token/TaikoToken.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; -import "./TaikoTokenBase.sol"; +import "../../shared/token/TaikoTokenBase.sol"; /// @title TaikoToken /// @notice The TaikoToken (TKO), in the protocol is used for prover collateral diff --git a/packages/protocol/contracts/verifiers/IVerifier.sol b/packages/protocol/contracts/layer1/verifiers/IVerifier.sol similarity index 95% rename from packages/protocol/contracts/verifiers/IVerifier.sol rename to packages/protocol/contracts/layer1/verifiers/IVerifier.sol index c16b42b46cf..ae9e91cbfe7 100644 --- a/packages/protocol/contracts/verifiers/IVerifier.sol +++ b/packages/protocol/contracts/layer1/verifiers/IVerifier.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; -import "../L1/TaikoData.sol"; +import "../based/TaikoData.sol"; /// @title IVerifier /// @notice Defines the function that handles proof verification. diff --git a/packages/protocol/contracts/verifiers/libs/LibPublicInput.sol b/packages/protocol/contracts/layer1/verifiers/LibPublicInput.sol similarity index 94% rename from packages/protocol/contracts/verifiers/libs/LibPublicInput.sol rename to packages/protocol/contracts/layer1/verifiers/LibPublicInput.sol index ae1c1e638f0..d85205fd53f 100644 --- a/packages/protocol/contracts/verifiers/libs/LibPublicInput.sol +++ b/packages/protocol/contracts/layer1/verifiers/LibPublicInput.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; -import "../../L1/TaikoData.sol"; +import "../../layer1/based/TaikoData.sol"; /// @title LibPublicInput /// @notice A library for handling hashing the so-called public input hash, used by sgx and zk diff --git a/packages/protocol/contracts/verifiers/Risc0Verifier.sol b/packages/protocol/contracts/layer1/verifiers/Risc0Verifier.sol similarity index 94% rename from packages/protocol/contracts/verifiers/Risc0Verifier.sol rename to packages/protocol/contracts/layer1/verifiers/Risc0Verifier.sol index 661a8fcc08a..dcbac258239 100644 --- a/packages/protocol/contracts/verifiers/Risc0Verifier.sol +++ b/packages/protocol/contracts/layer1/verifiers/Risc0Verifier.sol @@ -1,12 +1,12 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "@risc0/contracts/IRiscZeroVerifier.sol"; -import "../common/EssentialContract.sol"; -import "../common/LibStrings.sol"; -import "../L1/ITaikoL1.sol"; +import "../../shared/common/EssentialContract.sol"; +import "../../shared/common/LibStrings.sol"; +import "../based/ITaikoL1.sol"; +import "./LibPublicInput.sol"; import "./IVerifier.sol"; -import "./libs/LibPublicInput.sol"; /// @title Risc0Verifier /// @custom:security-contact security@taiko.xyz diff --git a/packages/protocol/contracts/verifiers/SP1Verifier.sol b/packages/protocol/contracts/layer1/verifiers/SP1Verifier.sol similarity index 94% rename from packages/protocol/contracts/verifiers/SP1Verifier.sol rename to packages/protocol/contracts/layer1/verifiers/SP1Verifier.sol index 03ee335feb1..8fe4e3ec713 100644 --- a/packages/protocol/contracts/verifiers/SP1Verifier.sol +++ b/packages/protocol/contracts/layer1/verifiers/SP1Verifier.sol @@ -1,12 +1,12 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "@sp1-contracts/src/ISP1Verifier.sol"; -import "../common/EssentialContract.sol"; -import "../common/LibStrings.sol"; -import "../L1/ITaikoL1.sol"; +import "../../shared/common/EssentialContract.sol"; +import "../../shared/common/LibStrings.sol"; +import "../based/ITaikoL1.sol"; +import "./LibPublicInput.sol"; import "./IVerifier.sol"; -import "./libs/LibPublicInput.sol"; /// @title SP1Verifier /// @custom:security-contact security@taiko.xyz diff --git a/packages/protocol/contracts/verifiers/SgxVerifier.sol b/packages/protocol/contracts/layer1/verifiers/SgxVerifier.sol similarity index 97% rename from packages/protocol/contracts/verifiers/SgxVerifier.sol rename to packages/protocol/contracts/layer1/verifiers/SgxVerifier.sol index bc2e5ea2baa..4a562d94b82 100644 --- a/packages/protocol/contracts/verifiers/SgxVerifier.sol +++ b/packages/protocol/contracts/layer1/verifiers/SgxVerifier.sol @@ -1,13 +1,14 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; -import "../L1/ITaikoL1.sol"; -import "../common/EssentialContract.sol"; -import "../common/LibStrings.sol"; +import "../../shared/common/EssentialContract.sol"; +import "../../shared/common/LibStrings.sol"; import "../automata-attestation/interfaces/IAttestation.sol"; import "../automata-attestation/lib/QuoteV3Auth/V3Struct.sol"; -import "./libs/LibPublicInput.sol"; +import "../based/ITaikoL1.sol"; +import "../based/TaikoData.sol"; +import "./LibPublicInput.sol"; import "./IVerifier.sol"; /// @title SgxVerifier diff --git a/packages/protocol/contracts/verifiers/compose/ComposeVerifier.sol b/packages/protocol/contracts/layer1/verifiers/compose/ComposeVerifier.sol similarity index 97% rename from packages/protocol/contracts/verifiers/compose/ComposeVerifier.sol rename to packages/protocol/contracts/layer1/verifiers/compose/ComposeVerifier.sol index b3f9a2ac92a..d9d59786a50 100644 --- a/packages/protocol/contracts/verifiers/compose/ComposeVerifier.sol +++ b/packages/protocol/contracts/layer1/verifiers/compose/ComposeVerifier.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; -import "../../common/EssentialContract.sol"; -import "../../common/LibStrings.sol"; +import "../../../shared/common/EssentialContract.sol"; +import "../../../shared/common/LibStrings.sol"; import "../IVerifier.sol"; /// @title ComposeVerifier diff --git a/packages/protocol/contracts/verifiers/compose/TeeAnyVerifier.sol b/packages/protocol/contracts/layer1/verifiers/compose/TeeAnyVerifier.sol similarity index 92% rename from packages/protocol/contracts/verifiers/compose/TeeAnyVerifier.sol rename to packages/protocol/contracts/layer1/verifiers/compose/TeeAnyVerifier.sol index a77c8674841..97eaac7e29a 100644 --- a/packages/protocol/contracts/verifiers/compose/TeeAnyVerifier.sol +++ b/packages/protocol/contracts/layer1/verifiers/compose/TeeAnyVerifier.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; -import "../../common/LibStrings.sol"; +import "../../../shared/common/LibStrings.sol"; import "./ComposeVerifier.sol"; /// @title TeeAnyVerifier diff --git a/packages/protocol/contracts/verifiers/compose/ZkAndTeeVerifier.sol b/packages/protocol/contracts/layer1/verifiers/compose/ZkAndTeeVerifier.sol similarity index 89% rename from packages/protocol/contracts/verifiers/compose/ZkAndTeeVerifier.sol rename to packages/protocol/contracts/layer1/verifiers/compose/ZkAndTeeVerifier.sol index 575a1775527..51a22785e3c 100644 --- a/packages/protocol/contracts/verifiers/compose/ZkAndTeeVerifier.sol +++ b/packages/protocol/contracts/layer1/verifiers/compose/ZkAndTeeVerifier.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; -import "../../common/LibStrings.sol"; +import "../../../shared/common/LibStrings.sol"; import "./ComposeVerifier.sol"; /// @title ZkAndTeeVerifier diff --git a/packages/protocol/contracts/verifiers/compose/ZkAnyVerifier.sol b/packages/protocol/contracts/layer1/verifiers/compose/ZkAnyVerifier.sol similarity index 92% rename from packages/protocol/contracts/verifiers/compose/ZkAnyVerifier.sol rename to packages/protocol/contracts/layer1/verifiers/compose/ZkAnyVerifier.sol index 25f20612cd2..261e4d2c2e0 100644 --- a/packages/protocol/contracts/verifiers/compose/ZkAnyVerifier.sol +++ b/packages/protocol/contracts/layer1/verifiers/compose/ZkAnyVerifier.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; -import "../../common/LibStrings.sol"; +import "../../../shared/common/LibStrings.sol"; import "./ComposeVerifier.sol"; /// @title ZkAnyVerifier diff --git a/packages/protocol/contracts/L2/DelegateOwner.sol b/packages/protocol/contracts/layer2/DelegateOwner.sol similarity index 95% rename from packages/protocol/contracts/L2/DelegateOwner.sol rename to packages/protocol/contracts/layer2/DelegateOwner.sol index 745589f036b..182e24d533a 100644 --- a/packages/protocol/contracts/L2/DelegateOwner.sol +++ b/packages/protocol/contracts/layer2/DelegateOwner.sol @@ -1,11 +1,11 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; -import "../common/EssentialContract.sol"; -import "../common/LibStrings.sol"; -import "../libs/LibAddress.sol"; -import "../libs/LibBytes.sol"; -import "../bridge/IBridge.sol"; +import "../shared/common/EssentialContract.sol"; +import "../shared/common/LibStrings.sol"; +import "../shared/common/LibAddress.sol"; +import "../shared/common/LibBytes.sol"; +import "../shared/bridge/IBridge.sol"; /// @title DelegateOwner /// @notice This contract will be the owner of all essential contracts deployed on the L2 chain. diff --git a/packages/protocol/contracts/L2/IBlockHash.sol b/packages/protocol/contracts/layer2/based/IBlockHash.sol similarity index 94% rename from packages/protocol/contracts/L2/IBlockHash.sol rename to packages/protocol/contracts/layer2/based/IBlockHash.sol index c1979a2900a..21f57452034 100644 --- a/packages/protocol/contracts/L2/IBlockHash.sol +++ b/packages/protocol/contracts/layer2/based/IBlockHash.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; /// @title IBlockHash /// @notice Interface for retrieving block hashes. diff --git a/packages/protocol/contracts/L2/Lib1559Math.sol b/packages/protocol/contracts/layer2/based/Lib1559Math.sol similarity index 98% rename from packages/protocol/contracts/L2/Lib1559Math.sol rename to packages/protocol/contracts/layer2/based/Lib1559Math.sol index 533a3cdd18e..c0e0116b1e2 100644 --- a/packages/protocol/contracts/L2/Lib1559Math.sol +++ b/packages/protocol/contracts/layer2/based/Lib1559Math.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "@solady/src/utils/FixedPointMathLib.sol"; -import "../libs/LibMath.sol"; +import "../../shared/common/LibMath.sol"; /// @title Lib1559Math /// @notice Implements e^(x) based bonding curve for EIP-1559 diff --git a/packages/protocol/contracts/L2/LibL2Config.sol b/packages/protocol/contracts/layer2/based/LibL2Config.sol similarity index 96% rename from packages/protocol/contracts/L2/LibL2Config.sol rename to packages/protocol/contracts/layer2/based/LibL2Config.sol index 3278656b1ea..e4ad74e2cc9 100644 --- a/packages/protocol/contracts/L2/LibL2Config.sol +++ b/packages/protocol/contracts/layer2/based/LibL2Config.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; /// @title LibL2Config library LibL2Config { diff --git a/packages/protocol/contracts/L2/TaikoL2.sol b/packages/protocol/contracts/layer2/based/TaikoL2.sol similarity index 97% rename from packages/protocol/contracts/L2/TaikoL2.sol rename to packages/protocol/contracts/layer2/based/TaikoL2.sol index dd8d33741e0..8740b50a1b5 100644 --- a/packages/protocol/contracts/L2/TaikoL2.sol +++ b/packages/protocol/contracts/layer2/based/TaikoL2.sol @@ -1,14 +1,14 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; -import { TaikoData } from "../L1/TaikoData.sol"; -import "../common/EssentialContract.sol"; -import "../common/LibStrings.sol"; -import "../libs/LibAddress.sol"; -import "../signal/ISignalService.sol"; +import "../../shared/data/LibSharedData.sol"; +import "../../shared/common/EssentialContract.sol"; +import "../../shared/common/LibStrings.sol"; +import "../../shared/common/LibAddress.sol"; +import "../../shared/signal/ISignalService.sol"; import "./Lib1559Math.sol"; import "./LibL2Config.sol"; import "./IBlockHash.sol"; @@ -164,7 +164,7 @@ contract TaikoL2 is EssentialContract, IBlockHash { uint64 _anchorBlockId, bytes32 _anchorStateRoot, uint32 _parentGasUsed, - TaikoData.BaseFeeConfig calldata _baseFeeConfig + LibSharedData.BaseFeeConfig calldata _baseFeeConfig ) external nonZeroValue(uint256(_anchorStateRoot)) @@ -326,7 +326,7 @@ contract TaikoL2 is EssentialContract, IBlockHash { /// @return basefee_ Next block's base fee. /// @return parentGasExcess_ The new gas excess value. function calculateBaseFee( - TaikoData.BaseFeeConfig calldata _baseFeeConfig, + LibSharedData.BaseFeeConfig calldata _baseFeeConfig, uint64 _blocktime, uint64 _parentGasExcess, uint32 _parentGasUsed diff --git a/packages/protocol/contracts/devnet/DevnetTaikoL2.sol b/packages/protocol/contracts/layer2/devnet/DevnetTaikoL2.sol similarity index 81% rename from packages/protocol/contracts/devnet/DevnetTaikoL2.sol rename to packages/protocol/contracts/layer2/devnet/DevnetTaikoL2.sol index 78c721d3ebc..bf3328a15cb 100644 --- a/packages/protocol/contracts/devnet/DevnetTaikoL2.sol +++ b/packages/protocol/contracts/layer2/devnet/DevnetTaikoL2.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; -import "../L2/TaikoL2.sol"; +import "../based/TaikoL2.sol"; /// @title DevnetTaikoL2 /// @custom:security-contact security@taiko.xyz diff --git a/packages/protocol/contracts/hekla/HeklaTaikoL2.sol b/packages/protocol/contracts/layer2/hekla/HeklaTaikoL2.sol similarity index 81% rename from packages/protocol/contracts/hekla/HeklaTaikoL2.sol rename to packages/protocol/contracts/layer2/hekla/HeklaTaikoL2.sol index bb1772d69aa..f1af6519eb4 100644 --- a/packages/protocol/contracts/hekla/HeklaTaikoL2.sol +++ b/packages/protocol/contracts/layer2/hekla/HeklaTaikoL2.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; -import "../L2/TaikoL2.sol"; +import "../based/TaikoL2.sol"; /// @title HeklaTaikoL2 /// @custom:security-contact security@taiko.xyz diff --git a/packages/protocol/contracts/mainnet/rollup/MainnetTaikoL2.sol b/packages/protocol/contracts/layer2/mainnet/MainnetTaikoL2.sol similarity index 82% rename from packages/protocol/contracts/mainnet/rollup/MainnetTaikoL2.sol rename to packages/protocol/contracts/layer2/mainnet/MainnetTaikoL2.sol index 0d19dbeb5f3..f7769413cb6 100644 --- a/packages/protocol/contracts/mainnet/rollup/MainnetTaikoL2.sol +++ b/packages/protocol/contracts/layer2/mainnet/MainnetTaikoL2.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; -import "../../L2/TaikoL2.sol"; +import "../based/TaikoL2.sol"; /// @title MainnetTaikoL2 /// @custom:security-contact security@taiko.xyz diff --git a/packages/protocol/contracts/tko/BridgedTaikoToken.sol b/packages/protocol/contracts/layer2/token/BridgedTaikoToken.sol similarity index 93% rename from packages/protocol/contracts/tko/BridgedTaikoToken.sol rename to packages/protocol/contracts/layer2/token/BridgedTaikoToken.sol index ceea652e326..e900bbdb151 100644 --- a/packages/protocol/contracts/tko/BridgedTaikoToken.sol +++ b/packages/protocol/contracts/layer2/token/BridgedTaikoToken.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; -import "../tokenvault/IBridgedERC20.sol"; -import "./TaikoTokenBase.sol"; +import "../../shared/tokenvault/IBridgedERC20.sol"; +import "../../shared/token/TaikoTokenBase.sol"; /// @title BridgedTaikoToken /// @notice The TaikoToken on L2 to support checkpoints and voting. For testnets, we do not need to diff --git a/packages/protocol/contracts/mainnet/shared/MainnetBridge.sol b/packages/protocol/contracts/mainnet/shared/MainnetBridge.sol deleted file mode 100644 index 651c6a85d40..00000000000 --- a/packages/protocol/contracts/mainnet/shared/MainnetBridge.sol +++ /dev/null @@ -1,17 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; - -import "../../bridge/Bridge.sol"; -import "../addrcache/SharedAddressCache.sol"; - -/// @title MainnetBridge -/// @dev This contract shall be deployed to replace its parent contract on Ethereum for Taiko -/// mainnet to reduce gas cost. In theory, the contract can also be deplyed on Taiko L2 but this is -/// not well testee nor necessary. -/// @notice See the documentation in {Bridge}. -/// @custom:security-contact security@taiko.xyz -contract MainnetBridge is Bridge, SharedAddressCache { - function _getAddress(uint64 _chainId, bytes32 _name) internal view override returns (address) { - return getAddress(_chainId, _name, super._getAddress); - } -} diff --git a/packages/protocol/contracts/bridge/Bridge.sol b/packages/protocol/contracts/shared/bridge/Bridge.sol similarity index 94% rename from packages/protocol/contracts/bridge/Bridge.sol rename to packages/protocol/contracts/shared/bridge/Bridge.sol index 7971b696d8c..3e67bad5cb7 100644 --- a/packages/protocol/contracts/bridge/Bridge.sol +++ b/packages/protocol/contracts/shared/bridge/Bridge.sol @@ -1,11 +1,12 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20VotesUpgradeable.sol"; import "../common/EssentialContract.sol"; import "../common/LibStrings.sol"; -import "../libs/LibAddress.sol"; -import "../libs/LibMath.sol"; +import "../common/LibAddress.sol"; +import "../common/LibMath.sol"; +import "../common/LibNetwork.sol"; import "../signal/ISignalService.sol"; import "./IBridge.sol"; import "./IQuotaManager.sol"; @@ -46,11 +47,6 @@ contract Bridge is EssentialContract, IBridge { /// @dev The amount of gas not to charge fee per cache operation. uint256 private constant _GAS_REFUND_PER_CACHE_OPERATION = 20_000; - /// @dev The slot in transient storage of the call context. This is the keccak256 hash - /// of "bridge.ctx_slot" - bytes32 private constant _CTX_SLOT = - 0xe4ece82196de19aabe639620d7f716c433d1348f96ce727c9989a982dbadc2b9; - /// @dev Gas limit for sending Ether. // - EOA gas used is < 21000 // - For Loopring smart wallet, gas used is about 23000 @@ -203,7 +199,9 @@ contract Bridge is EssentialContract, IBridge { ); // Must reset the context after the message call - _resetContext(); + _storeContext( + bytes32(_PLACEHOLDER), address(uint160(_PLACEHOLDER)), uint64(_PLACEHOLDER) + ); } else { _message.srcOwner.sendEtherAndVerify(_message.value, _SEND_ETHER_GAS_LIMIT); } @@ -515,7 +513,7 @@ contract Bridge is EssentialContract, IBridge { if (_shouldCheckForwardedGas) { _checkForwardedGas(gasLeft, _gasLimit); } - _resetContext(); + _storeContext(bytes32(_PLACEHOLDER), address(uint160(_PLACEHOLDER)), uint64(_PLACEHOLDER)); } /// @notice Updates the status of a bridge message. @@ -529,31 +527,12 @@ contract Bridge is EssentialContract, IBridge { emit MessageStatusChanged(_msgHash, _status); } - /// @notice Resets the call context - function _resetContext() private { - if (LibNetwork.isDencunSupported(block.chainid)) { - _storeContext(bytes32(0), address(0), uint64(0)); - } else { - _storeContext( - bytes32(_PLACEHOLDER), address(uint160(_PLACEHOLDER)), uint64(_PLACEHOLDER) - ); - } - } - /// @notice Stores the call context /// @param _msgHash The message hash. /// @param _from The sender's address. /// @param _srcChainId The source chain ID. - function _storeContext(bytes32 _msgHash, address _from, uint64 _srcChainId) private { - if (LibNetwork.isDencunSupported(block.chainid)) { - assembly { - tstore(_CTX_SLOT, _msgHash) - tstore(add(_CTX_SLOT, 1), _from) - tstore(add(_CTX_SLOT, 2), _srcChainId) - } - } else { - __ctx = Context(_msgHash, _from, _srcChainId); - } + function _storeContext(bytes32 _msgHash, address _from, uint64 _srcChainId) internal virtual { + __ctx = Context(_msgHash, _from, _srcChainId); } /// @notice Checks if the signal was received and caches cross-chain data if requested. @@ -597,20 +576,8 @@ contract Bridge is EssentialContract, IBridge { /// @notice Loads and returns the call context. /// @return ctx_ The call context. - function _loadContext() private view returns (Context memory) { - if (LibNetwork.isDencunSupported(block.chainid)) { - bytes32 msgHash; - address from; - uint64 srcChainId; - assembly { - msgHash := tload(_CTX_SLOT) - from := tload(add(_CTX_SLOT, 1)) - srcChainId := tload(add(_CTX_SLOT, 2)) - } - return Context(msgHash, from, srcChainId); - } else { - return __ctx; - } + function _loadContext() internal view virtual returns (Context memory) { + return __ctx; } /// @notice Checks if the signal was received. diff --git a/packages/protocol/contracts/bridge/IBridge.sol b/packages/protocol/contracts/shared/bridge/IBridge.sol similarity index 99% rename from packages/protocol/contracts/bridge/IBridge.sol rename to packages/protocol/contracts/shared/bridge/IBridge.sol index 598ff3bc736..23e6eecee0f 100644 --- a/packages/protocol/contracts/bridge/IBridge.sol +++ b/packages/protocol/contracts/shared/bridge/IBridge.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; /// @title IBridge /// @notice The bridge used in conjunction with the {ISignalService}. diff --git a/packages/protocol/contracts/bridge/IQuotaManager.sol b/packages/protocol/contracts/shared/bridge/IQuotaManager.sol similarity index 97% rename from packages/protocol/contracts/bridge/IQuotaManager.sol rename to packages/protocol/contracts/shared/bridge/IQuotaManager.sol index b2c296e8b15..02b28292e7c 100644 --- a/packages/protocol/contracts/bridge/IQuotaManager.sol +++ b/packages/protocol/contracts/shared/bridge/IQuotaManager.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; /// @title IQuotaManager /// @custom:security-contact security@taiko.xyz diff --git a/packages/protocol/contracts/bridge/QuotaManager.sol b/packages/protocol/contracts/shared/bridge/QuotaManager.sol similarity index 98% rename from packages/protocol/contracts/bridge/QuotaManager.sol rename to packages/protocol/contracts/shared/bridge/QuotaManager.sol index 2cb1fe40d03..293eeb7ca8d 100644 --- a/packages/protocol/contracts/bridge/QuotaManager.sol +++ b/packages/protocol/contracts/shared/bridge/QuotaManager.sol @@ -1,9 +1,9 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "../common/EssentialContract.sol"; import "../common/LibStrings.sol"; -import "../libs/LibMath.sol"; +import "../common/LibMath.sol"; import "./IQuotaManager.sol"; /// @title QuotaManager diff --git a/packages/protocol/contracts/bridge/README.md b/packages/protocol/contracts/shared/bridge/README.md similarity index 100% rename from packages/protocol/contracts/bridge/README.md rename to packages/protocol/contracts/shared/bridge/README.md diff --git a/packages/protocol/contracts/common/AddressManager.sol b/packages/protocol/contracts/shared/common/AddressManager.sol similarity index 98% rename from packages/protocol/contracts/common/AddressManager.sol rename to packages/protocol/contracts/shared/common/AddressManager.sol index d5b0e5c687f..ad064952fe2 100644 --- a/packages/protocol/contracts/common/AddressManager.sol +++ b/packages/protocol/contracts/shared/common/AddressManager.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "./EssentialContract.sol"; diff --git a/packages/protocol/contracts/common/AddressResolver.sol b/packages/protocol/contracts/shared/common/AddressResolver.sol similarity index 99% rename from packages/protocol/contracts/common/AddressResolver.sol rename to packages/protocol/contracts/shared/common/AddressResolver.sol index d1b17161a77..d00705f9255 100644 --- a/packages/protocol/contracts/common/AddressResolver.sol +++ b/packages/protocol/contracts/shared/common/AddressResolver.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import "./IAddressManager.sol"; diff --git a/packages/protocol/contracts/common/EssentialContract.sol b/packages/protocol/contracts/shared/common/EssentialContract.sol similarity index 82% rename from packages/protocol/contracts/common/EssentialContract.sol rename to packages/protocol/contracts/shared/common/EssentialContract.sol index a23723a8bc5..777ce8809ff 100644 --- a/packages/protocol/contracts/common/EssentialContract.sol +++ b/packages/protocol/contracts/shared/common/EssentialContract.sol @@ -1,26 +1,16 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol"; import "./AddressResolver.sol"; -import "../libs/LibNetwork.sol"; /// @title EssentialContract /// @custom:security-contact security@taiko.xyz abstract contract EssentialContract is UUPSUpgradeable, Ownable2StepUpgradeable, AddressResolver { uint8 private constant _FALSE = 1; - uint8 private constant _TRUE = 2; - /// @dev The slot in transient storage of the reentry lock. - /// This is the result of keccak256("ownerUUPS.reentry_slot") plus 1. The addition aims to - /// prevent hash collisions with slots defined in EIP-1967, where slots are derived by - /// keccak256("something") - 1, and with slots in SignalService, calculated directly with - /// keccak256("something"). - bytes32 private constant _REENTRY_SLOT = - 0xa5054f728453d3dbe953bdc43e4d0cb97e662ea32d7958190f3dc2da31d9721b; - /// @dev Slot 1. uint8 private __reentry; uint8 private __paused; @@ -153,23 +143,11 @@ abstract contract EssentialContract is UUPSUpgradeable, Ownable2StepUpgradeable, // Stores the reentry lock function _storeReentryLock(uint8 _reentry) internal virtual { - if (LibNetwork.isDencunSupported(block.chainid)) { - assembly { - tstore(_REENTRY_SLOT, _reentry) - } - } else { - __reentry = _reentry; - } + __reentry = _reentry; } // Loads the reentry lock function _loadReentryLock() internal view virtual returns (uint8 reentry_) { - if (LibNetwork.isDencunSupported(block.chainid)) { - assembly { - reentry_ := tload(_REENTRY_SLOT) - } - } else { - reentry_ = __reentry; - } + reentry_ = __reentry; } } diff --git a/packages/protocol/contracts/common/IAddressManager.sol b/packages/protocol/contracts/shared/common/IAddressManager.sol similarity index 96% rename from packages/protocol/contracts/common/IAddressManager.sol rename to packages/protocol/contracts/shared/common/IAddressManager.sol index 35da9ff77db..46ee1478156 100644 --- a/packages/protocol/contracts/common/IAddressManager.sol +++ b/packages/protocol/contracts/shared/common/IAddressManager.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; /// @title IAddressManager /// @notice Manages a mapping of (chainId, name) pairs to Ethereum addresses. diff --git a/packages/protocol/contracts/common/IAddressResolver.sol b/packages/protocol/contracts/shared/common/IAddressResolver.sol similarity index 98% rename from packages/protocol/contracts/common/IAddressResolver.sol rename to packages/protocol/contracts/shared/common/IAddressResolver.sol index 237dd500caa..efeae4a73d6 100644 --- a/packages/protocol/contracts/common/IAddressResolver.sol +++ b/packages/protocol/contracts/shared/common/IAddressResolver.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; /// @title IAddressResolver /// @notice This contract acts as a bridge for name-to-address resolution. diff --git a/packages/protocol/contracts/libs/LibAddress.sol b/packages/protocol/contracts/shared/common/LibAddress.sol similarity index 99% rename from packages/protocol/contracts/libs/LibAddress.sol rename to packages/protocol/contracts/shared/common/LibAddress.sol index 342d0222eb5..f79bad2610b 100644 --- a/packages/protocol/contracts/libs/LibAddress.sol +++ b/packages/protocol/contracts/shared/common/LibAddress.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/utils/introspection/IERC165.sol"; diff --git a/packages/protocol/contracts/libs/LibBytes.sol b/packages/protocol/contracts/shared/common/LibBytes.sol similarity index 98% rename from packages/protocol/contracts/libs/LibBytes.sol rename to packages/protocol/contracts/shared/common/LibBytes.sol index c8ab684951a..e8818321561 100644 --- a/packages/protocol/contracts/libs/LibBytes.sol +++ b/packages/protocol/contracts/shared/common/LibBytes.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; library LibBytes { error INNER_ERROR(bytes innerError); diff --git a/packages/protocol/contracts/libs/LibMath.sol b/packages/protocol/contracts/shared/common/LibMath.sol similarity index 97% rename from packages/protocol/contracts/libs/LibMath.sol rename to packages/protocol/contracts/shared/common/LibMath.sol index 6f05b843694..7fc0cf3d28f 100644 --- a/packages/protocol/contracts/libs/LibMath.sol +++ b/packages/protocol/contracts/shared/common/LibMath.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; /// @title LibMath /// @dev This library offers additional math functions for uint256. diff --git a/packages/protocol/contracts/libs/LibNetwork.sol b/packages/protocol/contracts/shared/common/LibNetwork.sol similarity index 99% rename from packages/protocol/contracts/libs/LibNetwork.sol rename to packages/protocol/contracts/shared/common/LibNetwork.sol index ff7e84aea69..2806b474a13 100644 --- a/packages/protocol/contracts/libs/LibNetwork.sol +++ b/packages/protocol/contracts/shared/common/LibNetwork.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; /// @title LibNetwork library LibNetwork { diff --git a/packages/protocol/contracts/common/LibStrings.sol b/packages/protocol/contracts/shared/common/LibStrings.sol similarity index 99% rename from packages/protocol/contracts/common/LibStrings.sol rename to packages/protocol/contracts/shared/common/LibStrings.sol index 9189ae0092f..2d889bd22b9 100644 --- a/packages/protocol/contracts/common/LibStrings.sol +++ b/packages/protocol/contracts/shared/common/LibStrings.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; /// @title LibStrings /// @custom:security-contact security@taiko.xyz diff --git a/packages/protocol/contracts/libs/LibTrieProof.sol b/packages/protocol/contracts/shared/common/LibTrieProof.sol similarity index 99% rename from packages/protocol/contracts/libs/LibTrieProof.sol rename to packages/protocol/contracts/shared/common/LibTrieProof.sol index 0bcf2a1753d..bb3cc7e0d9e 100644 --- a/packages/protocol/contracts/libs/LibTrieProof.sol +++ b/packages/protocol/contracts/shared/common/LibTrieProof.sol @@ -4,7 +4,7 @@ // | |/ _` | | / / _ \ | |__/ _` | '_ (_-< // |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/ -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "@optimism/packages/contracts-bedrock/src/libraries/rlp/RLPReader.sol"; import "@optimism/packages/contracts-bedrock/src/libraries/rlp/RLPWriter.sol"; diff --git a/packages/protocol/contracts/shared/data/LibSharedData.sol b/packages/protocol/contracts/shared/data/LibSharedData.sol new file mode 100644 index 00000000000..3bf9e665fd9 --- /dev/null +++ b/packages/protocol/contracts/shared/data/LibSharedData.sol @@ -0,0 +1,13 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.24; + +library LibSharedData { + /// @dev Struct that represents L2 basefee configurations + struct BaseFeeConfig { + uint8 adjustmentQuotient; + uint8 sharingPctg; + uint32 gasIssuancePerSecond; + uint64 minGasExcess; + uint32 maxGasIssuancePerBlock; + } +} diff --git a/packages/protocol/contracts/signal/ISignalService.sol b/packages/protocol/contracts/shared/signal/ISignalService.sol similarity index 99% rename from packages/protocol/contracts/signal/ISignalService.sol rename to packages/protocol/contracts/shared/signal/ISignalService.sol index 1b1c56d51a9..f6e8cc7b81f 100644 --- a/packages/protocol/contracts/signal/ISignalService.sol +++ b/packages/protocol/contracts/shared/signal/ISignalService.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; /// @title ISignalService /// @notice The SignalService contract serves as a secure cross-chain message diff --git a/packages/protocol/contracts/signal/SignalService.sol b/packages/protocol/contracts/shared/signal/SignalService.sol similarity index 99% rename from packages/protocol/contracts/signal/SignalService.sol rename to packages/protocol/contracts/shared/signal/SignalService.sol index 4fab944a7ed..8b4416eda8c 100644 --- a/packages/protocol/contracts/signal/SignalService.sol +++ b/packages/protocol/contracts/shared/signal/SignalService.sol @@ -1,9 +1,9 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "../common/EssentialContract.sol"; import "../common/LibStrings.sol"; -import "../libs/LibTrieProof.sol"; +import "../common/LibTrieProof.sol"; import "./ISignalService.sol"; /// @title SignalService diff --git a/packages/protocol/contracts/tko/TaikoTokenBase.sol b/packages/protocol/contracts/shared/token/TaikoTokenBase.sol similarity index 98% rename from packages/protocol/contracts/tko/TaikoTokenBase.sol rename to packages/protocol/contracts/shared/token/TaikoTokenBase.sol index 870cba39779..b0f373fac6c 100644 --- a/packages/protocol/contracts/tko/TaikoTokenBase.sol +++ b/packages/protocol/contracts/shared/token/TaikoTokenBase.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20VotesUpgradeable.sol"; import "../common/EssentialContract.sol"; diff --git a/packages/protocol/contracts/tokenvault/BaseNFTVault.sol b/packages/protocol/contracts/shared/tokenvault/BaseNFTVault.sol similarity index 99% rename from packages/protocol/contracts/tokenvault/BaseNFTVault.sol rename to packages/protocol/contracts/shared/tokenvault/BaseNFTVault.sol index 70f42e37f48..e47075803f7 100644 --- a/packages/protocol/contracts/tokenvault/BaseNFTVault.sol +++ b/packages/protocol/contracts/shared/tokenvault/BaseNFTVault.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "./BaseVault.sol"; diff --git a/packages/protocol/contracts/tokenvault/BaseVault.sol b/packages/protocol/contracts/shared/tokenvault/BaseVault.sol similarity index 98% rename from packages/protocol/contracts/tokenvault/BaseVault.sol rename to packages/protocol/contracts/shared/tokenvault/BaseVault.sol index 41c63722d61..de9db5c8314 100644 --- a/packages/protocol/contracts/tokenvault/BaseVault.sol +++ b/packages/protocol/contracts/shared/tokenvault/BaseVault.sol @@ -1,12 +1,12 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "@openzeppelin/contracts-upgradeable/utils/introspection/IERC165Upgradeable.sol"; import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol"; import "../bridge/IBridge.sol"; import "../common/EssentialContract.sol"; import "../common/LibStrings.sol"; -import "../libs/LibBytes.sol"; +import "../common/LibBytes.sol"; /// @title INameSymbol /// @notice Interface for contracts that provide name() and symbol() diff --git a/packages/protocol/contracts/tokenvault/BridgedERC1155.sol b/packages/protocol/contracts/shared/tokenvault/BridgedERC1155.sol similarity index 99% rename from packages/protocol/contracts/tokenvault/BridgedERC1155.sol rename to packages/protocol/contracts/shared/tokenvault/BridgedERC1155.sol index a262ed01770..2edb63ce287 100644 --- a/packages/protocol/contracts/tokenvault/BridgedERC1155.sol +++ b/packages/protocol/contracts/shared/tokenvault/BridgedERC1155.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "@openzeppelin/contracts-upgradeable/token/ERC1155/ERC1155Upgradeable.sol"; import "../common/EssentialContract.sol"; diff --git a/packages/protocol/contracts/tokenvault/BridgedERC20.sol b/packages/protocol/contracts/shared/tokenvault/BridgedERC20.sol similarity index 99% rename from packages/protocol/contracts/tokenvault/BridgedERC20.sol rename to packages/protocol/contracts/shared/tokenvault/BridgedERC20.sol index 9320df5b046..f8a564680dc 100644 --- a/packages/protocol/contracts/tokenvault/BridgedERC20.sol +++ b/packages/protocol/contracts/shared/tokenvault/BridgedERC20.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/introspection/IERC165Upgradeable.sol"; diff --git a/packages/protocol/contracts/tokenvault/BridgedERC20V2.sol b/packages/protocol/contracts/shared/tokenvault/BridgedERC20V2.sol similarity index 99% rename from packages/protocol/contracts/tokenvault/BridgedERC20V2.sol rename to packages/protocol/contracts/shared/tokenvault/BridgedERC20V2.sol index 10da51b7ab2..cc2b58ffa76 100644 --- a/packages/protocol/contracts/tokenvault/BridgedERC20V2.sol +++ b/packages/protocol/contracts/shared/tokenvault/BridgedERC20V2.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "@openzeppelin/contracts-upgradeable/interfaces/IERC5267Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20PermitUpgradeable.sol"; diff --git a/packages/protocol/contracts/tokenvault/BridgedERC721.sol b/packages/protocol/contracts/shared/tokenvault/BridgedERC721.sol similarity index 99% rename from packages/protocol/contracts/tokenvault/BridgedERC721.sol rename to packages/protocol/contracts/shared/tokenvault/BridgedERC721.sol index fd157570da5..979aa00edb2 100644 --- a/packages/protocol/contracts/tokenvault/BridgedERC721.sol +++ b/packages/protocol/contracts/shared/tokenvault/BridgedERC721.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol"; import "../common/EssentialContract.sol"; diff --git a/packages/protocol/contracts/tokenvault/ERC1155Vault.sol b/packages/protocol/contracts/shared/tokenvault/ERC1155Vault.sol similarity index 99% rename from packages/protocol/contracts/tokenvault/ERC1155Vault.sol rename to packages/protocol/contracts/shared/tokenvault/ERC1155Vault.sol index eb83c030659..d9de36a88bf 100644 --- a/packages/protocol/contracts/tokenvault/ERC1155Vault.sol +++ b/packages/protocol/contracts/shared/tokenvault/ERC1155Vault.sol @@ -1,9 +1,9 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "@openzeppelin/contracts/token/ERC1155/IERC1155.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC1155/utils/ERC1155ReceiverUpgradeable.sol"; -import "../libs/LibAddress.sol"; +import "../common/LibAddress.sol"; import "../common/LibStrings.sol"; import "./IBridgedERC1155.sol"; import "./BaseNFTVault.sol"; diff --git a/packages/protocol/contracts/tokenvault/ERC20Vault.sol b/packages/protocol/contracts/shared/tokenvault/ERC20Vault.sol similarity index 99% rename from packages/protocol/contracts/tokenvault/ERC20Vault.sol rename to packages/protocol/contracts/shared/tokenvault/ERC20Vault.sol index 2c2dfc2ad98..b7b0b0296b2 100644 --- a/packages/protocol/contracts/tokenvault/ERC20Vault.sol +++ b/packages/protocol/contracts/shared/tokenvault/ERC20Vault.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol"; @@ -7,7 +7,7 @@ import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import "../bridge/IQuotaManager.sol"; import "../common/LibStrings.sol"; -import "../libs/LibAddress.sol"; +import "../common/LibAddress.sol"; import "./IBridgedERC20.sol"; import "./BaseVault.sol"; diff --git a/packages/protocol/contracts/tokenvault/ERC721Vault.sol b/packages/protocol/contracts/shared/tokenvault/ERC721Vault.sol similarity index 99% rename from packages/protocol/contracts/tokenvault/ERC721Vault.sol rename to packages/protocol/contracts/shared/tokenvault/ERC721Vault.sol index 9d83a1cee0c..2784e80d64a 100644 --- a/packages/protocol/contracts/tokenvault/ERC721Vault.sol +++ b/packages/protocol/contracts/shared/tokenvault/ERC721Vault.sol @@ -1,9 +1,9 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "@openzeppelin/contracts/token/ERC721/IERC721.sol"; import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol"; -import "../libs/LibAddress.sol"; +import "../common/LibAddress.sol"; import "../common/LibStrings.sol"; import "./IBridgedERC721.sol"; import "./BaseNFTVault.sol"; diff --git a/packages/protocol/contracts/tokenvault/IBridgedERC1155.sol b/packages/protocol/contracts/shared/tokenvault/IBridgedERC1155.sol similarity index 98% rename from packages/protocol/contracts/tokenvault/IBridgedERC1155.sol rename to packages/protocol/contracts/shared/tokenvault/IBridgedERC1155.sol index bfa4226a58e..4c3e721782f 100644 --- a/packages/protocol/contracts/tokenvault/IBridgedERC1155.sol +++ b/packages/protocol/contracts/shared/tokenvault/IBridgedERC1155.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; /// @title IBridgedERC1155 /// @notice Contract for bridging ERC1155 tokens across different chains. diff --git a/packages/protocol/contracts/tokenvault/IBridgedERC20.sol b/packages/protocol/contracts/shared/tokenvault/IBridgedERC20.sol similarity index 99% rename from packages/protocol/contracts/tokenvault/IBridgedERC20.sol rename to packages/protocol/contracts/shared/tokenvault/IBridgedERC20.sol index fe86ca8f089..b8b672b4791 100644 --- a/packages/protocol/contracts/tokenvault/IBridgedERC20.sol +++ b/packages/protocol/contracts/shared/tokenvault/IBridgedERC20.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; /// @title IBridgedERC20 /// @notice Interface for all bridged tokens. diff --git a/packages/protocol/contracts/tokenvault/IBridgedERC721.sol b/packages/protocol/contracts/shared/tokenvault/IBridgedERC721.sol similarity index 98% rename from packages/protocol/contracts/tokenvault/IBridgedERC721.sol rename to packages/protocol/contracts/shared/tokenvault/IBridgedERC721.sol index 05cf26c8b5e..8f89632084c 100644 --- a/packages/protocol/contracts/tokenvault/IBridgedERC721.sol +++ b/packages/protocol/contracts/shared/tokenvault/IBridgedERC721.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; /// @title IBridgedERC721 /// @notice Contract for bridging ERC721 tokens across different chains. diff --git a/packages/protocol/contracts/tokenvault/LibBridgedToken.sol b/packages/protocol/contracts/shared/tokenvault/LibBridgedToken.sol similarity index 98% rename from packages/protocol/contracts/tokenvault/LibBridgedToken.sol rename to packages/protocol/contracts/shared/tokenvault/LibBridgedToken.sol index 16c08853b0d..bf6b8125b8a 100644 --- a/packages/protocol/contracts/tokenvault/LibBridgedToken.sol +++ b/packages/protocol/contracts/shared/tokenvault/LibBridgedToken.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "@openzeppelin/contracts/utils/Strings.sol"; diff --git a/packages/protocol/deployments/gen-layouts.sh b/packages/protocol/deployments/gen-layouts.sh deleted file mode 100755 index 2dc43caa845..00000000000 --- a/packages/protocol/deployments/gen-layouts.sh +++ /dev/null @@ -1,107 +0,0 @@ -#!/bin/bash - -# Define the list of contracts to inspect -# Please try not to change the order -# Contracts shared between layer 1 and layer 2 -contracts_shared=( -"contracts/tokenvault/ERC1155Vault.sol:ERC1155Vault" -"contracts/tokenvault/ERC20Vault.sol:ERC20Vault" -"contracts/tokenvault/ERC721Vault.sol:ERC721Vault" -"contracts/tokenvault/BridgedERC20.sol:BridgedERC20" -"contracts/tokenvault/BridgedERC20V2.sol:BridgedERC20V2" -"contracts/tokenvault/BridgedERC721.sol:BridgedERC721" -"contracts/tokenvault/BridgedERC1155.sol:BridgedERC1155" -"contracts/bridge/Bridge.sol:Bridge" -"contracts/bridge/QuotaManager.sol:QuotaManager" -"contracts/common/AddressManager.sol:AddressManager" -"contracts/common/AddressResolver.sol:AddressResolver" -"contracts/common/EssentialContract.sol:EssentialContract" -"contracts/signal/SignalService.sol:SignalService" -) - -# Layer 1 contracts -contracts_layer1=( -"contracts/tko/TaikoToken.sol:TaikoToken" -"contracts/verifiers/compose/ComposeVerifier.sol:ComposeVerifier" -"contracts/verifiers/compose/TeeAnyVerifier.sol:TeeAnyVerifier" -"contracts/verifiers/compose/ZkAndTeeVerifier.sol:ZkAndTeeVerifier" -"contracts/verifiers/compose/ZkAnyVerifier.sol:ZkAnyVerifier" -"contracts/verifiers/Risc0Verifier.sol:Risc0Verifier" -"contracts/verifiers/SP1Verifier.sol:SP1Verifier" -"contracts/verifiers/SgxVerifier.sol:SgxVerifier" -"contracts/automata-attestation/AutomataDcapV3Attestation.sol:AutomataDcapV3Attestation" -"contracts/L1/TaikoL1.sol:TaikoL1" -"contracts/L1/tiers/TierProviderV2.sol:TierProviderV2" -"contracts/hekla/HeklaTaikoL1.sol:HeklaTaikoL1" -"contracts/hekla/HeklaTierProvider.sol:HeklaTierProvider" -"contracts/mainnet/shared/MainnetBridge.sol:MainnetBridge" -"contracts/mainnet/shared/MainnetSignalService.sol:MainnetSignalService" -"contracts/mainnet/shared/MainnetERC20Vault.sol:MainnetERC20Vault" -"contracts/mainnet/shared/MainnetERC1155Vault.sol:MainnetERC1155Vault" -"contracts/mainnet/shared/MainnetERC721Vault.sol:MainnetERC721Vault" -"contracts/mainnet/shared/MainnetSharedAddressManager.sol:MainnetSharedAddressManager" -"contracts/mainnet/addrcache/RollupAddressCache.sol:RollupAddressCache" -"contracts/mainnet/addrcache/SharedAddressCache.sol:SharedAddressCache" -"contracts/mainnet/addrcache/AddressCache.sol:AddressCache" -"contracts/mainnet/rollup/verifiers/MainnetSgxVerifier.sol:MainnetSgxVerifier" -"contracts/mainnet/rollup/verifiers/MainnetSP1Verifier.sol:MainnetSP1Verifier" -"contracts/mainnet/rollup/verifiers/MainnetZkAnyVerifier.sol:MainnetZkAnyVerifier" -"contracts/mainnet/rollup/verifiers/MainnetRisc0Verifier.sol:MainnetRisc0Verifier" -"contracts/mainnet/rollup/verifiers/MainnetZkAndTeeVerifier.sol:MainnetZkAndTeeVerifier" -"contracts/mainnet/rollup/verifiers/MainnetTeeAnyVerifier.sol:MainnetTeeAnyVerifier" -"contracts/mainnet/rollup/MainnetGuardianProver.sol:MainnetGuardianProver" -"contracts/mainnet/rollup/MainnetTaikoL1.sol:MainnetTaikoL1" -"contracts/mainnet/rollup/MainnetRollupAddressManager.sol:MainnetRollupAddressManager" -"contracts/mainnet/rollup/MainnetTierRouter.sol:MainnetTierRouter" -"contracts/mainnet/rollup/MainnetProverSet.sol:MainnetProverSet" -"contracts/team/tokenunlock/TokenUnlock.sol:TokenUnlock" -"contracts/team/proving/ProverSet.sol:ProverSet" -"contracts/L1/provers/GuardianProver.sol:GuardianProver" -) - -# Layer 2 contracts -contracts_layer2=( -"contracts/tko/BridgedTaikoToken.sol:BridgedTaikoToken" -"contracts/L2/DelegateOwner.sol:DelegateOwner" -"contracts/L2/TaikoL2.sol:TaikoL2" -"contracts/hekla/HeklaTaikoL2.sol:HeklaTaikoL2" -"contracts/mainnet/rollup/MainnetTaikoL2.sol:MainnetTaikoL2" -) - -profile=$1 - -if [ "$profile" == "layer1" ]; then - echo "Generating layer 1 contract layouts..." - contracts=("${contracts_shared[@]}" "${contracts_layer1[@]}") -elif [ "$profile" == "layer2" ]; then - echo "Generating layer 2 contract layouts..." - contracts=("${contracts_shared[@]}" "${contracts_layer2[@]}") -else - echo "Invalid profile. Please enter either 'layer1' or 'layer2'." - exit 1 -fi - -# Empty the output file initially -output_file="contract_layout_${profile}.md" -> $output_file - -# Loop over each contract -for contract in "${contracts[@]}"; do - # Run forge inspect and append to the file - # Ensure correct concatenation of the command without commas - echo "inspect ${contract}" - - echo "## ${contract}" >> $output_file - FOUNDRY_PROFILE=${profile} forge inspect -C ./contracts/${profile} -o ./out/${profile} ${contract} storagelayout --pretty >> $output_file - echo "" >> $output_file - -done - -sed_pattern='s|contracts/.*/\([^/]*\)\.sol:\([^/]*\)|\2|g' - -if [[ "$(uname -s)" == "Darwin" ]]; then - sed -i '' "$sed_pattern" "$output_file" -else - sed -i "$sed_pattern" "$output_file" -fi - diff --git a/packages/protocol/deployments/hekla-contract-logs.md b/packages/protocol/deployments/hekla-contract-logs.md index f4543e45556..8ed476cfae5 100644 --- a/packages/protocol/deployments/hekla-contract-logs.md +++ b/packages/protocol/deployments/hekla-contract-logs.md @@ -14,7 +14,7 @@ - logs: - upgraded on May 10, 2024 at commit `4903bec` - upgraded on Jun 10, 2024 at commit `d5965bb` - - transfered ownership on Jul 8, 2024 + - transferred ownership on Jul 8, 2024 ### taiko_token @@ -24,7 +24,7 @@ - logs: - deployed on Mar 29, 2024 at commit `b341a68d5` - upgraded on Jun 18, 2024, added `batchTransfer` method. - - transfered ownership on Jul 8, 2024 + - transferred ownership on Jul 8, 2024 ### signal_service @@ -34,7 +34,7 @@ - logs: - upgraded on May 10, 2024 at commit `4903bec` - upgraded on Jun 10, 2024 at commit `d5965bb` - - transfered ownership on Jul 8, 2024 + - transferred ownership on Jul 8, 2024 ### bridge @@ -44,7 +44,7 @@ - logs: - upgraded on May 10, 2024 at commit `4903bec` - upgraded on Jun 10, 2024 at commit `d5965bb` - - transfered ownership on Jul 8, 2024 + - transferred ownership on Jul 8, 2024 ### erc20_vault @@ -54,7 +54,7 @@ - logs: - upgraded on May 10, 2024 at commit `4903bec` - upgraded on Jun 10, 2024 at commit `d5965bb` - - transfered ownership on Jul 8, 2024 + - transferred ownership on Jul 8, 2024 ### erc721_vault @@ -64,7 +64,7 @@ - logs: - upgraded on May 10, 2024 at commit `4903bec` - upgraded on Jun 10, 2024 at commit `d5965bb` - - transfered ownership on Jul 8, 2024 + - transferred ownership on Jul 8, 2024 ### erc1155_vault @@ -74,7 +74,7 @@ - logs: - upgraded on May 10, 2024 at commit `4903bec` - upgraded on Jun 10, 2024 at commit `d5965bb` - - transfered ownership on Jul 8, 2024 + - transferred ownership on Jul 8, 2024 ### bridged_erc20 @@ -103,7 +103,7 @@ - logs: - upgraded on May 10, 2024 at commit `13ad99d` - upgraded on Jun 10, 2024 at commit `d5965bb` - - transfered ownership on Jul 8, 2024 + - transferred ownership on Jul 8, 2024 ### taikoL1 @@ -118,7 +118,7 @@ - upgraded on Jun 14, 2024 at [PR #17553](https://github.com/taikoxyz/taiko-mono/pull/17553) @commit `baed5b5` - upgraded on Jun 19, 2024 at commit `b7e12e3` - upgraded on Jun 20, 2024 at commit `6e07ab5` - - transfered ownership on Jul 8, 2024 + - transferred ownership on Jul 8, 2024 - upgraded on Jul 11, 2024 at [PR #17779](https://github.com/taikoxyz/taiko-mono/pull/17779) - upgraded on Jul 15, 2024 at commit `45281b8` - upgraded on Aug 15, 2024 at `protocol-v1.8.0` with [#17919](https://github.com/taikoxyz/taiko-mono/pull/17919) @@ -131,7 +131,7 @@ - logs: - upgraded on May 10, 2024 at commit `4903bec` - upgraded on Jun 12, 2024 at commit `04bb81e` - - transfered ownership on Jul 8, 2024 + - transferred ownership on Jul 8, 2024 ### tierProvider @@ -178,7 +178,7 @@ - logs: - upgraded on May 10, 2024 at commit `4903bec` - upgraded on Jun 10, 2024 at commit `d5965bb` - - transfered ownership on Jul 8, 2024 + - transferred ownership on Jul 8, 2024 ### guardian_minority @@ -188,7 +188,7 @@ - logs: - deployed on May 20, 2024 at commit `6e56475` - upgraded on Jun 10, 2024 at commit `d5965bb` - - transfered ownership on Jul 8, 2024 + - transferred ownership on Jul 8, 2024 ### risc0_groth16_verifier @@ -210,7 +210,6 @@ - logs: - deployed on September 02, 2024 at commit `16ac02e` - ### tier_zkvm_sp1 - proxy : 0xFbE49f777E0078b3Fa0bae6de4794c88d6EA6DDD diff --git a/packages/protocol/docs/how_taiko_is_deployed.md b/packages/protocol/docs/how_taiko_is_deployed.md index 70d25938054..c9a5f33e9af 100644 --- a/packages/protocol/docs/how_taiko_is_deployed.md +++ b/packages/protocol/docs/how_taiko_is_deployed.md @@ -2,6 +2,6 @@ The Taiko protocol smart contracts are deployed on L1 and L2. The L2 contracts are pre-deployed first by creating a genesis block, and then the L1 contracts are deployed using a script. The general flow is like this: -1. A `genesis.json` is generated, which includes the L2 contracts (see: [generate genesis](../utils/generate_genesis/main.ts)). +1. A `genesis.json` is generated, which includes the L2 contracts (see: [generate genesis](../utils/generate_genesis/generate.ts)). 2. The `genesis.json` is used as input to generate the genesis block (see: https://geth.ethereum.org/docs/fundamentals/private-network#creating-genesis-block). 3. The L1 smart contracts are deployed by executing the L1 deployment script, [DeployOnL1.s.sol](../script/DeployOnL1.s.sol). The L1 deployment script takes in artifacts from the L2 deployment such as the deployed contract addresses, and genesis block hash. diff --git a/packages/protocol/foundry.toml b/packages/protocol/foundry.toml index 626e2bce947..144650ef190 100644 --- a/packages/protocol/foundry.toml +++ b/packages/protocol/foundry.toml @@ -1,7 +1,4 @@ [profile.default] -src = "contracts" -out = "out" -test = "test" script = "script" gas_price = 10_000_000_000 # 10 Gwei gas_limit = "18446744073709551615" # u64::MAX @@ -10,7 +7,6 @@ optimizer_runs = 200 ffi = true memory_limit = 2_073_741_824 solc_version = "0.8.27" -evm_version = "cancun" remappings = [ "@openzeppelin/contracts-upgradeable/=node_modules/@openzeppelin/contracts-upgradeable/", "openzeppelin/contracts-upgradeable/=node_modules/@openzeppelin/contracts-upgradeable/", @@ -54,5 +50,23 @@ multiline_func_header = "all" number_underscore = "thousands" wrap_comments = true +[profile.layer1] +src = "contracts/layer1" +test = "test/layer1" +script = "script/layer1" +out = "out/layer1" +evm_version = "cancun" + +[profile.layer2] +src = "contracts/layer2" +test = "test/layer2" +script = "script/layer2" +out = "out/layer2" +evm_version = "shanghai" + [profile.genesis] -test = "genesis" +src = "contracts/layer2" +test = "test/genesis" +script = "script/layer2" +out = "out/layer2" +evm_version = "shanghai" \ No newline at end of file diff --git a/packages/protocol/monitors/actions/ERC1155Vault-BridgedTokenDeployed.js b/packages/protocol/monitors/actions/ERC1155Vault-BridgedTokenDeployed.js index bfac4d6be94..4a0b8b9573c 100644 --- a/packages/protocol/monitors/actions/ERC1155Vault-BridgedTokenDeployed.js +++ b/packages/protocol/monitors/actions/ERC1155Vault-BridgedTokenDeployed.js @@ -1,5 +1,5 @@ -const {ethers} = require("ethers"); -const {Defender} = require("@openzeppelin/defender-sdk"); +const { ethers } = require("ethers"); +const { Defender } = require("@openzeppelin/defender-sdk"); const ABI = [ { @@ -45,7 +45,7 @@ function alertOrg(notificationClient, message) { notificationClient.send({ channelAlias: "discord_bridging", subject: "ERC1155Vault BridgedTokenDeployed Event Count", - message: message, + message, }); } @@ -75,7 +75,7 @@ async function calculateBlockRange(provider) { console.log(`Calculated block range: from ${fromBlock} to ${toBlock}`); - return {fromBlock, toBlock}; + return { fromBlock, toBlock }; } async function fetchLogs( @@ -84,7 +84,7 @@ async function fetchLogs( toBlock, address, abi, - provider + provider, ) { const iface = new ethers.utils.Interface(abi); const eventTopic = iface.getEventTopic(eventName); @@ -120,16 +120,16 @@ function createProvider(apiKey, apiSecret, relayerApiKey, relayerApiSecret) { } exports.handler = async function (event, context) { - const {notificationClient} = context; - const {apiKey, apiSecret, l1ApiKey, l1ApiSecret, l2ApiKey, l2ApiSecret} = + const { notificationClient } = context; + const { apiKey, apiSecret, l1ApiKey, l1ApiSecret, l2ApiKey, l2ApiSecret } = event.secrets; const l1Provider = createProvider(apiKey, apiSecret, l1ApiKey, l1ApiSecret); const l2Provider = createProvider(apiKey, apiSecret, l2ApiKey, l2ApiSecret); - const {fromBlock: l1FromBlock, toBlock: l1ToBlock} = + const { fromBlock: l1FromBlock, toBlock: l1ToBlock } = await calculateBlockRange(l1Provider); - const {fromBlock: l2FromBlock, toBlock: l2ToBlock} = + const { fromBlock: l2FromBlock, toBlock: l2ToBlock } = await calculateBlockRange(l2Provider); const l1Logs = await fetchLogs( @@ -138,7 +138,7 @@ exports.handler = async function (event, context) { l1ToBlock, "0xaf145913EA4a56BE22E120ED9C24589659881702", ABI, - l1Provider + l1Provider, ); const l2Logs = await fetchLogs( @@ -147,7 +147,7 @@ exports.handler = async function (event, context) { l2ToBlock, "0x1670000000000000000000000000000000000004", ABI, - l2Provider + l2Provider, ); const l1EventCount = l1Logs.length; diff --git a/packages/protocol/monitors/actions/ERC20Vault-BridgedTokenDeployed.js b/packages/protocol/monitors/actions/ERC20Vault-BridgedTokenDeployed.js index 969f16000e0..3939975e8f1 100644 --- a/packages/protocol/monitors/actions/ERC20Vault-BridgedTokenDeployed.js +++ b/packages/protocol/monitors/actions/ERC20Vault-BridgedTokenDeployed.js @@ -1,5 +1,5 @@ -const {ethers} = require("ethers"); -const {Defender} = require("@openzeppelin/defender-sdk"); +const { ethers } = require("ethers"); +const { Defender } = require("@openzeppelin/defender-sdk"); const ABI = [ { @@ -51,7 +51,7 @@ function alertOrg(notificationClient, message) { notificationClient.send({ channelAlias: "discord_bridging", subject: "BridgedTokenDeployed Event Count", - message: message, + message, }); } @@ -81,7 +81,7 @@ async function calculateBlockRange(provider) { console.log(`Calculated block range: from ${fromBlock} to ${toBlock}`); - return {fromBlock, toBlock}; + return { fromBlock, toBlock }; } async function fetchLogs( @@ -90,7 +90,7 @@ async function fetchLogs( toBlock, address, abi, - provider + provider, ) { const iface = new ethers.utils.Interface(abi); const eventTopic = iface.getEventTopic(eventName); @@ -126,16 +126,16 @@ function createProvider(apiKey, apiSecret, relayerApiKey, relayerApiSecret) { } exports.handler = async function (event, context) { - const {notificationClient} = context; - const {apiKey, apiSecret, l1ApiKey, l1ApiSecret, l2ApiKey, l2ApiSecret} = + const { notificationClient } = context; + const { apiKey, apiSecret, l1ApiKey, l1ApiSecret, l2ApiKey, l2ApiSecret } = event.secrets; const l1Provider = createProvider(apiKey, apiSecret, l1ApiKey, l1ApiSecret); const l2Provider = createProvider(apiKey, apiSecret, l2ApiKey, l2ApiSecret); - const {fromBlock: l1FromBlock, toBlock: l1ToBlock} = + const { fromBlock: l1FromBlock, toBlock: l1ToBlock } = await calculateBlockRange(l1Provider); - const {fromBlock: l2FromBlock, toBlock: l2ToBlock} = + const { fromBlock: l2FromBlock, toBlock: l2ToBlock } = await calculateBlockRange(l2Provider); const l1Logs = await fetchLogs( @@ -144,7 +144,7 @@ exports.handler = async function (event, context) { l1ToBlock, "0x996282cA11E5DEb6B5D122CC3B9A1FcAAD4415Ab", ABI, - l1Provider + l1Provider, ); const l2Logs = await fetchLogs( @@ -153,7 +153,7 @@ exports.handler = async function (event, context) { l2ToBlock, "0x1670000000000000000000000000000000000002", ABI, - l2Provider + l2Provider, ); const l1EventCount = l1Logs.length; diff --git a/packages/protocol/monitors/actions/ERC721Vault-BridgedTokenDeployed.js b/packages/protocol/monitors/actions/ERC721Vault-BridgedTokenDeployed.js index c111fd73d75..7684f22971c 100644 --- a/packages/protocol/monitors/actions/ERC721Vault-BridgedTokenDeployed.js +++ b/packages/protocol/monitors/actions/ERC721Vault-BridgedTokenDeployed.js @@ -1,5 +1,5 @@ -const {ethers} = require("ethers"); -const {Defender} = require("@openzeppelin/defender-sdk"); +const { ethers } = require("ethers"); +const { Defender } = require("@openzeppelin/defender-sdk"); const ABI = [ { @@ -45,7 +45,7 @@ function alertOrg(notificationClient, message) { notificationClient.send({ channelAlias: "discord_bridging", subject: "ERC721Vault BridgedTokenDeployed Event Count", - message: message, + message, }); } @@ -75,7 +75,7 @@ async function calculateBlockRange(provider) { console.log(`Calculated block range: from ${fromBlock} to ${toBlock}`); - return {fromBlock, toBlock}; + return { fromBlock, toBlock }; } async function fetchLogs( @@ -84,7 +84,7 @@ async function fetchLogs( toBlock, address, abi, - provider + provider, ) { const iface = new ethers.utils.Interface(abi); const eventTopic = iface.getEventTopic(eventName); @@ -120,16 +120,16 @@ function createProvider(apiKey, apiSecret, relayerApiKey, relayerApiSecret) { } exports.handler = async function (event, context) { - const {notificationClient} = context; - const {apiKey, apiSecret, l1ApiKey, l1ApiSecret, l2ApiKey, l2ApiSecret} = + const { notificationClient } = context; + const { apiKey, apiSecret, l1ApiKey, l1ApiSecret, l2ApiKey, l2ApiSecret } = event.secrets; const l1Provider = createProvider(apiKey, apiSecret, l1ApiKey, l1ApiSecret); const l2Provider = createProvider(apiKey, apiSecret, l2ApiKey, l2ApiSecret); - const {fromBlock: l1FromBlock, toBlock: l1ToBlock} = + const { fromBlock: l1FromBlock, toBlock: l1ToBlock } = await calculateBlockRange(l1Provider); - const {fromBlock: l2FromBlock, toBlock: l2ToBlock} = + const { fromBlock: l2FromBlock, toBlock: l2ToBlock } = await calculateBlockRange(l2Provider); const l1Logs = await fetchLogs( @@ -138,7 +138,7 @@ exports.handler = async function (event, context) { l1ToBlock, "0x0b470dd3A0e1C41228856Fb319649E7c08f419Aa", ABI, - l1Provider + l1Provider, ); const l2Logs = await fetchLogs( @@ -147,7 +147,7 @@ exports.handler = async function (event, context) { l2ToBlock, "0x1670000000000000000000000000000000000003", ABI, - l2Provider + l2Provider, ); const l1EventCount = l1Logs.length; diff --git a/packages/protocol/package.json b/packages/protocol/package.json index f12de834167..747686c68e4 100644 --- a/packages/protocol/package.json +++ b/packages/protocol/package.json @@ -1,24 +1,27 @@ { "name": "@taiko/protocol", - "version": "1.9.0", + "version": "1.8.0", "private": true, "scripts": { "buildMerkle": "ts-node ./utils/airdrop/buildMerkleTree.ts ./utils/airdrop/airdrop_db/example_claimList.json", - "clean": "rm -rf abis cache* && forge clean", - "compile": "forge build --build-info --extra-output storage-layout", - "layout:l1": "./deployments/gen-layouts.sh layer1", - "layout:l2": "./deployments/gen-layouts.sh layer2", + "clean": "rm -rf out abis cache* && forge clean", + "compile:l1": "FOUNDRY_PROFILE=layer1 forge build --build-info --extra-output storage-layout", + "compile:l2": "FOUNDRY_PROFILE=layer2 forge build --build-info --extra-output storage-layout", + "compile:genesis": "FOUNDRY_PROFILE=genesis forge build --build-info --extra-output storage-layout", + "compile": "pnpm compile:l1 && pnpm compile:l2", + "test:l1": "FOUNDRY_PROFILE=layer1 forge test -vvv --extra-output storage-layout", + "test:l2": "FOUNDRY_PROFILE=layer2 forge test -vvv --extra-output storage-layout", + "test": "pnpm test:l1 && pnpm test:l2", + "layout:l1": "./script/gen-layouts.sh layer1", + "layout:l2": "./script/gen-layouts.sh layer2", "layout": "pnpm layout:l1 && pnpm layout:l2", - "test:deploy": "./script/download_solc.sh && ./script/test_deploy_on_l1.sh", + "test:deploy:l1": "./script/download_solc.sh && ./script/layer1/deploy_protocol_on_l1.sh", "eslint": "pnpm exec eslint --fix --ignore-path .eslintignore --ext .js,.ts .", - "fmt:sol": "forge fmt", - "generate:genesis": "ts-node ./utils/generate_genesis/main.ts", - "lint:sol": "forge fmt && pnpm solhint 'contracts/**/*.sol'", - "snapshot": "forge snapshot --match-path 'test/**/*.t.sol'", - "test": "forge test -vvv --match-path test/*.t.sol", + "fmt:sol": "forge fmt && pnpm solhint 'contracts/**/*.sol'", "test:coverage": "mkdir -p coverage && forge coverage --report lcov && lcov --remove ./lcov.info -o ./coverage/lcov.info 'test/' 'script/' 'contracts/thirdparty/' && genhtml coverage/lcov.info --branch-coverage --output-dir coverage --ignore-errors category && open coverage/index.html", - "test:genesis": "pnpm compile && FOUNDRY_PROFILE=genesis ./genesis/generate_genesis.test.sh", - "export:simconf": "mkdir -p simulation/out && forge test --match-test 'test_L2_NoFeeCheck_simulation' -vv > simulation/out/simconf_$(date +%s).txt" + "genesis:gen": "pnpm compile:l2 && ts-node ./test/genesis/generate/generate.ts", + "genesis:test": "./test/genesis/genesis.test.sh", + "export:simconf": "mkdir -p simulation/out && FOUNDRY_PROFILE=layer2 forge test --match-test 'test_L2_NoFeeCheck_simulation' -vv > simulation/out/simconf_$(date +%s).txt" }, "devDependencies": { "@types/node": "^20.11.30", @@ -32,7 +35,7 @@ "eslint-plugin-prettier": "^5.1.3", "eslint-plugin-promise": "^6.1.1", "ethers": "^5.7.2", - "solc": "0.8.27", + "solc": "0.8.24", "solhint": "^5.0.3", "ts-node": "^10.9.2", "typescript": "^5.2.2" diff --git a/packages/protocol/script/download_solc.sh b/packages/protocol/script/download_solc.sh index 8c77c315a8a..0f078855856 100755 --- a/packages/protocol/script/download_solc.sh +++ b/packages/protocol/script/download_solc.sh @@ -11,7 +11,7 @@ fi mkdir -p "$(dirname "${solc_bin}")" -VERSION=v0.8.24 +VERSION=v0.8.27 if [ "$(uname)" = 'Darwin' ]; then SOLC_FILE_NAME=solc-macos diff --git a/packages/protocol/script/gen-layouts.sh b/packages/protocol/script/gen-layouts.sh new file mode 100755 index 00000000000..6216cbc7630 --- /dev/null +++ b/packages/protocol/script/gen-layouts.sh @@ -0,0 +1,105 @@ +#!/bin/bash + +# Define the list of contracts to inspect +# Please try not to change the order +# Contracts shared between layer 1 and layer 2 +contracts_shared=( +"contracts/shared/tokenvault/ERC1155Vault.sol:ERC1155Vault" +"contracts/shared/tokenvault/ERC20Vault.sol:ERC20Vault" +"contracts/shared/tokenvault/ERC721Vault.sol:ERC721Vault" +"contracts/shared/tokenvault/BridgedERC20.sol:BridgedERC20" +"contracts/shared/tokenvault/BridgedERC20V2.sol:BridgedERC20V2" +"contracts/shared/tokenvault/BridgedERC721.sol:BridgedERC721" +"contracts/shared/tokenvault/BridgedERC1155.sol:BridgedERC1155" +"contracts/shared/bridge/Bridge.sol:Bridge" +"contracts/shared/bridge/QuotaManager.sol:QuotaManager" +"contracts/shared/common/AddressManager.sol:AddressManager" +"contracts/shared/common/AddressResolver.sol:AddressResolver" +"contracts/shared/common/EssentialContract.sol:EssentialContract" +"contracts/shared/signal/SignalService.sol:SignalService" +) + +# Layer 1 contracts +contracts_layer1=( +"contracts/layer1/token/TaikoToken.sol:TaikoToken" +"contracts/layer1/verifiers/compose/ComposeVerifier.sol:ComposeVerifier" +"contracts/layer1/verifiers/compose/TeeAnyVerifier.sol:TeeAnyVerifier" +"contracts/layer1/verifiers/compose/ZkAndTeeVerifier.sol:ZkAndTeeVerifier" +"contracts/layer1/verifiers/compose/ZkAnyVerifier.sol:ZkAnyVerifier" +"contracts/layer1/verifiers/Risc0Verifier.sol:Risc0Verifier" +"contracts/layer1/verifiers/SP1Verifier.sol:SP1Verifier" +"contracts/layer1/verifiers/SgxVerifier.sol:SgxVerifier" +"contracts/layer1/automata-attestation/AutomataDcapV3Attestation.sol:AutomataDcapV3Attestation" +"contracts/layer1/based/TaikoL1.sol:TaikoL1" +"contracts/layer1/tiers/TierProviderV2.sol:TierProviderV2" +"contracts/layer1/hekla/HeklaTaikoL1.sol:HeklaTaikoL1" +"contracts/layer1/hekla/HeklaTierProvider.sol:HeklaTierProvider" +"contracts/layer1/mainnet/multirollup/MainnetBridge.sol:MainnetBridge" +"contracts/layer1/mainnet/multirollup/MainnetSignalService.sol:MainnetSignalService" +"contracts/layer1/mainnet/multirollup/MainnetERC20Vault.sol:MainnetERC20Vault" +"contracts/layer1/mainnet/multirollup/MainnetERC1155Vault.sol:MainnetERC1155Vault" +"contracts/layer1/mainnet/multirollup/MainnetERC721Vault.sol:MainnetERC721Vault" +"contracts/layer1/mainnet/multirollup/MainnetSharedAddressManager.sol:MainnetSharedAddressManager" +"contracts/layer1/mainnet/addrcache/RollupAddressCache.sol:RollupAddressCache" +"contracts/layer1/mainnet/addrcache/SharedAddressCache.sol:SharedAddressCache" +"contracts/layer1/mainnet/addrcache/AddressCache.sol:AddressCache" +"contracts/layer1/mainnet/rollup/verifiers/MainnetSgxVerifier.sol:MainnetSgxVerifier" +"contracts/layer1/mainnet/rollup/verifiers/MainnetSP1Verifier.sol:MainnetSP1Verifier" +"contracts/layer1/mainnet/rollup/verifiers/MainnetZkAnyVerifier.sol:MainnetZkAnyVerifier" +"contracts/layer1/mainnet/rollup/verifiers/MainnetRisc0Verifier.sol:MainnetRisc0Verifier" +"contracts/layer1/mainnet/rollup/verifiers/MainnetZkAndTeeVerifier.sol:MainnetZkAndTeeVerifier" +"contracts/layer1/mainnet/rollup/verifiers/MainnetTeeAnyVerifier.sol:MainnetTeeAnyVerifier" +"contracts/layer1/mainnet/rollup/MainnetGuardianProver.sol:MainnetGuardianProver" +"contracts/layer1/mainnet/rollup/MainnetTaikoL1.sol:MainnetTaikoL1" +"contracts/layer1/mainnet/rollup/MainnetRollupAddressManager.sol:MainnetRollupAddressManager" +"contracts/layer1/mainnet/rollup/MainnetTierRouter.sol:MainnetTierRouter" +"contracts/layer1/mainnet/rollup/MainnetProverSet.sol:MainnetProverSet" +"contracts/layer1/team/tokenunlock/TokenUnlock.sol:TokenUnlock" +"contracts/layer1/provers/ProverSet.sol:ProverSet" +"contracts/layer1/provers/GuardianProver.sol:GuardianProver" +) + +# Layer 2 contracts +contracts_layer2=( +"contracts/layer2/token/BridgedTaikoToken.sol:BridgedTaikoToken" +"contracts/layer2/DelegateOwner.sol:DelegateOwner" +"contracts/layer2/based/TaikoL2.sol:TaikoL2" +"contracts/layer2/hekla/HeklaTaikoL2.sol:HeklaTaikoL2" +"contracts/layer2/mainnet/MainnetTaikoL2.sol:MainnetTaikoL2" +) + +profile=$1 + +if [ "$profile" == "layer1" ]; then + echo "Generating layer 1 contract layouts..." + contracts=("${contracts_shared[@]}" "${contracts_layer1[@]}") +elif [ "$profile" == "layer2" ]; then + echo "Generating layer 2 contract layouts..." + contracts=("${contracts_shared[@]}" "${contracts_layer2[@]}") +else + echo "Invalid profile. Please enter either 'layer1' or 'layer2'." + exit 1 +fi + +# Empty the output file initially +output_file="contract_layout_${profile}.md" +> $output_file + +# Loop over each contract +for contract in "${contracts[@]}"; do + # Run forge inspect and append to the file + # Ensure correct concatenation of the command without commas + echo "inspect ${contract}" + + echo "## ${contract}" >> $output_file + FOUNDRY_PROFILE=${profile} forge inspect -C ./contracts/${profile} -o ./out/${profile} ${contract} storagelayout --pretty >> $output_file + echo "" >> $output_file +done + +sed_pattern='s|contracts/.*/\([^/]*\)\.sol:\([^/]*\)|\2|g' + +if [[ "$(uname -s)" == "Darwin" ]]; then + sed -i '' "$sed_pattern" "$output_file" +else + sed -i "$sed_pattern" "$output_file" +fi diff --git a/packages/protocol/script/AddSGXVerifierInstances.s.sol b/packages/protocol/script/layer1/AddSGXVerifierInstances.s.sol similarity index 84% rename from packages/protocol/script/AddSGXVerifierInstances.s.sol rename to packages/protocol/script/layer1/AddSGXVerifierInstances.s.sol index 0c728774453..92800f94f64 100644 --- a/packages/protocol/script/AddSGXVerifierInstances.s.sol +++ b/packages/protocol/script/layer1/AddSGXVerifierInstances.s.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; -import "../test/DeployCapability.sol"; -import "../contracts/verifiers/SgxVerifier.sol"; +import "../../test/shared/DeployCapability.sol"; +import "../../contracts/layer1/verifiers/SgxVerifier.sol"; contract AddSGXVerifierInstances is DeployCapability { uint256 public privateKey = vm.envUint("PRIVATE_KEY"); diff --git a/packages/protocol/script/DeployERC20Airdrop.s.sol b/packages/protocol/script/layer1/DeployERC20Airdrop.s.sol similarity index 93% rename from packages/protocol/script/DeployERC20Airdrop.s.sol rename to packages/protocol/script/layer1/DeployERC20Airdrop.s.sol index 68fd8581106..939fdfffa38 100644 --- a/packages/protocol/script/DeployERC20Airdrop.s.sol +++ b/packages/protocol/script/layer1/DeployERC20Airdrop.s.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; -import "../test/DeployCapability.sol"; -import "../contracts/team/airdrop/ERC20Airdrop.sol"; +import "../../test/shared/DeployCapability.sol"; +import "../../contracts/layer1/team/airdrop/ERC20Airdrop.sol"; // @KorbinianK , @2manslkh // As written also in the tests the workflow shall be the following (checklist): diff --git a/packages/protocol/script/DeployLabsProverPool.s.sol b/packages/protocol/script/layer1/DeployLabsProverPool.s.sol similarity index 82% rename from packages/protocol/script/DeployLabsProverPool.s.sol rename to packages/protocol/script/layer1/DeployLabsProverPool.s.sol index 57abcc13a30..887bd135b43 100644 --- a/packages/protocol/script/DeployLabsProverPool.s.sol +++ b/packages/protocol/script/layer1/DeployLabsProverPool.s.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; -import "../test/DeployCapability.sol"; -import "../contracts/team/proving/ProverSet.sol"; +import "../../test/shared/DeployCapability.sol"; +import "../../contracts/layer1/provers/ProverSet.sol"; contract DeployLabsProverPool is DeployCapability { address public addressManager = 0x579f40D0BE111b823962043702cabe6Aaa290780; diff --git a/packages/protocol/script/DeployOnL1.s.sol b/packages/protocol/script/layer1/DeployProtocolOnL1.s.sol similarity index 90% rename from packages/protocol/script/DeployOnL1.s.sol rename to packages/protocol/script/layer1/DeployProtocolOnL1.s.sol index c935f913aed..ec97f9c8f54 100644 --- a/packages/protocol/script/DeployOnL1.s.sol +++ b/packages/protocol/script/layer1/DeployProtocolOnL1.s.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "@openzeppelin/contracts/utils/Strings.sol"; import "@risc0/contracts/groth16/RiscZeroGroth16Verifier.sol"; @@ -11,38 +11,38 @@ import { SP1Verifier as SP1Verifier120rc } from "@sp1-contracts/src/v1.2.0-rc/SP // - https://github.com/rdubois-crypto/FreshCryptoLib import "@p256-verifier/contracts/P256Verifier.sol"; -import "../contracts/common/LibStrings.sol"; -import "../contracts/tko/TaikoToken.sol"; -import "../contracts/mainnet/rollup/MainnetTaikoL1.sol"; -import "../contracts/devnet/DevnetTaikoL1.sol"; -import "../contracts/L1/provers/GuardianProver.sol"; -import "../contracts/L1/tiers/DevnetTierProvider.sol"; -import "../contracts/L1/tiers/TierProviderV2.sol"; -import "../contracts/mainnet/shared/MainnetBridge.sol"; -import "../contracts/tokenvault/BridgedERC20.sol"; -import "../contracts/tokenvault/BridgedERC721.sol"; -import "../contracts/tokenvault/BridgedERC1155.sol"; -import "../contracts/mainnet/shared/MainnetERC20Vault.sol"; -import "../contracts/mainnet/shared/MainnetERC1155Vault.sol"; -import "../contracts/mainnet/shared/MainnetERC721Vault.sol"; -import "../contracts/mainnet/shared/MainnetSignalService.sol"; -import "../contracts/mainnet/rollup/MainnetGuardianProver.sol"; -import "../contracts/automata-attestation/AutomataDcapV3Attestation.sol"; -import "../contracts/automata-attestation/utils/SigVerifyLib.sol"; -import "../contracts/automata-attestation/lib/PEMCertChainLib.sol"; -import "../contracts/mainnet/rollup/verifiers/MainnetSgxVerifier.sol"; -import "../contracts/team/proving/ProverSet.sol"; -import "../test/common/erc20/FreeMintERC20.sol"; -import "../test/common/erc20/MayFailFreeMintERC20.sol"; -import "../test/L1/TestTierProvider.sol"; -import "../test/DeployCapability.sol"; -import "../contracts/verifiers/Risc0Verifier.sol"; -import "../contracts/verifiers/SP1Verifier.sol"; - -/// @title DeployOnL1 +import "../../contracts/shared/common/LibStrings.sol"; +import "../../contracts/shared/tokenvault/BridgedERC1155.sol"; +import "../../contracts/shared/tokenvault/BridgedERC20.sol"; +import "../../contracts/shared/tokenvault/BridgedERC721.sol"; +import "../../contracts/layer1/automata-attestation/AutomataDcapV3Attestation.sol"; +import "../../contracts/layer1/automata-attestation/lib/PEMCertChainLib.sol"; +import "../../contracts/layer1/automata-attestation/utils/SigVerifyLib.sol"; +import "../../contracts/layer1/devnet/DevnetTaikoL1.sol"; +import "../../contracts/layer1/devnet/DevnetTierProvider.sol"; +import "../../contracts/layer1/mainnet/rollup/MainnetGuardianProver.sol"; +import "../../contracts/layer1/mainnet/rollup/MainnetTaikoL1.sol"; +import "../../contracts/layer1/mainnet/rollup/verifiers/MainnetSgxVerifier.sol"; +import "../../contracts/layer1/mainnet/multirollup/MainnetBridge.sol"; +import "../../contracts/layer1/mainnet/multirollup/MainnetERC1155Vault.sol"; +import "../../contracts/layer1/mainnet/multirollup/MainnetERC20Vault.sol"; +import "../../contracts/layer1/mainnet/multirollup/MainnetERC721Vault.sol"; +import "../../contracts/layer1/mainnet/multirollup/MainnetSignalService.sol"; +import "../../contracts/layer1/provers/GuardianProver.sol"; +import "../../contracts/layer1/provers/ProverSet.sol"; +import "../../contracts/layer1/tiers/TierProviderV2.sol"; +import "../../contracts/layer1/token/TaikoToken.sol"; +import "../../contracts/layer1/verifiers/Risc0Verifier.sol"; +import "../../contracts/layer1/verifiers/SP1Verifier.sol"; +import "../../test/layer1/based/TestTierProvider.sol"; +import "../../test/shared/token/FreeMintERC20.sol"; +import "../../test/shared/token/MayFailFreeMintERC20.sol"; +import "../../test/shared/DeployCapability.sol"; + +/// @title DeployProtocolOnL1 /// @notice This script deploys the core Taiko protocol smart contract on L1, /// initializing the rollup. -contract DeployOnL1 is DeployCapability { +contract DeployProtocolOnL1 is DeployCapability { uint256 public NUM_MIN_MAJORITY_GUARDIANS = vm.envUint("NUM_MIN_MAJORITY_GUARDIANS"); uint256 public NUM_MIN_MINORITY_GUARDIANS = vm.envUint("NUM_MIN_MINORITY_GUARDIANS"); diff --git a/packages/protocol/script/DeployProverSet.s.sol b/packages/protocol/script/layer1/DeployProverSet.s.sol similarity index 90% rename from packages/protocol/script/DeployProverSet.s.sol rename to packages/protocol/script/layer1/DeployProverSet.s.sol index 4a0306ae413..eb874c2ba70 100644 --- a/packages/protocol/script/DeployProverSet.s.sol +++ b/packages/protocol/script/layer1/DeployProverSet.s.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; -import "../contracts/team/proving/ProverSet.sol"; -import "../test/DeployCapability.sol"; +import "../../contracts/layer1/provers/ProverSet.sol"; +import "../../test/shared/DeployCapability.sol"; contract DeployProverSet is DeployCapability { modifier broadcast() { diff --git a/packages/protocol/script/DeployL1QuotaManager.s.sol b/packages/protocol/script/layer1/DeployQuotaManager.s.sol similarity index 89% rename from packages/protocol/script/DeployL1QuotaManager.s.sol rename to packages/protocol/script/layer1/DeployQuotaManager.s.sol index bd909355099..d3d2f8122ae 100644 --- a/packages/protocol/script/DeployL1QuotaManager.s.sol +++ b/packages/protocol/script/layer1/DeployQuotaManager.s.sol @@ -1,10 +1,10 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; -import "../test/DeployCapability.sol"; -import "../contracts/bridge/QuotaManager.sol"; +import "../../test/shared/DeployCapability.sol"; +import "../../contracts/shared/bridge/QuotaManager.sol"; -contract DeployL1QuotaManager is DeployCapability { +contract DeployQuotaManager is DeployCapability { uint256 public privateKey = vm.envUint("PRIVATE_KEY"); // MAINNET_L1_SHARED_ADDRESS_MANAGER: 0xEf9EaA1dd30a9AA1df01c36411b5F082aA65fBaa address public addressManager = vm.envAddress("L1_SHARED_ADDRESS_MANAGER"); diff --git a/packages/protocol/script/DeployRisc0Verifier.s.sol b/packages/protocol/script/layer1/DeployRisc0Verifier.s.sol similarity index 88% rename from packages/protocol/script/DeployRisc0Verifier.s.sol rename to packages/protocol/script/layer1/DeployRisc0Verifier.s.sol index 772e110cba2..76dc325a720 100644 --- a/packages/protocol/script/DeployRisc0Verifier.s.sol +++ b/packages/protocol/script/layer1/DeployRisc0Verifier.s.sol @@ -1,9 +1,9 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "@risc0/contracts/groth16/RiscZeroGroth16Verifier.sol"; -import "../test/DeployCapability.sol"; -import "../contracts/verifiers/Risc0Verifier.sol"; +import "../../test/shared/DeployCapability.sol"; +import "../../contracts/layer1/verifiers/Risc0Verifier.sol"; contract DeployRisc0Verifier is DeployCapability { uint256 public deployerPrivKey = vm.envUint("PRIVATE_KEY"); diff --git a/packages/protocol/script/DeploySP1Verifier.s.sol b/packages/protocol/script/layer1/DeploySP1Verifier.s.sol similarity index 88% rename from packages/protocol/script/DeploySP1Verifier.s.sol rename to packages/protocol/script/layer1/DeploySP1Verifier.s.sol index 7306c615c21..c17a09ebb61 100644 --- a/packages/protocol/script/DeploySP1Verifier.s.sol +++ b/packages/protocol/script/layer1/DeploySP1Verifier.s.sol @@ -1,9 +1,9 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import { SP1Verifier as SP1Verifier120rc } from "@sp1-contracts/src/v1.2.0-rc/SP1VerifierPlonk.sol"; -import "../test/DeployCapability.sol"; -import "../contracts/verifiers/SP1Verifier.sol"; +import "../../test/shared/DeployCapability.sol"; +import "../../contracts/layer1/verifiers/SP1Verifier.sol"; contract DeploySP1Verifier is DeployCapability { uint256 public deployerPrivKey = vm.envUint("PRIVATE_KEY"); diff --git a/packages/protocol/script/DeployTaikoToken.s.sol b/packages/protocol/script/layer1/DeployTaikoToken.s.sol similarity index 87% rename from packages/protocol/script/DeployTaikoToken.s.sol rename to packages/protocol/script/layer1/DeployTaikoToken.s.sol index 55134312015..fafcebd8cc9 100644 --- a/packages/protocol/script/DeployTaikoToken.s.sol +++ b/packages/protocol/script/layer1/DeployTaikoToken.s.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; -import "../test/DeployCapability.sol"; -import "../contracts/tko/TaikoToken.sol"; +import "../../test/shared/DeployCapability.sol"; +import "../../contracts/layer1/token/TaikoToken.sol"; contract DeployTaikoToken is DeployCapability { uint256 public privateKey = vm.envUint("PRIVATE_KEY"); diff --git a/packages/protocol/script/SendMessageToDelegateOwner.s.sol b/packages/protocol/script/layer1/SendMessageToDelegateOwner.s.sol similarity index 91% rename from packages/protocol/script/SendMessageToDelegateOwner.s.sol rename to packages/protocol/script/layer1/SendMessageToDelegateOwner.s.sol index d90e0ade263..f202a1bd864 100644 --- a/packages/protocol/script/SendMessageToDelegateOwner.s.sol +++ b/packages/protocol/script/layer1/SendMessageToDelegateOwner.s.sol @@ -1,10 +1,10 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "forge-std/src/Script.sol"; -import "../contracts/L2/DelegateOwner.sol"; -import "../contracts/bridge/IBridge.sol"; -import "../test/thirdparty/Multicall3.sol"; +import "../../contracts/shared/bridge/IBridge.sol"; +import "../../contracts/layer2/DelegateOwner.sol"; +import "../../test/shared/thirdparty/Multicall3.sol"; contract SendMessageToDelegateOwner is Script { address public delegateOwner = 0x5995941Df88F30Ac140515AA39832db963E2f863; diff --git a/packages/protocol/script/SetDcapParams.s.sol b/packages/protocol/script/layer1/SetDcapParams.s.sol similarity index 96% rename from packages/protocol/script/SetDcapParams.s.sol rename to packages/protocol/script/layer1/SetDcapParams.s.sol index 3429e816b3c..411c322e522 100644 --- a/packages/protocol/script/SetDcapParams.s.sol +++ b/packages/protocol/script/layer1/SetDcapParams.s.sol @@ -1,10 +1,10 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "forge-std/src/Script.sol"; import "forge-std/src/console2.sol"; -import "../test/automata-attestation/common/AttestationBase.t.sol"; +import "../../test/layer1/automata-attestation/common/AttestationBase.t.sol"; contract SetDcapParams is Script, AttestationBase { uint256 public ownerPrivateKey = vm.envUint("PRIVATE_KEY"); // Owner of the attestation contract diff --git a/packages/protocol/script/config_dcap_sgx_verifier.sh b/packages/protocol/script/layer1/config_dcap_sgx_verifier.sh similarity index 99% rename from packages/protocol/script/config_dcap_sgx_verifier.sh rename to packages/protocol/script/layer1/config_dcap_sgx_verifier.sh index 98874c1ae97..4043f5f8ae5 100755 --- a/packages/protocol/script/config_dcap_sgx_verifier.sh +++ b/packages/protocol/script/layer1/config_dcap_sgx_verifier.sh @@ -63,7 +63,7 @@ toggle_check=0 vm_file_path() { local file_path="$1" local parent_dir=$(dirname "$file_path") - local trimmed_path="/test/automata-attestation/assets/$(basename "$parent_dir")/$(basename "$file_path")" + local trimmed_path="/test/layer1/automata-attestation/assets/$(basename "$parent_dir")/$(basename "$file_path")" echo "$trimmed_path" } diff --git a/packages/protocol/script/test_deploy_on_l1.sh b/packages/protocol/script/layer1/deploy_protocol_on_l1.sh similarity index 84% rename from packages/protocol/script/test_deploy_on_l1.sh rename to packages/protocol/script/layer1/deploy_protocol_on_l1.sh index c4df51742f9..b225c2279a6 100755 --- a/packages/protocol/script/test_deploy_on_l1.sh +++ b/packages/protocol/script/layer1/deploy_protocol_on_l1.sh @@ -1,6 +1,6 @@ #!/bin/sh -# This script is only used by `pnpm test:deploy`. +# This script is only used by `pnpm test:deploy:l1`. set -e export PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 @@ -13,7 +13,7 @@ L2_SIGNAL_SERVICE=0x1000777700000000000000000000000000000007 \ CONTRACT_OWNER=0x60997970C51812dc3A010C7d01b50e0d17dc79C8 \ PROVER_SET_ADMIN=0x60997970C51812dc3A010C7d01b50e0d17dc79C8 \ TAIKO_TOKEN_PREMINT_RECIPIENT=0xa0Ee7A142d267C1f36714E4a8F75612F20a79720 \ -TAIKO_TOKEN_NAME="Taiko Token Katla" \ +TAIKO_TOKEN_NAME="Taiko Token Test" \ TAIKO_TOKEN_SYMBOL=TTKOk \ SHARED_ADDRESS_MANAGER=0x0000000000000000000000000000000000000000 \ L2_GENESIS_HASH=0xee1950562d42f0da28bd4550d88886bc90894c77c9c9eaefef775d4c8223f259 \ @@ -22,7 +22,8 @@ PAUSE_BRIDGE=true \ NUM_MIN_MAJORITY_GUARDIANS=7 \ NUM_MIN_MINORITY_GUARDIANS=2 \ TIER_PROVIDER="devnet" \ -forge script script/DeployOnL1.s.sol:DeployOnL1 \ +FOUNDRY_PROFILE="layer1" \ +forge script ./script/layer1/DeployProtocolOnL1.s.sol:DeployProtocolOnL1 \ --fork-url http://localhost:8545 \ --broadcast \ --ffi \ @@ -34,8 +35,9 @@ export PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f SECURITY_COUNCIL=0x60997970C51812dc3A010C7d01b50e0d17dc79C8 \ TAIKO_TOKEN_PREMINT_RECIPIENT=0xa0Ee7A142d267C1f36714E4a8F75612F20a79720 \ TAIKO_TOKEN_NAME="Taiko Token" \ -TAIKO_TOKEN_SYMBOL=TTKO \ -forge script script/DeployTaikoToken.s.sol:DeployTaikoToken \ +TAIKO_TOKEN_SYMBOL=TAIKO \ +FOUNDRY_PROFILE="layer1" \ +forge script ./script/layer1/DeployTaikoToken.s.sol:DeployTaikoToken \ --fork-url http://localhost:8545 \ --broadcast \ --ffi \ diff --git a/packages/protocol/script/tokenunlock/Deploy.data.json b/packages/protocol/script/layer1/tokenunlock/Deploy.data.json similarity index 100% rename from packages/protocol/script/tokenunlock/Deploy.data.json rename to packages/protocol/script/layer1/tokenunlock/Deploy.data.json diff --git a/packages/protocol/script/tokenunlock/Deploy.s.sol b/packages/protocol/script/layer1/tokenunlock/Deploy.s.sol similarity index 92% rename from packages/protocol/script/tokenunlock/Deploy.s.sol rename to packages/protocol/script/layer1/tokenunlock/Deploy.s.sol index 14200c9ab2a..2b13bec09dc 100644 --- a/packages/protocol/script/tokenunlock/Deploy.s.sol +++ b/packages/protocol/script/layer1/tokenunlock/Deploy.s.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; -import "../../test/DeployCapability.sol"; -import "../../contracts/team/tokenunlock/TokenUnlock.sol"; +import "../../../test/shared/DeployCapability.sol"; +import "../../../contracts/layer1/team/tokenunlock/TokenUnlock.sol"; contract DeployTokenUnlock is DeployCapability { using stdJson for string; diff --git a/packages/protocol/script/tokenunlock/Vest.data.json b/packages/protocol/script/layer1/tokenunlock/Vest.data.json similarity index 100% rename from packages/protocol/script/tokenunlock/Vest.data.json rename to packages/protocol/script/layer1/tokenunlock/Vest.data.json diff --git a/packages/protocol/script/tokenunlock/Vest.s.sol b/packages/protocol/script/layer1/tokenunlock/Vest.s.sol similarity index 95% rename from packages/protocol/script/tokenunlock/Vest.s.sol rename to packages/protocol/script/layer1/tokenunlock/Vest.s.sol index 1b146bfecc3..9b7a7285a01 100644 --- a/packages/protocol/script/tokenunlock/Vest.s.sol +++ b/packages/protocol/script/layer1/tokenunlock/Vest.s.sol @@ -1,11 +1,11 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "forge-std/src/Script.sol"; import "forge-std/src/console2.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; -import "../../contracts/team/tokenunlock/TokenUnlock.sol"; +import "../../../contracts/layer1/team/tokenunlock/TokenUnlock.sol"; contract VestTokenUnlock is Script { using stdJson for string; diff --git a/packages/protocol/script/tokenunlock/exercise1.data.json b/packages/protocol/script/layer1/tokenunlock/exercise1.data.json similarity index 100% rename from packages/protocol/script/tokenunlock/exercise1.data.json rename to packages/protocol/script/layer1/tokenunlock/exercise1.data.json diff --git a/packages/protocol/script/DeployL2DelegateOwner.s.sol b/packages/protocol/script/layer2/DeployDelegateOwner.s.sol similarity index 77% rename from packages/protocol/script/DeployL2DelegateOwner.s.sol rename to packages/protocol/script/layer2/DeployDelegateOwner.s.sol index 93621c025a8..ad07e0970b4 100644 --- a/packages/protocol/script/DeployL2DelegateOwner.s.sol +++ b/packages/protocol/script/layer2/DeployDelegateOwner.s.sol @@ -1,11 +1,11 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; -import "../test/DeployCapability.sol"; -import "../contracts/L2/DelegateOwner.sol"; +import "../../test/shared/DeployCapability.sol"; +import "../../contracts/layer2/DelegateOwner.sol"; -// forge script --rpc-url https://rpc.mainnet.taiko.xyz script/DeployL2DelegateOwner.s.sol -contract DeployL2DelegateOwner is DeployCapability { +// forge script --rpc-url https://rpc.mainnet.taiko.xyz script/DeployDelegateOwner.s.sol +contract DeployDelegateOwner is DeployCapability { address public l2Sam = 0x1670000000000000000000000000000000000006; address public testAccount2 = 0x3c181965C5cFAE61a9010A283e5e0C1445649810; // owned by Daniel W diff --git a/packages/protocol/script/L2PostGenesisConfig.s.sol b/packages/protocol/script/layer2/PostGenesisConfig.s.sol similarity index 93% rename from packages/protocol/script/L2PostGenesisConfig.s.sol rename to packages/protocol/script/layer2/PostGenesisConfig.s.sol index 46390b58541..1c59866f9fd 100644 --- a/packages/protocol/script/L2PostGenesisConfig.s.sol +++ b/packages/protocol/script/layer2/PostGenesisConfig.s.sol @@ -1,20 +1,20 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "forge-std/src/Script.sol"; import "forge-std/src/console2.sol"; -import "../contracts/tokenvault/ERC20Vault.sol"; -import "../contracts/bridge/Bridge.sol"; -import "../contracts/common/AddressManager.sol"; +import "../../contracts/shared/tokenvault/ERC20Vault.sol"; +import "../../contracts/shared/bridge/Bridge.sol"; +import "../../contracts/shared/common/AddressManager.sol"; interface USDCProxy { function configureMinter(address minter, uint256 minterAllowedAmount) external; } // Run with: -// forge script --rpc-url https://rpc.mainnet.taiko.xyz script/L2PostGenesisConfig.s.sol -contract L2PostGenesisConfig is Script { +// forge script --rpc-url https://rpc.mainnet.taiko.xyz script/PostGenesisConfig.s.sol +contract PostGenesisConfig is Script { // All following addresses are L2 addresses address public bridgedTKO = 0xA9d23408b9bA935c230493c40C73824Df71A0975; address public bridgedUSDC = 0x07d83526730c7438048D55A4fc0b850e2aaB6f0b; diff --git a/packages/protocol/script/L2PostGenesisQuery.s.sol b/packages/protocol/script/layer2/PostGenesisQuery.s.sol similarity index 92% rename from packages/protocol/script/L2PostGenesisQuery.s.sol rename to packages/protocol/script/layer2/PostGenesisQuery.s.sol index b69999229b8..7c8882f9edc 100644 --- a/packages/protocol/script/L2PostGenesisQuery.s.sol +++ b/packages/protocol/script/layer2/PostGenesisQuery.s.sol @@ -1,13 +1,13 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; -import "../test/DeployCapability.sol"; -import "../contracts/common/AddressManager.sol"; -import "../contracts/bridge/Bridge.sol"; +import "../../test/shared/DeployCapability.sol"; +import "../../contracts/shared/common/AddressManager.sol"; +import "../../contracts/shared/bridge/Bridge.sol"; // Run with: -// forge script --rpc-url https://rpc.mainnet.taiko.xyz script/L2PostGenesisQuery.s.sol -contract L2PostGenesisQuery is DeployCapability { +// forge script --rpc-url https://rpc.mainnet.taiko.xyz script/PostGenesisQuery.s.sol +contract PostGenesisQuery is DeployCapability { uint64 taiko_id = 167_000; function run() external view { diff --git a/packages/protocol/script/merge_contracts.py b/packages/protocol/script/merge_contracts.py deleted file mode 100644 index 7722d5d5ebd..00000000000 --- a/packages/protocol/script/merge_contracts.py +++ /dev/null @@ -1,27 +0,0 @@ -import os -import argparse - -def merge_solidity_files(root_dir, output_file='../out/taiko_protocol.md'): - with open(output_file, 'w') as outfile: - for subdir, dirs, files in os.walk(root_dir): - for file in files: - if file.endswith('.sol') and not file.endswith('.t.sol'): - file_path = os.path.join(subdir, file) - if "/test/" in file_path: - continue - print("merging ", file_path) - relative_path = os.path.relpath(file_path, root_dir) - outfile.write(f"## {relative_path}\n") - outfile.write("```solidity\n") - with open(file_path, 'r') as infile: - outfile.write(infile.read()) - outfile.write("\n```\n\n") - - -if __name__ == "__main__": - # parser = argparse.ArgumentParser(description="Merge Solidity files into a Markdown file.") - # parser.add_argument("root_dir", type=str, help="Root directory containing Solidity files") - # args = parser.parse_args() - # merge_solidity_files(args.root_dir) - merge_solidity_files("../contracts") - print("merged into ../out/taiko_protocol.md") diff --git a/packages/protocol/script/AuthorizeTaikoForMultihop.s.sol b/packages/protocol/script/shared/AuthorizeTaikoForMultihop.s.sol similarity index 83% rename from packages/protocol/script/AuthorizeTaikoForMultihop.s.sol rename to packages/protocol/script/shared/AuthorizeTaikoForMultihop.s.sol index bd236c699b4..db7b01f4274 100644 --- a/packages/protocol/script/AuthorizeTaikoForMultihop.s.sol +++ b/packages/protocol/script/shared/AuthorizeTaikoForMultihop.s.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; -import "../test/DeployCapability.sol"; -import "../contracts/signal/SignalService.sol"; +import "../../test/shared/DeployCapability.sol"; +import "../../contracts/shared/signal/SignalService.sol"; contract AuthorizeTaikoForMultihop is DeployCapability { uint256 public privateKey = vm.envUint("PRIVATE_KEY"); diff --git a/packages/protocol/script/SetAddress.s.sol b/packages/protocol/script/shared/SetAddress.s.sol similarity index 91% rename from packages/protocol/script/SetAddress.s.sol rename to packages/protocol/script/shared/SetAddress.s.sol index 8a4f4e04328..422b061f49f 100644 --- a/packages/protocol/script/SetAddress.s.sol +++ b/packages/protocol/script/shared/SetAddress.s.sol @@ -1,10 +1,10 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "forge-std/src/Script.sol"; import "forge-std/src/console2.sol"; -import "../contracts/common/AddressManager.sol"; +import "../../contracts/shared/common/AddressManager.sol"; contract SetAddress is Script { uint256 public adminPrivateKey = vm.envUint("PRIVATE_KEY"); diff --git a/packages/protocol/script/SetRemoteBridgeSuites.s.sol b/packages/protocol/script/shared/SetRemoteBridgeSuites.s.sol similarity index 96% rename from packages/protocol/script/SetRemoteBridgeSuites.s.sol rename to packages/protocol/script/shared/SetRemoteBridgeSuites.s.sol index 03a65c7b79f..5240e503602 100644 --- a/packages/protocol/script/SetRemoteBridgeSuites.s.sol +++ b/packages/protocol/script/shared/SetRemoteBridgeSuites.s.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; -import "../test/DeployCapability.sol"; +import "../../test/shared/DeployCapability.sol"; contract SetRemoteBridgeSuites is DeployCapability { uint256 public privateKey = vm.envUint("PRIVATE_KEY"); diff --git a/packages/protocol/script/upgrade/UpgradeAddressManager.s.sol b/packages/protocol/script/upgrade/UpgradeAddressManager.s.sol deleted file mode 100644 index 7836043b2ef..00000000000 --- a/packages/protocol/script/upgrade/UpgradeAddressManager.s.sol +++ /dev/null @@ -1,13 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; - -import "forge-std/src/Script.sol"; -import "forge-std/src/console2.sol"; -import "../../contracts/common/AddressManager.sol"; -import "./UpgradeScript.s.sol"; - -contract UpgradeAddressManager is UpgradeScript { - function run() external setUp { - upgrade("AddressManager", address(new AddressManager())); - } -} diff --git a/packages/protocol/script/upgrade/UpgradeBridge.s.sol b/packages/protocol/script/upgrade/UpgradeBridge.s.sol deleted file mode 100644 index ccd9265ec41..00000000000 --- a/packages/protocol/script/upgrade/UpgradeBridge.s.sol +++ /dev/null @@ -1,13 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; - -import "forge-std/src/Script.sol"; -import "forge-std/src/console2.sol"; -import "../../contracts/bridge/Bridge.sol"; -import "./UpgradeScript.s.sol"; - -contract UpgradeBridge is UpgradeScript { - function run() external setUp { - upgrade("Bridge", address(new Bridge())); - } -} diff --git a/packages/protocol/script/upgrade/UpgradeERC1155Vault.s.sol b/packages/protocol/script/upgrade/UpgradeERC1155Vault.s.sol deleted file mode 100644 index 94977d34fd7..00000000000 --- a/packages/protocol/script/upgrade/UpgradeERC1155Vault.s.sol +++ /dev/null @@ -1,13 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; - -import "forge-std/src/Script.sol"; -import "forge-std/src/console2.sol"; -import "../../contracts/tokenvault/ERC1155Vault.sol"; -import "./UpgradeScript.s.sol"; - -contract UpgradeERC1155Vault is UpgradeScript { - function run() external setUp { - upgrade("ERC1155Vault", address(new ERC1155Vault())); - } -} diff --git a/packages/protocol/script/upgrade/UpgradeERC20Vault.s.sol b/packages/protocol/script/upgrade/UpgradeERC20Vault.s.sol deleted file mode 100644 index 7e15feda859..00000000000 --- a/packages/protocol/script/upgrade/UpgradeERC20Vault.s.sol +++ /dev/null @@ -1,13 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; - -import "forge-std/src/Script.sol"; -import "forge-std/src/console2.sol"; -import "../../contracts/tokenvault/ERC20Vault.sol"; -import "./UpgradeScript.s.sol"; - -contract UpgradeERC20Vault is UpgradeScript { - function run() external setUp { - upgrade("ERC20Vault", address(new ERC20Vault())); - } -} diff --git a/packages/protocol/script/upgrade/UpgradeERC721Vault.s.sol b/packages/protocol/script/upgrade/UpgradeERC721Vault.s.sol deleted file mode 100644 index dd7d053f28a..00000000000 --- a/packages/protocol/script/upgrade/UpgradeERC721Vault.s.sol +++ /dev/null @@ -1,13 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; - -import "forge-std/src/Script.sol"; -import "forge-std/src/console2.sol"; -import "../../contracts/tokenvault/ERC721Vault.sol"; -import "./UpgradeScript.s.sol"; - -contract UpgradeERC721Vault is UpgradeScript { - function run() external setUp { - upgrade("ERC721Vault", address(new ERC721Vault())); - } -} diff --git a/packages/protocol/script/upgrade/UpgradeGuardianProver.s.sol b/packages/protocol/script/upgrade/UpgradeGuardianProver.s.sol deleted file mode 100644 index 0065cf2487b..00000000000 --- a/packages/protocol/script/upgrade/UpgradeGuardianProver.s.sol +++ /dev/null @@ -1,13 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; - -import "forge-std/src/Script.sol"; -import "forge-std/src/console2.sol"; -import "../../contracts/L1/provers/GuardianProver.sol"; -import "./UpgradeScript.s.sol"; - -contract UpgradeGuardianProver is UpgradeScript { - function run() external setUp { - upgrade("GuardianProver", address(new GuardianProver())); - } -} diff --git a/packages/protocol/script/upgrade/UpgradeProverSet.s.sol b/packages/protocol/script/upgrade/UpgradeProverSet.s.sol deleted file mode 100644 index c725614e597..00000000000 --- a/packages/protocol/script/upgrade/UpgradeProverSet.s.sol +++ /dev/null @@ -1,13 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; - -import "forge-std/src/Script.sol"; -import "forge-std/src/console2.sol"; -import "../../contracts/team/proving/ProverSet.sol"; -import "./UpgradeScript.s.sol"; - -contract UpgradeProverSet is UpgradeScript { - function run() external setUp { - upgrade("ProverSet", address(new ProverSet())); - } -} diff --git a/packages/protocol/script/upgrade/UpgradeRisc0Verifier.s.sol b/packages/protocol/script/upgrade/UpgradeRisc0Verifier.s.sol deleted file mode 100644 index 7276db5d4dd..00000000000 --- a/packages/protocol/script/upgrade/UpgradeRisc0Verifier.s.sol +++ /dev/null @@ -1,14 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; - -import "forge-std/src/Script.sol"; -import "forge-std/src/console2.sol"; - -import "./UpgradeScript.s.sol"; -import "../../contracts/verifiers/Risc0Verifier.sol"; - -contract UpgradeRisc0Verifier is UpgradeScript { - function run() external setUp { - upgrade("Risc0Verifier", address(new Risc0Verifier())); - } -} diff --git a/packages/protocol/script/upgrade/UpgradeScript.s.sol b/packages/protocol/script/upgrade/UpgradeScript.s.sol deleted file mode 100644 index ef3cb45cc25..00000000000 --- a/packages/protocol/script/upgrade/UpgradeScript.s.sol +++ /dev/null @@ -1,32 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; - -import "@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol"; - -import "forge-std/src/console2.sol"; -import "forge-std/src/Script.sol"; - -contract UpgradeScript is Script { - uint256 public privateKey = vm.envUint("PRIVATE_KEY"); - address public proxyAddress = vm.envAddress("PROXY_ADDRESS"); - - UUPSUpgradeable proxy; - - modifier setUp() { - require(privateKey != 0, "PRIVATE_KEY not set"); - require(proxyAddress != address(0), "PROXY_ADDRESS not set"); - - proxy = UUPSUpgradeable(payable(proxyAddress)); - vm.startBroadcast(privateKey); - - _; - - vm.stopBroadcast(); - } - - function upgrade(string memory name, address newImpl) public { - console2.log("Upgrading", name, proxyAddress); - proxy.upgradeTo(newImpl); - console2.log("Upgraded", proxyAddress, "to", newImpl); - } -} diff --git a/packages/protocol/script/upgrade/UpgradeSignalService.s.sol b/packages/protocol/script/upgrade/UpgradeSignalService.s.sol deleted file mode 100644 index f0b9ca7e69e..00000000000 --- a/packages/protocol/script/upgrade/UpgradeSignalService.s.sol +++ /dev/null @@ -1,13 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; - -import "forge-std/src/Script.sol"; -import "forge-std/src/console2.sol"; -import "../../contracts/signal/SignalService.sol"; -import "./UpgradeScript.s.sol"; - -contract UpgradeSignalService is UpgradeScript { - function run() external setUp { - upgrade("SignalService", address(new SignalService())); - } -} diff --git a/packages/protocol/script/upgrade/UpgradeTaikoL1.s.sol b/packages/protocol/script/upgrade/UpgradeTaikoL1.s.sol deleted file mode 100644 index c0472ab2cb1..00000000000 --- a/packages/protocol/script/upgrade/UpgradeTaikoL1.s.sol +++ /dev/null @@ -1,14 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; - -import "forge-std/src/Script.sol"; -import "forge-std/src/console2.sol"; - -import "../../contracts/hekla/HeklaTaikoL1.sol"; -import "./UpgradeScript.s.sol"; - -contract UpgradeTaikoL1 is UpgradeScript { - function run() external setUp { - upgrade("HeklaTaikoL1", address(new HeklaTaikoL1())); - } -} diff --git a/packages/protocol/script/upgrade/UpgradeTierProvider.s.sol b/packages/protocol/script/upgrade/UpgradeTierProvider.s.sol deleted file mode 100644 index 4b6d9b03fba..00000000000 --- a/packages/protocol/script/upgrade/UpgradeTierProvider.s.sol +++ /dev/null @@ -1,19 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; - -import "../../test/DeployCapability.sol"; -import "../../test/L1/TestTierProvider.sol"; - -contract UpgradeTierProvider is DeployCapability { - uint256 public privateKey = vm.envUint("PRIVATE_KEY"); - address public addressManager = vm.envAddress("ADDRESS_MANAGER_ADDRESS"); - - function run() external { - vm.startBroadcast(privateKey); - address impl = address(new TestTierProvider()); - AddressManager(addressManager).setAddress(uint64(block.chainid), "tier_provider", impl); - vm.stopBroadcast(); - console2.log("> tier_provider@", addressManager); - console2.log("\t addr : ", impl); - } -} diff --git a/packages/protocol/script/upgrade_to.sh b/packages/protocol/script/upgrade_to.sh deleted file mode 100755 index 59c920490ff..00000000000 --- a/packages/protocol/script/upgrade_to.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -set -e -: "${FORK_URL:=http://localhost:8545}" - -forge script script/upgrade/Upgrade$CONTRACT.s.sol:Upgrade$CONTRACT \ - --fork-url $FORK_URL \ - -vvvvv \ - --broadcast \ - --ffi \ diff --git a/packages/protocol/genesis/GenerateGenesis.g.sol b/packages/protocol/test/genesis/GenerateGenesis.g.sol similarity index 91% rename from packages/protocol/genesis/GenerateGenesis.g.sol rename to packages/protocol/test/genesis/GenerateGenesis.g.sol index 81664dc4b11..4140409b79d 100644 --- a/packages/protocol/genesis/GenerateGenesis.g.sol +++ b/packages/protocol/test/genesis/GenerateGenesis.g.sol @@ -1,25 +1,25 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "forge-std/src/console2.sol"; import "forge-std/src/StdJson.sol"; import "forge-std/src/Test.sol"; -import "../contracts/common/AddressManager.sol"; -import "../contracts/bridge/Bridge.sol"; -import "../contracts/tokenvault/ERC1155Vault.sol"; -import "../contracts/tokenvault/ERC20Vault.sol"; -import "../contracts/tokenvault/ERC721Vault.sol"; -import "../contracts/signal/SignalService.sol"; -import "../contracts/L2/TaikoL2.sol"; -import "../test/common/erc20/RegularERC20.sol"; +import "../../contracts/shared/common/AddressManager.sol"; +import "../../contracts/shared/bridge/Bridge.sol"; +import "../../contracts/shared/tokenvault/ERC1155Vault.sol"; +import "../../contracts/shared/tokenvault/ERC20Vault.sol"; +import "../../contracts/shared/tokenvault/ERC721Vault.sol"; +import "../../contracts/shared/signal/SignalService.sol"; +import "../../contracts/layer2/based/TaikoL2.sol"; +import "../shared/token/RegularERC20.sol"; contract TestGenerateGenesis is Test, AddressResolver { using stdJson for string; string private configJSON = - vm.readFile(string.concat(vm.projectRoot(), "/deployments/genesis_config.json")); + vm.readFile(string.concat(vm.projectRoot(), "/test/genesis/data/genesis_config.json")); string private genesisAllocJSON = - vm.readFile(string.concat(vm.projectRoot(), "/deployments/genesis_alloc.json")); + vm.readFile(string.concat(vm.projectRoot(), "/test/genesis/data/genesis_alloc.json")); address private contractOwner = configJSON.readAddress(".contractOwner"); uint256 private l1ChainId = configJSON.readUint(".l1ChainId"); @@ -272,7 +272,11 @@ contract TestGenerateGenesis is Test, AddressResolver { assertEq(regularERC20.symbol(), "RGL"); } - function getPredeployedContractAddress(string memory contractName) private view returns (address) { + function getPredeployedContractAddress(string memory contractName) + private + view + returns (address) + { return configJSON.readAddress(string.concat(".contractAddresses.", contractName)); } @@ -284,20 +288,11 @@ contract TestGenerateGenesis is Test, AddressResolver { assertEq(address(contractAddress).code, vm.parseBytes(deployedCode)); } - function checkProxyImplementation( - string memory proxyName - ) - private - { - return checkProxyImplementation(proxyName, contractOwner); + function checkProxyImplementation(string memory proxyName) private { + return checkProxyImplementation(proxyName, contractOwner); } - function checkProxyImplementation( - string memory proxyName, - address owner - ) - private - { + function checkProxyImplementation(string memory proxyName, address owner) private { vm.startPrank(owner); // address contractAddress = getPredeployedContractAddress(contractName); address proxyAddress = getPredeployedContractAddress(proxyName); diff --git a/packages/protocol/test/genesis/data/genesis_config.js b/packages/protocol/test/genesis/data/genesis_config.js new file mode 100644 index 00000000000..df60b5b536f --- /dev/null +++ b/packages/protocol/test/genesis/data/genesis_config.js @@ -0,0 +1,61 @@ +"use strict"; +const ADDRESS_LENGTH = 40; + +module.exports = { + // Owner address of the pre-deployed L2 contracts. + contractOwner: "0xDf08F82De32B8d460adbE8D72043E3a7e25A3B39", + l1ChainId: 1, + // Chain ID of the Taiko L2 network. + chainId: 167, + // Account address and pre-mint ETH amount as key-value pairs. + seedAccounts: [ + { "0xDf08F82De32B8d460adbE8D72043E3a7e25A3B39": 1000 }, + { "0x79fcdef22feed20eddacbb2587640e45491b757f": 1000 }, + ], + // Owner Chain ID, Security Council, and Timelock Controller + l1ChainId: 31337, + ownerSecurityCouncil: "0xDf08F82De32B8d460adbE8D72043E3a7e25A3B39", + ownerTimelockController: "0xDf08F82De32B8d460adbE8D72043E3a7e25A3B39", + get contractAddresses() { + return { + // ============ Implementations ============ + // Shared Contracts + BridgeImpl: getConstantAddress(`0${this.chainId}`, 1), + ERC20VaultImpl: getConstantAddress(`0${this.chainId}`, 2), + ERC721VaultImpl: getConstantAddress(`0${this.chainId}`, 3), + ERC1155VaultImpl: getConstantAddress(`0${this.chainId}`, 4), + SignalServiceImpl: getConstantAddress(`0${this.chainId}`, 5), + SharedAddressManagerImpl: getConstantAddress(`0${this.chainId}`, 6), + BridgedERC20Impl: getConstantAddress(`0${this.chainId}`, 10096), + BridgedERC721Impl: getConstantAddress(`0${this.chainId}`, 10097), + BridgedERC1155Impl: getConstantAddress(`0${this.chainId}`, 10098), + RegularERC20: getConstantAddress(`0${this.chainId}`, 10099), + // Rollup Contracts + TaikoL2Impl: getConstantAddress(`0${this.chainId}`, 10001), + RollupAddressManagerImpl: getConstantAddress(`0${this.chainId}`, 10002), + // ============ Proxies ============ + // Shared Contracts + Bridge: getConstantAddress(this.chainId, 1), + ERC20Vault: getConstantAddress(this.chainId, 2), + ERC721Vault: getConstantAddress(this.chainId, 3), + ERC1155Vault: getConstantAddress(this.chainId, 4), + SignalService: getConstantAddress(this.chainId, 5), + SharedAddressManager: getConstantAddress(this.chainId, 6), + // Rollup Contracts + TaikoL2: getConstantAddress(this.chainId, 10001), + RollupAddressManager: getConstantAddress(this.chainId, 10002), + }; + }, + // L2 EIP-1559 baseFee calculation related fields. + param1559: { + gasExcess: 1, + }, + // Option to pre-deploy an ERC-20 token. + predeployERC20: true, +}; + +function getConstantAddress(prefix, suffix) { + return `0x${prefix}${"0".repeat( + ADDRESS_LENGTH - String(prefix).length - String(suffix).length, + )}${suffix}`; +} diff --git a/packages/protocol/utils/generate_genesis/erc20.ts b/packages/protocol/test/genesis/generate/erc20.ts similarity index 97% rename from packages/protocol/utils/generate_genesis/erc20.ts rename to packages/protocol/test/genesis/generate/erc20.ts index 1d08dd69ec1..d85c266c1e6 100644 --- a/packages/protocol/utils/generate_genesis/erc20.ts +++ b/packages/protocol/test/genesis/generate/erc20.ts @@ -1,7 +1,7 @@ import { ethers } from "ethers"; import { Result } from "./interface"; const path = require("path"); -const ARTIFACTS_PATH = path.join(__dirname, "../../out"); +const ARTIFACTS_PATH = path.join(__dirname, "../../../out/layer2"); const { computeStorageSlots, getStorageLayout } = require("./utils"); export const TOKEN_NAME = "RegularERC20"; diff --git a/packages/protocol/utils/generate_genesis/main.ts b/packages/protocol/test/genesis/generate/generate.ts similarity index 82% rename from packages/protocol/utils/generate_genesis/main.ts rename to packages/protocol/test/genesis/generate/generate.ts index a792c95a1c5..2462397624c 100644 --- a/packages/protocol/utils/generate_genesis/main.ts +++ b/packages/protocol/test/genesis/generate/generate.ts @@ -4,20 +4,11 @@ const path = require("path"); const { ethers } = require("ethers"); const { deployTaikoL2 } = require("./taikoL2"); const { deployERC20 } = require("./erc20"); +const config: Config = require("../data/genesis_config.js"); // Generate a L2 genesis JSON based on the given configurations. // ref: https://docs.soliditylang.org/en/latest/internals/layout_in_storage.html async function main() { - if (process.argv.length < 3) { - throw new Error("missing config json"); - } - - const config: Config = require( - path.isAbsolute(process.argv[2]) - ? process.argv[2] - : path.join(process.cwd(), process.argv[2]), - ); - const contractOwner = config.contractOwner; const chainId = config.chainId; const seedAccounts = config.seedAccounts; @@ -60,16 +51,13 @@ async function main() { result = await deployERC20(config, result); } - const allocSavedPath = path.join( - __dirname, - "../../deployments/genesis_alloc.json", - ); + const allocSavedPath = path.join(__dirname, "../data/genesis_alloc.json"); fs.writeFileSync(allocSavedPath, JSON.stringify(result.alloc, null, 2)); const layoutSavedPath = path.join( __dirname, - "../../deployments/genesis_storage_layout.json", + "../data/genesis_storage_layout.json", ); fs.writeFileSync( @@ -79,7 +67,7 @@ async function main() { const configJsonSavedPath = path.join( __dirname, - "../../deployments/genesis_config.json", + "../data/genesis_config.json", ); fs.writeFileSync(configJsonSavedPath, JSON.stringify(config)); diff --git a/packages/protocol/utils/generate_genesis/interface.ts b/packages/protocol/test/genesis/generate/interface.ts similarity index 100% rename from packages/protocol/utils/generate_genesis/interface.ts rename to packages/protocol/test/genesis/generate/interface.ts diff --git a/packages/protocol/utils/generate_genesis/taikoL2.ts b/packages/protocol/test/genesis/generate/taikoL2.ts similarity index 99% rename from packages/protocol/utils/generate_genesis/taikoL2.ts rename to packages/protocol/test/genesis/generate/taikoL2.ts index 30d33fedd4f..48e7979c010 100644 --- a/packages/protocol/utils/generate_genesis/taikoL2.ts +++ b/packages/protocol/test/genesis/generate/taikoL2.ts @@ -4,7 +4,7 @@ const { ethers } = require("ethers"); // eslint-disable-next-line node/no-extraneous-require const linker = require("solc/linker"); const { computeStorageSlots, getStorageLayout } = require("./utils"); -const ARTIFACTS_PATH = path.join(__dirname, "../../out"); +const ARTIFACTS_PATH = path.join(__dirname, "../../../out/layer2"); const IMPLEMENTATION_SLOT = "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc"; diff --git a/packages/protocol/utils/generate_genesis/utils.ts b/packages/protocol/test/genesis/generate/utils.ts similarity index 99% rename from packages/protocol/utils/generate_genesis/utils.ts rename to packages/protocol/test/genesis/generate/utils.ts index 96e1adcf0f7..c84f98616ac 100644 --- a/packages/protocol/utils/generate_genesis/utils.ts +++ b/packages/protocol/test/genesis/generate/utils.ts @@ -43,7 +43,7 @@ export interface SolidityStorageLayout { export async function getStorageLayout( name: string, ): Promise { - const artifact = require(`../../out/${name}.sol/${name}.json`); + const artifact = require(`../../../out/layer2/${name}.sol/${name}.json`); if (!("storageLayout" in artifact)) { throw new Error(`Storage layout for ${name} not found.`); } diff --git a/packages/protocol/genesis/generate_genesis.test.sh b/packages/protocol/test/genesis/genesis.test.sh similarity index 87% rename from packages/protocol/genesis/generate_genesis.test.sh rename to packages/protocol/test/genesis/genesis.test.sh index 97d3c848dae..a0046e1b91e 100755 --- a/packages/protocol/genesis/generate_genesis.test.sh +++ b/packages/protocol/test/genesis/genesis.test.sh @@ -14,8 +14,8 @@ if ! docker info > /dev/null 2>&1; then exit 1 fi -GENESIS_JSON=$(cd "$(dirname "$DIR/../..")"; pwd)/deployments/genesis.json -TESTNET_CONFIG=$DIR/testnet/docker-compose.yml +GENESIS_JSON="$DIR/data/genesis.json" +TESTNET_CONFIG="$DIR/testnet/docker-compose.yml" touch "$GENESIS_JSON" @@ -48,13 +48,13 @@ echo ' echo "Starting generate_genesis tests..." # compile the contracts to get latest bytecode -rm -rf out && pnpm compile +rm -rf out && pnpm compile:genesis # run the task -pnpm run generate:genesis $DIR/test_config.js +pnpm run genesis:gen $DIR/test_config.js # generate complete genesis json -cat "$DIR"/../deployments/genesis_alloc.json >> "$GENESIS_JSON" +cat "$DIR/data/genesis_alloc.json" >> "$GENESIS_JSON" echo '}' >> "$GENESIS_JSON" @@ -88,11 +88,11 @@ function waitTestNode { waitTestNode http://localhost:18545 -forge test \ +FOUNDRY_PROFILE=genesis forge test \ -vvv \ --gas-report \ --fork-url http://localhost:18545 \ --fork-retry-backoff 120 \ --no-storage-caching \ - --match-path genesis/*.g.sol \ + --match-path test/genesis/GenerateGenesis.g.sol \ --block-gas-limit 1000000000 diff --git a/packages/protocol/genesis/mainnet.js b/packages/protocol/test/genesis/mainnet.js similarity index 100% rename from packages/protocol/genesis/mainnet.js rename to packages/protocol/test/genesis/mainnet.js diff --git a/packages/protocol/genesis/test_config.js b/packages/protocol/test/genesis/test_config.js similarity index 99% rename from packages/protocol/genesis/test_config.js rename to packages/protocol/test/genesis/test_config.js index 43637193643..8b67ec687bf 100644 --- a/packages/protocol/genesis/test_config.js +++ b/packages/protocol/test/genesis/test_config.js @@ -110,7 +110,7 @@ module.exports = { }; }, param1559: { - gasExcess: 20000000000, + gasExcess: 0, }, predeployERC20: true, }; diff --git a/packages/protocol/genesis/testnet/docker-compose.yml b/packages/protocol/test/genesis/testnet/docker-compose.yml similarity index 79% rename from packages/protocol/genesis/testnet/docker-compose.yml rename to packages/protocol/test/genesis/testnet/docker-compose.yml index 069d744f363..745f43de926 100644 --- a/packages/protocol/genesis/testnet/docker-compose.yml +++ b/packages/protocol/test/genesis/testnet/docker-compose.yml @@ -1,11 +1,9 @@ -version: "3.9" - services: geth: image: ethereum/client-go:v1.13.14 restart: unless-stopped volumes: - - ../../deployments:/data + - ../data:/data - .:/host ports: - 18545:8545 diff --git a/packages/protocol/genesis/testnet/init_geth.sh b/packages/protocol/test/genesis/testnet/init_geth.sh similarity index 100% rename from packages/protocol/genesis/testnet/init_geth.sh rename to packages/protocol/test/genesis/testnet/init_geth.sh diff --git a/packages/protocol/genesis/testnet/keyfile.json b/packages/protocol/test/genesis/testnet/keyfile.json similarity index 100% rename from packages/protocol/genesis/testnet/keyfile.json rename to packages/protocol/test/genesis/testnet/keyfile.json diff --git a/packages/protocol/genesis/testnet/password b/packages/protocol/test/genesis/testnet/password similarity index 100% rename from packages/protocol/genesis/testnet/password rename to packages/protocol/test/genesis/testnet/password diff --git a/packages/protocol/test/layer1/TaikoL1Test.sol b/packages/protocol/test/layer1/TaikoL1Test.sol new file mode 100644 index 00000000000..d83f508cf0e --- /dev/null +++ b/packages/protocol/test/layer1/TaikoL1Test.sol @@ -0,0 +1,15 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.24; + +import "../../contracts/layer1/based/TaikoL1.sol"; +import "../../contracts/layer1/token/TaikoToken.sol"; +import "../../contracts/layer1/verifiers/SgxVerifier.sol"; +import "../../contracts/layer1/verifiers/SP1Verifier.sol"; +import "../../contracts/layer1/verifiers/Risc0Verifier.sol"; +import "../../contracts/layer1/provers/GuardianProver.sol"; +import "../../contracts/layer1/team/airdrop/ERC20Airdrop.sol"; +import "../../contracts/shared/bridge/QuotaManager.sol"; +import "../layer1/based/TestTierProvider.sol"; +import "../shared/TaikoTest.sol"; + +abstract contract TaikoL1Test is TaikoTest { } diff --git a/packages/protocol/test/automata-attestation/AutomataDcapV3AttestationTest.t.sol b/packages/protocol/test/layer1/automata-attestation/AutomataDcapV3AttestationTest.t.sol similarity index 99% rename from packages/protocol/test/automata-attestation/AutomataDcapV3AttestationTest.t.sol rename to packages/protocol/test/layer1/automata-attestation/AutomataDcapV3AttestationTest.t.sol index 6ec3632126e..148cae8a13f 100644 --- a/packages/protocol/test/automata-attestation/AutomataDcapV3AttestationTest.t.sol +++ b/packages/protocol/test/layer1/automata-attestation/AutomataDcapV3AttestationTest.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "forge-std/src/Test.sol"; import "forge-std/src/console.sol"; @@ -10,7 +10,7 @@ contract AutomataDcapV3AttestationTest is Test, AttestationBase { using BytesUtils for bytes; using stdJson for string; - string internal v3QuoteJsonPath = "/test/automata-attestation/assets/0923/v3quote.json"; + string internal v3QuoteJsonPath = "/test/layer1/automata-attestation/assets/0923/v3quote.json"; function setUp() public { // Call the AttestationBase init setup diff --git a/packages/protocol/test/automata-attestation/assets/0424/tcb_00706A100000.json b/packages/protocol/test/layer1/automata-attestation/assets/0424/tcb_00706A100000.json similarity index 100% rename from packages/protocol/test/automata-attestation/assets/0424/tcb_00706A100000.json rename to packages/protocol/test/layer1/automata-attestation/assets/0424/tcb_00706A100000.json diff --git a/packages/protocol/test/automata-attestation/assets/0424/tcb_00906ED50000.json b/packages/protocol/test/layer1/automata-attestation/assets/0424/tcb_00906ED50000.json similarity index 100% rename from packages/protocol/test/automata-attestation/assets/0424/tcb_00906ED50000.json rename to packages/protocol/test/layer1/automata-attestation/assets/0424/tcb_00906ED50000.json diff --git a/packages/protocol/test/automata-attestation/assets/0424/tcb_00A067110000.json b/packages/protocol/test/layer1/automata-attestation/assets/0424/tcb_00A067110000.json similarity index 100% rename from packages/protocol/test/automata-attestation/assets/0424/tcb_00A067110000.json rename to packages/protocol/test/layer1/automata-attestation/assets/0424/tcb_00A067110000.json diff --git a/packages/protocol/test/automata-attestation/assets/0424/tcb_30606a000000.json b/packages/protocol/test/layer1/automata-attestation/assets/0424/tcb_30606a000000.json similarity index 100% rename from packages/protocol/test/automata-attestation/assets/0424/tcb_30606a000000.json rename to packages/protocol/test/layer1/automata-attestation/assets/0424/tcb_30606a000000.json diff --git a/packages/protocol/test/automata-attestation/assets/0923/identity.json b/packages/protocol/test/layer1/automata-attestation/assets/0923/identity.json similarity index 100% rename from packages/protocol/test/automata-attestation/assets/0923/identity.json rename to packages/protocol/test/layer1/automata-attestation/assets/0923/identity.json diff --git a/packages/protocol/test/automata-attestation/assets/0923/tcb_00606A000000.json b/packages/protocol/test/layer1/automata-attestation/assets/0923/tcb_00606A000000.json similarity index 100% rename from packages/protocol/test/automata-attestation/assets/0923/tcb_00606A000000.json rename to packages/protocol/test/layer1/automata-attestation/assets/0923/tcb_00606A000000.json diff --git a/packages/protocol/test/automata-attestation/assets/0923/v3quote.json b/packages/protocol/test/layer1/automata-attestation/assets/0923/v3quote.json similarity index 100% rename from packages/protocol/test/automata-attestation/assets/0923/v3quote.json rename to packages/protocol/test/layer1/automata-attestation/assets/0923/v3quote.json diff --git a/packages/protocol/test/automata-attestation/assets/complex.json b/packages/protocol/test/layer1/automata-attestation/assets/complex.json similarity index 100% rename from packages/protocol/test/automata-attestation/assets/complex.json rename to packages/protocol/test/layer1/automata-attestation/assets/complex.json diff --git a/packages/protocol/test/automata-attestation/common/AttestationBase.t.sol b/packages/protocol/test/layer1/automata-attestation/common/AttestationBase.t.sol similarity index 93% rename from packages/protocol/test/automata-attestation/common/AttestationBase.t.sol rename to packages/protocol/test/layer1/automata-attestation/common/AttestationBase.t.sol index df72befa33a..f517f7bb06a 100644 --- a/packages/protocol/test/automata-attestation/common/AttestationBase.t.sol +++ b/packages/protocol/test/layer1/automata-attestation/common/AttestationBase.t.sol @@ -1,27 +1,28 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "forge-std/src/Test.sol"; import "forge-std/src/console.sol"; import "forge-std/src/StdJson.sol"; -import { P256Verifier } from "@p256-verifier/contracts/P256Verifier.sol"; - import "@optimism/packages/contracts-bedrock/src/libraries/Bytes.sol"; +import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol"; +import { P256Verifier } from "@p256-verifier/contracts/P256Verifier.sol"; -import "../../../contracts/verifiers/SgxVerifier.sol"; +import "../../../../contracts/layer1/verifiers/SgxVerifier.sol"; import { AutomataDcapV3Attestation } from - "../../../contracts/automata-attestation/AutomataDcapV3Attestation.sol"; -import { SigVerifyLib } from "../../../contracts/automata-attestation/utils/SigVerifyLib.sol"; -import { PEMCertChainLib } from "../../../contracts/automata-attestation/lib/PEMCertChainLib.sol"; -import { V3Struct } from "../../../contracts/automata-attestation/lib/QuoteV3Auth/V3Struct.sol"; -import { BytesUtils } from "../../../contracts/automata-attestation/utils/BytesUtils.sol"; + "../../../../contracts/layer1/automata-attestation/AutomataDcapV3Attestation.sol"; +import { SigVerifyLib } from + "../../../../contracts/layer1/automata-attestation/utils/SigVerifyLib.sol"; +import { PEMCertChainLib } from + "../../../../contracts/layer1/automata-attestation/lib/PEMCertChainLib.sol"; +import { V3Struct } from + "../../../../contracts/layer1/automata-attestation/lib/QuoteV3Auth/V3Struct.sol"; +import { BytesUtils } from "../../../../contracts/layer1/automata-attestation/utils/BytesUtils.sol"; import { Base64 } from "solady/src/utils/Base64.sol"; import "../utils/DcapTestUtils.t.sol"; import "../utils/V3QuoteParseUtils.t.sol"; -import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol"; - contract AttestationBase is Test, DcapTestUtils, V3QuoteParseUtils { using BytesUtils for bytes; using stdJson for string; @@ -34,13 +35,13 @@ contract AttestationBase is Test, DcapTestUtils, V3QuoteParseUtils { // ref: https://github.com/daimo-eth/p256-verifier //string internal rpcUrl = vm.envString("RPC_URL"); string[] internal tcbInfoPaths = [ - "/test/automata-attestation/assets/0923/tcb_00606A000000.json", - "/test/automata-attestation/assets/0424/tcb_00A067110000.json", - "/test/automata-attestation/assets/0424/tcb_00906ED50000.json", - "/test/automata-attestation/assets/0424/tcb_30606a000000.json", - "/test/automata-attestation/assets/0424/tcb_00706A100000.json" + "/test/layer1/automata-attestation/assets/0923/tcb_00606A000000.json", + "/test/layer1/automata-attestation/assets/0424/tcb_00A067110000.json", + "/test/layer1/automata-attestation/assets/0424/tcb_00906ED50000.json", + "/test/layer1/automata-attestation/assets/0424/tcb_30606a000000.json", + "/test/layer1/automata-attestation/assets/0424/tcb_00706A100000.json" ]; - string internal idPath = "/test/automata-attestation/assets/0923/identity.json"; + string internal idPath = "/test/layer1/automata-attestation/assets/0923/identity.json"; address constant admin = address(1); address constant user = 0x0926b716f6aEF52F9F3C3474A2846e1Bf1ACedf6; bytes32 mrEnclave = 0x46049af725ec3986eeb788693df7bc5f14d3f2705106a19cd09b9d89237db1a0; diff --git a/packages/protocol/test/automata-attestation/utils/DcapTestUtils.t.sol b/packages/protocol/test/layer1/automata-attestation/utils/DcapTestUtils.t.sol similarity index 96% rename from packages/protocol/test/automata-attestation/utils/DcapTestUtils.t.sol rename to packages/protocol/test/layer1/automata-attestation/utils/DcapTestUtils.t.sol index 4e0db7d01df..7ffcf221617 100644 --- a/packages/protocol/test/automata-attestation/utils/DcapTestUtils.t.sol +++ b/packages/protocol/test/layer1/automata-attestation/utils/DcapTestUtils.t.sol @@ -1,9 +1,12 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; -import { TCBInfoStruct } from "../../../contracts/automata-attestation/lib/TCBInfoStruct.sol"; -import { EnclaveIdStruct } from "../../../contracts/automata-attestation/lib/EnclaveIdStruct.sol"; -import { V3Struct } from "../../../contracts/automata-attestation/lib/QuoteV3Auth/V3Struct.sol"; +import { TCBInfoStruct } from + "../../../../contracts/layer1/automata-attestation/lib/TCBInfoStruct.sol"; +import { EnclaveIdStruct } from + "../../../../contracts/layer1/automata-attestation/lib/EnclaveIdStruct.sol"; +import { V3Struct } from + "../../../../contracts/layer1/automata-attestation/lib/QuoteV3Auth/V3Struct.sol"; import { JSONParserLib } from "solady/src/utils/JSONParserLib.sol"; import { LibString } from "solady/src/utils/LibString.sol"; diff --git a/packages/protocol/test/automata-attestation/utils/V3QuoteParseUtils.t.sol b/packages/protocol/test/layer1/automata-attestation/utils/V3QuoteParseUtils.t.sol similarity index 93% rename from packages/protocol/test/automata-attestation/utils/V3QuoteParseUtils.t.sol rename to packages/protocol/test/layer1/automata-attestation/utils/V3QuoteParseUtils.t.sol index e85886a20ea..f27862eef7b 100644 --- a/packages/protocol/test/automata-attestation/utils/V3QuoteParseUtils.t.sol +++ b/packages/protocol/test/layer1/automata-attestation/utils/V3QuoteParseUtils.t.sol @@ -1,11 +1,14 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; -import { V3Struct } from "../../../contracts/automata-attestation/lib/QuoteV3Auth/V3Struct.sol"; -import { V3Parser } from "../../../contracts/automata-attestation/lib/QuoteV3Auth/V3Parser.sol"; +import { V3Struct } from + "../../../../contracts/layer1/automata-attestation/lib/QuoteV3Auth/V3Struct.sol"; +import { V3Parser } from + "../../../../contracts/layer1/automata-attestation/lib/QuoteV3Auth/V3Parser.sol"; import { IPEMCertChainLib } from - "../../../contracts/automata-attestation/lib/interfaces/IPEMCertChainLib.sol"; -import { PEMCertChainLib } from "../../../contracts/automata-attestation/lib/PEMCertChainLib.sol"; + "../../../../contracts/layer1/automata-attestation/lib/interfaces/IPEMCertChainLib.sol"; +import { PEMCertChainLib } from + "../../../../contracts/layer1/automata-attestation/lib/PEMCertChainLib.sol"; import { Base64 } from "solady/src/utils/Base64.sol"; import { JSONParserLib } from "solady/src/utils/JSONParserLib.sol"; import { LibString } from "solady/src/utils/LibString.sol"; diff --git a/packages/protocol/test/L1/GuardianProver1.t.sol b/packages/protocol/test/layer1/based/GuardianProver1.t.sol similarity index 95% rename from packages/protocol/test/L1/GuardianProver1.t.sol rename to packages/protocol/test/layer1/based/GuardianProver1.t.sol index d62b0fceb8c..3f8a7705e22 100644 --- a/packages/protocol/test/L1/GuardianProver1.t.sol +++ b/packages/protocol/test/layer1/based/GuardianProver1.t.sol @@ -1,7 +1,8 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; -import "../TaikoTest.sol"; +import "../../../contracts/layer1/provers/GuardianProver.sol"; +import "../../shared/TaikoTest.sol"; contract DummyGuardianProver is GuardianProver { uint256 public operationId; diff --git a/packages/protocol/test/L1/GuardianProver2.t.sol b/packages/protocol/test/layer1/based/GuardianProver2.t.sol similarity index 95% rename from packages/protocol/test/L1/GuardianProver2.t.sol rename to packages/protocol/test/layer1/based/GuardianProver2.t.sol index 29f741e3819..3fe8ee23cd3 100644 --- a/packages/protocol/test/L1/GuardianProver2.t.sol +++ b/packages/protocol/test/layer1/based/GuardianProver2.t.sol @@ -1,7 +1,8 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; -import "../L1/TaikoL1TestBase.sol"; +import "../../../contracts/layer1/provers/GuardianProver.sol"; +import "./TaikoL1TestBase.sol"; /// @author Kirk Baird contract TestGuardianProver2 is TaikoL1TestBase { diff --git a/packages/protocol/test/L1/TaikoL1.t.sol b/packages/protocol/test/layer1/based/TaikoL1.t.sol similarity index 99% rename from packages/protocol/test/L1/TaikoL1.t.sol rename to packages/protocol/test/layer1/based/TaikoL1.t.sol index 9450e4066aa..39918e9d14a 100644 --- a/packages/protocol/test/L1/TaikoL1.t.sol +++ b/packages/protocol/test/layer1/based/TaikoL1.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "./TaikoL1TestBase.sol"; @@ -20,7 +20,7 @@ contract Verifier { } } -contract TaikoL1Test is TaikoL1TestBase { +contract TaikoL1Tests is TaikoL1TestBase { function deployTaikoL1() internal override returns (TaikoL1) { return TaikoL1( payable( diff --git a/packages/protocol/test/L1/TaikoL1LibProvingWithTiers.t.sol b/packages/protocol/test/layer1/based/TaikoL1LibProvingWithTiers.t.sol similarity index 99% rename from packages/protocol/test/L1/TaikoL1LibProvingWithTiers.t.sol rename to packages/protocol/test/layer1/based/TaikoL1LibProvingWithTiers.t.sol index e288b5aa73a..cbac7074a58 100644 --- a/packages/protocol/test/L1/TaikoL1LibProvingWithTiers.t.sol +++ b/packages/protocol/test/layer1/based/TaikoL1LibProvingWithTiers.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "./TaikoL1TestBase.sol"; diff --git a/packages/protocol/test/L1/TaikoL1TestBase.sol b/packages/protocol/test/layer1/based/TaikoL1TestBase.sol similarity index 99% rename from packages/protocol/test/L1/TaikoL1TestBase.sol rename to packages/protocol/test/layer1/based/TaikoL1TestBase.sol index ac901d03159..f3620aaad02 100644 --- a/packages/protocol/test/L1/TaikoL1TestBase.sol +++ b/packages/protocol/test/layer1/based/TaikoL1TestBase.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; -import "../TaikoTest.sol"; +import "../TaikoL1Test.sol"; abstract contract TaikoL1TestBase is TaikoTest { AddressManager public addressManager; diff --git a/packages/protocol/test/L1/TaikoL1TestGroup1.t.sol b/packages/protocol/test/layer1/based/TaikoL1TestGroup1.t.sol similarity index 99% rename from packages/protocol/test/L1/TaikoL1TestGroup1.t.sol rename to packages/protocol/test/layer1/based/TaikoL1TestGroup1.t.sol index a43feae8875..7192f3b8e6c 100644 --- a/packages/protocol/test/L1/TaikoL1TestGroup1.t.sol +++ b/packages/protocol/test/layer1/based/TaikoL1TestGroup1.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "./TaikoL1TestGroupBase.sol"; diff --git a/packages/protocol/test/L1/TaikoL1TestGroup10.t.sol b/packages/protocol/test/layer1/based/TaikoL1TestGroup10.t.sol similarity index 98% rename from packages/protocol/test/L1/TaikoL1TestGroup10.t.sol rename to packages/protocol/test/layer1/based/TaikoL1TestGroup10.t.sol index 06a2cc9b6b9..c843b43e60c 100644 --- a/packages/protocol/test/L1/TaikoL1TestGroup10.t.sol +++ b/packages/protocol/test/layer1/based/TaikoL1TestGroup10.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "./TaikoL1TestGroupBase.sol"; diff --git a/packages/protocol/test/L1/TaikoL1TestGroup2.t.sol b/packages/protocol/test/layer1/based/TaikoL1TestGroup2.t.sol similarity index 99% rename from packages/protocol/test/L1/TaikoL1TestGroup2.t.sol rename to packages/protocol/test/layer1/based/TaikoL1TestGroup2.t.sol index 2a6d832040c..9bb5f5cf8a7 100644 --- a/packages/protocol/test/L1/TaikoL1TestGroup2.t.sol +++ b/packages/protocol/test/layer1/based/TaikoL1TestGroup2.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "./TaikoL1TestGroupBase.sol"; diff --git a/packages/protocol/test/L1/TaikoL1TestGroup3.t.sol b/packages/protocol/test/layer1/based/TaikoL1TestGroup3.t.sol similarity index 99% rename from packages/protocol/test/L1/TaikoL1TestGroup3.t.sol rename to packages/protocol/test/layer1/based/TaikoL1TestGroup3.t.sol index 7011d8f03f7..b27ffda2c9e 100644 --- a/packages/protocol/test/L1/TaikoL1TestGroup3.t.sol +++ b/packages/protocol/test/layer1/based/TaikoL1TestGroup3.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "./TaikoL1TestGroupBase.sol"; diff --git a/packages/protocol/test/L1/TaikoL1TestGroup4.t.sol b/packages/protocol/test/layer1/based/TaikoL1TestGroup4.t.sol similarity index 99% rename from packages/protocol/test/L1/TaikoL1TestGroup4.t.sol rename to packages/protocol/test/layer1/based/TaikoL1TestGroup4.t.sol index 5b0b9db0859..c5850ebf3bc 100644 --- a/packages/protocol/test/L1/TaikoL1TestGroup4.t.sol +++ b/packages/protocol/test/layer1/based/TaikoL1TestGroup4.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "./TaikoL1TestGroupBase.sol"; diff --git a/packages/protocol/test/L1/TaikoL1TestGroup5.t.sol b/packages/protocol/test/layer1/based/TaikoL1TestGroup5.t.sol similarity index 99% rename from packages/protocol/test/L1/TaikoL1TestGroup5.t.sol rename to packages/protocol/test/layer1/based/TaikoL1TestGroup5.t.sol index 816d586e649..d6d1a294b2f 100644 --- a/packages/protocol/test/L1/TaikoL1TestGroup5.t.sol +++ b/packages/protocol/test/layer1/based/TaikoL1TestGroup5.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "./TaikoL1TestGroupBase.sol"; diff --git a/packages/protocol/test/L1/TaikoL1TestGroup6.t.sol b/packages/protocol/test/layer1/based/TaikoL1TestGroup6.t.sol similarity index 99% rename from packages/protocol/test/L1/TaikoL1TestGroup6.t.sol rename to packages/protocol/test/layer1/based/TaikoL1TestGroup6.t.sol index 1cdcc161102..15fa6b57fb0 100644 --- a/packages/protocol/test/L1/TaikoL1TestGroup6.t.sol +++ b/packages/protocol/test/layer1/based/TaikoL1TestGroup6.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "./TaikoL1TestGroupBase.sol"; diff --git a/packages/protocol/test/L1/TaikoL1TestGroup7.t.sol b/packages/protocol/test/layer1/based/TaikoL1TestGroup7.t.sol similarity index 99% rename from packages/protocol/test/L1/TaikoL1TestGroup7.t.sol rename to packages/protocol/test/layer1/based/TaikoL1TestGroup7.t.sol index 1bc3aa48ca5..d255a89328d 100644 --- a/packages/protocol/test/L1/TaikoL1TestGroup7.t.sol +++ b/packages/protocol/test/layer1/based/TaikoL1TestGroup7.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "./TaikoL1TestGroupBase.sol"; diff --git a/packages/protocol/test/L1/TaikoL1TestGroup8.t.sol b/packages/protocol/test/layer1/based/TaikoL1TestGroup8.t.sol similarity index 99% rename from packages/protocol/test/L1/TaikoL1TestGroup8.t.sol rename to packages/protocol/test/layer1/based/TaikoL1TestGroup8.t.sol index e39f923bbf5..ecb34e99b81 100644 --- a/packages/protocol/test/L1/TaikoL1TestGroup8.t.sol +++ b/packages/protocol/test/layer1/based/TaikoL1TestGroup8.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "./TaikoL1TestGroupBase.sol"; diff --git a/packages/protocol/test/L1/TaikoL1TestGroup9.t.sol b/packages/protocol/test/layer1/based/TaikoL1TestGroup9.t.sol similarity index 99% rename from packages/protocol/test/L1/TaikoL1TestGroup9.t.sol rename to packages/protocol/test/layer1/based/TaikoL1TestGroup9.t.sol index 16978612917..e1aa9e67bf8 100644 --- a/packages/protocol/test/L1/TaikoL1TestGroup9.t.sol +++ b/packages/protocol/test/layer1/based/TaikoL1TestGroup9.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "./TaikoL1TestGroupBase.sol"; diff --git a/packages/protocol/test/L1/TaikoL1TestGroupBase.sol b/packages/protocol/test/layer1/based/TaikoL1TestGroupBase.sol similarity index 99% rename from packages/protocol/test/L1/TaikoL1TestGroupBase.sol rename to packages/protocol/test/layer1/based/TaikoL1TestGroupBase.sol index 25a18c1f5a6..8843b39ff8b 100644 --- a/packages/protocol/test/L1/TaikoL1TestGroupBase.sol +++ b/packages/protocol/test/layer1/based/TaikoL1TestGroupBase.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "./TaikoL1TestBase.sol"; diff --git a/packages/protocol/test/L1/TaikoL1testGroupA1.t.sol b/packages/protocol/test/layer1/based/TaikoL1testGroupA1.t.sol similarity index 99% rename from packages/protocol/test/L1/TaikoL1testGroupA1.t.sol rename to packages/protocol/test/layer1/based/TaikoL1testGroupA1.t.sol index a0a95e2227e..1aa4a34452d 100644 --- a/packages/protocol/test/L1/TaikoL1testGroupA1.t.sol +++ b/packages/protocol/test/layer1/based/TaikoL1testGroupA1.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "./TaikoL1TestGroupBase.sol"; diff --git a/packages/protocol/test/L1/TaikoL1testGroupA2.t.sol b/packages/protocol/test/layer1/based/TaikoL1testGroupA2.t.sol similarity index 99% rename from packages/protocol/test/L1/TaikoL1testGroupA2.t.sol rename to packages/protocol/test/layer1/based/TaikoL1testGroupA2.t.sol index 6e7935f31ab..764a3d58b8c 100644 --- a/packages/protocol/test/L1/TaikoL1testGroupA2.t.sol +++ b/packages/protocol/test/layer1/based/TaikoL1testGroupA2.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "./TaikoL1TestGroupBase.sol"; diff --git a/packages/protocol/test/L1/TestTierProvider.sol b/packages/protocol/test/layer1/based/TestTierProvider.sol similarity index 90% rename from packages/protocol/test/L1/TestTierProvider.sol rename to packages/protocol/test/layer1/based/TestTierProvider.sol index 5320fa2dac4..4832486357e 100644 --- a/packages/protocol/test/L1/TestTierProvider.sol +++ b/packages/protocol/test/layer1/based/TestTierProvider.sol @@ -1,10 +1,10 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; -import "../../contracts/common/LibStrings.sol"; -import "../../contracts/L1/tiers/ITierProvider.sol"; -import "../../contracts/L1/tiers/LibTiers.sol"; -import "../../contracts/L1/tiers/ITierRouter.sol"; +import "../../../contracts/shared/common/LibStrings.sol"; +import "../../../contracts/layer1/tiers/ITierProvider.sol"; +import "../../../contracts/layer1/tiers/LibTiers.sol"; +import "../../../contracts/layer1/tiers/ITierRouter.sol"; /// @title TestTierProvider /// @dev Labeled in AddressResolver as "tier_router" diff --git a/packages/protocol/test/team/airdrop/ERC20Airdrop.t.sol b/packages/protocol/test/layer1/team/airdrop/ERC20Airdrop.t.sol similarity index 98% rename from packages/protocol/test/team/airdrop/ERC20Airdrop.t.sol rename to packages/protocol/test/layer1/team/airdrop/ERC20Airdrop.t.sol index c7d769502ed..b96d8454d30 100644 --- a/packages/protocol/test/team/airdrop/ERC20Airdrop.t.sol +++ b/packages/protocol/test/layer1/team/airdrop/ERC20Airdrop.t.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; -import "../../TaikoTest.sol"; import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; +import "../../TaikoL1Test.sol"; contract MockERC20Airdrop is ERC20Airdrop { function _verifyMerkleProof( diff --git a/packages/protocol/test/team/airdrop/MerkleClaimable.t.sol b/packages/protocol/test/layer1/team/airdrop/MerkleClaimable.t.sol similarity index 98% rename from packages/protocol/test/team/airdrop/MerkleClaimable.t.sol rename to packages/protocol/test/layer1/team/airdrop/MerkleClaimable.t.sol index 7f9240bf326..613a34637ce 100644 --- a/packages/protocol/test/team/airdrop/MerkleClaimable.t.sol +++ b/packages/protocol/test/layer1/team/airdrop/MerkleClaimable.t.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; -import "../../TaikoTest.sol"; +import "../../TaikoL1Test.sol"; contract MockMerkleClaimable is MerkleClaimable { function init(uint64 _claimStart, uint64 _claimEnd, bytes32 _merkleRoot) external initializer { diff --git a/packages/protocol/test/team/tokenunlock/TokenUnlock.t.sol b/packages/protocol/test/layer1/team/tokenunlock/TokenUnlock.t.sol similarity index 98% rename from packages/protocol/test/team/tokenunlock/TokenUnlock.t.sol rename to packages/protocol/test/layer1/team/tokenunlock/TokenUnlock.t.sol index 9357524bfc0..d0d22b9a1e0 100644 --- a/packages/protocol/test/team/tokenunlock/TokenUnlock.t.sol +++ b/packages/protocol/test/layer1/team/tokenunlock/TokenUnlock.t.sol @@ -1,9 +1,9 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Votes.sol"; -import "../../TaikoTest.sol"; -import "../../../contracts/team/tokenunlock/TokenUnlock.sol"; +import "../../../shared/TaikoTest.sol"; +import "../../../../contracts/layer1/team/tokenunlock/TokenUnlock.sol"; contract MyERC20 is ERC20, ERC20Votes { constructor(address owner) ERC20("Taiko Token", "TKO") ERC20Permit("Taiko Token") { diff --git a/packages/protocol/test/mocks/MockPlonkVerifier.sol b/packages/protocol/test/layer1/verifiers/MockPlonkVerifier.sol similarity index 96% rename from packages/protocol/test/mocks/MockPlonkVerifier.sol rename to packages/protocol/test/layer1/verifiers/MockPlonkVerifier.sol index dc4fb376275..9ff78e24627 100644 --- a/packages/protocol/test/mocks/MockPlonkVerifier.sol +++ b/packages/protocol/test/layer1/verifiers/MockPlonkVerifier.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "@optimism/packages/contracts-bedrock/src/libraries/Bytes.sol"; diff --git a/packages/protocol/test/verifiers/Risc0Verifier.t.sol b/packages/protocol/test/layer1/verifiers/Risc0Verifier.t.sol similarity index 98% rename from packages/protocol/test/verifiers/Risc0Verifier.t.sol rename to packages/protocol/test/layer1/verifiers/Risc0Verifier.t.sol index a3d2bfa0d87..67915c77fa3 100644 --- a/packages/protocol/test/verifiers/Risc0Verifier.t.sol +++ b/packages/protocol/test/layer1/verifiers/Risc0Verifier.t.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; -import "../L1/TaikoL1TestBase.sol"; +import "../based/TaikoL1TestBase.sol"; contract MockRisc0RemoteVerifier is IRiscZeroVerifier { // To simulate failing and succeeding diff --git a/packages/protocol/test/verifiers/RiscZeroGroth16Verifier.t.sol b/packages/protocol/test/layer1/verifiers/RiscZeroGroth16Verifier.t.sol similarity index 98% rename from packages/protocol/test/verifiers/RiscZeroGroth16Verifier.t.sol rename to packages/protocol/test/layer1/verifiers/RiscZeroGroth16Verifier.t.sol index e337e7d1b17..5e3667e58e3 100644 --- a/packages/protocol/test/verifiers/RiscZeroGroth16Verifier.t.sol +++ b/packages/protocol/test/layer1/verifiers/RiscZeroGroth16Verifier.t.sol @@ -1,9 +1,9 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; -import "../L1/TaikoL1TestBase.sol"; import "@risc0/contracts/groth16/RiscZeroGroth16Verifier.sol"; import "@risc0/contracts/groth16/ControlID.sol"; +import "../based/TaikoL1TestBase.sol"; contract RiscZeroGroth16VerifierTest is TaikoL1TestBase { function deployTaikoL1() internal override returns (TaikoL1) { diff --git a/packages/protocol/test/verifiers/SP1PlonkVerifier.t.sol b/packages/protocol/test/layer1/verifiers/SP1PlonkVerifier.t.sol similarity index 98% rename from packages/protocol/test/verifiers/SP1PlonkVerifier.t.sol rename to packages/protocol/test/layer1/verifiers/SP1PlonkVerifier.t.sol index 65b8cfaa76c..5d66cfd8978 100644 --- a/packages/protocol/test/verifiers/SP1PlonkVerifier.t.sol +++ b/packages/protocol/test/layer1/verifiers/SP1PlonkVerifier.t.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; -import "../L1/TaikoL1TestBase.sol"; import { SP1Verifier as SP1PlonkVerifier } from "@sp1-contracts/src/v1.2.0-rc/SP1VerifierPlonk.sol"; +import "../based/TaikoL1TestBase.sol"; contract SP1PlonkVerifierTest is TaikoL1TestBase { function deployTaikoL1() internal override returns (TaikoL1) { diff --git a/packages/protocol/test/verifiers/SP1Verifier.t.sol b/packages/protocol/test/layer1/verifiers/SP1Verifier.t.sol similarity index 98% rename from packages/protocol/test/verifiers/SP1Verifier.t.sol rename to packages/protocol/test/layer1/verifiers/SP1Verifier.t.sol index 46e48f00765..329031fdd83 100644 --- a/packages/protocol/test/verifiers/SP1Verifier.t.sol +++ b/packages/protocol/test/layer1/verifiers/SP1Verifier.t.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; -import "../L1/TaikoL1TestBase.sol"; +import "../based/TaikoL1TestBase.sol"; contract MockSP1Gateway is ISP1Verifier { // To simulate failing and succeeding diff --git a/packages/protocol/test/verifiers/SgxVerifier.t.sol b/packages/protocol/test/layer1/verifiers/SgxVerifier.t.sol similarity index 99% rename from packages/protocol/test/verifiers/SgxVerifier.t.sol rename to packages/protocol/test/layer1/verifiers/SgxVerifier.t.sol index f650d4cf79b..2618a640bae 100644 --- a/packages/protocol/test/verifiers/SgxVerifier.t.sol +++ b/packages/protocol/test/layer1/verifiers/SgxVerifier.t.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; -import "../L1/TaikoL1TestBase.sol"; import "../automata-attestation/common/AttestationBase.t.sol"; +import "../based/TaikoL1TestBase.sol"; contract TestSgxVerifier is TaikoL1TestBase, AttestationBase { address internal SGX_Y = diff --git a/packages/protocol/test/verifiers/compose/ComposeVerifeir.t.sol b/packages/protocol/test/layer1/verifiers/compose/ComposeVerifeir.t.sol similarity index 98% rename from packages/protocol/test/verifiers/compose/ComposeVerifeir.t.sol rename to packages/protocol/test/layer1/verifiers/compose/ComposeVerifeir.t.sol index 045dbb15aa4..d6e6ff554ba 100644 --- a/packages/protocol/test/verifiers/compose/ComposeVerifeir.t.sol +++ b/packages/protocol/test/layer1/verifiers/compose/ComposeVerifeir.t.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; -import "../../TaikoTest.sol"; -import "../../../contracts/verifiers/compose/ComposeVerifier.sol"; +import "../../../shared/TaikoTest.sol"; +import "../../../../contracts/layer1/verifiers/compose/ComposeVerifier.sol"; contract ComposeVerifierForTest is ComposeVerifier { uint256 private threshold; diff --git a/packages/protocol/test/L2/DelegateOwner.t.sol b/packages/protocol/test/layer2/DelegateOwner.t.sol similarity index 98% rename from packages/protocol/test/L2/DelegateOwner.t.sol rename to packages/protocol/test/layer2/DelegateOwner.t.sol index e9e2f342f94..431219d9508 100644 --- a/packages/protocol/test/L2/DelegateOwner.t.sol +++ b/packages/protocol/test/layer2/DelegateOwner.t.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; -import "../thirdparty/Multicall3.sol"; -import "../TaikoTest.sol"; +import "../shared/thirdparty/Multicall3.sol"; +import "./TaikoL2Test.sol"; contract Target is EssentialContract { function init(address _owner) external initializer { @@ -10,7 +10,7 @@ contract Target is EssentialContract { } } -contract TestDelegateOwner is TaikoTest { +contract TestDelegateOwner is TaikoL2Test { address public owner; address public remoteOwner; Bridge public bridge; diff --git a/packages/protocol/test/L2/Lib1559Math.t.sol b/packages/protocol/test/layer2/Lib1559Math.t.sol similarity index 97% rename from packages/protocol/test/L2/Lib1559Math.t.sol rename to packages/protocol/test/layer2/Lib1559Math.t.sol index d355f5d9fae..dd821e0e13e 100644 --- a/packages/protocol/test/L2/Lib1559Math.t.sol +++ b/packages/protocol/test/layer2/Lib1559Math.t.sol @@ -1,9 +1,9 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; -import "../TaikoTest.sol"; +import "./TaikoL2Test.sol"; -contract TestLib1559Math is TaikoTest { +contract TestLib1559Math is TaikoL2Test { using LibMath for uint256; function test_ethQty() external { diff --git a/packages/protocol/test/L2/LibL2Signer.sol b/packages/protocol/test/layer2/LibL2Signer.sol similarity index 98% rename from packages/protocol/test/L2/LibL2Signer.sol rename to packages/protocol/test/layer2/LibL2Signer.sol index 82c626d4e90..42cfc4e8734 100644 --- a/packages/protocol/test/L2/LibL2Signer.sol +++ b/packages/protocol/test/layer2/LibL2Signer.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; -import "../thirdparty/LibUint512Math.sol"; +import "../shared/thirdparty/LibUint512Math.sol"; /// @title LibL2Signer /// @notice This contract allows for signing operations required on Taiko L2. diff --git a/packages/protocol/test/L2/TaikoL2.t.sol b/packages/protocol/test/layer2/TaikoL2.t.sol similarity index 97% rename from packages/protocol/test/L2/TaikoL2.t.sol rename to packages/protocol/test/layer2/TaikoL2.t.sol index ac8103786aa..20beeaa94d7 100644 --- a/packages/protocol/test/L2/TaikoL2.t.sol +++ b/packages/protocol/test/layer2/TaikoL2.t.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; -import "../TaikoTest.sol"; +import "./TaikoL2Test.sol"; contract SkipBasefeeCheckL2 is TaikoL2EIP1559Configurable { function skipFeeCheck() public pure override returns (bool) { @@ -9,7 +9,7 @@ contract SkipBasefeeCheckL2 is TaikoL2EIP1559Configurable { } } -contract TestTaikoL2 is TaikoTest { +contract TaikoL2Tests is TaikoL2Test { using SafeCast for uint256; // Initial salt for semi-random generation diff --git a/packages/protocol/test/L2/TaikoL2EIP1559Configurable.sol b/packages/protocol/test/layer2/TaikoL2EIP1559Configurable.sol similarity index 95% rename from packages/protocol/test/L2/TaikoL2EIP1559Configurable.sol rename to packages/protocol/test/layer2/TaikoL2EIP1559Configurable.sol index b122db18a84..85c3c8450cd 100644 --- a/packages/protocol/test/L2/TaikoL2EIP1559Configurable.sol +++ b/packages/protocol/test/layer2/TaikoL2EIP1559Configurable.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; -import "../../contracts/L2/TaikoL2.sol"; +import "../../contracts/layer2/based/TaikoL2.sol"; /// @title TaikoL2EIP1559Configurable /// @notice TaikoL2 with a setter to change EIP-1559 configurations and states. diff --git a/packages/protocol/test/L2/TaikoL2NoFeeCheck.t.sol b/packages/protocol/test/layer2/TaikoL2NoFeeCheck.t.sol similarity index 98% rename from packages/protocol/test/L2/TaikoL2NoFeeCheck.t.sol rename to packages/protocol/test/layer2/TaikoL2NoFeeCheck.t.sol index e32738ebce6..f0a76219598 100644 --- a/packages/protocol/test/L2/TaikoL2NoFeeCheck.t.sol +++ b/packages/protocol/test/layer2/TaikoL2NoFeeCheck.t.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; -import "../TaikoTest.sol"; +import "./TaikoL2Test.sol"; contract SkipBasefeeCheckL2 is TaikoL2EIP1559Configurable { function skipFeeCheck() public pure override returns (bool) { @@ -9,7 +9,7 @@ contract SkipBasefeeCheckL2 is TaikoL2EIP1559Configurable { } } -contract TestTaikoL2NoFeeCheck is TaikoTest { +contract TaikoL2NoFeeCheckTests is TaikoL2Test { using SafeCast for uint256; // Initial salt for semi-random generation diff --git a/packages/protocol/test/layer2/TaikoL2Test.sol b/packages/protocol/test/layer2/TaikoL2Test.sol new file mode 100644 index 00000000000..ad9eeb0e61a --- /dev/null +++ b/packages/protocol/test/layer2/TaikoL2Test.sol @@ -0,0 +1,9 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.24; + +import "../../contracts/layer2/DelegateOwner.sol"; +import "../layer2/TaikoL2EIP1559Configurable.sol"; +import "../layer2/LibL2Signer.sol"; +import "../shared/TaikoTest.sol"; + +abstract contract TaikoL2Test is TaikoTest { } diff --git a/packages/protocol/test/DeployCapability.sol b/packages/protocol/test/shared/DeployCapability.sol similarity index 96% rename from packages/protocol/test/DeployCapability.sol rename to packages/protocol/test/shared/DeployCapability.sol index ae059deef55..aa54d9e0774 100644 --- a/packages/protocol/test/DeployCapability.sol +++ b/packages/protocol/test/shared/DeployCapability.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol"; import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; @@ -8,7 +8,7 @@ import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import "forge-std/src/console2.sol"; import "forge-std/src/Script.sol"; -import "../contracts/common/AddressManager.sol"; +import "../../contracts/shared/common/AddressManager.sol"; /// @title DeployCapability abstract contract DeployCapability is Script { diff --git a/packages/protocol/test/HelperContracts.sol b/packages/protocol/test/shared/HelperContracts.sol similarity index 88% rename from packages/protocol/test/HelperContracts.sol rename to packages/protocol/test/shared/HelperContracts.sol index de21aac1367..15b4444dffb 100644 --- a/packages/protocol/test/HelperContracts.sol +++ b/packages/protocol/test/shared/HelperContracts.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; -import "../contracts/bridge/Bridge.sol"; -import "../contracts/signal/SignalService.sol"; +import "../../contracts/shared/bridge/Bridge.sol"; +import "../../contracts/shared/signal/SignalService.sol"; contract BadReceiver { receive() external payable { diff --git a/packages/protocol/test/TaikoTest.sol b/packages/protocol/test/shared/TaikoTest.sol similarity index 69% rename from packages/protocol/test/TaikoTest.sol rename to packages/protocol/test/shared/TaikoTest.sol index 883289065e9..ce24659cd01 100644 --- a/packages/protocol/test/TaikoTest.sol +++ b/packages/protocol/test/shared/TaikoTest.sol @@ -1,37 +1,22 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "forge-std/src/Test.sol"; import "@openzeppelin/contracts/utils/math/SafeCast.sol"; import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; -import "../contracts/tokenvault/BridgedERC20V2.sol"; -import "../contracts/tokenvault/BridgedERC721.sol"; -import "../contracts/tokenvault/BridgedERC1155.sol"; -import "../contracts/tokenvault/ERC20Vault.sol"; -import "../contracts/tokenvault/ERC721Vault.sol"; -import "../contracts/tokenvault/ERC1155Vault.sol"; - -import "../contracts/tko/TaikoToken.sol"; -import "../contracts/L1/TaikoL1.sol"; -import "../contracts/verifiers/SgxVerifier.sol"; -import "../contracts/verifiers/SP1Verifier.sol"; -import "../contracts/verifiers/Risc0Verifier.sol"; -import "../test/L1/TestTierProvider.sol"; -import "../contracts/L1/provers/GuardianProver.sol"; -import "../contracts/bridge/QuotaManager.sol"; - -import "../contracts/L2/DelegateOwner.sol"; - -import "../contracts/team/airdrop/ERC20Airdrop.sol"; - -import "../test/common/erc20/FreeMintERC20.sol"; -import "../test/L2/TaikoL2EIP1559Configurable.sol"; - +import "../../contracts/shared/tokenvault/BridgedERC20V2.sol"; +import "../../contracts/shared/tokenvault/BridgedERC721.sol"; +import "../../contracts/shared/tokenvault/BridgedERC1155.sol"; +import "../../contracts/shared/tokenvault/ERC20Vault.sol"; +import "../../contracts/shared/tokenvault/ERC721Vault.sol"; +import "../../contracts/shared/tokenvault/ERC1155Vault.sol"; +import "./token/FreeMintERC20.sol"; +import "./token/RegularERC20.sol"; +import "./token/MayFailFreeMintERC20.sol"; import "./DeployCapability.sol"; import "./HelperContracts.sol"; -import "./L2/LibL2Signer.sol"; abstract contract TaikoTest is Test, DeployCapability { uint256 private _seed = 0x12345678; diff --git a/packages/protocol/test/bridge/Bridge.t.sol b/packages/protocol/test/shared/bridge/Bridge.t.sol similarity index 99% rename from packages/protocol/test/bridge/Bridge.t.sol rename to packages/protocol/test/shared/bridge/Bridge.t.sol index 86947bb7831..9406a70ce1c 100644 --- a/packages/protocol/test/bridge/Bridge.t.sol +++ b/packages/protocol/test/shared/bridge/Bridge.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "../TaikoTest.sol"; diff --git a/packages/protocol/test/bridge/Bridge2.t.sol b/packages/protocol/test/shared/bridge/Bridge2.t.sol similarity index 98% rename from packages/protocol/test/bridge/Bridge2.t.sol rename to packages/protocol/test/shared/bridge/Bridge2.t.sol index 070e56614fb..95ffe3075b7 100644 --- a/packages/protocol/test/bridge/Bridge2.t.sol +++ b/packages/protocol/test/shared/bridge/Bridge2.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "../TaikoTest.sol"; diff --git a/packages/protocol/test/bridge/Bridge2_failMessage.t.sol b/packages/protocol/test/shared/bridge/Bridge2_failMessage.t.sol similarity index 99% rename from packages/protocol/test/bridge/Bridge2_failMessage.t.sol rename to packages/protocol/test/shared/bridge/Bridge2_failMessage.t.sol index 8f50e23dadc..c677c76daa2 100644 --- a/packages/protocol/test/bridge/Bridge2_failMessage.t.sol +++ b/packages/protocol/test/shared/bridge/Bridge2_failMessage.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "./Bridge2.t.sol"; diff --git a/packages/protocol/test/bridge/Bridge2_processMessage.t.sol b/packages/protocol/test/shared/bridge/Bridge2_processMessage.t.sol similarity index 99% rename from packages/protocol/test/bridge/Bridge2_processMessage.t.sol rename to packages/protocol/test/shared/bridge/Bridge2_processMessage.t.sol index ec4c3df667d..5c3ed60b746 100644 --- a/packages/protocol/test/bridge/Bridge2_processMessage.t.sol +++ b/packages/protocol/test/shared/bridge/Bridge2_processMessage.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "./Bridge2.t.sol"; diff --git a/packages/protocol/test/bridge/Bridge2_recallMessage.t.sol b/packages/protocol/test/shared/bridge/Bridge2_recallMessage.t.sol similarity index 99% rename from packages/protocol/test/bridge/Bridge2_recallMessage.t.sol rename to packages/protocol/test/shared/bridge/Bridge2_recallMessage.t.sol index 4c0bfbc44eb..d45331ce74e 100644 --- a/packages/protocol/test/bridge/Bridge2_recallMessage.t.sol +++ b/packages/protocol/test/shared/bridge/Bridge2_recallMessage.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "./Bridge2.t.sol"; diff --git a/packages/protocol/test/bridge/Bridge2_retryMessage.t.sol b/packages/protocol/test/shared/bridge/Bridge2_retryMessage.t.sol similarity index 99% rename from packages/protocol/test/bridge/Bridge2_retryMessage.t.sol rename to packages/protocol/test/shared/bridge/Bridge2_retryMessage.t.sol index f6da3ab30db..ab4c8a65213 100644 --- a/packages/protocol/test/bridge/Bridge2_retryMessage.t.sol +++ b/packages/protocol/test/shared/bridge/Bridge2_retryMessage.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "./Bridge2.t.sol"; diff --git a/packages/protocol/test/bridge/Bridge2_sendMessage.t.sol b/packages/protocol/test/shared/bridge/Bridge2_sendMessage.t.sol similarity index 99% rename from packages/protocol/test/bridge/Bridge2_sendMessage.t.sol rename to packages/protocol/test/shared/bridge/Bridge2_sendMessage.t.sol index ba323785c7f..5310f242a49 100644 --- a/packages/protocol/test/bridge/Bridge2_sendMessage.t.sol +++ b/packages/protocol/test/shared/bridge/Bridge2_sendMessage.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "./Bridge2.t.sol"; diff --git a/packages/protocol/test/bridge/QuotaManager.t.sol b/packages/protocol/test/shared/bridge/QuotaManager.t.sol similarity index 99% rename from packages/protocol/test/bridge/QuotaManager.t.sol rename to packages/protocol/test/shared/bridge/QuotaManager.t.sol index 5d25eebab4c..fa44f0cc9e6 100644 --- a/packages/protocol/test/bridge/QuotaManager.t.sol +++ b/packages/protocol/test/shared/bridge/QuotaManager.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "../TaikoTest.sol"; diff --git a/packages/protocol/test/common/AddressManager.t.sol b/packages/protocol/test/shared/common/AddressManager.t.sol similarity index 93% rename from packages/protocol/test/common/AddressManager.t.sol rename to packages/protocol/test/shared/common/AddressManager.t.sol index 91b6383f269..94e64b5c836 100644 --- a/packages/protocol/test/common/AddressManager.t.sol +++ b/packages/protocol/test/shared/common/AddressManager.t.sol @@ -1,10 +1,10 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; -import "../L1/TaikoL1TestBase.sol"; +import "../TaikoTest.sol"; /// @author Kirk Baird -contract TestAddressManager is TaikoL1TestBase { +contract TestAddressManager is TaikoTest { function deployTaikoL1() internal override returns (TaikoL1) { return TaikoL1(payable(deployProxy({ name: "taiko", impl: address(new TaikoL1()), data: "" }))); diff --git a/packages/protocol/test/common/AddressResolver.t.sol b/packages/protocol/test/shared/common/AddressResolver.t.sol similarity index 92% rename from packages/protocol/test/common/AddressResolver.t.sol rename to packages/protocol/test/shared/common/AddressResolver.t.sol index ef08e2abefe..b416c950db2 100644 --- a/packages/protocol/test/common/AddressResolver.t.sol +++ b/packages/protocol/test/shared/common/AddressResolver.t.sol @@ -1,10 +1,10 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; -import "../L1/TaikoL1TestBase.sol"; +import "../TaikoTest.sol"; /// @author Kirk Baird -contract TestAddressResolver is TaikoL1TestBase { +contract TestAddressResolver is TaikoTest { function deployTaikoL1() internal override returns (TaikoL1) { return TaikoL1(payable(deployProxy({ name: "taiko", impl: address(new TaikoL1()), data: "" }))); diff --git a/packages/protocol/test/common/EssentialContract.t.sol b/packages/protocol/test/shared/common/EssentialContract.t.sol similarity index 98% rename from packages/protocol/test/common/EssentialContract.t.sol rename to packages/protocol/test/shared/common/EssentialContract.t.sol index d9aa975ada1..dc9d90eeae3 100644 --- a/packages/protocol/test/common/EssentialContract.t.sol +++ b/packages/protocol/test/shared/common/EssentialContract.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "../TaikoTest.sol"; diff --git a/packages/protocol/test/libs/LibAddress.t.sol b/packages/protocol/test/shared/common/LibAddress.t.sol similarity index 97% rename from packages/protocol/test/libs/LibAddress.t.sol rename to packages/protocol/test/shared/common/LibAddress.t.sol index 11855ea2d59..ce6b29a5eac 100644 --- a/packages/protocol/test/libs/LibAddress.t.sol +++ b/packages/protocol/test/shared/common/LibAddress.t.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "../TaikoTest.sol"; -import "../../contracts/libs/LibAddress.sol"; +import "../../../contracts/shared/common/LibAddress.sol"; contract CalldataReceiver { // Returns success diff --git a/packages/protocol/test/libs/LibTrieProof.t.sol b/packages/protocol/test/shared/common/LibTrieProof.t.sol similarity index 99% rename from packages/protocol/test/libs/LibTrieProof.t.sol rename to packages/protocol/test/shared/common/LibTrieProof.t.sol index ed0acad1fff..42f2820d86f 100644 --- a/packages/protocol/test/libs/LibTrieProof.t.sol +++ b/packages/protocol/test/shared/common/LibTrieProof.t.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; +import "../../../contracts/shared/common/LibTrieProof.sol"; import "../TaikoTest.sol"; -import "../../contracts/libs/LibTrieProof.sol"; contract TestLibTrieProof is TaikoTest { function test_verifyMerkleProof() public { diff --git a/packages/protocol/test/signal/SignalService.t.sol b/packages/protocol/test/shared/signal/SignalService.t.sol similarity index 99% rename from packages/protocol/test/signal/SignalService.t.sol rename to packages/protocol/test/shared/signal/SignalService.t.sol index 875fd7677e1..289d35fc60e 100644 --- a/packages/protocol/test/signal/SignalService.t.sol +++ b/packages/protocol/test/shared/signal/SignalService.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "../TaikoTest.sol"; import "forge-std/src/console2.sol"; diff --git a/packages/protocol/test/thirdparty/LibUint512Math.sol b/packages/protocol/test/shared/thirdparty/LibUint512Math.sol similarity index 99% rename from packages/protocol/test/thirdparty/LibUint512Math.sol rename to packages/protocol/test/shared/thirdparty/LibUint512Math.sol index 927acb48d64..ae732cf8eba 100644 --- a/packages/protocol/test/thirdparty/LibUint512Math.sol +++ b/packages/protocol/test/shared/thirdparty/LibUint512Math.sol @@ -23,7 +23,7 @@ // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; /// @title LibUint512Math library LibUint512Math { diff --git a/packages/protocol/test/thirdparty/Multicall3.sol b/packages/protocol/test/shared/thirdparty/Multicall3.sol similarity index 99% rename from packages/protocol/test/thirdparty/Multicall3.sol rename to packages/protocol/test/shared/thirdparty/Multicall3.sol index 62ac791f6cb..2b15bc3d116 100644 --- a/packages/protocol/test/thirdparty/Multicall3.sol +++ b/packages/protocol/test/shared/thirdparty/Multicall3.sol @@ -3,7 +3,7 @@ */ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; /// @title Multicall3 /// @notice Aggregate results from multiple function calls diff --git a/packages/protocol/test/common/erc20/FreeMintERC20.sol b/packages/protocol/test/shared/token/FreeMintERC20.sol similarity index 95% rename from packages/protocol/test/common/erc20/FreeMintERC20.sol rename to packages/protocol/test/shared/token/FreeMintERC20.sol index 419fde30cff..96e02962edc 100644 --- a/packages/protocol/test/common/erc20/FreeMintERC20.sol +++ b/packages/protocol/test/shared/token/FreeMintERC20.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; diff --git a/packages/protocol/test/common/erc20/MayFailFreeMintERC20.sol b/packages/protocol/test/shared/token/MayFailFreeMintERC20.sol similarity index 98% rename from packages/protocol/test/common/erc20/MayFailFreeMintERC20.sol rename to packages/protocol/test/shared/token/MayFailFreeMintERC20.sol index c78aedd4a9d..4fe4e76501a 100644 --- a/packages/protocol/test/common/erc20/MayFailFreeMintERC20.sol +++ b/packages/protocol/test/shared/token/MayFailFreeMintERC20.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; diff --git a/packages/protocol/test/common/erc20/RegularERC20.sol b/packages/protocol/test/shared/token/RegularERC20.sol similarity index 90% rename from packages/protocol/test/common/erc20/RegularERC20.sol rename to packages/protocol/test/shared/token/RegularERC20.sol index be6fa1bf139..5216f9077af 100644 --- a/packages/protocol/test/common/erc20/RegularERC20.sol +++ b/packages/protocol/test/shared/token/RegularERC20.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; diff --git a/packages/protocol/test/tokenvault/BridgedERC20V2.t.sol b/packages/protocol/test/shared/tokenvault/BridgedERC20V2.t.sol similarity index 99% rename from packages/protocol/test/tokenvault/BridgedERC20V2.t.sol rename to packages/protocol/test/shared/tokenvault/BridgedERC20V2.t.sol index 0ba20904a7a..9d07025e40b 100644 --- a/packages/protocol/test/tokenvault/BridgedERC20V2.t.sol +++ b/packages/protocol/test/shared/tokenvault/BridgedERC20V2.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "../TaikoTest.sol"; diff --git a/packages/protocol/test/tokenvault/ERC1155Vault.t.sol b/packages/protocol/test/shared/tokenvault/ERC1155Vault.t.sol similarity index 99% rename from packages/protocol/test/tokenvault/ERC1155Vault.t.sol rename to packages/protocol/test/shared/tokenvault/ERC1155Vault.t.sol index 9aa95614e68..6c28e585e7d 100644 --- a/packages/protocol/test/tokenvault/ERC1155Vault.t.sol +++ b/packages/protocol/test/shared/tokenvault/ERC1155Vault.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol"; import "../TaikoTest.sol"; diff --git a/packages/protocol/test/tokenvault/ERC20Vault.t.sol b/packages/protocol/test/shared/tokenvault/ERC20Vault.t.sol similarity index 99% rename from packages/protocol/test/tokenvault/ERC20Vault.t.sol rename to packages/protocol/test/shared/tokenvault/ERC20Vault.t.sol index 26526463d05..1f8804a84f8 100644 --- a/packages/protocol/test/tokenvault/ERC20Vault.t.sol +++ b/packages/protocol/test/shared/tokenvault/ERC20Vault.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "../TaikoTest.sol"; diff --git a/packages/protocol/test/tokenvault/ERC721Vault.t.sol b/packages/protocol/test/shared/tokenvault/ERC721Vault.t.sol similarity index 99% rename from packages/protocol/test/tokenvault/ERC721Vault.t.sol rename to packages/protocol/test/shared/tokenvault/ERC721Vault.t.sol index e3ddfc2901e..0ef70957687 100644 --- a/packages/protocol/test/tokenvault/ERC721Vault.t.sol +++ b/packages/protocol/test/shared/tokenvault/ERC721Vault.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.24; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "../TaikoTest.sol"; diff --git a/packages/protocol/utils/airdrop/airdrop_db/example_claimList.json b/packages/protocol/utils/airdrop/airdrop_db/example_claimList.json deleted file mode 100644 index 3208e43309c..00000000000 --- a/packages/protocol/utils/airdrop/airdrop_db/example_claimList.json +++ /dev/null @@ -1,7 +0,0 @@ -[ - { "address": "0x7E5F4552091A69125d5DfCb7b8C2659029395Bdf", "amount": 100 }, - { "address": "0x2B5AD5c4795c026514f8317c7a215E218DcCD6cF", "amount": 100 }, - { "address": "0x6813Eb9362372EEF6200f3b1dbC3f819671cBA69", "amount": 100 }, - { "address": "0x1efF47bc3a10a45D4B230B5d10E37751FE6AA718", "amount": 100 }, - { "address": "0xe1AB8145F7E55DC933d51a18c793F901A3A0b276", "amount": 200 } -] diff --git a/packages/protocol/utils/airdrop/buildMerkleTree.ts b/packages/protocol/utils/airdrop/buildMerkleTree.ts deleted file mode 100644 index f732a115c79..00000000000 --- a/packages/protocol/utils/airdrop/buildMerkleTree.ts +++ /dev/null @@ -1,97 +0,0 @@ -import { MerkleTree } from "merkletreejs/dist/MerkleTree"; -const { ethers } = require("ethers"); -const keccak256 = require("keccak256"); -const fs = require("fs"); - -interface IClaimListData { - address: string; - amount: number; -} - -interface IMerkle { - merkleTree: MerkleTree; - rootHash: string; -} - -async function buildMerkleTree( - allowListDataArr: IClaimListData[], -): Promise { - // create merkle tree - const leafNodes: any = []; - for (let i = 0; i < allowListDataArr.length; i++) { - leafNodes.push(buildLeaf(allowListDataArr[i])); - } - const merkleTree = new MerkleTree(leafNodes, keccak256, { - sortPairs: true, - }); - - const rootHash = merkleTree.getHexRoot(); - - return { - merkleTree, - rootHash, - }; -} - -function buildLeaf(data: IClaimListData) { - const inputData = ethers.utils.defaultAbiCoder.encode( - ["address", "uint256"], - [data.address, data.amount], - ); - - return Buffer.from( - ethers.utils - .keccak256( - ethers.utils.defaultAbiCoder.encode( - ["bytes", "bytes"], - [ - ethers.utils.toUtf8Bytes("CLAIM_TAIKO_AIRDROP"), - inputData, - ], - ), - ) - .slice(2), - "hex", - ); -} - -async function getMerkleProof( - address: string, - amount: number, - claimList: IClaimListData[], -) { - const merkleData = await buildMerkleTree(claimList); - const leaf = buildLeaf({ address, amount }); - - return merkleData.merkleTree.getHexProof(leaf); -} - -async function main() { - const filePath = process.argv[2]; - - if (!filePath) { - console.error( - "Please provide a path to the JSON file as a command-line argument.", - ); - return; - } - - const jsonData = fs.readFileSync(filePath, "utf-8"); - const claimList: IClaimListData[] = JSON.parse(jsonData); - const merkleData = await buildMerkleTree(claimList); - - console.log("Merkle root:", merkleData.rootHash); - console.log("Nr of leaves (entries):", claimList.length); - - const exampleProof = await getMerkleProof( - "0x7E5F4552091A69125d5DfCb7b8C2659029395Bdf", - 100, - claimList, - ); - - console.log("Example proof for Alice (foundry) is: ", exampleProof); -} - -main().catch((error) => { - console.error(error); -}); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ec4e0516c2f..5303428e71c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -471,8 +471,8 @@ importers: specifier: ^5.7.2 version: 5.7.2 solc: - specifier: 0.8.27 - version: 0.8.27 + specifier: 0.8.24 + version: 0.8.24 solhint: specifier: ^5.0.3 version: 5.0.3(typescript@5.4.5) @@ -10094,11 +10094,6 @@ packages: engines: {node: '>=10.0.0'} hasBin: true - solc@0.8.27: - resolution: {integrity: sha512-BNxMol2tUAbkH7HKlXBcBqrGi2aqgv+uMHz26mJyTtlVgWmBA4ktiw0qVKHfkjf2oaHbwtbtaSeE2dhn/gTAKw==} - engines: {node: '>=10.0.0'} - hasBin: true - solhint@4.5.4: resolution: {integrity: sha512-Cu1XiJXub2q1eCr9kkJ9VPv1sGcmj3V7Zb76B0CoezDOB9bu3DxKIFFH7ggCl9fWpEPD6xBmRLfZrYijkVmujQ==} hasBin: true @@ -25188,18 +25183,6 @@ snapshots: transitivePeerDependencies: - debug - solc@0.8.27: - dependencies: - command-exists: 1.2.9 - commander: 8.3.0 - follow-redirects: 1.15.6(debug@4.3.4) - js-sha3: 0.8.0 - memorystream: 0.3.1 - semver: 5.7.2 - tmp: 0.0.33 - transitivePeerDependencies: - - debug - solhint@4.5.4(typescript@5.4.5): dependencies: '@solidity-parser/parser': 0.18.0