diff --git a/client/tests/integration/smartcontracts/mint_rose_trigger_args/src/lib.rs b/client/tests/integration/smartcontracts/mint_rose_trigger_args/src/lib.rs index eda3d291902..41a35db8a6b 100644 --- a/client/tests/integration/smartcontracts/mint_rose_trigger_args/src/lib.rs +++ b/client/tests/integration/smartcontracts/mint_rose_trigger_args/src/lib.rs @@ -10,7 +10,6 @@ use core::str::FromStr as _; use executor_custom_data_model::mint_rose_args::MintRoseArgs; use iroha_trigger::{debug::dbg_panic, prelude::*}; use lol_alloc::{FreeListAllocator, LockedAllocator}; -use serde::{Deserialize, Serialize}; #[global_allocator] static ALLOC: LockedAllocator = LockedAllocator::new(FreeListAllocator::new()); diff --git a/configs/swarm/executor.wasm b/configs/swarm/executor.wasm index 22eeb3f283f..1cc29162a85 100644 Binary files a/configs/swarm/executor.wasm and b/configs/swarm/executor.wasm differ diff --git a/core/src/smartcontracts/isi/triggers/mod.rs b/core/src/smartcontracts/isi/triggers/mod.rs index a6950a792ab..62e2d1d259c 100644 --- a/core/src/smartcontracts/isi/triggers/mod.rs +++ b/core/src/smartcontracts/isi/triggers/mod.rs @@ -13,8 +13,6 @@ pub mod specialized; /// - TODO: authorities. /// - TODO: authority permissions. pub mod isi { - use std::time::Duration; - use iroha_data_model::{ events::EventFilter, isi::error::{InvalidParameterError, RepetitionError}, @@ -42,11 +40,12 @@ pub mod isi { } let last_block_estimation = state_transaction.latest_block().map(|block| { - block.header().creation_time() - + Duration::from_millis(block.header().consensus_estimation_ms) + block.header().creation_time() + block.header().consensus_estimation() }); let engine = state_transaction.engine.clone(); // Cloning engine is cheap + let genesis_creation_time_ms = state_transaction.world().genesis_creation_time_ms(); + let triggers = &mut state_transaction.world.triggers; let trigger_id = new_trigger.id().clone(); let success = match &new_trigger.action.filter { @@ -65,20 +64,24 @@ pub mod isi { TriggeringEventFilterBox::Time(time_filter) => { if let ExecutionTime::Schedule(schedule) = time_filter.0 { match last_block_estimation { - // We're in genesis + // Genesis block None => { - return Err(Error::InvalidParameter( - InvalidParameterError::TimeTriggerInThePast, - )); + let genesis_creation_time_ms = genesis_creation_time_ms + .expect("INTERNAL BUG: genesis creation time not set"); + + if schedule.start_ms < genesis_creation_time_ms { + return Err(Error::InvalidParameter( + InvalidParameterError::TimeTriggerInThePast, + )); + } } - Some(latest_block_estimation) - if schedule.start < latest_block_estimation => - { - return Err(Error::InvalidParameter( - InvalidParameterError::TimeTriggerInThePast, - )); + Some(latest_block_estimation) => { + if schedule.start() < latest_block_estimation { + return Err(Error::InvalidParameter( + InvalidParameterError::TimeTriggerInThePast, + )); + } } - Some(_) => (), } } triggers.add_time_trigger( diff --git a/core/src/state.rs b/core/src/state.rs index 8575de56543..4b138674fd8 100644 --- a/core/src/state.rs +++ b/core/src/state.rs @@ -121,6 +121,8 @@ pub struct WorldBlock<'world> { pub(crate) executor_data_model: CellBlock<'world, ExecutorDataModel>, /// Events produced during execution of block events_buffer: Vec, + + pub(crate) genesis_creation_time_ms: Option, } /// Struct for single transaction's aggregated changes @@ -155,6 +157,8 @@ pub struct WorldTransaction<'block, 'world> { pub(crate) executor_data_model: CellTransaction<'block, 'world, ExecutorDataModel>, /// Events produced during execution of a transaction events_buffer: TransactionEventBuffer<'block>, + + pub(crate) genesis_creation_time_ms: Option, } /// Wrapper for event's buffer to apply transaction rollback @@ -193,6 +197,8 @@ pub struct WorldView<'world> { pub(crate) executor: CellView<'world, Executor>, /// Executor-defined data model pub(crate) executor_data_model: CellView<'world, ExecutorDataModel>, + + pub(crate) genesis_creation_time_ms: Option, } /// Current state of the blockchain @@ -356,6 +362,8 @@ impl World { executor: self.executor.block(), executor_data_model: self.executor_data_model.block(), events_buffer: Vec::new(), + + genesis_creation_time_ms: None, } } @@ -376,6 +384,8 @@ impl World { executor: self.executor.block_and_revert(), executor_data_model: self.executor_data_model.block_and_revert(), events_buffer: Vec::new(), + + genesis_creation_time_ms: None, } } @@ -395,6 +405,8 @@ impl World { triggers: self.triggers.view(), executor: self.executor.view(), executor_data_model: self.executor_data_model.view(), + + genesis_creation_time_ms: None, } } } @@ -416,6 +428,8 @@ pub trait WorldReadOnly { fn executor(&self) -> &Executor; fn executor_data_model(&self) -> &ExecutorDataModel; + fn genesis_creation_time_ms(&self) -> Option; + // Domain-related methods /// Get `Domain` without an ability to modify it. @@ -698,6 +712,10 @@ macro_rules! impl_world_ro { fn executor_data_model(&self) -> &ExecutorDataModel { &self.executor_data_model } + + fn genesis_creation_time_ms(&self) -> Option { + self.genesis_creation_time_ms + } } )*}; } @@ -710,6 +728,8 @@ impl<'world> WorldBlock<'world> { /// Create struct to apply transaction's changes pub fn trasaction(&mut self) -> WorldTransaction<'_, 'world> { WorldTransaction { + genesis_creation_time_ms: self.genesis_creation_time_ms(), + parameters: self.parameters.transaction(), trusted_peers_ids: self.trusted_peers_ids.transaction(), domains: self.domains.transaction(), @@ -1367,16 +1387,13 @@ impl<'state> StateBlock<'state> { let prev_interval = self.latest_block().map(|latest_block| { let header = &latest_block.as_ref().header(); - TimeInterval { - since: header.creation_time(), - length: header.consensus_estimation(), - } + TimeInterval::new(header.creation_time(), header.consensus_estimation()) }); - let interval = TimeInterval { - since: block.as_ref().header().creation_time(), - length: block.as_ref().header().consensus_estimation(), - }; + let interval = TimeInterval::new( + block.as_ref().header().creation_time(), + block.as_ref().header().consensus_estimation(), + ); TimeEvent { prev_interval, diff --git a/core/src/sumeragi/main_loop.rs b/core/src/sumeragi/main_loop.rs index 45e41276a5c..c368f48afd2 100644 --- a/core/src/sumeragi/main_loop.rs +++ b/core/src/sumeragi/main_loop.rs @@ -226,6 +226,8 @@ impl Sumeragi { }; let mut state_block = state.block(); + state_block.world.genesis_creation_time_ms = + Some(block.header().creation_time_ms); let block = match ValidBlock::validate( block, &self.topology, @@ -289,6 +291,7 @@ impl Sumeragi { } let mut state_block = state.block(); + state_block.world.genesis_creation_time_ms = Some(genesis.0.header().creation_time_ms); let genesis = ValidBlock::validate( genesis.0, &self.topology, diff --git a/core/src/sumeragi/mod.rs b/core/src/sumeragi/mod.rs index 42a7921a617..fd098c005dc 100644 --- a/core/src/sumeragi/mod.rs +++ b/core/src/sumeragi/mod.rs @@ -82,6 +82,10 @@ impl SumeragiHandle { // NOTE: topology need to be updated up to block's view_change_index topology.nth_rotation(block.header().view_change_index as usize); + if block.header().is_genesis() { + state_block.world.genesis_creation_time_ms = Some(block.header().creation_time_ms); + } + let block = ValidBlock::validate( block.clone(), topology, diff --git a/data_model/src/block.rs b/data_model/src/block.rs index b9b60110e86..9a5c21b3824 100644 --- a/data_model/src/block.rs +++ b/data_model/src/block.rs @@ -295,7 +295,7 @@ impl SignedBlock { .expect("Tree is not empty"); let first_transaction = &genesis_transactions[0]; let creation_time_ms = u64::try_from(first_transaction.creation_time().as_millis()) - .expect("Must fit since Duration was created from u64 in creation_time()"); + .expect("INTERNAL BUG: Unix timestamp exceedes u64::MAX"); let header = BlockHeader { height: nonzero!(1_u64), prev_block_hash: None, diff --git a/data_model/src/events/time.rs b/data_model/src/events/time.rs index 46bd80e5bc8..e01c101b464 100644 --- a/data_model/src/events/time.rs +++ b/data_model/src/events/time.rs @@ -99,9 +99,9 @@ mod model { )] pub struct Schedule { /// The first execution time - pub start: Duration, + pub start_ms: u64, /// If some, the period between cyclic executions - pub period: Option, + pub period_ms: Option, } /// Time interval in which `TimeAction` should appear @@ -113,7 +113,6 @@ mod model { Eq, PartialOrd, Ord, - Getters, Decode, Encode, Deserialize, @@ -121,13 +120,12 @@ mod model { IntoSchema, )] // TODO: Figure out how to serialize duration - // #[getset(get = "pub")] #[ffi_type] pub struct TimeInterval { /// The start of a time interval - pub since: Duration, + pub since_ms: u64, /// The length of a time interval - pub length: Duration, + pub length_ms: u64, } } @@ -145,7 +143,7 @@ impl EventFilter for TimeEventFilter { ExecutionTime::PreCommit => 1, ExecutionTime::Schedule(schedule) => { // Prevent matching in the future it will be handled by the next block - if schedule.start > event.interval.since { + if schedule.start() > event.interval.since() { return 0; } @@ -175,15 +173,15 @@ impl EventFilter for TimeEventFilter { // // Schedule start is after current block (c1). // In this case event won't match and it will be handled in the next block. - let since = if Range::from(prev).contains(&schedule.start) { - schedule.start + let since = if Range::from(prev).contains(&schedule.start()) { + schedule.start() } else { - prev.since + prev.length + prev.since() + prev.length() }; - let estimation = event.interval.since + event.interval.length; + let estimation = event.interval.since() + event.interval.length(); let length = estimation - since; - TimeInterval { since, length } + TimeInterval::new(since, length) }); count_matches_in_interval(schedule, ¤t_interval) @@ -194,7 +192,10 @@ impl EventFilter for TimeEventFilter { fn mintable(&self) -> bool { !matches!( self.0, - ExecutionTime::Schedule(Schedule { period: None, .. }) + ExecutionTime::Schedule(Schedule { + period_ms: None, + .. + }) ) } } @@ -202,16 +203,20 @@ impl EventFilter for TimeEventFilter { /// Count something with the `schedule` within the `interval` #[cfg(feature = "transparent_api")] fn count_matches_in_interval(schedule: &Schedule, interval: &TimeInterval) -> u32 { - schedule.period.map_or_else( - || u32::from(Range::from(*interval).contains(&schedule.start)), + schedule.period().map_or_else( + || u32::from(Range::from(*interval).contains(&schedule.start())), |period| { #[allow(clippy::integer_division)] - let k = interval.since.saturating_sub(schedule.start).as_millis() / period.as_millis(); - let start = schedule.start + multiply_duration_by_u128(period, k); + let k = interval + .since() + .saturating_sub(schedule.start()) + .as_millis() + / period.as_millis(); + let start = schedule.start() + multiply_duration_by_u128(period, k); let range = Range::from(*interval); (0..) .map(|i| start + period * i) - .skip_while(|time| *time < interval.since) + .skip_while(|time| *time < interval.since()) .take_while(|time| range.contains(time)) .count() .try_into() @@ -248,38 +253,70 @@ impl Schedule { /// Create new [`Schedule`] starting at `start` and without period #[must_use] #[inline] - pub const fn starting_at(start: Duration) -> Self { + pub fn starting_at(start: Duration) -> Self { Self { - start, - period: None, + start_ms: start + .as_millis() + .try_into() + .expect("INTERNAL BUG: Unix timestamp exceedes u64::MAX"), + period_ms: None, } } /// Add `period` to `self` #[must_use] #[inline] - pub const fn with_period(mut self, period: Duration) -> Self { - self.period = Some(period); + pub fn with_period(mut self, period: Duration) -> Self { + self.period_ms = Some( + period + .as_millis() + .try_into() + .expect("INTERNAL BUG: Unix timestamp exceedes u64::MAX"), + ); self } + + /// Instant of the first execution + pub fn start(&self) -> Duration { + Duration::from_millis(self.start_ms) + } + + /// Period of repeated executions + pub fn period(&self) -> Option { + self.period_ms.map(Duration::from_millis) + } } impl TimeInterval { - /// Getter for `since` - pub fn since(&self) -> &Duration { - &self.since + /// Create new [`Self`] + pub fn new(since: Duration, length: Duration) -> Self { + Self { + since_ms: since + .as_millis() + .try_into() + .expect("INTERNAL BUG: Unix timestamp exceedes u64::MAX"), + length_ms: length + .as_millis() + .try_into() + .expect("INTERNAL BUG: Unix timestamp exceedes u64::MAX"), + } + } + + /// Instant of the previous execution + pub fn since(&self) -> Duration { + Duration::from_millis(self.since_ms) } - /// Getter for `length` - pub fn length(&self) -> &Duration { - &self.length + /// Time since the previous execution + pub fn length(&self) -> Duration { + Duration::from_millis(self.length_ms) } } impl From for Range { #[inline] fn from(interval: TimeInterval) -> Self { - interval.since..interval.since + interval.length + interval.since()..interval.since() + interval.length() } } @@ -310,7 +347,7 @@ mod tests { let schedule = Schedule::starting_at(Duration::from_secs(TIMESTAMP - 5)); let since = Duration::from_secs(TIMESTAMP); let length = Duration::from_secs(10); - let interval = TimeInterval { since, length }; + let interval = TimeInterval::new(since, length); assert_eq!(count_matches_in_interval(&schedule, &interval), 0); } @@ -323,7 +360,7 @@ mod tests { let schedule = Schedule::starting_at(Duration::from_secs(TIMESTAMP)); let since = Duration::from_secs(TIMESTAMP); let length = Duration::from_secs(10); - let interval = TimeInterval { since, length }; + let interval = TimeInterval::new(since, length); assert_eq!(count_matches_in_interval(&schedule, &interval), 1); } @@ -335,7 +372,7 @@ mod tests { let schedule = Schedule::starting_at(Duration::from_secs(TIMESTAMP + 5)); let since = Duration::from_secs(TIMESTAMP); let length = Duration::from_secs(10); - let interval = TimeInterval { since, length }; + let interval = TimeInterval::new(since, length); assert_eq!(count_matches_in_interval(&schedule, &interval), 1); } @@ -348,7 +385,7 @@ mod tests { let schedule = Schedule::starting_at(Duration::from_secs(TIMESTAMP + 10)); let since = Duration::from_secs(TIMESTAMP); let length = Duration::from_secs(10); - let interval = TimeInterval { since, length }; + let interval = TimeInterval::new(since, length); assert_eq!(count_matches_in_interval(&schedule, &interval), 0); } @@ -361,7 +398,7 @@ mod tests { .with_period(Duration::from_secs(30)); let since = Duration::from_secs(TIMESTAMP); let length = Duration::from_secs(10); - let interval = TimeInterval { since, length }; + let interval = TimeInterval::new(since, length); assert_eq!(count_matches_in_interval(&schedule, &interval), 1); } @@ -374,7 +411,7 @@ mod tests { .with_period(Duration::from_secs(10)); let since = Duration::from_secs(TIMESTAMP + 35); let length = Duration::from_secs(4); - let interval = TimeInterval { since, length }; + let interval = TimeInterval::new(since, length); assert_eq!(count_matches_in_interval(&schedule, &interval), 0); } @@ -387,7 +424,7 @@ mod tests { .with_period(Duration::from_secs(6)); let since = Duration::from_secs(TIMESTAMP - 10); let length = Duration::from_secs(4); - let interval = TimeInterval { since, length }; + let interval = TimeInterval::new(since, length); assert_eq!(count_matches_in_interval(&schedule, &interval), 0); } @@ -400,7 +437,7 @@ mod tests { .with_period(Duration::from_secs(6)); let since = Duration::from_secs(TIMESTAMP - 10); let length = Duration::from_secs(30); - let interval = TimeInterval { since, length }; + let interval = TimeInterval::new(since, length); assert_eq!(count_matches_in_interval(&schedule, &interval), 4); } @@ -413,7 +450,7 @@ mod tests { .with_period(Duration::from_millis(600)); let since = Duration::from_secs(TIMESTAMP + 3) + Duration::from_millis(500); let length = Duration::from_secs(2); - let interval = TimeInterval { since, length }; + let interval = TimeInterval::new(since, length); assert_eq!(count_matches_in_interval(&schedule, &interval), 4); } @@ -427,7 +464,7 @@ mod tests { .with_period(Duration::from_secs(10)); let since = Duration::from_secs(TIMESTAMP); let length = Duration::from_secs(5); - let interval = TimeInterval { since, length }; + let interval = TimeInterval::new(since, length); assert_eq!(count_matches_in_interval(&schedule, &interval), 1); } @@ -441,7 +478,7 @@ mod tests { .with_period(Duration::from_secs(5)); let since = Duration::from_secs(TIMESTAMP - 10); let length = Duration::from_secs(15); - let interval = TimeInterval { since, length }; + let interval = TimeInterval::new(since, length); assert_eq!(count_matches_in_interval(&schedule, &interval), 1); } @@ -455,7 +492,7 @@ mod tests { .with_period(Duration::from_secs(15)); let since = Duration::from_secs(TIMESTAMP); let length = Duration::from_secs(5); - let interval = TimeInterval { since, length }; + let interval = TimeInterval::new(since, length); assert_eq!(count_matches_in_interval(&schedule, &interval), 0); } @@ -469,7 +506,7 @@ mod tests { .with_period(Duration::from_secs(1)); let since = Duration::from_secs(TIMESTAMP); let length = Duration::from_secs(7); - let interval = TimeInterval { since, length }; + let interval = TimeInterval::new(since, length); assert_eq!(count_matches_in_interval(&schedule, &interval), 7); } } @@ -490,11 +527,11 @@ mod tests { let since = Duration::from_secs(TIMESTAMP + 5); let length = Duration::from_secs(10); - let prev_interval = TimeInterval { since, length }; + let prev_interval = TimeInterval::new(since, length); let since = Duration::from_secs(TIMESTAMP + 25); let length = Duration::from_secs(10); - let interval = TimeInterval { since, length }; + let interval = TimeInterval::new(since, length); let event = TimeEvent { prev_interval: Some(prev_interval), @@ -516,11 +553,11 @@ mod tests { let since = Duration::from_secs(TIMESTAMP); let length = Duration::from_secs(10); - let prev_interval = TimeInterval { since, length }; + let prev_interval = TimeInterval::new(since, length); let since = Duration::from_secs(TIMESTAMP + 20); let length = Duration::from_secs(10); - let interval = TimeInterval { since, length }; + let interval = TimeInterval::new(since, length); let event = TimeEvent { prev_interval: Some(prev_interval), @@ -542,11 +579,11 @@ mod tests { let since = Duration::from_secs(TIMESTAMP); let length = Duration::from_secs(10); - let prev_interval = TimeInterval { since, length }; + let prev_interval = TimeInterval::new(since, length); let since = Duration::from_secs(TIMESTAMP + 20); let length = Duration::from_secs(10); - let interval = TimeInterval { since, length }; + let interval = TimeInterval::new(since, length); let event = TimeEvent { prev_interval: Some(prev_interval), @@ -568,11 +605,11 @@ mod tests { let since = Duration::from_secs(TIMESTAMP); let length = Duration::from_secs(10); - let prev_interval = TimeInterval { since, length }; + let prev_interval = TimeInterval::new(since, length); let since = Duration::from_secs(TIMESTAMP + 20); let length = Duration::from_secs(10); - let interval = TimeInterval { since, length }; + let interval = TimeInterval::new(since, length); let event = TimeEvent { prev_interval: Some(prev_interval), @@ -594,11 +631,11 @@ mod tests { let since = Duration::from_secs(TIMESTAMP); let length = Duration::from_secs(10); - let prev_interval = TimeInterval { since, length }; + let prev_interval = TimeInterval::new(since, length); let since = Duration::from_secs(TIMESTAMP + 20); let length = Duration::from_secs(10); - let interval = TimeInterval { since, length }; + let interval = TimeInterval::new(since, length); let event = TimeEvent { prev_interval: Some(prev_interval), diff --git a/data_model/src/transaction.rs b/data_model/src/transaction.rs index 19a5b97c60a..cc55718e155 100644 --- a/data_model/src/transaction.rs +++ b/data_model/src/transaction.rs @@ -635,7 +635,7 @@ mod http { .get_unix_time() .as_millis() .try_into() - .expect("Unix timestamp exceedes u64::MAX"); + .expect("INTERNAL BUG: Unix timestamp exceedes u64::MAX"); Self::new_with_time(chain_id, authority, creation_time_ms) } @@ -652,7 +652,7 @@ mod http { .expect("Failed to get the current system time") .as_millis() .try_into() - .expect("Unix timestamp exceedes u64::MAX"); + .expect("INTERNAL BUG: Unix timestamp exceedes u64::MAX"); Self::new_with_time(chain_id, authority, creation_time_ms) } } @@ -700,7 +700,7 @@ mod http { let ttl: u64 = time_to_live .as_millis() .try_into() - .expect("Unix timestamp exceedes u64::MAX"); + .expect("INTERNAL BUG: Unix timestamp exceedes u64::MAX"); self.payload.time_to_live_ms = if ttl == 0 { // TODO: This is not correct, 0 is not the same as None @@ -714,8 +714,8 @@ mod http { /// Set creation time of transaction pub fn set_creation_time(&mut self, value: Duration) -> &mut Self { - self.payload.creation_time_ms = - u64::try_from(value.as_millis()).expect("should never exceed u64"); + self.payload.creation_time_ms = u64::try_from(value.as_millis()) + .expect("INTERNAL BUG: Unix timestamp exceedes u64::MAX"); self } diff --git a/docs/source/references/schema.json b/docs/source/references/schema.json index 65ed5f1a562..41442085923 100644 --- a/docs/source/references/schema.json +++ b/docs/source/references/schema.json @@ -1282,12 +1282,6 @@ } ] }, - "Duration": { - "Tuple": [ - "u64", - "u32" - ] - }, "EventBox": { "Enum": [ { @@ -2577,9 +2571,6 @@ "Option": { "Option": "DomainId" }, - "Option": { - "Option": "Duration" - }, "Option>": { "Option": "HashOf" }, @@ -2631,6 +2622,9 @@ "Option": { "Option": "u32" }, + "Option": { + "Option": "u64" + }, "Pagination": { "Struct": [ { @@ -3535,12 +3529,12 @@ "Schedule": { "Struct": [ { - "name": "start", - "type": "Duration" + "name": "start_ms", + "type": "u64" }, { - "name": "period", - "type": "Option" + "name": "period_ms", + "type": "Option" } ] }, @@ -3935,12 +3929,12 @@ "TimeInterval": { "Struct": [ { - "name": "since", - "type": "Duration" + "name": "since_ms", + "type": "u64" }, { - "name": "length", - "type": "Duration" + "name": "length_ms", + "type": "u64" } ] }, diff --git a/schema/gen/src/lib.rs b/schema/gen/src/lib.rs index 4de30ede387..83ca017e11e 100644 --- a/schema/gen/src/lib.rs +++ b/schema/gen/src/lib.rs @@ -167,7 +167,6 @@ types!( DomainEventSet, DomainId, DomainOwnerChanged, - Duration, EventBox, EventFilterBox, EventMessage, @@ -278,7 +277,6 @@ types!( Option, Option, Option, - Option, Option>, Option>, Option, @@ -296,6 +294,7 @@ types!( Option, Option, Option, + Option, Pagination, Parameter, ParameterChanged, @@ -418,6 +417,7 @@ types!( Vec, Vec, Vec, + Vec, Vec, Vec, Vec, @@ -440,10 +440,7 @@ pub mod complete_data_model { //! Complete set of types participating in the schema pub use core::num::{NonZeroU32, NonZeroU64}; - pub use std::{ - collections::{BTreeMap, BTreeSet, HashMap, HashSet}, - time::Duration, - }; + pub use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet}; pub use iroha_crypto::*; pub use iroha_data_model::{ diff --git a/schema/src/lib.rs b/schema/src/lib.rs index 8d1736d04d2..f3047a14aae 100644 --- a/schema/src/lib.rs +++ b/schema/src/lib.rs @@ -506,31 +506,6 @@ impl IntoSchema for btree_set::BTreeSet { } } -impl TypeId for core::time::Duration { - fn id() -> String { - "Duration".to_owned() - } -} -impl IntoSchema for core::time::Duration { - fn type_name() -> String { - "Duration".to_owned() - } - // Look at: https://docs.rs/parity-scale-codec/2.1.1/src/parity_scale_codec/codec.rs.html#1182-1192 - fn update_schema_map(map: &mut MetaMap) { - if !map.contains_key::() { - map.insert::(Metadata::Tuple(UnnamedFieldsMeta { - types: vec![ - core::any::TypeId::of::(), - core::any::TypeId::of::(), - ], - })); - - u32::update_schema_map(map); - u64::update_schema_map(map); - } - } -} - impl TypeId for [T; L] { fn id() -> String { format!("Array<{}, {}>", T::id(), L) diff --git a/tools/parity_scale_cli/src/main.rs b/tools/parity_scale_cli/src/main.rs index 06ff793d7d4..c68cb4c8589 100644 --- a/tools/parity_scale_cli/src/main.rs +++ b/tools/parity_scale_cli/src/main.rs @@ -9,7 +9,6 @@ use std::{ io::{BufRead, BufReader, BufWriter, Read, Write}, marker::PhantomData, path::PathBuf, - time::Duration, }; use clap::Parser;