Skip to content

feat(validator): Implement validator reputation system#230

Closed
dharapandya85 wants to merge 9 commits into
Web3Novalabs:mainfrom
dharapandya85:feat/validator-incentive-system
Closed

feat(validator): Implement validator reputation system#230
dharapandya85 wants to merge 9 commits into
Web3Novalabs:mainfrom
dharapandya85:feat/validator-incentive-system

Conversation

@dharapandya85

@dharapandya85 dharapandya85 commented Sep 1, 2025

Copy link
Copy Markdown

Fixes #223

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

@vercel

vercel Bot commented Sep 1, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
nova-one-7r2r Ready Ready Preview Comment Sep 22, 2025 10:20am

@Akshola00

Copy link
Copy Markdown
Contributor

@dharapandya85 link to issue being addressed

@Akshola00 Akshola00 left a comment

Copy link
Copy Markdown
Contributor

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

@Akshola00 Akshola00 left a comment

Copy link
Copy Markdown
Contributor

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

Comment thread src/predifi.cairo Outdated
ValidatorPerformanceUpdated:ValidatorPerformanceUpdated,
}

#[derive(Drop,starknet::Event)]

Copy link
Copy Markdown
Contributor

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

Comment thread 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){

Copy link
Copy Markdown
Contributor

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

Comment thread 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){

Copy link
Copy Markdown
Contributor

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

Comment thread src/predifi.cairo Outdated
}
}

// -----------------------------------------

Copy link
Copy Markdown
Contributor

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

Comment thread tests/test_predifi.cairo Outdated

Copy link
Copy Markdown
Contributor

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

@Akshola00 Akshola00 left a comment

Copy link
Copy Markdown
Contributor

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

Comment thread src/base/events.cairo

Copy link
Copy Markdown
Contributor

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

Comment thread tests/test_validators.cairo Outdated
}
#[test]
fn test_slash_validator_halves_rep_and_treasury(){
let (_contract_address, mut state)= deploy_contract("src/predifi.cairo");

Copy link
Copy Markdown
Contributor

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

Comment thread tests/test_predifi.cairo Outdated

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor

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

Comment thread 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){

Copy link
Copy Markdown
Contributor

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 ?

Comment thread 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){

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this is better now

@Akshola00

Copy link
Copy Markdown
Contributor

@dharapandya85 reach out to me on tg @Akshola00 if you have an issues here

@Akshola00

Copy link
Copy Markdown
Contributor

@dharapandya85 any updates on this

@Akshola00

Copy link
Copy Markdown
Contributor

@dharapandya85 build is failing

@vercel

vercel Bot commented Oct 3, 2025

Copy link
Copy Markdown

@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.

@Akshola00

Copy link
Copy Markdown
Contributor
Screenshot 2025-10-03 at 12 19 23 PM

@dharapandya85

pls format your code scarb fmt
before you push just go to youre terminal and run make pr
it will run all the necessary things you need for the ci to pass and if it fails you can fix it there before push

@dharapandya85

Copy link
Copy Markdown
Author

Got it! Sorry for the mess.

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.

3 participants