Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
54a23a5
Refactor pallet-dip-provider
ntn-x2 Jul 11, 2023
25b3cb6
Remove unused dependencies from pallet-dip-provider
ntn-x2 Jul 11, 2023
c7ef216
mIntroduce state proofs in pallet-dip-consumer
ntn-x2 Jul 11, 2023
06de832
Temporarly fix kilt-dip-support to compile
ntn-x2 Jul 11, 2023
dda48d6
Whole project compiling
ntn-x2 Jul 11, 2023
cfe1fb3
Add parachain root state proof verifier
ntn-x2 Jul 12, 2023
77b2a48
Proof of storage entry for parachain also working
ntn-x2 Jul 12, 2023
4fd3f06
Half-way
ntn-x2 Jul 12, 2023
a9ca939
Before replacing 'read_proof_check'
ntn-x2 Jul 13, 2023
81ea88c
Ported the proof verification for no_std
ntn-x2 Jul 13, 2023
e8919f1
Refactoring on the way
ntn-x2 Jul 13, 2023
8808f14
New overarching verifier
ntn-x2 Jul 13, 2023
16b1bc9
Whole workspace compiling (not run/tested yet)
ntn-x2 Jul 13, 2023
47481e0
Keep track of the last 2 relay state roots to allow for proof creation
ntn-x2 Jul 14, 2023
50edc7b
Compiles
ntn-x2 Jul 17, 2023
f542428
Use relay block height instead of block hash
ntn-x2 Jul 18, 2023
318d765
Cleaning before kilt-dip-support
ntn-x2 Jul 20, 2023
7b67a57
On the way there
ntn-x2 Jul 20, 2023
d7dda64
Step n.2
ntn-x2 Jul 20, 2023
6b94cbf
all good
ntn-x2 Jul 21, 2023
622c046
Everything compiling
ntn-x2 Jul 21, 2023
2718f95
Still working
ntn-x2 Jul 21, 2023
f00cf33
Refactor complete
ntn-x2 Jul 21, 2023
f91693d
Pallet updated
ntn-x2 Jul 21, 2023
d81ac18
Renaming
ntn-x2 Jul 21, 2023
22b577c
Change SignedExtra to not be Optional
ntn-x2 Jul 21, 2023
358c095
clippy
ntn-x2 Jul 21, 2023
6020f80
Remove unnecessary derive
ntn-x2 Jul 21, 2023
408f5b9
Remove XCM from templates
ntn-x2 Jul 21, 2023
4dfc7a3
Remove unwanted file
ntn-x2 Jul 21, 2023
ff68537
Merge branch 'aa/dip' into aa/state-proofs
ntn-x2 Aug 10, 2023
9cbbd54
feat: add support for relay chain (#553)
ntn-x2 Aug 23, 2023
9d36356
feat: add relaychain support (#563)
ntn-x2 Sep 20, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Cleaning before kilt-dip-support
  • Loading branch information
ntn-x2 committed Jul 21, 2023
commit 318d7650635ff2fd149bb5385c9b84f797715e3f
12 changes: 0 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ parachain-staking = {path = "pallets/parachain-staking", default-features = fals
public-credentials = {path = "pallets/public-credentials", default-features = false}

# Internal support (with default disabled)
dip-support = {path = "crates/dip-support", default-features = false}
kilt-asset-dids = {path = "crates/assets", default-features = false}
kilt-dip-support = {path = "crates/kilt-dip-support", default-features = false}
kilt-support = {path = "support", default-features = false}
Expand Down
27 changes: 0 additions & 27 deletions crates/dip-support/Cargo.toml

This file was deleted.

31 changes: 0 additions & 31 deletions crates/dip-support/src/lib.rs

This file was deleted.

2 changes: 0 additions & 2 deletions crates/kilt-dip-support/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ hash-db.workspace = true

# Internal dependencies
did.workspace = true
dip-support.workspace = true
pallet-dip-consumer.workspace = true
pallet-dip-provider.workspace = true
pallet-relay-store.workspace = true
Expand Down Expand Up @@ -52,7 +51,6 @@ default = ["std"]
std = [
"hash-db/std",
"did/std",
"dip-support/std",
"pallet-dip-consumer/std",
"pallet-dip-provider/std",
"pallet-relay-store/std",
Expand Down
2 changes: 0 additions & 2 deletions dip-template/runtimes/dip-consumer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ scale-info = {workspace = true, features = ["derive"]}

# DIP
dip-provider-runtime-template.workspace = true
dip-support.workspace = true
did.workspace = true
kilt-dip-support.workspace = true
pallet-did-lookup.workspace = true
Expand Down Expand Up @@ -80,7 +79,6 @@ std = [
"parity-scale-codec/std",
"scale-info/std",
"dip-provider-runtime-template/std",
"dip-support/std",
"did/std",
"kilt-dip-support/std",
"pallet-did-lookup/std",
Expand Down
2 changes: 1 addition & 1 deletion dip-template/runtimes/dip-consumer/src/dip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,5 +177,5 @@ mod dip_call_origin_filter_tests {
}

impl pallet_relay_store::Config for Runtime {
type MaxBlocks = ConstU32<100>;
type MaxRelayBlocksStored = ConstU32<100>;
}
2 changes: 0 additions & 2 deletions dip-template/runtimes/dip-provider/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ scale-info = {workspace = true, features = ["derive"]}

# DIP
did.workspace = true
dip-support.workspace = true
kilt-dip-support.workspace = true
kilt-runtime-api-dip-provider.workspace = true
pallet-did-lookup.workspace = true
Expand Down Expand Up @@ -78,7 +77,6 @@ std = [
"parity-scale-codec/std",
"scale-info/std",
"did/std",
"dip-support/std",
"kilt-dip-support/std",
"kilt-runtime-api-dip-provider/std",
"pallet-did-lookup/std",
Expand Down
2 changes: 1 addition & 1 deletion dip-template/runtimes/dip-provider/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ construct_runtime!(
Web3Names: pallet_web3_names = 32,

// DIP
DipProvider: pallet_dip_provider = 50,
DipProvider: pallet_dip_provider = 40,
}
);

Expand Down
28 changes: 16 additions & 12 deletions pallets/pallet-relay-store/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@ pub use crate::pallet::*;
pub mod pallet {
use super::*;

use frame_support::{
pallet_prelude::{ValueQuery, *},
BoundedVec,
};
use frame_support::{pallet_prelude::*, BoundedVec};
use frame_system::pallet_prelude::*;
use sp_core::H256;

Expand All @@ -43,14 +40,16 @@ pub mod pallet {
#[pallet::getter(fn latest_relay_head_for_block)]
pub(crate) type LatestRelayHeads<T: Config> = StorageMap<_, Twox64Concat, u32, RelayParentInfo<H256>>;

// TODO: Use a better data structure for lookups
// TODO: Replace this with an array once support for const generics is fully
// supported in Substrate.
#[pallet::storage]
pub(crate) type LatestBlockHeights<T: Config> = StorageValue<_, BoundedVec<u32, T::MaxBlocks>, ValueQuery>;
pub(crate) type LatestBlockHeights<T: Config> =
StorageValue<_, BoundedVec<u32, T::MaxRelayBlocksStored>, ValueQuery>;

#[pallet::config]
pub trait Config: frame_system::Config {
#[pallet::constant]
type MaxBlocks: Get<u32>;
type MaxRelayBlocksStored: Get<u32>;
}

#[pallet::pallet]
Expand All @@ -65,15 +64,17 @@ pub mod pallet {
{
fn on_initialize(_n: BlockNumberFor<T>) -> Weight {
// Reserve weight to update the last relay state root
// TODO: Replace with benchmarked version of `on_finalize(`
<T as frame_system::Config>::DbWeight::get().writes(2)
}

// TODO: Benchmarks
fn on_finalize(_n: BlockNumberFor<T>) {
// Called before the validation data is cleaned in the
// parachain_system::on_finalize hook
let Some(new_validation_data) = cumulus_pallet_parachain_system::Pallet::<T>::validation_data() else { return; };
// Remove old relay block from both storage entries.
let mut latest_block_heights = LatestBlockHeights::<T>::get();
// Remove old relay block from both storage entries.
if latest_block_heights.is_full() {
let oldest_block_height = latest_block_heights.remove(0);
LatestRelayHeads::<T>::remove(oldest_block_height);
Expand All @@ -84,7 +85,6 @@ pub mod pallet {
}
// Set the new relay block in storage.
let relay_block_height = new_validation_data.relay_parent_number;
// TODO: Replace hardcoded generics with proper definitions.
log::trace!(
"Adding new relay block with state root {:#02x?} and number {:?}",
new_validation_data.relay_parent_storage_root,
Expand All @@ -96,9 +96,13 @@ pub mod pallet {
relay_parent_storage_root: new_validation_data.relay_parent_storage_root,
},
);
latest_block_heights
.try_push(relay_block_height)
.expect("Should never fail to push a new object on the BoundedVec of relay block heights.");
let push_res = latest_block_heights.try_push(relay_block_height);
if let Err(err) = push_res {
log::error!(
"Pushing a new relay block to the queue should not fail but it did when adding relay block n. {:?}",
err
);
}
LatestBlockHeights::<T>::set(latest_block_heights);
}
}
Expand Down