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

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

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.
//

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)
}

View File

@ -2,6 +2,7 @@ package server
import (
"net/http"
"time"
"github.com/gorilla/mux"
"github.com/improbable-eng/grpc-web/go/grpcweb"
@ -42,31 +43,32 @@ func AddCommands(rootCmd *cobra.Command, defaultNodeHome string, appCreator type
}
func ConnectTmWS(tmRPCAddr, tmEndpoint string, logger tmlog.Logger) *rpcclient.WSClient {
// tmWsClient, err := rpcclient.NewWS(tmRPCAddr, tmEndpoint,
// rpcclient.MaxReconnectAttempts(256),
// rpcclient.ReadWait(120*time.Second),
// rpcclient.WriteWait(120*time.Second),
// rpcclient.PingPeriod(50*time.Second),
// rpcclient.OnReconnect(func() {
// logger.Debug("EVM RPC reconnects to Tendermint WS", "address", tmRPCAddr+tmEndpoint)
// }),
// )
tmWsClient, err := rpcclient.NewWSWithOptions(tmRPCAddr, tmEndpoint, rpcclient.WSOptions{
MaxReconnectAttempts: 256, // first: 2 sec, last: 17 min.
WriteWait: 120 * time.Second,
ReadWait: 120 * time.Second,
PingPeriod: 50 * time.Second,
})
// if err != nil {
// logger.Error(
// "Tendermint WS client could not be created",
// "address", tmRPCAddr+tmEndpoint,
// "error", err,
// )
// } else if err := tmWsClient.OnStart(); err != nil {
// logger.Error(
// "Tendermint WS client could not start",
// "address", tmRPCAddr+tmEndpoint,
// "error", err,
// )
// }
tmWsClient.OnReconnect(func() {
logger.Debug("EVM RPC reconnects to Tendermint WS", "address", tmRPCAddr+tmEndpoint)
})
return nil
if err != nil {
logger.Error(
"Tendermint WS client could not be created",
"address", tmRPCAddr+tmEndpoint,
"error", err,
)
} else if err := tmWsClient.Start(); err != nil {
logger.Error(
"Tendermint WS client could not start",
"address", tmRPCAddr+tmEndpoint,
"error", err,
)
}
return tmWsClient
}
func MountGRPCWebServices(