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

ZK-559: Remove "/crypto" package from shielder-sdk #81

Open
wants to merge 31 commits into
base: main
Choose a base branch
from

Conversation

kroist
Copy link
Collaborator

@kroist kroist commented Jan 9, 2025

This PR introduces changes to shielder-sdk, effectively making it independent of native cryptography implementation.

  • remove ./src/crypto package and all configuration of WASM, including shielder-wasm bindings.
  • add a dependency to shielder-sdk-crypto interface
  • embed a CryptoClient interface for calling cryptographic functions where needed.
  • some additional refactors of code
  • add build scripts for typescript workspace
  • moving shielder-sdk-tests a dead code, as we intend to rewrite them into simpler framework soon. Disabling CI for shielder-sdk-tests package

@kroist kroist changed the base branch from main to crypto-wasm January 9, 2025 12:42
Copy link

github-actions bot commented Jan 9, 2025

Transaction NameMainCurrentDifference (%)
NewAccountNative20002152000335+0.00600%
DepositNative18279181827894-0.00131%
WithdrawNative18980901898162+0.00379%

@kroist kroist marked this pull request as ready for review January 9, 2025 13:03
@@ -46,18 +45,12 @@ jobs:
uses: ./.github/workflows/_ts-checks.yml
secrets: inherit

ts-sdk-playwright-tests:
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we removing the workflow entirely? Playwright is needed for testing the smaller shielder-sdk-crypto-wasm package.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

we can add it later

Base automatically changed from crypto-wasm to main January 10, 2025 14:31
Copy link
Member

@pmikolajczyk41 pmikolajczyk41 left a comment

Choose a reason for hiding this comment

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

after browsing through ts files (with partial understanding) I had a feeling that this PR makes more changes than necessary, so it's a bit hard to follow everything at once; anyway, looks good to me

Copy link
Member

Choose a reason for hiding this comment

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

very nice readme

Copy link
Contributor

@guspiel guspiel left a comment

Choose a reason for hiding this comment

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

LGTM up to some small comments to resolve. The true verification will come with tests.


## Usage

In order to use most of the modules, WASM needs to be loaded. This package starts loading WASM automatically. User should await the published promise `wasmClientWorkerReady()`.
The main entry point is the `createShielderClient` function which provides methods for interacting with the Shielder protocol.
Copy link
Contributor

Choose a reason for hiding this comment

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

Forgive my focusing on a tiny language nitpick, but please add a comma before "which":P Not having a comma means there is many createShielderClient functions and we're choosing the one which provides methods for interacting with the Shielder protocol.

@@ -119,7 +85,6 @@ jobs:
NO_FORMATTING=true TESTNET=true ./tooling-e2e-tests/full_scenario.sh
NO_FORMATTING=true TESTNET=true ./tooling-e2e-tests/recovery_scenario.sh
NO_FORMATTING=true TESTNET=true ./tooling-e2e-tests/many_actors.sh
NO_FORMATTING=true TESTNET=true ./tooling-e2e-tests/ts_sdk_tests.sh
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider removing shielder-sdk-tests code entirely. We have repo history, not having dead code seems preferrable.


// Initialize the client
const shielderClient = createShielderClient(
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider replacing fake variables with literal fake values like 0xcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc. This would improve readability as the reader then sees the formatting of the expected arguments.

};
}

async merklePathAndRoot(
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you move this helper out of NoteAction? An isolated stateless helper is simpler than keeping it inside an abstract base class. It seems unnecessary to require the user to create an object like DepositAction for a Merkle path query. The tests will have to create the Merkle path, it seems simpler to have this call decoupled.

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.

3 participants