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

project voting data api #224

Merged
merged 112 commits into from
Oct 7, 2023
Merged

project voting data api #224

merged 112 commits into from
Oct 7, 2023

Conversation

f-gate
Copy link
Member

@f-gate f-gate commented Sep 21, 2023

Add the new runtime apis for the FE devs.
There is a mgration included for the v5 update, i have pulled in rococo-admin.
Rococo-admin should be merged before this.

Solves:

Notable api details

Get all project data

You can now call proposals_getAllProjectData(project_key) to get all project data.
The data returned is a tuple Option<(Vec<u8>, Vec<u8>)>.
If nothing is found then None is returned.
To decode this you must use the types Project<T> and ImmutableIndividualVotes<T>.
The endoded type therefore looks like (Project, ImmutableIndividualVotes<T>).

Project total votes per milestone

The storage item MilestoneVotes has so we dont now need a runtime api for it. Now contains the total votes and will return: BTreeMap<MilestoneKey, Vote<Balance>>
From this you can get the total votes of each milestone, aggregated.

Get round ending

You can already get the round end by using the Rounds storage item. pass in 2 keys, (ProjectKey, MilestoneKey) and RoundType. It will return the ending block number for that round if it exists.

Get only individual voting data

You can now call the storage item IndividualVoteStore which will return an ImmutableIndividualVotes. This contains all the votes. To access there are 2 keys, 1: MilestoneKey, 2: AccountId.

After discussion this PR will be changed so that:

  • The apis are combined for ease, to return ALL data about a project.
  • The optimisation for UserHasVoted has been implemented so its far more scalable
  • Migration v5 is being run so put the new migration into proposals::v6

@f-gate f-gate merged commit 84dd997 into main Oct 7, 2023
2 checks passed
samelamin pushed a commit that referenced this pull request Oct 12, 2023
* add back sudo to rococo

* runtime api

* runtime-api-wiring

* some dummy log statements

* attempt 1 to add try-runtime

* second attempt

* add to the cli

* fix warn issue

* on initialise, remove on runtime upgrade proposasl

* add the new storage version migration

* pick runtime

* new migration for proposals

* fmt

* fix v3-v4 migration test

* fix 2

* fix brief migration test

* clippy

* fmt

* new MilestoneVote implementation

* fix implementation

* get project individual votes

* remove total votes api

* fmt

* ummm

* new format for Individual votes

* boom baby, and a fmt

* clippy

* fix build

* fmt

* bump spec version

* 1

* individual votes impl with storage

* fix buggy impl

* define immutability, update on vote

* use individual votes for oninit and submit and close voting + update migration

* fixing build

* seperated test files, tested ImmutableVotes

* fix runtime api, reorg proposals

* fmt

* fmt

* clippy

* migration, err handling

* fix migration

* fmt

* fix

* clippy

* update executive and spec version

* fmt

* remove todos

* remove wrong comment

* fix failing test

* fmt

* run on gcp

* bump to rebuild

* use self hosted runner

* already installed on runner

* attempt auto scaling runner

* increase disk size

* bump to build again

* dont delete at the end of the job

* remove unused directories

* bump

* change region

* split the jobs

* add -y flag

* test menually installing rust

* -y flag

* more -y

* remove double install of protobugf

* -y

* trial 1

* fix

* fix2

* fix3

* bump up

* bump

* change zone

* bump

* lol -y

* bump

* bump 2

* set home directory

* try to run as user

* init commit

* commit 2

* test

* test 3

* attempt 4

* bump

* bump

* bump

* bump

* bump

* reduce image size

* bump

* bump

* bump again

* add clippy

* build essentials

* clang

* refactor

* typo

* typo 2

* make zone configurable

---------

Co-authored-by: samelamin <hussam.elamin@gmail.com>
(cherry picked from commit 84dd997)

# Conflicts:
#	Cargo.lock
#	pallets/proposals/src/lib.rs
@samelamin samelamin deleted the project-voting-data-api branch November 16, 2023 09:17
f-gate added a commit that referenced this pull request Nov 24, 2023
* add back sudo to rococo

* runtime api

* runtime-api-wiring

* some dummy log statements

* attempt 1 to add try-runtime

* second attempt

* add to the cli

* fix warn issue

* on initialise, remove on runtime upgrade proposasl

* add the new storage version migration

* pick runtime

* new migration for proposals

* fmt

* fix v3-v4 migration test

* fix 2

* fix brief migration test

* clippy

* fmt

* new MilestoneVote implementation

* fix implementation

* get project individual votes

* remove total votes api

* fmt

* ummm

* new format for Individual votes

* boom baby, and a fmt

* clippy

* fix build

* fmt

* bump spec version

* 1

* individual votes impl with storage

* fix buggy impl

* define immutability, update on vote

* use individual votes for oninit and submit and close voting + update migration

* fixing build

* seperated test files, tested ImmutableVotes

* fix runtime api, reorg proposals

* fmt

* fmt

* clippy

* migration, err handling

* fix migration

* fmt

* fix

* clippy

* update executive and spec version

* fmt

* remove todos

* remove wrong comment

* fix failing test

