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

feat: export genesis in simapp v2 #21199

Merged
merged 48 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
ebf5006
add state export
tac0turtle Jun 24, 2024
268c034
minor
tac0turtle Jun 24, 2024
babf339
Merge branch 'main' into marko/state_export
tac0turtle Jul 1, 2024
6780043
comment out export zero height
tac0turtle Jul 1, 2024
61c0343
Merge branch 'main' into marko/state_export
randygrok Jul 30, 2024
b8ac0e5
add logic for export app state and bootstrap simapp tests
randygrok Aug 6, 2024
a1b0a5f
fix bug with export genesis nil pointer
randygrok Aug 6, 2024
71d0027
some additions to continue the test
randygrok Aug 6, 2024
cadccd4
add context with value
randygrok Aug 6, 2024
7bc73f0
remove commented code
randygrok Aug 7, 2024
728313a
go mod tidy all
randygrok Aug 7, 2024
e97fda6
add version on export
randygrok Aug 7, 2024
57c9751
include export validators
randygrok Aug 8, 2024
a32d778
add validators into status
randygrok Aug 8, 2024
4bcf345
include new types mode
randygrok Aug 9, 2024
7006da5
go mod tidy all
randygrok Aug 13, 2024
91570fb
temp commit, include logic for zeroheight
randygrok Aug 13, 2024
de93866
remove zero height part
randygrok Aug 13, 2024
9fc2546
add export
randygrok Aug 13, 2024
7a1fa60
apply into simapp v2
randygrok Aug 13, 2024
6b32d53
Merge remote-tracking branch 'origin/main' into randy/export-genesis
randygrok Aug 13, 2024
db542cf
remove option to export certain modules only
randygrok Aug 13, 2024
70f1090
remove modules to export feature
randygrok Aug 13, 2024
ea0193d
remove modules to export feature part 2
randygrok Aug 13, 2024
c552beb
remove debug entry in manager
randygrok Aug 13, 2024
f67770e
delete commented code
randygrok Aug 14, 2024
2948e09
rename RunWithCtx
randygrok Aug 14, 2024
a0ffd0a
race condition not fixed yet
randygrok Aug 14, 2024
519d6b7
remove concurrent export
randygrok Aug 14, 2024
f199f06
include issue number
randygrok Aug 14, 2024
11ec8d2
fix lint
randygrok Aug 15, 2024
a634633
fix lint, last
randygrok Aug 15, 2024
e0093cf
move ExportedApp to genutil
randygrok Aug 15, 2024
5ab7c1a
Merge branch 'main' into randy/export-genesis
randygrok Aug 15, 2024
da07a4a
lint
randygrok Aug 15, 2024
264434e
Merge branch 'randy/export-genesis' of github.com-randy:cosmos/cosmos…
randygrok Aug 15, 2024
aedc7b0
remove duplicated package on import
randygrok Aug 15, 2024
8f97b21
lint
randygrok Aug 15, 2024
9156b86
linter
randygrok Aug 15, 2024
858af16
pass linter
randygrok Aug 15, 2024
a789413
remove unsafe message
randygrok Aug 15, 2024
dee4c3b
remove command
randygrok Aug 15, 2024
5051c67
review changes
randygrok Aug 15, 2024
73e839b
Revert "remove option to export certain modules only"
randygrok Aug 15, 2024
98b4397
remove comment
randygrok Aug 15, 2024
4324f42
Merge branch 'main' into randy/export-genesis
randygrok Aug 15, 2024
3ea6367
bring back viper sets
randygrok Aug 16, 2024
1874e0c
Merge branch 'randy/export-genesis' of github.com-randy:cosmos/cosmos…
randygrok Aug 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
remove modules to export feature part 2
  • Loading branch information
randygrok committed Aug 13, 2024
commit ea0193d25640a7c05f2f1b0e355666b22bf34730
2 changes: 1 addition & 1 deletion simapp/v2/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

