Skip to content

Commit

Permalink
perf(workspace): inherit dependencies from workspace for version mana…
Browse files Browse the repository at this point in the history
…gement (#2427)
  • Loading branch information
clearloop authored Apr 3, 2023
1 parent e3fbb48 commit 33b723a
Show file tree
Hide file tree
Showing 209 changed files with 1,765 additions and 1,370 deletions.
120 changes: 48 additions & 72 deletions Cargo.lock

Large diffs are not rendered by default.

293 changes: 293 additions & 0 deletions Cargo.toml

Large diffs are not rendered by default.

38 changes: 16 additions & 22 deletions common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,41 +6,35 @@ edition = "2018"
license = "GPL-3.0"

[dependencies]
codec = { package = "parity-scale-codec", version = "3.4.0", default-features = false, features = ["derive", "max-encoded-len"] }
scale-info = { version = "2.5.0", default-features = false, features = ["derive"] }
primitive-types = { version = "0.12.1", default-features = false, features = ["scale-info"] }
log = "0.4.17"
derive_more = "0.99.17"
primitive-types = { workspace = true, features = ["scale-info"] }
log.workspace = true
derive_more.workspace = true

# Internal deps
gear-core = { path = "../core" }
gear-common-codegen = { path = "./codegen" }
gear-core.workspace = true
gear-common-codegen.workspace = true
gear-wasm-instrument = { workspace = true, optional = true }

# Substrate deps
sp-core = { version = "7.0.0", git = "https://github.com/gear-tech/substrate.git", branch = "gear-polkadot-v0.9.38", default-features = false }
sp-io = { version = "7.0.0", git = "https://github.com/gear-tech/substrate.git", branch = "gear-polkadot-v0.9.38", default-features = false }
sp-runtime = { version = "7.0.0", git = "https://github.com/gear-tech/substrate.git", branch = "gear-polkadot-v0.9.38", default-features = false }
sp-std = { version = "5.0.0", git = "https://github.com/gear-tech/substrate.git", branch = "gear-polkadot-v0.9.38", default-features = false }
sp-arithmetic = { version = "6.0.0", git = "https://github.com/gear-tech/substrate.git", branch = "gear-polkadot-v0.9.38", default-features = false }
frame-support = { version = "4.0.0-dev", git = "https://github.com/gear-tech/substrate.git", branch = "gear-polkadot-v0.9.38", default-features = false }
frame-system = { version = "4.0.0-dev", git = "https://github.com/gear-tech/substrate.git", branch = "gear-polkadot-v0.9.38", default-features = false, optional = true }
frame-benchmarking = { version = "4.0.0-dev", git = "https://github.com/gear-tech/substrate.git", branch = "gear-polkadot-v0.9.38", default-features = false, optional = true }
gear-wasm-instrument = { path = "../utils/wasm-instrument", default-features = false, optional = true }
sp-core.workspace = true
sp-io.workspace = true
sp-std.workspace = true
sp-arithmetic.workspace = true
frame-support.workspace = true
frame-system = { workspace = true, optional = true }
frame-benchmarking = { workspace = true, optional = true }

[dev-dependencies]
hex-literal = "0.3.4"
proptest = "1.1.0"
gear-utils = { path = "../utils/utils" }
hex-literal.workspace = true
proptest.workspace = true
gear-utils.workspace = true

[features]
default = ["std"]
std = [
"codec/std",
"scale-info/std",
"sp-core/std",
"sp-std/std",
"sp-io/std",
"sp-runtime/std",
"sp-arithmetic/std",
"frame-support/std",
"primitive-types/std",
Expand Down
4 changes: 2 additions & 2 deletions common/codegen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ license = "GPL-3.0"
proc-macro = true

[dependencies]
quote = "1.0.23"
syn = "2.0.8"
quote.workspace = true
syn.workspace = true
16 changes: 8 additions & 8 deletions common/lazy-pages/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ edition = "2018"
license = "GPL-3.0"

[dependencies]
derive_more = "0.99.17"
log = { version = "0.4.17", default-features = false }
derive_more.workspace = true
log.workspace = true

gear-core = { path = "../../core" }
gear-backend-common = { path = "../../core-backend/common", default-features = false }
gear-common = { path = "..", default-features = false }
gear-runtime-interface = { path = "../../runtime-interface", default-features = false }
gear-wasm-instrument = { path = "../../utils/wasm-instrument", default-features = false }
gear-core.workspace = true
gear-backend-common.workspace = true
gear-common.workspace = true
gear-runtime-interface.workspace = true
gear-wasm-instrument.workspace = true

sp-std = { version = "5.0.0", git = "https://github.com/gear-tech/substrate.git", branch = "gear-polkadot-v0.9.38", default-features = false }
sp-std.workspace = true

[features]
default = ["std"]
Expand Down
28 changes: 26 additions & 2 deletions common/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,20 @@
//! This module contains components for depositing proper
//! and extensive data about actions happen.

use codec::{Decode, Encode};
use frame_support::{
codec::{self, Decode, Encode},
scale_info::{self, TypeInfo},
};
use gear_core::{ids::MessageId, message::MessageWaitedType};
use primitive_types::H256;
use scale_info::TypeInfo;

/// Programs entry for messages.
///
/// Same as `gear_core::message::DispatchKind`,
/// but with additional info about reply.
#[derive(Debug, Encode, Decode, Clone, PartialEq, Eq, TypeInfo)]
#[codec(crate = codec)]
#[scale_info(crate = scale_info)]
pub enum MessageEntry {
/// Init entry point.
Init,
Expand All @@ -44,6 +48,8 @@ pub enum MessageEntry {

/// Status of dispatch dequeue and execution.
#[derive(Debug, Encode, Decode, Clone, PartialEq, Eq, TypeInfo)]
#[codec(crate = codec)]
#[scale_info(crate = scale_info)]
pub enum DispatchStatus {
/// Dispatch was dequeued and succeed with execution.
Success,
Expand Down Expand Up @@ -78,6 +84,8 @@ impl SystemReason for () {}

/// Composite reason type for any action happened on chain.
#[derive(Debug, Encode, Decode, Clone, PartialEq, Eq, TypeInfo)]
#[codec(crate = codec)]
#[scale_info(crate = scale_info)]
pub enum Reason<R: RuntimeReason, S: SystemReason> {
/// Runtime reason variant.
///
Expand All @@ -93,6 +101,8 @@ pub enum Reason<R: RuntimeReason, S: SystemReason> {

/// Runtime reason for messages waiting.
#[derive(Debug, Encode, Decode, Clone, PartialEq, Eq, TypeInfo, RuntimeReason)]
#[codec(crate = codec)]
#[scale_info(crate = scale_info)]
pub enum MessageWaitedRuntimeReason {
/// Program called `gr_wait` while executing message.
WaitCalled,
Expand All @@ -119,6 +129,8 @@ impl From<MessageWaitedType> for MessageWaitedRuntimeReason {

/// System reason for messages waiting.
#[derive(Debug, Encode, Decode, Clone, PartialEq, Eq, TypeInfo, SystemReason)]
#[codec(crate = codec)]
#[scale_info(crate = scale_info)]
pub enum MessageWaitedSystemReason {
/// Program hadn't finished initialization and can not
/// process received message yet.
Expand All @@ -130,13 +142,17 @@ pub type MessageWaitedReason = Reason<MessageWaitedRuntimeReason, MessageWaitedS

/// Runtime reason for messages waking.
#[derive(Debug, Encode, Decode, Clone, PartialEq, Eq, TypeInfo, RuntimeReason)]
#[codec(crate = codec)]
#[scale_info(crate = scale_info)]
pub enum MessageWokenRuntimeReason {
/// Program called `gr_wake` with corresponding message id.
WakeCalled,
}

/// System reason for messages waking.
#[derive(Debug, Encode, Decode, Clone, PartialEq, Eq, TypeInfo, SystemReason)]
#[codec(crate = codec)]
#[scale_info(crate = scale_info)]
pub enum MessageWokenSystemReason {
/// Program had finished initialization.
///
Expand All @@ -154,6 +170,8 @@ pub type MessageWokenReason = Reason<MessageWokenRuntimeReason, MessageWokenSyst

/// Type of changes applied to code in storage.
#[derive(Debug, Encode, Decode, Clone, PartialEq, Eq, TypeInfo)]
#[codec(crate = codec)]
#[scale_info(crate = scale_info)]
pub enum CodeChangeKind<BlockNumber> {
/// Code become active and ready for use.
///
Expand All @@ -173,6 +191,8 @@ pub enum CodeChangeKind<BlockNumber> {

/// Runtime reason for messages reading from `Mailbox`.
#[derive(Debug, Encode, Decode, Clone, PartialEq, Eq, TypeInfo, RuntimeReason)]
#[codec(crate = codec)]
#[scale_info(crate = scale_info)]
pub enum UserMessageReadRuntimeReason {
/// Message was replied by user.
MessageReplied,
Expand All @@ -182,6 +202,8 @@ pub enum UserMessageReadRuntimeReason {

/// System reason for messages reading from `Mailbox`.
#[derive(Debug, Encode, Decode, Clone, PartialEq, Eq, TypeInfo, SystemReason)]
#[codec(crate = codec)]
#[scale_info(crate = scale_info)]
pub enum UserMessageReadSystemReason {
/// Message can no longer pay rent for holding in storage (see #646).
OutOfRent,
Expand All @@ -192,6 +214,8 @@ pub type UserMessageReadReason = Reason<UserMessageReadRuntimeReason, UserMessag

/// Type of changes applied to program in storage.
#[derive(Debug, Encode, Decode, Clone, PartialEq, Eq, TypeInfo)]
#[codec(crate = codec)]
#[scale_info(crate = scale_info)]
pub enum ProgramChangeKind<BlockNumber> {
/// Active status achieved.
///
Expand Down
5 changes: 3 additions & 2 deletions common/src/gas_provider/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.

use super::*;
use frame_support::{traits::tokens::Balance as BalanceTrait, RuntimeDebug};
use sp_runtime::traits::Zero;
use frame_support::{
sp_runtime::traits::Zero, traits::tokens::Balance as BalanceTrait, RuntimeDebug,
};
use sp_std::marker::PhantomData;

mod error;
Expand Down
8 changes: 7 additions & 1 deletion common/src/gas_provider/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.

use super::*;
use codec::MaxEncodedLen;
use frame_support::{codec, dispatch::MaxEncodedLen, scale_info};
use gear_core::ids::ReservationId;

/// ID of the [`GasNode`].
#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, TypeInfo)]
#[codec(crate = codec)]
#[scale_info(crate = scale_info)]
pub enum GasNodeId<T, U> {
Node(T),
Reservation(U),
Expand Down Expand Up @@ -70,6 +72,8 @@ impl<T> From<ReservationId> for GasNodeId<T, ReservationId> {

/// Node of the ['Tree'] gas tree
#[derive(Clone, Decode, Debug, Encode, MaxEncodedLen, TypeInfo, PartialEq, Eq)]
#[codec(crate = codec)]
#[scale_info(crate = scale_info)]
pub enum GasNode<ExternalId: Clone, Id: Clone, Balance: Zero + Clone> {
/// A root node for each gas tree.
///
Expand Down Expand Up @@ -134,6 +138,8 @@ pub enum GasNode<ExternalId: Clone, Id: Clone, Balance: Zero + Clone> {

/// Children references convenience struct
#[derive(Clone, Copy, Default, Decode, Debug, Encode, MaxEncodedLen, TypeInfo, PartialEq, Eq)]
#[codec(crate = codec)]
#[scale_info(crate = scale_info)]
pub struct ChildrenRefs {
spec_refs: u32,
unspec_refs: u32,
Expand Down
21 changes: 15 additions & 6 deletions common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,16 @@ pub mod gas_provider;
#[cfg(feature = "runtime-benchmarks")]
pub mod benchmarking;

use codec::{Decode, Encode};
use core::fmt;
use frame_support::{
codec::{self, Decode, Encode},
dispatch::DispatchError,
scale_info::{self, TypeInfo},
sp_runtime::{
self,
generic::{CheckedExtrinsic, UncheckedExtrinsic},
traits::{Dispatchable, SignedExtension},
},
traits::Get,
weights::{ConstantMultiplier, Weight, WeightToFee},
};
Expand All @@ -50,13 +56,8 @@ use gear_core::{
reservation::GasReservationMap,
};
use primitive_types::H256;
use scale_info::TypeInfo;
use sp_arithmetic::traits::{BaseArithmetic, Unsigned};
use sp_core::crypto::UncheckedFrom;
use sp_runtime::{
generic::{CheckedExtrinsic, UncheckedExtrinsic},
traits::{Dispatchable, SignedExtension},
};
use sp_std::{
collections::{btree_map::BTreeMap, btree_set::BTreeSet},
prelude::*,
Expand Down Expand Up @@ -180,6 +181,8 @@ pub trait BlockLimiter {
}

#[derive(Clone, Debug, Decode, Encode, PartialEq, Eq, TypeInfo)]
#[codec(crate = codec)]
#[scale_info(crate = scale_info)]
pub enum Program {
Active(ActiveProgram),
Exited(ProgramId),
Expand Down Expand Up @@ -236,6 +239,8 @@ impl core::convert::TryFrom<Program> for ActiveProgram {
}

#[derive(Clone, Debug, Decode, Encode, PartialEq, Eq, TypeInfo)]
#[codec(crate = codec)]
#[scale_info(crate = scale_info)]
pub struct ActiveProgram {
/// Set of dynamic wasm page numbers, which are allocated by the program.
pub allocations: BTreeSet<WasmPage>,
Expand All @@ -250,6 +255,8 @@ pub struct ActiveProgram {

/// Enumeration contains variants for program state.
#[derive(Clone, Debug, Decode, Encode, PartialEq, Eq, TypeInfo)]
#[codec(crate = codec)]
#[scale_info(crate = scale_info)]
pub enum ProgramState {
/// `init` method of a program has not yet finished its execution so
/// the program is not considered as initialized. All messages to such a
Expand All @@ -261,6 +268,8 @@ pub enum ProgramState {
}

#[derive(Clone, Debug, Decode, Encode, PartialEq, Eq, TypeInfo)]
#[codec(crate = codec)]
#[scale_info(crate = scale_info)]
pub struct CodeMetadata {
pub author: H256,
#[codec(compact)]
Expand Down
8 changes: 6 additions & 2 deletions common/src/scheduler/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,18 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

use codec::{Decode, Encode, MaxEncodedLen};
use frame_support::{
codec::{self, Decode, Encode, MaxEncodedLen},
scale_info::{self, TypeInfo},
};
use gear_core::ids::{CodeId, MessageId, ProgramId, ReservationId};
use scale_info::TypeInfo;

/// Scheduled task sense and required data for processing action.
///
/// CAUTION: NEVER ALLOW `ScheduledTask<AccountId>` BE A BIG DATA.
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord, Encode, Decode, TypeInfo, MaxEncodedLen)]
#[codec(crate = codec)]
#[scale_info(crate = scale_info)]
pub enum ScheduledTask<AccountId> {
// Rent charging section.
// -----
Expand Down
8 changes: 6 additions & 2 deletions common/src/storage/complicated/dequeue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@
//! if they present.

use crate::storage::{Callback, Counted, EmptyCallback, IterableMap, MapStorage, ValueStorage};
use codec::{Decode, Encode};
use core::marker::PhantomData;
use scale_info::TypeInfo;
use frame_support::{
codec::{self, Decode, Encode},
scale_info::{self, TypeInfo},
};

/// Represents dequeue implementation.
pub trait Dequeue {
Expand Down Expand Up @@ -137,6 +139,8 @@ where
///
/// Contains value and link to the next node.
#[derive(Encode, Decode, TypeInfo)]
#[codec(crate = codec)]
#[scale_info(crate = scale_info)]
pub struct LinkedNode<K, V> {
/// Key of the next node of dequeue,
/// if present.
Expand Down
2 changes: 1 addition & 1 deletion common/src/storage/primitives/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
//! This primitive defines interface of interaction
//! with globally stored single-key map (Key -> Value).

use codec::{Encode, EncodeAppend, EncodeLike};
use frame_support::codec::{Encode, EncodeAppend, EncodeLike};

/// Represents logic of managing globally stored
/// single-key map for more complicated logic.
Expand Down
8 changes: 6 additions & 2 deletions common/src/storage/primitives/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,15 @@ pub use key::{KeyFor, MailboxKeyGen, QueueKeyGen, WaitlistKeyGen};
pub use map::{AppendMapStorage, MapStorage};
pub use value::ValueStorage;

use codec::{Decode, Encode, MaxEncodedLen};
use scale_info::TypeInfo;
use frame_support::{
codec::{self, Decode, Encode, MaxEncodedLen},
scale_info::{self, TypeInfo},
};

/// Type for interval values: e.g. in time `(since, till)`.
#[derive(Clone, Debug, Decode, Encode, MaxEncodedLen, PartialEq, Eq, PartialOrd, Ord, TypeInfo)]
#[codec(crate = codec)]
#[scale_info(crate = scale_info)]
pub struct Interval<T> {
pub start: T,
pub finish: T,
Expand Down
Loading

0 comments on commit 33b723a

Please sign in to comment.