Skip to content

feat: Added in-memory storage for testing purposes#59

Open
Harshdev098 wants to merge 2 commits intolightningdevkit:mainfrom
Harshdev098:memory_store
Open

feat: Added in-memory storage for testing purposes#59
Harshdev098 wants to merge 2 commits intolightningdevkit:mainfrom
Harshdev098:memory_store

Conversation

@Harshdev098
Copy link
Copy Markdown

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
Copy Markdown

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Author

@tnull Have done the required changes

Copy link
Copy Markdown
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
Copy Markdown

🔔 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
Copy Markdown

🔔 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
Copy Markdown

🔔 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
Copy Markdown
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
Copy Markdown
Author

@tankyleo Can you please review it!

@ldk-reviews-bot
Copy link
Copy Markdown

🔔 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
Copy Markdown

🔔 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
Copy Markdown

🔔 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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Author

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

Copy link
Copy Markdown
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
Copy Markdown

🔔 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
Copy Markdown

🔔 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
Copy Markdown
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
Copy Markdown

🔔 8th 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
Copy Markdown

🔔 9th 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
Copy Markdown

🔔 10th 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
Copy Markdown

🔔 11th 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
Copy Markdown

🔔 12th 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
Copy Markdown

🔔 13th 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
Copy link
Copy Markdown
Author

@tankyleo Can you please tabke a look at it!

@ldk-reviews-bot
Copy link
Copy Markdown

🔔 14th 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
Copy Markdown

🔔 15th 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
Copy Markdown
Contributor

tnull commented Mar 5, 2026

This needs a rebase by now unfortunately, sorry!

@ldk-reviews-bot
Copy link
Copy Markdown

🔔 16th 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
Copy Markdown

🔔 17th 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
Copy Markdown

🔔 18th 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
Copy Markdown

🔔 19th 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
Copy Markdown

🔔 20th 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
Copy Markdown

🔔 21st 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
Copy Markdown

🔔 22nd 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 force-pushed the memory_store branch 3 times, most recently from f571b29 to 06eeb34 Compare March 21, 2026 09:22
@Harshdev098
Copy link
Copy Markdown
Author

@tnull @tankyleo I have rebased it, can you please review it in your mean time!

@ldk-reviews-bot
Copy link
Copy Markdown

🔔 23rd 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
Copy Markdown

🔔 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
Copy Markdown

🔔 24th 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
Copy Markdown

🔔 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.

@tnull
Copy link
Copy Markdown
Contributor

tnull commented Mar 27, 2026

Thanks! Please feel free to re-request review once @tankyleo is happy with the current state.

@ldk-reviews-bot
Copy link
Copy Markdown

🔔 25th 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
Copy Markdown
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.

Thanks for your patience

[server_config]
host = "127.0.0.1"
port = 8080
bind_address = "127.0.0.1:8080"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please make all the changes in this file in a single commit.

path: ldk-node

- name: Build and Deploy VSS Server
- name: Create Postgres config
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's not make any edits to the CI of the postgres backend in this PR. We'll use a cfg flag to enable the in-memory backend so that no edits to the config file will be needed.

[server_config]
host = "127.0.0.1"
port = 8080
bind_address = "127.0.0.1:8080"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please keep all your changes for the CI of the in-memory server to a single commit.

) -> Result<(), VssError> {
let key = build_storage_key(user_token, store_id, &key_value.key);

if key_value.version == -1 {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is used to validate a PutObjectRequest, and therefore should return a ConflictError in case the key does not exist, even in the case of a non-conditional write.

let store_id = request.store_id;
let mut guard = self.store.lock().await;

execute_delete_object(&mut guard, &user_token, &store_id, &key_value);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Before we reach this point for conditional deletes, we still need to make sure that the version matches in case the key does exist. See rust/api/src/types.rs for further details.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's remove all the changes in this file, and use a cfg flag to override the postgres backend configuration in src/main.rs. See how we use the noop_authorizer, we want to do something very similar for in-memory store as it will also be a developer tool and not something to be run in any production setting.

Comment on lines +40 to +43
if args.len() < 2 {
eprintln!("Usage: {} <config-file-path> [--in-memory]", args[0]);
std::process::exit(1);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A change of direction thank you: I prefer we use a RUSTFLAGS="--cfg in-memory-store" to set the backend, as it's a developer-only tool just like noop_authorizer. We can delete this as the postgres backend does not require a configuration file.

std::process::exit(-1);
});

let store: Arc<dyn KvStore> = if let Some(crt_pem) = config.tls_config {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Here let's use cfg flags to set the in-memory-store backend.

# Maximum request body size in bytes. Can be set here or be overridden by env var 'VSS_MAX_REQUEST_BODY_SIZE'
# Defaults to the maximum possible value of 1 GB if unset.
# max_request_body_size = 1073741824
store_type = "postgres" # "postgres" for using postgresql and "in-memory" for testing purposes
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I prefer we make no changes to the config file for a developer-only tool.

Comment on lines +30 to +32
**Note:** For testing purposes, you can pass `--in-memory` to use in-memory instead of PostgreSQL
```
cargo run -- server/vss-server-config.toml --in-memory
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We'll have to update this to use RUSTFLAGS instead.

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