Skip to content

Conversation

@Harshdev098
Copy link

Have added in_memory store for testing purpose.
We can edit config file to use specific store either postgresql or memory

@ldk-reviews-bot
Copy link

ldk-reviews-bot commented Oct 12, 2025

👋 I see @tnull was un-assigned.
If you'd like another reviewer assignment, please click here.

@Harshdev098
Copy link
Author

Harshdev098 commented Oct 12, 2025

Hey @tnull @tankyleo Can you please review it

@tnull tnull self-requested a review October 13, 2025 07:10
Copy link
Contributor

@tnull tnull left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for looking into this!

Generally goes into the right direction, but we def. need to avoid re-allocating everything on every operation.

@Harshdev098 Harshdev098 force-pushed the memory_store branch 2 times, most recently from 4980a75 to 25d57e3 Compare October 14, 2025 06:16
@Harshdev098 Harshdev098 requested a review from tnull October 14, 2025 06:17
@Harshdev098
Copy link
Author

@tnull Have done the required changes

Copy link
Contributor

@tnull tnull left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks much better, but I think we still need to handle global_version properly, even if we're currently not using it client-side.

@ldk-reviews-bot
Copy link

🔔 1st Reminder

Hey @tankyleo! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@ldk-reviews-bot
Copy link

🔔 2nd Reminder

Hey @tnull @tankyleo! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@ldk-reviews-bot
Copy link

🔔 1st Reminder

Hey @tnull @tankyleo! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

Copy link
Contributor

@tnull tnull left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One comment, will take another look once @tankyleo also had a chance to do a review round here.

@Harshdev098
Copy link
Author

@tankyleo Can you please review it!

@ldk-reviews-bot
Copy link

🔔 3rd Reminder

Hey @tankyleo! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@ldk-reviews-bot
Copy link

🔔 4th Reminder

Hey @tankyleo! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@ldk-reviews-bot
Copy link

🔔 5th Reminder

Hey @tankyleo! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

Copy link
Contributor

@tankyleo tankyleo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay !

version: record.version,
}),
})
} else if request.key == GLOBAL_VERSION_KEY {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like by the time we are here, we know the GLOBAL_VERSION_KEY does not have a value, otherwise guard.get would have returned Some previously. We can just return the GetObjectResponse below directly with version: 0.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Harshdev098 double checking things here, we still have this second branch the same as before ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we still return early if request.key == GLOBAL_VERSION_KEY rather than always first making the lookup?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first lookup handles cases where the GLOBAL_VERSION_KEY is some non-zero value. We want to check whether it's been set to some value in the map before returning the initial value in this branch.

@Harshdev098
Copy link
Author

@tankyleo Have done with the required changes! Can you please review it

Copy link
Contributor

@tnull tnull left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When testing integration with LDK Node locally I found that the tests are currently failing. I now opened #62 to add LDK Node integration tests to our CI here. It would be great if that could land first, and we could also add a CI job for the in-memory store as part of this PR then, ensuring the implementation actually works as expected.

@ldk-reviews-bot
Copy link

🔔 1st Reminder

Hey @tankyleo! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@ldk-reviews-bot
Copy link

🔔 2nd Reminder

Hey @tankyleo! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@tnull
Copy link
Contributor

tnull commented Oct 31, 2025

@Harshdev098 Please rebase now that #62 landed to make use of the new CI checks here.

@ldk-reviews-bot
Copy link

🔔 4th Reminder

Hey @tnull! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

Copy link
Contributor

@tankyleo tankyleo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also rephrase your commit messages to use the imperative form ? See https://cbea.ms/git-commit/

Err(VssError::NoSuchKeyError("Requested key not found.".to_string()))
};

result
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: no need for the extra result variable here, just return from the if statement directly

let storage_prefix = format!("{}#{}#", user_token, store_id);
let prefix_len = storage_prefix.len();

let mut all_items: Vec<KeyValue> = guard
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You did not address the earlier feedback, we are still making an extra allocation here when we only need one

})
.collect();

all_items.sort_by(|a, b| a.key.cmp(&b.key));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again as I mentioned further above, we now don't need this sort here let's delete it


