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

Have a default way to download genesis files #2777

Closed
evan-forbes opened this issue Oct 27, 2023 · 3 comments · Fixed by #2791
Closed

Have a default way to download genesis files #2777

evan-forbes opened this issue Oct 27, 2023 · 3 comments · Fixed by #2791
Assignees

Comments

@evan-forbes
Copy link
Member

It would be nice if users have to spend less time thinking about which genesis they download and install.

As pointed out in a sync discussion, osmosis acheives this by including the genesis in the binary. This is a good simple option, as users likely have to download the mainnet genesis anyway.

Another option would be to hardcode the hashes of the genesis for each live network in the binary, and add a subcommand that would download, verify the hash of, and then install the genesis of a specific network.

@adlerjohn
Copy link
Member

Another option would be to hardcode the hashes of the genesis for each live network in the binary, and add a subcommand that would download, verify the hash of, and then install the genesis of a specific network.

This seems like a decent point in the tradeoff space.

@cmwaters
Copy link
Contributor

I agree with just adding support to download the genesis when init is run

@rootulp rootulp self-assigned this Oct 30, 2023
@rootulp
Copy link
Collaborator

rootulp commented Oct 30, 2023

I briefly explored adding this to the celestia-appd init command but init is defined in Cosmos SDK which makes it (a) more difficult to modify and (b) more likely to break when we pull upstream changes. Given our motivation to minimize the diff with upstream, I think another option worth exploring is adding a unique command to celestia-app (e.g. celestia-appd download-genesis <chain-id>).

rootulp added a commit that referenced this issue Oct 31, 2023
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>
mergify bot pushed a commit that referenced this issue Oct 31, 2023
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
0xchainlover pushed a commit to celestia-org/celestia-app that referenced this issue Aug 1, 2024
Closes celestiaorg/celestia-app#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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants