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

37 improve reputation #116

Open
wants to merge 19 commits into
base: universal-develop
Choose a base branch
from
Open

Conversation

f-gate
Copy link

@f-gate f-gate commented Sep 28, 2022

Reputation pallet with basic implementation,

@f-gate f-gate linked an issue Sep 28, 2022 that may be closed by this pull request
@stojanov-igor
Copy link
Member

Can you merge univeresal-develop into this branch and resolve the conflicts? @f-gate

Copy link
Member

@stojanov-igor stojanov-igor left a comment

Choose a reason for hiding this comment

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

  1. Resolve the merge conflicts with universal-develop.
  2. Solve the Clippy warnings.
  3. In the current implementation, ratings are too generically implemented, while we need them only for our Profile. This is overengineering for the problem we are trying to solve. On the good side, you have created a generic solution that others can reuse. However, I would still like Reputation to be tied to a Profile.
  4. TIght coupling is a mess when you need to update the version. Consider loosely coupling.
  5. Implement some tests in Task pallet that verify that Profile reputation is updated when task is accepted with a certain rating.

type Event = Event;
type ReputationHandler = pallet_reputation::impls::ReputationHandler;
type DefaultReputation = DefaultReputation;
type MaximumRatingsPer = MaximumRatingsPer;
Copy link
Member

Choose a reason for hiding this comment

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

Why we need max ratings?

@@ -101,14 +106,13 @@ pub mod pallet {
pub name: BoundedVec<u8, T::MaxUsernameLen>,
pub interests: BoundedVec<u8, T::MaxInterestsLen>,
pub balance: Option<BalanceOf<T>>,
pub reputation: u32,
Copy link
Member

Choose a reason for hiding this comment

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

We have to keep the reputation as part of the profile struct.


#[pallet::storage]
#[pallet::getter(fn reputation_of)]
pub type RepInfoOf<T: Config> = StorageMap<_, Twox64Concat, T::AccountId, Reputable<T>, OptionQuery>;
Copy link
Member

Choose a reason for hiding this comment

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

Based on my initial design, reputation was tied to profile, now it is tied to AccountId.

pallet_profile::Pallet::<T>::add_reputation(&task.initiator)?;
pallet_profile::Pallet::<T>::add_reputation(&task.volunteer)?;
if *task_status == TaskStatus::Accepted {
// TODO:pallet_profile::Pallet::<T>::add_reputation(&task.initiator)?;
Copy link
Member

Choose a reason for hiding this comment

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

TODO is what we need.

}

/// Remove a reputation record from storage.
pub fn remove_reputation_record(account: T::AccountId) -> DispatchResult {
Copy link
Member

Choose a reason for hiding this comment

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

We should not allow removing of reputation. Not even by a sudo account.


parameter_types! {
#[derive(TypeInfo, MaxEncodedLen, Encode)]
pub MaximumRatingsPer: u32 = 5;
Copy link
Member

Choose a reason for hiding this comment

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

I see MaximumRatingsPer is the maximum rate per rating. Maybe call it MaxRatePerRating.

@@ -183,7 +186,7 @@ pub mod pallet {

/// Configure the pallet by specifying the parameters and types on which it depends.
#[pallet::config]
pub trait Config: frame_system::Config + pallet_profile::Config {
pub trait Config: frame_system::Config + pallet_reputation::Config + pallet_profile::Config {
Copy link
Member

Choose a reason for hiding this comment

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

The tight coupling will be a problem.


// Assert logic follows as described in: https://github.com/UniversalDot/universal-dot-node/issues/37
assert_ok!(Reputation::rate_account(&0, &bounded_vec![1u8, 1u8]));
let rep_record = RepInfoOf::<Test>::get(0).unwrap();
Copy link
Member

Choose a reason for hiding this comment

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

Based on the design, 1 rating gets -2, and in this one gets a -4.

Copy link
Member

Choose a reason for hiding this comment

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

Change the implementation, or change the design. :)

pub type Rating = u8;
use crate::traits::ReputationHandler;

pub const MAX_CREDIBILITY: CredibilityUnit = 1000;
Copy link
Member

Choose a reason for hiding this comment

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

How is Max Credibility decided?

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.

improve reputation calculations
2 participants