ethereumjs-monorepo icon indicating copy to clipboard operation
ethereumjs-monorepo copied to clipboard

Generalized Runtime Docs / (First round) Bun Support

Open holgerd77 opened this issue 1 year ago • 5 comments

This PR adds a generalized "Runtimes" information section to the docs combining info for Node.js and browser (rewritten to be more specific) and then also adds a new "Bun" sub section there (we might want to add Deno as well).

I've done this in an examplaric way for one library, open for a first round of feedback, then I would expand (the same section/structure) to the other libraries (except client).

I've also added a simple.ts example, I would want to have one for each package, since this just makes sense in general.

For Bun I have also added a new GH Actions script. This is meant to be run nightly. After a first round I would comment out all non-working packages. For the working ones we can add the new "Bun Support" runtime section.

holgerd77 avatar Jan 08 '24 13:01 holgerd77

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (11f3a9c) 86.77% compared to head (43f245a) 86.85%.

Additional details and impacted files

Impacted file tree graph

Flag Coverage Δ
block 88.33% <ø> (ø)
blockchain 91.61% <ø> (ø)
client 84.69% <ø> (ø)
common 98.25% <ø> (ø)
devp2p 82.12% <ø> (ø)
ethash ∅ <ø> (∅)
evm 74.33% <ø> (ø)
genesis 99.98% <ø> (ø)
rlp ∅ <ø> (∅)
statemanager 75.86% <ø> (ø)
trie 89.16% <ø> (ø)
tx 95.45% <ø> (ø)
util 89.13% <ø> (?)
vm 80.20% <ø> (ø)
wallet 88.35% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

codecov[bot] avatar Jan 08 '24 13:01 codecov[bot]

@roninjin10 Thanks a lot for the feedback, that helps a lot!

I wanted to wait for our "self-contained examples" work (see some other now merged in PRs), so we basically have made all examples self-contained, so that they can now run "on their own" with all necessary dependencies included and stuff, the examples are now also included in a dedicated examples folder per package.

So this makes bun EthereumJS API testing easier. The examples work is now done, so I will pick up this PR sometime soon (next week or the week after I guess). Sufficient basis for this now, also with your --bun flag tip (thanks again for that!).

holgerd77 avatar Feb 09 '24 12:02 holgerd77

Resolved merge conflict here and updated this via UI

holgerd77 avatar Feb 14 '24 08:02 holgerd77

Update: gave this another try.

There is an issue open on Vitest support over on Bun which is still open: https://github.com/oven-sh/bun/issues/4145 and states that there is something in Bun still missing for this to work:

grafik

So seems it is still too early to try on this route.

holgerd77 avatar Feb 14 '24 09:02 holgerd77

What was an interesting experiment though: I managed to switch over our transaction test runner (which takes quite some time, >30 sec) to use the Bun native test runner (see docs) by doing some few replacements:

// import { assert, describe, it } from 'vitest'
import { describe, expect, test } from 'bun:test'

// assert.ok(!txIsValid, `Transaction should be invalid on ${forkName}`)
expect(!txIsValid).toBeTruthy()

// assert.ok(hashAndSenderAreCorrect && txIsValid,`Transaction should be valid on ${forkName}`)
expect(hashAndSenderAreCorrect && txIsValid).toBeTruthy()

// assert.ok(shouldBeInvalid, `Transaction should be invalid on ${forkName}`)
expect(shouldBeInvalid).toBeTruthy()

//assert.fail(`Transaction should be valid on ${forkName}`) (no replacement)

This produces the following output:

grafik

Test execution times are 31.11s with Bun and 32.97s with Vitest.

holgerd77 avatar Feb 14 '24 09:02 holgerd77