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

[DO NOT MERGE] CI EVM Yul #217

Draft
wants to merge 219 commits into
base: evm-equivalence-yul
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
219 commits
Select commit Hold shift + click to select a range
ab0165c
Add addmod opcode
ManuelBilbao Apr 8, 2024
5147884
Add mulmod opcode
ManuelBilbao Apr 8, 2024
5b322f6
Add ext opcode
ManuelBilbao Apr 8, 2024
cb09228
Add signextend opcode
ManuelBilbao Apr 8, 2024
0edb493
Add div opcode
ManuelBilbao Apr 9, 2024
8d92309
Merge pull request #1613 from lambdaclass/addmod-mulmod
jrchatruc Apr 9, 2024
1310949
Merge remote-tracking branch 'upstream/evm-equivalence-yul' into evm-…
jrchatruc Apr 9, 2024
02ab414
Add sdiv opcode
ManuelBilbao Apr 9, 2024
a5df05f
Add mod opcode
ManuelBilbao Apr 9, 2024
692f645
Add smod opcode
ManuelBilbao Apr 9, 2024
5371db4
Resolve conflicts
ManuelBilbao Apr 9, 2024
d369e6f
Update contracts submodule
jrchatruc Apr 9, 2024
fb5621d
Merge pull request #1615 from lambdaclass/yul-ext-signext
jrchatruc Apr 9, 2024
fcd2e5a
Merge remote-tracking branch 'upstream/evm-equivalence-yul' into yul-…
jrchatruc Apr 9, 2024
4d16850
Merge pull request #1622 from lambdaclass/yul-div-opcodes
jrchatruc Apr 9, 2024
a6bbaaf
Merge remote-tracking branch 'upstream/evm-equivalence-yul' into evm-…
jrchatruc Apr 9, 2024
8a7fdbc
Update contracts submodule
jrchatruc Apr 9, 2024
d5552ba
Add jump opcode
ManuelBilbao Apr 9, 2024
98a2131
Add jumpi opcode
ManuelBilbao Apr 9, 2024
53658ff
Add lt opcode
ManuelBilbao Apr 9, 2024
0c31718
Add gt opcode
ManuelBilbao Apr 9, 2024
392159e
Add slt opcode
ManuelBilbao Apr 9, 2024
adce396
Move signextend tests
ManuelBilbao Apr 9, 2024
d8aa5c9
Add sgt opcode
ManuelBilbao Apr 9, 2024
4cdd554
feat(dup-opcode): Add tests
fborello-lambda Apr 9, 2024
012c50d
Add eq opcode
ManuelBilbao Apr 9, 2024
5bceceb
Add iszero opcode
ManuelBilbao Apr 9, 2024
fda8fca
Add xor opcode
ManuelBilbao Apr 9, 2024
98c893a
Add basic "print" functions
jrchatruc Apr 9, 2024
9234173
Add not opcode
ManuelBilbao Apr 9, 2024
b90ef60
refactor(dup-opcode): Add tests for dup opcode
fborello-lambda Apr 9, 2024
acdacf0
Add byte opcode
ManuelBilbao Apr 10, 2024
09841f3
feat(swap-opcode): Add tests for swap opcodes
fborello-lambda Apr 10, 2024
62960aa
chore(dup-opcode): Remove println from test
fborello-lambda Apr 10, 2024
513fb7d
Merge branch 'evm-dup-opcode-tests' into evm-yul-swap-opcode
fborello-lambda Apr 10, 2024
4d1a3eb
Update submodule
jrchatruc Apr 10, 2024
79a9451
Add pop opcode
ManuelBilbao Apr 10, 2024
abd5fd1
Resolve conflicts
ManuelBilbao Apr 10, 2024
7d6c21d
Update contracts submodule
ManuelBilbao Apr 10, 2024
84ece96
Resolve conflicts
ManuelBilbao Apr 10, 2024
12a775b
Better print functionality
jrchatruc Apr 10, 2024
a32e796
Update submodule
jrchatruc Apr 10, 2024
fac2289
Update submodule
jrchatruc Apr 10, 2024
28a4707
Resolve conflicts
ManuelBilbao Apr 10, 2024
c7c47b8
Add mload and mstore opcodes
ManuelBilbao Apr 10, 2024
d390c78
Add sload op
gianbelinche Apr 10, 2024
12237d5
Add tests to mload and mstore
ManuelBilbao Apr 10, 2024
21fd7db
Add mstore8 opcode
ManuelBilbao Apr 10, 2024
c91f8f5
Update contracts commit
ManuelBilbao Apr 10, 2024
cb77026
Update submodule
jrchatruc Apr 10, 2024
12cca5e
Merge remote-tracking branch 'upstream/evm-equivalence-yul' into yul-…
jrchatruc Apr 10, 2024
5066257
Merge pull request #1624 from lambdaclass/yul-jump
jrchatruc Apr 10, 2024
abe16fc
Merge remote-tracking branch 'upstream/evm-equivalence-yul' into yul-…
jrchatruc Apr 10, 2024
f6c0289
Update submodule
jrchatruc Apr 10, 2024
d9451cf
Merge pull request #1625 from lambdaclass/yul-logic-operators
jrchatruc Apr 10, 2024
431c123
Merge remote-tracking branch 'upstream/evm-equivalence-yul' into evm-…
jrchatruc Apr 10, 2024
8a57b95
Merge pull request #1626 from lambdaclass/evm-dup-opcode-tests
jrchatruc Apr 10, 2024
a8abb42
Merge branch 'evm-equivalence-yul' into evm-yul-swap-opcode
jrchatruc Apr 10, 2024
b71fef8
Merge remote-tracking branch 'upstream/evm-equivalence-yul' into evm-…
jrchatruc Apr 10, 2024
4eb62d6
Merge pull request #1633 from lambdaclass/evm-yul-swap-opcode
jrchatruc Apr 10, 2024
8c230ff
Add address opcode
ManuelBilbao Apr 10, 2024
3ff3194
Fix address test
ManuelBilbao Apr 10, 2024
553663a
Add pc opcode
ManuelBilbao Apr 10, 2024
b6005f1
Add balance opcode
ManuelBilbao Apr 10, 2024
0d15b4f
Add origin opcode
ManuelBilbao Apr 10, 2024
162a598
feat(keccak-opcode): add tests template (WIP)
fborello-lambda Apr 11, 2024
ca36bf3
chore(keccak-opcode): cargo fmt
fborello-lambda Apr 11, 2024
626a71d
Add gas opcode
ManuelBilbao Apr 11, 2024
9f0a55c
Add caller opcode
ManuelBilbao Apr 11, 2024
755131b
feat(blockenvironment-opcodes): Add basic tests
fborello-lambda Apr 11, 2024
2d766c9
chore(blockenvironment-opcodes): remove comment
fborello-lambda Apr 11, 2024
b4fa603
Delete .envrc
ManuelBilbao Apr 11, 2024
8712138
Add callvalue opcode
ManuelBilbao Apr 11, 2024
96c3fe3
Add calldataload opcode
ManuelBilbao Apr 11, 2024
1734fe6
Add calldatasize opcode
ManuelBilbao Apr 11, 2024
e8e9f50
feat(environment3-opcodes): add tests for OPs: CODESIZE CODECOPY GASP…
fborello-lambda Apr 11, 2024
1342006
Add cold/warm cases for sload and sstore
gianbelinche Apr 11, 2024
61a2e27
Add msize op
gianbelinche Apr 11, 2024
e1f3e65
Fix sload tests
gianbelinche Apr 11, 2024
55d4441
Add calldatacopy opcode
ManuelBilbao Apr 11, 2024
d5a647b
fix(keccak-opcode): fix tests
fborello-lambda Apr 11, 2024
8162cac
Update submodule
ManuelBilbao Apr 11, 2024
983cb8e
Resolve conflicts
ManuelBilbao Apr 12, 2024
ff073b5
Merge pull request #1639 from lambdaclass/yul-stack-memory
jrchatruc Apr 12, 2024
3ddb360
Fix mstore opcode
ManuelBilbao Apr 12, 2024
4e71b40
Merge branch 'evm-equivalence-yul' into evm-yul-stack-memory-2
gianbelinche Apr 12, 2024
b6b8903
feat(codecopy-opcode): Add test for codecopy
fborello-lambda Apr 12, 2024
4dccda9
Update contracts
gianbelinche Apr 12, 2024
7103d47
Remove todo comment
gianbelinche Apr 12, 2024
c8afd45
Merge pull request #1637 from lambdaclass/evm-yul-stack-memory-2
jrchatruc Apr 12, 2024
a462067
fix(keccak-opcode): Fix test
fborello-lambda Apr 12, 2024
cb1b166
Resolve conflicts
ManuelBilbao Apr 12, 2024
86179cf
Resolve conflicts
ManuelBilbao Apr 12, 2024
8a551ef
Merge pull request #1640 from lambdaclass/yul-environment-1
jrchatruc Apr 12, 2024
2c01ef8
Merge remote-tracking branch 'upstream/evm-equivalence-yul' into yul-…
jrchatruc Apr 12, 2024
c16505d
Merge pull request #1655 from lambdaclass/yul-environment-2
jrchatruc Apr 12, 2024
a918bd4
Merge remote-tracking branch 'upstream/evm-equivalence-yul' into evm-…
jrchatruc Apr 12, 2024
244d826
Merge pull request #1656 from lambdaclass/evm-yul-blockenvironment-op…
jrchatruc Apr 12, 2024
ed2ca14
Fix tests
ManuelBilbao Apr 12, 2024
2e0e44f
Resolve conflicts
ManuelBilbao Apr 12, 2024
2ec3171
Merge pull request #1679 from lambdaclass/yul-charge-gas
jrchatruc Apr 12, 2024
295c50a
fix(codecopy): Fix test
fborello-lambda Apr 12, 2024
5a218df
chore(contracts): Add last commit of era-contracts/evm-equivalence-yul
fborello-lambda Apr 12, 2024
a37ef82
chore(codesize-test): change comment
fborello-lambda Apr 12, 2024
9ab2eb0
chore(codesize-test): Change comment
fborello-lambda Apr 12, 2024
b477df3
Add balance gas test
gianbelinche Apr 12, 2024
8e4746b
Add balance gas tests
gianbelinche Apr 15, 2024
3eeff80
fix(submodule contracts): fix commit of submodule /contracts
fborello-lambda Apr 15, 2024
5300bc1
Merge remote-tracking branch 'matterlabs/evm-equivalence-yul' into ev…
fborello-lambda Apr 15, 2024
3580021
Add balance gas test
gianbelinche Apr 12, 2024
e3a21cf
Add balance gas tests
gianbelinche Apr 15, 2024
b6eadee
Change contracts submodule
gianbelinche Apr 15, 2024
8e223ac
Merge branch 'evm-balance-dynamic-gas' of github.com:lambdaclass/zksy…
gianbelinche Apr 15, 2024
60746ad
Update submodule
jrchatruc Apr 15, 2024
6faf370
Fix balance tests gas results
gianbelinche Apr 15, 2024
f6bcc07
fix(byte_opcodes): Fix tests
fborello-lambda Apr 15, 2024
79d3396
Update contracts
gianbelinche Apr 15, 2024
46da653
Merge pull request #1662 from lambdaclass/evm-yul-environment3-opcodes
jrchatruc Apr 15, 2024
c85c1fe
Merge matter-labs/evm-equivalence-yul into lambdaclass/evm-yul-keccak…
fborello-lambda Apr 15, 2024
b22adff
Update submodule
jrchatruc Apr 15, 2024
1f8fb2a
Merge pull request #1663 from lambdaclass/evm-yul-keccak-opcode
jrchatruc Apr 15, 2024
4d1051d
Merge remote-tracking branch 'upstream/evm-equivalence-yul' into evm-…
jrchatruc Apr 15, 2024
65dea14
Merge pull request #1680 from lambdaclass/evm-balance-dynamic-gas
jrchatruc Apr 15, 2024
c6c4f1e
Merge remote-tracking branch 'matterlabs/evm-equivalence-yul' into ev…
fborello-lambda Apr 15, 2024
9151761
Merge matter-labs/evm-equivalence-yul into lambdaclass/evm-yul-byte-o…
fborello-lambda Apr 15, 2024
74d86ef
fix(submodule contracts): fix commit of submodule /contracts
fborello-lambda Apr 15, 2024
9ebbfb0
Initial tests of return and revert
gianbelinche Apr 15, 2024
be919c2
feat(log0..4-opcodes): Implement tests for log opcodes
fborello-lambda Apr 16, 2024
2df2b4a
fix(log0..4-opcodes): Remove imports
fborello-lambda Apr 16, 2024
31f69f4
fix(log0..4-opcodes): Check if the memory value logged is valid
fborello-lambda Apr 16, 2024
cb8d42f
Add callcode tests
gianbelinche Apr 16, 2024
2d60a79
Add tests for create opcode
ManuelBilbao Apr 16, 2024
aea9b89
Remove debug code
gianbelinche Apr 16, 2024
b914c80
Format code
gianbelinche Apr 16, 2024
c377180
Merge pull request #1693 from lambdaclass/evm-yul-byte-opcodes
jrchatruc Apr 17, 2024
6f1e35f
Add invalid test
gianbelinche Apr 17, 2024
8bf079f
Add more complex contract create
ManuelBilbao Apr 17, 2024
7e85306
Remove callcode tests
gianbelinche Apr 17, 2024
1f1f08b
Update submodule
jrchatruc Apr 17, 2024
b975ab8
Merge remote-tracking branch 'upstream/evm-equivalence-yul' into evm-…
jrchatruc Apr 17, 2024
10690bb
Merge pull request #1703 from lambdaclass/evm-yul-system1-opcodes
jrchatruc Apr 17, 2024
00733bf
Merge branch 'evm-equivalence-yul' into evm-system-instruction-3
gianbelinche Apr 17, 2024
659a75e
Merge branch 'evm-equivalence-yul' into evm-system-instruction-3
gianbelinche Apr 17, 2024
45d666b
Change zksolc download path
gianbelinche Apr 17, 2024
0fe172c
Re add debug tracer
jrchatruc Apr 17, 2024
8a1d70f
Add tests for create2
ManuelBilbao Apr 17, 2024
b094349
Update submodule
jrchatruc Apr 17, 2024
c634816
Merge pull request #1695 from lambdaclass/evm-system-instruction-3
jrchatruc Apr 17, 2024
e9fba2f
Update tests for create2
ManuelBilbao Apr 17, 2024
4e0e670
Add preprocessor for evm interpreter
gianbelinche Apr 18, 2024
cdc87da
Update submodule
jrchatruc Apr 18, 2024
81628a2
Merge pull request #1730 from lambdaclass/evm-preprocessor
jrchatruc Apr 18, 2024
a49a295
Test CALL opcode (#213)
fborello-lambda Apr 18, 2024
c537610
Merge remote-tracking branch 'upstream/evm-equivalence-yul' into yul-…
jrchatruc Apr 18, 2024
dd6045c
Fix contract we run
jrchatruc Apr 18, 2024
e4d67ba
Update submodule
jrchatruc Apr 18, 2024
78278dc
Fix recompile_interpreter.sh
ManuelBilbao Apr 18, 2024
02da92c
Format
ManuelBilbao Apr 18, 2024
cb3f1aa
Update submodule
jrchatruc Apr 19, 2024
851c946
fix(call tests): Fix call with create tests
fborello-lambda Apr 19, 2024
88b136a
feat(env4-opcodes): Add tests for env4 opcodes
fborello-lambda Apr 22, 2024
1a0650f
Update contracts submodule
ManuelBilbao Apr 22, 2024
4329260
Update submodule
jrchatruc Apr 22, 2024
98f7fbd
Merge pull request #1704 from lambdaclass/yul-system-2
jrchatruc Apr 22, 2024
c13f510
fix(op-extcodesize): Fix tests
fborello-lambda Apr 22, 2024
20496e3
Implement before_execution on CallTracer so we get prints on integrat…
jrchatruc Apr 22, 2024
492378f
Add reload_interpreter script to get print changes faster
jrchatruc Apr 22, 2024
ce53195
test(op-returndatacopy): fix tests
fborello-lambda Apr 24, 2024
f7ac3c3
Merge remote-tracking branch 'upstream/evm-equivalence-yul' into evm-…
jrchatruc Apr 24, 2024
555ad71
Update submodule
jrchatruc Apr 24, 2024
3e8e0ed
Merge pull request #1764 from lambdaclass/evm-yul-env4
jrchatruc Apr 24, 2024
da4c58e
Add delegatecall opcode tests
ManuelBilbao Apr 24, 2024
c861e96
Fix tests
jrchatruc Apr 25, 2024
c70bbb6
Update submodule
jrchatruc Apr 25, 2024
e481062
Merge pull request #1788 from lambdaclass/yul-delegatecall
jrchatruc Apr 25, 2024
044cc39
(WIP) Add CI for Yul EVM Interpreter
ManuelBilbao Apr 25, 2024
656b39c
Add evm-equivalence-yul to trigger branches
ManuelBilbao Apr 25, 2024
7398bd6
Change rust version
ManuelBilbao Apr 25, 2024
5064bf8
Alter zksolc download link
ManuelBilbao Apr 25, 2024
f0ab1cd
Remove rust version
ManuelBilbao Apr 25, 2024
4a623e8
Remove RUSTFLAGS env var
ManuelBilbao Apr 25, 2024
bb566f9
Test env var on step
ManuelBilbao Apr 25, 2024
93d0332
Change the way ZKSYNC_HOME is set
ManuelBilbao Apr 25, 2024
7f7878b
Add recompile EVM interpreter step
ManuelBilbao Apr 25, 2024
89d19cb
Add recompile EVM interpreter step env vars
ManuelBilbao Apr 25, 2024
b366892
Add zksolc download step
ManuelBilbao Apr 25, 2024
ed1ee64
Add execution permissions to zksolc
ManuelBilbao Apr 25, 2024
514452b
Add solc installation step
ManuelBilbao Apr 25, 2024
c7a2f95
Pin solc version
ManuelBilbao Apr 25, 2024
82e142d
Download solc binary from github
ManuelBilbao Apr 25, 2024
bb24640
Fix tests contract path
ManuelBilbao Apr 25, 2024
7def783
Revert last commit
ManuelBilbao Apr 25, 2024
33a4ff1
Remove counter contract
ManuelBilbao Apr 25, 2024
90a7c31
Readd counter contract
ManuelBilbao Apr 25, 2024
52c49ff
Add new line to counter contract
ManuelBilbao Apr 25, 2024
27a3862
Add integration tests
ManuelBilbao Apr 25, 2024
a96acf7
Fix integration tests
ManuelBilbao Apr 25, 2024
0d87a16
Refactor integration tests
ManuelBilbao Apr 25, 2024
87f0be3
Test background
ManuelBilbao Apr 25, 2024
27d7ca4
Add sqlx installation
ManuelBilbao Apr 25, 2024
b2304a9
Fix sqlx
ManuelBilbao Apr 25, 2024
5dda037
Fix sqlx install
ManuelBilbao Apr 25, 2024
ae728e6
Fix sqlx install
ManuelBilbao Apr 25, 2024
84188d4
Refactor integration tests
ManuelBilbao Apr 25, 2024
888dad2
Refactor CI
ManuelBilbao Apr 26, 2024
6bfea36
Add start services step
ManuelBilbao Apr 26, 2024
f842c3a
Remove sccache
ManuelBilbao Apr 26, 2024
d5c5234
Alter ci_localnet_up
ManuelBilbao Apr 26, 2024
40b514a
Test without docker
ManuelBilbao Apr 26, 2024
83ddedb
Change zksolc version to linux
ManuelBilbao Apr 26, 2024
e11ce9a
Fix typo
ManuelBilbao Apr 26, 2024
59dfa13
Start services
ManuelBilbao Apr 26, 2024
f7c8949
Create dirs for volumes
ManuelBilbao Apr 26, 2024
1b306f1
Remove warnings errors
ManuelBilbao Apr 26, 2024
d203428
Move tests with server start
ManuelBilbao Apr 26, 2024
52283c0
Test server without background
ManuelBilbao Apr 26, 2024
d189317
Remove warnings errors
ManuelBilbao Apr 26, 2024
f3eedbe
Move server to background and add sleep
ManuelBilbao Apr 26, 2024
80b9a41
Put all together
ManuelBilbao Apr 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 111 additions & 0 deletions .github/workflows/ci-evm-yul.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
name: CI Yul equivalent EVM

on:
pull_request:
merge_group:
push:
branches:
- staging
- trying
- main
- evm-equivalence-yul

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
tests:
runs-on: ubuntu-latest
name: Run tests
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 2
submodules: "recursive"

- name: Install Rust
uses: actions-rust-lang/setup-rust-toolchain@v1

- name: Install node
uses: actions/setup-node@v4
with:
node-version: 21.7

- name: Install yarn
run: corepack enable
# https://yarnpkg.com/corepack

- name: Install preprocessor
run: npm install -g preprocess-cli-tool

- name: Install sqlx
run: cargo install sqlx-cli@^0.5 --locked

- name: Download solc
run: |
curl -L -o bin/solc https://github.com/ethereum/solidity/releases/download/v0.8.24/solc-static-linux \
&& chmod +x bin/solc

- name: Download zksolc
run: |
curl -L -o bin/zksolc https://github.com/matter-labs/zksolc-bin/releases/download/v1.4.0/zksolc-linux-amd64-musl-v1.4.0 \
&& chmod +x bin/zksolc

- name: Setup environment
run: |
echo ZKSYNC_HOME=$(pwd) >> $GITHUB_ENV
echo $(pwd)/bin >> $GITHUB_PATH
echo IN_DOCKER=1 >> .env
echo ZKSYNC_DEBUG_LOGS=true >> .env

- name: Build system contracts
run: |
cd contracts/system-contracts \
&& yarn install \
&& yarn build

- name: Build EVM test contracts
run: |
cd etc/evm-contracts-test-data \
&& yarn install \
&& yarn build

- name: Build zkEVM test contracts
run: |
cd etc/contracts-test-data \
&& sed -i 's/zksolc-macosx-arm64/zksolc-linux-amd64-musl/' hardhat.config.ts \
&& yarn install \
&& yarn build

- name: Compile EVM interpreter
run: bash recompile_interpreter.sh

- name: Run unit tests
run: ZKSYNC_HOME=$(pwd) cargo test evm_simulator
env:
RUSTFLAGS: ""

- name: Start services
run: |
mkdir -p ./volumes/postgres ./volumes/reth/data
docker compose up -d

- name: Init
run: |
sed -i 's/zksolc-macosx-arm64/zksolc-linux-amd64-musl/' etc/contracts-test-data/hardhat.config.ts
zk
zk env dev
zk config compile dev
zk init
env:
RUSTFLAGS: ""

- name: Run integration tests
run: |
zk server --components "api,tree,eth,state_keeper,housekeeper" >/dev/null &
sleep 10
cd core/tests/ts-integration && yarn test evm-contracts-test.ts
env:
RUSTFLAGS: ""
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ cobertura.xml
tags
*.orig
.direnv
.envrc

# Yarn files
.yarn/
Expand Down
2 changes: 1 addition & 1 deletion core/lib/contracts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ impl BaseSystemContracts {
// so it is better to rely on more dynamic value instead of disk value
let evm_simulator_bytecode =
// read_sys_contract_bytecode("", "EvmInterpreter", ContractLanguage::Sol);
read_sys_contract_bytecode("", "EvmInterpreter", ContractLanguage::Yul);
read_sys_contract_bytecode("", "EvmInterpreterPreprocessed", ContractLanguage::Yul);
let evm_simulator_hash = hash_bytecode(&evm_simulator_bytecode);
let evm_simulator = SystemContractCode {
code: bytes_to_be_words(evm_simulator_bytecode),
Expand Down
77 changes: 73 additions & 4 deletions core/lib/multivm/src/tracers/call_tracer/vm_latest/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
use std::str::FromStr;

use zk_evm_1_5_0::{
tracing::{AfterExecutionData, VmLocalStateData},
tracing::{AfterExecutionData, BeforeExecutionData, VmLocalStateData},
zkevm_opcode_defs::{
FarCallABI, FatPointer, Opcode, RetOpcode, CALL_IMPLICIT_CALLDATA_FAT_PTR_REGISTER,
RET_IMPLICIT_RETURNDATA_PARAMS_REGISTER,
FarCallABI, FatPointer, Opcode, RetOpcode, UMAOpcode,
CALL_IMPLICIT_CALLDATA_FAT_PTR_REGISTER, RET_IMPLICIT_RETURNDATA_PARAMS_REGISTER,
},
};
use zksync_state::{StoragePtr, WriteStorage};
Expand All @@ -20,10 +22,77 @@ use crate::{
VmRevertReason,
},
tracers::call_tracer::CallTracer,
vm_latest::{BootloaderState, HistoryMode, SimpleMemory, VmTracer, ZkSyncVmState},
vm_latest::{
utils::heap_page_from_base, BootloaderState, HistoryMode, SimpleMemory, VmTracer,
ZkSyncVmState,
},
};

impl<S, H: HistoryMode> DynTracer<S, SimpleMemory<H>> for CallTracer {
fn before_execution(
&mut self,
state: VmLocalStateData<'_>,
data: BeforeExecutionData,
memory: &SimpleMemory<H>,
storage: StoragePtr<S>,
) {
// FIXME: this catches not only Evm contracts

let opcode_variant = data.opcode.variant;
let heap_page =
heap_page_from_base(state.vm_local_state.callstack.current.base_memory_page).0;

let src0_value = data.src0_value.value;

let fat_ptr = FatPointer::from_u256(src0_value);

let value = data.src1_value.value;

const DEBUG_SLOT: u32 = 32 * 32;

let debug_magic = U256::from_dec_str(
"33509158800074003487174289148292687789659295220513886355337449724907776218753",
)
.unwrap();

// Only `UMA` opcodes in the bootloader serve for vm hooks
if !matches!(opcode_variant.opcode, Opcode::UMA(UMAOpcode::HeapWrite))
|| fat_ptr.offset != DEBUG_SLOT
|| value != debug_magic
{
// println!("I tried");
return;
}

let how_to_print_value = memory.read_slot(heap_page as usize, 32 + 1).value;
let value_to_print = memory.read_slot(heap_page as usize, 32 + 2).value;

let print_as_hex_value =
U256::from_str("0x00debdebdebdebdebdebdebdebdebdebdebdebdebdebdebdebdebdebdebdebde")
.unwrap();
let print_as_string_value =
U256::from_str("0x00debdebdebdebdebdebdebdebdebdebdebdebdebdebdebdebdebdebdebdebdf")
.unwrap();

if how_to_print_value == print_as_hex_value {
print!("PRINTED: ");
println!("0x{:02x}", value_to_print);
}

if how_to_print_value == print_as_string_value {
print!("PRINTED: ");
let mut value = value_to_print.0;
value.reverse();
for limb in value {
print!(
"{}",
String::from_utf8(limb.to_be_bytes().to_vec()).unwrap()
);
}
println!("");
}
}

fn after_execution(
&mut self,
state: VmLocalStateData<'_>,
Expand Down
Loading
Loading