ethereumjs / ethereumjs-monorepo

Monorepo for the Ethereum VM TypeScript Implementation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

VM: State/Blockchain Test Runs with Bun fail

holgerd77 opened this issue Β· comments

Running the VM state/blockchain tests with Bun currently fails (see #3219 for additional context). The error message is pretty generic, so it is likely generally worth looking into this.

"Pure" test run with tsx can be done with:

tsx ./test/tester --stack-size=1500 --state

(from the VM package folder)

Running with Bun can be triggered with:

bun run ./test/tester/index.ts --stack-size=1500 --state

This gives the following breakage after a couple of successful test proceedings:

grafik

So: pretty basic error (ignore the red whiggle underlinings, just some formatting).

As mentioned above, likely worth to give this a look, maybe this gives some additional insights.

I can take a look at this by tomorrow afternoon the latest? πŸ˜ƒπŸ‘

I can take a look at this by tomorrow afternoon the latest? πŸ˜ƒπŸ‘

@jochem-brouwer Sounds good, that would be nice! πŸ‘

First note here: the error messages point to the esm build output, not to the original ts source code (which is not so nice πŸ˜… - but might be for performance reasons)

Test results by using bun run ./test/tester/index.ts --stack-size=1500 --state --test=create2InitCodeSizeLimit

In evm.ts add this:

    await this.journal.putAccount(message.to, toAccount)
    ;(<any>Address).abcde = 123
    console.log((<any>Address).abcde)
    await this.stateManager.clearContractStorage(message.to)

    const newContractEvent = {
      address: message.to,
      code: message.code,
    }

This adds this abcde to the Address constructor

In statemanager.ts add:

  /**
   * Clears all storage entries for the account corresponding to `address`.
   * @param address - Address to clear the storage of
   */
  async clearContractStorage(address: Address): Promise<void> {
    console.log((<any>Address).abcde)

This will print:

123
undefined

So it looks like somehow Bun is importing the same constructors from two different files πŸ€”

Not sure how to proceed here though.

Note: if this is tested using tsx it will output 123 both in state manager and in evm.

It seems that VM and EVM run on CJS (so also their imports), but StateManager (as imported in the general state tests runner), runs on ESM πŸ€”

Short update: tested this with bun v1.0.26 (release from early February 2024) and the bug still persists.