cli
cli copied to clipboard
refactor(network): genesis parser
close #2197 close #2210
Description
- Add the possibility to fetch a genesis from a URL inside a tarball, checking the folders recursively to find the
genesis.json
file. - Refactor the commands to download/open the genesis file only one time
- Cache the Genesis into disk instead memory
- Create a more efficiently JSON reader, reading line by line for we can get only one parameter
- Open the Genesis file only one time
- Set the new values when writing into the file using the io.Writer method
Write([]byte) (int, error)
How to test
- Publish a chain with a tarball genesis file
starport n --nightly chain publish https://github.com/Pantani/mars --genesis https://github.com/Pantani/genesis/raw/main/genesis.tar.gz --chain-id mars-1
- Publish a chain with a simple genesis from the URL
starport n --nightly chain publish https://github.com/Pantani/mars --genesis https://github.com/Pantani/genesis/raw/main/genesis.json --chain-id mars-1
the command should fail in the genesis verification because the genesis file is not valid for the chain
the CLI logs are a little bit different from the issue to avoid adding too much logic into the code
Before merging this PR, let's wait for at least 4 reviews, so we can ensure that everything is good. 👍
I get the tarball extracted log twice, can we fix that if we're extracting two times?
gitpod /workspace/ignite/.gitpod (feat/tarball-genesis) $ ignite n --nightly chain publish https://github.com/Pantani/mars --genesis https://github.com/Pantani/genesis/raw/main/genesis.tar.gz --chain-id mars-1 ✔ Source code fetched ✔ Blockchain set up ✔ Chain's binary built ✔ Extracted custom Genesis from tarball at config/genesis.json ✔ Genesis initialized ✔ Blockchain initialized ✔ Extracted custom Genesis from tarball at config/genesis.json ✔ Network published ⋆ Launch ID: 5 ⋆ Campaign ID: 5
handled in 1130def
Closing in favour of https://github.com/ignite/cli/pull/2846