Skip to content

Evm can't be sent between threads #1062

@impactdni2

Description

@impactdni2

Working on 4.0 support in my application, and trying to figure out what the correct pattern is for passing an Evm to a thread.

My use case is I have an Evm that has been built (DB, BlockEnv, etc), and I'd like to simulate multiple parallel transactions (with different inputs) in that environment.

My previous (pseudo)code was:

fn simulate(evm: EVM) {
  some_list
    .par_iter()  // <-- rayon parallelization
    .for_each(|item| {
      let mut evm = evm.clone();
      // modify evm transaction env
      // simulate txn
    });
}

Looks like in 4.0, Evm can't be safely sent between threads. Is there any recommended way to accomplish this? Should I just be pulling out the DB + Env, and sending those to the thread and rebuilding a new Evm?

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureNew feature or lib ability

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions