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

Feature manifest and permission system #766

Merged
merged 66 commits into from
May 24, 2019

Conversation

shargon
Copy link
Member

@shargon shargon commented May 20, 2019

@erikzhang erikzhang added this to the NEO 3.0 milestone May 20, 2019
neo/SmartContract/ContractAbi.cs Outdated Show resolved Hide resolved
neo/SmartContract/ContractManifestFeatures.cs Outdated Show resolved Hide resolved
@saltyskip
Copy link

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

@erikzhang
Copy link
Member

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

Yes.

neo/Ledger/ContractState.cs Outdated Show resolved Hide resolved
neo/Ledger/ContractState.cs Outdated Show resolved Hide resolved
neo/Ledger/ContractState.cs Outdated Show resolved Hide resolved
neo/SmartContract/Native/NativeContract.cs Outdated Show resolved Hide resolved
neo/SmartContract/Native/NativeContract.cs Outdated Show resolved Hide resolved
return true;
}

if (manifest.Trusts != null && !manifest.Trusts.IsWildcard && !manifest.Trusts.Contains(Hash))
Copy link
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
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
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
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
Member Author

shargon commented May 23, 2019

@vncoelho do you want to review it again?

@vncoelho
Copy link
Member

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

neo/SmartContract/Manifest/WildCardContainer.cs Outdated Show resolved Hide resolved
}
else if (Contract.IsGroup)
{
if (manifest.Groups.All(p => !p.PubKey.Equals(Contract.Group))) return false;
Copy link
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
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
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
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
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
Member

Choose a reason for hiding this comment

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

All

Copy link
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.

neo.UnitTests/UT_ContractManifest.cs Show resolved Hide resolved
[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
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
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
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
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
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
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
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
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
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
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