Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions devnet-sdk/telemetry/slog.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (

"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/trace"

"github.com/ethereum-optimism/optimism/op-service/logmods"
)

func WrapHandler(h slog.Handler) slog.Handler {
Expand All @@ -19,6 +21,12 @@ type tracingHandler struct {
slog.Handler
}

var _ logmods.Handler = (*tracingHandler)(nil)

func (h *tracingHandler) Unwrap() slog.Handler {
return h.Handler
}

func (h *tracingHandler) Handle(ctx context.Context, record slog.Record) error {
// Send log entries as events to the tracer
if h.Handler.Enabled(ctx, record.Level) {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ require (
rsc.io/tmplfunc v0.0.3 // indirect
)

replace github.com/ethereum/go-ethereum => github.com/ethereum-optimism/op-geth v1.101511.0-rc.1
replace github.com/ethereum/go-ethereum => github.com/ethereum-optimism/op-geth v1.101511.1-0.20250523133920-e3f85bf38455

//replace github.com/ethereum/go-ethereum => ../op-geth

Expand Down
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,8 @@ github.com/elastic/gosigar v0.14.3 h1:xwkKwPia+hSfg9GqrCUKYdId102m9qTJIIr7egmK/u
github.com/elastic/gosigar v0.14.3/go.mod h1:iXRIGg2tLnu7LBdpqzyQfGDEidKCfWcCMS0WKyPWoMs=
github.com/ethereum-optimism/go-ethereum-hdwallet v0.1.3 h1:RWHKLhCrQThMfch+QJ1Z8veEq5ZO3DfIhZ7xgRP9WTc=
github.com/ethereum-optimism/go-ethereum-hdwallet v0.1.3/go.mod h1:QziizLAiF0KqyLdNJYD7O5cpDlaFMNZzlxYNcWsJUxs=
github.com/ethereum-optimism/op-geth v1.101511.0-rc.1 h1:DTQwpncGhqrxUO4YqmY740mYwFc+C5eh9mqGHhRerHg=
github.com/ethereum-optimism/op-geth v1.101511.0-rc.1/go.mod h1:SkytozVEPtnUeBlquwl0Qv5JKvrN/Y5aqh+VkQo/EOI=
github.com/ethereum-optimism/superchain-registry/validation v0.0.0-20250314162817-2c60e5723c64 h1:teDhU4h4ryaE8rSBl+vJJiwKHjxdnnHPkKZ9iNr2R8k=
github.com/ethereum-optimism/superchain-registry/validation v0.0.0-20250314162817-2c60e5723c64/go.mod h1:NZ816PzLU1TLv1RdAvYAb6KWOj4Zm5aInT0YpDVml2Y=
github.com/ethereum-optimism/op-geth v1.101511.1-0.20250523133920-e3f85bf38455 h1:uIZUYbfz+KqMUgVrrhVLzIk9AGZx0BrWr+nKe6ccENo=
github.com/ethereum-optimism/op-geth v1.101511.1-0.20250523133920-e3f85bf38455/go.mod h1:SkytozVEPtnUeBlquwl0Qv5JKvrN/Y5aqh+VkQo/EOI=
github.com/ethereum-optimism/superchain-registry/validation v0.0.0-20250521132634-76f6d741b33f h1:L4Q9iIthJHsrIS1rwEYcZDlMtIeKzwRRByQALNvJ3cQ=
github.com/ethereum-optimism/superchain-registry/validation v0.0.0-20250521132634-76f6d741b33f/go.mod h1:NZ816PzLU1TLv1RdAvYAb6KWOj4Zm5aInT0YpDVml2Y=
github.com/ethereum/c-kzg-4844/v2 v2.1.0 h1:gQropX9YFBhl3g4HYhwE70zq3IHFRgbbNPw0Shwzf5w=
Expand Down
2 changes: 1 addition & 1 deletion op-acceptance-tests/tests/base/advance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestCLAdvance(gt *testing.T) {
defer span.End()

new_num, num = sys.L2CL.SafeL2BlockRef().Number, new_num
t.Logger().WithContext(ctx).Info("safe head", "number", new_num)
t.Logger().InfoContext(ctx, "safe head", "number", new_num)
return new_num > num
}, 30*time.Second, waitTime)
}
2 changes: 1 addition & 1 deletion op-acceptance-tests/tests/base/faucet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ func TestFaucetFund(gt *testing.T) {
_, span = tracer.Start(ctx, "transfer funds")
amount := eth.OneEther
funded.Transfer(unfunded.Address(), amount)
t.Logger().WithContext(ctx).Info("funds transferred", "amount", amount)
t.Logger().InfoContext(ctx, "funds transferred", "amount", amount)
span.End()
}
25 changes: 24 additions & 1 deletion op-devstack/devtest/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package devtest
import (
"context"

"github.com/ethereum/go-ethereum/log"

"github.com/stretchr/testify/require"
"go.opentelemetry.io/otel/trace"
)
Expand All @@ -22,8 +24,29 @@ type CommonT interface {
Helper()
Name() string

Logger() Logger
Logger() log.Logger
Tracer() trace.Tracer
Ctx() context.Context
Require() *require.Assertions
}

type testScopeCtxKeyType struct{}

// testScopeCtxKey is a key added to the test-context to identify the test-scope.
var testScopeCtxKey = testScopeCtxKeyType{}

// TestScope retrieves the test-scope from the context
func TestScope(ctx context.Context) string {
scope := ctx.Value(testScopeCtxKey)
if scope == nil {
return ""
}
return scope.(string)
}

// AddTestScope combines the sub-scope with the test-scope of the context,
// and returns a context with the updated scope value.
func AddTestScope(ctx context.Context, scope string) context.Context {
prev := TestScope(ctx)
return context.WithValue(ctx, testScopeCtxKey, prev+"/"+scope)
}
64 changes: 0 additions & 64 deletions op-devstack/devtest/logging.go

This file was deleted.

42 changes: 38 additions & 4 deletions op-devstack/devtest/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ import (
type P interface {
CommonT

// WithCtx makes a copy of P with a specific context.
// The ctx must match the test-scope of the existing context.
// This function is used to create a P with annotated context, e.g. a specific resource.
// The logger may be annotated with additional arguments.
WithCtx(ctx context.Context, args ...any) P

// TempDir creates a temporary directory, and returns the file-path.
// This directory is cleaned up at the end of the package,
// and can be shared safely between tests that run in that package scope.
Expand All @@ -42,7 +48,7 @@ type implP struct {
scopeName string

// logger is used for logging. Regular test errors will also be redirected to get logged here.
logger Logger
logger log.Logger

// fail will be called to register a critical failure.
// The implementer can choose to panic, crit-log, exit, etc. as preferred.
Expand Down Expand Up @@ -103,7 +109,7 @@ func (t *implP) Name() string {
return t.scopeName
}

func (t *implP) Logger() Logger {
func (t *implP) Logger() log.Logger {
return t.logger
}

Expand All @@ -115,6 +121,34 @@ func (t *implP) Ctx() context.Context {
return t.ctx
}

type wrapP struct {
ctx context.Context
logger log.Logger
req *require.Assertions
P
}

var _ P = (*wrapP)(nil)

func (p *wrapP) Ctx() context.Context {
return p.ctx
}

func (p *wrapP) Logger() log.Logger {
return p.logger
}

func (t *implP) WithCtx(ctx context.Context, args ...any) P {
expected := TestScope(t.ctx)
got := TestScope(ctx)
t.req.Equal(expected, got, "cannot replace context with different test-scope")
logger := t.logger.New(args...)
logger.SetContext(ctx)
out := &wrapP{ctx: ctx, logger: logger, P: t}
out.req = require.New(out)
return out
}

func (t *implP) Require() *require.Assertions {
return t.req
}
Expand Down Expand Up @@ -166,9 +200,9 @@ func NewP(ctx context.Context, logger log.Logger, onFail func()) P {
ctx, cancel := context.WithCancel(ctx)
out := &implP{
scopeName: "pkg",
logger: &pkgLogger{logger},
logger: logger,
fail: onFail,
ctx: ctx,
ctx: AddTestScope(ctx, "pkg"),
cancel: cancel,
}
out.req = require.New(out)
Expand Down
Loading