Skip to content

Commit

Permalink
[Node] change block timestamp from sec to microsec (#1067)
Browse files Browse the repository at this point in the history
  • Loading branch information
musitdev authored Feb 27, 2025
1 parent 339b06c commit b2b0ad6
Showing 1 changed file with 2 additions and 25 deletions.
27 changes: 2 additions & 25 deletions protocol-units/da/movement/protocol/util/src/blob/ir/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ where
}

pub fn now(blob: Vec<u8>) -> Self {
// mark the timestamp as now in milliseconds
// Define the block timestamp value. Aptos framework need a timestamp in micro sec.
// Changing this value will generate blocks that can't be executed.
let timestamp = chrono::Utc::now().timestamp_micros() as u64;

Self::new(blob, timestamp)
Expand Down Expand Up @@ -79,28 +80,4 @@ pub mod block {
Ok(Self::now(blob))
}
}

impl<C> TryFrom<block::Id> for InnerSignedBlobV1Data<C>
where
C: Curve + Verify<C> + Digester<C>,
{
type Error = anyhow::Error;

fn try_from(id: block::Id) -> Result<Self, Self::Error> {
let blob = id.as_bytes().to_vec();
Ok(Self::now(blob))
}
}

impl<C> TryFrom<Vec<block::Id>> for InnerSignedBlobV1Data<C>
where
C: Curve + Verify<C> + Digester<C>,
{
type Error = anyhow::Error;

fn try_from(ids: Vec<block::Id>) -> Result<Self, Self::Error> {
let blob = bcs::to_bytes(&ids)?;
Ok(Self::now(blob))
}
}
}

0 comments on commit b2b0ad6

Please sign in to comment.