Skip to content

Commit

Permalink
Expose UpdateAccumulator (#196)
Browse files Browse the repository at this point in the history
* Include `UpdateAccumulator` in metadata

* Expose `UpdateAccumulator` + merge with the upstream
  • Loading branch information
olegnn authored Jan 31, 2025
1 parent 837fa0c commit 0535ca0
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 25 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ authors = ["Dock.io"]
build = "build.rs"
edition = "2021"
name = "dock-node"
version = "0.33.0"
version = "0.34.0"

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
Expand All @@ -28,7 +28,7 @@ optional = true

[dependencies.dock-runtime]
path = "../runtime"
version = "0.33.0"
version = "0.34.0"

[dependencies.beefy-primitives]
git = "https://github.com/paritytech/substrate.git"
Expand Down
1 change: 1 addition & 0 deletions pallets/core/src/modules/did/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,7 @@ pub mod pallet {
_qi: crate::trust_registry::QueryTrustRegistryBy,
_qy: crate::trust_registry::QueryTrustRegistriesBy,
_a: crate::trust_registry::AggregatedTrustRegistrySchemaMetadata<T>,
_u: crate::accumulator::UpdateAccumulator<T>,
) -> DispatchResult {
Err(DispatchError::BadOrigin)
}
Expand Down
36 changes: 21 additions & 15 deletions pallets/core/src/util/batch_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,10 +341,12 @@ where
U: GetUpdateKind<Option<<C::Target as KeyValue>::Value>>,
C::Target: KeyValue,
{
type Targets<'a> = alloc::collections::btree_map::Keys<'a, <C::Target as KeyValue>::Key, U> where
Self: 'a,
<C::Target as KeyValue>::Key: 'a,
C: 'a;
type Targets<'a>
= alloc::collections::btree_map::Keys<'a, <C::Target as KeyValue>::Key, U>
where
Self: 'a,
<C::Target as KeyValue>::Key: 'a,
C: 'a;

fn targets<'targets>(&'targets self, _entity: &'targets C) -> Self::Targets<'targets> {
self.keys()
Expand Down Expand Up @@ -549,7 +551,12 @@ where
U: GetUpdateKind<Option<<C::Target as KeyValue>::Value>>,
C::Target: KeyValue,
{
type Targets<'a> = core::iter::Once<&'a <C::Target as KeyValue>::Key> where U: 'a, C: 'a, <C::Target as KeyValue>::Key: 'a;
type Targets<'a>
= core::iter::Once<&'a <C::Target as KeyValue>::Key>
where
U: 'a,
C: 'a,
<C::Target as KeyValue>::Key: 'a;

fn targets<'targets>(&'targets self, _entity: &'targets C) -> Self::Targets<'targets> {
once(&self.key)
Expand Down Expand Up @@ -909,16 +916,15 @@ where
C::Target: KeyValue,
U: KeyedUpdate<C>,
{
type Targets<'a> = Either<
core::iter::Chain<
<C::Target as KeyValue>::Keys<'a>,
<C::Target as KeyValue>::Keys<'a>,
>,
U::Targets<'a>
> where
Self: 'a,
<C::Target as KeyValue>::Key: 'a,
C: 'a;
type Targets<'a>
= Either<
core::iter::Chain<<C::Target as KeyValue>::Keys<'a>, <C::Target as KeyValue>::Keys<'a>>,
U::Targets<'a>,
>
where
Self: 'a,
<C::Target as KeyValue>::Key: 'a,
C: 'a;

fn targets<'targets>(&'targets self, entity: &'targets C) -> Self::Targets<'targets> {
match self {
Expand Down
24 changes: 20 additions & 4 deletions pallets/core/src/util/key_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ impl<K: Ord + Clone, V: Clone, S: Get<u32>> KeyValue for BoundedBTreeMap<K, V, S
type Key = K;
type Value = V;

type Keys<'keys> = alloc::collections::btree_map::Keys<'keys, K, V> where Self: 'keys, K: 'keys;
type Keys<'keys>
= alloc::collections::btree_map::Keys<'keys, K, V>
where
Self: 'keys,
K: 'keys;

fn capacity(&self) -> Option<u32> {
Some(S::get())
Expand Down Expand Up @@ -73,7 +77,11 @@ impl<V: Ord + Clone, S: Get<u32>> KeyValue for BoundedBTreeSet<V, S> {
type Key = V;
type Value = ();

type Keys<'keys> = alloc::collections::btree_set::Iter<'keys, V> where Self: 'keys, V: 'keys;
type Keys<'keys>
= alloc::collections::btree_set::Iter<'keys, V>
where
Self: 'keys,
V: 'keys;

fn capacity(&self) -> Option<u32> {
Some(S::get())
Expand All @@ -100,7 +108,11 @@ impl<K: Ord + Clone, V: Clone> KeyValue for BTreeMap<K, V> {
type Key = K;
type Value = V;

type Keys<'keys> = alloc::collections::btree_map::Keys<'keys, K, V> where Self: 'keys, K: 'keys;
type Keys<'keys>
= alloc::collections::btree_map::Keys<'keys, K, V>
where
Self: 'keys,
K: 'keys;

fn capacity(&self) -> Option<u32> {
None
Expand Down Expand Up @@ -133,7 +145,11 @@ impl<V: Ord + Clone> KeyValue for BTreeSet<V> {
type Key = V;
type Value = ();

type Keys<'keys> = alloc::collections::btree_set::Iter<'keys, V> where Self: 'keys, V: 'keys;
type Keys<'keys>
= alloc::collections::btree_set::Iter<'keys, V>
where
Self: 'keys,
V: 'keys;

fn capacity(&self) -> Option<u32> {
None
Expand Down
2 changes: 1 addition & 1 deletion runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
authors = ["Dock.io"]
edition = "2021"
name = "dock-runtime"
version = "0.33.0"
version = "0.34.0"
license = "Apache-2.0"

[package.metadata.docs.rs]
Expand Down
23 changes: 22 additions & 1 deletion runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,32 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("dock-pos-dev-runtime"),
impl_name: create_runtime_str!("Dock"),
authoring_version: 1,
spec_version: 67,
spec_version: 68,
impl_version: 2,
transaction_version: 2,
apis: RUNTIME_API_VERSIONS,
};

pub struct ChangeValidatorsConfiguration;

#[cfg(feature = "mainnet")]
impl ChangeValidatorsConfiguration {
pub const VALIDATOR_COUNT: u32 = 10;
}

#[cfg(not(feature = "mainnet"))]
impl ChangeValidatorsConfiguration {
pub const VALIDATOR_COUNT: u32 = 2;
}

impl OnRuntimeUpgrade for ChangeValidatorsConfiguration {
fn on_runtime_upgrade() -> Weight {
pallet_staking::ValidatorCount::<Runtime>::put(Self::VALIDATOR_COUNT);

<Runtime as frame_system::Config>::DbWeight::get().writes(1)
}
}

/// `fastblock` reduces the block time for faster testing. It isn't recommended for production.
/// Also build the node in release mode to support small block times (< 1 sec)
/// TODO: Support instant seal
Expand Down Expand Up @@ -1859,6 +1879,7 @@ type Executive = frame_executive::Executive<
frame_system::ChainContext<Runtime>,
Runtime,
AllPalletsWithSystem,
ChangeValidatorsConfiguration,
>;

/// The address format for describing accounts.
Expand Down

0 comments on commit 0535ca0

Please sign in to comment.