* fmt

* rip the proposals changes

* merge and fix tests

* remove unused config items, reorg them, add test cases

* actually add decent documentation in pallet-proposals

* run on gcp

* bump to rebuild

* use self hosted runner

* already installed on runner

* attempt auto scaling runner

* increase disk size

* bump to build again

* dont delete at the end of the job

* remove unused directories

* bump

* change region

* split the jobs

* add -y flag

* test menually installing rust

* -y flag

* more -y

* remove double install of protobugf

* -y

* trial 1

* fix

* fix2

* fix3

* bump up

* bump

* change zone

* bump

* lol -y

* bump

* bump 2

* set home directory

* try to run as user

* init commit

* commit 2

* test

* test 3

* attempt 4

* bump

* bump

* bump

* bump

* bump

* reduce image size

* bump

* bump

* bump again

* add clippy

* build essentials

* lock

* clang

* refactor

* typo

* typo 2

* make zone configurable

* project voting data api (#224)

* add back sudo to rococo

* runtime api

* runtime-api-wiring

* some dummy log statements

* attempt 1 to add try-runtime

* second attempt

* add to the cli

* fix warn issue

* on initialise, remove on runtime upgrade proposasl

* add the new storage version migration

* pick runtime

* new migration for proposals

* fmt

* fix v3-v4 migration test

* fix 2

* fix brief migration test

* clippy

* fmt

* new MilestoneVote implementation

* fix implementation

* get project individual votes

* remove total votes api

* fmt

* ummm

* new format for Individual votes

* boom baby, and a fmt

* clippy

* fix build

* fmt

* bump spec version

* 1

* individual votes impl with storage

* fix buggy impl

* define immutability, update on vote

* use individual votes for oninit and submit and close voting + update migration

* fixing build

* seperated test files, tested ImmutableVotes

* fix runtime api, reorg proposals

* fmt

* fmt

* clippy

* migration, err handling

* fix migration

* fmt

* fix

* clippy

* update executive and spec version

* fmt

* remove todos

* remove wrong comment

* fix failing test

* fmt

* run on gcp

* bump to rebuild

* use self hosted runner

* already installed on runner

* attempt auto scaling runner

* increase disk size

* bump to build again

* dont delete at the end of the job

* remove unused directories

* bump

* change region

* split the jobs

* add -y flag

* test menually installing rust

* -y flag

* more -y

* remove double install of protobugf

* -y

* trial 1

* fix

* fix2

* fix3

* bump up

* bump

* change zone

* bump

* lol -y

* bump

* bump 2

* set home directory

* try to run as user

* init commit

* commit 2

* test

* test 3

* attempt 4

* bump

* bump

* bump

* bump

* bump

* reduce image size

* bump

* bump

* bump again

* add clippy

* build essentials

* clang

* refactor

* typo

* typo 2

* make zone configurable

---------

Co-authored-by: samelamin <hussam.elamin@gmail.com>

* refactoring

* mark the no_confidence as deprecated with the introduction of pallet-disputes

* migration for new fields

* add to runtime with dummy weights

* add genesis config

* removed everything about no-confidence logic

* fixed the format check as it was failing in the build

* add fellowship migration, add migration to runtime

* move migration to v7 after rococo upgrade

* fix migration

* fix accountid trait bounds

* fix dependancy issue: #252

* add fellowship to runtime benchmarks

* generate fellowship weights

* remove test test

* fmt

* add jury selector trait

* run gcp on all pushes

* restore

* select a random jury given a jury length

* fix randomer

* select jury tests

* refactor minor

* remove genesis, add permissions, FellowshipPermissions trait

* permissions impl, mock impl

* fix tests

* organise tests, add permissions tests

* add new config to runtime

* fmt

* add jury selector into migration

* dispute hooks draft, pallet-dispute in runtime

* raise disputes and hooks skeleton

* forgot

* trait bounds impl, todos

* bugs

* fix

* tests

* track dispute per milestone instead of per project

* minor fixes

* update withdrawn to use is_withdrawn

* fix

* fix

* more todos! Jury selector fix

* tests, refund extrinsic

* mindbending fix

* try_mutate_exists instead

* fixing just keep fixing

* another one

* marching

* my fingers hurt

* green stuff has appeared!

* grants fixes

* fixrs

* fix

* optimise refund extrinsics

* add non zero arith check, deposit event, refund benchmark

* fix

* raise dispute benchmark

* migration madness

* fix migration and tests

* jury selector move around

* fix bloomin proposals

* fix briefs

* fix grants

* fiix runtime

* fix integration test, rewrite get jury

* generate dispute weights

* fix all but deposits

* fix xcm tranfers

* trying

* fix grants benchmark tests

* fix for proposal benchmark tests

* cargo fmt

* fix for failing benchmark tests

* audit warnings

* minor fix

* remove generic param for run to block felloship

* clippy

* weights

* proposal benchmark fixes + weights

* change balance type proposals mock to u128 to prevent overflow

* fmt

---------

Co-authored-by: samelamin <hussam.elamin@gmail.com>
Co-authored-by: Shankar Rao Mata <mshankarrao1970@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants