-
Notifications
You must be signed in to change notification settings - Fork 62
feat(validator): Implement validator reputation system #230
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
base: main
Are you sure you want to change the base?
feat(validator): Implement validator reputation system #230
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
@dharapandya85 link to issue being addressed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
write thorough tests for these functions you have included, also add thier interfaces
make sure to also perform neccessary validations, create getter functions for the frontend and follow the standard ie: natspec commments where neccessary and modularized error and events
if you are stuck or have any questiosn reach out to me @Akshola00 on telegram
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better variable naming would be appreciated also
src/predifi.cairo
Outdated
| ValidatorPerformanceUpdated:ValidatorPerformanceUpdated, | ||
| } | ||
|
|
||
| #[derive(Drop,starknet::Event)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is an event file for these
src/predifi.cairo
Outdated
| /// @notice Slash a validator by reducing reputation and treasury. | ||
| /// @param validator Validator address to slash. | ||
| /// @param amount Amount to slash. | ||
| fn slash_validator(ref self:ContractState,validator:ContractAddress,amount:u256){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
slash shoulnt take in any amount, it should be halved ie /2
src/predifi.cairo
Outdated
|
|
||
| /// @notice Distribute validator fees among validators based on reputation. | ||
| /// @param pool_id ID fo the pool to distribute fees for. | ||
| fn distribute_validator_fees(ref self:ContractState,pool_id:u256){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this validator fee is to be distributed to only the validators of that pool that chose the correct option, not all validators
perform neccessary assert statements here, assert the pool has ended assert that the pool has been resolved and assert that the fees are shared to only the validators that chose the correct option, not all validators and not all validators of a pool
src/predifi.cairo
Outdated
| } | ||
| } | ||
|
|
||
| // ----------------------------------------- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this comment is not neccessary, pls remove
tests/test_predifi.cairo
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wirte tests in the test validator use already existing setup and follow the standard there
we are using foundry to test not cfg tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ci is still failaing, meaning build and test are still failing
run make pr before you push to always see weather everything needed for the ci is passing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great all events are here now, easier to modify later and structured
tests/test_validators.cairo
Outdated
| } | ||
| #[test] | ||
| fn test_slash_validator_halves_rep_and_treasury(){ | ||
| let (_contract_address, mut state)= deploy_contract("src/predifi.cairo"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this work deploy_contract("src/predifi.cairo"); ?
this doesnt work
tests/test_predifi.cairo
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all tests youre writting should be in the test validators, and youre required to use the existing test setup to make your tests modular
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also add edge case testing
src/predifi.cairo
Outdated
|
|
||
| /// @notice Slash a validator by halving reputation and treasury. | ||
| /// @param validator Validator address to slash. | ||
| fn slash_validator(ref self:Storage,validator:ContractAddress){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are you referencing storage here instead of contract state here ?
src/predifi.cairo
Outdated
| /// @notice Update validator performance and adjust reputation. | ||
| /// @param validator Address of the validator. | ||
| /// @param success True if validation was correct, false otherwise. | ||
| fn update_performance(ref self:ContractState,validator:ContractAddress,success:bool){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is better now
|
@dharapandya85 reach out to me on tg @Akshola00 if you have an issues here |
|
@dharapandya85 any updates on this |
…dharapandya85/predifi into feat/validator-incentive-system
|
@dharapandya85 build is failing |
|
@dharapandya85 is attempting to deploy a commit to the shola's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
Got it! Sorry for the mess. |

Fixes #223
Current Validator system lacks incentive system. This PR introduces a validator incentive system.
distribute_validate_feesfunction divides fees equally. Reputation score is tracked with validator reputation system. Success count is tracked for each validator.