From 065406bd7752e83278d87529920ba4b9c592bd0c Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Fri, 14 Jun 2024 10:53:01 +0300 Subject: [PATCH] adm: add support for the new neofs-contract archives As a part of https://github.com/nspcc-dev/neofs-contract/issues/384 I'd like to unify different code dealing with them. Signed-off-by: Roman Khimov --- CHANGELOG.md | 1 + .../internal/modules/morph/initialize_deploy.go | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ae4e09ed8..8248a499f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ Changelog for NeoFS Node ### Added - Indexes inspection command to neofs-lens (#2882) - Add objects sanity checker to neofs-lens (#2506) +- Support for 0.20.0+ neofs-contract archive format (#2872) ### Fixed - Control service's Drop call does not clean metabase (#2822) diff --git a/cmd/neofs-adm/internal/modules/morph/initialize_deploy.go b/cmd/neofs-adm/internal/modules/morph/initialize_deploy.go index 19a2dec15a..e519f51197 100644 --- a/cmd/neofs-adm/internal/modules/morph/initialize_deploy.go +++ b/cmd/neofs-adm/internal/modules/morph/initialize_deploy.go @@ -372,11 +372,17 @@ func (c *initializeContext) readContracts(names []string) error { func readContract(ctrPath, ctrName string) (*contractState, error) { rawNef, err := os.ReadFile(filepath.Join(ctrPath, ctrName+"_contract.nef")) if err != nil { - return nil, fmt.Errorf("can't read NEF file for %s contract: %w", ctrName, err) + rawNef, err = os.ReadFile(filepath.Join(ctrPath, "contract.nef")) + if err != nil { + return nil, fmt.Errorf("can't read NEF file for %s contract: %w", ctrName, err) + } } rawManif, err := os.ReadFile(filepath.Join(ctrPath, "config.json")) if err != nil { - return nil, fmt.Errorf("can't read manifest file for %s contract: %w", ctrName, err) + rawManif, err = os.ReadFile(filepath.Join(ctrPath, "manifest.json")) + if err != nil { + return nil, fmt.Errorf("can't read manifest file for %s contract: %w", ctrName, err) + } } cs := &contractState{ @@ -429,12 +435,14 @@ func readContractsFromArchive(file io.Reader, names []string) (map[string]*contr } switch { - case strings.HasSuffix(h.Name, filepath.Join(ctrName, ctrName+"_contract.nef")): + case strings.HasSuffix(h.Name, filepath.Join(ctrName, ctrName+"_contract.nef")) || + strings.HasSuffix(h.Name, "contract.nef"): cs.RawNEF, err = io.ReadAll(r) if err != nil { return nil, fmt.Errorf("can't read NEF file for %s contract: %w", ctrName, err) } - case strings.HasSuffix(h.Name, "config.json"): + case strings.HasSuffix(h.Name, "config.json") || + strings.HasSuffix(h.Name, "manifest.json"): cs.RawManifest, err = io.ReadAll(r) if err != nil { return nil, fmt.Errorf("can't read manifest file for %s contract: %w", ctrName, err)