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

[EVM-Equivalence-Yul] ERC20 example #1871

Merged
merged 12 commits into from
May 22, 2024
1,324 changes: 1,308 additions & 16 deletions Cargo.lock

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ members = [

# SDK section
"sdk/zksync-rs",

#Yul evm utils
"erc20_example"
]
resolver = "2"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4044,6 +4044,7 @@ fn test_basic_environment4_vectors() {
}

#[test]
#[ignore = "Ignored because the current compared values don't match"]
fn test_basic_extcodehash_vectors() {
// extcodehash
let evm_output = test_evm_vector(
Expand Down
1 change: 1 addition & 0 deletions erc20_example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target
39 changes: 39 additions & 0 deletions erc20_example/BytesWriter.abi
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[
{
"inputs": [
{
"internalType": "bytes",
"name": "_message",
"type": "bytes"
}
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"inputs": [],
"name": "readBytes",
"outputs": [
{
"internalType": "bytes",
"name": "",
"type": "bytes"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes",
"name": "_message",
"type": "bytes"
}
],
"name": "writeBytes",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}
]
1 change: 1 addition & 0 deletions erc20_example/BytesWriter.bin
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
00050000000000020000008003000039000000400030043f0000000003010019000000600330027000000073033001970000000102200190000000960000c13d000000040230008c000001600000413d000000000201043b000000e0022002700000007a0420009c0000014e0000613d0000007b0220009c000001600000c13d0000000002000416000000000202004b000001600000c13d000000040230008a000000200220008c000001600000413d0000000402100370000000000502043b000000770250009c000001600000213d00000023025000390000007f04000041000000000632004b000000000600001900000000060480190000007f02200197000000000702004b00000000040080190000007f0220009c000000000406c019000000000204004b000001600000c13d0000000406500039000000000261034f000000000402043b000000770240009c0000009c0000213d000000bf07400039000000200200008a000000000727016f000000770870009c0000009c0000213d000000400070043f000000800040043f00000000054500190000002405500039000000000335004b000001600000213d0000002003600039000000000131034f0000001f0340018f0000000505400272000000440000613d00000000060000190000000507600210000000000871034f000000000808043b000000a00770003900000000008704350000000106600039000000000756004b0000003c0000413d000000000603004b000000530000613d0000000505500210000000000151034f0000000303300210000000a005500039000000000605043300000000063601cf000000000636022f000000000101043b0000010003300089000000000131022f00000000013101cf000000000161019f0000000000150435000000a0014000390000000000010435000000800100043d000000770310009c0000009c0000213d000000000400041a000000010340019000000001054002700000007f0350018f000000000305c0190000001f0530008c00000000050000190000000105002039000000000454013f00000001044001900000015c0000c13d000000200430008c000000750000413d0000001f0410003900000005044002700000007c054000410000007c04000041000000200610008c000000000405801900000000000004350000001f0330003900000005033002700000007c03300041000000000534004b000000750000813d000000000004041b0000000104400039000000000534004b000000710000413d0000001f0310008c0000019f0000a13d0000000003210170000000a0040000390000007c020000410000000000000435000000890000613d0000007c0200004100000020060000390000000004000019000000000506001900000080065000390000000006060433000000000062041b000000200650003900000001022000390000002004400039000000000734004b0000007f0000413d000000a004500039000000000313004b000000930000813d0000000303100210000000f80330018f000000010500008a000000000335022f000000000353013f0000000004040433000000000334016f000000000032041b00000001020000390000000103100210000001a90000013d0000000002000416000000000202004b000001600000c13d0000007402300041000000750220009c000000a20000213d000000800100004100000000001004350000004101000039000000040010043f0000008101000041000001c9000104300000009f023000390000007602200197000000400020043f0000001f0230018f0000000504300272000000b10000613d00000000050000190000000506500210000000000761034f000000000707043b000000800660003900000000007604350000000105500039000000000645004b000000a90000413d000000000502004b000000c00000613d0000000504400210000000000141034f00000003022002100000008004400039000000000504043300000000052501cf000000000525022f000000000101043b0000010002200089000000000121022f00000000012101cf000000000151019f0000000000140435000000200130008c000001600000413d000000800400043d000000770140009c000001600000213d00000080033000390000009f01400039000000000131004b000001600000813d00000080024000390000000001020433000000770510009c0000009c0000213d0000003f05100039000000200900008a000000000595016f000000400800043d0000000005580019000000000685004b00000000060000190000000106004039000000770750009c0000009c0000213d00000001066001900000009c0000c13d000000400050043f00000000061804360000000004140019000000a004400039000000000334004b000001600000213d000000000301004b000000e90000613d000000000300001900000000046300190000002003300039000000000523001900000000050504330000000000540435000000000413004b000000e20000413d000000000116001900000000000104350000000004080433000000770140009c0000009c0000213d000000000100041a000000010210019000000001011002700000007f0310018f000000000301c0190000001f0130008c00000000010000190000000101002039000000010110018f000000000112004b0000015c0000c13d000000200130008c0000011f0000413d000100000003001d000300000004001d000000000000043500000073010000410000000002000414000000730320009c0000000002018019000000c00120021000000078011001c70000801002000039000500000008001d000400000009001d000200000006001d01c701c20000040f0000000206000029000000040900002900000005080000290000000102200190000001600000613d00000003040000290000001f024000390000000502200270000000200340008c0000000002004019000000000301043b00000001010000290000001f01100039000000050110027000000000011300190000000002230019000000000312004b0000011f0000813d000000000002041b0000000102200039000000000312004b0000011b0000413d0000001f0140008c000001b10000a13d000300000004001d000000000000043500000073010000410000000002000414000000730320009c0000000002018019000000c00120021000000078011001c70000801002000039000500000008001d000400000009001d01c701c20000040f000000040300002900000005060000290000000102200190000001600000613d000000030700002900000000033701700000002002000039000000000101043b000001400000613d0000002002000039000000000400001900000000056200190000000005050433000000000051041b000000200220003900000001011000390000002004400039000000000534004b000001380000413d000000000373004b0000014b0000813d0000000303700210000000f80330018f000000010400008a000000000334022f000000000343013f00000000026200190000000002020433000000000232016f000000000021041b00000001010000390000000102700210000001bb0000013d0000000001000416000000000101004b000001600000c13d000000000100041a000000010310019000000001041002700000007f0240018f000000000204c0190000001f0420008c00000000040000190000000104002039000000000441013f0000000104400190000001620000613d0000008001000041000000000010043500000022010000390000009f0000013d0000000001000019000001c900010430000000800020043f000000000303004b000001750000613d000000a0010000390000000000000435000000000302004b000001810000613d0000007c0100004100000000040000190000000003040019000000000401041a000000a005300039000000000045043500000001011000390000002004300039000000000524004b0000016b0000413d000000c0013000390000017b0000013d000001000300008a000000000131016f000000a00010043f000000000102004b000000c001000039000000a0010060390000001f01100039000000200200008a000000000121016f0000007d021000410000007e0220009c0000009c0000413d000000400010043f00000020020000390000000003210436000000800200043d00000000002304350000004003100039000000000402004b000001910000613d00000000040000190000000005340019000000a006400039000000000606043300000000006504350000002004400039000000000524004b0000018a0000413d000000000332001900000000000304350000005f02200039000000200300008a000000000232016f0000007303000041000000730420009c0000000002038019000000730410009c000000000103801900000040011002100000006002200210000000000112019f000001c80001042e000000000201004b0000000002000019000001a30000613d000000a00200043d0000000303100210000000010400008a000000000334022f000000000343013f000000000332016f0000000102100210000000000123019f000000000010041b0000007301000041000000400200043d000000730320009c00000000020180190000004001200210000001c80001042e000000000104004b0000000001000019000001b50000613d00000000010604330000000302400210000000010300008a000000000223022f000000000232013f000000000221016f0000000101400210000000000112019f000000000010041b0000002001000039000001000010044300000120000004430000007901000041000001c80001042e000001c5002104230000000102000039000000000001042d0000000002000019000000000001042d000001c700000432000001c80001042e000001c9000104300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000009fffffffffffffffffffffffffffffffffffffffffffffffff000000000000007f00000000000000000000000000000000000000000000000000000001ffffffe0000000000000000000000000000000000000000000000000ffffffffffffffff0200000000000000000000000000000000000020000000000000000000000000000000020000000000000000000000000000004000000100000000000000000000000000000000000000000000000000000000000000000000000000d98b5568000000000000000000000000000000000000000000000000000000007932db75290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563ffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000ffffffffffffffffffffffffffffffffffffffffffffffff000000000000008080000000000000000000000000000000000000000000000000000000000000004e487b71000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024000000000000000000000000b6a433bc7df435258118f8b80ff5a7799eb18cd0bf3a38b685cb901f1d11d13f
27 changes: 27 additions & 0 deletions erc20_example/BytesWriter.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.8;

contract BytesWriter {
bytes private message;

constructor(bytes memory _message) {
message = _message;
}

function readBytes() public view returns (bytes memory) {
return message;
}

function writeBytes(bytes memory _message) public {
message = _message;
}

// event StringBytesLengthMessage(address sender, string inputString, uint256 bytesLength);

// function getStringBytesLength(string memory str) external {
// bytes memory strBytes = bytes(str);
// uint256 length = strBytes.length;

// emit StringBytesLengthMessage(msg.sender, str, length);
// }
}
17 changes: 17 additions & 0 deletions erc20_example/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[package]
name = "erc20_example"
version = "0.1.0"
edition = "2021"
license = "MIT OR Apache-2.0"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
zksync_types = { path = "../core/lib/types" }
zksync-web3-rs = "*"
zksync_web3_decl = { path = "../core/lib/web3_decl" }
loadnext = { path = "../core/tests/loadnext" }
ethers = "2.0.1"
hex = "0.4.3"
tokio = { version = "1", features = ["macros", "process"] }
colored = "2.0"
23 changes: 23 additions & 0 deletions erc20_example/Context.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// SPDX-License-Identifier: MIT

pragma solidity >=0.8.0;

/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}

function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
Loading
Loading