-
Notifications
You must be signed in to change notification settings - Fork 784
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
feat(scripts): fix bug about sed -i
#5169
Conversation
which OS are you using where it didn't work? AFAIK our scripts are working on Linux and macOS. Are you using a BSD? |
My OS is macOS m3. |
On mac you need to install gnu sed and gnu grep to run these scripts. If these changes work for linux an mac out of the box, it'd be nice. |
@mask-pp would you mind signing the CLA? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR, left some comments
@@ -20,16 +20,21 @@ echo "slot_per_epoch=$SLOT_PER_EPOCH" | |||
genesis_file=$1 | |||
|
|||
# Update future hardforks time in the EL genesis file based on the CL genesis time | |||
GENESIS_TIME=$(lcli pretty-ssz --spec $SPEC_PRESET --testnet-dir $TESTNET_DIR BeaconState $TESTNET_DIR/genesis.ssz | jq | grep -Po 'genesis_time": "\K.*\d') | |||
echo $GENESIS_TIME | |||
GENESIS_TIME=$(lcli pretty-ssz --spec $SPEC_PRESET --testnet-dir $TESTNET_DIR BeaconState $TESTNET_DIR/genesis.ssz | jq | sed -n 's/.*genesis_time": "\([0-9]*\).*/\1/p') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original script outputs the genesis_time
, so does your script - they do the same thing. Not sure what do you mean by invalid option --P
? Does the script not work in your OS (MacOS)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original script outputs the
genesis_time
, so does your script - they do the same thing. Not sure what do you mean by invalid option--P
? Does the script not work in your OS (MacOS)?
Yeah, it doesn't work in my MacOS.
scripts/local_testnet/setup.sh
Outdated
bootnode_enr=`cat $DATADIR/bootnode/enr.dat` | ||
echo "- $bootnode_enr" > $TESTNET_DIR/boot_enr.yaml | ||
|
||
echo "Generated bootnode enr and written to $TESTNET_DIR/boot_enr.yaml" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what is the motivation of moving the initialization of boot_node
to setup.sh
? There is no harm here, just that the original script will have:
Now Generating bootnode enr
and
Generated bootnode enr and written to $TESTNET_DIR
written to bootnode.log
. Now it is written to setup.log
echo $CAPELLA_TIME | ||
sed -i 's/"shanghaiTime".*$/"shanghaiTime": '"$CAPELLA_TIME"',/g' $genesis_file | ||
echo "SHANGHAI_TIME: $CAPELLA_TIME" | ||
sed 's/"shanghaiTime".*$/"shanghaiTime": '"$CAPELLA_TIME"',/g' $genesis_file > "/tmp/genesis.json" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the command not work in MacOS (I am not familiar with it)?
The original script with option -i
in sed is to allow in-file editing straightaway, so it works. The proposed change creates a temporary file to replace the genesis.json
, which does the same thing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the command not work in MacOS (I am not familiar with it)?
The original script with option
-i
in sed is to allow in-file editing straightaway, so it works. The proposed change creates a temporary file to replace thegenesis.json
, which does the same thing
It also doesn't work in MacOS, so I have to change it.
Done! |
Thanks very much for your review man. |
I am good with the proposed change since it does the same thing, and it will be good for other users using MacOS trying to run a local testnet using the scripts. So I am happy to recommend merging this PR. Thanks again! Edit: how about the change in bootnode logs from to setup.sh: #5169 (comment) It is not a major thing, but may I know the motivation behind? I think that should work on MacOS? If so, we can remain that part the same |
Yeah, the |
Thanks @mask-pp This seems to be a cleaner solution to enable MacOS to work with the script with Could you give this a try and see if it works? If so, I can test linux on my end and we can use this cleaner solution |
It works with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this PR!
I also noticed that we need to remove these lines from local-testnet.yml to avoid using GNU sed/grep in CI for macOS:
lighthouse/.github/workflows/local-testnet.yml
Lines 42 to 47 in 8cd2b1c
- name: Install GNU sed & GNU grep | |
if: matrix.os == 'macos-12' | |
run: | | |
brew install gnu-sed grep | |
echo "$(brew --prefix)/opt/gnu-sed/libexec/gnubin" >> $GITHUB_PATH | |
echo "$(brew --prefix)/opt/grep/libexec/gnubin" >> $GITHUB_PATH |
and the README in the local_testnet directory:
MacOS users need to install GNU `sed` and GNU `grep`, and add them both to `PATH` as well. |
Deleted. |
I am not sure why we need to delete the line on the As for the |
If my understanding of this PR is correct, it eliminates the need for macOS users to install GNU sed/grep. They can now run start_local_testnet.sh using the built-in sed/grep commands. So the line in the README.md that encourages macOS users to install GNU sed/grep can be removed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much for your contribution @mask-pp, but we recently replaced our local testnet scripts with kurtosis |
Issue Addressed
Which issue # does this PR address?
appear error when run
./setup_time.sh genesis.json
:grep: invalid option -- P
sed: 1: "genesis.json": extra characters at the end of g command
taif
inscripts/local_testnet/README.md
--debug-level
flag inbootnode.sh
Proposed Changes
Please list or describe the changes introduced by this PR.
Additional Info
Please provide any additional information. For example, future considerations
or information useful for reviewers.