forked from foundry-rs/book
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add cheatcodes, configuration, forge-zksync-std (#18)
- Loading branch information
Showing
14 changed files
with
390 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
## Forge ZKsync Standard Library Overview | ||
|
||
Forge ZKsync Standard Library is an addition to the [Forge Standard Library](./forge-std.md) that adds further collection of helpful contracts that make writing tests easier, faster, and more user-friendly for the ZKsync ecosystem. | ||
|
||
Refer to this [section](../zksync-specifics/forge-zksync-std.md) for more details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
## `zkRegisterContract` | ||
|
||
### Signature | ||
|
||
```solidity | ||
function zkRegisterContract( | ||
string calldata name, | ||
bytes32 evmBytecodeHash, | ||
bytes calldata evmDeployedBytecode, | ||
bytes calldata evmBytecode, | ||
bytes32 zkBytecodeHash, | ||
bytes calldata zkDeployedBytecode | ||
) external pure; | ||
``` | ||
|
||
### Description | ||
|
||
Registers bytecodes for ZK-VM for transact/call and create instructions. | ||
|
||
This is especially useful if there are certain contracts already deployed on-chain (EVM or ZKsync). Since we compile with both `solc` and `zksolc` as defined in the [Dual Compilation](../compilation-overview.md#dual-compilation) section, if there's an already existing EVM bytecode that must be translated into its zkEVM counterpart, we need to define it with this cheatcode. | ||
|
||
Such an operation must be carried out separately where the source of the pre-deployed contract must be obtained and compiled with zksolc. The artifact json will contain the `zkBytecodeHash` and `zkDeployedBytecode` parameters. The process is similar for obtaining EVM parameters with `solc` - `evmBytecodeHash`, `evmDeployedBytecode`, `evmBytecode`. | ||
|
||
The `name` parameter must be unique if possible and not clash with locally existing contracts. | ||
|
||
### Examples | ||
|
||
```solidity | ||
// LeetContract is pre-deployed on EVM on address(65536) | ||
/// interface ILeetContract { | ||
/// function leet() public { | ||
/// // do something | ||
/// } | ||
/// } | ||
vmExt.zkVm(true); | ||
ILeetContract(address(65536)).leet(); // fails, as the contract was not found locally so not migrated to zkEVM | ||
vmExt.zkRegisterContract("LeetContract", 0x111.., 0x222.., 0x333..., 0x444..., 0x555...); // register LeetContract for migration | ||
vmExt.zkVm(true); | ||
ILeetContract(address(65536)).leet(); // succeeds, as the contract was registered via cheatcode, so migrated to zkEVM | ||
``` |
Oops, something went wrong.