diff --git a/movement-sdk/Cargo.lock b/movement-sdk/Cargo.lock index de4052a5..2cacc5e8 100644 --- a/movement-sdk/Cargo.lock +++ b/movement-sdk/Cargo.lock @@ -12985,6 +12985,7 @@ dependencies = [ "futures", "sui-helper-types", "sui-types", + "typed-store", ] [[package]] diff --git a/movement-sdk/Cargo.toml b/movement-sdk/Cargo.toml index 4b6028ff..bca49211 100644 --- a/movement-sdk/Cargo.toml +++ b/movement-sdk/Cargo.toml @@ -85,4 +85,5 @@ sui-adapter-latest = { path = "../vendors/sui/sui-execution/latest/sui-adapter" sui-types = { path = "../vendors/sui/crates/sui-types" } sui-core = { path = "../vendors/sui/crates/sui-core" } sui-swarm-config = { path = "../vendors/sui/crates/sui-swarm-config" } -sui-test-transaction-builder = { path = "../vendors/sui/crates/sui-test-transaction-builder" } \ No newline at end of file +sui-test-transaction-builder = { path = "../vendors/sui/crates/sui-test-transaction-builder" } +typed-store = { path = "../vendors/sui/crates/typed-store" } \ No newline at end of file diff --git a/movement-sdk/sui-helpers/sui-block-authority-providers/Cargo.toml b/movement-sdk/sui-helpers/sui-block-authority-providers/Cargo.toml index f29413d3..fe90ebde 100644 --- a/movement-sdk/sui-helpers/sui-block-authority-providers/Cargo.toml +++ b/movement-sdk/sui-helpers/sui-block-authority-providers/Cargo.toml @@ -11,6 +11,7 @@ sui-helper-types = { workspace = true } # sui sui-types = { workspace = true } +typed-store = { workspace = true } # general futures = {workspace = true} diff --git a/movement-sdk/sui-helpers/sui-block-authority-providers/src/object_version/object_version_rocksdb.rs b/movement-sdk/sui-helpers/sui-block-authority-providers/src/object_version/object_version_rocksdb.rs index fa9291fd..63b9f512 100644 --- a/movement-sdk/sui-helpers/sui-block-authority-providers/src/object_version/object_version_rocksdb.rs +++ b/movement-sdk/sui-helpers/sui-block-authority-providers/src/object_version/object_version_rocksdb.rs @@ -2,10 +2,12 @@ use sui_helper_types::{ providers::object_version::ObjectVersionProvider, block::VerifiedExecutableExecutionGroups }; +use sui_types::{digests::TransactionDigest, base_types::{ObjectID, SequenceNumber}, transaction::{TransactionData, TransactionDataAPI, SharedInputObject, SenderSignedData}, executable_transaction::VerifiedExecutableTransaction, message_envelope::{Message, VerifiedEnvelope, Envelope}}; +use typed_store::{rocks::DBMap, Map}; #[derive(Debug, Clone)] // would like for this to remain debug clone pub struct ObjectVersionRocksDB { - + shared_object_versions: DBMap> } #[async_trait::async_trait] @@ -14,8 +16,43 @@ impl ObjectVersionProvider for ObjectVersionRocksDB { // todo: implement against rocksdb store // todo: add methods to the trait in the `sui-helper-types` crate - async fn assign_shared_object_versions(&self, transactions : VerifiedExecutableExecutionGroups) -> Result { - unimplemented!(); + async fn assign_shared_object_versions(&self, transaction_groups : VerifiedExecutableExecutionGroups) -> Result { + + let mut new_groups: Vec> = Vec::new(); +/* + for tx_group in transaction_groups { + + let mut new_group: Vec = Vec::new(); + + for transaction in tx_group { + let modified_transaction = transaction.clone(); + let transaction_data = &mut modified_transaction.inner_mut().intent_message.value; + + let TransactionData::V1(tx_data_v1) = transaction_data; + + // get SharedObjects from transaction data + let mut shared_objects: Vec = tx_data_v1.kind_mut().shared_input_objects().collect(); + let digest = modified_transaction.digest(); + + // update sequence_number of shared_objects + if let Ok(shared_object_versions) = self.shared_object_versions.get(&digest) { + if shared_object_versions.is_some() { + for version in shared_object_versions.unwrap() { + if let Some(obj) = shared_objects.iter_mut().find(|obj| obj.id == version.0) { + obj.initial_shared_version = version.1; + } + } + } + } + + new_group.push(modified_transaction); + } + + new_groups.push(new_group); + } + */ + let verified_executable_execution_groups = VerifiedExecutableExecutionGroups(new_groups); + Ok(verified_executable_execution_groups) } } \ No newline at end of file diff --git a/movement-sdk/types/sui-helper-types/src/block/block.rs b/movement-sdk/types/sui-helper-types/src/block/block.rs index 3a9c74a0..6dfe8b49 100644 --- a/movement-sdk/types/sui-helper-types/src/block/block.rs +++ b/movement-sdk/types/sui-helper-types/src/block/block.rs @@ -14,7 +14,7 @@ pub struct Block(Vec); pub struct VerifiedExecutableBlock(Vec); #[derive(Debug, Clone)] -pub struct VerifiedExecutableExecutionGroups(Vec>); +pub struct VerifiedExecutableExecutionGroups(pub Vec>); impl IntoIterator for VerifiedExecutableExecutionGroups { type Item = Vec;