Skip to content
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: download-genesis command (backport #2791) #2795

Merged
merged 2 commits into from
Oct 31, 2023
Merged

Commits on Oct 31, 2023

  1. feat: download-genesis command (#2791)

    Closes #2777
    
    Note for reviewers: I'd rather not backport this PR to v1.x b/c it's a
    new feature and not a bug fix. I wanted to have it ready in case ppl do
    want it on v1.x
    
    ## Testing
    
    Works for all 3 known networks. Complains on an unknown network
    ```shell
    $ ./build/celestia-appd download-genesis mocha-4
    Downloading genesis file for mocha-4 to /Users/rootulp/.celestia-app/config/genesis.json
    Downloaded genesis file for mocha-4 to /Users/rootulp/.celestia-app/config/genesis.json
    SHA-256 hash verified for mocha-4
    
    $ ./build/celestia-appd download-genesis celestia
    Downloading genesis file for celestia to /Users/rootulp/.celestia-app/config/genesis.json
    Downloaded genesis file for celestia to /Users/rootulp/.celestia-app/config/genesis.json
    SHA-256 hash verified for celestia
    
    $ ./build/celestia-appd download-genesis arabica-10
    Downloading genesis file for arabica-10 to /Users/rootulp/.celestia-app/config/genesis.json
    Downloaded genesis file for arabica-10 to /Users/rootulp/.celestia-app/config/genesis.json
    SHA-256 hash verified for arabica-10
    
    $ ./build/celestia-appd download-genesis foo
    Error: unknown chain-id: foo. Must be: celestia, mocha-4, or arabica-10.
    ```
    
    I verified the chain ID actually differs for each file:
    
    ```shell
    $ ./build/celestia-appd download-genesis mocha-4 && cat ~/.celestia-app/config/genesis.json | jq ."chain_id"
    Downloading genesis file for mocha-4 to /Users/rootulp/.celestia-app/config/genesis.json
    Downloaded genesis file for mocha-4 to /Users/rootulp/.celestia-app/config/genesis.json
    SHA-256 hash verified for mocha-4
    "mocha-4"
    
    $ ./build/celestia-appd download-genesis celestia && cat ~/.celestia-app/config/genesis.json | jq ."chain_id"
    Downloading genesis file for celestia to /Users/rootulp/.celestia-app/config/genesis.json
    Downloaded genesis file for celestia to /Users/rootulp/.celestia-app/config/genesis.json
    SHA-256 hash verified for celestia
    "celestia"
    ```
    
    I tampered with the hard-coded Arabica hash and it correctly identified
    the mismatch:
    
    ```shell
    $ ./build/celestia-appd download-genesis arabica-10
    Downloading genesis file for arabica-10 to /Users/rootulp/.celestia-app/config/genesis.json
    Downloaded genesis file for arabica-10 to /Users/rootulp/.celestia-app/config/genesis.json
    Error: sha256 hash mismatch: got fad0a187669f7a2c11bb07f9dc27140d66d2448b7193e186312713856f28e3e1, expected fad0a187669f7a2c11bb07f9dc27140d66d2448b7193e186312713856f28e3e2
    ```
    
    ---------
    
    Co-authored-by: Sanaz Taheri <35961250+staheri14@users.noreply.github.com>
    (cherry picked from commit c34a93d)
    
    # Conflicts:
    #	cmd/celestia-appd/cmd/root.go
    rootulp authored and mergify[bot] committed Oct 31, 2023
    Configuration menu
    Copy the full SHA
    2b7a32e View commit details
    Browse the repository at this point in the history
  2. fix: merge conflict

    rootulp committed Oct 31, 2023
    Configuration menu
    Copy the full SHA
    fb5a3a8 View commit details
    Browse the repository at this point in the history