let mut all_items: Vec<KeyValue> = guard
.iter()
.filter(|(storage_key, _)| storage_key.starts_with(&storage_prefix))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here let's filter out the keys that do not match the prefix as well as the global version key

global_version = Some(self.get_current_global_version(&guard, &user_token, &store_id));
}

let storage_prefix = format!("{}#{}#", user_token, store_id);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's set this to build_storage_key(&user_token, &store_id, &key_prefix); so that we can do a single filter call to filter out all the keys.

let mut all_items: Vec<KeyValue> = guard
.iter()
.filter(|(storage_key, _)| storage_key.starts_with(&storage_prefix))
.filter_map(|(storage_key, record)| {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not do any filtering in this function, just map


let mut all_items: Vec<KeyValue> = guard
.iter()
.filter(|(storage_key, _)| storage_key.starts_with(&storage_prefix))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After this call, we can do .skip(offset).take(limit).map...

all_items.sort_by(|a, b| a.key.cmp(&b.key));

let page_items: Vec<KeyValue> =
all_items.iter().skip(offset).take(limit).cloned().collect();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned earlier, this skip(offset).take(limit) can be folded into the first iterator chain.

[server_config]
host = "127.0.0.1"
port = 8080
store_type = "postgres" # "postgres" for using postgresql and "in_memory" for testing purposes
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in_memory is not valid any longer

use chrono::Utc;

/// A record stored in the VSS database.
pub struct VssDbRecord {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's delete all the pub here this is not part of the public API, and let's move this to the tail end of src/lib.rs, this is a better spot for this stuff - we can delete model.rs

let limit = std::cmp::min(page_size, LIST_KEY_VERSIONS_MAX_PAGE_SIZE) as usize;

let offset: usize =
request.page_token.as_ref().and_then(|s| s.parse::<usize>().ok()).unwrap_or(0);
Copy link
Contributor

@tankyleo tankyleo Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we cannot parse the token, that is an error - currently we accept it and set offset to 0.

@ldk-reviews-bot
Copy link

🔔 5th Reminder

Hey @tnull! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@ldk-reviews-bot
Copy link

🔔 6th Reminder

Hey @tnull! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@ldk-reviews-bot
Copy link

🔔 7th Reminder

Hey @tnull! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@Harshdev098 Harshdev098 force-pushed the memory_store branch 2 times, most recently from 2d78e44 to 6ee3bc8 Compare November 24, 2025 06:46
@Harshdev098 Harshdev098 requested a review from tankyleo November 24, 2025 07:32
@Harshdev098
Copy link
Author

Harshdev098 commented Nov 25, 2025

Hey @tankyleo @tnull Can you review it! I have updated the PR

@ldk-reviews-bot
Copy link

🔔 8th Reminder

Hey @tnull @tankyleo! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@ldk-reviews-bot
Copy link

🔔 1st Reminder

Hey @tnull @tankyleo! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@ldk-reviews-bot
Copy link

🔔 9th Reminder

Hey @tnull @tankyleo! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@ldk-reviews-bot
Copy link

🔔 2nd Reminder

Hey @tnull @tankyleo! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@ldk-reviews-bot
Copy link

🔔 10th Reminder

Hey @tnull @tankyleo! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@ldk-reviews-bot
Copy link

🔔 3rd Reminder

Hey @tnull @tankyleo! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

version: record.version,
}),
})
} else if request.key == GLOBAL_VERSION_KEY {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we still return early if request.key == GLOBAL_VERSION_KEY rather than always first making the lookup?

@ldk-reviews-bot
Copy link

🔔 4th Reminder

Hey @tankyleo! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

Copy link
Contributor

@tnull tnull left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs a rebase now that #67 landed.

@ldk-reviews-bot
Copy link

🔔 5th Reminder

Hey @tankyleo! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@ldk-reviews-bot
Copy link

🔔 6th Reminder

Hey @tankyleo! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@ldk-reviews-bot
Copy link

🔔 7th Reminder

Hey @tankyleo! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@Harshdev098 Harshdev098 requested a review from tnull December 12, 2025 09:50
@tnull tnull removed their request for review December 12, 2025 10:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants