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

container: allow to iterate over container list #300

Merged
merged 1 commit into from
Dec 23, 2022

Conversation

fyrchik
Copy link
Contributor

@fyrchik fyrchik commented Dec 22, 2022

Signed-off-by: Evgenii Stratonikov [email protected]

@@ -93,6 +95,32 @@ func _deploy(data interface{}, isUpdate bool) {
if isUpdate {
args := data.([]interface{})
common.CheckVersion(args[len(args)-1].(int))

Copy link
Member

Choose a reason for hiding this comment

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

There has to be some check for the current contract version here, if it's >= some this migration is not needed.

Copy link
Contributor Author

@fyrchik fyrchik Dec 23, 2022

Choose a reason for hiding this comment

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

Our current policy is that we remove this code after release and update "min updating from" versions in common package. This way we can update contract multiple times, but do not have complex logic in _deploy.

Copy link
Member

Choose a reason for hiding this comment

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

Not very user-friendly, upgrading contracts multiple times in no fun especially given that some node versions work fine with some contract versions and don't work with others.

container/container_contract.go Outdated Show resolved Hide resolved
container/container_contract.go Outdated Show resolved Hide resolved
container/container_contract.go Outdated Show resolved Hide resolved
container/container_contract.go Outdated Show resolved Hide resolved
}

func getAllContainers(ctx storage.Context) [][]byte {
var list [][]byte
list := [][]byte{}
Copy link
Member

Choose a reason for hiding this comment

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

what's the byte code diff with that lines?

Copy link
Member

Choose a reason for hiding this comment

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

Should be none, which means that the change is not needed.

Copy link
Contributor

@alexvanin alexvanin Dec 23, 2022

Choose a reason for hiding this comment

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

I think empty var list [][]byte returns [{"type":"Any"}] on stack, while list := [][]byte{} returns [{"type":"Array","value":[]}]. Not sure it is related to the code, but still.

}
require.ElementsMatch(t, expected, actual)
})
t.Run("check with `iterate`", func(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
t.Run("check with `iterate`", func(t *testing.T) {
t.Run("check with `containersOf`", func(t *testing.T) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@fyrchik fyrchik merged commit 1303cfe into nspcc-dev:support/v0.16 Dec 23, 2022
roman-khimov added a commit that referenced this pull request Jan 17, 2023
* origin/support/v0.16:
  common: bump version, do netmap migrations pre-0.16.0
  netmap: migrate candidate states for pre-0.16.0
  netmap: fix infinite loop in pre-0.16.0 migration code
  [#300] container: Allow to iterate over container list
  [#293] container: Add IterateContainerSizes method
  [#296] container: Increase default expiration time
  [#291] Debian packaging
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants