-
Notifications
You must be signed in to change notification settings - Fork 115
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
Redux: Requirements for smart contract content directory #1520
Comments
I suggest we do this in two iterations, first iteration avoids any need for upgradability, as described by this bullet point
Then we can do a second iteration where we consider whether its worth itnroducing some kind of upgradability. The major approaches seem to be separate data and delegatecall proxying, but there seems to be substantial tradeoffs is safety, maintainability of this
Storage separation, but without eternal storage, seems like the most acceptable tradeoff in terms of complexity and benefit. |
This seems like a very useful resource |
Initial design draftThis just an initial design draft of content directory smart contracts describing:
ModifiersInside the Solidity pseudocode provided under Contracts I assumed the existance of some basic function modifiers that would be used to check permissions:
ContractsThis sections describes some basic contract instances required, along with some pseudocode that briefly describes the storage and methods of each of those contracts,
|
OverallPhenomenal work, and extremly fast turnaround, very excited to see this get implemented. General
membership module bridge
content working group module bridge
CuratorGroupStorage
ChannelStorage
VideoStorage
ContentDirectoryLogic
|
If we use the same address for methods that are called through proposals and the methods that are called by the runtime to, for example, update the bridge contracts' state (ie. I suppose it would make no sense to break them intentionally, but it's just an additional security measure (alternatively we can just have
We could maybe use
Perhaps we could try implementaing our own library to sidestep that.
In
I was thinking in context of easily retrieving
I was assuming the runtime would execute all the necessary evm calls to
In the current example Perhaps we can have separate methods for that, implement additional checks and emit an event from the contract in cases like the one mentioned, so that any inconsistencies could be more easily spotted.
I agree,
Good points, it's possible to simplify it this way
Those are a bit more tricky because, for example, it's |
As discussed with @bedeho, we should allow updating the metadata of both disabled channels and videos, since the reason to disable a channel/video may be related to its metadata, in which case we would want the owner to fix the issue while the channel/video is still deactivated, so it can be then verified and reenabled by the curator. This imples that:
|
Was tried. |
Redux: Requirements for smart contract content directory
Problem
Our current content directory has a bespoke, complex and arbitrary write access model that has multiple independent strands in order to model ownership, relationship constraints and ration resource utilisation. It is a very inflexible model in terms of what functionality it support, and increasing this scope requires compounding the already disorganised write access model.
Proposal
This proposal for requirements for a smart contract based content directory rests on the analysis here
#1518
and the assumption that the, yet to be conducted, benchmarking analysis finds that it is practical and safe to accept the need for migrations in rare cases.
Note
This is not a specification, it is a draft for a set of requirements for a specification.
Prior Approach
There was an exploratory attempt at sketching out an implementation for a smart contract based content directory here
#368
The outcome was evaluated to be quite positive, however more recent lessons suggest that even this evaluation was too pessimistic, specifically
Requirements
EVM
We are using the EVM module because it has the best supporting tooling and the broadest developer adoption at this time. One important limitation is worth keeping in mind when using the
EVM
FRAME module, which actually also applies for theContract
FRAME module. This limitation is that it is not possible to make any call, synchronous or asynchronous, from the smart contract environment and into the rest of the runtime. In the same vein it is not possible to read or write to external storage. However, it is possible to make the following synchronous calls into the smart contract environment from the runtime:Call
: Call a method on a contract.Deploy
: Deploy a new contract.Deposit
: Deposit funds from abalances
account to a smart contract account.Withdraw
: Withdraw funds from a smart contract account into abalances
account.This impacts how to integrate external parts of our runtime with the content directory, such as the content directory working group, the proposal system, and so on. The key take away here is that these integrations cannot depend on being able to read external runtime state, as is typical for example when we wish to authenticate someone as holding a role in a working group, or being a given member. Inverse integrations, such as proposals updating the state in the content directory, works just fine, you just need some contract for the proposal system, and only the proposal system, to be able to invoke.
We want to retain the feature that any user can submit new smart contracts in the EVM, this will be essential for allowing new ownership abstractions not built in to the system.
Flexible Proposal System Integration
At all times there must be a hard coded account, only updatable with a runtime upgrade, referred to as the council smart contract account. This account is the equivalent of the funds and contract caller that the council has the right to use directly.
There should be at least the following types of proposals:
Call
on any contract as council smart contract account. Gas is still paid, and (1) can be used to finance it.Deploy
for any contract as council smart contract account. Gas is still paid, and (1) can be used to finance it.It's worth nothing that 2 above actually allows for extreme flexibility in how the content directory can be updated in the future. For example, what it means to be a curator, curator group and so on, can be entirely altered.
Metadata
Metadata refers to that data which is write only, that is the values are not relevant to any state transition. For content, metadata is typically things like titles, descriptions and so on. The majority of the fields found in runtime schemas shipped for Babylon Network constitute such metadata. Recall that such metadata is not to be stored in state. The old content directory attempted to have schema based validation of the metadata itself, however this has limited value. Instead, the metadata for any entity in the content directory should just follow the semantics of a raw blob based dictionary. This means that when initialising metadata for some entity, such an initial dictionary is provided, and then there is a subsequent ability to set, or unset mappings in this dictionary for a given entity. Here are some hypothetical metadata mutators for
Channel
entities:makeChannel(..., initial_metadata: BTreeMap<Vec<u8>, Vec<u8>>)
setChannelMetadata(update_mappings: BTreeMap<Vec<u8>, Vec<u8>>)
unsetChannelMetadata(drop_keys: BTreeSet<Vec<u8>>)
The benefit of treating the metadata as a dictionary, rather than a singular blob, is that it allows for more space efficient updating of parts of the metadata, as compared to uploading a new blob for every change. Do of course keep in mind, none of the metadata is held in state, the dictionary mutations only occur virtually.
Lastly, both curators, and any owner, should be able to update metadata.
Roles
There are three roles in the Joystream runtime which make their way into the content directory
There is also the concept of a curator group, which is simply an identifiable group with a dynamic membership set of curators, managed by the lead. Such groups are meant to represent an intermediary for managing channels belonging to the platform itself. Each of these concepts are explained in the following sections.
Lead
A lead can directly act as a curator and as a member of any curator group.
A lead can also be deactivated or activated by the council through a proposal, when deactivated, the lead cannot perform any lead action.
The working group lead can only act as a lead as long as they have are not unstaking.
Curator
A curator can act as a member of a curator group, the significance of which is explained later, and otherwise perform curator activities like deactivating/activating channels or videos, or deleting videos.
A working group worker can only act as a curator as long as they have are not unstaking.
A curator can only be part of up to a hard coded number of working groups which is sufficiently low that it is considered safe and economical to iterate and remove the curator from all such groups in the event that the curator the working group.
Be aware that since the EVM cannot dial out to the working group to authenticate callers as workers, it must be the case that there is some EVM state accumulated about what memberships exist, and what their controller accounts are at any given time. This will requires introducing hooks in the working group module that call into the EVM to build synch this state.
Curator Group
A curator group is created by the lead, and the lead can manage the membership of each curator in each group. A group can be deleted only when no curators are members and no channels are owned by the group. Each curator has independent permissions associated with membership in a given group, describing which among the following are available in a group owned channel
Publish
: Publish new videos.UpdateVideo
: Update video metadata.Delete
: Delete videos.UpdateChannel
: Update channel metadata.It follows that channels owned by curator groups do not follow the normal permission model, where the curators normally can do lots of things (see Channels). Only the lead can create a group channel and manage what groups maintain what channel.
Members
A member can create a new channel and own it as a member.
Be aware that since the EVM cannot dial out to the membership module to authenticate callers as members, it must be the case that there is some EVM state accumulated about what memberships exist, and what their controller accounts are at any given time. This will requires introducing hooks in the membership module that call into the EVM to build synch this state.
Channels
Channels satisfy the following requirements.
Videos
Videos satisfy the following requirements.
Specification
As stated, this description is more a description of requirements, and a more detailed specification is needed to move forward. This specification must describe
The text was updated successfully, but these errors were encountered: