Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • 1000i100-test
  • 105_gitlab_container_registry
  • cgeek/issue-297-cpu
  • ci_cache
  • debug/podman
  • elois-compose-metrics
  • elois-duniter-storage
  • elois-smoldot
  • feature/dc-dump
  • feature/distance-rule
  • feature/show_milestone
  • fix-252
  • fix_picked_up_file_in_runtime_release
  • gdev-800-tests
  • hugo-release/runtime-701
  • hugo-tmp-dockerfile-cache
  • hugo/195-doc
  • hugo/195-graphql-schema
  • hugo/distance-precompute
  • hugo/endpoint-gossip
  • hugo/tmp-0.9.1
  • master
  • network/gdev-800
  • network/gdev-802
  • network/gdev-803
  • network/gdev-900
  • network/gtest-1000
  • pini-check-password
  • release/client-800.2
  • release/hugo-chainspec-gdev5
  • release/poka-chainspec-gdev5
  • release/poka-chainspec-gdev5-pini-docker
  • release/runtime-100
  • release/runtime-200
  • release/runtime-300
  • release/runtime-400
  • release/runtime-401
  • release/runtime-500
  • release/runtime-600
  • release/runtime-700
  • release/runtime-701
  • release/runtime-800
  • runtime/gtest-1000
  • tests/distance-with-oracle
  • tuxmain/anonymous-tx
  • tuxmain/benchmark-distance
  • tuxmain/fix-change-owner-key
  • update-docker-compose-rpc-squid-names
  • upgradable-multisig
  • gdev-800
  • gdev-800-0.8.0
  • gdev-802
  • gdev-803
  • gdev-900-0.10.0
  • gdev-900-0.10.1
  • gdev-900-0.9.0
  • gdev-900-0.9.1
  • gdev-900-0.9.2
  • gtest-1000
  • gtest-1000-0.11.0
  • gtest-1000-0.11.1
  • runtime-100
  • runtime-101
  • runtime-102
  • runtime-103
  • runtime-104
  • runtime-105
  • runtime-200
  • runtime-201
  • runtime-300
  • runtime-301
  • runtime-302
  • runtime-303
  • runtime-400
  • runtime-401
  • runtime-500
  • runtime-600
  • runtime-700
  • runtime-701
  • runtime-800
  • runtime-800-backup
  • runtime-800-bis
  • runtime-801
  • v0.1.0
  • v0.2.0
  • v0.3.0
  • v0.4.0
  • v0.4.1
88 results

Target

Select target project
  • nodes/rust/duniter-v2s
  • llaq/lc-core-substrate
  • pini-gh/duniter-v2s
  • vincentux/duniter-v2s
  • mildred/duniter-v2s
  • d0p1/duniter-v2s
  • bgallois/duniter-v2s
  • Nicolas80/duniter-v2s
8 results
Select Git revision
  • archive_upgrade_polkadot_v0.9.42
  • david-wot-scenarios-cucumber
  • distance
  • elois-ci-binary-release
  • elois-compose-metrics
  • elois-duniter-storage
  • elois-fix-85
  • elois-fix-idty-post-genesis
  • elois-fix-sufficients-change-owner-key
  • elois-opti-cert
  • elois-remove-renewable-period
  • elois-revoc-with-old-key
  • elois-rework-certs
  • elois-smish-members-cant-change-or-rem-idty
  • elois-smoldot
  • elois-substrate-v0.9.23
  • elois-technical-commitee
  • hugo-gtest
  • hugo-remove-duniter-account
  • hugo-rework-genesis
  • hugo-tmp
  • jrx/workspace_tomls
  • master
  • no-bootnodes
  • pallet-benchmark
  • release/poka-chainspec-gdev5
  • release/poka-chainspec-gdev5-pini-docker
  • release/runtime-100
  • release/runtime-200
  • release/runtime-300
  • release/runtime-400
  • test-gen-new-owner-key-msg
  • ts-types
  • ud-time-64
  • upgrade_polkadot_v0.9.42
  • runtime-100
  • runtime-101
  • runtime-102
  • runtime-103
  • runtime-104
  • runtime-105
  • runtime-200
  • runtime-201
  • runtime-300
  • runtime-301
  • runtime-302
  • runtime-303
  • runtime-400
  • v0.1.0
  • v0.2.0
  • v0.3.0
  • v0.4.0
