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

Using EDR makes node hang #339

Closed
fvictorio opened this issue Mar 25, 2024 · 0 comments · Fixed by NomicFoundation/hardhat#5025
Closed

Using EDR makes node hang #339

fvictorio opened this issue Mar 25, 2024 · 0 comments · Fixed by NomicFoundation/hardhat#5025
Assignees
Milestone

Comments

@fvictorio
Copy link
Member

Hardhat issue: NomicFoundation/hardhat#4997

Reproduction steps:

  1. Create a node project

  2. Install @nomicfoundation/edr

  3. Create an index.js file with these contents:

    const edr = require("@nomicfoundation/edr")
    
    const config = {
      allowBlocksWithSameTimestamp: true,
      allowUnlimitedContractSize: true,
      bailOnCallFailure: true,
      bailOnTransactionFailure: true,
      blockGasLimit: 1_000_000n,
      chainId: 31337n,
      chains: [],
      coinbase: Buffer.from("0000000000000000000000000000000000000000", "hex"),
      genesisAccounts: [],
      hardfork: edr.SpecId.Latest,
      minGasPrice: 0n,
      mining: {
        autoMine: true,
        memPool: {
          order: edr.MineOrdering.Priority,
        }
      },
      networkId: 31337n,
    }
    
    const loggerConfig = {
      enable: true,
      decodeConsoleLogInputsCallback: () => {},
      getContractAndFunctionNameCallback: () => {},
      printLineCallback: () => {},
    }
    
    async function main() {
      const context = new edr.EdrContext()
      const provider = edr.Provider.withConfig(context, config, loggerConfig, () => {})
    
      console.log("main finished")
    }
    
    main().catch((e) => {
        console.error(e);
        process.exit(1);
    });
  4. Run node index.js

main finished will be logged, but the process will hang.

What I know so far

There are a couple of issues in the napi-rs repo (here and here) that suggest that ThreadSafeFunction is the cause.

I upgraded the napi and napi-derive dependencies but that didn't fix the issue (also, when I did this I got some compilation errors, and I fixed them by adding a bunch of .to_vec() and replacing some ._as_ptr() with .as_mut_ptr()).

I then removed all the functions that EdrProvider.with_config receives. This did fix the issue, which seems to confirm that the problem is related to ThreadSafeFunction.

@Wodann Wodann self-assigned this Mar 26, 2024
@Wodann Wodann added this to the EDR v0.3.3 milestone Apr 9, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants