Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrbrt committed Aug 26, 2024
1 parent 207ccae commit 90f4aeb
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 10 deletions.
12 changes: 11 additions & 1 deletion UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,17 @@ need to remove them both from your app.go code, they will yield to unresolvable
The Cosmos SDK now supports unordered transactions. This means that transactions
can be executed in any order and doesn't require the client to deal with or manage
nonces. This also means the order of execution is not guaranteed.
Unordered transactions are automatically enabled when using runtime / depinject.

Unordered transactions are automatically enabled when using `depinject` / app di, simply supply the `servertypes.AppOptions` in `app.go`:

```diff
depinject.Supply(
+ // supply the application options
+ appOpts,
// supply the logger
logger,
)
```

<details>
<summary>Step-by-step Wiring </summary>
Expand Down
12 changes: 8 additions & 4 deletions runtime/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,15 @@ func (a *App) Load(loadLatest bool) error {
return nil
}

// Close implements the Application interface and closes all necessary application
// resources.
// Close closes all necessary application resources.
// It implements servertypes.Application.
func (a *App) Close() error {
if err := a.UnorderedTxManager.Close(); err != nil {
return err
// the unordered tx manager could be nil (unlikely but possible)
// if the app has no app options supplied.
if a.UnorderedTxManager != nil {
if err := a.UnorderedTxManager.Close(); err != nil {
return err
}
}

return a.BaseApp.Close()
Expand Down
4 changes: 2 additions & 2 deletions simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -662,8 +662,8 @@ func (app *SimApp) setPostHandler() {
app.SetPostHandler(postHandler)
}

// Close implements the Application interface and closes all necessary application
// resources.
// Close closes all necessary application resources.
// It implements servertypes.Application.
func (app *SimApp) Close() error {
if err := app.BaseApp.Close(); err != nil {
return err
Expand Down
1 change: 1 addition & 0 deletions simapp/app_config.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//nolint:unused,nolintlint // ignore unused code linting
package simapp

import (
Expand Down
1 change: 1 addition & 0 deletions simapp/v2/app_config.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//nolint:unused,nolintlint // ignore unused code linting
package simapp

import (
Expand Down
6 changes: 5 additions & 1 deletion testutil/network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import (
srvconfig "github.com/cosmos/cosmos-sdk/server/config"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
"github.com/cosmos/cosmos-sdk/testutil"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
Expand Down Expand Up @@ -210,7 +211,10 @@ func DefaultConfigWithAppConfig(appConfig depinject.Config, baseappOpts ...func(
if err := depinject.Inject(
depinject.Configs(
appConfig,
depinject.Supply(val.GetLogger()),
depinject.Supply(
val.GetLogger(),
simtestutil.NewAppOptionsWithFlagHome(val.GetViper().GetString(flags.FlagHome)),
),
),
&appBuilder); err != nil {
panic(err)
Expand Down
1 change: 0 additions & 1 deletion x/auth/ante/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {

if options.UnorderedTxManager != nil {
anteDecorators = append(anteDecorators, NewUnorderedTxDecorator(unorderedtx.DefaultMaxTimeoutDuration, options.UnorderedTxManager, options.Environment, DefaultSha256Cost))

}

return sdk.ChainAnteDecorators(anteDecorators...), nil
Expand Down
2 changes: 1 addition & 1 deletion x/auth/tx/config/depinject.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,12 @@ func newAnteHandler(txConfig client.TxConfig, in ModuleInputs) (sdk.AnteHandler,

anteHandler, err := ante.NewAnteHandler(
ante.HandlerOptions{
Environment: in.Environment,
AccountKeeper: in.AccountKeeper,
BankKeeper: in.BankKeeper,
SignModeHandler: txConfig.SignModeHandler(),
FeegrantKeeper: in.FeeGrantKeeper,
SigGasConsumer: ante.DefaultSigVerificationGasConsumer,
Environment: in.Environment,
UnorderedTxManager: in.UnorderedTxManager,
},
)
Expand Down

0 comments on commit 90f4aeb

Please sign in to comment.