Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Generalize logger for MerklePatriciaTrie #3915

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

Closed
wants to merge 3 commits into from
Closed

Conversation

am1r021
Copy link
Contributor

@am1r021 am1r021 commented Mar 15, 2025

This change looks into making logger usage more modular. I am starting with just the MPT package and changing the MerklePatriciaTrie class to allow passing in a general logger as an opt. A console.log-based logger class is provided and can be used as a lightweight and secure default. Many different loggers, like debug, winston, and others like pino can be used through the general logger interface.

@am1r021
Copy link
Contributor Author

am1r021 commented Mar 15, 2025

Bundle size can be tested using a program like this:

import { MerklePatriciaTrie } from '@ethereumjs/mpt'

import debug from 'debug'
const debugF = debug('mpt:#')
const l = {
  debug: (message, ...meta) => {
    let log = debugF
    for (const name of meta) {
      log = log.extend(name)
    }
    log(message)
  }
}
const t = new MerklePatriciaTrie({logger: l})

// const t = new MerklePatriciaTrie()

for (let i = 0; i < 100; i++) {
  t.put(new Uint8Array(i), new Uint8Array(i))
}
console.log(t.root())

Bundle size:

before: 202.5kb
after: 186.6kb

About %8 smaller when the debug logger is omitted

Copy link

codecov bot commented Mar 15, 2025

Codecov Report

Attention: Patch coverage is 62.50000% with 9 lines in your changes missing coverage. Please review.

Project coverage is 78.23%. Comparing base (a4c0393) to head (812776a).
Report is 6 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

Flag Coverage Δ
block ∅ <ø> (∅)
blockchain ∅ <ø> (∅)
client ?
common ∅ <ø> (∅)
devp2p ∅ <ø> (∅)
evm ∅ <ø> (∅)
genesis ∅ <ø> (∅)
mpt ∅ <62.50%> (∅)
rlp ∅ <ø> (∅)
statemanager ∅ <ø> (∅)
tx ∅ <ø> (∅)
util ∅ <ø> (∅)
vm ∅ <ø> (∅)
wallet ∅ <ø> (?)

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

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@am1r021 am1r021 marked this pull request as draft March 19, 2025 04:59
@am1r021
Copy link
Contributor Author

am1r021 commented Mar 19, 2025

Closing and continuing in #3923.

@am1r021 am1r021 closed this Mar 19, 2025
@holgerd77 holgerd77 deleted the logger-spike branch March 20, 2025 10:39
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.

1 participant
Morty Proxy This is a proxified and sanitized view of the page, visit original site.