52 results
Show changes
Showing
with 280626 additions and 364 deletions
...@@ -24,13 +24,13 @@ pub use pallet::*; ...@@ -24,13 +24,13 @@ pub use pallet::*;
pub use weights::WeightInfo; pub use weights::WeightInfo;
use frame_support::{ use frame_support::{
dispatch::GetDispatchInfo, dispatch::{GetDispatchInfo, PostDispatchInfo},
dispatch::PostDispatchInfo,
traits::{IsSubType, UnfilteredDispatchable}, traits::{IsSubType, UnfilteredDispatchable},
}; };
use scale_info::prelude::boxed::Box;
use sp_runtime::traits::Dispatchable; use sp_runtime::traits::Dispatchable;
use sp_std::prelude::*;
#[allow(unreachable_patterns)]
#[frame_support::pallet] #[frame_support::pallet]
pub mod pallet { pub mod pallet {
use super::*; use super::*;
...@@ -38,7 +38,6 @@ pub mod pallet { ...@@ -38,7 +38,6 @@ pub mod pallet {
use frame_system::pallet_prelude::*; use frame_system::pallet_prelude::*;
#[pallet::pallet] #[pallet::pallet]
#[pallet::generate_store(pub(super) trait Store)]
pub struct Pallet<T>(_); pub struct Pallet<T>(_);
/// Configuration trait. /// Configuration trait.
...@@ -56,18 +55,18 @@ pub mod pallet { ...@@ -56,18 +55,18 @@ pub mod pallet {
/// The overarching event type. /// The overarching event type.
type RuntimeEvent: From<Event> + IsType<<Self as frame_system::Config>::RuntimeEvent>; type RuntimeEvent: From<Event> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
/// The upgradable origin /// The origin type required for performing upgradable operations.
type UpgradableOrigin: EnsureOrigin<Self::RuntimeOrigin>; type UpgradableOrigin: EnsureOrigin<Self::RuntimeOrigin>;
/// Pallet weights info /// Type representing the weight of this pallet.
type WeightInfo: WeightInfo; type WeightInfo: WeightInfo;
/// Type representing the worst case origin type used in weight benchmarks.
#[cfg(feature = "runtime-benchmarks")] #[cfg(feature = "runtime-benchmarks")]
/// The worst case origin type to use in weights benchmarking
type WorstCaseOriginType: Into<Self::RuntimeOrigin>; type WorstCaseOriginType: Into<Self::RuntimeOrigin>;
/// Retrieves the worst case origin for use in weight benchmarks.
#[cfg(feature = "runtime-benchmarks")] #[cfg(feature = "runtime-benchmarks")]
/// The worst case origin to use in weights benchmarking
type WorstCaseOrigin: Get<Self::WorstCaseOriginType>; type WorstCaseOrigin: Get<Self::WorstCaseOriginType>;
} }
...@@ -83,11 +82,12 @@ pub mod pallet { ...@@ -83,11 +82,12 @@ pub mod pallet {
/// Dispatches a function call from root origin. /// Dispatches a function call from root origin.
/// ///
/// The weight of this call is defined by the caller. /// The weight of this call is defined by the caller.
#[pallet::call_index(0)]
#[pallet::weight({ #[pallet::weight({
let dispatch_info = call.get_dispatch_info(); let dispatch_info = call.get_dispatch_info();
( (
T::WeightInfo::dispatch_as_root() T::WeightInfo::dispatch_as_root()
.saturating_add(dispatch_info.weight), .saturating_add(dispatch_info.call_weight).saturating_add(dispatch_info.extension_weight),
dispatch_info.class, dispatch_info.class,
) )
})] })]
...@@ -104,17 +104,20 @@ pub mod pallet { ...@@ -104,17 +104,20 @@ pub mod pallet {
}); });
Ok(Pays::No.into()) Ok(Pays::No.into())
} }
/// Dispatches a function call from root origin. /// Dispatches a function call from root origin.
/// This function does not check the weight of the call, and instead allows the /// This function does not check the weight of the call, and instead allows the
/// caller to specify the weight of the call. /// caller to specify the weight of the call.
/// ///
/// The weight of this call is defined by the caller. /// The weight of this call is defined by the caller.
#[pallet::weight((*_weight, call.get_dispatch_info().class))] #[pallet::call_index(1)]
#[pallet::weight((*weight, call.get_dispatch_info().class))]
pub fn dispatch_as_root_unchecked_weight( pub fn dispatch_as_root_unchecked_weight(
origin: OriginFor<T>, origin: OriginFor<T>,
call: Box<<T as Config>::Call>, call: Box<<T as Config>::Call>,
_weight: Weight, weight: Weight,
) -> DispatchResultWithPostInfo { ) -> DispatchResultWithPostInfo {
let _ = weight; // We dont need to check the weight witness.
T::UpgradableOrigin::ensure_origin(origin)?; T::UpgradableOrigin::ensure_origin(origin)?;
let res = call.dispatch_bypass_filter(frame_system::RawOrigin::Root.into()); let res = call.dispatch_bypass_filter(frame_system::RawOrigin::Root.into());
......
...@@ -26,6 +26,6 @@ pub trait WeightInfo { ...@@ -26,6 +26,6 @@ pub trait WeightInfo {
// Insecure weights implementation, use it for tests only! // Insecure weights implementation, use it for tests only!
impl WeightInfo for () { impl WeightInfo for () {
fn dispatch_as_root() -> Weight { fn dispatch_as_root() -> Weight {
Weight::from_ref_time(8_000) Weight::from_parts(8_000, 0)
} }
} }
[package]
authors.workspace = true
description = "primitives for pallet distance"
edition.workspace = true
homepage.workspace = true
license.workspace = true
name = "sp-distance"
readme = "README.md"
repository.workspace = true
version.workspace = true
[package.metadata.docs.rs]
default-features = false
targets = ["x86_64-unknown-linux-gnu"]
[features]
default = ["std"]
std = [
"async-trait",
"codec/std",
"frame-support/std",
"scale-info/std",
"serde/std",
"sp-inherents/std",
"sp-runtime/std",
"thiserror",
]
try-runtime = ["frame-support/try-runtime", "sp-runtime/try-runtime"]
runtime-benchmarks = []
[dependencies]
async-trait = { workspace = true, optional = true }
codec = { workspace = true, features = ["derive"] }
frame-support = { workspace = true }
scale-info = { workspace = true, features = ["derive"] }
serde = { workspace = true, features = ["derive"] }
sp-inherents = { workspace = true }
sp-runtime = { workspace = true }
thiserror = { workspace = true, optional = true }
// Copyright 2023 Axiom-Team
//
// This file is part of Duniter-v2S.
//
// Duniter-v2S is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, version 3 of the License.
//
// Duniter-v2S is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with Duniter-v2S. If not, see <https://www.gnu.org/licenses/>.
//! Defines types and traits for users of pallet distance.
#![cfg_attr(not(feature = "std"), no_std)]
#![allow(clippy::type_complexity)]
use codec::{Decode, DecodeWithMemTracking, Encode};
use frame_support::pallet_prelude::RuntimeDebug;
use scale_info::TypeInfo;
use sp_inherents::{InherentIdentifier, IsFatalError};
use sp_runtime::Perbill;
#[cfg(feature = "std")]
use std::marker::PhantomData;
pub const INHERENT_IDENTIFIER: InherentIdentifier = *b"distanc0";
/// Represents the result of a distance computation.
#[derive(Clone, DecodeWithMemTracking, Decode, Encode, PartialEq, RuntimeDebug, TypeInfo)]
pub struct ComputationResult {
pub distances: scale_info::prelude::vec::Vec<Perbill>,
}
/// Errors that can occur while checking the inherent data in `ProvideInherent::check_inherent` from pallet-distance.
#[derive(Encode, sp_runtime::RuntimeDebug)]
#[cfg_attr(feature = "std", derive(Decode, thiserror::Error))]
pub enum InherentError {}
impl IsFatalError for InherentError {
fn is_fatal_error(&self) -> bool {
false
}
}
#[cfg(feature = "std")]
pub struct InherentDataProvider<IdtyIndex: Decode + Encode + PartialEq + TypeInfo> {
computation_result: Option<ComputationResult>,
_p: PhantomData<IdtyIndex>,
}
#[cfg(feature = "std")]
impl<IdtyIndex: Decode + Encode + PartialEq + TypeInfo> InherentDataProvider<IdtyIndex> {
pub fn new(computation_result: Option<ComputationResult>) -> Self {
Self {
computation_result,
_p: PhantomData,
}
}
}
#[cfg(feature = "std")]
#[async_trait::async_trait]
impl<IdtyIndex: Decode + Encode + PartialEq + TypeInfo + Send + Sync>
sp_inherents::InherentDataProvider for InherentDataProvider<IdtyIndex>
{
async fn provide_inherent_data(
&self,
inherent_data: &mut sp_inherents::InherentData,
) -> Result<(), sp_inherents::Error> {
if let Some(computation_result) = &self.computation_result {
inherent_data.put_data(INHERENT_IDENTIFIER, computation_result)?;
}
Ok(())
}
async fn try_handle_error(
&self,
_identifier: &InherentIdentifier,
_error: &[u8],
) -> Option<Result<(), sp_inherents::Error>> {
// No errors occur here.
// Errors handled here are emitted in the `ProvideInherent::check_inherent`
// (from pallet-distance) which is not implemented.
None
}
}
[package] [package]
authors = ['librelois <c@elo.tf>'] authors.workspace = true
description = 'primitives for duniter runtime.' description = "primitives for duniter runtime"
edition = "2021" edition.workspace = true
homepage = 'https://duniter.org' homepage.workspace = true
license = 'AGPL-3.0' license.workspace = true
name = 'duniter-primitives' name = "duniter-primitives"
readme = 'README.md' readme = "README.md"
repository = 'https://git.duniter.org/nodes/rust/duniter-v2s' repository.workspace = true
version = '3.0.0' version.workspace = true
[features] [package.metadata.docs.rs]
default = ['std']
std = [
'codec/std',
'frame-support/std',
'sp-runtime/std',
'sp-std/std',
]
try-runtime = ['frame-support/try-runtime']
[dependencies]
# substrate
scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }
[dependencies.codec]
default-features = false
features = ['derive']
package = 'parity-scale-codec'
version = "3.1.5"
[dependencies.frame-support]
default-features = false
git = 'https://github.com/duniter/substrate'
branch = 'duniter-substrate-v0.9.32'
[dependencies.sp-runtime]
default-features = false
git = 'https://github.com/duniter/substrate'
branch = 'duniter-substrate-v0.9.32'
[dependencies.sp-std]
default-features = false default-features = false
git = 'https://github.com/duniter/substrate' targets = ["x86_64-unknown-linux-gnu"]
branch = 'duniter-substrate-v0.9.32'
### DOC ### [dependencies]
sp-runtime = { workspace = true }
[package.metadata.docs.rs] [features]
targets = ['x86_64-unknown-linux-gnu'] default = ["std"]
std = [
"sp-runtime/std",
]
...@@ -16,18 +16,54 @@ ...@@ -16,18 +16,54 @@
#![cfg_attr(not(feature = "std"), no_std)] #![cfg_attr(not(feature = "std"), no_std)]
/// Rules for valid identity names are defined below /// Checks rules for valid identity names
/// - Bound length to 42 /// - Limit length to 42
/// - accept only ascii alphanumeric or - or _ /// - Accept only ascii alphanumeric or `-` or `_`
pub fn validate_idty_name(idty_name: &[u8]) -> bool { pub fn validate_idty_name(idty_name: &[u8]) -> bool {
idty_name.len() >= 3 idty_name.len() >= 3
&& idty_name.len() <= 42 // length smaller than 42 && idty_name.len() <= 42
// all characters are alphanumeric or - or _
&& idty_name && idty_name
.iter() .iter()
.all(|c| c.is_ascii_alphanumeric() || *c == b'-' || *c == b'_') .all(|c| c.is_ascii_alphanumeric() || *c == b'-' || *c == b'_')
} }
pub trait GetSigner<Lookup: sp_runtime::traits::StaticLookup> {
fn get_signer(&self) -> Option<Lookup::Target>;
}
impl<Address: Clone, Lookup, Call, Signature, Extension> GetSigner<Lookup>
for sp_runtime::generic::UncheckedExtrinsic<Address, Call, Signature, Extension>
where
Lookup: sp_runtime::traits::StaticLookup<Source = Address>,
{
fn get_signer(&self) -> Option<Lookup::Target> {
match &self.preamble {
sp_runtime::generic::Preamble::Signed(signer, _, _) => {
Lookup::lookup(signer.clone()).ok()
}
_ => None,
}
}
}
/// trait used to go from index to owner key and reverse
// replaces less explicit "Convert" implementations
pub trait Idty<IdtyIndex, AccountId> {
fn owner_key(index: IdtyIndex) -> Option<AccountId>;
fn idty_index(owner_key: AccountId) -> Option<IdtyIndex>;
}
// mock implementation for any type
impl<T> Idty<T, T> for () {
fn owner_key(t: T) -> Option<T> {
Some(t)
}
fn idty_index(t: T) -> Option<T> {
Some(t)
}
}
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
......
[package] [package]
authors = ['librelois <c@elo.tf>'] authors.workspace = true
description = 'primitives for pallet membership.' description = "primitives for pallet membership"
edition = "2021" edition.workspace = true
homepage = 'https://duniter.org' homepage.workspace = true
license = 'AGPL-3.0' license.workspace = true
name = 'sp-membership' name = "sp-membership"
readme = 'README.md' readme = "README.md"
repository = 'https://git.duniter.org/nodes/rust/duniter-v2s' repository.workspace = true
version = '3.0.0' version.workspace = true
[package.metadata.docs.rs]
default-features = false
targets = ["x86_64-unknown-linux-gnu"]
[features] [features]
default = ['std'] default = ["std"]
std = [ std = [
'codec/std', "codec/std",
'frame-support/std', "frame-support/std",
'serde', "scale-info/std",
'sp-runtime/std', "serde/std",
'sp-std/std', "sp-runtime/std",
] ]
try-runtime = ['frame-support/try-runtime'] try-runtime = ["frame-support/try-runtime", "sp-runtime/try-runtime"]
runtime-benchmarks = []
[dependencies] [dependencies]
codec = { workspace = true, features = ["derive"] }
# substrate frame-support = { workspace = true }
scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } scale-info = { workspace = true, features = ["derive"] }
serde = { workspace = true }
[dependencies.codec] sp-runtime = { workspace = true }
default-features = false
features = ['derive']
package = 'parity-scale-codec'
version = "3.1.5"
[dependencies.frame-support]
default-features = false
git = 'https://github.com/duniter/substrate'
branch = 'duniter-substrate-v0.9.32'
[dependencies.serde]
version = "1.0.101"
optional = true
features = ["derive"]
[dependencies.sp-runtime]
default-features = false
git = 'https://github.com/duniter/substrate'
branch = 'duniter-substrate-v0.9.32'
[dependencies.sp-std]
default-features = false
git = 'https://github.com/duniter/substrate'
branch = 'duniter-substrate-v0.9.32'
### DOC ###
[package.metadata.docs.rs]
targets = ['x86_64-unknown-linux-gnu']
...@@ -22,28 +22,47 @@ ...@@ -22,28 +22,47 @@
pub mod traits; pub mod traits;
use codec::{Decode, Encode}; use codec::{Decode, Encode};
use frame_support::RuntimeDebug; use frame_support::pallet_prelude::{RuntimeDebug, Weight};
use scale_info::TypeInfo; use scale_info::TypeInfo;
#[cfg(feature = "std")]
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
pub enum Event<IdtyId, MetaData = ()> { /// Represent membership-related events.
/// A membership has acquired pub enum Event<IdtyId> {
MembershipAcquired(IdtyId, MetaData), /// A membership was acquired.
/// A membership has expired MembershipAdded(IdtyId),
MembershipExpired(IdtyId), /// A membership was terminated.
/// A membership has renewed MembershipRemoved(IdtyId),
/// A membership was renewed.
MembershipRenewed(IdtyId), MembershipRenewed(IdtyId),
/// An identity requested membership
MembershipRequested(IdtyId),
/// A membership has revoked
MembershipRevoked(IdtyId),
/// A pending membership request has expired
PendingMembershipExpired(IdtyId),
} }
#[cfg_attr(feature = "std", derive(Deserialize, Serialize))] /// Represent membership data.
#[derive(Encode, Decode, Default, Clone, Copy, PartialEq, Eq, RuntimeDebug, TypeInfo)] #[derive(
Encode,
Decode,
Default,
Clone,
Copy,
PartialEq,
Eq,
RuntimeDebug,
TypeInfo,
Deserialize,
Serialize,
)]
pub struct MembershipData<BlockNumber: Decode + Encode + TypeInfo> { pub struct MembershipData<BlockNumber: Decode + Encode + TypeInfo> {
pub expire_on: BlockNumber, pub expire_on: BlockNumber,
} }
impl<IdtyId> traits::OnNewMembership<IdtyId> for () {
fn on_created(_idty_index: &IdtyId) {}
fn on_renewed(_idty_index: &IdtyId) {}
}
impl<IdtyId> traits::OnRemoveMembership<IdtyId> for () {
fn on_removed(_idty_index: &IdtyId) -> Weight {
Weight::zero()
}
}
...@@ -16,48 +16,40 @@ ...@@ -16,48 +16,40 @@
use frame_support::pallet_prelude::*; use frame_support::pallet_prelude::*;
pub trait CheckCallAllowed<IdtyId> { /// A trait defining operations for checking if membership-related operations are allowed.
fn check_idty_allowed_to_claim_membership(idty_id: &IdtyId) -> Result<(), DispatchError>; pub trait CheckMembershipOpAllowed<IdtyId> {
fn check_idty_allowed_to_renew_membership(idty_id: &IdtyId) -> Result<(), DispatchError>; /// Checks if adding a membership is allowed.
fn check_idty_allowed_to_request_membership(idty_id: &IdtyId) -> Result<(), DispatchError>; fn check_add_membership(idty_id: IdtyId) -> Result<(), DispatchError>;
/// Checks if renewing a membership is allowed.
fn check_renew_membership(idty_id: IdtyId) -> Result<(), DispatchError>;
} }
impl<IdtyId> CheckCallAllowed<IdtyId> for () { impl<IdtyId> CheckMembershipOpAllowed<IdtyId> for () {
fn check_idty_allowed_to_claim_membership(_: &IdtyId) -> Result<(), DispatchError> { fn check_add_membership(_: IdtyId) -> Result<(), DispatchError> {
Ok(()) Ok(())
} }
fn check_idty_allowed_to_renew_membership(_: &IdtyId) -> Result<(), DispatchError> {
Ok(()) fn check_renew_membership(_: IdtyId) -> Result<(), DispatchError> {
}
fn check_idty_allowed_to_request_membership(_: &IdtyId) -> Result<(), DispatchError> {
Ok(()) Ok(())
} }
} }
pub trait IsInPendingMemberships<IdtyId> { /// A trait defining behavior for handling new memberships and membership renewals.
fn is_in_pending_memberships(idty_id: IdtyId) -> bool; pub trait OnNewMembership<IdtyId> {
/// Called when a new membership is created.
fn on_created(idty_index: &IdtyId);
/// Called when a membership is renewed.
fn on_renewed(idty_index: &IdtyId);
} }
pub trait OnEvent<IdtyId, MetaData> { /// A trait defining operations for handling the removal of memberships.
fn on_event(event: &crate::Event<IdtyId, MetaData>) -> Weight; pub trait OnRemoveMembership<IdtyId> {
} /// Called when a membership is removed.
fn on_removed(idty_index: &IdtyId) -> Weight;
impl<IdtyId, MetaData> OnEvent<IdtyId, MetaData> for () {
fn on_event(_: &crate::Event<IdtyId, MetaData>) -> Weight {
Weight::zero()
}
} }
/// A trait defining an operation to retrieve the count of members.
pub trait MembersCount { pub trait MembersCount {
/// The count of members.
fn members_count() -> u32; fn members_count() -> u32;
} }
pub trait Validate<AccountId> {
fn validate(&self, account_id: &AccountId) -> bool;
}
impl<AccountId> Validate<AccountId> for () {
fn validate(&self, _account_id: &AccountId) -> bool {
true
}
}
# Resources # Resources
Files used for different purpose like tests. Files used for different purpose like tests.
## metadata.scale
To generate it for GDev:
cargo run -- --dev --tmp
subxt metadata -f bytes > resources/metadata.scale
See [Upgrade metadata](../end2end-tests/README.md#upgrade-metadata) for more details.
[Unit]
Description=Duniter distance oracle.
Requires=duniter-smith.service
After=duniter-smith.service
[Service]
EnvironmentFile=/etc/duniter/env_file
ExecStart=/usr/bin/duniter2 distance-oracle --evaluation-result-dir ${BASE_PATH}/chains/${DUNITER_CHAIN_NAME}/distance --rpc-url ${ORACLE_RPC_URL} --interval ${ORACLE_INTERVAL} --log ${ORACLE_LOG_LEVEL}
User=duniter
Group=duniter
# Inspired from https://github.com/paritytech/polkadot-sdk/blob/master/polkadot/scripts/packaging/polkadot.service
[Unit]
Description=Duniter mirror node.
[Service]
EnvironmentFile=/etc/duniter/env_file
ExecStart=/usr/bin/duniter2 --chain ${DUNITER_CHAIN_NAME} --name ${DUNITER_NODE_NAME}_mirror --listen-addr ${DUNITER_LISTEN_ADDR} --rpc-cors ${DUNITER_RPC_CORS} --state-pruning ${DUNITER_PRUNING_PROFILE} --base-path ${BASE_PATH}
User=duniter
Group=duniter
Restart=always
RestartSec=120
CapabilityBoundingSet=
LockPersonality=true
NoNewPrivileges=true
PrivateDevices=true
PrivateMounts=true
PrivateTmp=true
PrivateUsers=true
ProtectClock=true
ProtectControlGroups=true
ProtectHostname=true
ProtectKernelModules=true
ProtectKernelTunables=true
ProtectSystem=strict
RemoveIPC=true
RestrictAddressFamilies=AF_INET AF_INET6 AF_NETLINK AF_UNIX
RestrictNamespaces=false
RestrictSUIDSGID=true
SystemCallArchitectures=native
SystemCallFilter=@system-service
SystemCallFilter=landlock_add_rule landlock_create_ruleset landlock_restrict_self seccomp mount umount2
SystemCallFilter=~@clock @module @reboot @swap @privileged
SystemCallFilter=pivot_root
UMask=0027
[Install]
WantedBy=multi-user.target
# Inspired from https://github.com/paritytech/polkadot-sdk/blob/master/polkadot/scripts/packaging/polkadot.service
[Unit]
Description=Duniter smith node.
[Service]
EnvironmentFile=/etc/duniter/env_file
ExecStart=/usr/bin/duniter2 --chain ${DUNITER_CHAIN_NAME} --name ${DUNITER_NODE_NAME}_smith --listen-addr ${DUNITER_LISTEN_ADDR} --rpc-cors ${DUNITER_RPC_CORS} --state-pruning ${DUNITER_PRUNING_PROFILE} --base-path ${BASE_PATH} --rpc-methods Unsafe --validator
User=duniter
Group=duniter
Restart=always
RestartSec=120
CapabilityBoundingSet=
LockPersonality=true
NoNewPrivileges=true
PrivateDevices=true
PrivateMounts=true
PrivateTmp=true
PrivateUsers=true
ProtectClock=true
ProtectControlGroups=true
ProtectHostname=true
ProtectKernelModules=true
ProtectKernelTunables=true
ProtectSystem=strict
RemoveIPC=true
RestrictAddressFamilies=AF_INET AF_INET6 AF_NETLINK AF_UNIX
RestrictNamespaces=false
RestrictSUIDSGID=true
SystemCallArchitectures=native
SystemCallFilter=@system-service
SystemCallFilter=landlock_add_rule landlock_create_ruleset landlock_restrict_self seccomp mount umount2
SystemCallFilter=~@clock @module @reboot @swap @privileged
SystemCallFilter=pivot_root
UMask=0027
[Install]
WantedBy=multi-user.target
#Type Name ID GECOS Home directory Shell
u duniter - "Duniter user" /var/lib/duniter /sbin/nologin
# Sets the name of the node.
# This should be a unique identifier for your node within the network.
DUNITER_NODE_NAME=My Node
# Specifies the blockchain network to connect to.
DUNITER_CHAIN_NAME=gdev
# Defines the address and port for node communication.
# The format is /ip4/[IP address]/tcp/[port]/[protocol].
# If SMITH NODE: `/ip4/0.0.0.0/tcp/<port>` and `/ip6/[::]/tcp/<port>`. Otherwise: `/ip4/0.0.0.0/tcp/<port>/ws` and `/ip6/[::]/tcp/<port>/ws`.
DUNITER_LISTEN_ADDR=/ip4/0.0.0.0/tcp/30333
# Specify browser origins allowed to access the HTTP & WS RPC servers.
# A comma-separated list with no space of origins.
# Value of `all` will disable origin validation. Default is to allow localhost and
#<https://polkadot.js.org> origins.
# Default: "http://localhost:*,http://127.0.0.1:*,https://localhost:*,https://127.0.0.1:*,https://polkadot.js.org"
DUNITER_RPC_CORS=http://localhost:*,http://127.0.0.1:*,https://localhost:*,https://127.0.0.1:*,https://polkadot.js.org
# Configures the pruning profile to manage how old blockchain data is stored.
# This setting can only be set on the first creation of the database.
# Options:
# - 'archive': Keep the state of all blocks.
# - 'archive-canonical': Keep only the state of finalized blocks.
# - [number]: Keep the state of the last specified number of finalized blocks.
# Default: 256 for a balanced pruning strategy.
DUNITER_PRUNING_PROFILE=256
# Sets the directory for storing Duniter data.
# This should be a writable path on your system by the duniter user where the node can store its data.
# Default: /home/duniter/.local/share/duniter
BASE_PATH=/home/duniter/.local/share/duniter
# URL for the Oracle RPC server.
# This should point to the RPC endpoint that the oracle will use to communicate with the blockchain.
# Default: ws://127.0.0.1:9944 for a local WebSocket RPC server.
ORACLE_RPC_URL=ws://127.0.0.1:9944
# Interval in seconds at which the oracle is run.
# This should not exceed the evaluation period of the blockchain.
# Default: 600 seconds
ORACLE_INTERVAL=600
# Determines the log level for the Oracle.
# Options include 'error', 'warn', 'info', 'debug', 'trace'.
# 'info' is a good default that provides useful runtime information without too much detail.
# Default: info
ORACLE_LOG_LEVEL=info
#!/bin/sh
set -e
action="$1"
config_file="/etc/duniter/env_file"
if [ "$action" = "configure" ]; then
# Make user and group
getent group duniter >/dev/null 2>&1 || addgroup --system duniter
getent passwd duniter >/dev/null 2>&1 ||
adduser --system --disabled-password \
--ingroup duniter duniter
# Create user home dir
if [ ! -d "/home/duniter/" ]; then
mkdir /home/duniter
chown -R duniter:duniter /home/duniter
chmod 700 /home/duniter
fi
fi
#DEBHELPER#
Source diff could not be displayed: it is too large. Options to address this: view the blob.
{
"first_ud": 10000,
"first_ud_reeval": 100800,
"genesis_parameters": {
"genesis_certs_expire_on": 2102400,
"genesis_certs_min_received": 3,
"genesis_memberships_expire_on": 1051200,
"genesis_smith_certs_expire_on": 2102400,
"genesis_smith_certs_min_received": 3,
"genesis_smith_memberships_expire_on": 1051200
},
"identities": {
"Elois": {
"balance": 10000,
"certs": [
"poka",
"cgeek",
"vit",
"tuxmain",
"HugoTrentesaux",
"ManUtopiK",
"moul",
"1000i100",
"kapis",
"David B",
"Gamaliel",
"wellno1"
],
"pubkey": "5H95G8bwuf4yyNNNa83hDhj7wpYaSRhZiGezZ9TDbyqNdAhY"
},
"Elois2": {
"balance": 10000,
"certs": ["tuxmain", "Elois", "HugoTrentesaux"],
"pubkey": "5GFEEx7kqvP4QEPCAXkALeYCG7m8DiA5LQ4YzW62j7FytQyg"
},
"poka": {
"balance": 10000,
"certs": ["cgeek", "vit", "tuxmain", "Elois", "HugoTrentesaux"],
"pubkey": "5CQ8T4qpbYJq7uVsxGPQ5q2df7x3Wa4aRY6HUWMBYjfLZhnn"
},
"tuxmain": {
"balance": 10000,
"certs": [
"cgeek",
"Elois",
"HugoTrentesaux",
"ManUtopiK",
"poka",
"moul",
"1000i100"
],
"pubkey": "5D2DnScFpxoEUXDwZbJH18tRsQMygBSh1F6YCcWvTYzKY2W7"
},
"vit": {
"balance": 10000,
"certs": [
"cgeek",
"Elois",
"HugoTrentesaux",
"ManUtopiK",
"poka",
"tuxmain",
"moul"
],
"pubkey": "5DqkYGjiT5TFm2pGMUBMuZW4sw13vDEZmxqkxmky5AoQvUwd"
},
"cgeek": {
"balance": 10000,
"certs": ["poka", "vit", "tuxmain", "Elois", "HugoTrentesaux", "moul"],
"pubkey": "5DP7ze5cJwtHbqXaP2aNtJ5jkULzcTCqXuMzDvk9JjneFjfq"
},
"HugoTrentesaux": {
"balance": 10000,
"certs": [
"poka",
"vit",
"tuxmain",
"Elois",
"moul",
"1000i100",
"ManUtopiK",
"kapis",
"David B",
"Gamaliel",
"wellno1"
],
"pubkey": "5Dq8xjvkmbz7q4g2LbZgyExD26VSCutfEc6n4W4AfQeVHZqz"
},
"ManUtopiK": {
"balance": 10000,
"certs": [
"poka",
"vit",
"tuxmain",
"Elois",
"HugoTrentesaux",
"1000i100"
],
"pubkey": "5DUjwHRqPayt3tAZk1fqEgU99xZB9jzBHKy2sMSTNcc7m9D1"
},
"1000i100": {
"balance": 10000,
"certs": [
"Elois",
"poka",
"cgeek",
"vit",
"tuxmain",
"HugoTrentesaux",
"ManUtopiK",
"moul"
],
"pubkey": "5CCrBS67BrpBx3ihGHc72HZp3eHHbETxWFuNfwbbdoGSJFN8"
},
"moul": {
"balance": 10000,
"certs": [
"ManUtopiK",
"vit",
"tuxmain",
"Elois",
"HugoTrentesaux",
"1000i100"
],
"pubkey": "5EPGRtBYLwfDinnaAXsscM3FkffRADpJRrkZETqW8N6uhp22"
},
"Gamaliel": {
"balance": 10000,
"certs": ["David B", "wellno1", "kapis"],
"pubkey": "5DS9iWBXW56N7XbeVyyp6CB7m4LeE5fGJYrUR9HDSStT5JN9"
},
"kapis": {
"balance": 10000,
"certs": ["David B", "wellno1", "Gamaliel"],
"pubkey": "5HJyyim1W8Y1UD8LAbBL7cQQLjGofMoD45RtRSAmhkFQxrvs"
},
"David B": {
"balance": 10000,
"certs": ["kapis", "wellno1", "Gamaliel"],
"pubkey": "5HKTDdXHj3MojiPRcEsVU9JaHyif5gg2br1sy3JZbsjuQebP"
},
"wellno1": {
"balance": 10000,
"certs": ["David B", "kapis", "Gamaliel"],
"pubkey": "5DyEZNkSuK5i8wZiXtvL63zqpye9zPBsPRauCjQkMuVzZYX7"
}
},
"parameters": {
"babe_epoch_duration": 600,
"cert_period": 14400,
"cert_max_by_issuer": 100,
"cert_min_received_cert_to_issue_cert": 3,
"cert_validity_period": 2102400,
"idty_confirm_period": 14400,
"idty_creation_period": 14400,
"membership_period": 1051200,
"pending_membership_period": 172800,
"ud_creation_period": 14400,
"ud_reeval_period": 100800,
"smith_cert_period": 14400,
"smith_cert_max_by_issuer": 15,
"smith_cert_min_received_cert_to_issue_cert": 3,
"smith_cert_validity_period": 2102400,
"smith_membership_period": 1051200,
"smith_pending_membership_period": 172800,
"smiths_wot_first_cert_issuable_on": 14400,
"smiths_wot_min_cert_for_membership": 3,
"wot_first_cert_issuable_on": 0,
"wot_min_cert_for_create_idty_right": 3,
"wot_min_cert_for_membership": 3
},
"smiths": {
"Elois": {
"certs": ["poka", "cgeek", "vit", "tuxmain", "HugoTrentesaux", "kapis"],
"session_keys": "0x92743b12d55242276539d7256951cdfda85371caefbd325396da9331011b737d14084d2537f77e786a75b9bcbe351051fad52946ec211724b5e8c93bb8aa7a6f14084d2537f77e786a75b9bcbe351051fad52946ec211724b5e8c93bb8aa7a6f14084d2537f77e786a75b9bcbe351051fad52946ec211724b5e8c93bb8aa7a6f"
},
"Elois2": {
"certs": ["tuxmain", "Elois", "HugoTrentesaux"]
},
"poka": {
"certs": ["cgeek", "vit", "tuxmain", "Elois", "HugoTrentesaux"]
},
"tuxmain": {
"certs": ["cgeek", "Elois", "HugoTrentesaux", "poka", "kapis"]
},
"vit": {
"certs": ["cgeek", "Elois", "HugoTrentesaux", "poka"]
},
"cgeek": {
"certs": ["poka", "vit", "tuxmain", "Elois", "HugoTrentesaux"]
},
"HugoTrentesaux": {
"certs": ["poka", "vit", "tuxmain", "Elois", "kapis"]
},
"1000i100": {
"certs": ["cgeek", "vit", "tuxmain", "Elois", "HugoTrentesaux", "poka"]
},
"kapis": {
"certs": ["Elois","tuxmain","HugoTrentesaux"]
}
},
"sudo_key": "5Hm8sBbwuLAU99dBezvgtnRmZCrUy9mhqmbQMFyGTaeATYg7",
"technical_committee": ["Elois", "cgeek", "tuxmain", "HugoTrentesaux"]
}
# 10,00 ĞD per UD
ud: 1000
# null = block#0 + ud_creation_period waiting (ms)
first_ud: null
# null = block#0 + ud_reeval_period waiting (ms)
first_ud_reeval: null
# Parameters used in pallet `duniter-test-parameters`
parameters:
# Epoch (session) duration, in number of blocks. 1h.
babe_epoch_duration: 600
# Time between 2 UDs, in milliseconds. 4 hours.
ud_creation_period: 14400000
# Time between 2 UD reevaluations, in milliseconds. 24 hours.
ud_reeval_period: 86400000
# ----- MAIN WOT -----
# Duration to wait between two emitted certifications 14400 blocks = 24h = 1 day.
cert_period: 14400
# Maximum quantity of currently valid certifications emitted by a same issuer. 100 certs.
cert_max_by_issuer: 100
# Minimum quantity of received certifications to be able to certify someone else. 3 certs.
cert_min_received_cert_to_issue_cert: 3
# Validity duration of a certification, 2102400 blocks = 146 days.
cert_validity_period: 2102400
# Validity duration of a membership. 1051200 blocks = 73 days.
membership_period: 1051200
# Period to wait before membership renewal. 1051200 blocks = 1 days.
membership_renewal_period: 14400
# Delay a new member must observe before being able to emit a certification
wot_first_cert_issuable_on: 0
# Number of required received certs to become a member
wot_min_cert_for_membership: 3
# Duration to wait between two identity creations. 14400 blocks = 24h = 1 day. (equal to cert_period)
idty_creation_period: 14400
# Window to confirm an identity, in blocks. 14400 blocks = 24h = 1 day.
idty_confirm_period: 14400
# Number of required received certs to be able to create identities
wot_min_cert_for_create_idty_right: 3
# ----- SMITH WOT -----
# Maximum quantity of currently valid certifications emitted by a same issuer. 15 certs.
smith_cert_max_by_issuer: 15
# Maximum duration a smith can be offline without being excluded
smith_inactivity_max_duration: 336
# Number of required received smith certs to become a smith member
smith_wot_min_cert_for_membership: 2
# Clique Smith WoT: each smith will certify by each other smith automatically on Genesis
clique_smiths:
- name: "Pini"
- name: "moul"
- name: "HugoTrentesaux"
- name: "tuxmain"
- name: "1000i100"
- name: "vit"
- name: "cgeek"
# This smith will be the first author
session_keys: "0xec6d7141864ca265b1c31a164d258e907e044380ac110c57502135943904137f5a172f9a6759763f59a7e0a4d170b467b744eabb3adb454f38a2e7957fb9cd285a172f9a6759763f59a7e0a4d170b467b744eabb3adb454f38a2e7957fb9cd285a172f9a6759763f59a7e0a4d170b467b744eabb3adb454f38a2e7957fb9cd28"
sudo_key: "5CfodrEFe64MJtWvfhTHYBuUySr4WXLv2B41mZFucTXSGMFA"
# The address which will automatically transfer 1,00 ĞD on Genesis to the Treasury
treasury_funder_pubkey: "2ny7YAdmzReQxAayyJZsyVYwYhVyax2thKcGknmQy5nQ"
# The technical committee members, to act as sudo
technical_committee:
["Pini", "moul", "HugoTrentesaux", "tuxmain", "Maaltir", "vit", "cgeek", "poka"]
# 10,00 ĞT per UD
ud: 1000
# FIXME: explain `null` meaning
first_ud: null
# FIXME: explain `null` meaning
first_ud_reeval: null
# Clique Smith WoT: each smith will certify by each other smith automatically on Genesis
clique_smiths:
- name: "moul"
- name: "HugoTrentesaux"
- name: "tuxmain"
- name: "1000i100"
- name: "vit"
- name: "cgeek"
- name: "Elois"
# This smith will be the first author
session_keys: "0xbd6d9041890bbf56fa5cb30c3db1b41f7cbf07b04b8a5cf1fb63d79b2029751ecc668b4c0fedf4fd7ac8e44014ffbe16a03b5f55274ac0b94e04e3a0a1fda70ccc668b4c0fedf4fd7ac8e44014ffbe16a03b5f55274ac0b94e04e3a0a1fda70ccc668b4c0fedf4fd7ac8e44014ffbe16a03b5f55274ac0b94e04e3a0a1fda70c"
# FIXME
sudo_key: "5Hm8sBbwuLAU99dBezvgtnRmZCrUy9mhqmbQMFyGTaeATYg7"
# The address which will automatically transfer 1,00 ĞD on Genesis to the Treasury
treasury_funder_pubkey: "2ny7YAdmzReQxAayyJZsyVYwYhVyax2thKcGknmQy5nQ"
# The technical committee members, to act as sudo
technical_committee: ["moul", "HugoTrentesaux", "tuxmain", "1000i100", "vit", "cgeek", "Elois"]