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

Switch from ts-node to tsx #3188

Merged
merged 26 commits into from
Jan 8, 2024
Merged

Switch from ts-node to tsx #3188

merged 26 commits into from
Jan 8, 2024

Conversation

acolytec3
Copy link
Contributor

@acolytec3 acolytec3 commented Dec 12, 2023

Switches our monorepo's usage of ts-node over to tsx

  • Replace ts-node dep with tsx globally
  • Replace all references to ts-node with tsx
  • Updates several namespace imports to default imports to make tsx happy
  • Update lru-cache dep in devp2p to get rid of = require('lru-cache') syntax
  • Adds a new install-browser-deps npm script to the monorepo root to install pinned versions of the browser testing dependencies (pinned to versions known to work with our code, should be updated if repo: update vitest #3191 is merged

Copy link

codecov bot commented Dec 12, 2023

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (4ec344b) 87.94% compared to head (c203b8b) 87.92%.

Additional details and impacted files

Impacted file tree graph

Flag Coverage Δ
block 87.52% <ø> (ø)
blockchain 91.60% <ø> (ø)
client 84.66% <0.00%> (ø)
common 98.25% <ø> (ø)
devp2p 82.15% <83.33%> (+0.04%) ⬆️
ethash ∅ <ø> (∅)
evm 76.96% <ø> (ø)
genesis 99.98% <ø> (ø)
rlp ∅ <ø> (?)
statemanager 86.29% <ø> (ø)
trie 89.80% <ø> (-0.66%) ⬇️
tx 95.73% <ø> (ø)
util 89.13% <ø> (ø)
vm 80.83% <ø> (ø)
wallet 91.00% <ø> (ø)

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

@jochem-brouwer
Copy link
Member

There are some files added to this PR, I think they should be git mvd instead of manual renames? (I don't see the originals being deleted in this PR though so thats a bit weird)

Copy link
Member

@jochem-brouwer jochem-brouwer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One comment, and I have to test this locally but looks great to me in general.

packages/vm/test/tester/index.ts Outdated Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be renamed from transition-child.cts to here? (Same with transition-cluster)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it matters. I was just removing that as it's no longer imperative to have these file extensions with tsx. That said, it shouldn't have any impact on it running since tsx handles CJS and ESM just fine.

@jochem-brouwer
Copy link
Member

I checked out retesteth, I think for now we should skip with the original instructions (use ts-node) or we should figure out how to use spawn which then spawns tsx processes 🤔

Copy link
Contributor Author

@acolytec3 acolytec3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked out retesteth, I think for now we should skip with the original instructions (use ts-node) or we should figure out how to use spawn which then spawns tsx processes 🤔

The transition cluster/child run just fine with tsx in my testing. If I do curlie -v POST 127.0.0.1:3000 when the transition cluster is running, I can see logs from the transition-child thread running if I add console logs so it's not an issue of the ethjs side of the setup running. It seems like the retesth instructions are out of date though as I'm not able to get it to initiate a test. I think I'm just not configuring my retesteth setup correctly.

Copy link
Member

@holgerd77 holgerd77 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some tests failing and two minor comments, otherwise looks good!

@@ -18,6 +18,7 @@ export function clientRunHelper(
return new Promise((resolve) => {
child.stdout.on('data', async (data) => {
const message: string = data.toString()
console.log(message)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Intended?

@@ -62,7 +62,7 @@
"@scure/base": "1.1.1",
"debug": "^4.3.3",
"ethereum-cryptography": "^2.1.2",
"lru-cache": "^7.18.3",
"lru-cache": "^10.0.0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without having checked if this is the case or not, it would be good if all out lru-cache deps would be Version aligned throughout the packages.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

10.0.0 is the correct version to match everything else in our usage so we should be good here. Some of our dev deps use older versions but that shouldn't impact us.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok, but it (generally) wouldn't hurt to align the dev dep versions too here (also just a mention)

@@ -45,7 +45,8 @@ import type { Common } from '@ethereumjs/common'
* --profile If this flag is passed, the state/blockchain tests will profile
*/

const argv = minimist(process.argv.slice(2))
//@ts-expect-error Typescript thinks there isn't a default export on minimist but there is
const argv = minimist.default(process.argv.slice(2))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Side note: minimist is also causing problems with bun and we should consider to replace (should be simple).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I think I might address this in a separate PR. Not sure how much of a rewrite that will be to switch to yargs.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, sure, definitely nothing for this PR and generally just a mention.

@acolytec3
Copy link
Contributor Author

Looks like everything is finally passing now so should be ready for review.

Copy link
Member

@jochem-brouwer jochem-brouwer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some tiny comments

packages/client/test/cli/cli.spec.ts Outdated Show resolved Hide resolved
packages/client/test/cli/cli.spec.ts Outdated Show resolved Hide resolved
@@ -74,7 +70,7 @@ describe('[CLI]', () => {
// if http endpoint startup message detected, call http endpoint with RPC method
await wait(600)
const client = Client.http({
port: 8562,
port: 8569,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of interest why does the port have to change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I had a port collision where multiple child processes (i.e individual tests) were started by vitest simultaneously and they both tried to grab the same port.

@scorbajio scorbajio mentioned this pull request Jan 4, 2024
Copy link
Member

@jochem-brouwer jochem-brouwer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@acolytec3 acolytec3 merged commit 3981bca into master Jan 8, 2024
45 of 46 checks passed
@holgerd77 holgerd77 deleted the tsx branch January 8, 2024 20:17
@holgerd77
Copy link
Member

Cool, congrats! 🎉🙂

@holgerd77
Copy link
Member

Ugh, just skimmed through the changes, wasn't aware that this has gone that extensive. 🤯

@acolytec3
Copy link
Contributor Author

Ugh, just skimmed through the changes, wasn't aware that this has gone that extensive. 🤯

😬 It was mostly just find and replace (except for the lru-cache update)

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

Successfully merging this pull request may close these issues.

3 participants