From 90cd4b4564ae1d81839793b2abab7ed1db8e02c7 Mon Sep 17 00:00:00 2001 From: MexicanAce Date: Thu, 26 Sep 2024 17:47:45 +0100 Subject: [PATCH] Update to latest version and check-in e2e test that displays console errors --- Cargo.lock | 3 +-- Cargo.toml | 3 +-- e2e-tests/contracts/Fib.sol | 9 +++++++++ e2e-tests/test/fib.test.ts | 25 +++++++++++++++++++++++++ src/node/call_error_tracer.rs | 12 ++++-------- 5 files changed, 40 insertions(+), 12 deletions(-) create mode 100644 e2e-tests/contracts/Fib.sol create mode 100644 e2e-tests/test/fib.test.ts diff --git a/Cargo.lock b/Cargo.lock index 8e0019e8..9e7520b4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1810,7 +1810,7 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "era_test_node" -version = "0.1.0-alpha.27" +version = "0.1.0-alpha.28" dependencies = [ "anyhow", "bigdecimal 0.3.1", @@ -1844,7 +1844,6 @@ dependencies = [ "toml 0.8.13", "tracing", "tracing-subscriber", - "zk_evm 1.5.0", "zkevm_opcode_defs 1.5.0", "zksync-web3-rs", "zksync_basic_types", diff --git a/Cargo.toml b/Cargo.toml index 3f5e1222..4af27db2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "era_test_node" -version = "0.1.0-alpha.27" +version = "0.1.0-alpha.28" edition = "2018" authors = ["The Matter Labs Team "] homepage = "https://zksync.io/" @@ -11,7 +11,6 @@ categories = ["cryptography"] publish = false # We don't want to publish our binaries. [dependencies] -zk_evm = { git = "https://github.com/matter-labs/era-zk_evm.git", branch = "v1.5.0" } zkevm_opcode_defs = { git = "https://github.com/matter-labs/era-zkevm_opcode_defs.git", branch = "v1.5.0" } zksync_basic_types = { git = "https://github.com/matter-labs/zksync-era.git", rev = "e214dd094457f196712722e084010a7ef94ee475" } zksync_node_fee_model = { git = "https://github.com/matter-labs/zksync-era.git", rev = "e214dd094457f196712722e084010a7ef94ee475" } diff --git a/e2e-tests/contracts/Fib.sol b/e2e-tests/contracts/Fib.sol new file mode 100644 index 00000000..d6053f1b --- /dev/null +++ b/e2e-tests/contracts/Fib.sol @@ -0,0 +1,9 @@ +// SPDX-License-Identifier: UNLICENSED + +pragma solidity ^0.8.0; + +contract Fib { + function fib(uint256 n) public pure returns (uint256) { + return n <= 1 ? 1 : fib(n - 1) + fib(n - 2); + } +} diff --git a/e2e-tests/test/fib.test.ts b/e2e-tests/test/fib.test.ts new file mode 100644 index 00000000..cb5bd7fc --- /dev/null +++ b/e2e-tests/test/fib.test.ts @@ -0,0 +1,25 @@ +import { ethers } from "ethers"; +import { Wallet } from "zksync-web3"; +import * as hre from "hardhat"; +import { Deployer } from "@matterlabs/hardhat-zksync-deploy"; +import { RichAccounts } from "../helpers/constants"; +import { deployContract, expectThrowsAsync, getTestProvider } from "../helpers/utils"; + +const provider = getTestProvider(); + +describe("Test Fib error flags", function () { + it("Should print to the console NOT ENOUGH ERGS", async function () { + const action = async () => { + const wallet = new Wallet(RichAccounts[0].PrivateKey, provider); + + const deployer = new Deployer(hre, wallet); + const fib = await deployContract(deployer, "Fib"); + const n = await fib.fib(100); + }; + + // This is expected to throw and the console is expected to show: + // XX:YY:ZZ ERROR !! Got error flags: + // XX:YY:ZZ ERROR NOT ENOUGH ERGS + await expectThrowsAsync(action, "call revert exception"); + }); +}); diff --git a/src/node/call_error_tracer.rs b/src/node/call_error_tracer.rs index b2b40acc..226f12f5 100644 --- a/src/node/call_error_tracer.rs +++ b/src/node/call_error_tracer.rs @@ -1,12 +1,8 @@ -use multivm::{ - interface::dyn_tracers::vm_1_5_0::DynTracer, - vm_latest::{HistoryMode, SimpleMemory, VmTracer}, +use zksync_multivm::{ + tracers::dynamic::vm_1_5_0::DynTracer, + vm_latest::{HistoryMode, SimpleMemory, VmTracer}, zk_evm_latest::{tracing::{AfterDecodingData, VmLocalStateData}, vm_state::ErrorFlags}, }; -use zk_evm::{ - tracing::{AfterDecodingData, VmLocalStateData}, - vm_state::ErrorFlags, -}; -use zksync_state::WriteStorage; +use zksync_state::interface::WriteStorage; pub struct CallErrorTracer {}