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

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Oct 31, 2023

Backport #2791

Testing

$ ./build/celestia-appd download-genesis
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

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 <[email protected]>
(cherry picked from commit c34a93d)

# Conflicts:
#	cmd/celestia-appd/cmd/root.go
@mergify mergify bot added the conflicts label Oct 31, 2023
@github-actions github-actions bot added the bot item was created by a bot label Oct 31, 2023
@celestia-bot celestia-bot requested a review from a team October 31, 2023 14:28
@rootulp rootulp self-assigned this Oct 31, 2023
@rootulp rootulp enabled auto-merge (squash) October 31, 2023 15:27
@rootulp rootulp requested review from staheri14 and rach-id October 31, 2023 15:34
@rootulp rootulp merged commit f6ac0cd into v1.x Oct 31, 2023
22 of 23 checks passed
@rootulp rootulp deleted the mergify/bp/v1.x/pr-2791 branch October 31, 2023 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot item was created by a bot
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants