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 NNS contract #266

Closed
wants to merge 17 commits into from
Closed

Conversation

AnnaShaleva
Copy link
Member

Refactor code and fix a couple of bugs. Thes PR may affect other services, so @fyrchik, @carpawell, @alexvanin please, review it carefully.

@roman-khimov, these changes are ported to nspcc-dev/neo-go#2687 and to the set of C# PRs (neo-project/non-native-contracts#27 and others).

AnnaShaleva added a commit to AnnaShaleva/neofs-contract that referenced this pull request Sep 12, 2022
AnnaShaleva added a commit to AnnaShaleva/neofs-contract that referenced this pull request Sep 12, 2022
AnnaShaleva added a commit to AnnaShaleva/neofs-contract that referenced this pull request Sep 12, 2022
AnnaShaleva added a commit to AnnaShaleva/neofs-contract that referenced this pull request Sep 12, 2022
Reuse getAllRecords for GetAllRecords.
AnnaShaleva added a commit to AnnaShaleva/neofs-contract that referenced this pull request Sep 12, 2022
Do not include CNAME to the resulting list if we're looking for another
record type. If it's CNAME than it must be resolved.
Copy link
Member

@roman-khimov roman-khimov left a comment

Choose a reason for hiding this comment

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

Seems to be reasonable.

nns/nns.yml Outdated Show resolved Hide resolved
_ = getNameState(ctx, tokenID) // ensure not expired
recordsKey := getRecordsKey(tokenID, name)
return storage.Find(ctx, recordsKey, storage.ValuesOnly|storage.DeserializeValues)
return getAllRecords(ctx, name)
Copy link
Member

Choose a reason for hiding this comment

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

If we have a maxRecordID and a limited set of types, maybe we can avoid having iterator.Iterator? Although we still should have some reasonable number of items in the end. Just an idea.

Copy link
Member Author

@AnnaShaleva AnnaShaleva Sep 12, 2022

Choose a reason for hiding this comment

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

Maybe we firstly need to discuss maxRecordID value? I've added this constraint because of the record ID type: it was byte, but all int-like go types are BiGInteger in the VM, so technically, the previous implementation didn't restrict the maximum number of records of the same type. I suppose, it's not the initial intention, thus let's decide on maxRecordID.

And if we're to keep MaxRecordID set to be 255 (not that much), then I vote for converting the result of getAllecords to []stirng.

Copy link
Member

Choose a reason for hiding this comment

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

DNS doesn't have this limit. C# NNS doesn't have it too. But I see what you're talking about now, id byte overflow can be a problem in some cases. It can be fixed at the same time to have unlimited number of records of any type. Practically I'd rather have some limit (16-64), at the moment C# contract has a limit of 1 IIRC and it's kinda OK.

Copy link
Member Author

Choose a reason for hiding this comment

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

@fyrchik, what do you think about it?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think []string is easier to work with. In our scenarios we have at most 2 records per type, so 255 is more than enough.

Copy link
Member Author

@AnnaShaleva AnnaShaleva Sep 14, 2022

Choose a reason for hiding this comment

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

Getting back to this discussion, the profit of Iterator returned value here is that it returns not only record name, but the complete record information which includes record's name, type, ID and data. Currently it's the only method allowing to retrieve the whole RecordState from the contract, so I've changed my mind and suggest to keep Iterator. @roman-khimov, somehow I've missed this point previously.

Copy link
Member

Choose a reason for hiding this comment

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

OK for iterator, but some lower limit is needed. 16?

AnnaShaleva added a commit to AnnaShaleva/neofs-contract that referenced this pull request Sep 12, 2022
@fyrchik
Copy link
Contributor

fyrchik commented Sep 12, 2022

@AnnaShaleva we agreed to use capital letters in NeoFS repos after nns: part, could you change this? You can use my script if you want https://gist.github.com/fyrchik/0c7075d03f4bfe3a7665e98f9100efdb (beautify #issue master)

AnnaShaleva added a commit to AnnaShaleva/neofs-contract that referenced this pull request Sep 13, 2022
In case if no records of the specified type found.

Signed-off-by: Anna Shaleva <[email protected]>
AnnaShaleva added a commit to AnnaShaleva/neofs-contract that referenced this pull request Sep 13, 2022
`getRecord` doesn't exist since
nspcc-dev@6ea4573.

Signed-off-by: Anna Shaleva <[email protected]>
AnnaShaleva added a commit to AnnaShaleva/neofs-contract that referenced this pull request Sep 13, 2022
And adjust method usages along the way.

