-
Notifications
You must be signed in to change notification settings - Fork 371
Reject blocks without justification which don't have the best number #105
Conversation
Forked at: 8f02e23 Parent branch: origin/master
This reverts commit ee60e12.
network/src/lib.rs
Outdated
| header: &B::Header, | ||
| mut data: &[u8], | ||
| ) -> Result<Validation, Box<dyn std::error::Error + Send>> { | ||
| // If no data is provided the announce is valid. |
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.
Comment needs updating
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.
fixed but the whole code changed
network/src/lib.rs
Outdated
| let best_number = self.parachain_client.info().best_number; | ||
| let block_number: <<B as BlockT>::Header as HeaderT>::Number = *header.number(); | ||
|
|
||
| if !(block_number == best_number + One::one() || block_number == best_number) { |
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.
Okay, I thought again about this. And I made a mistake.
We should extract the last parachain header that was stored on the relay chain. We get the number of this Parachain header an make sure that:
block_number == parachain_header_number + 1
This way we make sure that we support forks on the same height
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.
If this condition holds, we need to make sure that there is a justification.
network/src/lib.rs
Outdated
| use std::{marker::PhantomData, sync::Arc}; | ||
| use parking_lot::Mutex; | ||
|
|
||
| /// The head data of the parachain, stored in the relay chain. |
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.
Please move that into primitives and consolidate with the one in collator
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.
done
network/src/lib.rs
Outdated
| if data.is_empty() { | ||
| // Check if block is one higher than best | ||
| let runtime_api_block_id = BlockId::Hash(polkadot_info.best_hash); | ||
| let block_number: <<B as BlockT>::Header as HeaderT>::Number = *header.number(); |
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.
| let block_number: <<B as BlockT>::Header as HeaderT>::Number = *header.number(); | |
| let block_number = header.number().clone(); |
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.
done
network/src/lib.rs
Outdated
| .map_err(|e| Box::new(ClientError::Msg(format!("{:?}", e))) as Box<_>)?; | ||
| let known_best_number = *parent_head.header.number(); | ||
|
|
||
| if !(block_number < known_best_number) { |
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.
| if !(block_number < known_best_number) { | |
| let res = if block_number >= known_best_number { |
Negations always makes stuff much more complicated.
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.
done
network/src/lib.rs
Outdated
| let polkadot_info = self.polkadot_client.info(); | ||
|
|
||
| if data.is_empty() { | ||
| // Check if block is one higher than best |
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.
You need a justification if this is a new best block.
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.
like this? 2f9131c
network/src/lib.rs
Outdated
| return Ok(Validation::Failure); | ||
| } | ||
|
|
||
| return Ok(Validation::Success); |
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.
| return Ok(Validation::Failure); | |
| } | |
| return Ok(Validation::Success); | |
| Validation::Failure | |
| } else { | |
| Validation::Success | |
| }; | |
| return Ok(res); |
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.
eww no, the rest of the function follows the pattern:
if <condition> {
return ... // short-circuit
}
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.
Yeah, but here a else makes sense.
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.
done
Co-authored-by: Bastian Köcher <[email protected]>
Co-authored-by: Bastian Köcher <[email protected]>
aeb7216 to
2f9131c
Compare
Co-authored-by: Bastian Köcher <[email protected]>
Co-authored-by: Bastian Köcher <[email protected]>
Co-authored-by: Bastian Köcher <[email protected]>
Co-authored-by: Bastian Köcher <[email protected]>
commit 1eec2cad1f92dece71a8813de18f3adaa3a3307f Author: Albrecht <[email protected]> Date: Wed May 27 09:45:54 2020 +0200 kilt runtime in cumulus commit 05a83e8 Author: Bastian Köcher <[email protected]> Date: Fri Jun 19 13:15:56 2020 +0200 Take storage root from parent header (paritytech#123) commit 62c22b8 Author: Bastian Köcher <[email protected]> Date: Thu Jun 18 12:10:20 2020 +0200 Implement basic upward & downward messages (paritytech#118) * Start by replacing branch names and set `DownwardMessage` * Add the upward-message crate * Add Kusama & Polkadot * More work on getting the upward messages working * Fix build * Begin to integrate it into the test Parachain * Update * Make everything compile again * Switch to westend and print parachain account on startup * Use MultiSignature etc * Fix validate block * Some downward messages work * Update git reference * More downward messages integration * Update test runtime for downward messages * Enable downward message handler and withdraw send tokens * Add some docs * Begin to implement simple XCMP * More work * Fixes and make parachain id configurable * Make parachain ID be part of the genesis * Finishing the XCMP message demo * Update and fixes tests * Update branch commit b082e7f Author: Joshy Orndorff <[email protected]> Date: Thu Jun 18 03:54:47 2020 -0400 Allow custom polkadot chainspec. (paritytech#122) commit 8b1fd65 Author: Cecile Tonglet <[email protected]> Date: Mon Jun 15 12:40:15 2020 +0200 Update polkadot & substrate (paritytech#112) commit 41376ce Author: Cecile Tonglet <[email protected]> Date: Thu Jun 11 12:39:20 2020 +0200 Prefix logs of parachain and relaychain differently + remove light client of relay chain (paritytech#109) commit b3603d1 Author: Bastian Köcher <[email protected]> Date: Fri Jun 5 16:57:02 2020 +0200 Update to latest Substrate & Polkadot (paritytech#107) * Update to latest Substrate & Polkadot * Replace --unsafe-rpc-export with --unsafe-rpc-external * Add --rpc-methods=Unsafe Documented in substrate 24486f52929e9e518eeccbc6ad6da70e9e5bdf8a * typos * more typo * fixed rpc expose * Disable the integration test Co-authored-by: Cecile Tonglet <[email protected]> commit 4c6b959 Author: Cecile Tonglet <[email protected]> Date: Wed Jun 3 17:51:49 2020 +0200 Enable mdns polkadot (paritytech#106) Fixes paritytech#57 commit 1afdba7 Author: Cecile Tonglet <[email protected]> Date: Wed Jun 3 14:15:52 2020 +0200 Reject blocks without justification which don't have the best number (paritytech#105) * Initial commit Forked at: 8f02e23 Parent branch: origin/master * Reject blocks without justification * Revert "Reject blocks without justification" This reverts commit ee60e12. * WIP Forked at: 8f02e23 Parent branch: origin/master * WIP Forked at: 8f02e23 Parent branch: origin/master * WIP Forked at: 8f02e23 Parent branch: origin/master * CLEANUP Forked at: 8f02e23 Parent branch: origin/master * WIP Forked at: 8f02e23 Parent branch: origin/master * WIP Forked at: 8f02e23 Parent branch: origin/master * CLEANUP Forked at: 8f02e23 Parent branch: origin/master * WIP Forked at: 8f02e23 Parent branch: origin/master * WIP Forked at: 8f02e23 Parent branch: origin/master * Move HeadData to primitives * Update network/src/lib.rs Co-authored-by: Bastian Köcher <[email protected]> * Update network/src/lib.rs Co-authored-by: Bastian Köcher <[email protected]> * CLEANUP Forked at: 8f02e23 Parent branch: origin/master * fix * CLEANUP Forked at: 8f02e23 Parent branch: origin/master * messages * for the greater good * Update primitives/src/lib.rs Co-authored-by: Bastian Köcher <[email protected]> * Update network/src/lib.rs Co-authored-by: Bastian Köcher <[email protected]> * Update network/src/lib.rs Co-authored-by: Bastian Köcher <[email protected]> * Update network/src/lib.rs Co-authored-by: Bastian Köcher <[email protected]> Co-authored-by: Bastian Köcher <[email protected]> commit 8f02e23 Author: Cecile Tonglet <[email protected]> Date: Wed May 27 14:43:45 2020 +0200 Ensure relay chain parent is the relay chain head (paritytech#103)
* bump encointer-pallets * benchmark encointer pallets * update weight of purge_community_ceremony Co-authored-by: Christian Langenbacher <[email protected]>
Related to #7