From 9c547e42f6e4c5a866a3131d1521a7ec57086a4c Mon Sep 17 00:00:00 2001 From: Joe Clapis Date: Thu, 6 Jun 2024 14:49:20 -0400 Subject: [PATCH 1/8] Updated Geth --- config/geth-config.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/geth-config.go b/config/geth-config.go index 0323f73..b4de1a5 100644 --- a/config/geth-config.go +++ b/config/geth-config.go @@ -10,8 +10,8 @@ import ( // Constants const ( // Tags - gethTagProd string = "ethereum/client-go:v1.14.3" - gethTagTest string = "ethereum/client-go:v1.14.3" + gethTagProd string = "ethereum/client-go:v1.14.5" + gethTagTest string = "ethereum/client-go:v1.14.5" ) // Configuration for Geth From 338c36a00a9a22abea985ff3c7585b12d36a527a Mon Sep 17 00:00:00 2001 From: Joe Clapis Date: Thu, 6 Jun 2024 15:24:01 -0400 Subject: [PATCH 2/8] Added an unlimited option for ValidateArgBatch --- api/server/utils.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/api/server/utils.go b/api/server/utils.go index 501aad1..666b2a7 100644 --- a/api/server/utils.go +++ b/api/server/utils.go @@ -29,7 +29,8 @@ func ValidateArg[ArgType any](name string, args url.Values, impl ArgValidator[Ar return nil } -// Validates an argument representing a batch of inputs, ensuring it exists and the inputs can be converted to the required type +// Validates an argument representing a batch of inputs, ensuring it exists and the inputs can be converted to the required type. +// Use a limit of 0 for no limit. func ValidateArgBatch[ArgType any](name string, args url.Values, batchLimit int, impl ArgValidator[ArgType], result_Out *[]ArgType) error { // Make sure it exists arg, exists := args[name] @@ -44,7 +45,7 @@ func ValidateArgBatch[ArgType any](name string, args url.Values, batchLimit int, } // Make sure there aren't too many entries - if len(result) > batchLimit { + if batchLimit > 0 && len(result) > batchLimit { return fmt.Errorf("too many inputs in arg %s (provided %d, max = %d)", name, len(result), batchLimit) } From 02cb18d7d44abba929fc6d9b6af42b599ba5022c Mon Sep 17 00:00:00 2001 From: Joe Clapis Date: Thu, 6 Jun 2024 16:11:46 -0400 Subject: [PATCH 3/8] Added ValidateOptionalArgBatch --- api/server/utils.go | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/api/server/utils.go b/api/server/utils.go index 666b2a7..300a072 100644 --- a/api/server/utils.go +++ b/api/server/utils.go @@ -29,6 +29,31 @@ func ValidateArg[ArgType any](name string, args url.Values, impl ArgValidator[Ar return nil } +// Validates an optional argument, converting to the required type if it exists +func ValidateOptionalArg[ArgType any](name string, args url.Values, impl ArgValidator[ArgType], result_Out *ArgType, exists_Out *bool) error { + // Make sure it exists + arg, exists := args[name] + if !exists { + if exists_Out != nil { + *exists_Out = false + } + return nil + } + + // Run the parser + result, err := impl(name, arg[0]) + if err != nil { + return err + } + + // Set the result + *result_Out = result + if exists_Out != nil { + *exists_Out = true + } + return nil +} + // Validates an argument representing a batch of inputs, ensuring it exists and the inputs can be converted to the required type. // Use a limit of 0 for no limit. func ValidateArgBatch[ArgType any](name string, args url.Values, batchLimit int, impl ArgValidator[ArgType], result_Out *[]ArgType) error { @@ -54,8 +79,9 @@ func ValidateArgBatch[ArgType any](name string, args url.Values, batchLimit int, return nil } -// Validates an optional argument, converting to the required type if it exists -func ValidateOptionalArg[ArgType any](name string, args url.Values, impl ArgValidator[ArgType], result_Out *ArgType, exists_Out *bool) error { +// Validates an optional argument representing a batch of inputs, converting them to the required type if it exists. +// Use a limit of 0 for no limit. +func ValidateOptionalArgBatch[ArgType any](name string, args url.Values, batchLimit int, impl ArgValidator[ArgType], result_Out *[]ArgType, exists_Out *bool) error { // Make sure it exists arg, exists := args[name] if !exists { @@ -66,11 +92,16 @@ func ValidateOptionalArg[ArgType any](name string, args url.Values, impl ArgVali } // Run the parser - result, err := impl(name, arg[0]) + result, err := input.ValidateBatch[ArgType](name, arg[0], impl) if err != nil { return err } + // Make sure there aren't too many entries + if batchLimit > 0 && len(result) > batchLimit { + return fmt.Errorf("too many inputs in arg %s (provided %d, max = %d)", name, len(result), batchLimit) + } + // Set the result *result_Out = result if exists_Out != nil { From 244896312e6539e938674ee0faef53097edf325f Mon Sep 17 00:00:00 2001 From: Joe Clapis Date: Mon, 10 Jun 2024 21:25:43 -0400 Subject: [PATCH 4/8] Updated Reth and Lodestar --- config/lodestar-bn-config.go | 4 ++-- config/reth-config.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/config/lodestar-bn-config.go b/config/lodestar-bn-config.go index aa11f33..a4c2403 100644 --- a/config/lodestar-bn-config.go +++ b/config/lodestar-bn-config.go @@ -5,8 +5,8 @@ import ( ) const ( - lodestarBnTagTest string = "chainsafe/lodestar:v1.18.1" - lodestarBnTagProd string = "chainsafe/lodestar:v1.18.1" + lodestarBnTagTest string = "chainsafe/lodestar:v1.19.0" + lodestarBnTagProd string = "chainsafe/lodestar:v1.19.0" ) // Configuration for the Lodestar BN diff --git a/config/reth-config.go b/config/reth-config.go index c3132a6..8e0d6c3 100644 --- a/config/reth-config.go +++ b/config/reth-config.go @@ -9,8 +9,8 @@ import ( // Constants const ( - rethTagProd string = "ghcr.io/paradigmxyz/reth:v0.2.0-beta.6" - rethTagTest string = "ghcr.io/paradigmxyz/reth:v0.2.0-beta.6" + rethTagProd string = "ghcr.io/paradigmxyz/reth:v0.2.0-beta.9" + rethTagTest string = "ghcr.io/paradigmxyz/reth:v0.2.0-beta.9" ) // Configuration for Reth From 4e31955b281768a13737816a2b56b20a922d142a Mon Sep 17 00:00:00 2001 From: Joe Clapis Date: Mon, 10 Jun 2024 21:27:54 -0400 Subject: [PATCH 5/8] Fixed some reinit / reload issues with the wallet manager --- node/wallet/address-manager.go | 3 +++ node/wallet/wallet.go | 2 ++ 2 files changed, 5 insertions(+) diff --git a/node/wallet/address-manager.go b/node/wallet/address-manager.go index f23ee07..825d8da 100644 --- a/node/wallet/address-manager.go +++ b/node/wallet/address-manager.go @@ -29,6 +29,9 @@ func newAddressManager(path string) *addressManager { // Gets the address saved on disk. Returns false if the address file doesn't exist. func (m *addressManager) LoadAddress() (common.Address, bool, error) { + m.address = common.Address{} + m.isLoaded = false + _, err := os.Stat(m.path) if errors.Is(err, fs.ErrNotExist) { return common.Address{}, false, nil diff --git a/node/wallet/wallet.go b/node/wallet/wallet.go index 0c283cb..85b5688 100644 --- a/node/wallet/wallet.go +++ b/node/wallet/wallet.go @@ -113,6 +113,8 @@ func (w *Wallet) Reload(logger *slog.Logger) error { } else if walletMgr != nil { w.walletManager = walletMgr } + } else { + w.walletManager = nil } // Load the node address From d8ec56d527124d9b4508368838cfdb4ecc192f9f Mon Sep 17 00:00:00 2001 From: Joe Clapis Date: Tue, 11 Jun 2024 11:08:49 -0400 Subject: [PATCH 6/8] Updated LH --- config/lighthouse-bn-config.go | 29 ++++------------------------- config/lighthouse-vc-config.go | 29 ++++------------------------- 2 files changed, 8 insertions(+), 50 deletions(-) diff --git a/config/lighthouse-bn-config.go b/config/lighthouse-bn-config.go index 5759335..f93c3e8 100644 --- a/config/lighthouse-bn-config.go +++ b/config/lighthouse-bn-config.go @@ -2,15 +2,12 @@ package config import ( "github.com/rocket-pool/node-manager-core/config/ids" - "github.com/rocket-pool/node-manager-core/utils/sys" ) const ( // Tags - lighthouseBnTagPortableTest string = "sigp/lighthouse:v5.1.3" - lighthouseBnTagPortableProd string = "sigp/lighthouse:v5.1.3" - lighthouseBnTagModernTest string = "sigp/lighthouse:v5.1.3-modern" - lighthouseBnTagModernProd string = "sigp/lighthouse:v5.1.3-modern" + lighthouseBnTagProd string = "sigp/lighthouse:v5.2.0" + lighthouseBnTagTest string = "sigp/lighthouse:v5.2.0" ) // Configuration for the Lighthouse BN @@ -69,8 +66,8 @@ func NewLighthouseBnConfig() *LighthouseBnConfig { OverwriteOnUpgrade: true, }, Default: map[Network]string{ - Network_Mainnet: getLighthouseBnTagProd(), - Network_Holesky: getLighthouseBnTagTest(), + Network_Mainnet: lighthouseBnTagProd, + Network_Holesky: lighthouseBnTagTest, }, }, @@ -109,21 +106,3 @@ func (cfg *LighthouseBnConfig) GetParameters() []IParameter { func (cfg *LighthouseBnConfig) GetSubconfigs() map[string]IConfigSection { return map[string]IConfigSection{} } - -// Get the appropriate LH default tag for production -func getLighthouseBnTagProd() string { - missingFeatures := sys.GetMissingModernCpuFeatures() - if len(missingFeatures) > 0 { - return lighthouseBnTagPortableProd - } - return lighthouseBnTagModernProd -} - -// Get the appropriate LH default tag for testnets -func getLighthouseBnTagTest() string { - missingFeatures := sys.GetMissingModernCpuFeatures() - if len(missingFeatures) > 0 { - return lighthouseBnTagPortableTest - } - return lighthouseBnTagModernTest -} diff --git a/config/lighthouse-vc-config.go b/config/lighthouse-vc-config.go index 38b6d82..cc9d3ee 100644 --- a/config/lighthouse-vc-config.go +++ b/config/lighthouse-vc-config.go @@ -2,15 +2,12 @@ package config import ( "github.com/rocket-pool/node-manager-core/config/ids" - "github.com/rocket-pool/node-manager-core/utils/sys" ) const ( // Tags - lighthouseVcTagPortableTest string = lighthouseBnTagPortableTest - lighthouseVcTagPortableProd string = lighthouseBnTagPortableProd - lighthouseVcTagModernTest string = lighthouseBnTagModernTest - lighthouseVcTagModernProd string = lighthouseBnTagModernProd + lighthouseVcTagProd string = lighthouseBnTagProd + lighthouseVcTagTest string = lighthouseBnTagTest ) // Configuration for the Lighthouse VC @@ -35,8 +32,8 @@ func NewLighthouseVcConfig() *LighthouseVcConfig { OverwriteOnUpgrade: true, }, Default: map[Network]string{ - Network_Mainnet: getLighthouseVcTagProd(), - Network_Holesky: getLighthouseVcTagTest(), + Network_Mainnet: lighthouseVcTagProd, + Network_Holesky: lighthouseVcTagTest, }, }, @@ -73,21 +70,3 @@ func (cfg *LighthouseVcConfig) GetParameters() []IParameter { func (cfg *LighthouseVcConfig) GetSubconfigs() map[string]IConfigSection { return map[string]IConfigSection{} } - -// Get the appropriate LH default tag for production -func getLighthouseVcTagProd() string { - missingFeatures := sys.GetMissingModernCpuFeatures() - if len(missingFeatures) > 0 { - return lighthouseVcTagPortableProd - } - return lighthouseVcTagModernProd -} - -// Get the appropriate LH default tag for testnets -func getLighthouseVcTagTest() string { - missingFeatures := sys.GetMissingModernCpuFeatures() - if len(missingFeatures) > 0 { - return lighthouseVcTagPortableTest - } - return lighthouseVcTagModernTest -} From 0d0c35e8098939864391199846d19d5da037952d Mon Sep 17 00:00:00 2001 From: Joe Clapis Date: Fri, 14 Jun 2024 14:17:21 -0400 Subject: [PATCH 7/8] Added a default logger for terminal testing --- log/logger.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/log/logger.go b/log/logger.go index c8cc50f..1bdd6df 100644 --- a/log/logger.go +++ b/log/logger.go @@ -17,7 +17,7 @@ type Logger struct { path string } -// Creates a new logger +// Creates a new logger that writes out to a log file on disk. func NewLogger(logFilePath string, options LoggerOptions) (*Logger, error) { // Make the file err := os.MkdirAll(filepath.Dir(logFilePath), logDirMode) @@ -58,6 +58,14 @@ func NewLogger(logFilePath string, options LoggerOptions) (*Logger, error) { }, nil } +// Creates a new logger that uses the slog default logger, which writes to the terminal instead of a file. +// Operations like rotation don't apply to this logger. +func NewDefaultLogger() *Logger { + return &Logger{ + Logger: slog.Default(), + } +} + // Get the path of the file this logger is writing to func (l *Logger) GetFilePath() string { return l.path @@ -65,7 +73,10 @@ func (l *Logger) GetFilePath() string { // Rotate the log file, migrating the current file to an old backup and starting a new one func (l *Logger) Rotate() error { - return l.logFile.Rotate() + if l.logFile != nil { + return l.logFile.Rotate() + } + return nil } // Closes the log file From 1546057bc5ef9ebf26989c5e76e7dcbe8d01dac3 Mon Sep 17 00:00:00 2001 From: Joe Clapis Date: Fri, 14 Jun 2024 14:31:25 -0400 Subject: [PATCH 8/8] Updated Besu --- config/besu-config.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/besu-config.go b/config/besu-config.go index 50d66d0..112697d 100644 --- a/config/besu-config.go +++ b/config/besu-config.go @@ -7,8 +7,8 @@ import ( // Constants const ( // Tags - besuTagTest string = "hyperledger/besu:24.5.2" - besuTagProd string = "hyperledger/besu:24.5.2" + besuTagTest string = "hyperledger/besu:24.6.0" + besuTagProd string = "hyperledger/besu:24.6.0" ) // Configuration for Besu