fix : fix the chain start

This commit is contained in:
Sai Kumar
2022-04-23 20:07:00 +05:30
parent feae504ff8
commit 9d7333d4fb
4 changed files with 49 additions and 35 deletions
+3 -7
View File
@@ -76,9 +76,7 @@ func (md MD) CheckTx(ctx context.Context, req tx.Request, checkReq tx.RequestChe
// return tx.Response{}, tx.ResponseCheckTx{}, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "invalid transaction type: %T", reqTx)
// }
anteHandler = md.cosmosMiddleware
return anteHandler.CheckTx(ctx, req, checkReq)
return md.cosmosMiddleware.CheckTx(ctx, req, checkReq)
}
// DeliverTx implements tx.Handler
@@ -107,8 +105,7 @@ func (md MD) DeliverTx(ctx context.Context, req tx.Request) (tx.Response, error)
}
}
anteHandler = md.cosmosMiddleware
return anteHandler.DeliverTx(ctx, req)
return md.cosmosMiddleware.DeliverTx(ctx, req)
}
// SimulateTx implements tx.Handler
@@ -137,8 +134,7 @@ func (md MD) SimulateTx(ctx context.Context, req tx.Request) (tx.Response, error
}
}
anteHandler = md.cosmosMiddleware
return anteHandler.SimulateTx(ctx, req)
return md.cosmosMiddleware.SimulateTx(ctx, req)
}
var _ authante.SignatureVerificationGasConsumer = DefaultSigVerificationGasConsumer
-5
View File
@@ -80,11 +80,8 @@ func newEthAuthMiddleware(options HandlerOptions) (tx.Handler, error) {
}
func newCosmosAuthMiddleware(options HandlerOptions) (tx.Handler, error) {
return authmiddleware.ComposeMiddlewares(
authmiddleware.NewRunMsgsTxHandler(options.MsgServiceRouter, options.LegacyRouter),
// reject MsgEthereumTxs
NewRejectMessagesDecorator(),
authmiddleware.NewTxDecoderMiddleware(options.TxDecoder),
// Set a new GasMeter on sdk.Context.
//
@@ -130,8 +127,6 @@ func newCosmosAnteHandlerEip712(options HandlerOptions) (tx.Handler, error) {
return authmiddleware.ComposeMiddlewares(
authmiddleware.NewRunMsgsTxHandler(options.MsgServiceRouter, options.LegacyRouter),
// reject MsgEthereumTxs
NewRejectMessagesDecorator(),
authmiddleware.NewTxDecoderMiddleware(options.TxDecoder),
// Set a new GasMeter on sdk.Context.
//
+21
View File
@@ -36,16 +36,37 @@ func (rmd RejectMessagesDecorator) CheckTx(ctx context.Context, req tx.Request,
)
}
}
return rmd.next.CheckTx(ctx, req, checkReq)
}
// DeliverTx implements tx.Handler
func (rmd RejectMessagesDecorator) DeliverTx(ctx context.Context, req tx.Request) (tx.Response, error) {
reqTx := req.Tx
for _, msg := range reqTx.GetMsgs() {
if _, ok := msg.(*evmtypes.MsgEthereumTx); ok {
return tx.Response{}, sdkerrors.Wrapf(
sdkerrors.ErrInvalidType,
"MsgEthereumTx needs to be contained within a tx with 'ExtensionOptionsEthereumTx' option",
)
}
}
return rmd.next.DeliverTx(ctx, req)
}
// SimulateTx implements tx.Handler
func (rmd RejectMessagesDecorator) SimulateTx(ctx context.Context, req tx.Request) (tx.Response, error) {
reqTx := req.Tx
for _, msg := range reqTx.GetMsgs() {
if _, ok := msg.(*evmtypes.MsgEthereumTx); ok {
return tx.Response{}, sdkerrors.Wrapf(
sdkerrors.ErrInvalidType,
"MsgEthereumTx needs to be contained within a tx with 'ExtensionOptionsEthereumTx' option",
)
}
}
return rmd.next.SimulateTx(ctx, req)
}