-
Notifications
You must be signed in to change notification settings - Fork 957
added check for fee recipient per validator and added unit tests #8454
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: unstable
Are you sure you want to change the base?
added check for fee recipient per validator and added unit tests #8454
Conversation
|
|
eserilev
left a comment
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.
Thanks for this! The added tests are very much appreciated. I think we can make some slight tweaks here to improve the UX a bit.
|
|
||
| // If nothing set | ||
| Err(format!( | ||
| "Validator {} is missing `suggested_fee_recipient`!\n\n\ |
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.
Can we update the error message to
Validator {} is missing a `suggested_fee_recipient`. Fix this by adding a `suggested_fee_recipient` in your `validator_definitions.yml` or by supplying a fallback fee recipient via the `--suggested-fee-recipient` flag.
We usually avoid \n. We can use \ to continue the string literal across multiple lines
| }) | ||
| } | ||
|
|
||
| pub fn check_fee_recipient(&self, global_fee_recipient: Option<Address>) -> Result<(), String> { |
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.
I think for better UX, we should iterate across all fee recipients, build a list of ones missing fee recipients and then log an error to the user. This way they can see the full list of missing fee recipients all at once.
| "Global --suggested-fee-recipient is being used for {} validator(s). \ | ||
| Consider setting it in validator_definitions.yml for each one.", |
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.
| "Global --suggested-fee-recipient is being used for {} validator(s). \ | |
| Consider setting it in validator_definitions.yml for each one.", | |
| "The fallback --suggested-fee-recipient is being used for {} validator(s). \ | |
| Consider setting the fee recipient for each validator individually via `validator_definitions.yml`.", |
| .filter(|d| d.enabled && d.suggested_fee_recipient.is_none()) | ||
| .count(); | ||
| if missing > 0 { | ||
| tracing::warn!( |
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.
| tracing::warn!( | |
| tracing::info!( |
…d modified code comment
Hello @eserilev. Much thanks for the review and the kind words. 🙏 I thought to explain the changes I made with this last push. The I also modified existing tests to work with the new |
|
This pull request has merge conflicts. Could you please resolve them @AbolareRoheemah? 🙏 |
…ke-fee-receipient-mandatory
eserilev
left a comment
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.
LGTM!
|
Some required checks have failed. Could you please take a look @AbolareRoheemah? 🙏 |
|
Hi @AbolareRoheemah can you please run |
chong-he
left a comment
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.
Looks pretty good to me. I have also tested manually and confirm that it's working.
Some comments below.
| }; | ||
|
|
||
| // Should return None since global fee recipient is set | ||
| let global_fee = Some(Address::from_str("0xa2e334e71511686bcfe38bb3ee1ad8f6babcc03d").unwrap()); |
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 just a nit for better clarity
| let global_fee = Some(Address::from_str("0xa2e334e71511686bcfe38bb3ee1ad8f6babcc03d").unwrap()); | |
| let global_fee_recipient = Some(Address::from_str("0xa2e334e71511686bcfe38bb3ee1ad8f6babcc03d").unwrap()); |
| let check_result = def.check_fee_recipient(global_fee); | ||
| assert!(check_result.is_none()); |
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.
For succinctness, we can combine this with the test fee_recipient_check_fails_when_missing() to avoid repeatedly defining the same fields. We can revise the test name a bit, then add the checks in the same tests
Edit: I believe we can even go "all out" for succinctness, to define a general ValidatorDefinitions, then for each test, update the necessary fields for each test purpose, and add an assert right below, i.e., instead of having multiple tests, we can have just 1 or 2 test functions, move the test name (and revise a bit) and put it as a comment right above and before the assert. This will be cleaner as well
|
|
||
| return Err(format!( | ||
| "The following validators are missing a `suggested_fee_recipient`: {}. \ | ||
| Fix this by adding a `suggested_fee_recipient` in your \ |
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.
I feel that the validator_definitions.yml reads better here, but feel free to take it or leave it
| Fix this by adding a `suggested_fee_recipient` in your \ | |
| Fix this by adding a `suggested_fee_recipient` in the \ |
| if count > 0 { | ||
| info!( | ||
| "The fallback --suggested-fee-recipient is being used for {} validator(s). \ | ||
| Consider setting the fee recipient for each validator individually via `validator_definitions.yml`.", |
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 about "reducing the severity" of the log, because if users only use the suggested-fee-recipient flag, this log will appear every time a VC starts, so it could be a bit of a warn thingy.
This is a my two cent, keep to hear from the author and other developers about this. (e.g., maybe even shift to debug log)?
| Consider setting the fee recipient for each validator individually via `validator_definitions.yml`.", | |
| You may alternatively set the fee recipient for each validator individually via `validator_definitions.yml`.", |
Issue Addressed
Addresses #5403
Proposed Changes
check_fee_recipient()method to validate individual validatorscheck_all_fee_recipients()to validate all validators on startupAdditional Info
The images show attempts to run the VC: 1. without fee-recipient set for a validator and no global flag 2. Only global flag used. No individual fee-recipient set

