-
Notifications
You must be signed in to change notification settings - Fork 0
Chain fault testing framework + Enable auto-rejoin #51
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
Changes from all commits
577c680
ab2b568
15e4bbc
b8a1b8c
d8c8e60
f69ec7a
71e4a97
e56632e
3e64c07
4d7dd91
fd6095d
b616721
5c90512
10cdce7
50083cc
6907125
5db192a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1269,4 +1269,75 @@ impl Actions { | |
| } | ||
| Ok(()) | ||
| } | ||
|
|
||
| // shortcut function to update all complaint configs to the same interval and tolerance for testing | ||
| pub async fn update_all_complaint_configs( | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Which testing scenario is this used for?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I used it for the auto-rejoin test ( not part of this PR ). Also used in the upgrade tests ( also not part of this PR! ). It's basically a shortcut to make tests work faster ;-) |
||
| &self, | ||
| interval_secs: Option<u64>, | ||
| tolerance: Option<u64>, | ||
| kick_penalty_percent: Option<u64>, | ||
| kick_penalty_demerits: Option<u64>, | ||
| ) -> Result<()> { | ||
| info!( | ||
| "Updating all complaint reason configs interval_secs to {:?} and tolerance to {:?}", | ||
| interval_secs, tolerance | ||
| ); | ||
|
|
||
| let interval_secs = if interval_secs.is_some() { | ||
| Some(U256::from(interval_secs.unwrap())) | ||
| } else { | ||
| None | ||
| }; | ||
| let tolerance = if tolerance.is_some() { | ||
| Some(U256::from(tolerance.unwrap())) | ||
| } else { | ||
| None | ||
| }; | ||
| let kick_penalty_percent = if kick_penalty_percent.is_some() { | ||
| Some(U256::from(kick_penalty_percent.unwrap())) | ||
| } else { | ||
| None | ||
| }; | ||
| let kick_penalty_demerits = if kick_penalty_demerits.is_some() { | ||
| Some(U256::from(kick_penalty_demerits.unwrap())) | ||
| } else { | ||
| None | ||
| }; | ||
| for i in 0..=MAX_COMPLAINT_REASON_VALUE { | ||
| let reason = U256::from(i); | ||
| // First, get current chain config for this reason. | ||
| let current_config: lit_blockchain::contracts::staking::ComplaintConfig = self | ||
| .contracts | ||
| .staking | ||
| .complaint_config(reason) | ||
| .call() | ||
| .await | ||
| .map_err(|e| anyhow::anyhow!("unable to get complaint config: {:?}", e))?; | ||
|
|
||
| // Then, set the config with any new values. | ||
| let cc = self.contracts.staking.set_complaint_config( | ||
| reason, | ||
| lit_blockchain::contracts::staking::ComplaintConfig { | ||
| tolerance: tolerance.unwrap_or(current_config.tolerance), | ||
| interval_secs: interval_secs.unwrap_or(current_config.interval_secs), | ||
| kick_penalty_percent: kick_penalty_percent | ||
| .unwrap_or(current_config.kick_penalty_percent), | ||
| kick_penalty_demerits: kick_penalty_demerits | ||
| .unwrap_or(current_config.kick_penalty_demerits), | ||
| }, | ||
| ); | ||
| if !Contracts::process_contract_call( | ||
| cc, | ||
| format!("updating staking complaint config for reason {:?}", reason).as_str(), | ||
| ) | ||
| .await | ||
| { | ||
| return Err(anyhow::anyhow!( | ||
| "Error updating complaint config for reason {:?}", | ||
| reason.as_u64() | ||
| )); | ||
| } | ||
| } | ||
| Ok(()) | ||
| } | ||
| } | ||
GTC6244 marked this conversation as resolved.
Show resolved
Hide resolved
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| pub const GIT_COMMIT_HASH: &str = "b04446f9037be567924971aad3cb78a1f17b7414"; | ||
| pub const GIT_COMMIT_HASH: &str = "50083ccf8061c4bfe17761be8b496bdab82851a6"; |
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.
Is this the only place we need to update the provider?
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.
Yup - code is nicely centralized. ;-)