Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zksync scripts finalization #53

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Zksync scripts finalization #53

wants to merge 6 commits into from

Conversation

Cycxyz
Copy link

@Cycxyz Cycxyz commented Dec 21, 2024

No description provided.

@Cycxyz Cycxyz changed the title add: doc for zksync create2 utils, small refactor Zksync scripts finalization Dec 21, 2024
Copy link
Contributor

github-actions bot commented Dec 21, 2024

🔮 Coverage report
File Line Coverage Function Coverage Branch Coverage
src/contracts/access-control/OwnableWithGuardian.sol ${\color{orange}90\%}$
$9 / 10$
20
${\color{orange}87.5\%}$
$7 / 8$
OwnableWithGuardian.onlyOwnerOrGuardian
${\color{green}100\%}$
$4 / 4$
src/contracts/access-control/UpgradeableOwnableWithGuardian.sol ${\color{green}100\%}$
$14 / 14$
${\color{green}100\%}$
$9 / 9$
${\color{green}100\%}$
$2 / 2$
src/contracts/create3/Create3.sol ${\color{orange}92.86\%}$
$13 / 14$
66
${\color{red}80\%}$
$4 / 5$
Create3.create3
${\color{red}33.33\%}$
$1 / 3$
src/contracts/create3/Create3Factory.sol ${\color{green}100\%}$
$4 / 4$
${\color{green}100\%}$
$2 / 2$
${\color{green}100\%}$
$0 / 0$
src/contracts/oz-common/Ownable.sol ${\color{red}80\%}$
$8 / 10$
37, 63
${\color{red}71.43\%}$
$5 / 7$
Ownable.onlyOwner, Ownable.renounceOwnership
${\color{red}50\%}$
$2 / 4$
src/contracts/oz-common/SafeERC20.sol ${\color{red}13.64\%}$
$3 / 22$
46, 54, 55, 64, 65 and 14 more
${\color{red}25\%}$
$2 / 8$
SafeERC20.safeTransferFrom, SafeERC20.safeIncreaseAllowance, SafeERC20.safeDecreaseAllowance, SafeERC20.forceApprove, SafeERC20.safePermit and 1 more
${\color{red}0\%}$
$0 / 4$
src/contracts/transparent-proxy/Initializable.sol ${\color{red}68.42\%}$
$13 / 19$
124, 128, 129, 131, 132 and 1 more
${\color{red}60\%}$
$3 / 5$
Initializable.reinitializer, Initializable.onlyInitializing
${\color{red}45.45\%}$
$5 / 11$
src/contracts/transparent-proxy/Proxy.sol ${\color{red}0\%}$
$0 / 11$
33, 37, 40, 44, 45 and 6 more
${\color{red}0\%}$
$0 / 5$
Proxy._delegate, Proxy._fallback, Proxy., Proxy., Proxy._beforeFallback
${\color{green}100\%}$
$0 / 0$
src/contracts/transparent-proxy/ProxyAdmin.sol ${\color{red}0\%}$
$0 / 1$
43
${\color{red}0\%}$
$0 / 1$
ProxyAdmin.upgradeAndCall
${\color{green}100\%}$
$0 / 0$
src/contracts/transparent-proxy/TransparentProxyFactory.sol ${\color{green}100\%}$
$2 / 2$
${\color{green}100\%}$
$1 / 1$
${\color{green}100\%}$
$0 / 0$
src/contracts/transparent-proxy/TransparentProxyFactoryBase.sol ${\color{red}62.5\%}$
$10 / 16$
19, 21, 22, 27, 29 and 1 more
${\color{red}66.67\%}$
$4 / 6$
TransparentProxyFactoryBase.create, TransparentProxyFactoryBase.createProxyAdmin
${\color{green}100\%}$
$0 / 0$
src/contracts/transparent-proxy/TransparentUpgradeableProxy.sol ${\color{red}50\%}$
$5 / 10$
104, 105, 107, 122, 123
${\color{red}75\%}$
$3 / 4$
TransparentUpgradeableProxy._dispatchUpgradeToAndCall
${\color{red}0\%}$
$0 / 4$
src/contracts/utils/PermissionlessRescuable.sol ${\color{green}100\%}$
$2 / 2$
${\color{green}100\%}$
$2 / 2$
${\color{green}100\%}$
$0 / 0$
src/contracts/utils/Rescuable.sol ${\color{green}100\%}$
$4 / 4$
${\color{green}100\%}$
$3 / 3$
${\color{green}100\%}$
$1 / 1$
src/contracts/utils/Rescuable721.sol ${\color{green}100\%}$
$2 / 2$
${\color{green}100\%}$
$1 / 1$
${\color{green}100\%}$
$0 / 0$
src/contracts/utils/RescuableACL.sol ${\color{green}100\%}$
$3 / 3$
${\color{green}100\%}$
$3 / 3$
${\color{green}100\%}$
$0 / 0$
src/contracts/utils/RescuableBase.sol ${\color{green}100\%}$
$8 / 8$
${\color{green}100\%}$
$2 / 2$
${\color{green}100\%}$
$1 / 1$

