Skip to content
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

Problem: internal websocket connection is heavy and unstable #373

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ test-import:
go test -run TestImporterTestSuite -v --vet=off github.com/evmos/ethermint/tests/importer

test-rpc:
./scripts/integration-test-all.sh -t "rpc" -q 1 -z 1 -s 2 -m "rpc" -r "true"
./scripts/integration-test-all.sh -t "rpc" -q 1 -z 1 -s 5 -m "rpc" -r "true"

run-integration-tests:
@nix-shell ./tests/integration_tests/shell.nix --run ./scripts/run-integration-tests.sh
Expand Down
24 changes: 12 additions & 12 deletions rpc/apis.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import (
"github.com/evmos/ethermint/rpc/namespaces/ethereum/web3"
ethermint "github.com/evmos/ethermint/types"

rpcclient "github.com/cometbft/cometbft/rpc/jsonrpc/client"
rpcclient "github.com/cometbft/cometbft/rpc/client"
)

// RPC namespaces and API version
Expand All @@ -60,7 +60,7 @@ const (
type APICreator = func(
ctx *server.Context,
clientCtx client.Context,
tendermintWebsocketClient *rpcclient.WSClient,
tendermintWebsocketClient rpcclient.EventsClient,
allowUnprotectedTxs bool,
indexer ethermint.EVMTxIndexer,
) []rpc.API
Expand All @@ -72,7 +72,7 @@ func init() {
apiCreators = map[string]APICreator{
EthNamespace: func(ctx *server.Context,
clientCtx client.Context,
tmWSClient *rpcclient.WSClient,
evtClient rpcclient.EventsClient,
allowUnprotectedTxs bool,
indexer ethermint.EVMTxIndexer,
) []rpc.API {
Expand All @@ -87,12 +87,12 @@ func init() {
{
Namespace: EthNamespace,
Version: apiVersion,
Service: filters.NewPublicAPI(ctx.Logger, clientCtx, tmWSClient, evmBackend),
Service: filters.NewPublicAPI(ctx.Logger, clientCtx, evtClient, evmBackend),
Public: true,
},
}
},
Web3Namespace: func(*server.Context, client.Context, *rpcclient.WSClient, bool, ethermint.EVMTxIndexer) []rpc.API {
Web3Namespace: func(*server.Context, client.Context, rpcclient.EventsClient, bool, ethermint.EVMTxIndexer) []rpc.API {
return []rpc.API{
{
Namespace: Web3Namespace,
Expand All @@ -102,7 +102,7 @@ func init() {
},
}
},
NetNamespace: func(_ *server.Context, clientCtx client.Context, _ *rpcclient.WSClient, _ bool, _ ethermint.EVMTxIndexer) []rpc.API {
NetNamespace: func(_ *server.Context, clientCtx client.Context, _ rpcclient.EventsClient, _ bool, _ ethermint.EVMTxIndexer) []rpc.API {
return []rpc.API{
{
Namespace: NetNamespace,
Expand All @@ -114,7 +114,7 @@ func init() {
},
PersonalNamespace: func(ctx *server.Context,
clientCtx client.Context,
_ *rpcclient.WSClient,
_ rpcclient.EventsClient,
allowUnprotectedTxs bool,
indexer ethermint.EVMTxIndexer,
) []rpc.API {
Expand All @@ -128,7 +128,7 @@ func init() {
},
}
},
TxPoolNamespace: func(ctx *server.Context, _ client.Context, _ *rpcclient.WSClient, _ bool, _ ethermint.EVMTxIndexer) []rpc.API {
TxPoolNamespace: func(ctx *server.Context, _ client.Context, _ rpcclient.EventsClient, _ bool, _ ethermint.EVMTxIndexer) []rpc.API {
return []rpc.API{
{
Namespace: TxPoolNamespace,
Expand All @@ -140,7 +140,7 @@ func init() {
},
DebugNamespace: func(ctx *server.Context,
clientCtx client.Context,
_ *rpcclient.WSClient,
_ rpcclient.EventsClient,
allowUnprotectedTxs bool,
indexer ethermint.EVMTxIndexer,
) []rpc.API {
Expand All @@ -156,7 +156,7 @@ func init() {
},
MinerNamespace: func(ctx *server.Context,
clientCtx client.Context,
_ *rpcclient.WSClient,
_ rpcclient.EventsClient,
allowUnprotectedTxs bool,
indexer ethermint.EVMTxIndexer,
) []rpc.API {
Expand All @@ -176,7 +176,7 @@ func init() {
// GetRPCAPIs returns the list of all APIs
func GetRPCAPIs(ctx *server.Context,
clientCtx client.Context,
tmWSClient *rpcclient.WSClient,
evtClient rpcclient.EventsClient,
allowUnprotectedTxs bool,
indexer ethermint.EVMTxIndexer,
selectedAPIs []string,
Expand All @@ -185,7 +185,7 @@ func GetRPCAPIs(ctx *server.Context,

for _, ns := range selectedAPIs {
if creator, ok := apiCreators[ns]; ok {
apis = append(apis, creator(ctx, clientCtx, tmWSClient, allowUnprotectedTxs, indexer)...)
apis = append(apis, creator(ctx, clientCtx, evtClient, allowUnprotectedTxs, indexer)...)
} else {
ctx.Logger.Error("invalid namespace value", "namespace", ns)
}
Expand Down
6 changes: 3 additions & 3 deletions rpc/namespaces/ethereum/eth/filters/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import (

"github.com/cometbft/cometbft/libs/log"

rpcclient "github.com/cometbft/cometbft/rpc/client"
coretypes "github.com/cometbft/cometbft/rpc/core/types"
rpcclient "github.com/cometbft/cometbft/rpc/jsonrpc/client"
tmtypes "github.com/cometbft/cometbft/types"

"github.com/ethereum/go-ethereum/common"
Expand Down Expand Up @@ -93,14 +93,14 @@ type PublicFilterAPI struct {
}

// NewPublicAPI returns a new PublicFilterAPI instance.
func NewPublicAPI(logger log.Logger, clientCtx client.Context, tmWSClient *rpcclient.WSClient, backend Backend) *PublicFilterAPI {
func NewPublicAPI(logger log.Logger, clientCtx client.Context, evtClient rpcclient.EventsClient, backend Backend) *PublicFilterAPI {
logger = logger.With("api", "filter")
api := &PublicFilterAPI{
logger: logger,
clientCtx: clientCtx,
backend: backend,
filters: make(map[rpc.ID]*filter),
events: NewEventSystem(logger, tmWSClient),
events: NewEventSystem(logger, evtClient),
}

go api.timeoutLoop()
Expand Down
Loading
Loading