Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: revise NonZeros #5278

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions crates/iroha_cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1581,7 +1581,7 @@ mod multisig {
proposal_status.instructions = proposal_value.instructions;
proposal_status.proposed_at = {
let proposed_at = Duration::from_secs(
Duration::from_millis(proposal_value.proposed_at_ms.into()).as_secs(),
Duration::from_millis(proposal_value.proposed_at_ms).as_secs(),
);
SystemTime::UNIX_EPOCH
.checked_add(proposed_at)
Expand All @@ -1592,7 +1592,7 @@ mod multisig {
let now = SystemTime::now()
.duration_since(SystemTime::UNIX_EPOCH)
.unwrap();
let expires_at = Duration::from_millis(proposal_value.expires_at_ms.into());
let expires_at = Duration::from_millis(proposal_value.expires_at_ms);
Duration::from_secs(expires_at.saturating_sub(now).as_secs()).into()
};
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! Validation and execution logic of instructions for multisig transactions

use alloc::{collections::btree_set::BTreeSet, vec};
use core::num::NonZeroU64;

use iroha_smart_contract::data_model::query::error::QueryExecutionFail;

Expand Down Expand Up @@ -189,15 +188,13 @@ fn proposal_value<V: Execute + Visit + ?Sized>(
.map_err(metadata_conversion_error)
}

fn now_ms<V: Execute + Visit + ?Sized>(executor: &V) -> NonZeroU64 {
fn now_ms<V: Execute + Visit + ?Sized>(executor: &V) -> u64 {
executor
.context()
.curr_block
.creation_time()
.as_millis()
.try_into()
.ok()
.and_then(NonZeroU64::new)
.dbg_expect("shouldn't overflow within 584942417 years")
}

Expand Down
4 changes: 2 additions & 2 deletions crates/iroha_executor_data_model/src/isi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ pub mod multisig {
/// Proposal contents
pub instructions: Vec<InstructionBox>,
/// Time in milliseconds at which the proposal was made
pub proposed_at_ms: NonZeroU64,
pub proposed_at_ms: u64,
/// Time in milliseconds at which the proposal will expire
pub expires_at_ms: NonZeroU64,
pub expires_at_ms: u64,
/// List of approvers of the proposal so far
pub approvals: BTreeSet<AccountId>,
/// In case this proposal is some relaying approval, indicates if it has executed or not
Expand Down
4 changes: 2 additions & 2 deletions docs/source/references/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -3041,11 +3041,11 @@
},
{
"name": "proposed_at_ms",
"type": "NonZero<u64>"
"type": "u64"
},
{
"name": "expires_at_ms",
"type": "NonZero<u64>"
"type": "u64"
},
{
"name": "approvals",
Expand Down
Loading