This repository was archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Add Bridge Header Sync to Rococo Runtime #2983
Merged
20 commits merged into
paritytech:master
from
HCastano:hc-wococo-rococo-bridge-integration
May 13, 2021
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
f6682b8
Add bridges code to workspace
HCastano eed0d61
Add Rococo and Wococo bridge instances to Rococo runtime
HCastano 2c5e641
Add Rococo and Wococo runtime APIs
HCastano 060c9e2
Add GenesisConfig parameters for bridge pallet
HCastano 99a4c21
Update Rococo spec_version used by bridge relayer
HCastano 8d5c068
Add scripts for running Rococo and Wococo dev nodes
HCastano c52b752
Add scripts for running Rococo<>Wococo header sync
HCastano e969faf
Apply patch for build artifact location
HCastano fbbc6a5
Remove bridges crates from workspace
HCastano 7727420
Merge branch 'master' into hc-wococo-rococo-bridge-integration
HCastano 348a5f2
Downgrade async related dependencies
HCastano ff0fee4
Change bridge pallet owner to be `root_key`
HCastano 9cf8fbb
Bump number of `MaxRequests` allowed
HCastano 8a029c9
Revert changes in `bridges` subtree folder
HCastano f65482d
Merge branch 'master' into hc-wococo-rococo-bridge-integration
HCastano 5e30ceb
Use correct account for Sudo
HCastano 3b69d93
Add comment explaining duplicate bridge pallets
HCastano 1bcf77a
Merge branch 'master' into hc-wococo-rococo-bridge-integration
HCastano d998df1
Remove WeightInfo comment.
tomusdrw 92f2205
Merge branch 'master' into hc-wococo-rococo-bridge-integration
HCastano File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -236,6 +236,12 @@ construct_runtime! { | |
| Beefy: pallet_beefy::{Pallet, Config<T>, Storage}, | ||
| MmrLeaf: mmr_common::{Pallet, Storage}, | ||
|
|
||
| // It might seem strange that we add both sides of the bridge to the same runtime. We do this because this | ||
| // runtime as shared by both the Rococo and Wococo chains. When running as Rococo we only use | ||
| // `BridgeWococoGrandpa`, and vice versa. | ||
| BridgeRococoGrandpa: pallet_bridge_grandpa::{Pallet, Call, Storage, Config<T>} = 40, | ||
| BridgeWococoGrandpa: pallet_bridge_grandpa::<Instance1>::{Pallet, Call, Storage, Config<T>} = 41, | ||
|
Comment on lines
+242
to
+243
Contributor
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 think an explanatory comment would be nice here, cause we are adding |
||
|
|
||
| // Validator Manager pallet. | ||
| ValidatorManager: validator_manager::{Pallet, Call, Storage, Event<T>}, | ||
|
|
||
|
|
@@ -794,6 +800,38 @@ impl mmr_common::Config for Runtime { | |
| type ParachainHeads = Paras; | ||
| } | ||
|
|
||
| parameter_types! { | ||
| // This is a pretty unscientific cap. | ||
| // | ||
| // Note that once this is hit the pallet will essentially throttle incoming requests down to one | ||
| // call per block. | ||
| pub const MaxRequests: u32 = 4 * HOURS as u32; | ||
|
|
||
| // Number of headers to keep. | ||
| // | ||
| // Assuming the worst case of every header being finalized, we will keep headers at least for a | ||
| // week. | ||
| pub const HeadersToKeep: u32 = 7 * DAYS as u32; | ||
| } | ||
|
|
||
| pub type RococoGrandpaInstance = (); | ||
| impl pallet_bridge_grandpa::Config for Runtime { | ||
| type BridgedChain = bp_rococo::Rococo; | ||
| type MaxRequests = MaxRequests; | ||
| type HeadersToKeep = HeadersToKeep; | ||
|
|
||
| type WeightInfo = pallet_bridge_grandpa::weights::RialtoWeight<Runtime>; | ||
| } | ||
|
|
||
| pub type WococoGrandpaInstance = pallet_bridge_grandpa::Instance1; | ||
| impl pallet_bridge_grandpa::Config<WococoGrandpaInstance> for Runtime { | ||
| type BridgedChain = bp_wococo::Wococo; | ||
| type MaxRequests = MaxRequests; | ||
| type HeadersToKeep = HeadersToKeep; | ||
|
|
||
| type WeightInfo = pallet_bridge_grandpa::weights::RialtoWeight<Runtime>; | ||
| } | ||
|
|
||
| impl Randomness<Hash, BlockNumber> for ParentHashRandomness { | ||
| fn random(subject: &[u8]) -> (Hash, BlockNumber) { | ||
| ( | ||
|
|
@@ -1222,6 +1260,28 @@ sp_api::impl_runtime_apis! { | |
| } | ||
| } | ||
|
|
||
| impl bp_rococo::RococoFinalityApi<Block> for Runtime { | ||
| fn best_finalized() -> (bp_rococo::BlockNumber, bp_rococo::Hash) { | ||
| let header = BridgeRococoGrandpa::best_finalized(); | ||
| (header.number, header.hash()) | ||
| } | ||
|
|
||
| fn is_known_header(hash: bp_rococo::Hash) -> bool { | ||
| BridgeRococoGrandpa::is_known_header(hash) | ||
| } | ||
| } | ||
|
|
||
| impl bp_wococo::WococoFinalityApi<Block> for Runtime { | ||
| fn best_finalized() -> (bp_wococo::BlockNumber, bp_wococo::Hash) { | ||
| let header = BridgeWococoGrandpa::best_finalized(); | ||
| (header.number, header.hash()) | ||
| } | ||
|
|
||
| fn is_known_header(hash: bp_wococo::Hash) -> bool { | ||
| BridgeWococoGrandpa::is_known_header(hash) | ||
| } | ||
| } | ||
|
|
||
| impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce> for Runtime { | ||
| fn account_nonce(account: AccountId) -> Nonce { | ||
| System::account_nonce(account) | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.