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

Initialize Genesis State #416

Merged
merged 15 commits into from
Feb 13, 2018
Merged

Initialize Genesis State #416

merged 15 commits into from
Feb 13, 2018

Conversation

rigelrozanski
Copy link
Contributor

closes #339
This PR includes some cleanup to make go-lint compliant

@rigelrozanski rigelrozanski changed the base branch from develop to feature/remove_tmc_dep February 4, 2018 20:57
@codecov
Copy link

codecov bot commented Feb 5, 2018

Codecov Report

Merging #416 into develop will increase coverage by 0.05%.
The diff coverage is 58.2%.

@@             Coverage Diff             @@
##           develop     #416      +/-   ##
===========================================
+ Coverage    52.13%   52.18%   +0.05%     
===========================================
  Files           34       35       +1     
  Lines         1619     1671      +52     
===========================================
+ Hits           844      872      +28     
- Misses         721      742      +21     
- Partials        54       57       +3

@rigelrozanski rigelrozanski changed the base branch from feature/remove_tmc_dep to develop February 7, 2018 13:33
@@ -32,33 +32,37 @@ type BaseApp struct {
// Main (uncached) state
cms sdk.CommitMultiStore

// Unmarshal []byte into sdk.Tx
// unmarshal []byte into sdk.Tx
Copy link
Member

Choose a reason for hiding this comment

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

Let's try to keep comments well formed (capitalized and with periods). https://github.com/tendermint/coding/blob/master/go/coding_standard.md#various

Copy link
Member

Choose a reason for hiding this comment

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

Did go-lint really complain about this ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no, there are not sentences, as in the spec, only sentences should start capitalized. Everything else should start lowercase and end without a period... We should further clarify this in the spec

@@ -174,7 +183,7 @@ func (app *BaseApp) initFromStore(mainKey sdk.StoreKey) error {

//----------------------------------------

// Implements ABCI.
// Implements ABCI
Copy link
Member

Choose a reason for hiding this comment

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

Why get rid of periods? It's also in the coding conventions

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See my previous comment (not a sentence)

@rigelrozanski rigelrozanski changed the title WIP: Initialize Genesis State Initialize Genesis State Feb 12, 2018
@cosmos cosmos deleted a comment from rigelrozanski Feb 13, 2018
Copy link
Member

@ebuchman ebuchman left a comment

Choose a reason for hiding this comment

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

Thanks Rige. I'll try to wrap this up tonight

// TODO this is dup code from tendermint-core to avoid dep issues
// should probably remove from both SDK / Tendermint and move to tmlibs
// ^^^^^^^^^^^^^ This is my preference to avoid DEP hell
// or sync up versioning and just reference tendermint
Copy link
Member

Choose a reason for hiding this comment

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

lol our deps are in a brutal state :(

we need to make sure it never happens again. obscene.

}
app.BaseApp.BeginBlock(abci.RequestBeginBlock{
Hash: nil,
Header: header,
Copy link
Member

Choose a reason for hiding this comment

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

why do we need this ?!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

to set up the multistore cache wrap for deliver store used in NewContext, I just made this code considerably smaller

@@ -26,3 +33,68 @@ func (app *BasecoinApp) initBaseAppTxDecoder() {
return tx, nil
})
}

// We use GenesisAccount instead of types.AppAccount for cleaner json input of PubKey
Copy link
Member

Choose a reason for hiding this comment

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

is this because we don't have go-wire JSON yet ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no, json representation of the new PubKey is a byte array... I'd obviously rather not use an input struct, if you have any other ideas lmn

Copy link
Member

Choose a reason for hiding this comment

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

Oh, we don't even need PubKeys for accounts in the genesis file!

return nil
}

var gaccs []*GenesisAccount
Copy link
Member

Choose a reason for hiding this comment

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

we should more clearly state this expectation somewhere - probably define an AppGenesis type that is a []*GenesisAccount ... or probably better to use a struct containing a []*GenesisAccount.

ie. we want to make clear somewhere outside this function what the json in the genesis should look like

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point, an alternative design should actually be used for custom genesis types which defines its own unmarshalling. aka AppAccount should actually exist as a custom module within basecoin which defines genesis unmarshalling... right now everything is just kind of unmarshalled here, I'm going to integrate this change in with the basecoin refactor


func main() {
fmt.Println("TODO: move examples/basecoin/main.go here and refactor")
// TODO CREATE CLI
Copy link
Member

Choose a reason for hiding this comment

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

++

types/errors.go Outdated
CodeUnknownRequest CodeType = 6
CodeUnrecognizedAddress CodeType = 7
CodeInvalidSequence CodeType = 8
CodeGenesisParse CodeType = 3
Copy link
Member

Choose a reason for hiding this comment

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

weird seeing this in here. InitChain doesn't even return a code - do we need this ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

SetInitStater can return error when initializing genesis - what error code would you use otherwise? CodeInternal?

@ebuchman ebuchman merged commit 69c316f into develop Feb 13, 2018
@ebuchman ebuchman deleted the feature/initgen branch February 13, 2018 12:38
ParthDesai pushed a commit to ChorusOne/cosmos-sdk that referenced this pull request Apr 19, 2021
* Alter identifier requirements
* Rebuild PDF
patiee pushed a commit to patiee/cosmos-sdk that referenced this pull request Mar 23, 2023
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.

InitChain logic to initialize genesis state
3 participants