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

fix contract trust FromStackItem ContractPermissionDescriptor.Create(StackItem item) #2901

Merged
merged 4 commits into from
Sep 25, 2023

Conversation

Hecate2
Copy link
Contributor

@Hecate2 Hecate2 commented Sep 8, 2023

#2899
nspcc-dev/neo-go#3105
#2890
NOT EXPECTED TO BE MERGED DIRECTLY. Just to make ListContracts and GetContract(0x12fbec62fb765ce3f55845106ccf3717716723ad) work on Testnet T5 for now
https://github.com/Hecate2/neo/releases/tag/fix-contract-trust

@Hecate2 Hecate2 changed the title ContractPermissionDescriptor.Create(StackItem item) fix contract trust FromStackItem ContractPermissionDescriptor.Create(StackItem item) Sep 8, 2023
@roman-khimov
Copy link
Contributor

Seems to be legit. We have appropriate NULL stored in the DB (T5 state matches between NeoGo 0.102.0 and C# 3.6), so the only question is to read it properly.

Jim8y
Jim8y previously approved these changes Sep 8, 2023
@Jim8y
Copy link
Contributor

Jim8y commented Sep 8, 2023

LGTM

Comment on lines 83 to +84
// Array array when array.Any(p => ((ByteString)p).Size == 0) => WildcardContainer<ContractPermissionDescriptor>.CreateWildcard(),
Array array => WildcardContainer<ContractPermissionDescriptor>.Create(array.Select(p => new ContractPermissionDescriptor(p.GetSpan())).ToArray()),
Array array => WildcardContainer<ContractPermissionDescriptor>.Create(array.Select(ContractPermissionDescriptor.Create).ToArray()),
Copy link
Contributor

Choose a reason for hiding this comment

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

Well i still recommand to have this logic: if any of the permission is any, then the permission is any:

                Array array when array.Any(p => p.Equals(StackItem.Null)) => WildcardContainer<ContractPermissionDescriptor>.CreateWildcard(),
                Array array => WildcardContainer<ContractPermissionDescriptor>.Create(array.Select(ContractPermissionDescriptor.Create).ToArray()),

Copy link
Member

@AnnaShaleva AnnaShaleva left a comment

Choose a reason for hiding this comment

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

It would be nice to extend the TestSerializeTrusts added in https://github.com/Liaojinghui/neo/pull/1/files with a wildcard deserialisation test.

Otherwise, LGTM.

@roman-khimov roman-khimov mentioned this pull request Sep 18, 2023
@roman-khimov
Copy link
Contributor

Anything preventing the merge now? Tested, @superboyiii?

@superboyiii
Copy link
Member

Tested OK.
1695626707852
1695626744497

@shargon shargon merged commit f6d578b into neo-project:master Sep 25, 2023
1 check passed
AnnaShaleva added a commit to nspcc-dev/neo-go that referenced this pull request Sep 25, 2023
If a manifest trusts presented as Null stackitem, then it should be
treated as wildcard, not as restricted.

It's not the same problem as described and fixed in
neo-project/neo#2901 and
https://github.com/neo-project/neo/pull/2892/files, although these
two PRs are related.

Signed-off-by: Anna Shaleva <[email protected]>
AnnaShaleva added a commit to nspcc-dev/neo-go that referenced this pull request Sep 25, 2023
If manifest trusts presented as Null stackitem, then they should be
treated as wildcard, not as restricted.

It's not the same problem as described and fixed in
neo-project/neo#2901 and
https://github.com/neo-project/neo/pull/2892/files, although these
two PRs are related.

Signed-off-by: Anna Shaleva <[email protected]>
AnnaShaleva added a commit to nspcc-dev/neo-go that referenced this pull request Sep 25, 2023
If manifest trusts presented as Null stackitem, then they should be
treated as wildcard, not as restricted.

It's not the same problem as described and fixed in
neo-project/neo#2901 and
neo-project/neo#2892, although these
two PRs are related.

Signed-off-by: Anna Shaleva <[email protected]>
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.

6 participants