From 103360044b14a79e4085c7ed3cc4191453e65648 Mon Sep 17 00:00:00 2001 From: supernova Date: Sat, 7 Jun 2025 00:25:55 +0530 Subject: [PATCH 1/8] warning for new context, old devkit version --- config/contexts/devnet.yaml | 34 +++++++++ embeds.go | 6 -- pkg/common/config.go | 141 +++++++++++++++++++++++++++++++++++- pkg/common/constants.go | 3 + pkg/migration/migrator.go | 95 +++++++++++++++++++++++- 5 files changed, 268 insertions(+), 11 deletions(-) create mode 100644 config/contexts/devnet.yaml delete mode 100644 embeds.go diff --git a/config/contexts/devnet.yaml b/config/contexts/devnet.yaml new file mode 100644 index 00000000..8d5d77e9 --- /dev/null +++ b/config/contexts/devnet.yaml @@ -0,0 +1,34 @@ +version: "0.0.6" +context: + name: "devnet" + chains: + l1: + chain_id: 1337 + rpc_url: "http://localhost:8545" + fork: + url: "https://ethereum-holesky-rpc.publicnode.com" + block: 22640530 + block_time: 12 + deployer_private_key: "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" + app_private_key: "0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d" + operators: + - address: "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266" + ecdsa_key: "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" + bls_keystore_path: "./tests/keys/opr1.ecdsa.key.json" + bls_keystore_password: "testpassword" + allocations: + - strategy: "0x54945180dB7943c0ed0FEE7EdaB2Bd24620256bc" + deposit_amount: "5ETH" + allocation_in_wads: "500000000000000000" + avs: + address: "0x9fe46736679d2d9a65f0992f2272de9f3c7fa6e0" + metadata_url: "https://yolo.com/metadata.json" + avs_private_key: "0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a" + registrar_address: "0xe7f1725e7734ce288f8367e1bb143e90bb3f0512" + eigenlayer: + allocation_manager: "0x3d9AcAab2F40b6a1d4887a7F13B27B503a5839e5" + delegation_manager: "0x39053D51B77DC0d36036Fc1fCc8Cb819df8Ef37A" + strategy_manager: "0x9240e7B73ec78B1C4843bdA0f7b5C1fCE93Dd5f1" + deployed_contracts: [] + operator_sets: [] + operator_registrations: [] \ No newline at end of file diff --git a/embeds.go b/embeds.go deleted file mode 100644 index e124b73b..00000000 --- a/embeds.go +++ /dev/null @@ -1,6 +0,0 @@ -package project - -import _ "embed" - -//go:embed README.md -var RawReadme []byte diff --git a/pkg/common/config.go b/pkg/common/config.go index d1f1066e..29708f62 100644 --- a/pkg/common/config.go +++ b/pkg/common/config.go @@ -3,12 +3,13 @@ package common import ( "encoding/json" "fmt" + "github.com/Layr-Labs/devkit-cli/internal/version" + "gopkg.in/yaml.v3" "os" "path/filepath" "reflect" + "strconv" "strings" - - "gopkg.in/yaml.v3" ) const DefaultConfigWithContextConfigPath = "config" @@ -106,6 +107,129 @@ type ChainContextConfig struct { OperatorRegistrations []OperatorRegistration `json:"operator_registrations" yaml:"operator_registrations"` } +// VersionCompatibilityError represents a version mismatch error +type VersionCompatibilityError struct { + ContextVersion string + CLIVersion string + LatestSupported string + ContextFile string +} + +func (e *VersionCompatibilityError) Error() string { + return fmt.Sprintf(` +⚠️ VERSION COMPATIBILITY WARNING ⚠️ + +Your context file version is newer than what this devkit CLI version supports: + + Context file: %s + Context version: %s + CLI version: %s + Latest supported: %s + +This can cause context corruption if you proceed. Please update your devkit CLI first: + + # Update devkit CLI to latest version + + VERSION=v0.0.8 + ARCH=$(uname -m | tr '[:upper:]' '[:lower:]') + DISTRO=$(uname -s | tr '[:upper:]' '[:lower:]') + + mkdir -p $HOME/bin + curl -sL "https://s3.amazonaws.com/eigenlayer-devkit-releases/${VERSION}/devkit-${DISTRO}-${ARCH}-${VERSION}.tar.gz" | tar xv -C "$HOME/bin" + + # Or build from source + git pull origin main && make install + +After updating, verify the CLI version supports your context: + devkit --version + +DO NOT edit the context file until you update the CLI version. +`, e.ContextFile, e.ContextVersion, e.CLIVersion, e.LatestSupported) +} + +// parseVersion converts version string like "0.0.5" to comparable integers +func parseVersion(v string) (major, minor, patch int, err error) { + parts := strings.Split(v, ".") + if len(parts) != 3 { + return 0, 0, 0, fmt.Errorf("invalid version format: %s", v) + } + + major, err = strconv.Atoi(parts[0]) + if err != nil { + return 0, 0, 0, fmt.Errorf("invalid major version: %s", parts[0]) + } + + minor, err = strconv.Atoi(parts[1]) + if err != nil { + return 0, 0, 0, fmt.Errorf("invalid minor version: %s", parts[1]) + } + + patch, err = strconv.Atoi(parts[2]) + if err != nil { + return 0, 0, 0, fmt.Errorf("invalid patch version: %s", parts[2]) + } + + return major, minor, patch, nil +} + +// compareVersions returns true if v1 > v2 +func compareVersions(v1, v2 string) (bool, error) { + major1, minor1, patch1, err := parseVersion(v1) + if err != nil { + return false, fmt.Errorf("parse version %s: %w", v1, err) + } + + major2, minor2, patch2, err := parseVersion(v2) + if err != nil { + return false, fmt.Errorf("parse version %s: %w", v2, err) + } + + if major1 > major2 { + return true, nil + } + if major1 < major2 { + return false, nil + } + + if minor1 > minor2 { + return true, nil + } + if minor1 < minor2 { + return false, nil + } + + return patch1 > patch2, nil +} + +// checkVersionCompatibility validates that the context version is supported by the current CLI +func checkVersionCompatibility(contextVersion, contextFile string) error { + if contextVersion == "" { + // Missing version - could be very old context, warn but allow + return fmt.Errorf("context file %s is missing version field - this may be an old context that needs migration", contextFile) + } + + // Get the latest version supported by this CLI + latestSupported := DevkitLatestContextVersion // This should match contexts.LatestVersion , but cannot check due to import cycle error + + // Compare versions + isNewer, err := compareVersions(contextVersion, latestSupported) + if err != nil { + return fmt.Errorf("failed to compare versions: %w", err) + } + + // If context version is newer than what we support, return compatibility error + if isNewer { + return &VersionCompatibilityError{ + ContextVersion: contextVersion, + CLIVersion: version.GetVersion(), + LatestSupported: latestSupported, + ContextFile: contextFile, + } + } + + return nil +} + func LoadBaseConfig() (map[string]interface{}, error) { path := filepath.Join(DefaultConfigWithContextConfigPath, "config.yaml") data, err := os.ReadFile(path) @@ -133,6 +257,14 @@ func LoadContextConfig(ctxName string) (map[string]interface{}, error) { if err := yaml.Unmarshal(data, &ctx); err != nil { return nil, fmt.Errorf("parse context %q: %w", ctxName, err) } + + // Check version compatibility + if version, ok := ctx["version"].(string); ok { + if err := checkVersionCompatibility(version, path); err != nil { + return nil, err + } + } + return ctx, nil } @@ -183,6 +315,11 @@ func LoadConfigWithContextConfig(ctxName string) (*ConfigWithContextConfig, erro return nil, fmt.Errorf("failed to parse context file %q: %w", contextFile, err) } + // Check version compatibility before proceeding + if err := checkVersionCompatibility(wrapper.Version, contextFile); err != nil { + return nil, err + } + cfg.Context = map[string]ChainContextConfig{ ctxName: wrapper.Context, } diff --git a/pkg/common/constants.go b/pkg/common/constants.go index 0a5bd630..e6b8aba9 100644 --- a/pkg/common/constants.go +++ b/pkg/common/constants.go @@ -28,4 +28,7 @@ const ( // Default chainId for Anvil DefaultAnvilChainId = 31337 + + // DevkitLatestContextVersion is the latest version of the context file + DevkitLatestContextVersion = "0.0.5" ) diff --git a/pkg/migration/migrator.go b/pkg/migration/migrator.go index fb5193ec..188d375a 100644 --- a/pkg/migration/migrator.go +++ b/pkg/migration/migrator.go @@ -7,6 +7,7 @@ import ( "strconv" "strings" + "github.com/Layr-Labs/devkit-cli/internal/version" "github.com/Layr-Labs/devkit-cli/pkg/common" "github.com/Layr-Labs/devkit-cli/pkg/common/iface" "gopkg.in/yaml.v3" @@ -67,6 +68,92 @@ type VersionComparator func(string, string) bool // Known errors which we can ignore var ErrAlreadyUpToDate = errors.New("already up to date") +// VersionCompatibilityError represents a version mismatch error in migration +type VersionCompatibilityError struct { + ContextVersion string + CLIVersion string + LatestSupported string + ContextFile string +} + +func (e *VersionCompatibilityError) Error() string { + return fmt.Sprintf(` +⚠️ VERSION COMPATIBILITY WARNING ⚠️ + +Your context file version is newer than what this devkit +CLI version supports: + + Current Context file: %s + Current Context version: %s + Current CLI version: %s + Latest supported context version: %s + +This can cause context corruption if you proceed. Please update your devkit CLI first: + + # Update devkit CLI to latest version + +VERSION=v0.0.8 +ARCH=$(uname -m | tr '[:upper:]' '[:lower:]') +DISTRO=$(uname -s | tr '[:upper:]' '[:lower:]') + +mkdir -p $HOME/bin +curl -sL "https://s3.amazonaws.com/eigenlayer-devkit-releases/${VERSION}/devkit-${DISTRO}-${ARCH}-${VERSION}.tar.gz" | tar xv -C "$HOME/bin" + + # Or build from source + git pull origin main && make install + +After updating, verify the CLI version supports your context: + devkit --version + +DO NOT edit the context file until you update the CLI version. +`, e.ContextFile, e.ContextVersion, e.CLIVersion, e.LatestSupported) +} + +// checkVersionCompatibility validates that the context version is supported by the current CLI +func checkVersionCompatibility(contextVersion, latestSupported, contextFile string) error { + if contextVersion == "" { + // Missing version - could be very old context, warn but allow + return fmt.Errorf("context file %s is missing version field - this may be an old context that needs migration", contextFile) + } + + // For CLI version v0.0.8, we can support up to context version 0.0.5 + // Override the latestSupported if this CLI version supports higher + cliVersion := version.GetVersion() + if cliVersion == "v0.0.8" || cliVersion == "0.0.8" { + latestSupported = "0.0.5" + } + if cliVersion == "v0.0.7" || cliVersion == "0.0.7" { + latestSupported = "0.0.3" + } + if cliVersion == "v0.0.6" || cliVersion == "0.0.6" { + latestSupported = "0.0.3" + } + if cliVersion == "v0.0.4" || cliVersion == "0.0.4" { + latestSupported = "0.0.3" + } + if cliVersion == "v0.0.3" || cliVersion == "0.0.3" { + latestSupported = "0.0.3" + } + if cliVersion == "v0.0.2" || cliVersion == "0.0.2" { + latestSupported = "0.0.3" + } + if cliVersion == "v0.0.1" || cliVersion == "0.0.1" { + latestSupported = "0.0.1" + } + + // If context version is newer than what we support, return compatibility error + if versionGreaterThan(contextVersion, latestSupported) { + return &VersionCompatibilityError{ + ContextVersion: contextVersion, + CLIVersion: version.GetVersion(), + LatestSupported: latestSupported, + ContextFile: contextFile, + } + } + + return nil +} + // Apply walks each rule, and when Condition is met, either removes the node or replaces it with a (transformed) copy func (e *PatchEngine) Apply() error { for _, rule := range e.Rules { @@ -113,6 +200,11 @@ func MigrateYaml(logger iface.Logger, path string, latestVersion string, migrati from := verNode.Value to := latestVersion + // Check version compatibility BEFORE attempting migration + if err := checkVersionCompatibility(from, latestVersion, path); err != nil { + return err + } + // Continue and don't say anything if the user version is latest if from == to { return ErrAlreadyUpToDate @@ -148,9 +240,6 @@ func MigrateNode( if step.From != current { continue } - if versionGreaterThan(step.To, to) { - break - } oldDef := &yaml.Node{} if err := yaml.Unmarshal(step.OldYAML, oldDef); err != nil { From c51e33f482d208ef1e7dd146c0e5f6109b365049 Mon Sep 17 00:00:00 2001 From: supernova Date: Sat, 7 Jun 2025 00:26:48 +0530 Subject: [PATCH 2/8] fix --- config/contexts/devnet.yaml | 34 ---------------------------------- embeds.go | 6 ++++++ 2 files changed, 6 insertions(+), 34 deletions(-) delete mode 100644 config/contexts/devnet.yaml create mode 100644 embeds.go diff --git a/config/contexts/devnet.yaml b/config/contexts/devnet.yaml deleted file mode 100644 index 8d5d77e9..00000000 --- a/config/contexts/devnet.yaml +++ /dev/null @@ -1,34 +0,0 @@ -version: "0.0.6" -context: - name: "devnet" - chains: - l1: - chain_id: 1337 - rpc_url: "http://localhost:8545" - fork: - url: "https://ethereum-holesky-rpc.publicnode.com" - block: 22640530 - block_time: 12 - deployer_private_key: "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" - app_private_key: "0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d" - operators: - - address: "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266" - ecdsa_key: "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" - bls_keystore_path: "./tests/keys/opr1.ecdsa.key.json" - bls_keystore_password: "testpassword" - allocations: - - strategy: "0x54945180dB7943c0ed0FEE7EdaB2Bd24620256bc" - deposit_amount: "5ETH" - allocation_in_wads: "500000000000000000" - avs: - address: "0x9fe46736679d2d9a65f0992f2272de9f3c7fa6e0" - metadata_url: "https://yolo.com/metadata.json" - avs_private_key: "0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a" - registrar_address: "0xe7f1725e7734ce288f8367e1bb143e90bb3f0512" - eigenlayer: - allocation_manager: "0x3d9AcAab2F40b6a1d4887a7F13B27B503a5839e5" - delegation_manager: "0x39053D51B77DC0d36036Fc1fCc8Cb819df8Ef37A" - strategy_manager: "0x9240e7B73ec78B1C4843bdA0f7b5C1fCE93Dd5f1" - deployed_contracts: [] - operator_sets: [] - operator_registrations: [] \ No newline at end of file diff --git a/embeds.go b/embeds.go new file mode 100644 index 00000000..e124b73b --- /dev/null +++ b/embeds.go @@ -0,0 +1,6 @@ +package project + +import _ "embed" + +//go:embed README.md +var RawReadme []byte From 9b093688f639a888672918bde7ee214e80a1be2c Mon Sep 17 00:00:00 2001 From: supernova Date: Sat, 7 Jun 2025 00:28:02 +0530 Subject: [PATCH 3/8] add back deleted code --- pkg/migration/migrator.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/migration/migrator.go b/pkg/migration/migrator.go index 188d375a..c85ba391 100644 --- a/pkg/migration/migrator.go +++ b/pkg/migration/migrator.go @@ -241,6 +241,10 @@ func MigrateNode( continue } + if versionGreaterThan(step.To, to) { + break + } + oldDef := &yaml.Node{} if err := yaml.Unmarshal(step.OldYAML, oldDef); err != nil { return nil, fmt.Errorf("failed to unmarshal old default for %s: %w", step.From, err) From e9ef6618ca514e206f115f8549ed867f3be8cc58 Mon Sep 17 00:00:00 2001 From: supernova Date: Sat, 7 Jun 2025 00:55:17 +0530 Subject: [PATCH 4/8] use logger,let execution continue --- pkg/common/config.go | 44 +++++++++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/pkg/common/config.go b/pkg/common/config.go index 29708f62..0dd5fb67 100644 --- a/pkg/common/config.go +++ b/pkg/common/config.go @@ -3,13 +3,15 @@ package common import ( "encoding/json" "fmt" - "github.com/Layr-Labs/devkit-cli/internal/version" - "gopkg.in/yaml.v3" "os" "path/filepath" "reflect" "strconv" "strings" + + "github.com/Layr-Labs/devkit-cli/internal/version" + "github.com/Layr-Labs/devkit-cli/pkg/common/iface" + "gopkg.in/yaml.v3" ) const DefaultConfigWithContextConfigPath = "config" @@ -202,10 +204,14 @@ func compareVersions(v1, v2 string) (bool, error) { } // checkVersionCompatibility validates that the context version is supported by the current CLI -func checkVersionCompatibility(contextVersion, contextFile string) error { +// Logs a warning if there's a version mismatch, but allows execution to continue +func checkVersionCompatibility(contextVersion, contextFile string, logger iface.Logger) { if contextVersion == "" { // Missing version - could be very old context, warn but allow - return fmt.Errorf("context file %s is missing version field - this may be an old context that needs migration", contextFile) + if logger != nil { + logger.Info("⚠️ Context file %s is missing version field - this may be an old context that needs migration", contextFile) + } + return } // Get the latest version supported by this CLI @@ -214,20 +220,24 @@ func checkVersionCompatibility(contextVersion, contextFile string) error { // Compare versions isNewer, err := compareVersions(contextVersion, latestSupported) if err != nil { - return fmt.Errorf("failed to compare versions: %w", err) + if logger != nil { + logger.Info("⚠️ Failed to compare versions: %v", err) + } + return } - // If context version is newer than what we support, return compatibility error + // If context version is newer than what we support, log compatibility warning if isNewer { - return &VersionCompatibilityError{ + compatError := &VersionCompatibilityError{ ContextVersion: contextVersion, CLIVersion: version.GetVersion(), LatestSupported: latestSupported, ContextFile: contextFile, } + if logger != nil { + logger.Info("%s", compatError.Error()) + } } - - return nil } func LoadBaseConfig() (map[string]interface{}, error) { @@ -244,6 +254,10 @@ func LoadBaseConfig() (map[string]interface{}, error) { } func LoadContextConfig(ctxName string) (map[string]interface{}, error) { + return LoadContextConfigWithLogger(ctxName, nil) +} + +func LoadContextConfigWithLogger(ctxName string, logger iface.Logger) (map[string]interface{}, error) { // Default to devnet if ctxName == "" { ctxName = "devnet" @@ -260,9 +274,7 @@ func LoadContextConfig(ctxName string) (map[string]interface{}, error) { // Check version compatibility if version, ok := ctx["version"].(string); ok { - if err := checkVersionCompatibility(version, path); err != nil { - return nil, err - } + checkVersionCompatibility(version, path, logger) } return ctx, nil @@ -282,6 +294,10 @@ func LoadBaseConfigYaml() (*Config, error) { } func LoadConfigWithContextConfig(ctxName string) (*ConfigWithContextConfig, error) { + return LoadConfigWithContextConfigAndLogger(ctxName, nil) +} + +func LoadConfigWithContextConfigAndLogger(ctxName string, logger iface.Logger) (*ConfigWithContextConfig, error) { // Default to devnet if ctxName == "" { ctxName = "devnet" @@ -316,9 +332,7 @@ func LoadConfigWithContextConfig(ctxName string) (*ConfigWithContextConfig, erro } // Check version compatibility before proceeding - if err := checkVersionCompatibility(wrapper.Version, contextFile); err != nil { - return nil, err - } + checkVersionCompatibility(wrapper.Version, contextFile, logger) cfg.Context = map[string]ChainContextConfig{ ctxName: wrapper.Context, From eea37a38663f987a33b3c112ace7962872b04aeb Mon Sep 17 00:00:00 2001 From: supernova Date: Mon, 9 Jun 2025 23:39:31 +0530 Subject: [PATCH 5/8] fix duplicate version compatiblity error --- pkg/common/config.go | 23 +++++++++++---------- pkg/migration/migrator.go | 43 +-------------------------------------- 2 files changed, 13 insertions(+), 53 deletions(-) diff --git a/pkg/common/config.go b/pkg/common/config.go index 0dd5fb67..109e0059 100644 --- a/pkg/common/config.go +++ b/pkg/common/config.go @@ -109,7 +109,7 @@ type ChainContextConfig struct { OperatorRegistrations []OperatorRegistration `json:"operator_registrations" yaml:"operator_registrations"` } -// VersionCompatibilityError represents a version mismatch error +// VersionCompatibilityError represents a version mismatch error in migration type VersionCompatibilityError struct { ContextVersion string CLIVersion string @@ -121,23 +121,24 @@ func (e *VersionCompatibilityError) Error() string { return fmt.Sprintf(` ⚠️ VERSION COMPATIBILITY WARNING ⚠️ -Your context file version is newer than what this devkit CLI version supports: +Your context file version is newer than what this devkit +CLI version supports: - Context file: %s - Context version: %s - CLI version: %s - Latest supported: %s + Current Context file: %s + Current Context version: %s + Current CLI version: %s + Latest supported context version: %s This can cause context corruption if you proceed. Please update your devkit CLI first: # Update devkit CLI to latest version - VERSION=v0.0.8 - ARCH=$(uname -m | tr '[:upper:]' '[:lower:]') - DISTRO=$(uname -s | tr '[:upper:]' '[:lower:]') +VERSION=v0.0.8 +ARCH=$(uname -m | tr '[:upper:]' '[:lower:]') +DISTRO=$(uname -s | tr '[:upper:]' '[:lower:]') - mkdir -p $HOME/bin - curl -sL "https://s3.amazonaws.com/eigenlayer-devkit-releases/${VERSION}/devkit-${DISTRO}-${ARCH}-${VERSION}.tar.gz" | tar xv -C "$HOME/bin" +mkdir -p $HOME/bin +curl -sL "https://s3.amazonaws.com/eigenlayer-devkit-releases/${VERSION}/devkit-${DISTRO}-${ARCH}-${VERSION}.tar.gz" | tar xv -C "$HOME/bin" # Or build from source git pull origin main && make install diff --git a/pkg/migration/migrator.go b/pkg/migration/migrator.go index c85ba391..28e02dce 100644 --- a/pkg/migration/migrator.go +++ b/pkg/migration/migrator.go @@ -68,47 +68,6 @@ type VersionComparator func(string, string) bool // Known errors which we can ignore var ErrAlreadyUpToDate = errors.New("already up to date") -// VersionCompatibilityError represents a version mismatch error in migration -type VersionCompatibilityError struct { - ContextVersion string - CLIVersion string - LatestSupported string - ContextFile string -} - -func (e *VersionCompatibilityError) Error() string { - return fmt.Sprintf(` -⚠️ VERSION COMPATIBILITY WARNING ⚠️ - -Your context file version is newer than what this devkit -CLI version supports: - - Current Context file: %s - Current Context version: %s - Current CLI version: %s - Latest supported context version: %s - -This can cause context corruption if you proceed. Please update your devkit CLI first: - - # Update devkit CLI to latest version - -VERSION=v0.0.8 -ARCH=$(uname -m | tr '[:upper:]' '[:lower:]') -DISTRO=$(uname -s | tr '[:upper:]' '[:lower:]') - -mkdir -p $HOME/bin -curl -sL "https://s3.amazonaws.com/eigenlayer-devkit-releases/${VERSION}/devkit-${DISTRO}-${ARCH}-${VERSION}.tar.gz" | tar xv -C "$HOME/bin" - - # Or build from source - git pull origin main && make install - -After updating, verify the CLI version supports your context: - devkit --version - -DO NOT edit the context file until you update the CLI version. -`, e.ContextFile, e.ContextVersion, e.CLIVersion, e.LatestSupported) -} - // checkVersionCompatibility validates that the context version is supported by the current CLI func checkVersionCompatibility(contextVersion, latestSupported, contextFile string) error { if contextVersion == "" { @@ -143,7 +102,7 @@ func checkVersionCompatibility(contextVersion, latestSupported, contextFile stri // If context version is newer than what we support, return compatibility error if versionGreaterThan(contextVersion, latestSupported) { - return &VersionCompatibilityError{ + return &common.VersionCompatibilityError{ ContextVersion: contextVersion, CLIVersion: version.GetVersion(), LatestSupported: latestSupported, From 5305a09be5fac720a06d43c80062bf6f14d9ba64 Mon Sep 17 00:00:00 2001 From: supernova Date: Tue, 10 Jun 2025 00:02:19 +0530 Subject: [PATCH 6/8] use embedded version --- pkg/common/config.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/common/config.go b/pkg/common/config.go index 109e0059..f242a7f2 100644 --- a/pkg/common/config.go +++ b/pkg/common/config.go @@ -133,7 +133,7 @@ This can cause context corruption if you proceed. Please update your devkit CLI # Update devkit CLI to latest version -VERSION=v0.0.8 +VERSION=%s ARCH=$(uname -m | tr '[:upper:]' '[:lower:]') DISTRO=$(uname -s | tr '[:upper:]' '[:lower:]') @@ -147,7 +147,7 @@ After updating, verify the CLI version supports your context: devkit --version DO NOT edit the context file until you update the CLI version. -`, e.ContextFile, e.ContextVersion, e.CLIVersion, e.LatestSupported) +`, e.ContextFile, e.ContextVersion, e.CLIVersion, e.LatestSupported, embeddedDevkitReleaseVersion) } // parseVersion converts version string like "0.0.5" to comparable integers From 3ada6155a3721a0a52c3fe3f202777d02d126df6 Mon Sep 17 00:00:00 2001 From: supernova Date: Tue, 10 Jun 2025 00:07:39 +0530 Subject: [PATCH 7/8] use common 's variable for latest context version in migration so we always udpate it(don't forget ) --- config/contexts/registry.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/contexts/registry.go b/config/contexts/registry.go index b73db499..660212ae 100644 --- a/config/contexts/registry.go +++ b/config/contexts/registry.go @@ -4,12 +4,12 @@ import ( _ "embed" "github.com/Layr-Labs/devkit-cli/pkg/migration" - + "github.com/Layr-Labs/devkit-cli/pkg/common" contextMigrations "github.com/Layr-Labs/devkit-cli/config/contexts/migrations" ) // Set the latest version -const LatestVersion = "0.0.5" +const LatestVersion =common.DevkitLatestContextVersion // Array of default contexts to create in project var DefaultContexts = [...]string{ From d76136d748be89936dbdf6acb3a4f332e7f9eb74 Mon Sep 17 00:00:00 2001 From: supernova Date: Mon, 16 Jun 2025 16:39:01 +0530 Subject: [PATCH 8/8] resolve nits --- pkg/migration/migrator.go | 33 +++++---------------------------- 1 file changed, 5 insertions(+), 28 deletions(-) diff --git a/pkg/migration/migrator.go b/pkg/migration/migrator.go index 28e02dce..2af899c9 100644 --- a/pkg/migration/migrator.go +++ b/pkg/migration/migrator.go @@ -69,43 +69,20 @@ type VersionComparator func(string, string) bool var ErrAlreadyUpToDate = errors.New("already up to date") // checkVersionCompatibility validates that the context version is supported by the current CLI -func checkVersionCompatibility(contextVersion, latestSupported, contextFile string) error { +func checkVersionCompatibility(contextVersion, contextFile string) error { if contextVersion == "" { // Missing version - could be very old context, warn but allow return fmt.Errorf("context file %s is missing version field - this may be an old context that needs migration", contextFile) } - // For CLI version v0.0.8, we can support up to context version 0.0.5 - // Override the latestSupported if this CLI version supports higher cliVersion := version.GetVersion() - if cliVersion == "v0.0.8" || cliVersion == "0.0.8" { - latestSupported = "0.0.5" - } - if cliVersion == "v0.0.7" || cliVersion == "0.0.7" { - latestSupported = "0.0.3" - } - if cliVersion == "v0.0.6" || cliVersion == "0.0.6" { - latestSupported = "0.0.3" - } - if cliVersion == "v0.0.4" || cliVersion == "0.0.4" { - latestSupported = "0.0.3" - } - if cliVersion == "v0.0.3" || cliVersion == "0.0.3" { - latestSupported = "0.0.3" - } - if cliVersion == "v0.0.2" || cliVersion == "0.0.2" { - latestSupported = "0.0.3" - } - if cliVersion == "v0.0.1" || cliVersion == "0.0.1" { - latestSupported = "0.0.1" - } // If context version is newer than what we support, return compatibility error - if versionGreaterThan(contextVersion, latestSupported) { + if versionGreaterThan(contextVersion, common.DevkitLatestContextVersion) { return &common.VersionCompatibilityError{ ContextVersion: contextVersion, - CLIVersion: version.GetVersion(), - LatestSupported: latestSupported, + CLIVersion: cliVersion, + LatestSupported: common.DevkitLatestContextVersion, ContextFile: contextFile, } } @@ -160,7 +137,7 @@ func MigrateYaml(logger iface.Logger, path string, latestVersion string, migrati to := latestVersion // Check version compatibility BEFORE attempting migration - if err := checkVersionCompatibility(from, latestVersion, path); err != nil { + if err := checkVersionCompatibility(from, path); err != nil { return err }