Skip to content

Commit

Permalink
Ethjs JavaScript REPL (#3781)
Browse files Browse the repository at this point in the history
* Add repl server to client

* Add example pectra4 genesis file for development

* Add engine and execution rpc servers to repl context and experiment with repl commands

* Ignore type errors in repl script

* Activate all execution/engine rpc methods as repl commands

* Cleanup helper function

* Ignore import error

* Implement admin_addPeer endpoint

* Add TODO comments

* Implement admin_addPeer endpoint

* Fix type errors

* Update package-lock file

* Add test for admin_addPeer

* Fix admin_addPeer implementation

* Ignore type error

* Implement debug_setHead

* Parameterize repl

* Increase test timeout

* Encapsulate yarg usage

* Fix lint issues

* Add common to returned values

* DRY up the code

* Move simutils to src instead of keeping it in test directory

* Fix spelling errors

* Fix broken simutils imports

* Fix spelling error

* Update package.json file

* Fix and clean up repl.ts

* Only move inline function to src from simutils.ts

* Remove genesis file used for development

* Fix imports

* Remove defaulted script param

* Add some minimal documentation

* client/bin: export cli helpers and import those by both cli and repl

* fix lint and comment stuff

* Rename file

* Fix imports

* Fix imports again

* Fix lint issue

* Fix sim test imports

* Make client and repl exit clean

* Add more docs on repl usage

* fix logging and empty params error

* Fix lint issue

* client: linter ignore console in repl

* client: remove ignore console rules from client/bin

---------

Co-authored-by: acolytec3 <[email protected]>
Co-authored-by: Jochem Brouwer <[email protected]>
  • Loading branch information
3 people authored Jan 17, 2025
1 parent be2b63a commit 78b0f28
Show file tree
Hide file tree
Showing 18 changed files with 1,175 additions and 980 deletions.
2 changes: 1 addition & 1 deletion packages/client/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = {
},
overrides: [
{
files: ['bin/**.ts', 'test/sim/**.ts', 'examples/**/*.ts'],
files: ['test/sim/**.ts', 'examples/**/*.ts'],
rules: {
'no-console': 'off',
},
Expand Down
31 changes: 31 additions & 0 deletions packages/client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,37 @@ Additional log selections can be added with a comma separated list (no spaces).
See [DEVELOPER.md](./DEVELOPER.md)
### REPL ###
An under-development REPL is now available to users. It can be run using the npm script available in the client package:
`npm run repl`
In order to pass parameters to the client while using the repl, you can append it to the npm script command:
`npm run repl -- --gethGenesis /data/genesis.json`
The repl allows access to the JSON-RPC and ENGINE API's from the terminal. For help and a list of supported functions, type `.help` upon repl startup:
```
[01-17|09:05:57] INFO Started JSON RPC Server address=http://localhost:8545 namespaces=eth,web3,net,admin,txpool,debug
[01-17|09:05:57] INFO Started JSON RPC server address=http://localhost:8551 namespaces=eth,engine rpcEngineAuth=false
EthJS > .help
```
Example usage of repl commands:
```
[01-17|09:10:54] INFO Started JSON RPC Server address=http://localhost:8545 namespaces=eth,web3,net,admin,txpool,debug
[01-17|09:10:54] INFO Started JSON RPC server address=http://localhost:8551 namespaces=eth,engine rpcEngineAuth=false
EthJS > .eth_getBlockByNumber ["latest", true]
EthJS > {
number: '0x0',
hash: '0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3',
parentHash: '0x0000000000000000000000000000000000000000000000000000000000000000',
mixHash: '0x0000000000000000000000000000000000000000000000000000000000000000',
nonce: '0x0000000000000042',
...
```
### Diagram Updates
To update the structure diagram files in the root folder open the `client.drawio` file in [draw.io](https://draw.io/), make your changes, and open a PR with the updated files. Export `svg` and `png` with `border` `width=20` and `transparency=false`. For `png` go to "Advanced" and select `300 DPI`.
Expand Down
Loading

0 comments on commit 78b0f28

Please sign in to comment.