Signed-off-by: Anna Shaleva <[email protected]>
AnnaShaleva added a commit to AnnaShaleva/neofs-contract that referenced this pull request Sep 13, 2022
AnnaShaleva added a commit to AnnaShaleva/neofs-contract that referenced this pull request Sep 13, 2022
AnnaShaleva added a commit to AnnaShaleva/neofs-contract that referenced this pull request Sep 13, 2022
Reuse getAllRecords for GetAllRecords.

Signed-off-by: Anna Shaleva <[email protected]>
AnnaShaleva added a commit to AnnaShaleva/neofs-contract that referenced this pull request Sep 13, 2022
Do not include CNAME to the resulting list if we're looking for another
record type. If it's CNAME than it must be resolved.

Signed-off-by: Anna Shaleva <[email protected]>
AnnaShaleva added a commit to AnnaShaleva/neofs-contract that referenced this pull request Sep 13, 2022
@AnnaShaleva AnnaShaleva marked this pull request as draft September 13, 2022 09:53
AnnaShaleva added a commit to AnnaShaleva/neofs-contract that referenced this pull request Sep 13, 2022
In case if no records of the specified type found.

Signed-off-by: Anna Shaleva <[email protected]>
AnnaShaleva added a commit to AnnaShaleva/neofs-contract that referenced this pull request Sep 13, 2022
`getRecord` doesn't exist since
nspcc-dev@6ea4573.

Signed-off-by: Anna Shaleva <[email protected]>
AnnaShaleva added a commit to AnnaShaleva/neofs-contract that referenced this pull request Sep 13, 2022
And adjust method usages along the way.

Signed-off-by: Anna Shaleva <[email protected]>
AnnaShaleva added a commit to AnnaShaleva/neofs-contract that referenced this pull request Sep 13, 2022
AnnaShaleva added a commit to AnnaShaleva/neofs-contract that referenced this pull request Sep 13, 2022
AnnaShaleva added a commit to AnnaShaleva/neofs-contract that referenced this pull request Sep 13, 2022
Reuse getAllRecords for GetAllRecords.

Signed-off-by: Anna Shaleva <[email protected]>
AnnaShaleva added a commit to AnnaShaleva/neofs-contract that referenced this pull request Sep 13, 2022
Do not include CNAME to the resulting list if we're looking for another
record type. If it's CNAME than it must be resolved.

Signed-off-by: Anna Shaleva <[email protected]>
If conflicting records '*.domain' are present on new domain
registration, then `isAvailable` should return false for this
domain. Ref.
nspcc-dev@f25296b.

Signed-off-by: Anna Shaleva <[email protected]>
AnnaShaleva added a commit to AnnaShaleva/neofs-contract that referenced this pull request Sep 14, 2022
@carpawell
Copy link
Member

Hey, what's up here? The anniversary coming up soon.

@roman-khimov
Copy link
Member

The anniversary coming up soon

Preparing for celebration, as usual.

@carpawell
Copy link
Member

So are the conflicts gonna be solved? Is the PR's idea actual? Haven't seen the code yet, should I review this?

Copy link
Member

@roman-khimov roman-khimov left a comment

Choose a reason for hiding this comment

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

These are good for 0.18.0:

  • rebased wrt recent TLD changes
  • don't fix nns.yml, drop it earlier
  • fix comments
  • move []string into some other PR, these change API, I'm not sure how it can affect callers

@@ -443,7 +443,8 @@ func DeleteRecords(name string, typ RecordType) {
// Resolve resolves given name (not more then three redirects are allowed).
func Resolve(name string, typ RecordType) []string {
ctx := storage.GetReadOnlyContext()
return resolve(ctx, nil, name, typ, 2)
res := []string{}
return resolve(ctx, res, name, typ, 2)
Copy link
Member

Choose a reason for hiding this comment

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

For better unwrap compatibility? nspcc-dev/neo-go#2795, maybe?

_ = getNameState(ctx, tokenID) // ensure not expired
recordsKey := getRecordsKey(tokenID, name)
return storage.Find(ctx, recordsKey, storage.ValuesOnly|storage.DeserializeValues)
return getAllRecords(ctx, name)
Copy link
Member

Choose a reason for hiding this comment

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

OK for iterator, but some lower limit is needed. 16?

@roman-khimov roman-khimov modified the milestones: v0.18.0, v0.19.0 Sep 21, 2023
@roman-khimov roman-khimov modified the milestones: v0.19.0, v0.20.0 Nov 22, 2023
This was referenced Jul 29, 2024
@roman-khimov roman-khimov removed this from the v0.20.0 milestone Jul 29, 2024
@roman-khimov
Copy link
Member

This one was superseded by #419 and #420.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
nns NNS contract related issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants