--- /dev/null +++ b/primitives/common/Cargo.toml @@ -0,0 +1,56 @@ +[package] +authors = ['Unique Network '] +description = 'Unique Runtime Common Primitives' +edition = '2021' +homepage = 'https://unique.network' +license = 'All Rights Reserved' +name = 'up-common' +repository = 'https://github.com/UniqueNetwork/unique-chain' +version = '0.9.24' + +[features] +default = ['std'] +std = [ + 'sp-std/std', + 'frame-support/std', + 'sp-runtime/std', + 'sp-core/std', + 'sp-consensus-aura/std', + 'fp-rpc/std', + 'pallet-evm/std', +] + +[dependencies.sp-std] +default-features = false +git = "https://github.com/paritytech/substrate" +branch = "polkadot-v0.9.24" + +[dependencies.frame-support] +default-features = false +git = "https://github.com/paritytech/substrate" +branch = "polkadot-v0.9.24" + +[dependencies.sp-runtime] +default-features = false +git = "https://github.com/paritytech/substrate" +branch = "polkadot-v0.9.24" + +[dependencies.sp-core] +default-features = false +git = "https://github.com/paritytech/substrate" +branch = "polkadot-v0.9.24" + +[dependencies.sp-consensus-aura] +default-features = false +git = "https://github.com/paritytech/substrate" +branch = "polkadot-v0.9.24" + +[dependencies.fp-rpc] +default-features = false +git = "https://github.com/uniquenetwork/frontier" +branch = "unique-polkadot-v0.9.24" + +[dependencies.pallet-evm] +default-features = false +git = "https://github.com/uniquenetwork/frontier" +branch = "unique-polkadot-v0.9.24" --- /dev/null +++ b/primitives/common/src/constants.rs @@ -0,0 +1,55 @@ +// Copyright 2019-2022 Unique Network (Gibraltar) Ltd. +// This file is part of Unique Network. + +// Unique Network is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Unique Network 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Unique Network. If not, see . + +use sp_runtime::Perbill; +use frame_support::{ + parameter_types, + weights::{Weight, constants::WEIGHT_PER_SECOND}, +}; +use crate::types::{BlockNumber, Balance}; + +pub const MILLISECS_PER_BLOCK: u64 = 12000; + +pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK; + +// These time units are defined in number of blocks. +pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber); +pub const HOURS: BlockNumber = MINUTES * 60; +pub const DAYS: BlockNumber = HOURS * 24; + +pub const MICROUNIQUE: Balance = 1_000_000_000_000; +pub const MILLIUNIQUE: Balance = 1_000 * MICROUNIQUE; +pub const CENTIUNIQUE: Balance = 10 * MILLIUNIQUE; +pub const UNIQUE: Balance = 100 * CENTIUNIQUE; + +// Targeting 0.1 UNQ per transfer +pub const WEIGHT_TO_FEE_COEFF: u32 = 207_890_902; + +// Targeting 0.15 UNQ per transfer via ETH +pub const MIN_GAS_PRICE: u64 = 1_019_493_469_850; + +/// We assume that ~10% of the block weight is consumed by `on_initalize` handlers. +/// This is used to limit the maximal weight of a single extrinsic. +pub const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(10); +/// We allow `Normal` extrinsics to fill up the block up to 75%, the rest can be used +/// by Operational extrinsics. +pub const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75); +/// We allow for 2 seconds of compute with a 6 second average block time. +pub const MAXIMUM_BLOCK_WEIGHT: Weight = WEIGHT_PER_SECOND / 2; + +parameter_types! { + pub const TransactionByteFee: Balance = 501 * MICROUNIQUE; +} --- /dev/null +++ b/primitives/common/src/lib.rs @@ -0,0 +1,20 @@ +// Copyright 2019-2022 Unique Network (Gibraltar) Ltd. +// This file is part of Unique Network. + +// Unique Network is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Unique Network 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Unique Network. If not, see . + +#![cfg_attr(not(feature = "std"), no_std)] + +pub mod constants; +pub mod types; --- /dev/null +++ b/primitives/common/src/types.rs @@ -0,0 +1,81 @@ +// Copyright 2019-2022 Unique Network (Gibraltar) Ltd. +// This file is part of Unique Network. + +// Unique Network is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Unique Network 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Unique Network. If not, see . + +use sp_runtime::{ + generic, + traits::{Verify, IdentifyAccount}, + MultiSignature, +}; + +/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know +/// the specifics of the runtime. They can then be made to be agnostic over specific formats +/// of data like extrinsics, allowing for them to continue syncing the network through upgrades +/// to even the core data structures. +pub mod opaque { + pub use sp_runtime::{generic, traits::BlakeTwo256, OpaqueExtrinsic as UncheckedExtrinsic}; + + pub use super::{BlockNumber, Signature, AccountId, Balance, Index, Hash, AuraId}; + + /// Opaque block header type. + pub type Header = generic::Header; + + /// Opaque block type. + pub type Block = generic::Block; + + pub trait RuntimeInstance { + type CrossAccountId: pallet_evm::account::CrossAccountId + + Send + + Sync + + 'static; + + type TransactionConverter: fp_rpc::ConvertTransaction + + Send + + Sync + + 'static; + + fn get_transaction_converter() -> Self::TransactionConverter; + } +} + +pub type SessionHandlers = (); + +/// An index to a block. +pub type BlockNumber = u32; + +/// Alias to 512-bit hash when used in the context of a transaction signature on the chain. +pub type Signature = MultiSignature; + +/// Some way of identifying an account on the chain. We intentionally make it equivalent +/// to the public key of our transaction signing scheme. +pub type AccountId = <::Signer as IdentifyAccount>::AccountId; + +/// The type for looking up accounts. We don't expect more than 4 billion of them, but you +/// never know... +pub type AccountIndex = u32; + +/// Balance of an account. +pub type Balance = u128; + +/// Index of a transaction in the chain. +pub type Index = u32; + +/// A hash of some data used by the chain. +pub type Hash = sp_core::H256; + +/// Digest item type. +pub type DigestItem = generic::DigestItem; + +pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;