Skip to content

refactor(l1): make logger a functional option in NewClient - #3943

Open
Mgabal wants to merge 3 commits into
NethermindEth:mainfrom
Mgabal:fix/l1-logger-functional-option
Open

refactor(l1): make logger a functional option in NewClient#3943
Mgabal wants to merge 3 commits into
NethermindEth:mainfrom
Mgabal:fix/l1-logger-functional-option

Conversation

@Mgabal

@Mgabal Mgabal commented Aug 13, 2026

Copy link
Copy Markdown

Summary

Closes #3820

Changes

  • Added Logger field to the internal options struct
  • Added WithLogger(log.StructuredLogger) Option functional option
  • Removed logger as a required positional parameter from NewClient
  • Default logger is log.NewNopZapLogger() when not provided
  • Updated all callers: node/migration.go, node/node.go
  • Updated all test files to use l1.WithLogger(nopLog)

Motivation

Makes NewClient consistent with the existing functional-options
pattern already used for EventListener, ResubscribeDelay,
PollFinalisedInterval, and CatchUpChunkSize. Logger becomes
optional with a safe default rather than a required argument.

Mgabal added 2 commits August 14, 2026 00:48
Prevent docs deployment from running on every push to main.
Only trigger when files under docs/ or the workflow itself change.
This avoids unnecessary CI usage and GitHub Pages deployments
when unrelated code changes are pushed.
Move logger from a required positional parameter to a functional
option via WithLogger(). This makes the logger optional with a
sensible default (NopZapLogger) and keeps the API consistent
with the existing opts ...Option pattern.

Callers updated:
- node/migration.go
- node/node.go
- l1/l1_test.go
- l1/l1_pkg_test.go

Closes NethermindEth#3820

@brbrr brbrr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please take a look at inline comments

Comment thread .github/workflows/docs-deploy.yml Outdated
- main
paths:
- 'docs/**'
- '.github/workflows/docs-deploy.yml'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

These changes are irrelevant to this PR

Comment thread l1/l1.go
// CatchUpChunkSize is the L1 block range per backward eth_getLogs request
// during the startup catch-up scan.
CatchUpChunkSize uint64
CatchUpChunkSize uint64

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why did you remove the comment above?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please double-check what your LLM generates. The comment was moved to the wrong field.

Comment thread node/node.go Outdated
}

return l1.NewClient(provider, chain, logger, l1Opts...), provider, nil
return l1.NewClient(provider, chain, append(l1Opts, l1.WithLogger(logger))...), provider, nil

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

let's move the append from the function call.

- Remove accidental docs-deploy workflow changes
- Restore CatchUpChunkSize comment in options struct
- Move append outside NewClient call in node.go

@brbrr brbrr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

check comment

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

l1: make logger a functional option in NewClient

2 participants