Skip to content

Commit

Permalink
chore(iota-types): Expand all type conversions (#3803)
Browse files Browse the repository at this point in the history
* chore(iota-types): Expand all type conversions

* update sdk hash

* convert events

* revert accidental change

* cleanup accesses

* renames

* clippy

---------

Co-authored-by: Thibault Martinez <[email protected]>
  • Loading branch information
DaughterOfMars and thibault-martinez authored Oct 31, 2024
1 parent 4eaf6cd commit b2ca31e
Show file tree
Hide file tree
Showing 16 changed files with 1,666 additions and 145 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ iota-rosetta = { path = "crates/iota-rosetta" }
iota-rpc-loadgen = { path = "crates/iota-rpc-loadgen" }
iota-sdk = { path = "crates/iota-sdk" }
# core-types with json format for REST API
iota-sdk2 = { package = "iota-rust-sdk", git = "ssh://[email protected]/iotaledger/iota-rust-sdk.git", rev = "ed6173d434c77604ddc93aaa1550168fdbe97b09", features = ["hash", "serde", "schemars"] }
iota-sdk2 = { package = "iota-rust-sdk", git = "ssh://[email protected]/iotaledger/iota-rust-sdk.git", rev = "dd7b331a5ec62fd5e810051d19f31dff90ea7e3f", features = ["hash", "serde", "schemars"] }
iota-simulator = { path = "crates/iota-simulator" }
iota-snapshot = { path = "crates/iota-snapshot" }
iota-source-validation = { path = "crates/iota-source-validation" }
Expand Down
2 changes: 1 addition & 1 deletion crates/iota-types/src/authenticator_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Modifications Copyright (c) 2024 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

use fastcrypto_zkp::bn254::zk_login::{JWK, JwkId};
pub(crate) use fastcrypto_zkp::bn254::zk_login::{JWK, JwkId};
use move_core_types::{account_address::AccountAddress, ident_str, identifier::IdentStr};
use serde::{Deserialize, Serialize};

Expand Down
4 changes: 4 additions & 0 deletions crates/iota-types/src/base_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,10 @@ pub struct IotaAddress(
impl IotaAddress {
pub const ZERO: Self = Self([0u8; IOTA_ADDRESS_LENGTH]);

pub fn new(bytes: [u8; IOTA_ADDRESS_LENGTH]) -> Self {
Self(bytes)
}

/// Convert the address to a byte buffer.
pub fn to_vec(&self) -> Vec<u8> {
self.0.to_vec()
Expand Down
10 changes: 9 additions & 1 deletion crates/iota-types/src/digests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ impl fmt::UpperHex for Digest {
Deserialize,
JsonSchema,
)]
pub struct ChainIdentifier(CheckpointDigest);
pub struct ChainIdentifier(pub(crate) CheckpointDigest);

pub static MAINNET_CHAIN_IDENTIFIER: OnceCell<ChainIdentifier> = OnceCell::new();
pub static TESTNET_CHAIN_IDENTIFIER: OnceCell<ChainIdentifier> = OnceCell::new();
Expand Down Expand Up @@ -205,6 +205,14 @@ impl ChainIdentifier {
pub fn as_bytes(&self) -> &[u8; 32] {
self.0.inner()
}

pub fn into_bytes(self) -> [u8; 32] {
self.0.into_inner()
}

pub fn digest(&self) -> CheckpointDigest {
self.0
}
}

pub fn get_mainnet_chain_identifier() -> ChainIdentifier {
Expand Down
24 changes: 14 additions & 10 deletions crates/iota-types/src/effects/effects_v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,37 +31,37 @@ use crate::{
#[derive(Eq, PartialEq, Clone, Debug, Serialize, Deserialize)]
pub struct TransactionEffectsV1 {
/// The status of the execution
status: ExecutionStatus,
pub(crate) status: ExecutionStatus,
/// The epoch when this transaction was executed.
executed_epoch: EpochId,
gas_used: GasCostSummary,
pub(crate) executed_epoch: EpochId,
pub(crate) gas_used: GasCostSummary,
/// The transaction digest
transaction_digest: TransactionDigest,
pub(crate) transaction_digest: TransactionDigest,
/// The updated gas object reference, as an index into the `changed_objects`
/// vector. Having a dedicated field for convenient access.
/// System transaction that don't require gas will leave this as None.
gas_object_index: Option<u32>,
pub(crate) gas_object_index: Option<u32>,
/// The digest of the events emitted during execution,
/// can be None if the transaction does not emit any event.
events_digest: Option<TransactionEventsDigest>,
pub(crate) events_digest: Option<TransactionEventsDigest>,
/// The set of transaction digests this transaction depends on.
dependencies: Vec<TransactionDigest>,
pub(crate) dependencies: Vec<TransactionDigest>,

/// The version number of all the written Move objects by this transaction.
pub(crate) lamport_version: SequenceNumber,
/// Objects whose state are changed in the object store.
changed_objects: Vec<(ObjectID, EffectsObjectChange)>,
pub(crate) changed_objects: Vec<(ObjectID, EffectsObjectChange)>,
/// Shared objects that are not mutated in this transaction. Unlike owned
/// objects, read-only shared objects' version are not committed in the
/// transaction, and in order for a node to catch up and execute it
/// without consensus sequencing, the version needs to be committed in
/// the effects.
unchanged_shared_objects: Vec<(ObjectID, UnchangedSharedKind)>,
pub(crate) unchanged_shared_objects: Vec<(ObjectID, UnchangedSharedKind)>,
/// Auxiliary data that are not protocol-critical, generated as part of the
/// effects but are stored separately. Storing it separately allows us
/// to avoid bloating the effects with data that are not critical.
/// It also provides more flexibility on the format and type of the data.
aux_data_digest: Option<EffectsAuxDataDigest>,
pub(crate) aux_data_digest: Option<EffectsAuxDataDigest>,
}

impl TransactionEffectsAPI for TransactionEffectsV1 {
Expand Down Expand Up @@ -574,6 +574,10 @@ impl TransactionEffectsV1 {
pub fn changed_objects(&self) -> &[(ObjectID, EffectsObjectChange)] {
&self.changed_objects
}

pub fn aux_data_digest(&self) -> Option<EffectsAuxDataDigest> {
self.aux_data_digest
}
}

impl Default for TransactionEffectsV1 {
Expand Down
2 changes: 1 addition & 1 deletion crates/iota-types/src/effects/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use crate::{
storage::WriteKind,
};

mod effects_v1;
pub(crate) mod effects_v1;
mod object_change;
mod test_effects_builder;

Expand Down
2 changes: 1 addition & 1 deletion crates/iota-types/src/execution_status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ pub enum ExecutionFailureStatus {
"Iota Move Bytecode Verification Timeout. \
Please run the Iota Move Verifier for more information."
)]
IotaMoveVerificationTimedout,
IotaMoveVerificationTimeout,

#[error("The shared object operation is not allowed.")]
SharedObjectOperationNotAllowed,
Expand Down
Loading

0 comments on commit b2ca31e

Please sign in to comment.