cli icon indicating copy to clipboard operation
cli copied to clipboard

refactor(network): genesis parser

Open Pantani opened this issue 2 years ago • 3 comments

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

Pantani avatar Mar 29 '22 00:03 Pantani

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 31adb35
Status:⚡️  Build in progress...

View logs

Before merging this PR, let's wait for at least 4 reviews, so we can ensure that everything is good. 👍

ilgooz avatar Apr 11 '22 12:04 ilgooz

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

Pantani avatar Apr 22 '22 02:04 Pantani

Closing in favour of https://github.com/ignite/cli/pull/2846

lumtis avatar Sep 21 '22 13:09 lumtis