// ExportAppStateAndValidators exports the state of the application for a genesis
// file.
func (app *SimApp[T]) ExportAppStateAndValidators(jailAllowedAddrs, modulesToExport []string) (serverv2.ExportedApp, error) {
func (app *SimApp[T]) ExportAppStateAndValidators(jailAllowedAddrs []string) (serverv2.ExportedApp, error) {
// as if they could withdraw from the start of the next block
ctx := context.Background()
Copy link
Contributor

Choose a reason for hiding this comment

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

Use context with timeout or cancellation.

Using context.Background() does not allow for timeout or cancellation. Consider using context.WithTimeout or context.WithCancel to handle potential long-running operations.

ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()


Expand Down
11 changes: 3 additions & 8 deletions simapp/v2/simdv2/cmd/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/genutil"
genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
genutilv2 "github.com/cosmos/cosmos-sdk/x/genutil/v2"
)

func newApp[T transaction.Tx](
Expand Down Expand Up @@ -81,12 +82,7 @@ func initRootCmd[T transaction.Tx](
// genesisCommand builds genesis-related `simd genesis` command. Users may provide application specific commands as a parameter
func genesisCommand[T transaction.Tx](
moduleManager *runtimev2.MM[T],
appExport func(logger log.Logger,
height int64,
jailAllowedAddrs []string,
viper *viper.Viper,
modulesToExport []string,
) (serverv2.ExportedApp, error),
appExport genutilv2.AppExporter,
cmds ...*cobra.Command,
) *cobra.Command {
cmd := v2.Commands(moduleManager.Modules()[genutiltypes.ModuleName].(genutil.AppModule), moduleManager, appExport)
Expand Down Expand Up @@ -149,7 +145,6 @@ func appExport[T transaction.Tx](
height int64,
jailAllowedAddrs []string,
viper *viper.Viper,
modulesToExport []string,
) (serverv2.ExportedApp, error) {
// overwrite the FlagInvCheckPeriod
viper.Set(server.FlagInvCheckPeriod, 1)
Expand All @@ -165,7 +160,7 @@ func appExport[T transaction.Tx](
simApp = simapp.NewSimApp[T](logger, viper)
}

return simApp.ExportAppStateAndValidators(jailAllowedAddrs, modulesToExport)
return simApp.ExportAppStateAndValidators(jailAllowedAddrs)
}

var _ transaction.Codec[transaction.Tx] = &genericTxDecoder[transaction.Tx]{}
Expand Down
2 changes: 1 addition & 1 deletion x/genutil/v2/cli/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func ExportCmd(appExporter v2.AppExporter) *cobra.Command {
jailAllowedAddrs, _ := cmd.Flags().GetStringSlice(flagJailAllowedAddrs)
outputDocument, _ := cmd.Flags().GetString(flags.FlagOutputDocument)

exported, err := appExporter(logger, height, jailAllowedAddrs, viper, modulesToExport)
exported, err := appExporter(logger, height, jailAllowedAddrs, viper)
if err != nil {
return fmt.Errorf("error exporting state: %w", err)
}
Expand Down
1 change: 0 additions & 1 deletion x/genutil/v2/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import (
"cosmossdk.io/log"
serverv2 "cosmossdk.io/server/v2"

Check failure on line 5 in x/genutil/v2/types.go

View workflow job for this annotation

GitHub Actions / dependency-review

no required module provides package cosmossdk.io/server/v2; to add it:

Check failure on line 5 in x/genutil/v2/types.go

View workflow job for this annotation

GitHub Actions / dependency-review

no required module provides package cosmossdk.io/server/v2; to add it:

Check failure on line 5 in x/genutil/v2/types.go

View workflow job for this annotation

GitHub Actions / dependency-review

could not import cosmossdk.io/server/v2 (invalid package name: "")

"github.com/spf13/viper"
)
Expand All @@ -14,5 +14,4 @@
height int64,
jailAllowedAddrs []string,
viper *viper.Viper,
modulesToExport []string,
) (serverv2.ExportedApp, error)
Loading