Copy link
Contributor

github-actions bot commented Dec 21, 2024

🔧 Build logs
Compiling 87 files with Solc 0.8.28
installing solc version "0.8.28"
Successfully installed solc 0.8.28
Solc 0.8.28 finished in 3.54s
Compiler run successful with warnings:
Warning (5667): Unused function parameter. Remove or comment out the variable name to silence this warning.
   --> src/mocks/ERC721.sol:933:23:
    |
933 |     function tokenURI(uint256 id) public view override returns (string memory) {
    |                       ^^^^^^^^^^

Warning (2018): Function state mutability can be restricted to pure
   --> src/mocks/ERC721.sol:923:5:
    |
923 |     function name() public view override returns (string memory) {
    |     ^ (Relevant source part starts here and spans across multiple lines).

Warning (2018): Function state mutability can be restricted to pure
   --> src/mocks/ERC721.sol:928:5:
    |
928 |     function symbol() public view override returns (string memory) {
    |     ^ (Relevant source part starts here and spans across multiple lines).

Warning (2018): Function state mutability can be restricted to pure
   --> src/mocks/ERC721.sol:933:5:
    |
933 |     function tokenURI(uint256 id) public view override returns (string memory) {
    |     ^ (Relevant source part starts here and spans across multiple lines).

Warning (2018): Function state mutability can be restricted to view
  --> test/PermissionlessRescuable.t.sol:63:3:
   |
63 |   function test_whoShouldReceiveFunds() public {
   |   ^ (Relevant source part starts here and spans across multiple lines).

Warning (2018): Function state mutability can be restricted to view
  --> test/UpgradeableOwnableWithGuardian.t.sol:29:3:
   |
29 |   function test_initializer() external {
   |   ^ (Relevant source part starts here and spans across multiple lines).

| Contract                    | Runtime Size (B) | Initcode Size (B) | Runtime Margin (B) | Initcode Margin (B) |
|-----------------------------|------------------|-------------------|--------------------|---------------------|
| Address                     |               85 |               135 |             24,491 |              49,017 |
| ChainHelpers                |               85 |               135 |             24,491 |              49,017 |
| ChainIds                    |               85 |               135 |             24,491 |              49,017 |
| Create2Utils                |              162 |               212 |             24,414 |              48,940 |
| Create3                     |               85 |               135 |             24,491 |              49,017 |
| Create3Factory              |            1,094 |             1,122 |             23,482 |              48,030 |
| ERC1967Proxy                |              163 |             1,014 |             24,413 |              48,138 |
| ERC1967Utils                |               85 |               135 |             24,491 |              49,017 |
| ERC20                       |            2,331 |             3,020 |             22,245 |              46,132 |
| EnumerableSet               |               85 |               135 |             24,491 |              49,017 |
| ImplOwnableWithGuardian     |            1,464 |             1,492 |             23,112 |              47,660 |
| MockContract                |              759 |             1,021 |             23,817 |              48,131 |
| MockERC721                  |            2,421 |             2,449 |             22,155 |              46,703 |
| MockImpl                    |              465 |               690 |             24,111 |              48,462 |
| PermissionlessRescuable     |            1,908 |             2,081 |             22,668 |              47,071 |
| ProxyAdmin                  |            1,039 |             1,275 |             23,537 |              47,877 |
| Rescuable                   |            1,807 |             1,958 |             22,769 |              47,194 |
| Rescuable721                |            2,043 |             2,201 |             22,533 |              46,951 |
| RescuableACL                |            1,695 |             1,827 |             22,881 |              47,325 |
| SafeCast                    |               85 |               135 |             24,491 |              49,017 |
| SafeERC20                   |               85 |               135 |             24,491 |              49,017 |
| StorageSlot                 |               85 |               135 |             24,491 |              49,017 |
| TestNetChainIds             |               85 |               135 |             24,491 |              49,017 |
| TransparentProxyFactory     |            5,314 |             5,342 |             19,262 |              43,810 |
| TransparentUpgradeableProxy |            1,137 |             2,266 |             23,439 |              46,886 |
🔧 Build logs zksync
Compiling 45 files with zksolc and ZKsync solc 0.8.24
zksolc and ZKsync solc 0.8.24 finished in 11.20s
Compiler run successful with warnings:
Warning (2519)
Warning: This declaration shadows an existing declaration.
  --> zksync/test/TransparentProxyFactoryZkSync.t.sol:88:5:
   |
88 |     address proxyAdmin = factory.createDeterministicProxyAdmin(proxyAdminOwner, proxyAdminSalt);
   |     ^^^^^^^^^^^^^^^^^^
Note: The shadowed declaration is here:
  --> zksync/test/TransparentProxyFactoryZkSync.t.sol:14:3:
   |
14 |   ProxyAdmin internal proxyAdmin;
   |   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Warning (2519)
Warning: This declaration shadows an existing declaration.
   --> zksync/test/TransparentProxyFactoryZkSync.t.sol:106:5:
    |
106 |     address proxyAdmin = factory.createDeterministicProxyAdmin(proxyAdminOwner, proxyAdminSalt);
    |     ^^^^^^^^^^^^^^^^^^
Note: The shadowed declaration is here:
  --> zksync/test/TransparentProxyFactoryZkSync.t.sol:14:3:
   |
14 |   ProxyAdmin internal proxyAdmin;
   |   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Warning

┌──────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Warning: Your code or one of its dependencies uses the 'extcodesize' instruction, which is       │
│ usually needed in the following cases:                                                           │
│   1. To detect whether an address belongs to a smart contract.                                   │
│   2. To detect whether the deploy code execution has finished.                                   │
│ zkSync Era comes with native account abstraction support (so accounts are smart contracts,       │
│ including private-key controlled EOAs), and you should avoid differentiating between contracts   │
│ and non-contract addresses.                                                                      │
└──────────────────────────────────────────────────────────────────────────────────────────────────┘
--> lib/forge-std/src/StdCheats.sol
Warning

┌──────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Warning: Your code or one of its dependencies uses the 'extcodesize' instruction, which is       │
│ usually needed in the following cases:                                                           │
│   1. To detect whether an address belongs to a smart contract.                                   │
│   2. To detect whether the deploy code execution has finished.                                   │
│ zkSync Era comes with native account abstraction support (so accounts are smart contracts,       │
│ including private-key controlled EOAs), and you should avoid differentiating between contracts   │
│ and non-contract addresses.                                                                      │
└──────────────────────────────────────────────────────────────────────────────────────────────────┘
--> lib/forge-std/src/StdUtils.sol
Warning

┌──────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Warning: It looks like you are using 'ecrecover' to validate a signature of a user account.      │
│ zkSync Era comes with native account abstraction support, therefore it is highly recommended NOT │
│ to rely on the fact that the account has an ECDSA private key attached to it since accounts might│
│ implement other signature schemes.                                                               │
│ Read more about Account Abstraction at https://v2-docs.zksync.io/dev/developer-guides/aa.html    │
└──────────────────────────────────────────────────────────────────────────────────────────────────┘
--> lib/forge-std/src/mocks/MockERC20.sol
Warning

┌──────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Warning: Your code or one of its dependencies uses the 'extcodesize' instruction, which is       │
│ usually needed in the following cases:                                                           │
│   1. To detect whether an address belongs to a smart contract.                                   │
│   2. To detect whether the deploy code execution has finished.                                   │
│ zkSync Era comes with native account abstraction support (so accounts are smart contracts,       │
│ including private-key controlled EOAs), and you should avoid differentiating between contracts   │
│ and non-contract addresses.                                                                      │
└──────────────────────────────────────────────────────────────────────────────────────────────────┘
--> lib/forge-std/src/mocks/MockERC721.sol
| Contract                      | Runtime Size (B) | Initcode Size (B) | Runtime Margin (B) | Initcode Margin (B) |
|-------------------------------|------------------|-------------------|--------------------|---------------------|
| Address                       |              224 |               224 |            450,775 |             450,775 |
| Create2UtilsZkSync            |              544 |               544 |            450,455 |             450,455 |
| ERC1967Proxy                  |            4,192 |             4,192 |            446,807 |             446,807 |
| ERC1967Utils                  |              224 |               224 |            450,775 |             450,775 |
| MockImpl                      |            2,272 |             2,272 |            448,727 |             448,727 |
| ProxyAdmin                    |            4,512 |             4,512 |            446,487 |             446,487 |
| StorageSlot                   |              224 |               224 |            450,775 |             450,775 |
| TransparentProxyFactoryZkSync |            7,776 |             7,776 |            443,223 |             443,223 |
| TransparentUpgradeableProxy   |            7,136 |             7,136 |            443,863 |             443,863 |

Copy link
Contributor

github-actions bot commented Dec 21, 2024

🌈 Test Results
No files changed, compilation skipped

Ran 1 test for test/ChainHelperTest.t.sol:TestChainHelpers
[PASS] test_selectChain_shouldRevert() (gas: 3293)
Suite result: ok. 1 passed; 0 failed; 0 skipped; finished in 357.30µs (109.44µs CPU time)

Ran 6 tests for test/PermissionlessRescuable.t.sol:PermissionlessRescuableTest
[PASS] test_emergencyEtherTransfer() (gas: 59257)
[PASS] test_emergencyEtherTransferInsufficientBalance_shouldRevert() (gas: 45456)
[PASS] test_emergencyTokenTransfer() (gas: 81017)
[PASS] test_emergencyTokenTransferInsufficientBalance_shouldRevert() (gas: 21438)
[PASS] test_emergencyTokenTransfer_withTransferRestriction() (gas: 115750)
[PASS] test_whoShouldReceiveFunds() (gas: 12734)
Suite result: ok. 6 passed; 0 failed; 0 skipped; finished in 947.33µs (557.61µs CPU time)

Ran 5 tests for test/Rescuable.t.sol:RescueTest
[PASS] testEmergencyEtherTransfer() (gas: 57744)
[PASS] testEmergencyEtherTransferWhenNotOwner() (gas: 17666)
[PASS] testEmergencyTokenTransfer() (gas: 231216)
[PASS] testEmergencyTokenTransferWhenNotOwner() (gas: 203504)
[PASS] testToken() (gas: 2392)
Suite result: ok. 5 passed; 0 failed; 0 skipped; finished in 2.41ms (2.04ms CPU time)

Ran 6 tests for test/OwnableWithGuardian.t.sol:TestOfOwnableWithGuardian
[PASS] testConstructorLogic() (gas: 18202)
[PASS] testGuardianUpdateNoAccess() (gas: 14902)
[PASS] testGuardianUpdateViaGuardian(address) (runs: 256, μ: 19408, ~: 19419)
[PASS] testGuardianUpdateViaOwner(address) (runs: 256, μ: 19236, ~: 19236)
[PASS] test_onlyGuardianGuard() (gas: 12577)
[PASS] test_onlyGuardianGuard_shouldRevert() (gas: 10566)
Suite result: ok. 6 passed; 0 failed; 0 skipped; finished in 28.74ms (25.21ms CPU time)

Ran 3 tests for test/Rescuable721.t.sol:Rescue721Test
[PASS] testFuzzEmergencyTokenTransfer(address) (runs: 256, μ: 79081, ~: 79081)
[PASS] testFuzzEmergencyTokenTransferWhenNotOwner(address,address) (runs: 256, μ: 71859, ~: 71859)
[PASS] testToken() (gas: 2458)
Suite result: ok. 3 passed; 0 failed; 0 skipped; finished in 60.92ms (60.55ms CPU time)

Ran 5 tests for test/RescuableACL.t.sol:RescueACLTest
[PASS] testEmergencyEtherTransfer() (gas: 57746)
[PASS] testEmergencyEtherTransferWhenNotOwner() (gas: 17659)
[PASS] testEmergencyTokenTransfer() (gas: 231235)
[PASS] testEmergencyTokenTransferWhenNotOwner() (gas: 203516)
[PASS] testToken() (gas: 2392)
Suite result: ok. 5 passed; 0 failed; 0 skipped; finished in 2.47ms (2.11ms CPU time)

Ran 6 tests for test/UpgradeableOwnableWithGuardian.t.sol:TestOfUpgradableOwnableWithGuardian
[PASS] test_initializer() (gas: 18304)
[PASS] test_onlyGuardian() (gas: 11066)
[PASS] test_onlyOwnerOrGuardian() (gas: 13262)
[PASS] test_updateGuardian_eoa(address,address) (runs: 256, μ: 18703, ~: 18703)
[PASS] test_updateGuardian_guardian(address) (runs: 256, μ: 19684, ~: 19684)
[PASS] test_updateGuardian_owner(address) (runs: 256, μ: 19400, ~: 19400)
Suite result: ok. 6 passed; 0 failed; 0 skipped; finished in 66.52ms (66.31ms CPU time)

Ran 2 tests for test/create3Test.t.sol:Create3FactoryTest
[PASS] testCreate3WithValue(address,address,address) (runs: 256, μ: 280857, ~: 280857)
[PASS] testCreate3WithoutValue(address,address,bytes32) (runs: 256, μ: 283786, ~: 283786)
Suite result: ok. 2 passed; 0 failed; 0 skipped; finished in 104.99ms (110.18ms CPU time)

Ran 4 tests for test/TransparentProxyFactory.t.sol:TestTransparentProxyFactory
[PASS] testCreateDeterministic(address,bytes32) (runs: 256, μ: 384826, ~: 384826)
[PASS] testCreateDeterministicProxyAdmin(address,bytes32) (runs: 256, μ: 282376, ~: 282376)
[PASS] testCreateDeterministicWithDeterministicProxy(bytes32,bytes32) (runs: 256, μ: 391377, ~: 391377)
[PASS] testCreateProxyAdmin(address,bytes32) (runs: 256, μ: 276438, ~: 276438)
Suite result: ok. 4 passed; 0 failed; 0 skipped; finished in 148.67ms (222.83ms CPU time)

Ran 9 test suites in 150.63ms (416.03ms CPU time): 38 tests passed, 0 failed, 0 skipped (38 total tests)
🌈 Test Results zksync
Compiling 43 files with Solc 0.8.24
Solc 0.8.24 finished in 1.52s
Compiler run successful with warnings:
Warning (2519): This declaration shadows an existing declaration.
  --> zksync/test/TransparentProxyFactoryZkSync.t.sol:88:5:
   |
88 |     address proxyAdmin = factory.createDeterministicProxyAdmin(proxyAdminOwner, proxyAdminSalt);
   |     ^^^^^^^^^^^^^^^^^^
Note: The shadowed declaration is here:
  --> zksync/test/TransparentProxyFactoryZkSync.t.sol:14:3:
   |
14 |   ProxyAdmin internal proxyAdmin;
   |   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Warning (2519): This declaration shadows an existing declaration.
   --> zksync/test/TransparentProxyFactoryZkSync.t.sol:106:5:
    |
106 |     address proxyAdmin = factory.createDeterministicProxyAdmin(proxyAdminOwner, proxyAdminSalt);
    |     ^^^^^^^^^^^^^^^^^^
Note: The shadowed declaration is here:
  --> zksync/test/TransparentProxyFactoryZkSync.t.sol:14:3:
   |
14 |   ProxyAdmin internal proxyAdmin;
   |   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^


No files changed, compilation skipped

Ran 5 tests for zksync/test/TransparentProxyFactoryZkSync.t.sol:TestTransparentProxyFactoryZkSync
[PASS] testCreate() (gas: 343998)
[PASS] testCreateDeterministic(bytes32) (runs: 256, μ: 577061, ~: 577061)
[PASS] testCreateDeterministicProxyAdmin(address,bytes32) (runs: 256, μ: 466597, ~: 471484)
[PASS] testCreateDeterministicWithDeterministicProxy(bytes32,bytes32) (runs: 256, μ: 688155, ~: 688155)
[PASS] testCreateProxyAdmin(address,bytes32) (runs: 256, μ: 355093, ~: 359879)
Suite result: ok. 5 passed; 0 failed; 0 skipped; finished in 9.79s (31.29s CPU time)

Ran 1 test suite in 9.79s (9.79s CPU time): 5 tests passed, 0 failed, 0 skipped (5 total tests)

Copy link
Contributor

github-actions bot commented Dec 21, 2024

Gas report

Create3Factory

  • size: 1122 / 49152
Method min mean median max calls
create(bytes32,bytes) 41711 209977 293930 294290 3
predictAddress(address,bytes32) 1020 1020 1020 1020 2

ProxyAdmin

  • size: 1307 / 49152
Method min mean median max calls
owner() 288 288 288 288 2

TransparentProxyFactory

  • size: 5342 / 49152
Method min mean median max calls
createDeterministic(address,address,bytes,bytes32) 384886 384898 384898 384910 2
createDeterministicProxyAdmin(address,bytes32) 288368 288644 288644 288920 2
predictCreateDeterministic(address,address,bytes,bytes32) 8698 8698 8698 8698 2
predictCreateDeterministicProxyAdmin(bytes32,address) 4876 4876 4876 4876 2

TransparentUpgradeableProxy

  • size: 2458 / 49152
Method min mean median max calls
fallback() 682 682 682 682 2

ERC20

  • size: 3212 / 49152
Method min mean median max calls
balanceOf(address) 559 901 559 2559 35
mint(address,uint256) 68172 68172 68172 68172 2
transfer(address,uint256) 51464 51464 51464 51464 4

MockERC721

  • size: 2449 / 49152
Method min mean median max calls
balanceOf(address) 605 605 605 605 4
mint(address,uint256) 68318 68318 68318 68318 2
transferFrom(address,address,uint256) 54097 54097 54097 54097 1

MockImpl

  • size: 690 / 49152
Method min mean median max calls
getFoo() 246 246 246 246 2
initialize(uint256) 46312 46312 46312 46312 2

ImplOwnableWithGuardian

  • size: 1198 / 49152
Method min mean median max calls
guardian() 352 637 352 2352 7
mock_onlyGuardian() 23394 23446 23446 23498 2
owner() 339 624 339 2339 7
transferOwnership(address) 28570 28570 28570 28570 6
updateGuardian(address) 26169 29998 30519 30519 9

PermissionlessRescuable

  • size: 2145 / 49152
Method min mean median max calls
emergencyEtherTransfer(uint256) 58362 59268 59268 60174 2
emergencyTokenTransfer(address,uint256) 32816 48600 49095 63393 4
receive() 0 0 0 0 1
whoShouldReceiveFunds() 2362 2362 2362 2362 1

Rescuable

  • size: 1990 / 49152
Method min mean median max calls
emergencyEtherTransfer(address,uint256) 21907 40134 40134 58361 2
emergencyTokenTransfer(address,address,uint256) 22291 37918 37918 53545 2
receive() 21055 21055 21055 21055 2

Rescuable721

  • size: 2233 / 49152
Method min mean median max calls
emergency721TokenTransfer(address,address,uint256) 22423 40970 40970 59517 2

RescuableACL

  • size: 1859 / 49152
Method min mean median max calls
emergencyEtherTransfer(address,uint256) 21900 40131 40131 58363 2
emergencyTokenTransfer(address,address,uint256) 22306 37937 37937 53569 2
receive() 21055 21055 21055 21055 2

ImplOwnableWithGuardian

  • size: 1492 / 49152
Method min mean median max calls
guardian() 2391 2391 2391 2391 1
initialize(address,address) 93656 93656 93656 93656 6
mock_onlyGuardian() 23513 23513 23513 23513 1
mock_onlyOwnerOrGuardian() 25753 25753 25753 25753 1
owner() 2379 2379 2379 2379 1
updateGuardian(address) 26343 29184 30472 30739 3

MockContract

  • size: 1085 / 49152
Method min mean median max calls
SOME_ADDRESS() 269 269 269 269 1
owner() 361 361 361 361 1

@Cycxyz Cycxyz marked this pull request as draft December 23, 2024 13:32
@Cycxyz Cycxyz marked this pull request as ready for review December 23, 2024 13:34
Comment on lines 13 to 16
* a deterministic address, you need to provide not the contract creation code, but the hash of the contract bytecode.
* Then zkSync tries to match the provided bytecode hash with contracts that already exist on the network. If it finds one,
* the contract will be deployed. These utils use the Create2Factory contract, so before trying to deploy a contract with a
* deterministic address, you first need to deploy it at a random address to let zkSync remember its bytecode.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This way for every contract deployment using create2 we first need to deploy the contract using create1 so that the bytecode hash is known, although it works but it is not efficient imo and could be done in a single step.

Deploying via create2 on zksync, we need to pass the bytecode hash from our side and the contract bytecode which needs to be passed via the factory_deps is the job of foundry-zksync to handle internally.
Thus deploying the contract using create1 from our end so that the bytecode hash is known is not needed and should be done by foundry-zksync.

Reference

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly, but foundry doesn't provide EIP 712 transaction type to make it possible

* @param data The bytecode from which to extract the hash.
* @return The extracted 32-byte hash.
*/
function getBytecodeHashFromBytecode(bytes memory data) internal pure returns (bytes32) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would not name this method as getBytecodeHashFromBytecode because this method is not actually converting the contract bytecode to bytecodeHash but rather is just sanitizing the bytecodeHash being received.

As foundry-zksync, when type(Contract).creationCode is used in script does not return the contract bytecode but rather the unformatted / unsanitized bytecodeHash

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants