diff --git a/ethexe/rpc/Cargo.toml b/ethexe/rpc/Cargo.toml index 352851766b7..8cf8f0bf0c2 100644 --- a/ethexe/rpc/Cargo.toml +++ b/ethexe/rpc/Cargo.toml @@ -23,7 +23,7 @@ log.workspace = true parity-scale-codec.workspace = true hex.workspace = true ethexe-common.workspace = true -ethexe-runtime-common.workspace = true +ethexe-runtime-common = { workspace = true, features = ["std"] } sp-core = { workspace = true, features = ["serde"] } gear-core = { workspace = true, features = ["std"] } -serde.workspace = true +serde = { workspace = true, features = ["std"] } diff --git a/ethexe/runtime/common/Cargo.toml b/ethexe/runtime/common/Cargo.toml index a03d747918d..aafd1a08a9a 100644 --- a/ethexe/runtime/common/Cargo.toml +++ b/ethexe/runtime/common/Cargo.toml @@ -13,7 +13,7 @@ ethexe-common.workspace = true gear-lazy-pages-common.workspace = true core-processor.workspace = true -gear-core = { workspace = true, features = ["std"] } +gear-core.workspace = true gprimitives.workspace = true gsys.workspace = true gear-core-errors.workspace = true @@ -21,8 +21,15 @@ gear-core-errors.workspace = true anyhow.workspace = true parity-scale-codec.workspace = true log.workspace = true -serde.workspace = true +serde = { workspace = true, features = ["derive"], optional = true } [features] default = ["std"] -std = ["anyhow/std", "core-processor/std", "log/std"] +std = [ + "anyhow/std", + "core-processor/std", + "gear-core/std", + "gprimitives/serde", + "log/std", + "serde/std", +] diff --git a/ethexe/runtime/common/src/state.rs b/ethexe/runtime/common/src/state.rs index 0959e09d6c2..7f6f5e6c1f2 100644 --- a/ethexe/runtime/common/src/state.rs +++ b/ethexe/runtime/common/src/state.rs @@ -41,14 +41,14 @@ use gear_core_errors::ReplyCode; use gprimitives::{ActorId, CodeId, MessageId, H256}; use gsys::BlockNumber; use parity_scale_codec::{Decode, Encode}; -use serde::{Deserialize, Serialize}; pub use gear_core::program::ProgramState as InitStatus; /// 3h validity in mailbox for 12s blocks. pub const MAILBOX_VALIDITY: u32 = 54_000; -#[derive(Clone, Debug, Encode, Decode, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Clone, Debug, Encode, Decode, PartialEq, Eq)] +#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] pub struct HashAndLen { pub hash: H256, pub len: NonZero, @@ -64,7 +64,8 @@ impl From for HashAndLen { } } -#[derive(Clone, Debug, Encode, Decode, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Clone, Debug, Encode, Decode, PartialEq, Eq)] +#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] pub enum MaybeHash { Hash(HashAndLen), Empty, @@ -102,7 +103,8 @@ impl MaybeHash { } } -#[derive(Clone, Debug, Decode, Encode, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Clone, Debug, Decode, Encode, PartialEq, Eq)] +#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] pub struct ActiveProgram { /// Hash of wasm memory pages allocations, see [`Allocations`]. pub allocations_hash: MaybeHash, @@ -114,7 +116,8 @@ pub struct ActiveProgram { pub initialized: bool, } -#[derive(Clone, Debug, Decode, Encode, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Clone, Debug, Decode, Encode, PartialEq, Eq)] +#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] pub enum Program { Active(ActiveProgram), Exited(ProgramId), @@ -138,7 +141,8 @@ impl Program { } /// ethexe program state. -#[derive(Clone, Debug, Decode, Encode, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Clone, Debug, Decode, Encode, PartialEq, Eq)] +#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] pub struct ProgramState { /// Active, exited or terminated program state. pub program: Program, @@ -193,7 +197,8 @@ impl ProgramState { } } -#[derive(Clone, Debug, Encode, Decode, Serialize, Deserialize)] +#[derive(Clone, Debug, Encode, Decode)] +#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] pub struct Dispatch { /// Message id. pub id: MessageId,