**Motivation**
Make the types exports consistent for all packages.
All modern runtimes support [conditional
exports](https://nodejs.org/api/packages.html#conditional-exports) and
there are caveats when we have both conditional exports and normal
exports present in a package.json. This PR tend to make all exports
follow same consistent and modern pattern.
**Description**
- We were using subpath exports for some packages and module exports for
other
- Keep all the types export consistent as subpath exports.
- Remove "types" and "exports` directive from package.json
- Remove `typesVersions`, this is useful only if we have different
version of types for different versions of Typescript. Or having
different types files for different file paths.
**Steps to test or reproduce**
- Run all CI
**Motivation**
Add `src` directory to package sources along with the `lib` files to
have working source map.
**Description**
- Add `src` to the files.
**Steps to test or reproduce**
- Run all tests
**Motivation**
- #7280
**Description**
- Add `"bun"` export to all packages that points to the _typescript
source_ rather than the transpiled javascript
- Allows for bun to use typescript directly
**Motivation**
Make the code transition for compatibility with the Bun.
**Description**
- The dependency `cpu-features` is not compatible with the `Bun`
- Removed the direct dependency
- Upgrade the `@chainsafe/persistent-merkle-tree` and `@chainsafe/ssz`
so the hasher detection is done implicitly.
- Latest commit for
[hahstree](e86a8b136a)
has the support for fallback, which is not used in the
`@chainsafe/persistent-merkle-tree`
**Steps to test or reproduce**
Run all tests
Follow up to https://github.com/ChainSafe/lodestar/pull/7610 with a few
restructuring suggestions, see comments below for detailed changes,
revives constants tests we are no longer running in CI and makes each
package executable separately again, ie. `cd packages/<package-name>`
into `yarn test:unit` works for all packages again.
One major change is that unit tests default should be written with
`mainnet` preset in mind as I noticed that makes a lot more sense for a
bunch of existing tests, eg. we have tests that depend on external
fixtures, like api spec tests for events and those are not compatible
with `minimal` preset. Also there doesn't seem to be much downside in
most cases for unit tests to use `mainnet` preset as it does not run
through all the epoch, like for example a e2e or sim test does. So
overall, it allows us to use mainnet fixtures / more "real world" data
which seems better with little to no downside.
Time comparison running unit tests on `unstable` vs. this branch
**unstable**

**nflaig/restructure-tests**

There is just a difference of 2 seconds (might be a fluke) in a 6 minute
run, this seems acceptable to me considering the benefits of using
`mainnet` preset noted above.
**Motivation**
Vitest workspaces is feature to mimic the package manager workspaces for
the tests only.
It provides following benefits:
1. Minimize the need the bunch of config files at every package root
2. Consolidate vitest configuration in project groups
3. Use consistent test configuration for all projects in the monorepo
4. Providing consistent test environment for all packages
5. Speed up visual interaction with tests in the IDEs (e.g. Visual
Studio Code)
**Description**
- Remove all unnecessary config files
- Update package json scripts to use `--project` flag
Closes#7603
Now we have following test directories.
| Directory | Description | CurrentPreset | Old Preset |
|---|---|---|---|
| test/unit | Unit tests | minimal | Default export from `params`
package |
| test/unit-mainnet | Unit tests | mainnet | mainnet |
| test/e2e | End-to-End Tests | minimal | Default export from `params`
package |
| test/e2e-mainnet | End-to-End Tests | mainnet | Never existed before,
mixed up pattern in different packages |
| test/spec | Spec tests | minimal | Default export from `params`
package, but common perception among team was that it's running with
`minimal` |
| test/spec-mainnet` | Spec tests | mainnet | Never existed as
directory, but mixed up among packages |
| test/browser | Symlink to `unit` for packages which supports browsers
| minimal | Default export from `params` package |
| test/types | Types test | minimal | Default export from `params`
package |
**Steps to test or reproduce**
Run all tests
**Motivation**
- as v1.28.0 was released, we want to upgrade to ssz v1.2.0 to test the
batch hash asap and unblock other works
**Description**
- replace ssz v1.0.2 by v1.2.0
---------
Co-authored-by: Tuyen Nguyen <twoeths@users.noreply.github.com>
**Motivation**
Update vitest and browser engine.
**Description**
- Move root level shared configs to `configs` directory
- Update to vitest 3.x
- Migrate from `webdriverio` to `playwright` which is more stable and
recommended by Vitest.
**NOTE**
Reverted the `playwright` upgrade. See the comments.
d2a7af0308/configs/vitest.config.base.browser.ts (L41-L43)
**Steps to test or reproduce**
Run all tests
**Motivation**
We dropped CJS support 🎉 fixed some file resolution issues causing
wrong hasher to be loaded and got some clean named imports for hasher
instead of having to dig it out of the libs folder.
**Description**
Update ssz and accompanying packages to v1.0.0
* chore: update ssz to use non-simd on systems that do not support
* chore: update as-sha256 and persistent-merkle-tree direct deps
* chore: update yarn.lock
* chore: update ssz package versions
* chore: add ssz resolution stemming from sub packages of prover
* chore: update yarn.lock
* fix: remove resolution for ssz
* chore: update yarn.lock
* Replace eslint with biomejs
* Update the inclusion of word
* Fix the formatting
* Update the lint task to do all checks
* Update biome rules from eslint config
* Replace eslint with biomejs
* Update the inclusion of word
* Fix the formatting
* Update the lint task to do all checks
* Update biome rules from eslint config
* Fix all lint issues
* Fix formatting
* Add extension recomendation for vscode
* Enable recommended rules
* Enable rule noUselessSwitchCase
* Enable rule noUselessConstructor
* Fix the types
* Fix unit tests
* Enforce import extensions
* Update the cli command
* Enforce useConsistentMemberAccessibility
* Update rules
* Fix rules
* Upgrade biomejs to latest version
* Update the rules
* Update and format the config file
* Fix types break during merge
* Fix unused check
* Add comment for explicit-return-type
* Remove eslint file
* Add _e objects for empty catch blocks
* Update formatter config
* Fix formatting
* Add config route definitions
* Add debug route definitions
* Add events route description
* Add lightclient route definitions
* Flatten function params
* Type safety for optional params in write / parse req
* Method args are optional if only optional props
* Fix genesisValidatorsRoot type issue
* Revert requiring all params in write / parse req
* Update http client errors
* Add lodestar route definitions
* Add node route definitions
* Add proof route definitions
* Add builder route definitions
* Add validator route definitions
* Application method response can be void
* Generic options can be passed to application methods
* Default endpoint request type has body property
* Improve types of transform methods
* Export server types from index (to be removed)
* Update config api impl
* Update lightclient api impl
* Update events api impl
* Update lodestar api impl
* Update proof api impl
* Update node api impl
* Update debug api impl
* Update state api impl
* Update pool api impl
* Update blocks api impl
* Partially update validator api impl
* Update beacon routes export
* Align submitPoolBlsToExecutionChange method args
* Filters are always a object
* Update errors messages
* Add beacon client methods
* Add missing routeId label to stream time metric
* Fix json casing in codecs
* Apply remaining changes from #6227
* Produce block apis only have version meta
* Add block values meta to all produce block apis
* Apply changes from #6337
* Handle unsafe version in WithMeta and WithVersion
* Restore server api error
* Update fastify route types
* Update server routes / handlers
* Remove unnecessary type cast
* Restore per route clients
* Fix beacon route types
* Remove option to patch fetch from http client
* Update eventstream client, remove fetch override
Fallback does not work like this, see #6180 for proper solution
* Use StringType for validator status until #6059
* Remove empty fetch.ts file
* Add a few todos
* Update builder client and server routes
* Update beacon exports
* Update api index exports
* Update builder index imports
* Improve type safety of schema definitions
* Add headers to fastify schema
* Fix schema definition type
* Add missing schemas to route definitions
* Fix response codec type
* Remove response codec type casts
* Fix casing in json only codec
* Reuse EmptyResponseCodec
* Update base rest api server
* Update keymanager routes, client and server
* Reuse data types in keymanager impl
* Do not await setting headers, not a promise
* Improve type safety of empty codecs
* Only require to implement supported req methods
* Handle requests that only support one format
* Handle responses that only support one format
* Add json / ssz only req codecs
* Update only support errors
* Fix assertion
* Set correct accept header if only supports one format
* Fix eslint / prettier issues
* More formatting fixes
* Fix fallback request retries in case of http errors
* Formatting of res.error
* Add add retry functionality to http client (from #6387)
* Update rewards routes and server (#6178 and #6260)
* Allow to omit body in ssz req if not defined
* Always set metadata headers in response
* Cache wire format in api response
* Only call raw body for json meta
* Update api package tests (wip)
* Test json and ssz format in generic server tests
* Add a bunch of todos
* Fix a few broken route definitions
* Fix partial config test
* Another todo note
* Stringify body of json requests
* Override default response json method
* Validate external consensus version headers in request
* Add error handling todo
* Skip body schema validation for ssz request bodies
* Clean up generic server tests
* Pass node, proof, events generic tests
* Use enum for media types
* Fix a bunch of route definitions
* Add justified to blockid type
* Properly handle booleans, remove block values codec
* Create Uint8Array test data without allocating Buffer
* Let fastify handle Buffer conversion
* Convert Buffer to Uint8Array in content type parser
* Fix build issues
* Fix fork type in builder routes
* Add some notes
* Properly parse request headers
* Fix incorrect type assumptions in transform
* Generic server tests are passing (except lightclient)
* Correctly handle APIs with empty responses
* Update getHeader return type to reflect no bid responses
* Do not append '?' to URL if query string is empty
* Let server handler set status code for parsing errors
* Remove unused import
* Rename function, request specific
* Completely drop ssz support from getSpec
* Spec tests are passing against latest releases
* Drop unused fastify route config
* Drop ssz request from builder routes, not yet supported
* Remove import
* Apply change from #6695
* Update execution optimistic meta
* Apply changes from #6645
* Add workaround to fix epoch committees type issue
* Add todo to fix inefficient state conversion
* Convert committee to normal array
* Apply changes from #6655
* Align args of validators endpoints
* Convert indices to str in rewards apis
* Update api spec version of README badges
* Revert table formatting changes
* Make this accessible for class-basd API implementations
* Throw err if metadata is accessed for failed response
* Add assertOk to api response
* Tweak api error message
* Update operationIds match spec value
* Add missing version to blob sidecars metadata
* Test headers and ssz bodies against spec
* Minor reordering of code in spec parsing
* submitBlindedBlock throws err if fork is not execution
* responseOk might be undefined
* Remove statusOk from route definition
* Remove stale comment
* Less build errors in beacon-node
* getBlobSidecars return version from server impl
* Update validator produce block impl
* More expressive pool method args
* Application methods might be undefined in mock implementations
* Adress open TODOs in server handler
* Api response methods are synchronous now
* Fix all remaining build issues
* Use more performant from/toHex in server api impls
* Clean up some TODOs
* Fix ApiError type
* Errors related to parsing return a 400 status code
* Simplify method binding
* Forward api context to application methods
* There is no easy way to make generic opts typesafe
* Better separation of server / client code
* Fix comment about missing builder bid
* Remove todo, not worth the change / extra indentation
* Rename route definitions functions
* Return 400 if data passed to keymanager is invalid
* Properly handle response metadata headers
* Fix lint issues
* Add header jsdoc
* Move metadata related code into separate file
* Remove ssz from POST requests without body
* Only set content-type header if body exists
* Fix headers extra
* POST requests without body are handled similar to GET requests
* Fix http client options tests
* Improve validation and type safety of JSON metadata
* Add type guard for request without body
* Differentiate based on body instead of GET vs POST
* More renaming
* Simplify RequestCode type
* Review routes, improve validation
* Remaining local diff
* Fix accept header handling if only support one wire format
* Update 406 error to more closely match spec example
* Enforce version header via custom check instead of schema
* Use ssz as default request wire format
* Log failure to receive head event to verbose
* Do not set default value for context
* Update getClient return type to better align with method name
* Consistent pattern to get route definitions
* Dedupe api client type for builder and keymanager
* Fix fallback logic if server returns http error
* Update head event error logging
* Retry 415 errors with JSON and cache SSZ not supported
* Use fetch spy to assert call times
* Update comment
* Update getLightClientUpdatesByRange endpoint meta
* Do not forward ssz bytes of blinded block to publishBlock
* Fix lightclient e2e tests
* Version header in publishBlock api is optional
* Reduce type duplication
* Add option to override request init in route definition
* Add JsonOnlyResp codec
* Validate boolean str value from headers
* Document default wire formats
* Simplify merging of inits in http client
* Remove type hacks from fetchBeaconHealth
* Reduce call stack in http client
* Add .ssz() equivalent method for json to api response
* More http client tests
* Ensure topics query is provided to eventstream api
* Validate request content type in handler
Fastify does not cover all edge cases
* Review routes, fix param docs, no empty comments
* Fix typo
* Add note about builder spec not supporting ssz
* Consistently move keymanager jsdoc to routes
* Sanitize user provided init values before merging
* Remove unused ssz only codec
* Allow passing wire formats as string literals
* chore: review proof routes (#6843)
Review proof routes
* chore: review lightclient routes (#6842)
Review lightclient routes
* chore: review node routes (#6844)
Review node routes
* feat: add cli flags to configure http wire format (#6840)
* Review PR, mostly cosmetic changes
* Fix event stream error handling
---------
Co-authored-by: Cayman <caymannava@gmail.com>