Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update neofs-contract to v0.20.0 #2872

Merged
merged 2 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -20,6 +21,8 @@ Changelog for NeoFS Node
### Removed

### Updated
- neofs-contract dependency to 0.20.0 (#2872)
- NeoGo dependency to 0.106.3 (#2872)

### Updating from v0.42.1

Expand Down
22 changes: 18 additions & 4 deletions cmd/neofs-adm/internal/modules/morph/initialize_deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"archive/tar"
"compress/gzip"
"encoding/json"
"errors"
"fmt"
"io"
"os"
Expand Down Expand Up @@ -372,11 +373,23 @@
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)
if !errors.Is(err, os.ErrNotExist) {
return nil, fmt.Errorf("can't read NEF file for %s contract: %w", ctrName, err)

Check warning on line 377 in cmd/neofs-adm/internal/modules/morph/initialize_deploy.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-adm/internal/modules/morph/initialize_deploy.go#L376-L377

Added lines #L376 - L377 were not covered by tests
}
rawNef, err = os.ReadFile(filepath.Join(ctrPath, "contract.nef"))
Copy link
Member

@carpawell carpawell Jul 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

go this way only if file not found? also, do you plan to drop it in the future?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@carpawell is faster, but i'll leave my comment anyway

err may be other than 404, so i'd either:

  1. try other file on 404 only
  2. try anyway, but keep both errors when it fails too

same for manifest files

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I doubt it's worth the trouble, but fixed anyway.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, do you plan to drop it in the future?

why do we try to support both ways? how long?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because it still is a generic tool. We'll see. An issue can be created.

if err != nil {
return nil, fmt.Errorf("can't read NEF file for %s contract: %w", ctrName, err)

Check warning on line 381 in cmd/neofs-adm/internal/modules/morph/initialize_deploy.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-adm/internal/modules/morph/initialize_deploy.go#L379-L381

Added lines #L379 - L381 were not covered by tests
}
}
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)
if !errors.Is(err, os.ErrNotExist) {
return nil, fmt.Errorf("can't read manifest file for %s contract: %w", ctrName, err)

Check warning on line 387 in cmd/neofs-adm/internal/modules/morph/initialize_deploy.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-adm/internal/modules/morph/initialize_deploy.go#L386-L387

Added lines #L386 - L387 were not covered by tests
}
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)

Check warning on line 391 in cmd/neofs-adm/internal/modules/morph/initialize_deploy.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-adm/internal/modules/morph/initialize_deploy.go#L389-L391

Added lines #L389 - L391 were not covered by tests
}
}

cs := &contractState{
Expand Down Expand Up @@ -429,12 +442,13 @@
}

switch {
case strings.HasSuffix(h.Name, filepath.Join(ctrName, ctrName+"_contract.nef")):
case strings.HasSuffix(h.Name, "contract.nef"):

Check warning on line 445 in cmd/neofs-adm/internal/modules/morph/initialize_deploy.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-adm/internal/modules/morph/initialize_deploy.go#L445

Added line #L445 was not covered by tests
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"):

Check warning on line 451 in cmd/neofs-adm/internal/modules/morph/initialize_deploy.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-adm/internal/modules/morph/initialize_deploy.go#L451

Added line #L451 was not covered by tests
cs.RawManifest, err = io.ReadAll(r)
if err != nil {
return nil, fmt.Errorf("can't read manifest file for %s contract: %w", ctrName, err)
Expand Down
4 changes: 2 additions & 2 deletions cmd/neofs-adm/internal/modules/morph/remove_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"github.com/nspcc-dev/neo-go/pkg/io"
"github.com/nspcc-dev/neo-go/pkg/smartcontract/callflag"
"github.com/nspcc-dev/neo-go/pkg/vm/emit"
netmapcontract "github.com/nspcc-dev/neofs-contract/contracts/netmap"
"github.com/nspcc-dev/neofs-contract/rpc/netmap"
"github.com/nspcc-dev/neofs-contract/rpc/nns"
"github.com/spf13/cobra"
"github.com/spf13/viper"
Expand Down Expand Up @@ -47,7 +47,7 @@
bw := io.NewBufBinWriter()
for i := range nodeKeys {
emit.AppCall(bw.BinWriter, nmHash, "updateStateIR", callflag.All,
int64(netmapcontract.NodeStateOffline), nodeKeys[i].Bytes())
netmap.NodeStateOffline, nodeKeys[i].Bytes())

Check warning on line 50 in cmd/neofs-adm/internal/modules/morph/remove_node.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-adm/internal/modules/morph/remove_node.go#L50

Added line #L50 was not covered by tests
}

if err := emitNewEpochCall(bw, wCtx, nmHash); err != nil {
Expand Down
4 changes: 2 additions & 2 deletions cmd/neofs-node/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

containerV2 "github.com/nspcc-dev/neofs-api-go/v2/container"
containerGRPC "github.com/nspcc-dev/neofs-api-go/v2/container/grpc"
containercontract "github.com/nspcc-dev/neofs-contract/contracts/container"
containerrpc "github.com/nspcc-dev/neofs-contract/rpc/container"
"github.com/nspcc-dev/neofs-node/pkg/core/client"
containerCore "github.com/nspcc-dev/neofs-node/pkg/core/container"
netmapCore "github.com/nspcc-dev/neofs-node/pkg/core/netmap"
Expand Down Expand Up @@ -133,7 +133,7 @@
key: pubKey,
}

loadAccumulator := loadstorage.New(containercontract.CleanupDelta)
loadAccumulator := loadstorage.New(containerrpc.CleanupDelta)

Check warning on line 136 in cmd/neofs-node/container.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-node/container.go#L136

Added line #L136 was not covered by tests

addNewEpochAsyncNotificationHandler(c, func(e event.Event) {
ev := e.(netmapEv.NewEpoch)
Expand Down
1 change: 0 additions & 1 deletion contracts/00-nns.manifest.json

This file was deleted.

Binary file removed contracts/00-nns.nef
Binary file not shown.
1 change: 0 additions & 1 deletion contracts/01-proxy.manifest.json

This file was deleted.

Binary file removed contracts/01-proxy.nef
Binary file not shown.
1 change: 0 additions & 1 deletion contracts/02-audit.manifest.json

This file was deleted.

Binary file removed contracts/02-audit.nef
Binary file not shown.
1 change: 0 additions & 1 deletion contracts/03-netmap.manifest.json

This file was deleted.

Binary file removed contracts/03-netmap.nef
Binary file not shown.
1 change: 0 additions & 1 deletion contracts/04-balance.manifest.json

This file was deleted.

Binary file removed contracts/04-balance.nef
Binary file not shown.
1 change: 0 additions & 1 deletion contracts/05-reputation.manifest.json

This file was deleted.

Binary file removed contracts/05-reputation.nef
Binary file not shown.
1 change: 0 additions & 1 deletion contracts/06-neofsid.manifest.json

This file was deleted.

Binary file removed contracts/06-neofsid.nef
Binary file not shown.
Loading
Loading