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

update: add a function to assign object versions #98

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions movement-sdk/Cargo.lock

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

3 changes: 2 additions & 1 deletion movement-sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
sui-test-transaction-builder = { path = "../vendors/sui/crates/sui-test-transaction-builder" }
typed-store = { path = "../vendors/sui/crates/typed-store" }
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ sui-helper-types = { workspace = true }

# sui
sui-types = { workspace = true }
typed-store = { workspace = true }

# general
futures = {workspace = true}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<TransactionDigest, Vec<(ObjectID, SequenceNumber)>>
}

#[async_trait::async_trait]
Expand All @@ -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<VerifiedExecutableExecutionGroups, anyhow::Error> {
unimplemented!();
async fn assign_shared_object_versions(&self, transaction_groups : VerifiedExecutableExecutionGroups) -> Result<VerifiedExecutableExecutionGroups, anyhow::Error> {

let mut new_groups: Vec<Vec<VerifiedExecutableTransaction>> = Vec::new();
/*
for tx_group in transaction_groups {

let mut new_group: Vec<VerifiedExecutableTransaction> = 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<SharedInputObject> = 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)
}

}
2 changes: 1 addition & 1 deletion movement-sdk/types/sui-helper-types/src/block/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub struct Block(Vec<SenderSignedData>);
pub struct VerifiedExecutableBlock(Vec<VerifiedExecutableTransaction>);

#[derive(Debug, Clone)]
pub struct VerifiedExecutableExecutionGroups(Vec<Vec<VerifiedExecutableTransaction>>);
pub struct VerifiedExecutableExecutionGroups(pub Vec<Vec<VerifiedExecutableTransaction>>);

impl IntoIterator for VerifiedExecutableExecutionGroups {
type Item = Vec<VerifiedExecutableTransaction>;
Expand Down