Skip to content

feat: add common functions from emp-wasm #7

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

0xshikhar
Copy link

What is this PR doing?

adding common utilities from emp-wasm to mpc-framework-common:

  • AsyncQueue
  • BufferQueue
  • AsyncQueueStore
  • BufferQueueStore
  • assert
  • never

These utilities are general-purpose. It aims reduces duplication and establish a single source of truth.

How can these changes be manually tested?

  • Import the common functions that you want to test in your code
  • Verify error handling by passing invalid values to both functions

Does this PR resolve or contribute to any issues?

Yes, PR related to MPC Framework issue - privacy-scaling-explorations/mpc-framework#10

Copy link
Member

Choose a reason for hiding this comment

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

I'm curious what source(s) this version of AsyncQueue is based on 🤔. I'm happy that you made updates, just curious.

return Promise.reject(new Error('Queue is closed'));
}
}

Copy link
Member

Choose a reason for hiding this comment

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

* @returns A Promise resolving with the popped item.
* @throws {Error} If the queue is closed.
*/
pop(): Promise<T> {
Copy link
Member

Choose a reason for hiding this comment

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

I like that you called this pop instead of shift (was your idea or did you get it from a version that was like that? 🤔). This method will need to be changed to facilitate stream but please keep the name pop (and don't add shift).

* @param channel - The channel identifier (typically 'a' or 'b')
* @returns An AsyncQueue instance for the specified communication channel
*/
get(from: number | string, to: number | string, channel: string): AsyncQueue<T> {
Copy link
Member

Choose a reason for hiding this comment

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

The shape of this method is specific to the channels concept in emp-wasm, which is bad. mpc-framework-common should avoid particulars of its dependencies. Please make it get(key: string): AsyncQueue<T> instead.

* @param channel - The channel identifier ('a' or 'b')
* @returns A BufferQueue instance for the specified communication channel
*/
get(from: number | string, to: number | string, channel: 'a' | 'b'): BufferQueue {
Copy link
Member

Choose a reason for hiding this comment

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

Similar to previous comment (see "shape of this method").

Copy link
Member

Choose a reason for hiding this comment

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

Please delete this and add .DS_Store to .gitignore.

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.

2 participants