-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* placeholder todo for self-doc * implement Sidechain pallet storage handler and merge all pallets into itp-pallet-storage * make block confirmation work with pallet_sidechain SBliFF * taplo fmt * fix cargo test * bump sdk patch revision * bump node for CI * std enable in itp-types
- Loading branch information
Showing
25 changed files
with
223 additions
and
170 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 was deleted.
Oops, something went wrong.
This file contains 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 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 |
---|---|---|
@@ -0,0 +1,78 @@ | ||
#![cfg_attr(not(feature = "std"), no_std)] | ||
|
||
use codec::Encode; | ||
use itp_storage::{storage_map_key, StorageHasher}; | ||
use itp_types::{AccountId, ShardIdentifier}; | ||
use sp_std::prelude::Vec; | ||
|
||
// Separate the prefix from the rest because in our case we changed the storage prefix due to | ||
// the rebranding. With the below implementation of the `TeerexStorageKeys`, we could simply | ||
// define another struct `OtherStorage`, implement `StoragePrefix` for it, and get the | ||
// `TeerexStorageKeys` implementation for free. | ||
pub trait StoragePrefix { | ||
fn prefix() -> &'static str; | ||
} | ||
|
||
pub struct EnclaveBridgeStorage; | ||
|
||
impl StoragePrefix for EnclaveBridgeStorage { | ||
fn prefix() -> &'static str { | ||
"EnclaveBridge" | ||
} | ||
} | ||
|
||
pub trait EnclaveBridgeStorageKeys { | ||
fn shard_status<T: Encode>(shard: T) -> Vec<u8>; | ||
} | ||
|
||
impl<S: StoragePrefix> EnclaveBridgeStorageKeys for S { | ||
fn shard_status<T: Encode>(shard: T) -> Vec<u8> { | ||
storage_map_key(Self::prefix(), "ShardStatus", &shard, &StorageHasher::Blake2_128Concat) | ||
} | ||
} | ||
|
||
pub struct TeeRexStorage; | ||
|
||
impl StoragePrefix for TeeRexStorage { | ||
fn prefix() -> &'static str { | ||
"Teerex" | ||
} | ||
} | ||
|
||
pub trait TeerexStorageKeys { | ||
fn sovereign_enclaves(account: AccountId) -> Vec<u8>; | ||
} | ||
|
||
impl<S: StoragePrefix> TeerexStorageKeys for S { | ||
fn sovereign_enclaves(account: AccountId) -> Vec<u8> { | ||
storage_map_key( | ||
Self::prefix(), | ||
"SovereignEnclaves", | ||
&account, | ||
&StorageHasher::Blake2_128Concat, | ||
) | ||
} | ||
} | ||
|
||
pub struct SidechainPalletStorage; | ||
|
||
impl StoragePrefix for SidechainPalletStorage { | ||
fn prefix() -> &'static str { | ||
"Sidechain" | ||
} | ||
} | ||
|
||
pub trait SidechainPalletStorageKeys { | ||
fn latest_sidechain_block_confirmation(shard: ShardIdentifier) -> Vec<u8>; | ||
} | ||
|
||
impl<S: StoragePrefix> SidechainPalletStorageKeys for S { | ||
fn latest_sidechain_block_confirmation(shard: ShardIdentifier) -> Vec<u8> { | ||
storage_map_key( | ||
Self::prefix(), | ||
"LatestSidechainBlockConfirmation", | ||
&shard, | ||
&StorageHasher::Blake2_128Concat, | ||
) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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 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 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
Oops, something went wrong.