From 660e5833df4a2aa0b384bdae5f03a75c2c27d127 Mon Sep 17 00:00:00 2001 From: PatStiles Date: Fri, 22 Nov 2024 10:11:05 -0300 Subject: [PATCH 1/7] bump eigensdk-go version --- go.mod | 5 ++--- go.sum | 10 ++++------ 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index c8726b19a7..d58d26a2a4 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/yetanotherco/aligned_layer go 1.22.2 require ( - github.com/Layr-Labs/eigensdk-go v0.1.12 + github.com/Layr-Labs/eigensdk-go v0.1.13 github.com/ethereum/go-ethereum v1.14.0 github.com/prometheus/client_golang v1.19.1 github.com/urfave/cli/v2 v2.27.1 @@ -16,6 +16,7 @@ require ( github.com/consensys/gnark v0.10.0 github.com/consensys/gnark-crypto v0.12.2-0.20240215234832-d72fcb379d3e github.com/fxamacker/cbor/v2 v2.7.0 + github.com/stretchr/testify v1.9.0 github.com/ugorji/go/codec v1.2.12 ) @@ -41,7 +42,6 @@ require ( 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.3.4 // indirect - github.com/cenkalti/backoff/v4 v4.3.0 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/consensys/bavard v0.1.13 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.3 // indirect @@ -75,7 +75,6 @@ require ( github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/shirou/gopsutil v3.21.6+incompatible // indirect github.com/shurcooL/graphql v0.0.0-20230722043721-ed46e5a46466 // indirect - github.com/stretchr/testify v1.9.0 // indirect github.com/supranational/blst v0.3.11 // indirect github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect github.com/tklauser/go-sysconf v0.3.12 // indirect diff --git a/go.sum b/go.sum index 02ace18bbc..ec49688fb8 100644 --- a/go.sum +++ b/go.sum @@ -6,8 +6,8 @@ github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOEl github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= github.com/DataDog/zstd v1.5.2 h1:vUG4lAyuPCXO0TLbXvPv7EB7cNK1QV/luu55UHLrrn8= github.com/DataDog/zstd v1.5.2/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= -github.com/Layr-Labs/eigensdk-go v0.1.12 h1:Drf59iJLvnTm2Om9AwAyUMiZeJaTI8ZameIrnhjopSY= -github.com/Layr-Labs/eigensdk-go v0.1.12/go.mod h1:XcLVDtlB1vOPj63D236b451+SC75B8gwgkpNhYHSxNs= +github.com/Layr-Labs/eigensdk-go v0.1.13 h1:llaDZW52AgrezJUpfqCzzgYuf47DK1HUOQLnI3jcVrA= +github.com/Layr-Labs/eigensdk-go v0.1.13/go.mod h1:aYdNURUhaqeYOS+Cq12TfSdPbjFfiLaHkxPdR4Exq/s= github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= github.com/Microsoft/hcsshim v0.11.4 h1:68vKo2VN8DE9AdN4tnkWnmdhqdbpUFM8OF3Airm7fz8= @@ -54,8 +54,6 @@ github.com/btcsuite/btcd/btcec/v2 v2.3.4 h1:3EJjcN70HCu/mwqlUsGK8GcNVyLVxFDlWurT github.com/btcsuite/btcd/btcec/v2 v2.3.4/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04= github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U= github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= -github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM= -github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8= github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= github.com/cespare/cp v0.1.0 h1:SE+dxFebS7Iik5LK0tsi1k9ZCxEaFX4AjQmoyA+1dJk= @@ -106,8 +104,8 @@ github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etly github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= github.com/distribution/reference v0.5.0 h1:/FUIFXtfc/x2gpa5/VGfiGLuOIdYa1t65IKK2OFGvA0= github.com/distribution/reference v0.5.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= -github.com/docker/docker v25.0.5+incompatible h1:UmQydMduGkrD5nQde1mecF/YnSbTOaPeFIeP5C4W+DE= -github.com/docker/docker v25.0.5+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/docker v25.0.6+incompatible h1:5cPwbwriIcsua2REJe8HqQV+6WlWc1byg2QSXzBxBGg= +github.com/docker/docker v25.0.6+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/go-connections v0.5.0 h1:USnMq7hx7gwdVZq1L49hLXaFtUdTADjXGp+uj1Br63c= github.com/docker/go-connections v0.5.0/go.mod h1:ov60Kzw0kKElRwhNs9UlUHAE/F9Fe6GLaXnqyDdmEXc= github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= From 86d4a042a7b968a046697fc6ecb638acce740a0f Mon Sep 17 00:00:00 2001 From: PatStiles Date: Fri, 22 Nov 2024 16:00:34 -0300 Subject: [PATCH 2/7] add util functions from v1.1.12 --- core/config/aggregator.go | 4 +- core/config/aligned_layer_deployment.go | 7 +-- core/config/base.go | 4 +- core/config/bls.go | 7 +-- core/config/ecdsa.go | 9 ++-- core/config/eigen_layer_deployment.go | 7 +-- core/config/operator.go | 4 +- core/utils/config_utils.go | 68 +++++++++++++++++++++++++ operator/cmd/actions/start.go | 4 +- 9 files changed, 93 insertions(+), 21 deletions(-) create mode 100644 core/utils/config_utils.go diff --git a/core/config/aggregator.go b/core/config/aggregator.go index a55da81938..c6812dee5d 100644 --- a/core/config/aggregator.go +++ b/core/config/aggregator.go @@ -6,8 +6,8 @@ import ( "os" "time" - sdkutils "github.com/Layr-Labs/eigensdk-go/utils" "github.com/ethereum/go-ethereum/common" + "github.com/yetanotherco/aligned_layer/core/utils" ) type AggregatorConfig struct { @@ -71,7 +71,7 @@ func NewAggregatorConfig(configFilePath string) *AggregatorConfig { } var aggregatorConfigFromYaml AggregatorConfigFromYaml - err := sdkutils.ReadYamlConfig(configFilePath, &aggregatorConfigFromYaml) + err := utils.ReadYamlConfig(configFilePath, &aggregatorConfigFromYaml) if err != nil { log.Fatal("Error reading aggregator config: ", err) } diff --git a/core/config/aligned_layer_deployment.go b/core/config/aligned_layer_deployment.go index 7b070c0cda..755b425f40 100644 --- a/core/config/aligned_layer_deployment.go +++ b/core/config/aligned_layer_deployment.go @@ -2,10 +2,11 @@ package config import ( "errors" - sdkutils "github.com/Layr-Labs/eigensdk-go/utils" - "github.com/ethereum/go-ethereum/common" "log" "os" + + "github.com/ethereum/go-ethereum/common" + "github.com/yetanotherco/aligned_layer/core/utils" ) type AlignedLayerDeploymentConfig struct { @@ -29,7 +30,7 @@ func NewAlignedLayerDeploymentConfig(alignedLayerDeploymentFilePath string) *Ali } var alignedLayerDeploymentConfigFromJson AlignedLayerDeploymentConfigFromJson - err := sdkutils.ReadJsonConfig(alignedLayerDeploymentFilePath, &alignedLayerDeploymentConfigFromJson) + err := utils.ReadJsonConfig(alignedLayerDeploymentFilePath, &alignedLayerDeploymentConfigFromJson) if err != nil { log.Fatal("Error reading aligned layer deployment config: ", err) diff --git a/core/config/base.go b/core/config/base.go index c54bb7671a..b1fd5d4491 100644 --- a/core/config/base.go +++ b/core/config/base.go @@ -10,9 +10,9 @@ import ( "github.com/Layr-Labs/eigensdk-go/chainio/clients/eth" sdklogging "github.com/Layr-Labs/eigensdk-go/logging" rpccalls "github.com/Layr-Labs/eigensdk-go/metrics/collectors/rpc_calls" - sdkutils "github.com/Layr-Labs/eigensdk-go/utils" "github.com/prometheus/client_golang/prometheus" "github.com/urfave/cli/v2" + "github.com/yetanotherco/aligned_layer/core/utils" ) var ( @@ -58,7 +58,7 @@ func NewBaseConfig(configFilePath string) *BaseConfig { var baseConfigFromYaml BaseConfigFromYaml - err := sdkutils.ReadYamlConfig(configFilePath, &baseConfigFromYaml) + err := utils.ReadYamlConfig(configFilePath, &baseConfigFromYaml) if err != nil { log.Fatal("Error reading setup config: ", err) } diff --git a/core/config/bls.go b/core/config/bls.go index b14052d5e1..3f9443be0a 100644 --- a/core/config/bls.go +++ b/core/config/bls.go @@ -2,10 +2,11 @@ package config import ( "errors" - "github.com/Layr-Labs/eigensdk-go/crypto/bls" - sdkutils "github.com/Layr-Labs/eigensdk-go/utils" "log" "os" + + "github.com/Layr-Labs/eigensdk-go/crypto/bls" + "github.com/yetanotherco/aligned_layer/core/utils" ) type BlsConfig struct { @@ -25,7 +26,7 @@ func NewBlsConfig(blsConfigFilePath string) *BlsConfig { } var blsConfigFromYaml BlsConfigFromYaml - err := sdkutils.ReadYamlConfig(blsConfigFilePath, &blsConfigFromYaml) + err := utils.ReadYamlConfig(blsConfigFilePath, &blsConfigFromYaml) if err != nil { log.Fatal("Error reading bls config: ", err) } diff --git a/core/config/ecdsa.go b/core/config/ecdsa.go index 55ac5fdc6c..31f837feab 100644 --- a/core/config/ecdsa.go +++ b/core/config/ecdsa.go @@ -3,12 +3,13 @@ package config import ( "crypto/ecdsa" "errors" - ecdsa2 "github.com/Layr-Labs/eigensdk-go/crypto/ecdsa" - "github.com/Layr-Labs/eigensdk-go/signer" - sdkutils "github.com/Layr-Labs/eigensdk-go/utils" "log" "math/big" "os" + + ecdsa2 "github.com/Layr-Labs/eigensdk-go/crypto/ecdsa" + "github.com/Layr-Labs/eigensdk-go/signer" + "github.com/yetanotherco/aligned_layer/core/utils" ) type EcdsaConfig struct { @@ -29,7 +30,7 @@ func NewEcdsaConfig(ecdsaConfigFilePath string, chainId *big.Int) *EcdsaConfig { } var ecdsaConfigFromYaml EcdsaConfigFromYaml - err := sdkutils.ReadYamlConfig(ecdsaConfigFilePath, &ecdsaConfigFromYaml) + err := utils.ReadYamlConfig(ecdsaConfigFilePath, &ecdsaConfigFromYaml) if err != nil { log.Fatal("Error reading ecdsa config: ", err) } diff --git a/core/config/eigen_layer_deployment.go b/core/config/eigen_layer_deployment.go index dc73a872da..ba64748418 100644 --- a/core/config/eigen_layer_deployment.go +++ b/core/config/eigen_layer_deployment.go @@ -2,10 +2,11 @@ package config import ( "errors" - sdkutils "github.com/Layr-Labs/eigensdk-go/utils" - "github.com/ethereum/go-ethereum/common" "log" "os" + + "github.com/ethereum/go-ethereum/common" + "github.com/yetanotherco/aligned_layer/core/utils" ) type EigenLayerDeploymentConfig struct { @@ -29,7 +30,7 @@ func NewEigenLayerDeploymentConfig(eigenLayerDeploymentFilePath string) *EigenLa } var eigenLayerDeploymentConfigFromJson EigenLayerDeploymentConfigFromJson - err := sdkutils.ReadJsonConfig(eigenLayerDeploymentFilePath, &eigenLayerDeploymentConfigFromJson) + err := utils.ReadJsonConfig(eigenLayerDeploymentFilePath, &eigenLayerDeploymentConfigFromJson) if err != nil { log.Fatal("Error reading eigen layer deployment config: ", err) diff --git a/core/config/operator.go b/core/config/operator.go index cac263f7a9..64cb153272 100644 --- a/core/config/operator.go +++ b/core/config/operator.go @@ -5,8 +5,8 @@ import ( "log" "os" - sdkutils "github.com/Layr-Labs/eigensdk-go/utils" "github.com/ethereum/go-ethereum/common" + "github.com/yetanotherco/aligned_layer/core/utils" ) type OperatorConfig struct { @@ -71,7 +71,7 @@ func NewOperatorConfig(configFilePath string) *OperatorConfig { } var operatorConfigFromYaml OperatorConfigFromYaml - err := sdkutils.ReadYamlConfig(configFilePath, &operatorConfigFromYaml) + err := utils.ReadYamlConfig(configFilePath, &operatorConfigFromYaml) if err != nil { log.Fatal("Error reading operator config: ", err) diff --git a/core/utils/config_utils.go b/core/utils/config_utils.go new file mode 100644 index 0000000000..613458312d --- /dev/null +++ b/core/utils/config_utils.go @@ -0,0 +1,68 @@ +package utils + +import ( + "encoding/json" + "errors" + + "log" + + "gopkg.in/yaml.v3" + + "os" + "path/filepath" +) + +const ( + PngMimeType = "image/png" + + TextRegex = `^[a-zA-Z0-9 +.,;:?!'’"“”\-_/()\[\]~&#$—%]+$` + + TextCharsLimit = 500 +) + +var ( + // ImageExtensions List of common image file extensions + // Only support PNG for now to reduce surface area of image validation + // We do NOT want to support formats like SVG since they can be used for javascript injection + // If we get pushback on only supporting png, we can support jpg, jpeg, gif, etc. later + ImageExtensions = []string{".png"} +) + +func ReadFile(path string) ([]byte, error) { + b, err := os.ReadFile(filepath.Clean(path)) + if err != nil { + return nil, err + } + return b, nil +} + +func ReadYamlConfig(path string, o interface{}) error { + if _, err := os.Stat(path); errors.Is(err, os.ErrNotExist) { + log.Fatal("Path ", path, " does not exist") + } + b, err := ReadFile(path) + if err != nil { + return err + } + + err = yaml.Unmarshal(b, o) + if err != nil { + log.Fatalf("unable to parse file with error %#v", err) + } + + return nil +} + +func ReadJsonConfig(path string, o interface{}) error { + b, err := ReadFile(path) + if err != nil { + return err + } + + err = json.Unmarshal(b, o) + if err != nil { + log.Fatalf("unable to parse file with error %#v", err) + } + + return nil +} diff --git a/operator/cmd/actions/start.go b/operator/cmd/actions/start.go index 4f2d7fcb50..c5adb9ef37 100644 --- a/operator/cmd/actions/start.go +++ b/operator/cmd/actions/start.go @@ -4,9 +4,9 @@ import ( "context" "log" - sdkutils "github.com/Layr-Labs/eigensdk-go/utils" "github.com/urfave/cli/v2" "github.com/yetanotherco/aligned_layer/core/config" + "github.com/yetanotherco/aligned_layer/core/utils" operator "github.com/yetanotherco/aligned_layer/operator/pkg" ) @@ -24,7 +24,7 @@ var StartCommand = &cli.Command{ func operatorMain(ctx *cli.Context) error { operatorConfigFilePath := ctx.String("config") operatorConfig := config.NewOperatorConfig(operatorConfigFilePath) - err := sdkutils.ReadYamlConfig(operatorConfigFilePath, &operatorConfig) + err := utils.ReadYamlConfig(operatorConfigFilePath, &operatorConfig) if err != nil { return err } From 19238a0dc2ec80dd9757bccd4af159fe4fe903a0 Mon Sep 17 00:00:00 2001 From: MauroFab Date: Tue, 26 Nov 2024 17:06:35 -0300 Subject: [PATCH 3/7] Go mod tidy --- go.mod | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index d58d26a2a4..5fb347c132 100644 --- a/go.mod +++ b/go.mod @@ -16,8 +16,8 @@ require ( github.com/consensys/gnark v0.10.0 github.com/consensys/gnark-crypto v0.12.2-0.20240215234832-d72fcb379d3e github.com/fxamacker/cbor/v2 v2.7.0 - github.com/stretchr/testify v1.9.0 github.com/ugorji/go/codec v1.2.12 + gopkg.in/yaml.v3 v3.0.1 ) require ( @@ -75,6 +75,7 @@ require ( github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/shirou/gopsutil v3.21.6+incompatible // indirect github.com/shurcooL/graphql v0.0.0-20230722043721-ed46e5a46466 // indirect + github.com/stretchr/testify v1.9.0 // indirect github.com/supranational/blst v0.3.11 // indirect github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect github.com/tklauser/go-sysconf v0.3.12 // indirect @@ -89,6 +90,5 @@ require ( golang.org/x/sys v0.19.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240730163845-b1a4ccb954bf // indirect google.golang.org/protobuf v1.34.2 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect rsc.io/tmplfunc v0.0.3 // indirect ) From dd82382dadaaa660cad6e02299d5aef6e289a444 Mon Sep 17 00:00:00 2001 From: MauroFab Date: Tue, 26 Nov 2024 17:10:32 -0300 Subject: [PATCH 4/7] Remove unused constants --- core/utils/config_utils.go | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/core/utils/config_utils.go b/core/utils/config_utils.go index 613458312d..adb25a47e3 100644 --- a/core/utils/config_utils.go +++ b/core/utils/config_utils.go @@ -12,22 +12,6 @@ import ( "path/filepath" ) -const ( - PngMimeType = "image/png" - - TextRegex = `^[a-zA-Z0-9 +.,;:?!'’"“”\-_/()\[\]~&#$—%]+$` - - TextCharsLimit = 500 -) - -var ( - // ImageExtensions List of common image file extensions - // Only support PNG for now to reduce surface area of image validation - // We do NOT want to support formats like SVG since they can be used for javascript injection - // If we get pushback on only supporting png, we can support jpg, jpeg, gif, etc. later - ImageExtensions = []string{".png"} -) - func ReadFile(path string) ([]byte, error) { b, err := os.ReadFile(filepath.Clean(path)) if err != nil { From e515f49197bc1cb9275a02746c6267f1a1e35b02 Mon Sep 17 00:00:00 2001 From: Mauro Toscano <12560266+MauroToscano@users.noreply.github.com> Date: Tue, 26 Nov 2024 17:16:01 -0300 Subject: [PATCH 5/7] Update core/utils/config_utils.go Co-authored-by: Mario Rugiero --- core/utils/config_utils.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/core/utils/config_utils.go b/core/utils/config_utils.go index adb25a47e3..6230b1e7be 100644 --- a/core/utils/config_utils.go +++ b/core/utils/config_utils.go @@ -13,11 +13,7 @@ import ( ) func ReadFile(path string) ([]byte, error) { - b, err := os.ReadFile(filepath.Clean(path)) - if err != nil { - return nil, err - } - return b, nil + return os.ReadFile(filepath.Clean(path)) } func ReadYamlConfig(path string, o interface{}) error { From 29e4b489d2a38532d1e9ba2a098e7ba20b5a2f65 Mon Sep 17 00:00:00 2001 From: Mauro Toscano <12560266+MauroToscano@users.noreply.github.com> Date: Tue, 26 Nov 2024 17:18:41 -0300 Subject: [PATCH 6/7] Update core/utils/config_utils.go Co-authored-by: Mario Rugiero --- core/utils/config_utils.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/core/utils/config_utils.go b/core/utils/config_utils.go index 6230b1e7be..63ac75fd51 100644 --- a/core/utils/config_utils.go +++ b/core/utils/config_utils.go @@ -17,9 +17,6 @@ func ReadFile(path string) ([]byte, error) { } func ReadYamlConfig(path string, o interface{}) error { - if _, err := os.Stat(path); errors.Is(err, os.ErrNotExist) { - log.Fatal("Path ", path, " does not exist") - } b, err := ReadFile(path) if err != nil { return err From 4111a459c4bbf6bc71d96e6e9c1687c483772a49 Mon Sep 17 00:00:00 2001 From: MauroFab Date: Tue, 26 Nov 2024 17:24:15 -0300 Subject: [PATCH 7/7] Fix --- core/utils/config_utils.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/core/utils/config_utils.go b/core/utils/config_utils.go index 63ac75fd51..6d527f1fbe 100644 --- a/core/utils/config_utils.go +++ b/core/utils/config_utils.go @@ -2,14 +2,11 @@ package utils import ( "encoding/json" - "errors" - "log" - - "gopkg.in/yaml.v3" - "os" "path/filepath" + + "gopkg.in/yaml.v3" ) func ReadFile(path string) ([]byte, error) {