From 75db4f372d9c5dc998626ba45451fad5af359ad7 Mon Sep 17 00:00:00 2001 From: Stanislav Breadless Date: Mon, 26 Aug 2024 17:58:42 +0200 Subject: [PATCH 1/4] fix server build with symlinks --- l1-contracts/foundry.toml | 2 ++ l1-contracts/lib/openzeppelin-contracts-upgradeable-v4 | 1 + l1-contracts/lib/openzeppelin-contracts-v4 | 1 + 3 files changed, 4 insertions(+) create mode 120000 l1-contracts/lib/openzeppelin-contracts-upgradeable-v4 create mode 120000 l1-contracts/lib/openzeppelin-contracts-v4 diff --git a/l1-contracts/foundry.toml b/l1-contracts/foundry.toml index be0511889..324d79b11 100644 --- a/l1-contracts/foundry.toml +++ b/l1-contracts/foundry.toml @@ -12,4 +12,6 @@ remappings = [ "forge-std/=../lib/forge-std/src/", "murky/=../lib/murky/src/", "foundry-test/=test/foundry/", + "@openzeppelin/contracts-v4/=./lib/openzeppelin-contracts-v4/contracts/", + "@openzeppelin/contracts-upgradeable-v4/=./lib/openzeppelin-contracts-upgradeable-v4/contracts/", ] diff --git a/l1-contracts/lib/openzeppelin-contracts-upgradeable-v4 b/l1-contracts/lib/openzeppelin-contracts-upgradeable-v4 new file mode 120000 index 000000000..0551b6016 --- /dev/null +++ b/l1-contracts/lib/openzeppelin-contracts-upgradeable-v4 @@ -0,0 +1 @@ +../../lib/openzeppelin-contracts-upgradeable-v4 \ No newline at end of file diff --git a/l1-contracts/lib/openzeppelin-contracts-v4 b/l1-contracts/lib/openzeppelin-contracts-v4 new file mode 120000 index 000000000..693e94537 --- /dev/null +++ b/l1-contracts/lib/openzeppelin-contracts-v4 @@ -0,0 +1 @@ +../../lib/openzeppelin-contracts-v4 \ No newline at end of file From 2076594154b53619570e3433b25a98119c8449b4 Mon Sep 17 00:00:00 2001 From: Zach Kolodny Date: Tue, 27 Aug 2024 13:17:31 -0400 Subject: [PATCH 2/4] remove upgradeSystemContextIfNecessary --- system-contracts/SystemContractsHashes.json | 20 +++---- system-contracts/bootloader/bootloader.yul | 61 --------------------- 2 files changed, 10 insertions(+), 71 deletions(-) diff --git a/system-contracts/SystemContractsHashes.json b/system-contracts/SystemContractsHashes.json index e70d6c003..9d17edc7d 100644 --- a/system-contracts/SystemContractsHashes.json +++ b/system-contracts/SystemContractsHashes.json @@ -178,35 +178,35 @@ "contractName": "bootloader_test", "bytecodePath": "bootloader/build/artifacts/bootloader_test.yul.zbin", "sourceCodePath": "bootloader/build/bootloader_test.yul", - "bytecodeHash": "0x010003cbdea8040793e57c3584e3ef2fd3260caf9244d1ab22a64e8cf890b485", - "sourceCodeHash": "0x8fe3cf367c26e64e8bfb85f7488723bcf229e71ee6685dda6ee6ce9bc7d28cab" + "bytecodeHash": "0x010003cb94018874dce8c4f3b254625cffc7032c37f85c6b743d30cbac87c934", + "sourceCodeHash": "0x42b9c4235bd0b3de0beff158d7d848381990c55907daeaa3a9c8b6d66b53c0f3" }, { "contractName": "fee_estimate", "bytecodePath": "bootloader/build/artifacts/fee_estimate.yul.zbin", "sourceCodePath": "bootloader/build/fee_estimate.yul", - "bytecodeHash": "0x0100094fe95a0ee1b8b9a86befeb23939f5036a69a5808235e058e1af1e935d8", - "sourceCodeHash": "0x6071a22c177ad6ed84a6d8a283eb3272dbb127da394417c11fb94056dfcce3cc" + "bytecodeHash": "0x0100092dd79e0d7171d5dfe246e20c2d3f2d8b1ba8104ba1199e0c1a4b8af9ef", + "sourceCodeHash": "0xe538d080f0071f7f31ab1ea013fccec31560450d67e2859257d627100a5fcd07" }, { "contractName": "gas_test", "bytecodePath": "bootloader/build/artifacts/gas_test.yul.zbin", "sourceCodePath": "bootloader/build/gas_test.yul", - "bytecodeHash": "0x010008d5319bd1a8c92f7519824ca73c6b993930a68982b205ad9cce2b50e147", - "sourceCodeHash": "0x0d08c8894d54a6498ae0ffbc10816439652c1b43022a77364b9aa4df91cd3ba5" + "bytecodeHash": "0x010008b3ffe296bc8b565f555fa15f8aca08d9b88f5b06c15d72094cf5d779b6", + "sourceCodeHash": "0xcc36539d29f136bccd80fea0c3f9976cfc9e238972930b2aca98e6ad2e38fd1c" }, { "contractName": "playground_batch", "bytecodePath": "bootloader/build/artifacts/playground_batch.yul.zbin", "sourceCodePath": "bootloader/build/playground_batch.yul", - "bytecodeHash": "0x0100095541c24966c34984d5521cb7a06263eb4715205f5632a6d5f596010c24", - "sourceCodeHash": "0x5a8ba82172223403a83ec95be070c87ec9bf931898f4df2091c93535fefd8223" + "bytecodeHash": "0x010009339296f1ba9bd8b81e7152125a8286c4e7f9c3e194e35fc325a9e5c7d2", + "sourceCodeHash": "0xaac0c38a7b033eec41e2533c04b3541099c0c6ee70eb4acd8eea69edd1ef936a" }, { "contractName": "proved_batch", "bytecodePath": "bootloader/build/artifacts/proved_batch.yul.zbin", "sourceCodePath": "bootloader/build/proved_batch.yul", - "bytecodeHash": "0x010008e50a84cb5e11b650d08b8040a90cd42203490f09362e5e39f1925234aa", - "sourceCodeHash": "0x2c4178f33c0c8ac6402d0f9f53c01c3a143c4d789cf97ba491ae590c4515a2b0" + "bytecodeHash": "0x010008c37ecadea8b003884eb9d81fdfb7161b3b309504e5318f15da19c500d8", + "sourceCodeHash": "0x64618bc0fd4affe7fd2a0fa6a5a16d16be2df194bbe3e0ad6d54f1878a4a6d95" } ] diff --git a/system-contracts/bootloader/bootloader.yul b/system-contracts/bootloader/bootloader.yul index 7d080009b..e5daed9e0 100644 --- a/system-contracts/bootloader/bootloader.yul +++ b/system-contracts/bootloader/bootloader.yul @@ -692,63 +692,6 @@ object "Bootloader" { ret := mload(0) } - /// @dev The function that is temporarily needed to upgrade the SystemContext system contract. This function is to be removed - /// once the upgrade is complete. - /// @dev Checks whether the code hash of the SystemContext contract is correct and updates it if needed. - /// @dev The bootloader calls `setPubdataInfo` before each transaction, including the upgrade one. - /// However, the old SystemContext does not have this method. So the bootloader should invoke this function - /// before starting any transaction. - function upgradeSystemContextIfNeeded() { - let expectedCodeHash := {{SYSTEM_CONTEXT_EXPECTED_CODE_HASH}} - - let actualCodeHash := getRawCodeHash(SYSTEM_CONTEXT_ADDR(), true) - if iszero(eq(expectedCodeHash, actualCodeHash)) { - // Now, we need to encode the call to the `ContractDeployer.forceDeployOnAddresses()` function. - - // The `mimicCallOnlyResult` requires that the first word of the data - // contains its length. Here it is 292 bytes. - mstore(0, 292) - mstore(32, {{PADDED_FORCE_DEPLOY_ON_ADDRESSES_SELECTOR}}) - - // The 0x20 offset, for the array of forced deployments - mstore(36, 0x0000000000000000000000000000000000000000000000000000000000000020) - // Only one force deployment - mstore(68, 0x0000000000000000000000000000000000000000000000000000000000000001) - - // Now, starts the description of the forced deployment itself. - // Firstly, the offset. - mstore(100, 0x0000000000000000000000000000000000000000000000000000000000000020) - // The new hash of the SystemContext contract. - mstore(132, expectedCodeHash) - // The address of the system context - mstore(164, SYSTEM_CONTEXT_ADDR()) - // The constructor must be called to reset the `blockGasLimit` variable - mstore(196, 0x0000000000000000000000000000000000000000000000000000000000000001) - // The value should be 0. - mstore(228, 0x0000000000000000000000000000000000000000000000000000000000000000) - // The offset of the input array. - mstore(260, 0x00000000000000000000000000000000000000000000000000000000000000a0) - // No input is provided, the array is empty. - mstore(292, 0x0000000000000000000000000000000000000000000000000000000000000000) - - // We'll use a mimicCall to simulate the correct sender. - let success := mimicCallOnlyResult( - CONTRACT_DEPLOYER_ADDR(), - FORCE_DEPLOYER(), - 0, - 0, - 0, - 0, - 0, - 0 - ) - - if iszero(success) { - assertionError("system context upgrade fail") - } - } - } - /// @dev Calculates the canonical hash of the L1->L2 transaction that will be /// sent to L1 as a message to the L1 contract that a certain operation has been processed. function getCanonicalL1TxHash(txDataOffset) -> ret { @@ -4019,8 +3962,6 @@ object "Bootloader" { assertionError("baseFee inconsistent") } - upgradeSystemContextIfNeeded() - setNewBatch(PREV_BATCH_HASH, NEW_BATCH_TIMESTAMP, NEW_BATCH_NUMBER, EXPECTED_BASE_FEE) @@ -4029,8 +3970,6 @@ object "Bootloader" { let SHOULD_SET_NEW_BATCH := mload(224) - upgradeSystemContextIfNeeded() - switch SHOULD_SET_NEW_BATCH case 0 { unsafeOverrideBatch(NEW_BATCH_TIMESTAMP, NEW_BATCH_NUMBER, EXPECTED_BASE_FEE) From 17e2c1be33a15357cf1689f62b972ab43b7a7e39 Mon Sep 17 00:00:00 2001 From: Zach Kolodny Date: Tue, 27 Aug 2024 14:52:00 -0400 Subject: [PATCH 3/4] fix l1 toml --- l1-contracts/foundry.toml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/l1-contracts/foundry.toml b/l1-contracts/foundry.toml index 324d79b11..04fd5c656 100644 --- a/l1-contracts/foundry.toml +++ b/l1-contracts/foundry.toml @@ -6,6 +6,17 @@ cache_path = "cache-forge" test = "test/foundry" solc_version = "0.8.24" evm_version = "cancun" +allow_paths = ["../l2-contracts/contracts"] +fs_permissions = [ + { access = "read", path = "../system-contracts/bootloader/build/artifacts" }, + { access = "read", path = "../system-contracts/artifacts-zk/contracts-preprocessed" }, + { access = "read", path = "../l2-contracts/artifacts-zk/" }, + { access = "read", path = "../l2-contracts/zkout/" }, + { access = "read", path = "../system-contracts/zkout/" }, + { access = "read", path = "./script-config" }, + { access = "read-write", path = "./script-out" }, + { access = "read", path = "./out" } +] ignored_error_codes = ["missing-receive-ether", "code-size"] ignored_warnings_from = ["test", "contracts/dev-contracts"] remappings = [ From 5b3f743ba798b51661f9a844fb56b0ce0da29a9e Mon Sep 17 00:00:00 2001 From: Zach Kolodny Date: Tue, 27 Aug 2024 15:06:19 -0400 Subject: [PATCH 4/4] update lint ignore path --- .eslintrc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.eslintrc b/.eslintrc index 077931cae..d8474e32a 100644 --- a/.eslintrc +++ b/.eslintrc @@ -11,6 +11,7 @@ "no-console": "off" }, "ignorePatterns": [ - "**/lib/*" + "**/lib/*", + "lib/*" ] }