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
Loading items

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
Loading items
Show changes
// Copyright 2021 Axiom-Team
//
// This file is part of Substrate-Libre-Currency.
// This file is part of Duniter-v2S.
//
// Substrate-Libre-Currency is free software: you can redistribute it and/or modify
// 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.
//
// Substrate-Libre-Currency is distributed in the hope that it will be useful,
// 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 Substrate-Libre-Currency. If not, see <https://www.gnu.org/licenses/>.
// along with Duniter-v2S. If not, see <https://www.gnu.org/licenses/>.
//! Defines types and traits for users of pallet membership.
......@@ -22,29 +22,47 @@
pub mod traits;
use codec::{Decode, Encode};
use frame_support::RuntimeDebug;
use frame_support::pallet_prelude::{RuntimeDebug, Weight};
use scale_info::TypeInfo;
#[cfg(feature = "std")]
use serde::{Deserialize, Serialize};
pub enum Event<IdtyId, MetaData = ()> {
/// A membership has acquired
MembershipAcquired(IdtyId, MetaData),
/// A membership has expired
MembershipExpired(IdtyId),
/// A membership has renewed
/// Represent membership-related events.
pub enum Event<IdtyId> {
/// A membership was acquired.
MembershipAdded(IdtyId),
/// A membership was terminated.
MembershipRemoved(IdtyId),
/// A membership was renewed.
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))]
#[derive(Encode, Decode, Default, Clone, Copy, PartialEq, Eq, RuntimeDebug, TypeInfo)]
/// Represent membership data.
#[derive(
Encode,
Decode,
Default,
Clone,
Copy,
PartialEq,
Eq,
RuntimeDebug,
TypeInfo,
Deserialize,
Serialize,
)]
pub struct MembershipData<BlockNumber: Decode + Encode + TypeInfo> {
pub expire_on: BlockNumber,
pub renewable_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()
}
}
// Copyright 2021 Axiom-Team
//
// This file is part of Substrate-Libre-Currency.
// This file is part of Duniter-v2S.
//
// Substrate-Libre-Currency is free software: you can redistribute it and/or modify
// 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.
//
// Substrate-Libre-Currency is distributed in the hope that it will be useful,
// 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 Substrate-Libre-Currency. If not, see <https://www.gnu.org/licenses/>.
// along with Duniter-v2S. If not, see <https://www.gnu.org/licenses/>.
use frame_support::pallet_prelude::Weight;
use frame_support::pallet_prelude::*;
pub trait IsIdtyAllowedToRenewMembership<IdtyId> {
fn is_idty_allowed_to_renew_membership(idty_id: &IdtyId) -> bool;
/// A trait defining operations for checking if membership-related operations are allowed.
pub trait CheckMembershipOpAllowed<IdtyId> {
/// Checks if adding a membership is allowed.
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> IsIdtyAllowedToRenewMembership<IdtyId> for () {
fn is_idty_allowed_to_renew_membership(_: &IdtyId) -> bool {
true
}
}
pub trait IsIdtyAllowedToRequestMembership<IdtyId> {
fn is_idty_allowed_to_request_membership(idty_id: &IdtyId) -> bool;
impl<IdtyId> CheckMembershipOpAllowed<IdtyId> for () {
fn check_add_membership(_: IdtyId) -> Result<(), DispatchError> {
Ok(())
}
impl<IdtyId> IsIdtyAllowedToRequestMembership<IdtyId> for () {
fn is_idty_allowed_to_request_membership(_: &IdtyId) -> bool {
true
fn check_renew_membership(_: IdtyId) -> Result<(), DispatchError> {
Ok(())
}
}
pub trait IsInPendingMemberships<IdtyId> {
fn is_in_pending_memberships(idty_id: IdtyId) -> bool;
/// A trait defining behavior for handling new memberships and membership renewals.
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> {
fn on_event(event: &crate::Event<IdtyId, MetaData>) -> Weight;
}
impl<IdtyId, MetaData> OnEvent<IdtyId, MetaData> for () {
fn on_event(_: &crate::Event<IdtyId, MetaData>) -> Weight {
0
}
/// A trait defining operations for handling the removal of memberships.
pub trait OnRemoveMembership<IdtyId> {
/// Called when a membership is removed.
fn on_removed(idty_index: &IdtyId) -> Weight;
}
/// A trait defining an operation to retrieve the count of members.
pub trait MembersCount {
/// The count of members.
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
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.