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

VM: State/Blockchain Test Runs with Bun fail #3223

Open
holgerd77 opened this issue Jan 9, 2024 · 6 comments
Open

VM: State/Blockchain Test Runs with Bun fail #3223

holgerd77 opened this issue Jan 9, 2024 · 6 comments

Comments

@holgerd77
Copy link
Member

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.

@jochem-brouwer
Copy link
Member

I can take a look at this by tomorrow afternoon the latest? 😃👍

@holgerd77
Copy link
Member Author

I can take a look at this by tomorrow afternoon the latest? 😃👍

@jochem-brouwer Sounds good, that would be nice! 👍

@jochem-brouwer
Copy link
Member

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)

@jochem-brouwer
Copy link
Member

jochem-brouwer commented Jan 10, 2024

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.

@jochem-brouwer
Copy link
Member

jochem-brouwer commented Jan 10, 2024

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 🤔

@holgerd77
Copy link
Member Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants