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

Simplify #51

Merged
merged 18 commits into from
Mar 23, 2017
Merged

Simplify #51

merged 18 commits into from
Mar 23, 2017

Conversation

ebuchman
Copy link
Member

@ebuchman ebuchman commented Mar 14, 2017

Simplify starting basecoin:

Fix up docs and guides

README.md Outdated

## Learn more
## Guide

1. Getting started with the [Basecoin tool](/docs/guide/basecoin-basics.md)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/tool/basic guide/g?

@ethanfrey
Copy link
Contributor

Very nice. I especially like the merging of genesis files, consolidation to one chain id, and the special format for accounts, to make that more clear, as that is the most common usage of the basecoin config.

I wonder if we should make BCHOME required? Without the default to ~/.basecoin. I think I remember a conversation on slack to that effect, but I'm fine with having the default as well.

This whole refactor really makes basecoin much more of a stand-alone app, and great intro. Now, I just need to get that light-client and a UI working nicely with it...

@ebuchman
Copy link
Member Author

Thanks frey. I think we should keep the default rather than forcing users to set it just to get started. Seems even Go adopted a default GOPATH :)

return nil
}

const privValJSON = `{
Copy link
Contributor

@rigelrozanski rigelrozanski Mar 16, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious as to why are all these json constants hard coded in? aka what is the purpose of not having them in json files that copy? It looks like we're creating new default json files. may make sense to copy these files as to not need to change source code if one wanted to change init parameters. just an idea/not certain on the drawbacks

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just simpler than needing to use a file. We should probably have no defaults and generate new keys/genesis on init but then we can't have a deterministic tutorial.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, definitely need to be able to easily use this for the tutorial.

},
}

func cmdUnsafeResetAll(c *cli.Context) error {
Copy link
Contributor

@rigelrozanski rigelrozanski Mar 16, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like copy-paste from tendermint-core. Should reference common code if possible

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

once all the cobra/cli stuff is merged we can go back through these and replace the ones that are just tendermint

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay agreed

key1File := path.Join(rootDir, "key.json")
key2File := path.Join(rootDir, "key2.json")

if err := ioutil.WriteFile(genesisFile, []byte(genesisJSON), 0644); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For readability, during refactor to cobra, error returns are not-necessarily needed can just exit. As so, we can condense code further using pkg/errors (for tracing) and a function variable, will implement during refactor

exitOnErr := func(err error){
     if err != nil {
          cmn.Exit(fmt.Sprintf("%+v\n", err))
     }
}

exitOnErr(ioutil.WriteFile(genesisFile, []byte(genesisJSON), 0644))
... 

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is one of those things that looks like a good idea at first and is discovered to have been a mistake later. If we ever want this functionality to be useable from a library, its a pain to have to go pull out the exits - best to just return errors.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm.. alright let's talk about this more later, I have had no trouble using traceable errors while debugging checking out failed tests etc. + I find it a whole lot easier to navigate the code.

},
}

func cmdInit(c *cli.Context) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a functional difference (besides the directory) between basecoin init and tendermint init noticed code is totally different, here if just looks like we're writing in some files, don't fully understand everything happening in tendermint init. If there is no other functional difference we should find a way to rectify the two functions to be able to call some core common code if possible. The refactor to cobra should make this easier.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tendermint creates a new key and makes a genesis from that. here we're using hard-coded. when the tendermint cli refactor is merged we can revisit and maybe have a basecoin init --default for sake of deterministic tutorials.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea of having a deterministic option strictly for tutorial usage... maybe a little bit of a discussion in the tutorial explaining this

err := basecoinApp.LoadGenesis(genesisFile)
if err != nil {
return errors.New(cmn.Fmt("%+v", err))
fmt.Println("CHAIN ID", basecoinApp.GetState().GetChainID())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to print CHAIN ID twice? If it is empty, the client will get

"CHAIN ID"
"CHAIN ID test"

if not empty

"CHAIN ID test"
"CHAIN ID test"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No we don't this is old debugging - thanks.

@ebuchman ebuchman merged commit facc428 into develop Mar 23, 2017
@ebuchman ebuchman deleted the simplify branch March 23, 2017 22:13
liamsi pushed a commit to liamsi/cosmos-sdk that referenced this pull request Jun 26, 2018
joeabbey referenced this pull request in joeabbey/cosmos-sdk Jan 21, 2022
Raumo0 pushed a commit to mapofzones/cosmos-sdk that referenced this pull request Feb 13, 2022
Thunnini referenced this pull request in Thunnini/cosmos-sdk Feb 28, 2022
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 this pull request may close these issues.

5 participants