Skip to content

Conversation

@dharapandya85
Copy link

@dharapandya85 dharapandya85 commented Sep 1, 2025

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
Copy link

vercel bot commented Sep 1, 2025

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
Contributor

@dharapandya85 link to issue being addressed

Copy link
Contributor

@Akshola00 Akshola00 left a 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

Copy link
Contributor

@Akshola00 Akshola00 left a 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

ValidatorPerformanceUpdated:ValidatorPerformanceUpdated,
}

#[derive(Drop,starknet::Event)]
Copy link
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

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


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

}
}

// -----------------------------------------
Copy link
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

Copy link
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

Copy link
Contributor

@Akshola00 Akshola00 left a 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

Copy link
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

}
#[test]
fn test_slash_validator_halves_rep_and_treasury(){
let (_contract_address, mut state)= deploy_contract("src/predifi.cairo");
Copy link
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

Copy link
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
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


/// @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
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 ?

/// @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
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
Contributor

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

@Akshola00
Copy link
Contributor

@dharapandya85 any updates on this

@Akshola00
Copy link
Contributor

@dharapandya85 build is failing

@vercel
Copy link

vercel bot commented Oct 3, 2025

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

Incomplete Validator Incentive System

2 participants