go-ethereum
go-ethereum copied to clipboard
blsync does not expand tilde for home
I think the following should work:
$ go run ./cmd/blsync --sepolia --beacon.api=https://xxx.io --beacon.checkpoint=$(curl -X 'GET' -H 'accept: application/json' 'https://xxx.io/eth/v1/beacon/headers/finalized' | jq -r ".data.root") --blsync.engine.api=http://localhost:8551 --blsync.jwtsecret=~/.ethereum/sepolia/geth/jwtsecret
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 667 100 667 0 0 1400 0 --:--:-- --:--:-- --:--:-- 1398
Fatal: Error loading or generating JWT secret: open ~/.ethereum/sepolia/geth/jwtsecret: no such file or directory
exit status 1
tildes are expanded by your shell, nowhere else. So it's nothing geth does or doesn't do, your shell should have expanded it before it reached us. It's out of our hands.
See here:
[user@work go-ethereum]$ go run ./cmd/geth --config=~/.ethereum/sepolia/geth/jwtsecret
INFO [08-15|15:06:08.697] Starting Geth on Ethereum mainnet...
INFO [08-15|15:06:08.698] Bumping default cache on mainnet provided=1024 updated=4096
Fatal: open ~/.ethereum/sepolia/geth/jwtsecret: no such file or directory
exit status 1
[user@work go-ethereum]$ go run ./cmd/geth --config ~/.ethereum/sepolia/geth/jwtsecret
INFO [08-15|15:06:15.676] Starting Geth on Ethereum mainnet...
INFO [08-15|15:06:15.677] Bumping default cache on mainnet provided=1024 updated=4096
Fatal: read /home/user/.ethereum/sepolia/geth/jwtsecret: is a directory
exit status 1
If you use the =-sign, you leave it up to go. If you use a space instead, the shell expands it.
Right, but this also works:
$ go run ./cmd/geth attach --datadir=~/.ethereum/sepolia
So I feel like blsync isn't consistent?
Ah, you are right. So the datadir uses DirectoryFlag, https://github.com/ethereum/go-ethereum/blob/master/internal/flags/flags.go#L57
// DirectoryFlag is custom cli.Flag type which expand the received string to an absolute path.
// e.g. ~/.ethereum -> /home/username/.ethereum
So ok, I agree, let's change blsync.jwtsecret so that it also uses the same mechanism. I guess we need a new type, similar to DirectoryFlag, which is a FileFlag (maybe such a thing already exists)
There exists an cli.PathFlag out of the box, but it doesn't expand tildes.
FYI, cli v3 dropped the path flag.