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

Prepare light-client for multi-environment support #6486

Open
1 of 6 tasks
jeluard opened this issue Feb 27, 2024 · 0 comments
Open
1 of 6 tasks

Prepare light-client for multi-environment support #6486

jeluard opened this issue Feb 27, 2024 · 0 comments
Labels
prio-low This is nice to have. scope-devex Issues for improving developer experience. scope-light-clients All issues regarding light client development.

Comments

@jeluard
Copy link
Contributor

jeluard commented Feb 27, 2024

Lodestar relies heavily on nodejs specifics (e.g. Buffer or native modules). This allows to provide good performance for client artifacts (e.g. beacon-node, validator).

The light-client package can be used independently in a number of alternative environment (e.g. browser, ReactNative). While such usage can be made to work it requires polyfilling and dark magic heavily tool dependent.

According to my tests, here is the current support of light-client for a number of well-known bundlers/platforms:

Platform Status Issue
webpack5 works for light-client; doesn't support node:* syntax
docusaurus
AWS Lambda
vite/astro Buffer usage
parcel top-level-await (in bls)
bun napi issues with bls
ReactNative exports
CloudFlare workers wasm limitations

Make sure we document supported platforms.

Different options should be pursued to improve this:

  • reducing lodestar libs inter-dependency (only rely on env safe libs)
  • reduce external dependencies; they should follow those same principles
  • reduce usage of node modules; follow principled patterns easing their polyfilling when are mandatory

Inter-packages dependencies

NodeJS modules

  • document patterns detailing preferred usage per module

In general:

  • reduce dependencies on nodejs modules, when possible:
  • consider creating helper function abstracting away node modules usage (similarly to what uint8arrays does)

It makes it simpler for end users of no shim are required.

light-client directly or indirectly depends on the following NodeJS modules:

From@chainsafe/blst #6519

  • crypto
  • path

From bls-eth-wasm

From @chainsafe/bls

From eventsource

  • url
  • https
  • http
  • util

External dependencies

Weight analysis

Capture d’écran 2024-03-19 à 11 53 05

See bundlejs

Heavy packages

  • bls herumi
  • js-yaml, from utils
@philknows philknows added scope-light-clients All issues regarding light client development. scope-devex Issues for improving developer experience. labels Feb 27, 2024
@jeluard jeluard changed the title Prepare for multi-environment support Prepare light-client for multi-environment support Feb 28, 2024
@philknows philknows added the prio-low This is nice to have. label Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
prio-low This is nice to have. scope-devex Issues for improving developer experience. scope-light-clients All issues regarding light client development.
Projects
None yet
Development

No branches or pull requests

2 participants