-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Handling of disabled validators in backing subsystem #1259
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 15 commits
800d8e5
936216d
7165ef9
24b5df5
eaca5ed
e4dee17
23023c4
8db76f5
e2846b2
8604b69
78afa76
9e39e58
0d0129c
23fbb41
91d1a8d
3d7efab
e68fa6a
5e7655f
c6bca9c
6fb4b7f
70dc6b6
bca3c83
f717d0b
2a5af89
2c53894
26866fa
a3bcb2f
863fc7d
c44093d
1e561e9
cf671f4
8807981
55f8e01
b5609e1
617e477
d7f4315
718f04b
275ce02
f2b17f1
7872f8f
3c89059
15b5069
96c1358
1a6648a
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 |
|---|---|---|
|
|
@@ -383,6 +383,19 @@ struct TableContext { | |
| validator: Option<Validator>, | ||
| groups: HashMap<ParaId, Vec<ValidatorIndex>>, | ||
| validators: Vec<ValidatorId>, | ||
| disabled_validators: Vec<ValidatorIndex>, | ||
| } | ||
|
|
||
| impl TableContext { | ||
| pub fn validator_is_disabled(&self, validator_idx: &ValidatorIndex) -> bool { | ||
| self.disabled_validators | ||
| .iter() | ||
| .any(|disabled_val_idx| *disabled_val_idx == *validator_idx) | ||
| } | ||
|
|
||
| pub fn local_validator_is_disabled(&self) -> Option<bool> { | ||
|
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. Why do we need to return Option ? 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 decided to return an |
||
| self.validator.as_ref().map(|v| v.disabled()) | ||
| } | ||
| } | ||
|
|
||
| impl TableContextTrait for TableContext { | ||
|
|
@@ -992,14 +1005,18 @@ async fn construct_per_relay_parent_state<Context>( | |
|
|
||
| let parent = relay_parent; | ||
|
|
||
| let (session_index, validators, groups, cores) = futures::try_join!( | ||
| let (session_index, validators, groups, cores, disabled_validators) = futures::try_join!( | ||
| request_session_index_for_child(parent, ctx.sender()).await, | ||
| request_validators(parent, ctx.sender()).await, | ||
| request_validator_groups(parent, ctx.sender()).await, | ||
| request_from_runtime(parent, ctx.sender(), |tx| { | ||
| RuntimeApiRequest::AvailabilityCores(tx) | ||
| },) | ||
| .await, | ||
| request_from_runtime(parent, ctx.sender(), |tx| { | ||
tdimitrov marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| RuntimeApiRequest::DisabledValidators(tx) | ||
| },) | ||
| .await, | ||
| ) | ||
| .map_err(Error::JoinMultiple)?; | ||
|
|
||
|
|
@@ -1009,22 +1026,27 @@ async fn construct_per_relay_parent_state<Context>( | |
| let cores = try_runtime_api!(cores); | ||
| let minimum_backing_votes = | ||
| try_runtime_api!(request_min_backing_votes(parent, session_index, ctx.sender()).await); | ||
| let disabled_validators = try_runtime_api!(disabled_validators); | ||
|
|
||
| let signing_context = SigningContext { parent_hash: parent, session_index }; | ||
| let validator = | ||
| match Validator::construct(&validators, signing_context.clone(), keystore.clone()) { | ||
| Ok(v) => Some(v), | ||
| Err(util::Error::NotAValidator) => None, | ||
| Err(e) => { | ||
| gum::warn!( | ||
| target: LOG_TARGET, | ||
| err = ?e, | ||
| "Cannot participate in candidate backing", | ||
| ); | ||
| let validator = match Validator::construct( | ||
| &validators, | ||
| &disabled_validators, | ||
| signing_context.clone(), | ||
| keystore.clone(), | ||
| ) { | ||
| Ok(v) => Some(v), | ||
| Err(util::Error::NotAValidator) => None, | ||
| Err(e) => { | ||
| gum::warn!( | ||
| target: LOG_TARGET, | ||
| err = ?e, | ||
| "Cannot participate in candidate backing", | ||
| ); | ||
|
|
||
| return Ok(None) | ||
| }, | ||
| }; | ||
| return Ok(None) | ||
| }, | ||
| }; | ||
|
|
||
| let mut groups = HashMap::new(); | ||
| let n_cores = cores.len(); | ||
|
|
@@ -1054,7 +1076,7 @@ async fn construct_per_relay_parent_state<Context>( | |
| } | ||
| } | ||
|
|
||
| let table_context = TableContext { groups, validators, validator }; | ||
| let table_context = TableContext { validator, groups, validators, disabled_validators }; | ||
| let table_config = TableConfig { | ||
| allow_multiple_seconded: match mode { | ||
| ProspectiveParachainsMode::Enabled { .. } => true, | ||
|
|
@@ -1564,7 +1586,17 @@ async fn import_statement<Context>( | |
|
|
||
| let stmt = primitive_statement_to_table(statement); | ||
|
|
||
| Ok(rp_state.table.import_statement(&rp_state.table_context, stmt)) | ||
| // Don't import statement if the sender is disabled | ||
| if rp_state.table_context.validator_is_disabled(&stmt.sender) { | ||
| gum::debug!( | ||
| target: LOG_TARGET, | ||
| sender_validator_idx = ?stmt.sender, | ||
| "Not importing statement because the sender is disabled" | ||
| ); | ||
| return Ok(None) | ||
tdimitrov marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } else { | ||
| Ok(rp_state.table.import_statement(&rp_state.table_context, stmt)) | ||
| } | ||
| } | ||
|
|
||
| /// Handles a summary received from [`import_statement`] and dispatches `Backed` notifications and | ||
|
|
@@ -1958,6 +1990,13 @@ async fn handle_second_message<Context>( | |
| return Ok(()) | ||
| } | ||
|
|
||
| // Just return if the local validator is disabled. If we are here the local node should be a | ||
| // validator but defensively use `unwrap_or(false)`) to continue processing in this case. | ||
| if rp_state.table_context.local_validator_is_disabled().unwrap_or(false) { | ||
| gum::warn!(target: LOG_TARGET, "Local validator is disabled. Don't validate and second"); | ||
| return Ok(()) | ||
| } | ||
|
|
||
| // If the message is a `CandidateBackingMessage::Second`, sign and dispatch a | ||
| // Seconded statement only if we have not signed a Valid statement for the requested candidate. | ||
| // | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.