Skip to content

Commit

Permalink
add version on export
Browse files Browse the repository at this point in the history
  • Loading branch information
randygrok committed Aug 7, 2024
1 parent 728313a commit e97fda6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 14 deletions.
4 changes: 2 additions & 2 deletions server/v2/appmanager/appmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (a AppManager[T]) InitGenesis(

// ExportGenesis exports the genesis state of the application.
func (a AppManager[T]) ExportGenesis(ctx context.Context, version uint64) ([]byte, error) {
v, zeroState, err := a.db.StateLatest()
zeroState, err := a.db.StateAt(version)
if err != nil {
return nil, fmt.Errorf("unable to get latest state: %w", err)
}
Expand All @@ -102,7 +102,7 @@ func (a AppManager[T]) ExportGenesis(ctx context.Context, version uint64) ([]byt
return errors.New("export genesis function not set")
}

bz, err = a.exportGenesis(ctx, v)
bz, err = a.exportGenesis(ctx, version)
if err != nil {
return fmt.Errorf("failed to export genesis state: %w", err)
}
Expand Down
5 changes: 1 addition & 4 deletions simapp/v2/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
serverv2 "cosmossdk.io/server/v2"
"crypto/sha256"
"encoding/json"
"fmt"
"testing"
"time"

Expand Down Expand Up @@ -107,8 +106,6 @@ func TestSimAppExportAndBlockedAddrs(t *testing.T) {

MoveNextBlock(t, app, ctx)

gen, err := app.ExportAppStateAndValidators(false, nil, nil)
_, err := app.ExportAppStateAndValidators(false, nil, nil)
require.NoError(t, err)

fmt.Printf("Exported genesis: %s\n", gen.AppState)
}
10 changes: 2 additions & 8 deletions simapp/v2/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,14 @@ func (app *SimApp[T]) ExportAppStateAndValidators(forZeroHeight bool, jailAllowe
// as if they could withdraw from the start of the next block
ctx := context.Background()

// We export at last height + 1, because that's the height at which
// CometBFT will start InitChain.
latestHeight, err := app.LoadLatestHeight()

if err != nil {
return servertypes.ExportedApp{}, err
}
height := latestHeight + 1
// if forZeroHeight {
// height = 0
// app.prepForZeroHeightGenesis(ctx, jailAllowedAddrs)
// }
height := latestHeight

genesis, err := app.ExportGenesis(ctx, height)
genesis, err := app.ExportGenesis(ctx, latestHeight)
if err != nil {
return servertypes.ExportedApp{}, err
}
Expand Down

0 comments on commit e97fda6

Please sign in to comment.