-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle nil *Any in UnpackAny and add panic handler for tx decoding (#…
…7594) * Handle nil any in UnpackAny * Add test * Add flag back * Update runTx signature * Update Simulate signature * Update calls to Simulate * Add txEncoder in baseapp * Fix TestTxWithoutPublicKey * Wrap errors * Use amino in baseapp tests * Add txEncoder arg to Check & Deliver * Fix gas in test * Fix remaining base app tests * Rename to amionTxEncoder * Update codec/types/interface_registry.go Co-authored-by: Aaron Craelius <aaron@regen.network> * golangci-lint fix Co-authored-by: Amaury Martiny <amaury.martiny@protonmail.com> Co-authored-by: Aaron Craelius <aaron@regen.network> Co-authored-by: Cory Levinson <cjlevinson@gmail.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
- Loading branch information
1 parent
9e7eb0d
commit eba4c8a
Showing
15 changed files
with
173 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package baseapp | ||
|
||
import ( | ||
tmproto "github.com/tendermint/tendermint/proto/tendermint/types" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" | ||
) | ||
|
||
func (app *BaseApp) Check(txEncoder sdk.TxEncoder, tx sdk.Tx) (sdk.GasInfo, *sdk.Result, error) { | ||
// runTx expects tx bytes as argument, so we encode the tx argument into | ||
// bytes. Note that runTx will actually decode those bytes again. But since | ||
// this helper is only used in tests/simulation, it's fine. | ||
bz, err := txEncoder(tx) | ||
if err != nil { | ||
return sdk.GasInfo{}, nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "%s", err) | ||
} | ||
return app.runTx(runTxModeCheck, bz) | ||
} | ||
|
||
func (app *BaseApp) Simulate(txBytes []byte) (sdk.GasInfo, *sdk.Result, error) { | ||
return app.runTx(runTxModeSimulate, txBytes) | ||
} | ||
|
||
func (app *BaseApp) Deliver(txEncoder sdk.TxEncoder, tx sdk.Tx) (sdk.GasInfo, *sdk.Result, error) { | ||
// See comment for Check(). | ||
bz, err := txEncoder(tx) | ||
if err != nil { | ||
return sdk.GasInfo{}, nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "%s", err) | ||
} | ||
return app.runTx(runTxModeDeliver, bz) | ||
} | ||
|
||
// Context with current {check, deliver}State of the app used by tests. | ||
func (app *BaseApp) NewContext(isCheckTx bool, header tmproto.Header) sdk.Context { | ||
if isCheckTx { | ||
return sdk.NewContext(app.checkState.ms, header, true, app.logger). | ||
WithMinGasPrices(app.minGasPrices) | ||
} | ||
|
||
return sdk.NewContext(app.deliverState.ms, header, false, app.logger) | ||
} | ||
|
||
func (app *BaseApp) NewUncachedContext(isCheckTx bool, header tmproto.Header) sdk.Context { | ||
return sdk.NewContext(app.cms, header, isCheckTx, app.logger) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.