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

Streamline ConsoleLogger logic and state #5411

Merged
merged 4 commits into from
Jul 2, 2024

Conversation

Xanewok
Copy link
Contributor

@Xanewok Xanewok commented Jun 19, 2024

  • Because this PR includes a bug fix, relevant tests have been included.
  • Because this PR includes a new feature, the change was previously discussed on an Issue or with someone from the team.
  • I didn't do anything of this.

Part of NomicFoundation/edr#246

The starting point for this PR was analyzing how we create the Provider and how different pieces interact with each other in JS and Rust<>JS in general around the stack traces logic and tests.

This removes some of the dead or redundant code and refreshes the console.log signature lookup table generation script. If we decide to move it to Rust, we won't have to call JS anymore and move buffers around just to decode and execute the console.log formatting logic.

After moving the auxiliary script to TS I re-ran it to verify that it outputs the same code (incl. the changes from this PR).

It was not type-checked previously and thus missed some renames and
dependencies' updates.
…lass

This makes it clearer what the exact logic is and if additional state is
used, which will be helpful when porting this code to Rust as we don't
want to rely on an external console.log decoding logic in JS.
@Xanewok Xanewok requested a review from fvictorio June 19, 2024 11:14
Copy link

vercel bot commented Jun 19, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
hardhat ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 19, 2024 11:14am

Copy link

changeset-bot bot commented Jun 19, 2024

⚠️ No Changeset found

Latest commit: cfd0884

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@Xanewok Xanewok added the no changeset needed This PR doesn't require a changeset label Jun 19, 2024
@Xanewok Xanewok requested a review from a team June 24, 2024 07:57
@agostbiro
Copy link
Contributor

Hey thanks for this PR @Xanewok ! I had a look, but I don't feel qualified to review it.

Copy link
Contributor

@Wodann Wodann left a comment

Choose a reason for hiding this comment

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

The changes to consoleLogger.ts look good to me.

I can't comment on anything else, as I'm not familiar enough with Hardhat's coding standard to validate it.

@Xanewok Xanewok requested a review from kanej June 25, 2024 10:14
@kanej kanej removed their assignment Jun 27, 2024
@Xanewok Xanewok requested a review from a team June 28, 2024 22:12
@fvictorio fvictorio changed the title Streamline ConsoleLogger logic and state Streamline ConsoleLogger logic and state Jul 2, 2024
@fvictorio fvictorio changed the title Streamline ConsoleLogger logic and state Streamline ConsoleLogger logic and state Jul 2, 2024
@fvictorio
Copy link
Member

Checking my understanding here. This PR has two parts:

  • The most important part is turning ConsoleLogger into a bag of static methods, because (I guess) that will make porting it easier. Is this correct?
  • The other part is migrating scripts/console-library-generator.js to typescript. I guess you did this as part of checking how the code works, and it doesn't hurt to commit it.

If this is correct, then LGTM.

@Xanewok
Copy link
Contributor Author

Xanewok commented Jul 2, 2024

That is correct:

  1. The first part isolates the logic in ConsoleLogger - the class did not in fact depend on some initial state but rather just used the selectors that are static/const and have to be generated by the script.
    After the refactor we know that we only need to depend on a single function to correctly format the logs in the EDR and it will be easier to port and use it directly rather than having to roundtrip via FFI only to format the console logs.
  2. The script that was originally used to generate the data used by the ConsoleLogger was discovered to be broken in the meantime (there's no bufferToInt anymore), so I migrated it to TS to ensure we catch any such regressions in the future (even if a short one, as we want to port it anyways) and made sure it still works as expected.

@fvictorio
Copy link
Member

Makes sense! Feel free to merge this if you want.

@Xanewok Xanewok merged commit aef55d2 into main Jul 2, 2024
95 of 98 checks passed
@Xanewok Xanewok deleted the refactor/streamline-console-logger branch July 2, 2024 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no changeset needed This PR doesn't require a changeset status:triaging
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

5 participants