diff --git a/cmd/daserver/daserver.go b/cmd/daserver/daserver.go index 07481651b2..3e96412648 100644 --- a/cmd/daserver/daserver.go +++ b/cmd/daserver/daserver.go @@ -7,12 +7,15 @@ import ( "context" "errors" "fmt" + "io" "net/http" "os" "os/signal" "syscall" "time" + "golang.org/x/exp/slog" + koanfjson "github.com/knadh/koanf/parsers/json" flag "github.com/spf13/pflag" @@ -182,14 +185,14 @@ func startup() error { confighelpers.PrintErrorAndExit(errors.New("please specify at least one of --enable-rest or --enable-rpc"), printSampleUsage) } - logFormat, err := genericconf.ParseLogType(serverConfig.LogType) + handler, err := genericconf.HandlerFromLogType(serverConfig.LogType, io.Writer(os.Stderr)) if err != nil { flag.Usage() - panic(fmt.Sprintf("Error parsing log type: %v", err)) + return fmt.Errorf("error parsing log type when creating handler: %w", err) } - glogger := log.NewGlogHandler(log.StreamHandler(os.Stderr, logFormat)) - glogger.Verbosity(log.Lvl(serverConfig.LogLevel)) - log.Root().SetHandler(glogger) + glogger := log.NewGlogHandler(handler) + glogger.Verbosity(slog.Level(serverConfig.LogLevel)) + log.SetDefault(log.NewLogger(glogger)) if err := startMetrics(serverConfig); err != nil { return err diff --git a/cmd/deploy/deploy.go b/cmd/deploy/deploy.go index 1c8b858106..d8c0aeeac4 100644 --- a/cmd/deploy/deploy.go +++ b/cmd/deploy/deploy.go @@ -8,6 +8,7 @@ import ( "encoding/json" "flag" "fmt" + "io" "math/big" "os" "strings" @@ -30,9 +31,10 @@ import ( ) func main() { - glogger := log.NewGlogHandler(log.StreamHandler(os.Stderr, log.TerminalFormat(false))) + glogger := log.NewGlogHandler( + log.NewTerminalHandler(io.Writer(os.Stderr), false)) glogger.Verbosity(log.LvlDebug) - log.Root().SetHandler(glogger) + log.SetDefault(log.NewLogger(glogger)) log.Info("deploying rollup") ctx := context.Background() diff --git a/cmd/genericconf/config.go b/cmd/genericconf/config.go index 50aafbe223..06e1fcd12d 100644 --- a/cmd/genericconf/config.go +++ b/cmd/genericconf/config.go @@ -5,11 +5,13 @@ package genericconf import ( "errors" + "io" "time" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/node" flag "github.com/spf13/pflag" + "golang.org/x/exp/slog" ) type ConfConfig struct { @@ -63,11 +65,11 @@ var DefaultS3Config = S3Config{ SecretKey: "", } -func ParseLogType(logType string) (log.Format, error) { +func HandlerFromLogType(logType string, output io.Writer) (slog.Handler, error) { if logType == "plaintext" { - return log.TerminalFormat(false), nil + return log.NewTerminalHandler(output, false), nil } else if logType == "json" { - return log.JSONFormat(), nil + return log.JSONHandler(output), nil } return nil, errors.New("invalid log type") } diff --git a/cmd/genericconf/filehandler_test.go b/cmd/genericconf/filehandler_test.go index 7ea0668229..daa9ed397c 100644 --- a/cmd/genericconf/filehandler_test.go +++ b/cmd/genericconf/filehandler_test.go @@ -72,9 +72,10 @@ func testFileHandler(t *testing.T, testCompressed bool) { config.MaxSize = 1 config.Compress = testCompressed config.File = testFile - fileHandler := globalFileHandlerFactory.newHandler(log.JSONFormat(), &config, testFile) - defer func() { testhelpers.RequireImpl(t, globalFileHandlerFactory.close()) }() - log.Root().SetHandler(fileHandler) + handler, err := HandlerFromLogType("json", globalFileLoggerFactory.newFileWriter(&config, testFile)) + defer func() { testhelpers.RequireImpl(t, globalFileLoggerFactory.close()) }() + testhelpers.RequireImpl(t, err) + log.SetDefault(log.NewLogger(handler)) expected := []string{"dead", "beef", "ate", "bad", "beef"} for _, e := range expected { log.Warn(e) diff --git a/cmd/genericconf/logging.go b/cmd/genericconf/logging.go index a50dfa3190..d77071a0bf 100644 --- a/cmd/genericconf/logging.go +++ b/cmd/genericconf/logging.go @@ -4,22 +4,47 @@ import ( "context" "flag" "fmt" + "io" "os" + "sync" "github.com/ethereum/go-ethereum/log" + "golang.org/x/exp/slog" "gopkg.in/natefinch/lumberjack.v2" ) -var globalFileHandlerFactory = fileHandlerFactory{} +var globalFileLoggerFactory = fileLoggerFactory{} -type fileHandlerFactory struct { - writer *lumberjack.Logger - records chan *log.Record - cancel context.CancelFunc +type fileLoggerFactory struct { + // writerMutex is to avoid parallel writes to the file-logger + writerMutex sync.Mutex + writer *lumberjack.Logger + + cancel context.CancelFunc + + // writeStartPing and writeDonePing are used to simulate sending of data via a buffered channel + // when Write is called and receiving it on another go-routine to write it to the io.Writer. + writeStartPing chan struct{} + writeDonePing chan struct{} +} + +// Write is essentially a wrapper for filewriter or lumberjack.Logger's Write method to implement +// config.BufSize functionality, data is dropped when l.writeStartPing channel (of size config.BuffSize) is full +func (l *fileLoggerFactory) Write(p []byte) (n int, err error) { + select { + case l.writeStartPing <- struct{}{}: + // Write data to the filelogger + l.writerMutex.Lock() + _, _ = l.writer.Write(p) + l.writerMutex.Unlock() + l.writeDonePing <- struct{}{} + default: + } + return len(p), nil } -// newHandler is not threadsafe -func (l *fileHandlerFactory) newHandler(logFormat log.Format, config *FileLoggingConfig, filename string) log.Handler { +// newFileWriter is not threadsafe +func (l *fileLoggerFactory) newFileWriter(config *FileLoggingConfig, filename string) io.Writer { l.close() l.writer = &lumberjack.Logger{ Filename: filename, @@ -28,40 +53,29 @@ func (l *fileHandlerFactory) newHandler(logFormat log.Format, config *FileLoggin MaxAge: config.MaxAge, Compress: config.Compress, } - // capture copy of the pointer - writer := l.writer - // lumberjack.Logger already locks on Write, no need for SyncHandler proxy which is used in StreamHandler - unsafeStreamHandler := log.LazyHandler(log.FuncHandler(func(r *log.Record) error { - _, err := writer.Write(logFormat.Format(r)) - return err - })) - l.records = make(chan *log.Record, config.BufSize) + l.writeStartPing = make(chan struct{}, config.BufSize) + l.writeDonePing = make(chan struct{}, config.BufSize) // capture copy - records := l.records + writeStartPing := l.writeStartPing + writeDonePing := l.writeDonePing var consumerCtx context.Context consumerCtx, l.cancel = context.WithCancel(context.Background()) go func() { + // writeStartPing channel signals Write operations to correctly implement config.BufSize functionality for { select { - case r := <-records: - _ = unsafeStreamHandler.Log(r) + case <-writeStartPing: + <-writeDonePing case <-consumerCtx.Done(): return } } }() - return log.FuncHandler(func(r *log.Record) error { - select { - case records <- r: - return nil - default: - return fmt.Errorf("Buffer overflow, dropping record") - } - }) + return l } // close is not threadsafe -func (l *fileHandlerFactory) close() error { +func (l *fileLoggerFactory) close() error { if l.cancel != nil { l.cancel() l.cancel = nil @@ -76,28 +90,29 @@ func (l *fileHandlerFactory) close() error { } // initLog is not threadsafe -func InitLog(logType string, logLevel log.Lvl, fileLoggingConfig *FileLoggingConfig, pathResolver func(string) string) error { - logFormat, err := ParseLogType(logType) - if err != nil { - flag.Usage() - return fmt.Errorf("error parsing log type: %w", err) - } +func InitLog(logType string, logLevel slog.Level, fileLoggingConfig *FileLoggingConfig, pathResolver func(string) string) error { var glogger *log.GlogHandler // always close previous instance of file logger - if err := globalFileHandlerFactory.close(); err != nil { + if err := globalFileLoggerFactory.close(); err != nil { return fmt.Errorf("failed to close file writer: %w", err) } + var output io.Writer if fileLoggingConfig.Enable { - glogger = log.NewGlogHandler( - log.MultiHandler( - log.StreamHandler(os.Stderr, logFormat), - // on overflow records are dropped silently as MultiHandler ignores errors - globalFileHandlerFactory.newHandler(logFormat, fileLoggingConfig, pathResolver(fileLoggingConfig.File)), - )) + output = io.MultiWriter( + io.Writer(os.Stderr), + // on overflow writeStartPing are dropped silently + globalFileLoggerFactory.newFileWriter(fileLoggingConfig, pathResolver(fileLoggingConfig.File)), + ) } else { - glogger = log.NewGlogHandler(log.StreamHandler(os.Stderr, logFormat)) + output = io.Writer(os.Stderr) + } + handler, err := HandlerFromLogType(logType, output) + if err != nil { + flag.Usage() + return fmt.Errorf("error parsing log type when creating handler: %w", err) } + glogger = log.NewGlogHandler(handler) glogger.Verbosity(logLevel) - log.Root().SetHandler(glogger) + log.SetDefault(log.NewLogger(glogger)) return nil } diff --git a/cmd/nitro-val/nitro_val.go b/cmd/nitro-val/nitro_val.go index 3671c7ea8d..4e543f7953 100644 --- a/cmd/nitro-val/nitro_val.go +++ b/cmd/nitro-val/nitro_val.go @@ -22,6 +22,7 @@ import ( "github.com/offchainlabs/nitro/cmd/util/confighelpers" _ "github.com/offchainlabs/nitro/execution/nodeInterface" "github.com/offchainlabs/nitro/validator/valnode" + "golang.org/x/exp/slog" ) func printSampleUsage(name string) { @@ -89,7 +90,7 @@ func mainImpl() int { } } - err = genericconf.InitLog(nodeConfig.LogType, log.Lvl(nodeConfig.LogLevel), &nodeConfig.FileLogging, pathResolver(nodeConfig.Persistent.LogDir)) + err = genericconf.InitLog(nodeConfig.LogType, slog.Level(nodeConfig.LogLevel), &nodeConfig.FileLogging, pathResolver(nodeConfig.Persistent.LogDir)) if err != nil { fmt.Fprintf(os.Stderr, "Error initializing logging: %v\n", err) return 1 @@ -108,7 +109,7 @@ func mainImpl() int { liveNodeConfig := genericconf.NewLiveConfig[*ValidationNodeConfig](args, nodeConfig, ParseNode) liveNodeConfig.SetOnReloadHook(func(oldCfg *ValidationNodeConfig, newCfg *ValidationNodeConfig) error { - return genericconf.InitLog(newCfg.LogType, log.Lvl(newCfg.LogLevel), &newCfg.FileLogging, pathResolver(nodeConfig.Persistent.LogDir)) + return genericconf.InitLog(newCfg.LogType, slog.Level(newCfg.LogLevel), &newCfg.FileLogging, pathResolver(nodeConfig.Persistent.LogDir)) }) valnode.EnsureValidationExposedViaAuthRPC(&stackConf) diff --git a/cmd/nitro/nitro.go b/cmd/nitro/nitro.go index 79ecd51ac2..df0feca8ee 100644 --- a/cmd/nitro/nitro.go +++ b/cmd/nitro/nitro.go @@ -63,6 +63,7 @@ import ( "github.com/offchainlabs/nitro/util/signature" "github.com/offchainlabs/nitro/validator/server_common" "github.com/offchainlabs/nitro/validator/valnode" + "golang.org/x/exp/slog" ) func printSampleUsage(name string) { @@ -207,7 +208,7 @@ func mainImpl() int { } stackConf.JWTSecret = filename } - err = genericconf.InitLog(nodeConfig.LogType, log.Lvl(nodeConfig.LogLevel), &nodeConfig.FileLogging, pathResolver(nodeConfig.Persistent.LogDir)) + err = genericconf.InitLog(nodeConfig.LogType, slog.Level(nodeConfig.LogLevel), &nodeConfig.FileLogging, pathResolver(nodeConfig.Persistent.LogDir)) if err != nil { fmt.Fprintf(os.Stderr, "Error initializing logging: %v\n", err) return 1 @@ -599,7 +600,7 @@ func mainImpl() int { } liveNodeConfig.SetOnReloadHook(func(oldCfg *NodeConfig, newCfg *NodeConfig) error { - if err := genericconf.InitLog(newCfg.LogType, log.Lvl(newCfg.LogLevel), &newCfg.FileLogging, pathResolver(nodeConfig.Persistent.LogDir)); err != nil { + if err := genericconf.InitLog(newCfg.LogType, slog.Level(newCfg.LogLevel), &newCfg.FileLogging, pathResolver(nodeConfig.Persistent.LogDir)); err != nil { return fmt.Errorf("failed to re-init logging: %w", err) } return currentNode.OnConfigReload(&oldCfg.Node, &newCfg.Node) diff --git a/cmd/relay/relay.go b/cmd/relay/relay.go index 40f4f26eec..5a7499e691 100644 --- a/cmd/relay/relay.go +++ b/cmd/relay/relay.go @@ -6,6 +6,7 @@ package main import ( "context" "fmt" + "io" "os" "os/signal" "syscall" @@ -19,6 +20,7 @@ import ( "github.com/offchainlabs/nitro/cmd/genericconf" "github.com/offchainlabs/nitro/cmd/util/confighelpers" "github.com/offchainlabs/nitro/relay" + "golang.org/x/exp/slog" ) func main() { @@ -62,14 +64,14 @@ func startup() error { confighelpers.PrintErrorAndExit(err, printSampleUsage) } - logFormat, err := genericconf.ParseLogType(relayConfig.LogType) + handler, err := genericconf.HandlerFromLogType(relayConfig.LogType, io.Writer(os.Stderr)) if err != nil { flag.Usage() - panic(fmt.Sprintf("Error parsing log type: %v", err)) + return fmt.Errorf("error parsing log type when creating handler: %w", err) } - glogger := log.NewGlogHandler(log.StreamHandler(os.Stderr, logFormat)) - glogger.Verbosity(log.Lvl(relayConfig.LogLevel)) - log.Root().SetHandler(glogger) + glogger := log.NewGlogHandler(handler) + glogger.Verbosity(slog.Level(relayConfig.LogLevel)) + log.SetDefault(log.NewLogger(glogger)) vcsRevision, _, vcsTime := confighelpers.GetVersion() log.Info("Running Arbitrum nitro relay", "revision", vcsRevision, "vcs.time", vcsTime) diff --git a/cmd/replay/main.go b/cmd/replay/main.go index 5369495324..3348d0b431 100644 --- a/cmd/replay/main.go +++ b/cmd/replay/main.go @@ -9,6 +9,7 @@ import ( "encoding/hex" "encoding/json" "fmt" + "io" "os" "github.com/ethereum/go-ethereum/common" @@ -172,9 +173,10 @@ func main() { wavmio.StubInit() gethhook.RequireHookedGeth() - glogger := log.NewGlogHandler(log.StreamHandler(os.Stderr, log.TerminalFormat(false))) - glogger.Verbosity(log.LvlError) - log.Root().SetHandler(glogger) + glogger := log.NewGlogHandler( + log.NewTerminalHandler(io.Writer(os.Stderr), false)) + glogger.Verbosity(log.LevelError) + log.SetDefault(log.NewLogger(glogger)) populateEcdsaCaches() diff --git a/das/aggregator_test.go b/das/aggregator_test.go index 776af3975b..ef8ef5327a 100644 --- a/das/aggregator_test.go +++ b/das/aggregator_test.go @@ -8,6 +8,7 @@ import ( "context" "errors" "fmt" + "io" "math/rand" "os" "strconv" @@ -158,9 +159,10 @@ func min(a, b int) int { } func enableLogging() { - glogger := log.NewGlogHandler(log.StreamHandler(os.Stderr, log.TerminalFormat(false))) - glogger.Verbosity(log.LvlTrace) - log.Root().SetHandler(glogger) + glogger := log.NewGlogHandler( + log.NewTerminalHandler(io.Writer(os.Stderr), false)) + glogger.Verbosity(log.LevelTrace) + log.SetDefault(log.NewLogger(glogger)) } func testConfigurableStorageFailures(t *testing.T, shouldFailAggregation bool) { diff --git a/execution/nodeInterface/virtual-contracts.go b/execution/nodeInterface/virtual-contracts.go index 3a863e31b5..d72ad0da8e 100644 --- a/execution/nodeInterface/virtual-contracts.go +++ b/execution/nodeInterface/virtual-contracts.go @@ -88,7 +88,7 @@ func init() { return msg, nil, nil } - evm, vmError := backend.GetEVM(ctx, msg, statedb, header, &vm.Config{NoBaseFee: true}, blockCtx) + evm := backend.GetEVM(ctx, msg, statedb, header, &vm.Config{NoBaseFee: true}, blockCtx) go func() { <-ctx.Done() evm.Cancel() @@ -110,7 +110,7 @@ func init() { ReturnData: output, ScheduledTxes: nil, } - return msg, res, vmError() + return msg, res, statedb.Error() } return msg, nil, nil } diff --git a/go-ethereum b/go-ethereum index 19f8227480..5b7a4020d8 160000 --- a/go-ethereum +++ b/go-ethereum @@ -1 +1 @@ -Subproject commit 19f82274804e2e21fbbb3379a02502910413b46c +Subproject commit 5b7a4020d8ef3d81fe2c645ec66c91cdb8719002 diff --git a/go.mod b/go.mod index e48d99f489..ded1fced70 100644 --- a/go.mod +++ b/go.mod @@ -21,12 +21,12 @@ require ( github.com/codeclysm/extract/v3 v3.0.2 github.com/dgraph-io/badger/v4 v4.2.0 github.com/enescakir/emoji v1.0.0 - github.com/ethereum/go-ethereum v1.10.26 + github.com/ethereum/go-ethereum v1.13.14 github.com/fatih/structtag v1.2.0 github.com/gdamore/tcell/v2 v2.6.0 github.com/google/go-cmp v0.6.0 github.com/hashicorp/golang-lru/v2 v2.0.2 - github.com/holiman/uint256 v1.2.3 + github.com/holiman/uint256 v1.2.4 github.com/ipfs/go-cid v0.4.1 github.com/ipfs/go-libipfs v0.6.2 github.com/ipfs/interface-go-ipfs-core v0.11.0 @@ -41,9 +41,10 @@ require ( github.com/spf13/pflag v1.0.5 github.com/wealdtech/go-merkletree v1.0.0 golang.org/x/crypto v0.21.0 + golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa golang.org/x/sys v0.18.0 golang.org/x/term v0.18.0 - golang.org/x/tools v0.13.0 + golang.org/x/tools v0.15.0 gopkg.in/natefinch/lumberjack.v2 v2.0.0 ) @@ -73,7 +74,7 @@ require ( github.com/aws/smithy-go v1.15.0 // indirect github.com/benbjohnson/clock v1.3.0 // indirect github.com/beorn7/perks v1.0.1 // indirect - github.com/bits-and-blooms/bitset v1.7.0 // indirect + github.com/bits-and-blooms/bitset v1.10.0 // indirect github.com/blang/semver/v4 v4.0.0 // indirect github.com/btcsuite/btcd/btcec/v2 v2.2.0 // indirect github.com/btcsuite/btcd/chaincfg/chainhash v1.0.2 // indirect @@ -90,6 +91,7 @@ require ( github.com/coreos/go-systemd/v22 v22.5.0 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect github.com/crackcomm/go-gitignore v0.0.0-20170627025303-887ab5e44cc3 // indirect + github.com/crate-crypto/go-ipa v0.0.0-20231025140028-3c0104f4b233 // indirect github.com/crate-crypto/go-kzg-4844 v0.7.0 // indirect github.com/cskr/pubsub v1.0.2 // indirect github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c // indirect @@ -109,6 +111,7 @@ require ( github.com/francoispqt/gojay v1.2.13 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect github.com/gammazero/deque v0.2.1 // indirect + github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46 // indirect github.com/gdamore/encoding v1.0.0 // indirect github.com/getsentry/sentry-go v0.18.0 // indirect github.com/go-logr/logr v1.2.3 // indirect @@ -280,10 +283,9 @@ require ( go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.24.0 // indirect go4.org v0.0.0-20200411211856-f5505b9728dd // indirect - golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect - golang.org/x/mod v0.12.0 // indirect + golang.org/x/mod v0.14.0 // indirect golang.org/x/net v0.22.0 // indirect - golang.org/x/sync v0.3.0 // indirect + golang.org/x/sync v0.5.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/time v0.3.0 // indirect golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect @@ -316,7 +318,6 @@ require ( github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff // indirect github.com/go-ole/go-ole v1.2.5 // indirect github.com/go-redis/redis/v8 v8.11.4 - github.com/go-stack/stack v1.8.1 // indirect github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect github.com/google/uuid v1.3.1 github.com/gorilla/websocket v1.5.0 // indirect diff --git a/go.sum b/go.sum index 484805a064..8be44da749 100644 --- a/go.sum +++ b/go.sum @@ -171,8 +171,8 @@ github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+Ce github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= -github.com/bits-and-blooms/bitset v1.7.0 h1:YjAGVd3XmtK9ktAbX8Zg2g2PwLIMjGREZJHlV4j7NEo= -github.com/bits-and-blooms/bitset v1.7.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA= +github.com/bits-and-blooms/bitset v1.10.0 h1:ePXTeiPEazB5+opbv5fr8umg2R/1NlzgDsyepwsSr88= +github.com/bits-and-blooms/bitset v1.10.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8= github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM= github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ= github.com/bradfitz/go-smtpd v0.0.0-20170404230938-deb6d6237625/go.mod h1:HYsPBTaaSFSlLx/70C2HPIMNZpVV8+vt/A+FMnYP11g= @@ -274,6 +274,8 @@ github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHH github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/crackcomm/go-gitignore v0.0.0-20170627025303-887ab5e44cc3 h1:HVTnpeuvF6Owjd5mniCL8DEXo7uYXdQEmOP4FJbV5tg= github.com/crackcomm/go-gitignore v0.0.0-20170627025303-887ab5e44cc3/go.mod h1:p1d6YEZWvFzEh4KLyvBcVSnrfNDDvK2zfK/4x2v/4pE= +github.com/crate-crypto/go-ipa v0.0.0-20231025140028-3c0104f4b233 h1:d28BXYi+wUpz1KBmiF9bWrjEMacUEREV6MBi2ODnrfQ= +github.com/crate-crypto/go-ipa v0.0.0-20231025140028-3c0104f4b233/go.mod h1:geZJZH3SzKCqnz5VT0q/DyIG/tvu/dZk+VIfXicupJs= github.com/crate-crypto/go-kzg-4844 v0.7.0 h1:C0vgZRk4q4EZ/JgPfzuSoxdCq3C3mOZMBShovmncxvA= github.com/crate-crypto/go-kzg-4844 v0.7.0/go.mod h1:1kMhvPgI0Ky3yIa+9lFySEBUBXkYxeOi8ZF1sYioxhc= github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= @@ -380,6 +382,8 @@ github.com/gammazero/deque v0.2.1/go.mod h1:LFroj8x4cMYCukHJDbxFCkT+r9AndaJnFMuZ github.com/gavv/httpexpect v2.0.0+incompatible/go.mod h1:x+9tiU1YnrOvnB725RkpoLv1M62hOWzwo5OXotisrKc= github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff h1:tY80oXqGNY4FhTFhk+o9oFHGINQ/+vhlm8HFzi6znCI= github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww= +github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46 h1:BAIP2GihuqhwdILrV+7GJel5lyPV3u1+PgzrWLc0TkE= +github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46/go.mod h1:QNpY22eby74jVhqH4WhDLDwxc/vqsern6pW+u2kbkpc= github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdko= github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg= github.com/gdamore/tcell/v2 v2.6.0 h1:OKbluoP9VYmJwZwq/iLb4BxwKcwGthaa1YNBJIyCySg= @@ -429,8 +433,6 @@ github.com/go-sourcemap/sourcemap v2.1.3+incompatible h1:W1iEw64niKVGogNgBN3ePyL github.com/go-sourcemap/sourcemap v2.1.3+incompatible/go.mod h1:F8jJfvm2KbVjc5NqelyYJmf/v5J0dwNLS2mL4sNA1Jg= github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= -github.com/go-stack/stack v1.8.1 h1:ntEHSVwIt7PNXNpgPmVfMrNhLtgjlmnZha2kOpuRiDw= -github.com/go-stack/stack v1.8.1/go.mod h1:dcoOX6HbPZSZptuspn9bctJ+N/CnF5gGygcUP3XYfe4= github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= @@ -537,6 +539,7 @@ github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ= github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= github.com/google/gopacket v1.1.17/go.mod h1:UdDNZ1OO62aGYVnPhxT1U6aI7ukYtA/kB8vaU0diBUM= github.com/google/gopacket v1.1.19 h1:ves8RnFZPGiFnTS0uPQStjwru6uO6h+nlr9j6fL7kF8= github.com/google/gopacket v1.1.19/go.mod h1:iJ8V8n6KS+z2U1A8pUwu8bW5SyEMkXJB8Yo/Vo+TKTo= @@ -646,8 +649,8 @@ github.com/holiman/billy v0.0.0-20230718173358-1c7e68d277a7 h1:3JQNjnMRil1yD0IfZ github.com/holiman/billy v0.0.0-20230718173358-1c7e68d277a7/go.mod h1:5GuXa7vkL8u9FkFuWdVvfR5ix8hRB7DbOAaYULamFpc= github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao= github.com/holiman/bloomfilter/v2 v2.0.3/go.mod h1:zpoh+gs7qcpqrHr3dB55AMiJwo0iURXE7ZOP9L9hSkA= -github.com/holiman/uint256 v1.2.3 h1:K8UWO1HUJpRMXBxbmaY1Y8IAMZC/RsKB+ArEnnK4l5o= -github.com/holiman/uint256 v1.2.3/go.mod h1:SC8Ryt4n+UBbPbIBKaG9zbbDlp4jOru9xFZmPzLUTxw= +github.com/holiman/uint256 v1.2.4 h1:jUc4Nk8fm9jZabQuqr2JzednajVmBpC+oiTiXZJEApU= +github.com/holiman/uint256 v1.2.4/go.mod h1:EOMSn4q6Nyt9P6efbI3bueV4e1b3dGlUCXeiRV4ng7E= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg= github.com/huin/goupnp v1.0.0/go.mod h1:n9v9KO1tAxYH82qOn+UTIFQDmx5n1Zxd/ClZDMX7Bnc= @@ -1812,8 +1815,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= -golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g= -golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k= +golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa h1:FRnLl4eNAQl8hwxVVC17teOw8kdjVDVAiFMtgUdTSRQ= +golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa/go.mod h1:zk2irFbV9DP96SEBUUAy67IdHUaZuSnrz1n472HUCLE= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -1838,8 +1841,8 @@ golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc= -golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0= +golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180406214816-61147c48b25b/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -1922,8 +1925,8 @@ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= -golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= +golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE= +golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180810173357-98c5dad5d1a0/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -2112,8 +2115,8 @@ golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.13.0 h1:Iey4qkscZuv0VvIt8E0neZjtPVQFSc870HQ448QgEmQ= -golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= +golang.org/x/tools v0.15.0 h1:zdAyfUGbYmuVokhzVmghFl2ZJh5QhcfebBgmVPFYA+8= +golang.org/x/tools v0.15.0/go.mod h1:hpksKq4dtpQWS1uQ61JkdqWM3LscIS6Slf+VVkm+wQk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/precompiles/precompile_test.go b/precompiles/precompile_test.go index 975856bced..376bfd7161 100644 --- a/precompiles/precompile_test.go +++ b/precompiles/precompile_test.go @@ -5,6 +5,7 @@ package precompiles import ( "fmt" + "io" "math/big" "os" "testing" @@ -181,9 +182,10 @@ func TestEventCosts(t *testing.T) { func TestPrecompilesPerArbosVersion(t *testing.T) { // Set up a logger in case log.Crit is called by Precompiles() - glogger := log.NewGlogHandler(log.StreamHandler(os.Stderr, log.TerminalFormat(false))) - glogger.Verbosity(log.LvlWarn) - log.Root().SetHandler(glogger) + glogger := log.NewGlogHandler( + log.NewTerminalHandler(io.Writer(os.Stderr), false)) + glogger.Verbosity(log.LevelWarn) + log.SetDefault(log.NewLogger(glogger)) expectedNewMethodsPerArbosVersion := map[uint64]int{ 0: 89, diff --git a/staker/challenge_test.go b/staker/challenge_test.go index c21ebcdecd..f74e18b63d 100644 --- a/staker/challenge_test.go +++ b/staker/challenge_test.go @@ -5,6 +5,7 @@ package staker import ( "context" + "io" "math/big" "os" "path" @@ -116,9 +117,10 @@ func runChallengeTest( testTimeout bool, maxInboxMessage uint64, ) { - glogger := log.NewGlogHandler(log.StreamHandler(os.Stderr, log.TerminalFormat(false))) - glogger.Verbosity(log.LvlDebug) - log.Root().SetHandler(glogger) + glogger := log.NewGlogHandler( + log.NewTerminalHandler(io.Writer(os.Stderr), false)) + glogger.Verbosity(log.LevelDebug) + log.SetDefault(log.NewLogger(glogger)) ctx, cancel := context.WithCancel(context.Background()) defer cancel() diff --git a/system_tests/common_test.go b/system_tests/common_test.go index a0bed2785d..4f7622f19d 100644 --- a/system_tests/common_test.go +++ b/system_tests/common_test.go @@ -8,6 +8,7 @@ import ( "context" "encoding/hex" "encoding/json" + "io" "math/big" "net" "os" @@ -67,6 +68,7 @@ import ( "github.com/offchainlabs/nitro/solgen/go/upgrade_executorgen" "github.com/offchainlabs/nitro/statetransfer" "github.com/offchainlabs/nitro/util/testhelpers" + "golang.org/x/exp/slog" ) type info = *BlockchainTestInfo @@ -634,7 +636,8 @@ func createTestL1BlockChainWithConfig(t *testing.T, l1info info, stackConfig *no nodeConf := ethconfig.Defaults nodeConf.NetworkId = chainConfig.ChainID.Uint64() - l1Genesis := core.DeveloperGenesisBlock(15_000_000, l1info.GetAddress("Faucet")) + faucetAddr := l1info.GetAddress("Faucet") + l1Genesis := core.DeveloperGenesisBlock(15_000_000, &faucetAddr) infoGenesis := l1info.GetGenesisAlloc() for acct, info := range infoGenesis { l1Genesis.Alloc[acct] = info @@ -1158,13 +1161,14 @@ func deploySimple( func TestMain(m *testing.M) { logLevelEnv := os.Getenv("TEST_LOGLEVEL") if logLevelEnv != "" { - logLevel, err := strconv.ParseUint(logLevelEnv, 10, 32) - if err != nil || logLevel > uint64(log.LvlTrace) { + logLevel, err := strconv.ParseInt(logLevelEnv, 10, 32) + if err != nil || logLevel > int64(log.LevelCrit) { log.Warn("TEST_LOGLEVEL exists but out of bound, ignoring", "logLevel", logLevelEnv, "max", log.LvlTrace) } - glogger := log.NewGlogHandler(log.StreamHandler(os.Stderr, log.TerminalFormat(false))) - glogger.Verbosity(log.Lvl(logLevel)) - log.Root().SetHandler(glogger) + glogger := log.NewGlogHandler( + log.NewTerminalHandler(io.Writer(os.Stderr), false)) + glogger.Verbosity(slog.Level(logLevel)) + log.SetDefault(log.NewLogger(glogger)) } code := m.Run() os.Exit(code) diff --git a/system_tests/conditionaltx_test.go b/system_tests/conditionaltx_test.go index 438e42d37e..5099fc6c01 100644 --- a/system_tests/conditionaltx_test.go +++ b/system_tests/conditionaltx_test.go @@ -101,7 +101,7 @@ func getOptions(address common.Address, rootHash common.Hash, slotValueMap map[c } func getFulfillableBlockTimeLimits(t *testing.T, blockNumber uint64, timestamp uint64) []*arbitrum_types.ConditionalOptions { - future := math.HexOrDecimal64(timestamp + 40) + future := math.HexOrDecimal64(timestamp + 70) past := math.HexOrDecimal64(timestamp - 1) futureBlockNumber := math.HexOrDecimal64(blockNumber + 1000) currentBlockNumber := math.HexOrDecimal64(blockNumber) diff --git a/system_tests/das_test.go b/system_tests/das_test.go index c4a3c453d8..bb09cc9880 100644 --- a/system_tests/das_test.go +++ b/system_tests/das_test.go @@ -7,6 +7,7 @@ import ( "context" "encoding/base64" "encoding/json" + "io" "math/big" "net" "net/http" @@ -32,6 +33,7 @@ import ( "github.com/offchainlabs/nitro/solgen/go/precompilesgen" "github.com/offchainlabs/nitro/util/headerreader" "github.com/offchainlabs/nitro/util/signature" + "golang.org/x/exp/slog" ) func startLocalDASServer( @@ -356,9 +358,10 @@ func TestDASComplexConfigAndRestMirror(t *testing.T) { } func enableLogging(logLvl int) { - glogger := log.NewGlogHandler(log.StreamHandler(os.Stderr, log.TerminalFormat(false))) - glogger.Verbosity(log.Lvl(logLvl)) - log.Root().SetHandler(glogger) + glogger := log.NewGlogHandler( + log.NewTerminalHandler(io.Writer(os.Stderr), false)) + glogger.Verbosity(slog.Level(logLvl)) + log.SetDefault(log.NewLogger(glogger)) } func initTest(t *testing.T) { diff --git a/system_tests/debugapi_test.go b/system_tests/debugapi_test.go index 52a6bb25c4..30a2bee03e 100644 --- a/system_tests/debugapi_test.go +++ b/system_tests/debugapi_test.go @@ -2,15 +2,15 @@ package arbtest import ( "context" - "github.com/ethereum/go-ethereum/eth/tracers" + "encoding/json" "testing" - "encoding/json" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/eth" + "github.com/ethereum/go-ethereum/eth/tracers" "github.com/ethereum/go-ethereum/rpc" "github.com/offchainlabs/nitro/solgen/go/precompilesgen" ) @@ -34,7 +34,7 @@ func TestDebugAPI(t *testing.T) { err = l2rpc.CallContext(ctx, &badBlocks, "debug_getBadBlocks") Require(t, err) - var dumpIt state.IteratorDump + var dumpIt state.Dump err = l2rpc.CallContext(ctx, &dumpIt, "debug_accountRange", rpc.LatestBlockNumber, hexutil.Bytes{}, 10, true, true, false) Require(t, err) err = l2rpc.CallContext(ctx, &dumpIt, "debug_accountRange", rpc.PendingBlockNumber, hexutil.Bytes{}, 10, true, true, false) diff --git a/system_tests/estimation_test.go b/system_tests/estimation_test.go index 6f47c14f1f..e7f00ca94e 100644 --- a/system_tests/estimation_test.go +++ b/system_tests/estimation_test.go @@ -13,6 +13,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" + "github.com/ethereum/go-ethereum/eth/gasestimator" "github.com/ethereum/go-ethereum/params" "github.com/offchainlabs/nitro/arbos/arbostypes" "github.com/offchainlabs/nitro/solgen/go/mocksgen" @@ -285,7 +286,7 @@ func TestComponentEstimate(t *testing.T) { l2Used := receipt.GasUsed - receipt.GasUsedForL1 colors.PrintMint("True ", receipt.GasUsed, " - ", receipt.GasUsedForL1, " = ", l2Used) - if l2Estimate != l2Used { + if float64(l2Estimate-l2Used) > float64(gasEstimateForL1+l2Used)*gasestimator.EstimateGasErrorRatio { Fatal(t, l2Estimate, l2Used) } } diff --git a/system_tests/full_challenge_impl_test.go b/system_tests/full_challenge_impl_test.go index af790c9a17..eec274a915 100644 --- a/system_tests/full_challenge_impl_test.go +++ b/system_tests/full_challenge_impl_test.go @@ -249,9 +249,10 @@ func createL2Nodes(t *testing.T, ctx context.Context, conf *arbnode.Config, chai } func RunChallengeTest(t *testing.T, asserterIsCorrect bool, useStubs bool, challengeMsgIdx int64) { - glogger := log.NewGlogHandler(log.StreamHandler(os.Stderr, log.TerminalFormat(false))) + glogger := log.NewGlogHandler( + log.NewTerminalHandler(io.Writer(os.Stderr), false)) glogger.Verbosity(log.LvlInfo) - log.Root().SetHandler(glogger) + log.SetDefault(log.NewLogger(glogger)) ctx, cancel := context.WithCancel(context.Background()) defer cancel() diff --git a/system_tests/retryable_test.go b/system_tests/retryable_test.go index b0691db173..132f2e7555 100644 --- a/system_tests/retryable_test.go +++ b/system_tests/retryable_test.go @@ -14,6 +14,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/eth/gasestimator" "github.com/ethereum/go-ethereum/params" "github.com/offchainlabs/nitro/arbnode" "github.com/offchainlabs/nitro/arbos" @@ -158,8 +159,12 @@ func TestSubmitRetryableImmediateSuccess(t *testing.T) { Require(t, err, "failed to estimate retryable submission") estimate := tx.Gas() expectedEstimate := params.TxGas + params.TxDataNonZeroGasEIP2028*4 - if estimate != expectedEstimate { - t.Errorf("estimated retryable ticket at %v gas but expected %v", estimate, expectedEstimate) + if float64(estimate) > float64(expectedEstimate)*(1+gasestimator.EstimateGasErrorRatio) { + t.Errorf("estimated retryable ticket at %v gas but expected %v, with error margin of %v", + estimate, + expectedEstimate, + gasestimator.EstimateGasErrorRatio, + ) } // submit & auto redeem the retryable using the gas estimate diff --git a/system_tests/triedb_race_test.go b/system_tests/triedb_race_test.go index 6d9415df83..9f14f08898 100644 --- a/system_tests/triedb_race_test.go +++ b/system_tests/triedb_race_test.go @@ -14,7 +14,7 @@ import ( ) func TestTrieDBCommitRace(t *testing.T) { - _ = testhelpers.InitTestLog(t, log.LvlError) + _ = testhelpers.InitTestLog(t, log.LevelError) ctx, cancel := context.WithCancel(context.Background()) defer cancel() diff --git a/util/testhelpers/testhelpers.go b/util/testhelpers/testhelpers.go index bccc269171..eafd0eda7e 100644 --- a/util/testhelpers/testhelpers.go +++ b/util/testhelpers/testhelpers.go @@ -4,7 +4,9 @@ package testhelpers import ( + "context" "crypto/rand" + "io" "os" "regexp" "sync" @@ -13,6 +15,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/log" "github.com/offchainlabs/nitro/util/colors" + "golang.org/x/exp/slog" ) // Fail a test should an error occur @@ -43,19 +46,29 @@ func RandomAddress() common.Address { } type LogHandler struct { - mutex sync.Mutex - t *testing.T - records []log.Record - streamHandler log.Handler + mutex sync.Mutex + t *testing.T + records []slog.Record + terminalHandler *log.TerminalHandler } -func (h *LogHandler) Log(record *log.Record) error { - if err := h.streamHandler.Log(record); err != nil { +func (h *LogHandler) Enabled(_ context.Context, level slog.Level) bool { + return h.terminalHandler.Enabled(context.Background(), level) +} +func (h *LogHandler) WithGroup(name string) slog.Handler { + return h.terminalHandler.WithGroup(name) +} +func (h *LogHandler) WithAttrs(attrs []slog.Attr) slog.Handler { + return h.terminalHandler.WithAttrs(attrs) +} + +func (h *LogHandler) Handle(_ context.Context, record slog.Record) error { + if err := h.terminalHandler.Handle(context.Background(), record); err != nil { return err } h.mutex.Lock() defer h.mutex.Unlock() - h.records = append(h.records, *record) + h.records = append(h.records, record) return nil } @@ -65,7 +78,7 @@ func (h *LogHandler) WasLogged(pattern string) bool { h.mutex.Lock() defer h.mutex.Unlock() for _, record := range h.records { - if re.MatchString(record.Msg) { + if re.MatchString(record.Message) { return true } } @@ -74,16 +87,16 @@ func (h *LogHandler) WasLogged(pattern string) bool { func newLogHandler(t *testing.T) *LogHandler { return &LogHandler{ - t: t, - records: make([]log.Record, 0), - streamHandler: log.StreamHandler(os.Stderr, log.TerminalFormat(false)), + t: t, + records: make([]slog.Record, 0), + terminalHandler: log.NewTerminalHandler(io.Writer(os.Stderr), false), } } -func InitTestLog(t *testing.T, level log.Lvl) *LogHandler { +func InitTestLog(t *testing.T, level slog.Level) *LogHandler { handler := newLogHandler(t) glogger := log.NewGlogHandler(handler) glogger.Verbosity(level) - log.Root().SetHandler(glogger) + log.SetDefault(log.NewLogger(glogger)) return handler }