Skip to content

Feature manifest and permission system#766

Merged
erikzhang merged 66 commits intoneo-project:masterfrom
shargon:feature-manifest
May 24, 2019
Merged

Feature manifest and permission system#766
erikzhang merged 66 commits intoneo-project:masterfrom
shargon:feature-manifest

Conversation

@shargon
Copy link
Copy Markdown
Member

@shargon shargon commented May 20, 2019

@erikzhang erikzhang added this to the NEO 3.0 milestone May 20, 2019
@saltyskip
Copy link
Copy Markdown

Can a contract update permissions without migrating to a new contract?

@erikzhang
Copy link
Copy Markdown
Member

Can a contract update permissions without migrating to a new contract?

Yes.

return true;
}

if (manifest.Trusts != null && !manifest.Trusts.IsWildcard && !manifest.Trusts.Contains(Hash))
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

now Trusts is not used

Copy link
Copy Markdown
Member

@erikzhang erikzhang May 23, 2019

Choose a reason for hiding this comment

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

trusts is for displaying warnings by client or wallet only.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Then trusts and safeMethods is only for user interfaces?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes.

erikzhang
erikzhang previously approved these changes May 23, 2019
erikzhang
erikzhang previously approved these changes May 23, 2019
@shargon
Copy link
Copy Markdown
Member Author

shargon commented May 23, 2019

@vncoelho do you want to review it again?

@vncoelho
Copy link
Copy Markdown
Member

With pleasure, in the middle of it, in 2 hours it will done.

}
else if (Contract.IsGroup)
{
if (manifest.Groups.All(p => !p.PubKey.Equals(Contract.Group))) return false;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Does All work as expected or Sum would also work?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What sum?

Copy link
Copy Markdown
Member

@vncoelho vncoelho May 23, 2019

Choose a reason for hiding this comment

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

It is checking, for all groups, if any of them is not equal.

Maybe this is strange, because one of yours groups may not allow you to enter, but another one can allow you to interact with the desired contract.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

All not Any.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If p.PubKey.Equals(Contract.Group) is false for any of the groups of have it will probably return false, no?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

All

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If p.PubKey.Equals(Contract.Group) is false for ALL of the groups, it will return false.

[TestMethod]
public void ParseFromJson_Groups()
{
var json = @"{""groups"":[{""pubKey"":""03b209fd4f53a7170ea4444e0cb0a6bb6a53c2bd016926989cf85f9b0fba17a70c"",""signature"":""41414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141""}],""features"":{""storage"":false,""payable"":false},""abi"":{""hash"":""0x0000000000000000000000000000000000000000"",""entryPoint"":{""name"":""Main"",""parameters"":[{""name"":""operation"",""type"":""String""},{""name"":""args"",""type"":""Array""}],""returnType"":""Any""},""methods"":[],""events"":[]},""permissions"":[{""contract"":""*"",""methods"":""*""}],""trusts"":[],""safeMethods"":[]}";
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

How does these groups really work? A contract can be part of more than one group in this current design, right?
And why the signature?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Without signature, you can join any group, which is not by design.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ok, I got it, in the current design, how is able to sign for entering? Is it a multisig with 1 single threshold?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just put the signature in the json.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The group identifier is the PublicKey, right? 03b209fd4f53a7170ea4444e0cb0a6bb6a53c2bd016926989cf85f9b0fba17a70c

Which signatures will be allowed?
If we have 10 members of the group, should we create a MultiSig 1/10? For each new member, append an additional PubKey?

Sorry for the trivial questions, @erikzhang, trying to get the idea here...aehauheau

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please check the specification here: #287

Where pubkey represents the public key of the group and signature is the signature of the contract hash.

@vncoelho
Copy link
Copy Markdown
Member

vncoelho commented May 23, 2019

I am still finishing, but it would be great if we could wait for @igormcoelho, he is on a trip today. We may have to wait some couple of hours.
Otherwise, fell free to merge.

Copy link
Copy Markdown
Contributor

@igormcoelho igormcoelho left a comment

Choose a reason for hiding this comment

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

Interesting implementation. My only opinion is that two things could be different: (1) groups could be a smart contract perhaps native (some NEP that allows or denies contracts to be invoked). But I agree that pubkey sig system will work.
(2) there could be an option for "final" contracts, that cannot be migrated. This would also apply for native contracts, that evolve outside the scope of migration system.

@igormcoelho
Copy link
Copy Markdown
Contributor

Something that may benefit users a lot is a DeployGroup operation, that deploys all group contracts at once (for the price of features + number of contracts). This could be cheaper and avoid people wanting to embed all in one just for price.

@erikzhang erikzhang merged commit af77daf into neo-project:master May 24, 2019
@erikzhang
Copy link
Copy Markdown
Member

there could be an option for "final" contracts, that cannot be migrated.

If you remove the call of System.Contract.Migrate of the contract, it will be final.

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.

Store contract ABI on the blockchain Feature manifest and permission system for NeoContract

6 participants