-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Dump all state to JSON #901
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #901 +/- ##
===========================================
- Coverage 62.61% 60.42% -2.19%
===========================================
Files 65 72 +7
Lines 3314 3500 +186
===========================================
+ Hits 2075 2115 +40
- Misses 1072 1215 +143
- Partials 167 170 +3 |
00d1b15
to
744a1e9
Compare
Swapped to general gaiad export > ~/.gaiad/config/genesis.json
# modify some consensus rules, rebuild
gaiad start |
Ready for review, the code coverage isn't very accurate & this isn't consensus-level anyways. Thoughts on this approach / alternative suggestions welcome. |
x/stake/keeper.go
Outdated
@@ -371,6 +371,30 @@ func (k Keeper) GetDelegatorBond(ctx sdk.Context, | |||
return bond, true | |||
} | |||
|
|||
// load all bonds | |||
func (k Keeper) GetBonds(ctx sdk.Context, maxRetrieve int16) (bonds []DelegatorBond) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need to be exposed? I don't think we need to use this outside of specialized stake functionality
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, now unexposed.
x/stake/handler.go
Outdated
@@ -49,9 +49,29 @@ func NewEndBlocker(k Keeper) sdk.EndBlocker { | |||
//_____________________________________________________________________ | |||
|
|||
// InitGenesis - store genesis parameters | |||
func InitGenesis(ctx sdk.Context, k Keeper, data GenesisState) { | |||
func (k Keeper) InitGenesis(ctx sdk.Context, data GenesisState) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
InitGenesis
(and WriteGenesis
now) should not be functions of the keeper. It's subtle, but a while back Jae and I came the conclusion that handler ought to not be a function of keeper, by extension I'd put genesis functionality in the same category
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed.
a20ac0d
to
6d0c313
Compare
cmd/gaia/app/app.go
Outdated
@@ -149,7 +149,15 @@ func (app *GaiaApp) initChainer(ctx sdk.Context, req abci.RequestInitChain) abci | |||
} | |||
|
|||
// load the initial stake information | |||
stake.InitGenesis(ctx, app.stakeKeeper, genesisState.StakeData) | |||
stake.InitGenesis(app.stakeKeeper, ctx, genesisState.StakeData) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why did you switch it's standard that the context is always the first function input
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, updated all instances.
cmd/gaia/cmd/gaiad/main.go
Outdated
if err != nil { | ||
return nil, nil, err | ||
} | ||
bapp := app.NewGaiaApp(log.NewNopLogger(), db) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bapp -> gapp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
cmd/gaia/cmd/gaiad/main.go
Outdated
} | ||
bapp := app.NewGaiaApp(log.NewNopLogger(), db) | ||
if err != nil { | ||
return nil, nil, err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This error check is not checking any new errors :P
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, too much vim-copy-search-replace fu. Fixed.
cmd/gaia/cmd/gaiad/main.go
Outdated
@@ -39,3 +40,16 @@ func generateApp(rootDir string, logger log.Logger) (abci.Application, error) { | |||
bapp := app.NewGaiaApp(logger, db) | |||
return bapp, nil | |||
} | |||
|
|||
func exportApp(rootDir string, logger log.Logger) (interface{}, *wire.Codec, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just reviewed all the instances of exportApp
in this PR and I think that we should be able to move it's functionality to baseapp
- we should probably really limit/group what is actually being passed into server.AddCommands
that list is growing fast, I think we just pass in the app
which extends baseapp
and therefore should have access to exportApp if we build it into their. - We could do this refactors as in this PR or in a separate PR I guess
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, I'll do this in this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reworked generateApp
and baseApp
to share common functionality, let me know what you think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good - I think we should refactor to bring exportApp
into baseapp
as I mentioned in one of my comments
Addressed PR comments and added an iterator to export accounts properly. Testsuite presently fails, I think because the account mapper no longer uses the main store. |
Testcases fixed, just needed to change some store names. Curious if there was a reason accounts were using the main store, or if it was just unintentional? edit: Per conversation, seems to be unintentional & using a separate store is the right approach. |
c67c98f
to
10ddd7a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice work
Closes #131