anvil-zksync icon indicating copy to clipboard operation
anvil-zksync copied to clipboard

Smaller `gas-price` values lead to crash

Open sayon opened this issue 8 months ago • 1 comments

🐛 Bug Report for anvil-zksync

📝 Description

Sending a transaction with --gas-price set to a low value leads to a crash

🔄 Reproduction Steps

  1. Execute the following
forge init test-erc
cd  test-erc
forge install OpenZeppelin/openzeppelin-contracts
  1. Create a file src/MyToken.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

contract MyToken is ERC20 {
    constructor(uint256 initialSupply) ERC20("MyToken", "MTK") {
        _mint(msg.sender, initialSupply);
    }
}
  1. Publish to running anvil-zksync
forge create \
    --chain 260 \
    --rpc-url localhost:8011 \
    --private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 \
    --zksync \
    src/MyToken.sol:MyToken \
    --constructor-args 10000000000

Response:

...
Deployed to: 0x588758d8a0Ad1162A6294f3C274753137E664aE0
cast send 0x588758d8a0Ad1162A6294f3C274753137E664aE0 "transfer(address,uint256)" 0x70997970C51812dc3A010C7d01b50e0d17dc79C8 5000 --private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80\
       --rpc-url http://localhost:8011 --chain 260       --gas-price 1

🤔 Expected Behavior

No crash.

😯 Current Behavior

Crash.

Submitted Tx is Unexecutable 0x15680421fbd3b46dd7163ff3789b82a364dd4aa4c7abb381930db95c1d270cb6 because of MaxFeePerGasTooLow 1
Error: Error while executing transaction: block base fee higher than max fee per gas
thread 'tokio-runtime-worker' panicked at /Users/sayon/.cargo/git/checkouts/zksync-era-657998444dcd9ed9/3e9fc0a/core/lib/multivm/src/versions/vm_latest/vm.rs:280:14:
Snapshot should be created before rolling it back
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'tokio-runtime-worker' panicked at crates/core/src/node/inner/node_executor.rs:108:14:
called `Result::unwrap()` on an `Err` value: batch executor panicked

Caused by:
    task 25 panicked with message "Snapshot should be created before rolling it back"
[anvil_zksync-gen-0] Generic error: channel closed
Error: AnvilGeneric(GenericError { message: "channel closed" })

🖥️ Environment

  • Rust version: rustc 1.83.0 (90b35a623 2024-11-26)
  • Operating System & Version: MacOS 14.7 (23H124)
  • Other relevant environment details: reproduced on f1d7f215b47d440860af0fcb465fbe61bdd1af7a

sayon avatar Apr 01 '25 13:04 sayon

Good catch. Seems like we try to rollback even if transaction simply failed validation. Likely rollback logic just needs to be closer to where we actually send tx to batch executor.

itegulov avatar Apr 02 '25 06:04 itegulov