starknet-devnet icon indicating copy to clipboard operation
starknet-devnet copied to clipboard

Devnet is failing to run with fork-network in debug mode

Open mikiw opened this issue 1 year ago • 12 comments

Describe the bug (observed vs expected behavior)

Devnet is failing to run with: cargo run -- --port 1025 --initial-balance 500000000000000000000 --seed 42 --accounts 3 --chain-id TESTNET --fork-network 'http://rpc.pathfinder.equilibrium.co/integration-sepolia/rpc/v0_7'

Not reproducible on testnet

  • [x] This issue is only present on Devnet and cannot be reproduced on the alpha-sepolia testnet (check the box if true).

To Reproduce Steps to reproduce the behavior:

  1. Run devnet with CLI args: cargo run -- --port 1025 --initial-balance 500000000000000000000 --seed 42 --accounts 3 --chain-id TESTNET --fork-network 'http://rpc.pathfinder.equilibrium.co/integration-sepolia/rpc/v0_7'
  2. Get error:
Forking from block: number=35172, hash=0x25a6765ed4756a519b23ba8b83cd11d9480ba4d798b392d74a9f14fd5c22b15
2024-07-03T12:31:59.239105Z  WARN starknet_devnet: Origin chain ID (0x534e5f494e544547524154494f4e5f5345504f4c4941) does not match this Devnet's chain ID (0x534e5f5345504f4c4941).
thread 'main' panicked at /Users/mikiw/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/blocking/shutdown.rs:51:21:
Cannot drop a runtime in a context where blocking is not allowed. This happens when a runtime is dropped from within an asynchronous context.
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
2024-07-03T12:31:59.244142Z ERROR reqwest::blocking::client: Failed to communicate successful startup: Ok(())    

Devnet version

  • I am using Devnet version:
  • [ ] This happens with a dockerized Devnet (check the box if true).
  • This does not appear on the following Devnet version:

System specifications

  • OS:

mikiw avatar Jul 03 '24 12:07 mikiw

maybe the problem is with tokio join added recently - checking

mikiw avatar Jul 03 '24 12:07 mikiw

doesn't happen if in release mode (--release)

FabijanC avatar Jul 03 '24 12:07 FabijanC

right cargo run --release -- --fork-network http://rpc.pathfinder.equilibrium.co/integration-sepolia/rpc/v0_7 works ...

mikiw avatar Jul 03 '24 12:07 mikiw

I deleted my recent comment which was wrong (perhaps I should have just edited). The error is present even before commit 3ad81456 (immediately before #491 was merged and tokio join introduced).

FabijanC avatar Jul 03 '24 12:07 FabijanC

Could be a reqwest issue: https://github.com/mozilla/sccache/issues/1161 Here they mention the same release vs debug mode problem

Here's what chatgpt says about debug-release differences (link to chat):

The difference between debug and release modes can sometimes expose race conditions or timing issues in your code. Optimizations in release mode can inadvertently mask these issues. Running your code with more extensive logging or using a tool like tokio-console can help you understand the runtime behavior in both modes.

FabijanC avatar Jul 05 '24 10:07 FabijanC

It is working as expected when the fork_config.block_number property is not modified. I dont know what optimisations the compiled does in release mode compared to debug build

marioiordanov avatar Jul 29 '24 13:07 marioiordanov

Perhaps changing the reqwest::blocking::Client to reqwest::Client will fix it

marioiordanov avatar Jul 29 '24 13:07 marioiordanov

+1 Error in crates/starknet-devnet-core/src/starknet/defaulter.rs:38:43 while calling reqwest::blocking::Client::new()

ArielTM avatar Aug 02 '24 11:08 ArielTM

@ArielTM Is running in debug mode from source important for your use case? Can you try switching to release mode? Docs: https://0xspaceshard.github.io/starknet-devnet-rs/docs/running/install#run-from-source

FabijanC avatar Aug 02 '24 11:08 FabijanC

We're actually trying to use starknet-devnet-core as a library, so developing in debug is easier

ArielTM avatar Aug 02 '24 11:08 ArielTM

@ArielTM If you run devnet without forking feature it should work as expected

marioiordanov avatar Aug 02 '24 11:08 marioiordanov

@marioiordanov we rely on forking :)

ArielTM avatar Aug 02 '24 11:08 ArielTM