From 758c366def0670a96374e53fa539fcad5148657f Mon Sep 17 00:00:00 2001 From: kevinssgh <79858682+kevinssgh@users.noreply.github.com> Date: Tue, 19 Sep 2023 14:10:37 -0400 Subject: [PATCH 1/2] fix: some data race warnings in zetaclient (#1100) * fixed some data race issues in zetaclient * refactored fix * cleanup extra spaces and comments. --- Makefile | 4 ++-- contrib/localnet/orchestrator/smoketest/main.go | 6 ++++-- zetaclient/broadcast.go | 10 ++++------ zetaclient/tss_signer.go | 1 + zetaclient/zetabridge.go | 6 +++++- 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index ec328166c6..99f64d7951 100644 --- a/Makefile +++ b/Makefile @@ -82,8 +82,8 @@ build-testnet-ubuntu: go.sum install: go.sum @echo "--> Installing zetacored & zetaclientd" - @go install -mod=readonly $(BUILD_FLAGS) ./cmd/zetacored - @go install -mod=readonly $(BUILD_FLAGS) ./cmd/zetaclientd + @go install -race -mod=readonly $(BUILD_FLAGS) ./cmd/zetacored + @go install -race -mod=readonly $(BUILD_FLAGS) ./cmd/zetaclientd install-zetaclient: go.sum @echo "--> Installing zetaclientd" diff --git a/contrib/localnet/orchestrator/smoketest/main.go b/contrib/localnet/orchestrator/smoketest/main.go index 5608bfca90..c08b04d3ac 100644 --- a/contrib/localnet/orchestrator/smoketest/main.go +++ b/contrib/localnet/orchestrator/smoketest/main.go @@ -148,6 +148,9 @@ func LocalSmokeTest(_ *cobra.Command, _ []string) { bankClient := banktypes.NewQueryClient(grpcConn) observerClient := observertypes.NewQueryClient(grpcConn) + //Wait for Genesis + time.Sleep(20 * time.Second) + // initialize client to send messages to ZetaChain zetaTxServer, err := NewZetaTxServer( "http://zetacore0:26657", @@ -158,8 +161,7 @@ func LocalSmokeTest(_ *cobra.Command, _ []string) { panic(err) } - // Wait for Genesis and keygen to be completed. ~ height 30 - time.Sleep(20 * time.Second) + //Wait for keygen to be completed. ~ height 30 for { time.Sleep(5 * time.Second) response, err := cctxClient.LastZetaHeight(context.Background(), &crosschaintypes.QueryLastZetaHeightRequest{}) diff --git a/zetaclient/broadcast.go b/zetaclient/broadcast.go index a9c9c91b3c..70f1ce0739 100644 --- a/zetaclient/broadcast.go +++ b/zetaclient/broadcast.go @@ -13,7 +13,6 @@ import ( authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" flag "github.com/spf13/pflag" rpchttp "github.com/tendermint/tendermint/rpc/client/http" - "github.com/zeta-chain/zetacore/app" ) // Broadcast Broadcasts tx to metachain. Returns txHash and error @@ -119,11 +118,10 @@ func (b *ZetaCoreBridge) GetContext() client.Context { ctx = ctx.WithFromAddress(addr) ctx = ctx.WithBroadcastMode("sync") - encodingConfig := app.MakeEncodingConfig() - ctx = ctx.WithCodec(encodingConfig.Codec) - ctx = ctx.WithInterfaceRegistry(encodingConfig.InterfaceRegistry) - ctx = ctx.WithTxConfig(encodingConfig.TxConfig) - ctx = ctx.WithLegacyAmino(encodingConfig.Amino) + ctx = ctx.WithCodec(b.encodingCfg.Codec) + ctx = ctx.WithInterfaceRegistry(b.encodingCfg.InterfaceRegistry) + ctx = ctx.WithTxConfig(b.encodingCfg.TxConfig) + ctx = ctx.WithLegacyAmino(b.encodingCfg.Amino) ctx = ctx.WithAccountRetriever(authtypes.AccountRetriever{}) remote := b.cfg.ChainRPC diff --git a/zetaclient/tss_signer.go b/zetaclient/tss_signer.go index d0e540017d..d171c74ff9 100644 --- a/zetaclient/tss_signer.go +++ b/zetaclient/tss_signer.go @@ -173,6 +173,7 @@ func (tss *TSS) SignBatch(digests [][]byte, height uint64, chain *common.Chain) digestBase64[i] = base64.StdEncoding.EncodeToString(digest) } keysignReq := keysign.NewRequest(tssPubkey, digestBase64, int64(height), nil, "0.14.0") + ksRes, err := tss.Server.KeySign(keysignReq) if err != nil { log.Warn().Err(err).Msg("keysign fail") diff --git a/zetaclient/zetabridge.go b/zetaclient/zetabridge.go index 64a7a565bd..6e4c625ec2 100644 --- a/zetaclient/zetabridge.go +++ b/zetaclient/zetabridge.go @@ -4,6 +4,8 @@ import ( "fmt" "time" + "github.com/cosmos/cosmos-sdk/simapp/params" + "github.com/zeta-chain/zetacore/common" "sync" @@ -32,6 +34,7 @@ import ( //"strconv" //"strings" + "github.com/zeta-chain/zetacore/app" crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types" observertypes "github.com/zeta-chain/zetacore/x/observer/types" "github.com/zeta-chain/zetacore/zetaclient/config" @@ -46,6 +49,7 @@ type ZetaCoreBridge struct { grpcConn *grpc.ClientConn httpClient *retryablehttp.Client cfg config.ClientConfiguration + encodingCfg params.EncodingConfig keys *Keys broadcastLock *sync.RWMutex zetaChainID string @@ -92,6 +96,7 @@ func NewZetaCoreBridge(k *Keys, chainIP string, signerName string, chainID strin accountNumber: accountsMap, seqNumber: seqMap, cfg: cfg, + encodingCfg: app.MakeEncodingConfig(), keys: k, broadcastLock: &sync.RWMutex{}, lastOutTxReportTime: map[string]time.Time{}, @@ -194,7 +199,6 @@ func (b *ZetaCoreBridge) UpdateConfigFromCore(cfg *config.Config, init bool) err } cfg.UpdateCoreParams(keyGen, newChains, newEVMParams, newBTCParams, init, b.logger) - cfg.Keygen = *keyGen tss, err := b.GetCurrentTss() if err != nil { b.logger.Error().Err(err).Msg("Unable to fetch TSS from zetacore") From de85c7faa88d9ef49b4bf8336d2d0cf7fa25c30e Mon Sep 17 00:00:00 2001 From: Lucas Bertrand Date: Wed, 20 Sep 2023 16:58:55 +0200 Subject: [PATCH 2/2] fix(`rpc`): reduce Ethereum rpc API and improve websocket API (#1106) * disable debug and personal * disable eth not secure * goimports * set message limit * set limit to 32MB * Update rpc/websockets.go --------- Co-authored-by: Charlie Chen <34498985+ws4charlie@users.noreply.github.com> --- rpc/apis.go | 129 +++++++++--------- rpc/namespaces/ethereum/debug/api.go | 10 +- rpc/namespaces/ethereum/eth/api.go | 60 ++++---- rpc/namespaces/ethereum/eth/filters/api.go | 14 +- .../ethereum/eth/filters/filter_system.go | 16 +-- .../ethereum/eth/filters/filters.go | 12 +- rpc/namespaces/ethereum/miner/api.go | 3 - rpc/namespaces/ethereum/personal/api.go | 13 +- rpc/namespaces/ethereum/txpool/api.go | 4 +- rpc/namespaces/ethereum/web3/api.go | 3 +- rpc/websockets.go | 17 ++- 11 files changed, 127 insertions(+), 154 deletions(-) diff --git a/rpc/apis.go b/rpc/apis.go index 3256f42d77..da130ad0a1 100644 --- a/rpc/apis.go +++ b/rpc/apis.go @@ -20,21 +20,14 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/server" - "github.com/ethereum/go-ethereum/rpc" - ethermint "github.com/evmos/ethermint/types" + rpcclient "github.com/tendermint/tendermint/rpc/jsonrpc/client" "github.com/zeta-chain/zetacore/rpc/backend" - "github.com/zeta-chain/zetacore/rpc/namespaces/ethereum/debug" "github.com/zeta-chain/zetacore/rpc/namespaces/ethereum/eth" "github.com/zeta-chain/zetacore/rpc/namespaces/ethereum/eth/filters" - "github.com/zeta-chain/zetacore/rpc/namespaces/ethereum/miner" "github.com/zeta-chain/zetacore/rpc/namespaces/ethereum/net" - "github.com/zeta-chain/zetacore/rpc/namespaces/ethereum/personal" - "github.com/zeta-chain/zetacore/rpc/namespaces/ethereum/txpool" "github.com/zeta-chain/zetacore/rpc/namespaces/ethereum/web3" - - rpcclient "github.com/tendermint/tendermint/rpc/jsonrpc/client" ) // RPC namespaces and API version @@ -47,8 +40,8 @@ const ( Web3Namespace = "web3" EthNamespace = "eth" - PersonalNamespace = "personal" NetNamespace = "net" + PersonalNamespace = "personal" TxPoolNamespace = "txpool" DebugNamespace = "debug" MinerNamespace = "miner" @@ -112,64 +105,66 @@ func init() { }, } }, - PersonalNamespace: func(ctx *server.Context, - clientCtx client.Context, - _ *rpcclient.WSClient, - allowUnprotectedTxs bool, - indexer ethermint.EVMTxIndexer, - ) []rpc.API { - evmBackend := backend.NewBackend(ctx, ctx.Logger, clientCtx, allowUnprotectedTxs, indexer) - return []rpc.API{ - { - Namespace: PersonalNamespace, - Version: apiVersion, - Service: personal.NewAPI(ctx.Logger, evmBackend), - Public: false, - }, - } - }, - TxPoolNamespace: func(ctx *server.Context, _ client.Context, _ *rpcclient.WSClient, _ bool, _ ethermint.EVMTxIndexer) []rpc.API { - return []rpc.API{ - { - Namespace: TxPoolNamespace, - Version: apiVersion, - Service: txpool.NewPublicAPI(ctx.Logger), - Public: true, - }, - } - }, - DebugNamespace: func(ctx *server.Context, - clientCtx client.Context, - _ *rpcclient.WSClient, - allowUnprotectedTxs bool, - indexer ethermint.EVMTxIndexer, - ) []rpc.API { - evmBackend := backend.NewBackend(ctx, ctx.Logger, clientCtx, allowUnprotectedTxs, indexer) - return []rpc.API{ - { - Namespace: DebugNamespace, - Version: apiVersion, - Service: debug.NewAPI(ctx, evmBackend), - Public: true, - }, - } - }, - MinerNamespace: func(ctx *server.Context, - clientCtx client.Context, - _ *rpcclient.WSClient, - allowUnprotectedTxs bool, - indexer ethermint.EVMTxIndexer, - ) []rpc.API { - evmBackend := backend.NewBackend(ctx, ctx.Logger, clientCtx, allowUnprotectedTxs, indexer) - return []rpc.API{ - { - Namespace: MinerNamespace, - Version: apiVersion, - Service: miner.NewPrivateAPI(ctx, evmBackend), - Public: false, - }, - } - }, + // Disabled + // NOTE: Public field of API is deprecated and defined only for compatibility. + //PersonalNamespace: func(ctx *server.Context, + // clientCtx client.Context, + // _ *rpcclient.WSClient, + // allowUnprotectedTxs bool, + // indexer ethermint.EVMTxIndexer, + //) []rpc.API { + // evmBackend := backend.NewBackend(ctx, ctx.Logger, clientCtx, allowUnprotectedTxs, indexer) + // return []rpc.API{ + // { + // Namespace: PersonalNamespace, + // Version: apiVersion, + // Service: personal.NewAPI(ctx.Logger, evmBackend), + // Public: false, + // }, + // } + //}, + //TxPoolNamespace: func(ctx *server.Context, _ client.Context, _ *rpcclient.WSClient, _ bool, _ ethermint.EVMTxIndexer) []rpc.API { + // return []rpc.API{ + // { + // Namespace: TxPoolNamespace, + // Version: apiVersion, + // Service: txpool.NewPublicAPI(ctx.Logger), + // Public: true, + // }, + // } + //}, + //DebugNamespace: func(ctx *server.Context, + // clientCtx client.Context, + // _ *rpcclient.WSClient, + // allowUnprotectedTxs bool, + // indexer ethermint.EVMTxIndexer, + //) []rpc.API { + // evmBackend := backend.NewBackend(ctx, ctx.Logger, clientCtx, allowUnprotectedTxs, indexer) + // return []rpc.API{ + // { + // Namespace: DebugNamespace, + // Version: apiVersion, + // Service: debug.NewAPI(ctx, evmBackend), + // Public: true, + // }, + // } + //}, + //MinerNamespace: func(ctx *server.Context, + // clientCtx client.Context, + // _ *rpcclient.WSClient, + // allowUnprotectedTxs bool, + // indexer ethermint.EVMTxIndexer, + //) []rpc.API { + // evmBackend := backend.NewBackend(ctx, ctx.Logger, clientCtx, allowUnprotectedTxs, indexer) + // return []rpc.API{ + // { + // Namespace: MinerNamespace, + // Version: apiVersion, + // Service: miner.NewPrivateAPI(ctx, evmBackend), + // Public: false, + // }, + // } + //}, } } diff --git a/rpc/namespaces/ethereum/debug/api.go b/rpc/namespaces/ethereum/debug/api.go index 0620b67be0..94f771ab39 100644 --- a/rpc/namespaces/ethereum/debug/api.go +++ b/rpc/namespaces/ethereum/debug/api.go @@ -27,18 +27,14 @@ import ( "sync" "time" - "github.com/davecgh/go-spew/spew" - - evmtypes "github.com/evmos/ethermint/x/evm/types" - - stderrors "github.com/pkg/errors" - "github.com/cosmos/cosmos-sdk/server" - + "github.com/davecgh/go-spew/spew" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/consensus/ethash" "github.com/ethereum/go-ethereum/rlp" + evmtypes "github.com/evmos/ethermint/x/evm/types" + stderrors "github.com/pkg/errors" "github.com/tendermint/tendermint/libs/log" "github.com/zeta-chain/zetacore/rpc/backend" rpctypes "github.com/zeta-chain/zetacore/rpc/types" diff --git a/rpc/namespaces/ethereum/eth/api.go b/rpc/namespaces/ethereum/eth/api.go index d62ddbe18c..7d05848b91 100644 --- a/rpc/namespaces/ethereum/eth/api.go +++ b/rpc/namespaces/ethereum/eth/api.go @@ -18,20 +18,14 @@ package eth import ( "context" - "github.com/ethereum/go-ethereum/signer/core/apitypes" - - "github.com/ethereum/go-ethereum/rpc" - - "github.com/tendermint/tendermint/libs/log" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" ethtypes "github.com/ethereum/go-ethereum/core/types" - - "github.com/zeta-chain/zetacore/rpc/backend" - + "github.com/ethereum/go-ethereum/rpc" ethermint "github.com/evmos/ethermint/types" evmtypes "github.com/evmos/ethermint/x/evm/types" + "github.com/tendermint/tendermint/libs/log" + "github.com/zeta-chain/zetacore/rpc/backend" rpctypes "github.com/zeta-chain/zetacore/rpc/types" ) @@ -67,7 +61,6 @@ type EthereumAPI interface { // Allows developers to both send ETH from one address to another, write data // on-chain, and interact with smart contracts. SendRawTransaction(data hexutil.Bytes) (common.Hash, error) - SendTransaction(args evmtypes.TransactionArgs) (common.Hash, error) // eth_sendPrivateTransaction // eth_cancel PrivateTransaction @@ -111,9 +104,7 @@ type EthereumAPI interface { // Other Syncing() (interface{}, error) Coinbase() (string, error) - Sign(address common.Address, data hexutil.Bytes) (hexutil.Bytes, error) GetTransactionLogs(txHash common.Hash) ([]*ethtypes.Log, error) - SignTypedData(address common.Address, typedData apitypes.TypedData) (hexutil.Bytes, error) FillTransaction(args evmtypes.TransactionArgs) (*rpctypes.SignTransactionResult, error) Resend(ctx context.Context, args evmtypes.TransactionArgs, gasPrice *hexutil.Big, gasLimit *hexutil.Uint64) (common.Hash, error) GetPendingTransactions() ([]*rpctypes.RPCTransaction, error) @@ -125,6 +116,11 @@ type EthereumAPI interface { // eth_getWork (on Ethereum.org) // eth_submitWork (on Ethereum.org) // eth_submitHashrate (on Ethereum.org) + + // Disabled APIs for security reasons + //SendTransaction(args evmtypes.TransactionArgs) (common.Hash, error) + //Sign(address common.Address, data hexutil.Bytes) (hexutil.Bytes, error) + //SignTypedData(address common.Address, typedData apitypes.TypedData) (hexutil.Bytes, error) } var _ EthereumAPI = (*PublicAPI)(nil) @@ -230,12 +226,6 @@ func (e *PublicAPI) SendRawTransaction(data hexutil.Bytes) (common.Hash, error) return e.backend.SendRawTransaction(data) } -// SendTransaction sends an Ethereum transaction. -func (e *PublicAPI) SendTransaction(args evmtypes.TransactionArgs) (common.Hash, error) { - e.logger.Debug("eth_sendTransaction", "args", args.String()) - return e.backend.SendTransaction(args) -} - /////////////////////////////////////////////////////////////////////////////// /// Account Information /// /////////////////////////////////////////////////////////////////////////////// @@ -416,12 +406,6 @@ func (e *PublicAPI) Coinbase() (string, error) { return ethAddr.Hex(), nil } -// Sign signs the provided data using the private key of address via Geth's signature standard. -func (e *PublicAPI) Sign(address common.Address, data hexutil.Bytes) (hexutil.Bytes, error) { - e.logger.Debug("eth_sign", "address", address.Hex(), "data", common.Bytes2Hex(data)) - return e.backend.Sign(address, data) -} - // GetTransactionLogs returns the logs given a transaction hash. func (e *PublicAPI) GetTransactionLogs(txHash common.Hash) ([]*ethtypes.Log, error) { e.logger.Debug("eth_getTransactionLogs", "hash", txHash) @@ -448,12 +432,6 @@ func (e *PublicAPI) GetTransactionLogs(txHash common.Hash) ([]*ethtypes.Log, err return backend.TxLogsFromEvents(resBlockResult.TxsResults[res.TxIndex].Events, int(res.MsgIndex)) } -// SignTypedData signs EIP-712 conformant typed data -func (e *PublicAPI) SignTypedData(address common.Address, typedData apitypes.TypedData) (hexutil.Bytes, error) { - e.logger.Debug("eth_signTypedData", "address", address.Hex(), "data", typedData) - return e.backend.SignTypedData(address, typedData) -} - // FillTransaction fills the defaults (nonce, gas, gasPrice or 1559 fields) // on a given unsigned transaction, and returns it to the caller for further // processing (signing + broadcast). @@ -527,3 +505,25 @@ func (e *PublicAPI) GetPendingTransactions() ([]*rpctypes.RPCTransaction, error) return result, nil } + +/////////////////////////////////////////////////////////////////////////////// +/// Disabled /// +/////////////////////////////////////////////////////////////////////////////// + +//// SendTransaction sends an Ethereum transaction. +//func (e *PublicAPI) SendTransaction(args evmtypes.TransactionArgs) (common.Hash, error) { +// e.logger.Debug("eth_sendTransaction", "args", args.String()) +// return e.backend.SendTransaction(args) +//} +// +//// Sign signs the provided data using the private key of address via Geth's signature standard. +//func (e *PublicAPI) Sign(address common.Address, data hexutil.Bytes) (hexutil.Bytes, error) { +// e.logger.Debug("eth_sign", "address", address.Hex(), "data", common.Bytes2Hex(data)) +// return e.backend.Sign(address, data) +//} +// +//// SignTypedData signs EIP-712 conformant typed data +//func (e *PublicAPI) SignTypedData(address common.Address, typedData apitypes.TypedData) (hexutil.Bytes, error) { +// e.logger.Debug("eth_signTypedData", "address", address.Hex(), "data", typedData) +// return e.backend.SignTypedData(address, typedData) +//} diff --git a/rpc/namespaces/ethereum/eth/filters/api.go b/rpc/namespaces/ethereum/eth/filters/api.go index f6a9135a16..0268c7217d 100644 --- a/rpc/namespaces/ethereum/eth/filters/api.go +++ b/rpc/namespaces/ethereum/eth/filters/api.go @@ -22,20 +22,16 @@ import ( "time" "github.com/cosmos/cosmos-sdk/client" - "github.com/zeta-chain/zetacore/rpc/types" - - "github.com/tendermint/tendermint/libs/log" - - coretypes "github.com/tendermint/tendermint/rpc/core/types" - rpcclient "github.com/tendermint/tendermint/rpc/jsonrpc/client" - tmtypes "github.com/tendermint/tendermint/types" - "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/eth/filters" "github.com/ethereum/go-ethereum/rpc" - evmtypes "github.com/evmos/ethermint/x/evm/types" + "github.com/tendermint/tendermint/libs/log" + coretypes "github.com/tendermint/tendermint/rpc/core/types" + rpcclient "github.com/tendermint/tendermint/rpc/jsonrpc/client" + tmtypes "github.com/tendermint/tendermint/types" + "github.com/zeta-chain/zetacore/rpc/types" ) // FilterAPI gathers diff --git a/rpc/namespaces/ethereum/eth/filters/filter_system.go b/rpc/namespaces/ethereum/eth/filters/filter_system.go index ac69cfc53d..ba203cf685 100644 --- a/rpc/namespaces/ethereum/eth/filters/filter_system.go +++ b/rpc/namespaces/ethereum/eth/filters/filter_system.go @@ -21,23 +21,19 @@ import ( "sync" "time" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/ethereum/go-ethereum/common" + ethtypes "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/eth/filters" + "github.com/ethereum/go-ethereum/rpc" + evmtypes "github.com/evmos/ethermint/x/evm/types" "github.com/pkg/errors" - tmjson "github.com/tendermint/tendermint/libs/json" "github.com/tendermint/tendermint/libs/log" tmquery "github.com/tendermint/tendermint/libs/pubsub/query" coretypes "github.com/tendermint/tendermint/rpc/core/types" rpcclient "github.com/tendermint/tendermint/rpc/jsonrpc/client" tmtypes "github.com/tendermint/tendermint/types" - - "github.com/ethereum/go-ethereum/common" - ethtypes "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/eth/filters" - "github.com/ethereum/go-ethereum/rpc" - - sdk "github.com/cosmos/cosmos-sdk/types" - - evmtypes "github.com/evmos/ethermint/x/evm/types" "github.com/zeta-chain/zetacore/rpc/ethereum/pubsub" ) diff --git a/rpc/namespaces/ethereum/eth/filters/filters.go b/rpc/namespaces/ethereum/eth/filters/filters.go index 7bcb08fd75..4355182001 100644 --- a/rpc/namespaces/ethereum/eth/filters/filters.go +++ b/rpc/namespaces/ethereum/eth/filters/filters.go @@ -21,17 +21,15 @@ import ( "fmt" "math/big" - "github.com/zeta-chain/zetacore/rpc/backend" - "github.com/zeta-chain/zetacore/rpc/types" - - "github.com/pkg/errors" - "github.com/tendermint/tendermint/libs/log" - tmrpctypes "github.com/tendermint/tendermint/rpc/core/types" - "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/eth/filters" + "github.com/pkg/errors" + "github.com/tendermint/tendermint/libs/log" + tmrpctypes "github.com/tendermint/tendermint/rpc/core/types" + "github.com/zeta-chain/zetacore/rpc/backend" + "github.com/zeta-chain/zetacore/rpc/types" ) // BloomIV represents the bit indexes and value inside the bloom filter that belong diff --git a/rpc/namespaces/ethereum/miner/api.go b/rpc/namespaces/ethereum/miner/api.go index 901c567a46..9d5e8fc556 100644 --- a/rpc/namespaces/ethereum/miner/api.go +++ b/rpc/namespaces/ethereum/miner/api.go @@ -17,12 +17,9 @@ package miner import ( "github.com/cosmos/cosmos-sdk/server" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/tendermint/tendermint/libs/log" - "github.com/zeta-chain/zetacore/rpc/backend" ) diff --git a/rpc/namespaces/ethereum/personal/api.go b/rpc/namespaces/ethereum/personal/api.go index 49b654c8dc..fa182c4759 100644 --- a/rpc/namespaces/ethereum/personal/api.go +++ b/rpc/namespaces/ethereum/personal/api.go @@ -21,22 +21,17 @@ import ( "os" "time" - "github.com/zeta-chain/zetacore/rpc/backend" - - "github.com/evmos/ethermint/crypto/hd" - ethermint "github.com/evmos/ethermint/types" - - "github.com/tendermint/tendermint/libs/log" - "github.com/cosmos/cosmos-sdk/crypto/keyring" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/ethereum/go-ethereum/accounts" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/crypto" - + "github.com/evmos/ethermint/crypto/hd" + ethermint "github.com/evmos/ethermint/types" evmtypes "github.com/evmos/ethermint/x/evm/types" + "github.com/tendermint/tendermint/libs/log" + "github.com/zeta-chain/zetacore/rpc/backend" ) // PrivateAccountAPI is the personal_ prefixed set of APIs in the Web3 JSON-RPC spec. diff --git a/rpc/namespaces/ethereum/txpool/api.go b/rpc/namespaces/ethereum/txpool/api.go index e8320b6655..89fb056bde 100644 --- a/rpc/namespaces/ethereum/txpool/api.go +++ b/rpc/namespaces/ethereum/txpool/api.go @@ -16,10 +16,8 @@ package txpool import ( - "github.com/tendermint/tendermint/libs/log" - "github.com/ethereum/go-ethereum/common/hexutil" - + "github.com/tendermint/tendermint/libs/log" "github.com/zeta-chain/zetacore/rpc/types" ) diff --git a/rpc/namespaces/ethereum/web3/api.go b/rpc/namespaces/ethereum/web3/api.go index 47f522785d..46e09d9637 100644 --- a/rpc/namespaces/ethereum/web3/api.go +++ b/rpc/namespaces/ethereum/web3/api.go @@ -19,10 +19,9 @@ import ( "fmt" "runtime" - "github.com/zeta-chain/zetacore/common" - "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/crypto" + "github.com/zeta-chain/zetacore/common" ) // PublicAPI is the web3_ prefixed set of APIs in the Web3 JSON-RPC spec. diff --git a/rpc/websockets.go b/rpc/websockets.go index c76a028ea3..ba0419efcc 100644 --- a/rpc/websockets.go +++ b/rpc/websockets.go @@ -27,27 +27,28 @@ import ( "sync" "github.com/cosmos/cosmos-sdk/client" - "github.com/gorilla/mux" - "github.com/gorilla/websocket" - "github.com/pkg/errors" - "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/eth/filters" "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/rpc" - + evmtypes "github.com/evmos/ethermint/x/evm/types" + "github.com/gorilla/mux" + "github.com/gorilla/websocket" + "github.com/pkg/errors" "github.com/tendermint/tendermint/libs/log" rpcclient "github.com/tendermint/tendermint/rpc/jsonrpc/client" tmtypes "github.com/tendermint/tendermint/types" - - evmtypes "github.com/evmos/ethermint/x/evm/types" "github.com/zeta-chain/zetacore/rpc/ethereum/pubsub" rpcfilters "github.com/zeta-chain/zetacore/rpc/namespaces/ethereum/eth/filters" "github.com/zeta-chain/zetacore/rpc/types" "github.com/zeta-chain/zetacore/server/config" ) +const ( + messageSizeLimit = 32 * 1024 * 1024 // 32MB +) + type WebsocketsServer interface { Start() } @@ -139,6 +140,8 @@ func (s *websocketsServer) ServeHTTP(w http.ResponseWriter, r *http.Request) { return } + conn.SetReadLimit(messageSizeLimit) + s.readLoop(&wsConn{ mux: new(sync.Mutex), conn: conn,