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

Optimistic Project Funding #6994

Open
wants to merge 115 commits into
base: master
Choose a base branch
from
Open

Optimistic Project Funding #6994

wants to merge 115 commits into from

Conversation

ndkazu
Copy link
Contributor

@ndkazu ndkazu commented Dec 24, 2024

Description

This PR is related to this issue .
Through the introduction of the OPF pallet and the DISTRIBUTION pallet, we are handling the Optimistic Project Funding.
It allows users to nominate projects (whitelisted in OpenGov) with their DOT. This mechanism will be funded with a constant stream of DOT taken directly from inflation and distributed to projects based on the proportion of DOT that has nominated them.

Integration

Review Notes

Terminology

The constants available in the runtime for the OPF Pallet:

  • MaxProjects: Maximum number of Whitelisted projects that can be handled by the pallet.
  • VotingPeriod: Period in which people can vote. After the period has ended, the votes are counted (STOP THE COUNT) and then the funds are distributed into Spends.
  • ClaimingPeriod: Time for claiming a Spend. After the period has passed, a spend is thrown away and the funds are available again for distribution in the pot.
  • VoteValidityPeriod: Period after which all the votes are reset.

Functions

  • - register_project: Register by OpenGov, should take AccountId and project Purpose.
  • - unregister_project: Unregister by OpenGov
  • - claim: To claim a spend

Checklist

pallet-opf

  • Pallet Config
  • Helper functions
  • Extrinsics
  • Events & Tests
  • Benchmarking & weights
  • Remove Dev-mode
  • Proper documentation

@ndkazu ndkazu requested a review from a team as a code owner December 24, 2024 12:34
Copy link
Contributor

@gui1117 gui1117 left a comment

Choose a reason for hiding this comment

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

you can open the PR as a draft until it is ready.

Or ping when it is ready.

substrate/frame/opf/src/types.rs Outdated Show resolved Hide resolved
substrate/frame/opf/src/lib.rs Show resolved Hide resolved
substrate/frame/opf/src/function.rs Outdated Show resolved Hide resolved
substrate/frame/opf/src/lib.rs Outdated Show resolved Hide resolved
substrate/frame/opf/src/lib.rs Outdated Show resolved Hide resolved
@gui1117 gui1117 marked this pull request as draft December 29, 2024 10:13
substrate/frame/opf/src/lib.rs Outdated Show resolved Hide resolved
substrate/frame/opf/src/lib.rs Outdated Show resolved Hide resolved
substrate/frame/opf/src/lib.rs Outdated Show resolved Hide resolved
substrate/frame/opf/src/lib.rs Outdated Show resolved Hide resolved
substrate/frame/opf/src/lib.rs Outdated Show resolved Hide resolved
substrate/frame/opf/src/functions.rs Show resolved Hide resolved
substrate/frame/opf/src/types.rs Outdated Show resolved Hide resolved
substrate/frame/opf/src/lib.rs Outdated Show resolved Hide resolved
substrate/frame/opf/src/types.rs Outdated Show resolved Hide resolved
substrate/frame/opf/src/lib.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@pandres95 pandres95 left a comment

Choose a reason for hiding this comment

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

Some pretty superficial notes to start my review. Can continue with a more detailed review later tomorrow.

As a general remark, if you have a voting schema that somehow resembles what's already out there on OpenGov, I suggest you consider exploring the pallets that implement Tally and integrate with pallet-referenda.

substrate/frame/opf/Cargo.toml Outdated Show resolved Hide resolved
substrate/frame/opf/Cargo.toml Outdated Show resolved Hide resolved
substrate/frame/opf/src/lib.rs Outdated Show resolved Hide resolved
Comment on lines 287 to 310
/// OPF Projects registration
///
/// ## Dispatch Origin
///
/// Must be AdminOrigin
///
/// ## Details
///
/// From this extrinsic only AdminOrigin can register project.
///
/// ### Parameters
/// - `projects_id`: The accounts that might be funded.
///
/// ### Errors
/// - [`Error::<T>::MaximumProjectsNumber`]: Maximum number of project subscriptions reached
///
/// ## Events
/// Emits [`Event::<T>::Projectslisted`].
#[pallet::call_index(1)]
#[pallet::weight(0)]
pub fn register_projects_batch(
origin: OriginFor<T>,
projects_id: BoundedVec<ProjectId<T>, T::MaxProjects>,
) -> DispatchResult {
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 it's better to just leave a register_project call, then allow people to propose a batch of projects via Utilities::batch/Utilities::batchAll.

This implies the additional gain of not needing to handle BoundedVecs, which sometimes can be annoying. Also, benchmarking is simpler.

Finally, consider this:

We already had registered three projects, max is 5. An actor not knowing this would attempt registering two projects (since 2 < 5): The extrinsic would fail at this point.

Now, consider the case with a batch: the first project would be registered, but the second one would fail. However, the actor would be able to know which one was registered, which one failed, and why.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In my understanding of the pallet specifications, projects are first whitelisted in OpenGov, and then transferred to the OPF pallet, so I assumed that this transfer is not the task of any user, but requires a particular Origin, and in this case, it made sense to register in batch.

substrate/frame/opf/src/lib.rs Show resolved Hide resolved
substrate/frame/opf/src/lib.rs Outdated Show resolved Hide resolved
substrate/frame/opf/src/lib.rs Outdated Show resolved Hide resolved
@ndkazu
Copy link
Contributor Author

ndkazu commented Feb 6, 2025

Some pretty superficial notes to start my review. Can continue with a more detailed review later tomorrow.

As a general remark, if you have a voting schema that somehow resembles what's already out there on OpenGov, I suggest you consider exploring the pallets that implement Tally and integrate with pallet-referenda.

@pandres95 and @kianenigma , I have a question: Is there a reason for Not using pallet-democracy?
During the PBA, I was told that open-gov not being one pallet, implementation is a "bit" complex (Is there a resource I can check that is describing how it's done?).
Looking into pallet-referenda & pallet-conviction, It felt like way more work to implement something using both of these pallets together, than simply using pallet-democracy. But I will gladly dive into it, if it is ABSOLUTELY necessary, I just want to understand the "why"...

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.

4 participants