Skip to content

clef: when --rules is used together with --stdio-ui then clef doesn't respond to clef_foo requests #25298

@attila-lendvai

Description

@attila-lendvai

System information

On Guix (Linux):

~ $ /gnu/store/01m5q699wca57mi5zp5qk0hbcalqmm37-geth-binary-1.10.20/bin/geth version
Geth
Version: 1.10.20-stable
Git Commit: 8f2416a89a3def6ec2c749d5afafbf2c9a18e3c8
Git Commit Date: 20220629
Architecture: amd64
Go Version: go1.18.1
Operating System: linux
GOPATH=
GOROOT=go

Expected behaviour

when --rules is used while --stdio-ui is enabled, then Clef still responds to the clef_foo requests.

Actual behaviour

when --rules is provided, then Clef responds with:

{"jsonrpc":"2.0","id":1,"error":{"code":-32601,"message":"the method clef_chainId does not exist/is not available"}}

Steps to reproduce the behaviour

~ $ rm -rf /tmp/data /tmp/seed
~ $ mkdir /tmp/data /tmp/seed
~ $ touch /tmp/rules.js
~ $ /gnu/store/ixrvspqpvpnqy45d3aakyafh78ffhdf4-geth-binary-1.10.20-clef/bin/clef --configdir /tmp/data --keystore /tmp/seed --chainid 15 --suppress-bootwarn init
The master seed of clef will be locked with a password.
Please specify a password. Do not forget this password!
Password: 
Repeat password: 

A master seed has been generated into /tmp/data/masterseed.json

This is required to be able to store credentials, such as:
* Passwords for keystores (used by rule engine)
* Storage for JavaScript auto-signing rules
* Hash of JavaScript rule-file

You should treat 'masterseed.json' with utmost secrecy and make a backup of it!
* The password is necessary but not enough, you need to back up the master seed too!
* The master seed does not contain your accounts, those need to be backed up separately!

~ $ /gnu/store/ixrvspqpvpnqy45d3aakyafh78ffhdf4-geth-binary-1.10.20-clef/bin/clef --configdir /tmp/data --keystore /tmp/seed --chainid 15 --suppress-bootwarn attest $(sha256sum /tmp/rules.js)
Decrypt master seed of clef
Password: 
INFO [07-14|10:55:31.541] Ruleset attestation updated              sha256=e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
~ $ /gnu/store/ixrvspqpvpnqy45d3aakyafh78ffhdf4-geth-binary-1.10.20-clef/bin/clef --configdir /tmp/data --keystore /tmp/seed --chainid 15 --rules /tmp/rules.js --suppress-bootwarn --stdio-ui
INFO [07-14|10:55:47.570] Using stdin/stdout as UI-channel 
INFO [07-14|10:55:47.818] Loaded 4byte database                    embeds=268,621 locals=0 local=./4byte-custom.json
{"jsonrpc":"2.0","id":1,"method":"ui_onInputRequired","params":[{"title":"Master Password","prompt":"Please enter the password to decrypt the master seed","isPassword":true}]}
{ "jsonrpc": "2.0", "id":1, "result": { "text":"almakortebanan" } }
INFO [07-14|10:55:57.750] Rule engine configured                   file=/tmp/rules.js
INFO [07-14|10:55:57.750] Starting signer                          chainid=15 keystore=/tmp/seed light-kdf=false advanced=false
DEBUG[07-14|10:55:57.750] FS scan times                            list="27.217µs" set=306ns diff=818ns
DEBUG[07-14|10:55:57.752] Ledger support enabled 
DEBUG[07-14|10:55:57.754] Trezor support enabled via HID 
DEBUG[07-14|10:55:57.754] Trezor support enabled via WebUSB 
INFO [07-14|10:55:57.754] Smartcard socket file missing, disabling err="stat /run/pcscd/pcscd.comm: no such file or directory"
INFO [07-14|10:55:57.754] Audit logs configured                    file=audit.log
DEBUG[07-14|10:55:57.754] IPCs registered                          namespaces=account
INFO [07-14|10:55:57.754] IPC endpoint opened                      url=/tmp/data/clef.ipc
{"jsonrpc":"2.0","method":"ui_onSignerStartup","params":[{"info":{"extapi_http":"n/a","extapi_ipc":"/tmp/data/clef.ipc","extapi_version":"6.1.0","intapi_version":"7.0.1"}}]}
INFO [07-14|10:55:57.769] error occurred during execution          error="ReferenceError: OnSignerStartup is not defined at <eval>:1:16(6)"
{"id": 1, "jsonrpc": "2.0", "method": "clef_chainId"}
WARN [07-14|10:56:17.698] Served clef_chainId                      conn=/dev/stdin reqid=1 duration="24.039µs" err="the method clef_chainId does not exist/is not available"
{"jsonrpc":"2.0","id":1,"error":{"code":-32601,"message":"the method clef_chainId does not exist/is not available"}}

note that this log includes pasting two lines:

  1. providing the password: { "jsonrpc": "2.0", "id":1, "result": { "text":"almakortebanan" } }
  2. the actual request: {"id": 1, "jsonrpc": "2.0", "method": "clef_chainId"}

the same without --rules

~ $ /gnu/store/ixrvspqpvpnqy45d3aakyafh78ffhdf4-geth-binary-1.10.20-clef/bin/clef --configdir /tmp/data --keystore /tmp/seed --chainid 15 --suppress-bootwarn --stdio-ui
INFO [07-14|10:57:51.220] Using stdin/stdout as UI-channel 
INFO [07-14|10:57:51.446] Loaded 4byte database                    embeds=268,621 locals=0 local=./4byte-custom.json
{"jsonrpc":"2.0","id":1,"method":"ui_onInputRequired","params":[{"title":"Master Password","prompt":"Please enter the password to decrypt the master seed","isPassword":true}]}
{ "jsonrpc": "2.0", "id":1, "result": { "text":"almakortebanan" } }
INFO [07-14|10:57:56.431] Starting signer                          chainid=15 keystore=/tmp/seed light-kdf=false advanced=false
DEBUG[07-14|10:57:56.432] FS scan times                            list="64.07µs" set=381ns diff=691ns
DEBUG[07-14|10:57:56.433] Ledger support enabled 
DEBUG[07-14|10:57:56.433] Trezor support enabled via HID 
DEBUG[07-14|10:57:56.433] Trezor support enabled via WebUSB 
INFO [07-14|10:57:56.433] Smartcard socket file missing, disabling err="stat /run/pcscd/pcscd.comm: no such file or directory"
INFO [07-14|10:57:56.433] Audit logs configured                    file=audit.log
DEBUG[07-14|10:57:56.433] IPCs registered                          namespaces=account
INFO [07-14|10:57:56.433] IPC endpoint opened                      url=/tmp/data/clef.ipc
{"jsonrpc":"2.0","method":"ui_onSignerStartup","params":[{"info":{"extapi_http":"n/a","extapi_ipc":"/tmp/data/clef.ipc","extapi_version":"6.1.0","intapi_version":"7.0.1"}}]}
{"id": 1, "jsonrpc": "2.0", "method": "clef_chainId"}
DEBUG[07-14|10:58:03.971] Served clef_chainId                      conn=/dev/stdin reqid=1 duration="57.703µs"
{"jsonrpc":"2.0","id":1,"result":"0xf"}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions