-
Notifications
You must be signed in to change notification settings - Fork 4.1k
fix(unorderedtx): issues reported in audit #21467
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
Changes from 11 commits
7aba2e7
8f3e2cb
83fa1f0
75e79c0
33665d5
0661845
c100377
af42e6c
32ec055
a06cc3f
8a5018e
5109b45
d86bfd4
8031960
9be58bd
7ccca5d
efee58b
74c1faa
d29c921
7b3ffef
804415f
0b9141a
dcc9705
4b30492
cf9fd70
274c596
0fcc166
9974f61
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ import ( | |
| _ "embed" | ||
| "fmt" | ||
| "io" | ||
| "path/filepath" | ||
|
|
||
| clienthelpers "cosmossdk.io/client/v2/helpers" | ||
| "cosmossdk.io/core/address" | ||
|
|
@@ -35,6 +36,7 @@ import ( | |
|
|
||
| "github.com/cosmos/cosmos-sdk/baseapp" | ||
| "github.com/cosmos/cosmos-sdk/client" | ||
| "github.com/cosmos/cosmos-sdk/client/flags" | ||
| "github.com/cosmos/cosmos-sdk/codec" | ||
| codectypes "github.com/cosmos/cosmos-sdk/codec/types" | ||
| "github.com/cosmos/cosmos-sdk/runtime" | ||
|
|
@@ -43,13 +45,15 @@ import ( | |
| "github.com/cosmos/cosmos-sdk/server/config" | ||
| servertypes "github.com/cosmos/cosmos-sdk/server/types" | ||
| testdata_pulsar "github.com/cosmos/cosmos-sdk/testutil/testdata/testpb" | ||
| sdk "github.com/cosmos/cosmos-sdk/types" | ||
| "github.com/cosmos/cosmos-sdk/types/module" | ||
| "github.com/cosmos/cosmos-sdk/x/auth" | ||
| "github.com/cosmos/cosmos-sdk/x/auth/ante" | ||
| "github.com/cosmos/cosmos-sdk/x/auth/ante/unorderedtx" | ||
| authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" | ||
| authsims "github.com/cosmos/cosmos-sdk/x/auth/simulation" | ||
| authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" | ||
| "github.com/spf13/cast" | ||
| ) | ||
|
|
||
| // DefaultNodeHome default home directories for the application daemon | ||
|
|
@@ -268,6 +272,16 @@ func NewSimApp( | |
| // return app.App.InitChainer(ctx, req) | ||
| // }) | ||
|
|
||
| // create, start, and load the unordered tx manager | ||
|
||
| utxDataDir := filepath.Join(cast.ToString(appOpts.Get(flags.FlagHome)), "data") | ||
| app.UnorderedTxManager = unorderedtx.NewManager(utxDataDir) | ||
| app.UnorderedTxManager.Start() | ||
| app.SetPrecommiter(app.Precommiter) | ||
|
|
||
| if err := app.UnorderedTxManager.OnInit(); err != nil { | ||
| panic(fmt.Errorf("failed to initialize unordered tx manager: %w", err)) | ||
| } | ||
|
|
||
| // register custom snapshot extensions (if any) | ||
| if manager := app.SnapshotManager(); manager != nil { | ||
| if err := manager.RegisterExtensions( | ||
|
|
@@ -312,6 +326,23 @@ func (app *SimApp) setCustomAnteHandler() { | |
| app.SetAnteHandler(anteHandler) | ||
| } | ||
|
|
||
| func (app *SimApp) Precommiter(ctx sdk.Context) { | ||
|
||
| if err := app.ModuleManager.Precommit(ctx); err != nil { | ||
| panic(err) | ||
| } | ||
|
|
||
| app.UnorderedTxManager.OnNewBlock(ctx.BlockTime()) | ||
| } | ||
|
|
||
| // Close implements the Application interface and closes all necessary application | ||
|
||
| // resources. | ||
| func (app *SimApp) Close() error { | ||
| if err := app.BaseApp.Close(); err != nil { | ||
| return err | ||
| } | ||
| return app.UnorderedTxManager.Close() | ||
| } | ||
|
|
||
| // LegacyAmino returns SimApp's amino codec. | ||
| // | ||
| // NOTE: This is solely to be used for testing purposes as it may be desirable | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.