mirror of
https://github.com/status-im/status-go.git
synced 2025-02-20 02:38:13 +00:00
chore_: initial steps to decouple rpc chain modules (#5856)
* chore_: moved chain rpclimiter and tagger to separate packages * chore_: initial steps to decouple rpc chain modules
This commit is contained in:
parent
a7daee3dae
commit
dd994587a3
2
Makefile
2
Makefile
@ -345,6 +345,8 @@ mock: ##@other Regenerate mocks
|
||||
mockgen -package=mock_transactor -destination=transactions/mock_transactor/transactor.go -source=transactions/transactor.go
|
||||
mockgen -package=mock_rpcclient -destination=rpc/mock/client/client.go -source=rpc/client.go
|
||||
mockgen -package=mock_network -destination=rpc/network/mock/network.go -source=rpc/network/network.go
|
||||
mockgen -package=mock_ethclient -destination=rpc/chain/mock/client/ethclient/eth_client.go -source=rpc/chain/ethclient/eth_client.go
|
||||
mockgen -package=mock_ethclient -destination=rpc/chain/mock/client/ethclient/rps_limited_eth_client.go -source=rpc/chain/ethclient/rps_limited_eth_client.go
|
||||
mockgen -package=mock_client -destination=rpc/chain/mock/client/client.go -source=rpc/chain/client.go
|
||||
mockgen -package=mock_token -destination=services/wallet/token/mock/token/tokenmanager.go -source=services/wallet/token/token.go
|
||||
mockgen -package=mock_balance_persistence -destination=services/wallet/token/mock/balance_persistence/balance_persistence.go -source=services/wallet/token/balance_persistence.go
|
||||
|
@ -15,61 +15,25 @@ import (
|
||||
"github.com/ethereum/go-ethereum/core"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/core/vm"
|
||||
"github.com/ethereum/go-ethereum/ethclient"
|
||||
"github.com/ethereum/go-ethereum/log"
|
||||
"github.com/ethereum/go-ethereum/rpc"
|
||||
"github.com/status-im/status-go/circuitbreaker"
|
||||
"github.com/status-im/status-go/rpc/chain/ethclient"
|
||||
"github.com/status-im/status-go/rpc/chain/rpclimiter"
|
||||
"github.com/status-im/status-go/rpc/chain/tagger"
|
||||
"github.com/status-im/status-go/services/rpcstats"
|
||||
"github.com/status-im/status-go/services/wallet/connection"
|
||||
)
|
||||
|
||||
type BatchCallClient interface {
|
||||
BatchCallContext(ctx context.Context, b []rpc.BatchElem) error
|
||||
}
|
||||
|
||||
type ChainInterface interface {
|
||||
BatchCallClient
|
||||
HeaderByHash(ctx context.Context, hash common.Hash) (*types.Header, error)
|
||||
BlockByHash(ctx context.Context, hash common.Hash) (*types.Block, error)
|
||||
BlockByNumber(ctx context.Context, number *big.Int) (*types.Block, error)
|
||||
NonceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (uint64, error)
|
||||
FilterLogs(ctx context.Context, q ethereum.FilterQuery) ([]types.Log, error)
|
||||
BalanceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (*big.Int, error)
|
||||
HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error)
|
||||
CallBlockHashByTransaction(ctx context.Context, blockNumber *big.Int, index uint) (common.Hash, error)
|
||||
GetBaseFeeFromBlock(ctx context.Context, blockNumber *big.Int) (string, error)
|
||||
type ClientInterface interface {
|
||||
ethclient.EthClientInterface
|
||||
NetworkID() uint64
|
||||
ToBigInt() *big.Int
|
||||
CodeAt(ctx context.Context, contract common.Address, blockNumber *big.Int) ([]byte, error)
|
||||
CallContract(ctx context.Context, call ethereum.CallMsg, blockNumber *big.Int) ([]byte, error)
|
||||
CallContext(ctx context.Context, result interface{}, method string, args ...interface{}) error
|
||||
TransactionByHash(ctx context.Context, hash common.Hash) (*types.Transaction, bool, error)
|
||||
TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error)
|
||||
BlockNumber(ctx context.Context) (uint64, error)
|
||||
}
|
||||
|
||||
type ClientInterface interface {
|
||||
ChainInterface
|
||||
GetWalletNotifier() func(chainId uint64, message string)
|
||||
SetWalletNotifier(notifier func(chainId uint64, message string))
|
||||
connection.Connectable
|
||||
bind.ContractCaller
|
||||
bind.ContractTransactor
|
||||
bind.ContractFilterer
|
||||
GetLimiter() RequestLimiter
|
||||
SetLimiter(RequestLimiter)
|
||||
}
|
||||
|
||||
type Tagger interface {
|
||||
Tag() string
|
||||
SetTag(tag string)
|
||||
GroupTag() string
|
||||
SetGroupTag(tag string)
|
||||
DeepCopyTag() Tagger
|
||||
}
|
||||
|
||||
func DeepCopyTagger(t Tagger) Tagger {
|
||||
return t.DeepCopyTag()
|
||||
GetLimiter() rpclimiter.RequestLimiter
|
||||
SetLimiter(rpclimiter.RequestLimiter)
|
||||
}
|
||||
|
||||
type HealthMonitor interface {
|
||||
@ -86,8 +50,8 @@ type Copyable interface {
|
||||
// to set the tag and group tag once on the client
|
||||
func ClientWithTag(chainClient ClientInterface, tag, groupTag string) ClientInterface {
|
||||
newClient := chainClient
|
||||
if tagIface, ok := chainClient.(Tagger); ok {
|
||||
tagIface = DeepCopyTagger(tagIface)
|
||||
if tagIface, ok := chainClient.(tagger.Tagger); ok {
|
||||
tagIface = tagger.DeepCopyTagger(tagIface)
|
||||
tagIface.SetTag(tag)
|
||||
tagIface.SetGroupTag(groupTag)
|
||||
newClient = tagIface.(ClientInterface)
|
||||
@ -96,26 +60,10 @@ func ClientWithTag(chainClient ClientInterface, tag, groupTag string) ClientInte
|
||||
return newClient
|
||||
}
|
||||
|
||||
type EthClient struct {
|
||||
ethClient *ethclient.Client
|
||||
limiter *RPCRpsLimiter
|
||||
rpcClient *rpc.Client
|
||||
name string
|
||||
}
|
||||
|
||||
func NewEthClient(ethClient *ethclient.Client, limiter *RPCRpsLimiter, rpcClient *rpc.Client, name string) *EthClient {
|
||||
return &EthClient{
|
||||
ethClient: ethClient,
|
||||
limiter: limiter,
|
||||
rpcClient: rpcClient,
|
||||
name: name,
|
||||
}
|
||||
}
|
||||
|
||||
type ClientWithFallback struct {
|
||||
ChainID uint64
|
||||
ethClients []*EthClient
|
||||
commonLimiter RequestLimiter
|
||||
ethClients []ethclient.RPSLimitedEthClientInterface
|
||||
commonLimiter rpclimiter.RequestLimiter
|
||||
circuitbreaker *circuitbreaker.CircuitBreaker
|
||||
|
||||
WalletNotifier func(chainId uint64, message string)
|
||||
@ -161,26 +109,7 @@ var propagateErrors = []error{
|
||||
bind.ErrNoCode,
|
||||
}
|
||||
|
||||
func NewSimpleClient(ethClient EthClient, chainID uint64) *ClientWithFallback {
|
||||
cbConfig := circuitbreaker.Config{
|
||||
Timeout: 20000,
|
||||
MaxConcurrentRequests: 100,
|
||||
SleepWindow: 300000,
|
||||
ErrorPercentThreshold: 25,
|
||||
}
|
||||
|
||||
isConnected := &atomic.Bool{}
|
||||
isConnected.Store(true)
|
||||
return &ClientWithFallback{
|
||||
ChainID: chainID,
|
||||
ethClients: []*EthClient{ðClient},
|
||||
isConnected: isConnected,
|
||||
LastCheckedAt: time.Now().Unix(),
|
||||
circuitbreaker: circuitbreaker.NewCircuitBreaker(cbConfig),
|
||||
}
|
||||
}
|
||||
|
||||
func NewClient(ethClients []*EthClient, chainID uint64) *ClientWithFallback {
|
||||
func NewClient(ethClients []ethclient.RPSLimitedEthClientInterface, chainID uint64) *ClientWithFallback {
|
||||
cbConfig := circuitbreaker.Config{
|
||||
Timeout: 20000,
|
||||
MaxConcurrentRequests: 100,
|
||||
@ -202,7 +131,7 @@ func NewClient(ethClients []*EthClient, chainID uint64) *ClientWithFallback {
|
||||
|
||||
func (c *ClientWithFallback) Close() {
|
||||
for _, client := range c.ethClients {
|
||||
client.ethClient.Close()
|
||||
client.Close()
|
||||
}
|
||||
}
|
||||
|
||||
@ -255,7 +184,7 @@ func (c *ClientWithFallback) IsConnected() bool {
|
||||
return c.isConnected.Load()
|
||||
}
|
||||
|
||||
func (c *ClientWithFallback) makeCall(ctx context.Context, ethClients []*EthClient, f func(client *EthClient) (interface{}, error)) (interface{}, error) {
|
||||
func (c *ClientWithFallback) makeCall(ctx context.Context, ethClients []ethclient.RPSLimitedEthClientInterface, f func(client ethclient.RPSLimitedEthClientInterface) (interface{}, error)) (interface{}, error) {
|
||||
if c.commonLimiter != nil {
|
||||
if allow, err := c.commonLimiter.Allow(c.tag); !allow {
|
||||
return nil, fmt.Errorf("tag=%s, %w", c.tag, err)
|
||||
@ -272,17 +201,20 @@ func (c *ClientWithFallback) makeCall(ctx context.Context, ethClients []*EthClie
|
||||
for _, provider := range ethClients {
|
||||
provider := provider
|
||||
cmd.Add(circuitbreaker.NewFunctor(func() ([]interface{}, error) {
|
||||
err := provider.limiter.WaitForRequestsAvailability(1)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
limiter := provider.GetLimiter()
|
||||
if limiter != nil {
|
||||
err := provider.GetLimiter().WaitForRequestsAvailability(1)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
res, err := f(provider)
|
||||
if err != nil {
|
||||
if isRPSLimitError(err) {
|
||||
provider.limiter.ReduceLimit()
|
||||
if limiter != nil && isRPSLimitError(err) {
|
||||
provider.GetLimiter().ReduceLimit()
|
||||
|
||||
err = provider.limiter.WaitForRequestsAvailability(1)
|
||||
err = provider.GetLimiter().WaitForRequestsAvailability(1)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -300,7 +232,7 @@ func (c *ClientWithFallback) makeCall(ctx context.Context, ethClients []*EthClie
|
||||
return nil, err
|
||||
}
|
||||
return []interface{}{res}, err
|
||||
}, provider.name))
|
||||
}, provider.GetName()))
|
||||
}
|
||||
|
||||
result := c.circuitbreaker.Execute(cmd)
|
||||
@ -315,8 +247,8 @@ func (c *ClientWithFallback) BlockByHash(ctx context.Context, hash common.Hash)
|
||||
rpcstats.CountCallWithTag("eth_BlockByHash", c.tag)
|
||||
|
||||
res, err := c.makeCall(
|
||||
ctx, c.ethClients, func(client *EthClient) (interface{}, error) {
|
||||
return client.ethClient.BlockByHash(ctx, hash)
|
||||
ctx, c.ethClients, func(client ethclient.RPSLimitedEthClientInterface) (interface{}, error) {
|
||||
return client.BlockByHash(ctx, hash)
|
||||
},
|
||||
)
|
||||
|
||||
@ -332,8 +264,8 @@ func (c *ClientWithFallback) BlockByHash(ctx context.Context, hash common.Hash)
|
||||
func (c *ClientWithFallback) BlockByNumber(ctx context.Context, number *big.Int) (*types.Block, error) {
|
||||
rpcstats.CountCallWithTag("eth_BlockByNumber", c.tag)
|
||||
res, err := c.makeCall(
|
||||
ctx, c.ethClients, func(client *EthClient) (interface{}, error) {
|
||||
return client.ethClient.BlockByNumber(ctx, number)
|
||||
ctx, c.ethClients, func(client ethclient.RPSLimitedEthClientInterface) (interface{}, error) {
|
||||
return client.BlockByNumber(ctx, number)
|
||||
},
|
||||
)
|
||||
|
||||
@ -350,26 +282,8 @@ func (c *ClientWithFallback) BlockNumber(ctx context.Context) (uint64, error) {
|
||||
rpcstats.CountCallWithTag("eth_BlockNumber", c.tag)
|
||||
|
||||
res, err := c.makeCall(
|
||||
ctx, c.ethClients, func(client *EthClient) (interface{}, error) {
|
||||
return client.ethClient.BlockNumber(ctx)
|
||||
},
|
||||
)
|
||||
|
||||
c.toggleConnectionState(err)
|
||||
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return res.(uint64), nil
|
||||
}
|
||||
|
||||
func (c *ClientWithFallback) PeerCount(ctx context.Context) (uint64, error) {
|
||||
rpcstats.CountCallWithTag("eth_PeerCount", c.tag)
|
||||
|
||||
res, err := c.makeCall(
|
||||
ctx, c.ethClients, func(client *EthClient) (interface{}, error) {
|
||||
return client.ethClient.PeerCount(ctx)
|
||||
ctx, c.ethClients, func(client ethclient.RPSLimitedEthClientInterface) (interface{}, error) {
|
||||
return client.BlockNumber(ctx)
|
||||
},
|
||||
)
|
||||
|
||||
@ -385,8 +299,8 @@ func (c *ClientWithFallback) PeerCount(ctx context.Context) (uint64, error) {
|
||||
func (c *ClientWithFallback) HeaderByHash(ctx context.Context, hash common.Hash) (*types.Header, error) {
|
||||
rpcstats.CountCallWithTag("eth_HeaderByHash", c.tag)
|
||||
res, err := c.makeCall(
|
||||
ctx, c.ethClients, func(client *EthClient) (interface{}, error) {
|
||||
return client.ethClient.HeaderByHash(ctx, hash)
|
||||
ctx, c.ethClients, func(client ethclient.RPSLimitedEthClientInterface) (interface{}, error) {
|
||||
return client.HeaderByHash(ctx, hash)
|
||||
},
|
||||
)
|
||||
|
||||
@ -402,8 +316,8 @@ func (c *ClientWithFallback) HeaderByHash(ctx context.Context, hash common.Hash)
|
||||
func (c *ClientWithFallback) HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error) {
|
||||
rpcstats.CountCallWithTag("eth_HeaderByNumber", c.tag)
|
||||
res, err := c.makeCall(
|
||||
ctx, c.ethClients, func(client *EthClient) (interface{}, error) {
|
||||
return client.ethClient.HeaderByNumber(ctx, number)
|
||||
ctx, c.ethClients, func(client ethclient.RPSLimitedEthClientInterface) (interface{}, error) {
|
||||
return client.HeaderByNumber(ctx, number)
|
||||
},
|
||||
)
|
||||
|
||||
@ -420,8 +334,8 @@ func (c *ClientWithFallback) TransactionByHash(ctx context.Context, hash common.
|
||||
rpcstats.CountCallWithTag("eth_TransactionByHash", c.tag)
|
||||
|
||||
res, err := c.makeCall(
|
||||
ctx, c.ethClients, func(client *EthClient) (interface{}, error) {
|
||||
tx, isPending, err := client.ethClient.TransactionByHash(ctx, hash)
|
||||
ctx, c.ethClients, func(client ethclient.RPSLimitedEthClientInterface) (interface{}, error) {
|
||||
tx, isPending, err := client.TransactionByHash(ctx, hash)
|
||||
return []any{tx, isPending}, err
|
||||
},
|
||||
)
|
||||
@ -440,8 +354,8 @@ func (c *ClientWithFallback) TransactionSender(ctx context.Context, tx *types.Tr
|
||||
rpcstats.CountCall("eth_TransactionSender")
|
||||
|
||||
res, err := c.makeCall(
|
||||
ctx, c.ethClients, func(client *EthClient) (interface{}, error) {
|
||||
return client.ethClient.TransactionSender(ctx, tx, block, index)
|
||||
ctx, c.ethClients, func(client ethclient.RPSLimitedEthClientInterface) (interface{}, error) {
|
||||
return client.TransactionSender(ctx, tx, block, index)
|
||||
},
|
||||
)
|
||||
|
||||
@ -450,48 +364,12 @@ func (c *ClientWithFallback) TransactionSender(ctx context.Context, tx *types.Tr
|
||||
return res.(common.Address), err
|
||||
}
|
||||
|
||||
func (c *ClientWithFallback) TransactionCount(ctx context.Context, blockHash common.Hash) (uint, error) {
|
||||
rpcstats.CountCall("eth_TransactionCount")
|
||||
|
||||
res, err := c.makeCall(
|
||||
ctx, c.ethClients, func(client *EthClient) (interface{}, error) {
|
||||
return client.ethClient.TransactionCount(ctx, blockHash)
|
||||
},
|
||||
)
|
||||
|
||||
c.toggleConnectionState(err)
|
||||
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return res.(uint), nil
|
||||
}
|
||||
|
||||
func (c *ClientWithFallback) TransactionInBlock(ctx context.Context, blockHash common.Hash, index uint) (*types.Transaction, error) {
|
||||
rpcstats.CountCall("eth_TransactionInBlock")
|
||||
|
||||
res, err := c.makeCall(
|
||||
ctx, c.ethClients, func(client *EthClient) (interface{}, error) {
|
||||
return client.ethClient.TransactionInBlock(ctx, blockHash, index)
|
||||
},
|
||||
)
|
||||
|
||||
c.toggleConnectionState(err)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return res.(*types.Transaction), nil
|
||||
}
|
||||
|
||||
func (c *ClientWithFallback) TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error) {
|
||||
rpcstats.CountCall("eth_TransactionReceipt")
|
||||
|
||||
res, err := c.makeCall(
|
||||
ctx, c.ethClients, func(client *EthClient) (interface{}, error) {
|
||||
return client.ethClient.TransactionReceipt(ctx, txHash)
|
||||
ctx, c.ethClients, func(client ethclient.RPSLimitedEthClientInterface) (interface{}, error) {
|
||||
return client.TransactionReceipt(ctx, txHash)
|
||||
},
|
||||
)
|
||||
|
||||
@ -508,8 +386,8 @@ func (c *ClientWithFallback) SyncProgress(ctx context.Context) (*ethereum.SyncPr
|
||||
rpcstats.CountCall("eth_SyncProgress")
|
||||
|
||||
res, err := c.makeCall(
|
||||
ctx, c.ethClients, func(client *EthClient) (interface{}, error) {
|
||||
return client.ethClient.SyncProgress(ctx)
|
||||
ctx, c.ethClients, func(client ethclient.RPSLimitedEthClientInterface) (interface{}, error) {
|
||||
return client.SyncProgress(ctx)
|
||||
},
|
||||
)
|
||||
|
||||
@ -522,24 +400,6 @@ func (c *ClientWithFallback) SyncProgress(ctx context.Context) (*ethereum.SyncPr
|
||||
return res.(*ethereum.SyncProgress), nil
|
||||
}
|
||||
|
||||
func (c *ClientWithFallback) SubscribeNewHead(ctx context.Context, ch chan<- *types.Header) (ethereum.Subscription, error) {
|
||||
rpcstats.CountCall("eth_SubscribeNewHead")
|
||||
|
||||
res, err := c.makeCall(
|
||||
ctx, c.ethClients, func(client *EthClient) (interface{}, error) {
|
||||
return client.ethClient.SubscribeNewHead(ctx, ch)
|
||||
},
|
||||
)
|
||||
|
||||
c.toggleConnectionState(err)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return res.(ethereum.Subscription), nil
|
||||
}
|
||||
|
||||
func (c *ClientWithFallback) NetworkID() uint64 {
|
||||
return c.ChainID
|
||||
}
|
||||
@ -548,8 +408,8 @@ func (c *ClientWithFallback) BalanceAt(ctx context.Context, account common.Addre
|
||||
rpcstats.CountCallWithTag("eth_BalanceAt", c.tag)
|
||||
|
||||
res, err := c.makeCall(
|
||||
ctx, c.ethClients, func(client *EthClient) (interface{}, error) {
|
||||
return client.ethClient.BalanceAt(ctx, account, blockNumber)
|
||||
ctx, c.ethClients, func(client ethclient.RPSLimitedEthClientInterface) (interface{}, error) {
|
||||
return client.BalanceAt(ctx, account, blockNumber)
|
||||
},
|
||||
)
|
||||
|
||||
@ -566,8 +426,8 @@ func (c *ClientWithFallback) StorageAt(ctx context.Context, account common.Addre
|
||||
rpcstats.CountCall("eth_StorageAt")
|
||||
|
||||
res, err := c.makeCall(
|
||||
ctx, c.ethClients, func(client *EthClient) (interface{}, error) {
|
||||
return client.ethClient.StorageAt(ctx, account, key, blockNumber)
|
||||
ctx, c.ethClients, func(client ethclient.RPSLimitedEthClientInterface) (interface{}, error) {
|
||||
return client.StorageAt(ctx, account, key, blockNumber)
|
||||
},
|
||||
)
|
||||
|
||||
@ -584,8 +444,8 @@ func (c *ClientWithFallback) CodeAt(ctx context.Context, account common.Address,
|
||||
rpcstats.CountCall("eth_CodeAt")
|
||||
|
||||
res, err := c.makeCall(
|
||||
ctx, c.ethClients, func(client *EthClient) (interface{}, error) {
|
||||
return client.ethClient.CodeAt(ctx, account, blockNumber)
|
||||
ctx, c.ethClients, func(client ethclient.RPSLimitedEthClientInterface) (interface{}, error) {
|
||||
return client.CodeAt(ctx, account, blockNumber)
|
||||
},
|
||||
)
|
||||
|
||||
@ -602,8 +462,8 @@ func (c *ClientWithFallback) NonceAt(ctx context.Context, account common.Address
|
||||
rpcstats.CountCallWithTag("eth_NonceAt", c.tag)
|
||||
|
||||
res, err := c.makeCall(
|
||||
ctx, c.ethClients, func(client *EthClient) (interface{}, error) {
|
||||
return client.ethClient.NonceAt(ctx, account, blockNumber)
|
||||
ctx, c.ethClients, func(client ethclient.RPSLimitedEthClientInterface) (interface{}, error) {
|
||||
return client.NonceAt(ctx, account, blockNumber)
|
||||
},
|
||||
)
|
||||
|
||||
@ -620,19 +480,14 @@ func (c *ClientWithFallback) FilterLogs(ctx context.Context, q ethereum.FilterQu
|
||||
rpcstats.CountCallWithTag("eth_FilterLogs", c.tag)
|
||||
|
||||
// Override providers name to use a separate circuit for this command as it more often fails due to rate limiting
|
||||
ethClients := make([]*EthClient, len(c.ethClients))
|
||||
ethClients := make([]ethclient.RPSLimitedEthClientInterface, len(c.ethClients))
|
||||
for i, client := range c.ethClients {
|
||||
ethClients[i] = &EthClient{
|
||||
ethClient: client.ethClient,
|
||||
limiter: client.limiter,
|
||||
rpcClient: client.rpcClient,
|
||||
name: client.name + "_FilterLogs",
|
||||
}
|
||||
ethClients[i] = client.CopyWithName(client.GetName() + "_FilterLogs")
|
||||
}
|
||||
|
||||
res, err := c.makeCall(
|
||||
ctx, c.ethClients, func(client *EthClient) (interface{}, error) {
|
||||
return client.ethClient.FilterLogs(ctx, q)
|
||||
ctx, c.ethClients, func(client ethclient.RPSLimitedEthClientInterface) (interface{}, error) {
|
||||
return client.FilterLogs(ctx, q)
|
||||
},
|
||||
)
|
||||
|
||||
@ -650,8 +505,8 @@ func (c *ClientWithFallback) SubscribeFilterLogs(ctx context.Context, q ethereum
|
||||
rpcstats.CountCall("eth_SubscribeFilterLogs")
|
||||
|
||||
res, err := c.makeCall(
|
||||
ctx, c.ethClients, func(client *EthClient) (interface{}, error) {
|
||||
return client.ethClient.SubscribeFilterLogs(ctx, q, ch)
|
||||
ctx, c.ethClients, func(client ethclient.RPSLimitedEthClientInterface) (interface{}, error) {
|
||||
return client.SubscribeFilterLogs(ctx, q, ch)
|
||||
},
|
||||
)
|
||||
|
||||
@ -668,8 +523,8 @@ func (c *ClientWithFallback) PendingBalanceAt(ctx context.Context, account commo
|
||||
rpcstats.CountCall("eth_PendingBalanceAt")
|
||||
|
||||
res, err := c.makeCall(
|
||||
ctx, c.ethClients, func(client *EthClient) (interface{}, error) {
|
||||
return client.ethClient.PendingBalanceAt(ctx, account)
|
||||
ctx, c.ethClients, func(client ethclient.RPSLimitedEthClientInterface) (interface{}, error) {
|
||||
return client.PendingBalanceAt(ctx, account)
|
||||
},
|
||||
)
|
||||
|
||||
@ -686,8 +541,8 @@ func (c *ClientWithFallback) PendingStorageAt(ctx context.Context, account commo
|
||||
rpcstats.CountCall("eth_PendingStorageAt")
|
||||
|
||||
res, err := c.makeCall(
|
||||
ctx, c.ethClients, func(client *EthClient) (interface{}, error) {
|
||||
return client.ethClient.PendingStorageAt(ctx, account, key)
|
||||
ctx, c.ethClients, func(client ethclient.RPSLimitedEthClientInterface) (interface{}, error) {
|
||||
return client.PendingStorageAt(ctx, account, key)
|
||||
},
|
||||
)
|
||||
|
||||
@ -704,8 +559,8 @@ func (c *ClientWithFallback) PendingCodeAt(ctx context.Context, account common.A
|
||||
rpcstats.CountCall("eth_PendingCodeAt")
|
||||
|
||||
res, err := c.makeCall(
|
||||
ctx, c.ethClients, func(client *EthClient) (interface{}, error) {
|
||||
return client.ethClient.PendingCodeAt(ctx, account)
|
||||
ctx, c.ethClients, func(client ethclient.RPSLimitedEthClientInterface) (interface{}, error) {
|
||||
return client.PendingCodeAt(ctx, account)
|
||||
},
|
||||
)
|
||||
|
||||
@ -722,8 +577,8 @@ func (c *ClientWithFallback) PendingNonceAt(ctx context.Context, account common.
|
||||
rpcstats.CountCall("eth_PendingNonceAt")
|
||||
|
||||
res, err := c.makeCall(
|
||||
ctx, c.ethClients, func(client *EthClient) (interface{}, error) {
|
||||
return client.ethClient.PendingNonceAt(ctx, account)
|
||||
ctx, c.ethClients, func(client ethclient.RPSLimitedEthClientInterface) (interface{}, error) {
|
||||
return client.PendingNonceAt(ctx, account)
|
||||
},
|
||||
)
|
||||
|
||||
@ -740,8 +595,8 @@ func (c *ClientWithFallback) PendingTransactionCount(ctx context.Context) (uint,
|
||||
rpcstats.CountCall("eth_PendingTransactionCount")
|
||||
|
||||
res, err := c.makeCall(
|
||||
ctx, c.ethClients, func(client *EthClient) (interface{}, error) {
|
||||
return client.ethClient.PendingTransactionCount(ctx)
|
||||
ctx, c.ethClients, func(client ethclient.RPSLimitedEthClientInterface) (interface{}, error) {
|
||||
return client.PendingTransactionCount(ctx)
|
||||
},
|
||||
)
|
||||
|
||||
@ -758,26 +613,8 @@ func (c *ClientWithFallback) CallContract(ctx context.Context, msg ethereum.Call
|
||||
rpcstats.CountCall("eth_CallContract_" + msg.To.String())
|
||||
|
||||
res, err := c.makeCall(
|
||||
ctx, c.ethClients, func(client *EthClient) (interface{}, error) {
|
||||
return client.ethClient.CallContract(ctx, msg, blockNumber)
|
||||
},
|
||||
)
|
||||
|
||||
c.toggleConnectionState(err)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return res.([]byte), nil
|
||||
}
|
||||
|
||||
func (c *ClientWithFallback) CallContractAtHash(ctx context.Context, msg ethereum.CallMsg, blockHash common.Hash) ([]byte, error) {
|
||||
rpcstats.CountCall("eth_CallContractAtHash")
|
||||
|
||||
res, err := c.makeCall(
|
||||
ctx, c.ethClients, func(client *EthClient) (interface{}, error) {
|
||||
return client.ethClient.CallContractAtHash(ctx, msg, blockHash)
|
||||
ctx, c.ethClients, func(client ethclient.RPSLimitedEthClientInterface) (interface{}, error) {
|
||||
return client.CallContract(ctx, msg, blockNumber)
|
||||
},
|
||||
)
|
||||
|
||||
@ -794,8 +631,8 @@ func (c *ClientWithFallback) PendingCallContract(ctx context.Context, msg ethere
|
||||
rpcstats.CountCall("eth_PendingCallContract")
|
||||
|
||||
res, err := c.makeCall(
|
||||
ctx, c.ethClients, func(client *EthClient) (interface{}, error) {
|
||||
return client.ethClient.PendingCallContract(ctx, msg)
|
||||
ctx, c.ethClients, func(client ethclient.RPSLimitedEthClientInterface) (interface{}, error) {
|
||||
return client.PendingCallContract(ctx, msg)
|
||||
},
|
||||
)
|
||||
|
||||
@ -812,8 +649,8 @@ func (c *ClientWithFallback) SuggestGasPrice(ctx context.Context) (*big.Int, err
|
||||
rpcstats.CountCall("eth_SuggestGasPrice")
|
||||
|
||||
res, err := c.makeCall(
|
||||
ctx, c.ethClients, func(client *EthClient) (interface{}, error) {
|
||||
return client.ethClient.SuggestGasPrice(ctx)
|
||||
ctx, c.ethClients, func(client ethclient.RPSLimitedEthClientInterface) (interface{}, error) {
|
||||
return client.SuggestGasPrice(ctx)
|
||||
},
|
||||
)
|
||||
|
||||
@ -830,8 +667,8 @@ func (c *ClientWithFallback) SuggestGasTipCap(ctx context.Context) (*big.Int, er
|
||||
rpcstats.CountCall("eth_SuggestGasTipCap")
|
||||
|
||||
res, err := c.makeCall(
|
||||
ctx, c.ethClients, func(client *EthClient) (interface{}, error) {
|
||||
return client.ethClient.SuggestGasTipCap(ctx)
|
||||
ctx, c.ethClients, func(client ethclient.RPSLimitedEthClientInterface) (interface{}, error) {
|
||||
return client.SuggestGasTipCap(ctx)
|
||||
},
|
||||
)
|
||||
|
||||
@ -848,8 +685,8 @@ func (c *ClientWithFallback) FeeHistory(ctx context.Context, blockCount uint64,
|
||||
rpcstats.CountCall("eth_FeeHistory")
|
||||
|
||||
res, err := c.makeCall(
|
||||
ctx, c.ethClients, func(client *EthClient) (interface{}, error) {
|
||||
return client.ethClient.FeeHistory(ctx, blockCount, lastBlock, rewardPercentiles)
|
||||
ctx, c.ethClients, func(client ethclient.RPSLimitedEthClientInterface) (interface{}, error) {
|
||||
return client.FeeHistory(ctx, blockCount, lastBlock, rewardPercentiles)
|
||||
},
|
||||
)
|
||||
|
||||
@ -866,8 +703,8 @@ func (c *ClientWithFallback) EstimateGas(ctx context.Context, msg ethereum.CallM
|
||||
rpcstats.CountCall("eth_EstimateGas")
|
||||
|
||||
res, err := c.makeCall(
|
||||
ctx, c.ethClients, func(client *EthClient) (interface{}, error) {
|
||||
return client.ethClient.EstimateGas(ctx, msg)
|
||||
ctx, c.ethClients, func(client ethclient.RPSLimitedEthClientInterface) (interface{}, error) {
|
||||
return client.EstimateGas(ctx, msg)
|
||||
},
|
||||
)
|
||||
|
||||
@ -884,8 +721,8 @@ func (c *ClientWithFallback) SendTransaction(ctx context.Context, tx *types.Tran
|
||||
rpcstats.CountCall("eth_SendTransaction")
|
||||
|
||||
_, err := c.makeCall(
|
||||
ctx, c.ethClients, func(client *EthClient) (interface{}, error) {
|
||||
return nil, client.ethClient.SendTransaction(ctx, tx)
|
||||
ctx, c.ethClients, func(client ethclient.RPSLimitedEthClientInterface) (interface{}, error) {
|
||||
return nil, client.SendTransaction(ctx, tx)
|
||||
},
|
||||
)
|
||||
|
||||
@ -898,8 +735,8 @@ func (c *ClientWithFallback) CallContext(ctx context.Context, result interface{}
|
||||
rpcstats.CountCall("eth_CallContext")
|
||||
|
||||
_, err := c.makeCall(
|
||||
ctx, c.ethClients, func(client *EthClient) (interface{}, error) {
|
||||
return nil, client.rpcClient.CallContext(ctx, result, method, args...)
|
||||
ctx, c.ethClients, func(client ethclient.RPSLimitedEthClientInterface) (interface{}, error) {
|
||||
return nil, client.CallContext(ctx, result, method, args...)
|
||||
},
|
||||
)
|
||||
|
||||
@ -912,8 +749,8 @@ func (c *ClientWithFallback) BatchCallContext(ctx context.Context, b []rpc.Batch
|
||||
rpcstats.CountCall("eth_BatchCallContext")
|
||||
|
||||
_, err := c.makeCall(
|
||||
ctx, c.ethClients, func(client *EthClient) (interface{}, error) {
|
||||
return nil, client.rpcClient.BatchCallContext(ctx, b)
|
||||
ctx, c.ethClients, func(client ethclient.RPSLimitedEthClientInterface) (interface{}, error) {
|
||||
return nil, client.BatchCallContext(ctx, b)
|
||||
},
|
||||
)
|
||||
|
||||
@ -946,15 +783,12 @@ func (c *ClientWithFallback) GetBaseFeeFromBlock(ctx context.Context, blockNumbe
|
||||
return baseGasFee, err
|
||||
}
|
||||
|
||||
// go-ethereum's `Transaction` items drop the blkHash obtained during the RPC call.
|
||||
// This function preserves the additional data. This is the cheapest way to obtain
|
||||
// the block hash for a given block number.
|
||||
func (c *ClientWithFallback) CallBlockHashByTransaction(ctx context.Context, blockNumber *big.Int, index uint) (common.Hash, error) {
|
||||
rpcstats.CountCallWithTag("eth_FullTransactionByBlockNumberAndIndex", c.tag)
|
||||
|
||||
res, err := c.makeCall(
|
||||
ctx, c.ethClients, func(client *EthClient) (interface{}, error) {
|
||||
return callBlockHashByTransaction(ctx, client.rpcClient, blockNumber, index)
|
||||
ctx, c.ethClients, func(client ethclient.RPSLimitedEthClientInterface) (interface{}, error) {
|
||||
return client.CallBlockHashByTransaction(ctx, blockNumber, index)
|
||||
},
|
||||
)
|
||||
|
||||
@ -978,7 +812,7 @@ func (c *ClientWithFallback) SetWalletNotifier(notifier func(chainId uint64, mes
|
||||
func (c *ClientWithFallback) toggleConnectionState(err error) {
|
||||
connected := true
|
||||
if err != nil {
|
||||
if !isNotFoundError(err) && !isVMError(err) && !errors.Is(err, ErrRequestsOverLimit) && !errors.Is(err, context.Canceled) {
|
||||
if !isNotFoundError(err) && !isVMError(err) && !errors.Is(err, rpclimiter.ErrRequestsOverLimit) && !errors.Is(err, context.Canceled) {
|
||||
log.Warn("Error not in chain call", "error", err, "chain", c.ChainID)
|
||||
connected = false
|
||||
} else {
|
||||
@ -1004,16 +838,16 @@ func (c *ClientWithFallback) SetGroupTag(tag string) {
|
||||
c.groupTag = tag
|
||||
}
|
||||
|
||||
func (c *ClientWithFallback) DeepCopyTag() Tagger {
|
||||
func (c *ClientWithFallback) DeepCopyTag() tagger.Tagger {
|
||||
copy := *c
|
||||
return ©
|
||||
}
|
||||
|
||||
func (c *ClientWithFallback) GetLimiter() RequestLimiter {
|
||||
func (c *ClientWithFallback) GetLimiter() rpclimiter.RequestLimiter {
|
||||
return c.commonLimiter
|
||||
}
|
||||
|
||||
func (c *ClientWithFallback) SetLimiter(limiter RequestLimiter) {
|
||||
func (c *ClientWithFallback) SetLimiter(limiter rpclimiter.RequestLimiter) {
|
||||
c.commonLimiter = limiter
|
||||
}
|
||||
|
||||
|
79
rpc/chain/client_test.go
Normal file
79
rpc/chain/client_test.go
Normal file
@ -0,0 +1,79 @@
|
||||
package chain
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
|
||||
"github.com/status-im/status-go/rpc/chain/ethclient"
|
||||
mock_ethclient "github.com/status-im/status-go/rpc/chain/mock/client/ethclient"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
gomock "go.uber.org/mock/gomock"
|
||||
)
|
||||
|
||||
func setupClientTest(t *testing.T) (*ClientWithFallback, []*mock_ethclient.MockRPSLimitedEthClientInterface, func()) {
|
||||
mockCtrl := gomock.NewController(t)
|
||||
|
||||
mockEthClients := make([]*mock_ethclient.MockRPSLimitedEthClientInterface, 0)
|
||||
ethClients := make([]ethclient.RPSLimitedEthClientInterface, 0)
|
||||
|
||||
for i := 0; i < 3; i++ {
|
||||
ethCl := mock_ethclient.NewMockRPSLimitedEthClientInterface(mockCtrl)
|
||||
ethCl.EXPECT().GetName().AnyTimes().Return("test" + strconv.Itoa(i))
|
||||
ethCl.EXPECT().GetLimiter().AnyTimes().Return(nil)
|
||||
|
||||
mockEthClients = append(mockEthClients, ethCl)
|
||||
ethClients = append(ethClients, ethCl)
|
||||
}
|
||||
|
||||
client := NewClient(ethClients, 0)
|
||||
|
||||
cleanup := func() {
|
||||
mockCtrl.Finish()
|
||||
}
|
||||
return client, mockEthClients, cleanup
|
||||
}
|
||||
|
||||
// Basic test, just make sure
|
||||
func TestClient_Fallbacks(t *testing.T) {
|
||||
client, ethClients, cleanup := setupClientTest(t)
|
||||
defer cleanup()
|
||||
|
||||
ctx := context.Background()
|
||||
hash := common.HexToHash("0x1234")
|
||||
block := &types.Block{}
|
||||
|
||||
// Expect the first client to be called, others should not be called, should succeed
|
||||
ethClients[0].EXPECT().BlockByHash(ctx, hash).Return(block, nil).Times(1)
|
||||
ethClients[1].EXPECT().BlockByHash(ctx, hash).Return(nil, nil).Times(0)
|
||||
ethClients[2].EXPECT().BlockByHash(ctx, hash).Return(nil, nil).Times(0)
|
||||
_, err := client.BlockByHash(ctx, hash)
|
||||
require.NoError(t, err)
|
||||
|
||||
// Expect the first and second client to be called, others should not be called, should succeed
|
||||
ethClients[0].EXPECT().BlockByHash(ctx, hash).Return(nil, errors.New("some error")).Times(1)
|
||||
ethClients[1].EXPECT().BlockByHash(ctx, hash).Return(block, nil).Times(1)
|
||||
ethClients[2].EXPECT().BlockByHash(ctx, hash).Return(nil, nil).Times(0)
|
||||
_, err = client.BlockByHash(ctx, hash)
|
||||
require.NoError(t, err)
|
||||
|
||||
// Expect the all client to be called, should succeed
|
||||
ethClients[0].EXPECT().BlockByHash(ctx, hash).Return(nil, errors.New("some error")).Times(1)
|
||||
ethClients[1].EXPECT().BlockByHash(ctx, hash).Return(nil, errors.New("some other error")).Times(1)
|
||||
ethClients[2].EXPECT().BlockByHash(ctx, hash).Return(block, nil).Times(1)
|
||||
_, err = client.BlockByHash(ctx, hash)
|
||||
require.NoError(t, err)
|
||||
|
||||
// Expect the all client to be called, should fail
|
||||
ethClients[0].EXPECT().BlockByHash(ctx, hash).Return(nil, errors.New("some error")).Times(1)
|
||||
ethClients[1].EXPECT().BlockByHash(ctx, hash).Return(nil, errors.New("some other error")).Times(1)
|
||||
ethClients[2].EXPECT().BlockByHash(ctx, hash).Return(nil, errors.New("some other other error")).Times(1)
|
||||
_, err = client.BlockByHash(ctx, hash)
|
||||
require.Error(t, err)
|
||||
}
|
112
rpc/chain/ethclient/eth_client.go
Normal file
112
rpc/chain/ethclient/eth_client.go
Normal file
@ -0,0 +1,112 @@
|
||||
package ethclient
|
||||
|
||||
import (
|
||||
"context"
|
||||
"math/big"
|
||||
|
||||
ethereum "github.com/ethereum/go-ethereum"
|
||||
"github.com/ethereum/go-ethereum/accounts/abi/bind"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/ethclient"
|
||||
"github.com/ethereum/go-ethereum/rpc"
|
||||
)
|
||||
|
||||
type ChainReader interface {
|
||||
BlockByHash(ctx context.Context, hash common.Hash) (*types.Block, error)
|
||||
BlockByNumber(ctx context.Context, number *big.Int) (*types.Block, error)
|
||||
HeaderByHash(ctx context.Context, hash common.Hash) (*types.Header, error)
|
||||
HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error)
|
||||
}
|
||||
|
||||
type CallClient interface {
|
||||
CallContext(ctx context.Context, result interface{}, method string, args ...interface{}) error
|
||||
}
|
||||
|
||||
type BatchCallClient interface {
|
||||
BatchCallContext(ctx context.Context, b []rpc.BatchElem) error
|
||||
}
|
||||
|
||||
// Interface for rpc.Client
|
||||
type RPCClientInterface interface {
|
||||
CallClient
|
||||
BatchCallClient
|
||||
}
|
||||
|
||||
// Interface for ethclient.Client
|
||||
type BaseEthClientInterface interface {
|
||||
// External calls
|
||||
ChainReader
|
||||
ethereum.TransactionReader
|
||||
ethereum.ChainStateReader
|
||||
ethereum.ChainSyncReader
|
||||
ethereum.ContractCaller
|
||||
ethereum.LogFilterer
|
||||
ethereum.TransactionSender
|
||||
ethereum.GasPricer
|
||||
ethereum.PendingStateReader
|
||||
ethereum.PendingContractCaller
|
||||
ethereum.GasEstimator
|
||||
FeeHistory(ctx context.Context, blockCount uint64, lastBlock *big.Int, rewardPercentiles []float64) (*ethereum.FeeHistory, error)
|
||||
BlockNumber(ctx context.Context) (uint64, error)
|
||||
TransactionSender(ctx context.Context, tx *types.Transaction, block common.Hash, index uint) (common.Address, error)
|
||||
// Internal calls
|
||||
Close()
|
||||
}
|
||||
|
||||
// EthClientInterface extends BaseEthClientInterface with additional capabilities
|
||||
type EthClientInterface interface {
|
||||
BaseEthClientInterface
|
||||
// Additional external calls
|
||||
RPCClientInterface
|
||||
GetBaseFeeFromBlock(ctx context.Context, blockNumber *big.Int) (string, error)
|
||||
bind.ContractCaller
|
||||
bind.ContractBackend
|
||||
CallBlockHashByTransaction(ctx context.Context, blockNumber *big.Int, index uint) (common.Hash, error)
|
||||
}
|
||||
|
||||
// EthClient implements EthClientInterface
|
||||
type EthClient struct {
|
||||
*ethclient.Client
|
||||
rpcClient *rpc.Client
|
||||
}
|
||||
|
||||
func NewEthClient(rpcClient *rpc.Client) *EthClient {
|
||||
return &EthClient{
|
||||
Client: ethclient.NewClient(rpcClient),
|
||||
rpcClient: rpcClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (ec *EthClient) BatchCallContext(ctx context.Context, b []rpc.BatchElem) error {
|
||||
return ec.rpcClient.BatchCallContext(ctx, b)
|
||||
}
|
||||
|
||||
// go-ethereum's `Transaction` items drop the blkHash obtained during the RPC call.
|
||||
// This function preserves the additional data. This is the cheapest way to obtain
|
||||
// the block hash for a given block number.
|
||||
func (ec *EthClient) CallBlockHashByTransaction(ctx context.Context, blockNumber *big.Int, index uint) (common.Hash, error) {
|
||||
return callBlockHashByTransaction(ctx, ec.rpcClient, blockNumber, index)
|
||||
}
|
||||
|
||||
func (ec *EthClient) GetBaseFeeFromBlock(ctx context.Context, blockNumber *big.Int) (string, error) {
|
||||
feeHistory, err := ec.FeeHistory(ctx, 1, blockNumber, nil)
|
||||
|
||||
if err != nil {
|
||||
if err.Error() == "the method eth_feeHistory does not exist/is not available" {
|
||||
return "", nil
|
||||
}
|
||||
return "", err
|
||||
}
|
||||
|
||||
var baseGasFee string = ""
|
||||
if len(feeHistory.BaseFee) > 0 {
|
||||
baseGasFee = feeHistory.BaseFee[0].String()
|
||||
}
|
||||
|
||||
return baseGasFee, err
|
||||
}
|
||||
|
||||
func (ec *EthClient) CallContext(ctx context.Context, result interface{}, method string, args ...interface{}) error {
|
||||
return ec.rpcClient.CallContext(ctx, result, method, args...)
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package chain
|
||||
package ethclient
|
||||
|
||||
import (
|
||||
"context"
|
44
rpc/chain/ethclient/rps_limited_eth_client.go
Normal file
44
rpc/chain/ethclient/rps_limited_eth_client.go
Normal file
@ -0,0 +1,44 @@
|
||||
package ethclient
|
||||
|
||||
import (
|
||||
"github.com/ethereum/go-ethereum/rpc"
|
||||
"github.com/status-im/status-go/rpc/chain/rpclimiter"
|
||||
)
|
||||
|
||||
// RPSLimitedEthClientInterface extends EthClientInterface with additional
|
||||
// RPS-Limiting related capabilities.
|
||||
// Ideally this shouldn't exist, instead we should be using EthClientInterface
|
||||
// everywhere and clients shouldn't be aware of additional capabilities like
|
||||
// PRS limiting. fallback mechanisms or caching.
|
||||
type RPSLimitedEthClientInterface interface {
|
||||
EthClientInterface
|
||||
GetLimiter() *rpclimiter.RPCRpsLimiter
|
||||
GetName() string
|
||||
CopyWithName(name string) RPSLimitedEthClientInterface
|
||||
}
|
||||
|
||||
type RPSLimitedEthClient struct {
|
||||
*EthClient
|
||||
limiter *rpclimiter.RPCRpsLimiter
|
||||
name string
|
||||
}
|
||||
|
||||
func NewRPSLimitedEthClient(rpcClient *rpc.Client, limiter *rpclimiter.RPCRpsLimiter, name string) *RPSLimitedEthClient {
|
||||
return &RPSLimitedEthClient{
|
||||
EthClient: NewEthClient(rpcClient),
|
||||
limiter: limiter,
|
||||
name: name,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *RPSLimitedEthClient) GetLimiter() *rpclimiter.RPCRpsLimiter {
|
||||
return c.limiter
|
||||
}
|
||||
|
||||
func (c *RPSLimitedEthClient) GetName() string {
|
||||
return c.name
|
||||
}
|
||||
|
||||
func (c *RPSLimitedEthClient) CopyWithName(name string) RPSLimitedEthClientInterface {
|
||||
return NewRPSLimitedEthClient(c.rpcClient, c.limiter, name)
|
||||
}
|
@ -19,342 +19,10 @@ import (
|
||||
types "github.com/ethereum/go-ethereum/core/types"
|
||||
rpc "github.com/ethereum/go-ethereum/rpc"
|
||||
circuitbreaker "github.com/status-im/status-go/circuitbreaker"
|
||||
chain "github.com/status-im/status-go/rpc/chain"
|
||||
rpclimiter "github.com/status-im/status-go/rpc/chain/rpclimiter"
|
||||
gomock "go.uber.org/mock/gomock"
|
||||
)
|
||||
|
||||
// MockBatchCallClient is a mock of BatchCallClient interface.
|
||||
type MockBatchCallClient struct {
|
||||
ctrl *gomock.Controller
|
||||
recorder *MockBatchCallClientMockRecorder
|
||||
}
|
||||
|
||||
// MockBatchCallClientMockRecorder is the mock recorder for MockBatchCallClient.
|
||||
type MockBatchCallClientMockRecorder struct {
|
||||
mock *MockBatchCallClient
|
||||
}
|
||||
|
||||
// NewMockBatchCallClient creates a new mock instance.
|
||||
func NewMockBatchCallClient(ctrl *gomock.Controller) *MockBatchCallClient {
|
||||
mock := &MockBatchCallClient{ctrl: ctrl}
|
||||
mock.recorder = &MockBatchCallClientMockRecorder{mock}
|
||||
return mock
|
||||
}
|
||||
|
||||
// EXPECT returns an object that allows the caller to indicate expected use.
|
||||
func (m *MockBatchCallClient) EXPECT() *MockBatchCallClientMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// BatchCallContext mocks base method.
|
||||
func (m *MockBatchCallClient) BatchCallContext(ctx context.Context, b []rpc.BatchElem) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "BatchCallContext", ctx, b)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// BatchCallContext indicates an expected call of BatchCallContext.
|
||||
func (mr *MockBatchCallClientMockRecorder) BatchCallContext(ctx, b any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BatchCallContext", reflect.TypeOf((*MockBatchCallClient)(nil).BatchCallContext), ctx, b)
|
||||
}
|
||||
|
||||
// MockChainInterface is a mock of ChainInterface interface.
|
||||
type MockChainInterface struct {
|
||||
ctrl *gomock.Controller
|
||||
recorder *MockChainInterfaceMockRecorder
|
||||
}
|
||||
|
||||
// MockChainInterfaceMockRecorder is the mock recorder for MockChainInterface.
|
||||
type MockChainInterfaceMockRecorder struct {
|
||||
mock *MockChainInterface
|
||||
}
|
||||
|
||||
// NewMockChainInterface creates a new mock instance.
|
||||
func NewMockChainInterface(ctrl *gomock.Controller) *MockChainInterface {
|
||||
mock := &MockChainInterface{ctrl: ctrl}
|
||||
mock.recorder = &MockChainInterfaceMockRecorder{mock}
|
||||
return mock
|
||||
}
|
||||
|
||||
// EXPECT returns an object that allows the caller to indicate expected use.
|
||||
func (m *MockChainInterface) EXPECT() *MockChainInterfaceMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// BalanceAt mocks base method.
|
||||
func (m *MockChainInterface) BalanceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (*big.Int, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "BalanceAt", ctx, account, blockNumber)
|
||||
ret0, _ := ret[0].(*big.Int)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// BalanceAt indicates an expected call of BalanceAt.
|
||||
func (mr *MockChainInterfaceMockRecorder) BalanceAt(ctx, account, blockNumber any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BalanceAt", reflect.TypeOf((*MockChainInterface)(nil).BalanceAt), ctx, account, blockNumber)
|
||||
}
|
||||
|
||||
// BatchCallContext mocks base method.
|
||||
func (m *MockChainInterface) BatchCallContext(ctx context.Context, b []rpc.BatchElem) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "BatchCallContext", ctx, b)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// BatchCallContext indicates an expected call of BatchCallContext.
|
||||
func (mr *MockChainInterfaceMockRecorder) BatchCallContext(ctx, b any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BatchCallContext", reflect.TypeOf((*MockChainInterface)(nil).BatchCallContext), ctx, b)
|
||||
}
|
||||
|
||||
// BlockByHash mocks base method.
|
||||
func (m *MockChainInterface) BlockByHash(ctx context.Context, hash common.Hash) (*types.Block, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "BlockByHash", ctx, hash)
|
||||
ret0, _ := ret[0].(*types.Block)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// BlockByHash indicates an expected call of BlockByHash.
|
||||
func (mr *MockChainInterfaceMockRecorder) BlockByHash(ctx, hash any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BlockByHash", reflect.TypeOf((*MockChainInterface)(nil).BlockByHash), ctx, hash)
|
||||
}
|
||||
|
||||
// BlockByNumber mocks base method.
|
||||
func (m *MockChainInterface) BlockByNumber(ctx context.Context, number *big.Int) (*types.Block, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "BlockByNumber", ctx, number)
|
||||
ret0, _ := ret[0].(*types.Block)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// BlockByNumber indicates an expected call of BlockByNumber.
|
||||
func (mr *MockChainInterfaceMockRecorder) BlockByNumber(ctx, number any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BlockByNumber", reflect.TypeOf((*MockChainInterface)(nil).BlockByNumber), ctx, number)
|
||||
}
|
||||
|
||||
// BlockNumber mocks base method.
|
||||
func (m *MockChainInterface) BlockNumber(ctx context.Context) (uint64, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "BlockNumber", ctx)
|
||||
ret0, _ := ret[0].(uint64)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// BlockNumber indicates an expected call of BlockNumber.
|
||||
func (mr *MockChainInterfaceMockRecorder) BlockNumber(ctx any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BlockNumber", reflect.TypeOf((*MockChainInterface)(nil).BlockNumber), ctx)
|
||||
}
|
||||
|
||||
// CallBlockHashByTransaction mocks base method.
|
||||
func (m *MockChainInterface) CallBlockHashByTransaction(ctx context.Context, blockNumber *big.Int, index uint) (common.Hash, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "CallBlockHashByTransaction", ctx, blockNumber, index)
|
||||
ret0, _ := ret[0].(common.Hash)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// CallBlockHashByTransaction indicates an expected call of CallBlockHashByTransaction.
|
||||
func (mr *MockChainInterfaceMockRecorder) CallBlockHashByTransaction(ctx, blockNumber, index any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CallBlockHashByTransaction", reflect.TypeOf((*MockChainInterface)(nil).CallBlockHashByTransaction), ctx, blockNumber, index)
|
||||
}
|
||||
|
||||
// CallContext mocks base method.
|
||||
func (m *MockChainInterface) CallContext(ctx context.Context, result any, method string, args ...any) error {
|
||||
m.ctrl.T.Helper()
|
||||
varargs := []any{ctx, result, method}
|
||||
for _, a := range args {
|
||||
varargs = append(varargs, a)
|
||||
}
|
||||
ret := m.ctrl.Call(m, "CallContext", varargs...)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// CallContext indicates an expected call of CallContext.
|
||||
func (mr *MockChainInterfaceMockRecorder) CallContext(ctx, result, method any, args ...any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
varargs := append([]any{ctx, result, method}, args...)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CallContext", reflect.TypeOf((*MockChainInterface)(nil).CallContext), varargs...)
|
||||
}
|
||||
|
||||
// CallContract mocks base method.
|
||||
func (m *MockChainInterface) CallContract(ctx context.Context, call ethereum.CallMsg, blockNumber *big.Int) ([]byte, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "CallContract", ctx, call, blockNumber)
|
||||
ret0, _ := ret[0].([]byte)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// CallContract indicates an expected call of CallContract.
|
||||
func (mr *MockChainInterfaceMockRecorder) CallContract(ctx, call, blockNumber any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CallContract", reflect.TypeOf((*MockChainInterface)(nil).CallContract), ctx, call, blockNumber)
|
||||
}
|
||||
|
||||
// CodeAt mocks base method.
|
||||
func (m *MockChainInterface) CodeAt(ctx context.Context, contract common.Address, blockNumber *big.Int) ([]byte, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "CodeAt", ctx, contract, blockNumber)
|
||||
ret0, _ := ret[0].([]byte)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// CodeAt indicates an expected call of CodeAt.
|
||||
func (mr *MockChainInterfaceMockRecorder) CodeAt(ctx, contract, blockNumber any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CodeAt", reflect.TypeOf((*MockChainInterface)(nil).CodeAt), ctx, contract, blockNumber)
|
||||
}
|
||||
|
||||
// FilterLogs mocks base method.
|
||||
func (m *MockChainInterface) FilterLogs(ctx context.Context, q ethereum.FilterQuery) ([]types.Log, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "FilterLogs", ctx, q)
|
||||
ret0, _ := ret[0].([]types.Log)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// FilterLogs indicates an expected call of FilterLogs.
|
||||
func (mr *MockChainInterfaceMockRecorder) FilterLogs(ctx, q any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FilterLogs", reflect.TypeOf((*MockChainInterface)(nil).FilterLogs), ctx, q)
|
||||
}
|
||||
|
||||
// GetBaseFeeFromBlock mocks base method.
|
||||
func (m *MockChainInterface) GetBaseFeeFromBlock(ctx context.Context, blockNumber *big.Int) (string, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetBaseFeeFromBlock", ctx, blockNumber)
|
||||
ret0, _ := ret[0].(string)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// GetBaseFeeFromBlock indicates an expected call of GetBaseFeeFromBlock.
|
||||
func (mr *MockChainInterfaceMockRecorder) GetBaseFeeFromBlock(ctx, blockNumber any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetBaseFeeFromBlock", reflect.TypeOf((*MockChainInterface)(nil).GetBaseFeeFromBlock), ctx, blockNumber)
|
||||
}
|
||||
|
||||
// HeaderByHash mocks base method.
|
||||
func (m *MockChainInterface) HeaderByHash(ctx context.Context, hash common.Hash) (*types.Header, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "HeaderByHash", ctx, hash)
|
||||
ret0, _ := ret[0].(*types.Header)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// HeaderByHash indicates an expected call of HeaderByHash.
|
||||
func (mr *MockChainInterfaceMockRecorder) HeaderByHash(ctx, hash any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HeaderByHash", reflect.TypeOf((*MockChainInterface)(nil).HeaderByHash), ctx, hash)
|
||||
}
|
||||
|
||||
// HeaderByNumber mocks base method.
|
||||
func (m *MockChainInterface) HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "HeaderByNumber", ctx, number)
|
||||
ret0, _ := ret[0].(*types.Header)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// HeaderByNumber indicates an expected call of HeaderByNumber.
|
||||
func (mr *MockChainInterfaceMockRecorder) HeaderByNumber(ctx, number any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HeaderByNumber", reflect.TypeOf((*MockChainInterface)(nil).HeaderByNumber), ctx, number)
|
||||
}
|
||||
|
||||
// NetworkID mocks base method.
|
||||
func (m *MockChainInterface) NetworkID() uint64 {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "NetworkID")
|
||||
ret0, _ := ret[0].(uint64)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// NetworkID indicates an expected call of NetworkID.
|
||||
func (mr *MockChainInterfaceMockRecorder) NetworkID() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NetworkID", reflect.TypeOf((*MockChainInterface)(nil).NetworkID))
|
||||
}
|
||||
|
||||
// NonceAt mocks base method.
|
||||
func (m *MockChainInterface) NonceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (uint64, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "NonceAt", ctx, account, blockNumber)
|
||||
ret0, _ := ret[0].(uint64)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// NonceAt indicates an expected call of NonceAt.
|
||||
func (mr *MockChainInterfaceMockRecorder) NonceAt(ctx, account, blockNumber any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NonceAt", reflect.TypeOf((*MockChainInterface)(nil).NonceAt), ctx, account, blockNumber)
|
||||
}
|
||||
|
||||
// ToBigInt mocks base method.
|
||||
func (m *MockChainInterface) ToBigInt() *big.Int {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "ToBigInt")
|
||||
ret0, _ := ret[0].(*big.Int)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// ToBigInt indicates an expected call of ToBigInt.
|
||||
func (mr *MockChainInterfaceMockRecorder) ToBigInt() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ToBigInt", reflect.TypeOf((*MockChainInterface)(nil).ToBigInt))
|
||||
}
|
||||
|
||||
// TransactionByHash mocks base method.
|
||||
func (m *MockChainInterface) TransactionByHash(ctx context.Context, hash common.Hash) (*types.Transaction, bool, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "TransactionByHash", ctx, hash)
|
||||
ret0, _ := ret[0].(*types.Transaction)
|
||||
ret1, _ := ret[1].(bool)
|
||||
ret2, _ := ret[2].(error)
|
||||
return ret0, ret1, ret2
|
||||
}
|
||||
|
||||
// TransactionByHash indicates an expected call of TransactionByHash.
|
||||
func (mr *MockChainInterfaceMockRecorder) TransactionByHash(ctx, hash any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "TransactionByHash", reflect.TypeOf((*MockChainInterface)(nil).TransactionByHash), ctx, hash)
|
||||
}
|
||||
|
||||
// TransactionReceipt mocks base method.
|
||||
func (m *MockChainInterface) TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "TransactionReceipt", ctx, txHash)
|
||||
ret0, _ := ret[0].(*types.Receipt)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// TransactionReceipt indicates an expected call of TransactionReceipt.
|
||||
func (mr *MockChainInterfaceMockRecorder) TransactionReceipt(ctx, txHash any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "TransactionReceipt", reflect.TypeOf((*MockChainInterface)(nil).TransactionReceipt), ctx, txHash)
|
||||
}
|
||||
|
||||
// MockClientInterface is a mock of ClientInterface interface.
|
||||
type MockClientInterface struct {
|
||||
ctrl *gomock.Controller
|
||||
@ -501,19 +169,31 @@ func (mr *MockClientInterfaceMockRecorder) CallContract(ctx, call, blockNumber a
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CallContract", reflect.TypeOf((*MockClientInterface)(nil).CallContract), ctx, call, blockNumber)
|
||||
}
|
||||
|
||||
// CodeAt mocks base method.
|
||||
func (m *MockClientInterface) CodeAt(ctx context.Context, contract common.Address, blockNumber *big.Int) ([]byte, error) {
|
||||
// Close mocks base method.
|
||||
func (m *MockClientInterface) Close() {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "CodeAt", ctx, contract, blockNumber)
|
||||
m.ctrl.Call(m, "Close")
|
||||
}
|
||||
|
||||
// Close indicates an expected call of Close.
|
||||
func (mr *MockClientInterfaceMockRecorder) Close() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Close", reflect.TypeOf((*MockClientInterface)(nil).Close))
|
||||
}
|
||||
|
||||
// CodeAt mocks base method.
|
||||
func (m *MockClientInterface) CodeAt(ctx context.Context, account common.Address, blockNumber *big.Int) ([]byte, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "CodeAt", ctx, account, blockNumber)
|
||||
ret0, _ := ret[0].([]byte)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// CodeAt indicates an expected call of CodeAt.
|
||||
func (mr *MockClientInterfaceMockRecorder) CodeAt(ctx, contract, blockNumber any) *gomock.Call {
|
||||
func (mr *MockClientInterfaceMockRecorder) CodeAt(ctx, account, blockNumber any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CodeAt", reflect.TypeOf((*MockClientInterface)(nil).CodeAt), ctx, contract, blockNumber)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CodeAt", reflect.TypeOf((*MockClientInterface)(nil).CodeAt), ctx, account, blockNumber)
|
||||
}
|
||||
|
||||
// EstimateGas mocks base method.
|
||||
@ -531,6 +211,21 @@ func (mr *MockClientInterfaceMockRecorder) EstimateGas(ctx, call any) *gomock.Ca
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EstimateGas", reflect.TypeOf((*MockClientInterface)(nil).EstimateGas), ctx, call)
|
||||
}
|
||||
|
||||
// FeeHistory mocks base method.
|
||||
func (m *MockClientInterface) FeeHistory(ctx context.Context, blockCount uint64, lastBlock *big.Int, rewardPercentiles []float64) (*ethereum.FeeHistory, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "FeeHistory", ctx, blockCount, lastBlock, rewardPercentiles)
|
||||
ret0, _ := ret[0].(*ethereum.FeeHistory)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// FeeHistory indicates an expected call of FeeHistory.
|
||||
func (mr *MockClientInterfaceMockRecorder) FeeHistory(ctx, blockCount, lastBlock, rewardPercentiles any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FeeHistory", reflect.TypeOf((*MockClientInterface)(nil).FeeHistory), ctx, blockCount, lastBlock, rewardPercentiles)
|
||||
}
|
||||
|
||||
// FilterLogs mocks base method.
|
||||
func (m *MockClientInterface) FilterLogs(ctx context.Context, q ethereum.FilterQuery) ([]types.Log, error) {
|
||||
m.ctrl.T.Helper()
|
||||
@ -562,10 +257,10 @@ func (mr *MockClientInterfaceMockRecorder) GetBaseFeeFromBlock(ctx, blockNumber
|
||||
}
|
||||
|
||||
// GetLimiter mocks base method.
|
||||
func (m *MockClientInterface) GetLimiter() chain.RequestLimiter {
|
||||
func (m *MockClientInterface) GetLimiter() rpclimiter.RequestLimiter {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetLimiter")
|
||||
ret0, _ := ret[0].(chain.RequestLimiter)
|
||||
ret0, _ := ret[0].(rpclimiter.RequestLimiter)
|
||||
return ret0
|
||||
}
|
||||
|
||||
@ -662,6 +357,36 @@ func (mr *MockClientInterfaceMockRecorder) NonceAt(ctx, account, blockNumber any
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NonceAt", reflect.TypeOf((*MockClientInterface)(nil).NonceAt), ctx, account, blockNumber)
|
||||
}
|
||||
|
||||
// PendingBalanceAt mocks base method.
|
||||
func (m *MockClientInterface) PendingBalanceAt(ctx context.Context, account common.Address) (*big.Int, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "PendingBalanceAt", ctx, account)
|
||||
ret0, _ := ret[0].(*big.Int)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// PendingBalanceAt indicates an expected call of PendingBalanceAt.
|
||||
func (mr *MockClientInterfaceMockRecorder) PendingBalanceAt(ctx, account any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PendingBalanceAt", reflect.TypeOf((*MockClientInterface)(nil).PendingBalanceAt), ctx, account)
|
||||
}
|
||||
|
||||
// PendingCallContract mocks base method.
|
||||
func (m *MockClientInterface) PendingCallContract(ctx context.Context, call ethereum.CallMsg) ([]byte, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "PendingCallContract", ctx, call)
|
||||
ret0, _ := ret[0].([]byte)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// PendingCallContract indicates an expected call of PendingCallContract.
|
||||
func (mr *MockClientInterfaceMockRecorder) PendingCallContract(ctx, call any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PendingCallContract", reflect.TypeOf((*MockClientInterface)(nil).PendingCallContract), ctx, call)
|
||||
}
|
||||
|
||||
// PendingCodeAt mocks base method.
|
||||
func (m *MockClientInterface) PendingCodeAt(ctx context.Context, account common.Address) ([]byte, error) {
|
||||
m.ctrl.T.Helper()
|
||||
@ -692,6 +417,36 @@ func (mr *MockClientInterfaceMockRecorder) PendingNonceAt(ctx, account any) *gom
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PendingNonceAt", reflect.TypeOf((*MockClientInterface)(nil).PendingNonceAt), ctx, account)
|
||||
}
|
||||
|
||||
// PendingStorageAt mocks base method.
|
||||
func (m *MockClientInterface) PendingStorageAt(ctx context.Context, account common.Address, key common.Hash) ([]byte, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "PendingStorageAt", ctx, account, key)
|
||||
ret0, _ := ret[0].([]byte)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// PendingStorageAt indicates an expected call of PendingStorageAt.
|
||||
func (mr *MockClientInterfaceMockRecorder) PendingStorageAt(ctx, account, key any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PendingStorageAt", reflect.TypeOf((*MockClientInterface)(nil).PendingStorageAt), ctx, account, key)
|
||||
}
|
||||
|
||||
// PendingTransactionCount mocks base method.
|
||||
func (m *MockClientInterface) PendingTransactionCount(ctx context.Context) (uint, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "PendingTransactionCount", ctx)
|
||||
ret0, _ := ret[0].(uint)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// PendingTransactionCount indicates an expected call of PendingTransactionCount.
|
||||
func (mr *MockClientInterfaceMockRecorder) PendingTransactionCount(ctx any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PendingTransactionCount", reflect.TypeOf((*MockClientInterface)(nil).PendingTransactionCount), ctx)
|
||||
}
|
||||
|
||||
// SendTransaction mocks base method.
|
||||
func (m *MockClientInterface) SendTransaction(ctx context.Context, tx *types.Transaction) error {
|
||||
m.ctrl.T.Helper()
|
||||
@ -719,7 +474,7 @@ func (mr *MockClientInterfaceMockRecorder) SetIsConnected(arg0 any) *gomock.Call
|
||||
}
|
||||
|
||||
// SetLimiter mocks base method.
|
||||
func (m *MockClientInterface) SetLimiter(arg0 chain.RequestLimiter) {
|
||||
func (m *MockClientInterface) SetLimiter(arg0 rpclimiter.RequestLimiter) {
|
||||
m.ctrl.T.Helper()
|
||||
m.ctrl.Call(m, "SetLimiter", arg0)
|
||||
}
|
||||
@ -742,19 +497,34 @@ func (mr *MockClientInterfaceMockRecorder) SetWalletNotifier(notifier any) *gomo
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetWalletNotifier", reflect.TypeOf((*MockClientInterface)(nil).SetWalletNotifier), notifier)
|
||||
}
|
||||
|
||||
// SubscribeFilterLogs mocks base method.
|
||||
func (m *MockClientInterface) SubscribeFilterLogs(ctx context.Context, query ethereum.FilterQuery, ch chan<- types.Log) (ethereum.Subscription, error) {
|
||||
// StorageAt mocks base method.
|
||||
func (m *MockClientInterface) StorageAt(ctx context.Context, account common.Address, key common.Hash, blockNumber *big.Int) ([]byte, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "SubscribeFilterLogs", ctx, query, ch)
|
||||
ret := m.ctrl.Call(m, "StorageAt", ctx, account, key, blockNumber)
|
||||
ret0, _ := ret[0].([]byte)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// StorageAt indicates an expected call of StorageAt.
|
||||
func (mr *MockClientInterfaceMockRecorder) StorageAt(ctx, account, key, blockNumber any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StorageAt", reflect.TypeOf((*MockClientInterface)(nil).StorageAt), ctx, account, key, blockNumber)
|
||||
}
|
||||
|
||||
// SubscribeFilterLogs mocks base method.
|
||||
func (m *MockClientInterface) SubscribeFilterLogs(ctx context.Context, q ethereum.FilterQuery, ch chan<- types.Log) (ethereum.Subscription, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "SubscribeFilterLogs", ctx, q, ch)
|
||||
ret0, _ := ret[0].(ethereum.Subscription)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// SubscribeFilterLogs indicates an expected call of SubscribeFilterLogs.
|
||||
func (mr *MockClientInterfaceMockRecorder) SubscribeFilterLogs(ctx, query, ch any) *gomock.Call {
|
||||
func (mr *MockClientInterfaceMockRecorder) SubscribeFilterLogs(ctx, q, ch any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SubscribeFilterLogs", reflect.TypeOf((*MockClientInterface)(nil).SubscribeFilterLogs), ctx, query, ch)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SubscribeFilterLogs", reflect.TypeOf((*MockClientInterface)(nil).SubscribeFilterLogs), ctx, q, ch)
|
||||
}
|
||||
|
||||
// SuggestGasPrice mocks base method.
|
||||
@ -787,6 +557,21 @@ func (mr *MockClientInterfaceMockRecorder) SuggestGasTipCap(ctx any) *gomock.Cal
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SuggestGasTipCap", reflect.TypeOf((*MockClientInterface)(nil).SuggestGasTipCap), ctx)
|
||||
}
|
||||
|
||||
// SyncProgress mocks base method.
|
||||
func (m *MockClientInterface) SyncProgress(ctx context.Context) (*ethereum.SyncProgress, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "SyncProgress", ctx)
|
||||
ret0, _ := ret[0].(*ethereum.SyncProgress)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// SyncProgress indicates an expected call of SyncProgress.
|
||||
func (mr *MockClientInterfaceMockRecorder) SyncProgress(ctx any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SyncProgress", reflect.TypeOf((*MockClientInterface)(nil).SyncProgress), ctx)
|
||||
}
|
||||
|
||||
// ToBigInt mocks base method.
|
||||
func (m *MockClientInterface) ToBigInt() *big.Int {
|
||||
m.ctrl.T.Helper()
|
||||
@ -802,9 +587,9 @@ func (mr *MockClientInterfaceMockRecorder) ToBigInt() *gomock.Call {
|
||||
}
|
||||
|
||||
// TransactionByHash mocks base method.
|
||||
func (m *MockClientInterface) TransactionByHash(ctx context.Context, hash common.Hash) (*types.Transaction, bool, error) {
|
||||
func (m *MockClientInterface) TransactionByHash(ctx context.Context, txHash common.Hash) (*types.Transaction, bool, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "TransactionByHash", ctx, hash)
|
||||
ret := m.ctrl.Call(m, "TransactionByHash", ctx, txHash)
|
||||
ret0, _ := ret[0].(*types.Transaction)
|
||||
ret1, _ := ret[1].(bool)
|
||||
ret2, _ := ret[2].(error)
|
||||
@ -812,9 +597,9 @@ func (m *MockClientInterface) TransactionByHash(ctx context.Context, hash common
|
||||
}
|
||||
|
||||
// TransactionByHash indicates an expected call of TransactionByHash.
|
||||
func (mr *MockClientInterfaceMockRecorder) TransactionByHash(ctx, hash any) *gomock.Call {
|
||||
func (mr *MockClientInterfaceMockRecorder) TransactionByHash(ctx, txHash any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "TransactionByHash", reflect.TypeOf((*MockClientInterface)(nil).TransactionByHash), ctx, hash)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "TransactionByHash", reflect.TypeOf((*MockClientInterface)(nil).TransactionByHash), ctx, txHash)
|
||||
}
|
||||
|
||||
// TransactionReceipt mocks base method.
|
||||
@ -832,93 +617,19 @@ func (mr *MockClientInterfaceMockRecorder) TransactionReceipt(ctx, txHash any) *
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "TransactionReceipt", reflect.TypeOf((*MockClientInterface)(nil).TransactionReceipt), ctx, txHash)
|
||||
}
|
||||
|
||||
// MockTagger is a mock of Tagger interface.
|
||||
type MockTagger struct {
|
||||
ctrl *gomock.Controller
|
||||
recorder *MockTaggerMockRecorder
|
||||
}
|
||||
|
||||
// MockTaggerMockRecorder is the mock recorder for MockTagger.
|
||||
type MockTaggerMockRecorder struct {
|
||||
mock *MockTagger
|
||||
}
|
||||
|
||||
// NewMockTagger creates a new mock instance.
|
||||
func NewMockTagger(ctrl *gomock.Controller) *MockTagger {
|
||||
mock := &MockTagger{ctrl: ctrl}
|
||||
mock.recorder = &MockTaggerMockRecorder{mock}
|
||||
return mock
|
||||
}
|
||||
|
||||
// EXPECT returns an object that allows the caller to indicate expected use.
|
||||
func (m *MockTagger) EXPECT() *MockTaggerMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// DeepCopyTag mocks base method.
|
||||
func (m *MockTagger) DeepCopyTag() chain.Tagger {
|
||||
// TransactionSender mocks base method.
|
||||
func (m *MockClientInterface) TransactionSender(ctx context.Context, tx *types.Transaction, block common.Hash, index uint) (common.Address, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "DeepCopyTag")
|
||||
ret0, _ := ret[0].(chain.Tagger)
|
||||
return ret0
|
||||
ret := m.ctrl.Call(m, "TransactionSender", ctx, tx, block, index)
|
||||
ret0, _ := ret[0].(common.Address)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// DeepCopyTag indicates an expected call of DeepCopyTag.
|
||||
func (mr *MockTaggerMockRecorder) DeepCopyTag() *gomock.Call {
|
||||
// TransactionSender indicates an expected call of TransactionSender.
|
||||
func (mr *MockClientInterfaceMockRecorder) TransactionSender(ctx, tx, block, index any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeepCopyTag", reflect.TypeOf((*MockTagger)(nil).DeepCopyTag))
|
||||
}
|
||||
|
||||
// GroupTag mocks base method.
|
||||
func (m *MockTagger) GroupTag() string {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GroupTag")
|
||||
ret0, _ := ret[0].(string)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// GroupTag indicates an expected call of GroupTag.
|
||||
func (mr *MockTaggerMockRecorder) GroupTag() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GroupTag", reflect.TypeOf((*MockTagger)(nil).GroupTag))
|
||||
}
|
||||
|
||||
// SetGroupTag mocks base method.
|
||||
func (m *MockTagger) SetGroupTag(tag string) {
|
||||
m.ctrl.T.Helper()
|
||||
m.ctrl.Call(m, "SetGroupTag", tag)
|
||||
}
|
||||
|
||||
// SetGroupTag indicates an expected call of SetGroupTag.
|
||||
func (mr *MockTaggerMockRecorder) SetGroupTag(tag any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetGroupTag", reflect.TypeOf((*MockTagger)(nil).SetGroupTag), tag)
|
||||
}
|
||||
|
||||
// SetTag mocks base method.
|
||||
func (m *MockTagger) SetTag(tag string) {
|
||||
m.ctrl.T.Helper()
|
||||
m.ctrl.Call(m, "SetTag", tag)
|
||||
}
|
||||
|
||||
// SetTag indicates an expected call of SetTag.
|
||||
func (mr *MockTaggerMockRecorder) SetTag(tag any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetTag", reflect.TypeOf((*MockTagger)(nil).SetTag), tag)
|
||||
}
|
||||
|
||||
// Tag mocks base method.
|
||||
func (m *MockTagger) Tag() string {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Tag")
|
||||
ret0, _ := ret[0].(string)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// Tag indicates an expected call of Tag.
|
||||
func (mr *MockTaggerMockRecorder) Tag() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Tag", reflect.TypeOf((*MockTagger)(nil).Tag))
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "TransactionSender", reflect.TypeOf((*MockClientInterface)(nil).TransactionSender), ctx, tx, block, index)
|
||||
}
|
||||
|
||||
// MockHealthMonitor is a mock of HealthMonitor interface.
|
||||
|
1168
rpc/chain/mock/client/ethclient/eth_client.go
Normal file
1168
rpc/chain/mock/client/ethclient/eth_client.go
Normal file
File diff suppressed because it is too large
Load Diff
569
rpc/chain/mock/client/ethclient/rps_limited_eth_client.go
Normal file
569
rpc/chain/mock/client/ethclient/rps_limited_eth_client.go
Normal file
@ -0,0 +1,569 @@
|
||||
// Code generated by MockGen. DO NOT EDIT.
|
||||
// Source: rpc/chain/ethclient/rps_limited_eth_client.go
|
||||
//
|
||||
// Generated by this command:
|
||||
//
|
||||
// mockgen -package=mock_ethclient -destination=rpc/chain/mock/client/ethclient/rps_limited_eth_client.go -source=rpc/chain/ethclient/rps_limited_eth_client.go
|
||||
//
|
||||
|
||||
// Package mock_ethclient is a generated GoMock package.
|
||||
package mock_ethclient
|
||||
|
||||
import (
|
||||
context "context"
|
||||
big "math/big"
|
||||
reflect "reflect"
|
||||
|
||||
ethereum "github.com/ethereum/go-ethereum"
|
||||
common "github.com/ethereum/go-ethereum/common"
|
||||
types "github.com/ethereum/go-ethereum/core/types"
|
||||
rpc "github.com/ethereum/go-ethereum/rpc"
|
||||
ethclient "github.com/status-im/status-go/rpc/chain/ethclient"
|
||||
rpclimiter "github.com/status-im/status-go/rpc/chain/rpclimiter"
|
||||
gomock "go.uber.org/mock/gomock"
|
||||
)
|
||||
|
||||
// MockRPSLimitedEthClientInterface is a mock of RPSLimitedEthClientInterface interface.
|
||||
type MockRPSLimitedEthClientInterface struct {
|
||||
ctrl *gomock.Controller
|
||||
recorder *MockRPSLimitedEthClientInterfaceMockRecorder
|
||||
}
|
||||
|
||||
// MockRPSLimitedEthClientInterfaceMockRecorder is the mock recorder for MockRPSLimitedEthClientInterface.
|
||||
type MockRPSLimitedEthClientInterfaceMockRecorder struct {
|
||||
mock *MockRPSLimitedEthClientInterface
|
||||
}
|
||||
|
||||
// NewMockRPSLimitedEthClientInterface creates a new mock instance.
|
||||
func NewMockRPSLimitedEthClientInterface(ctrl *gomock.Controller) *MockRPSLimitedEthClientInterface {
|
||||
mock := &MockRPSLimitedEthClientInterface{ctrl: ctrl}
|
||||
mock.recorder = &MockRPSLimitedEthClientInterfaceMockRecorder{mock}
|
||||
return mock
|
||||
}
|
||||
|
||||
// EXPECT returns an object that allows the caller to indicate expected use.
|
||||
func (m *MockRPSLimitedEthClientInterface) EXPECT() *MockRPSLimitedEthClientInterfaceMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// BalanceAt mocks base method.
|
||||
func (m *MockRPSLimitedEthClientInterface) BalanceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (*big.Int, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "BalanceAt", ctx, account, blockNumber)
|
||||
ret0, _ := ret[0].(*big.Int)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// BalanceAt indicates an expected call of BalanceAt.
|
||||
func (mr *MockRPSLimitedEthClientInterfaceMockRecorder) BalanceAt(ctx, account, blockNumber any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BalanceAt", reflect.TypeOf((*MockRPSLimitedEthClientInterface)(nil).BalanceAt), ctx, account, blockNumber)
|
||||
}
|
||||
|
||||
// BatchCallContext mocks base method.
|
||||
func (m *MockRPSLimitedEthClientInterface) BatchCallContext(ctx context.Context, b []rpc.BatchElem) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "BatchCallContext", ctx, b)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// BatchCallContext indicates an expected call of BatchCallContext.
|
||||
func (mr *MockRPSLimitedEthClientInterfaceMockRecorder) BatchCallContext(ctx, b any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BatchCallContext", reflect.TypeOf((*MockRPSLimitedEthClientInterface)(nil).BatchCallContext), ctx, b)
|
||||
}
|
||||
|
||||
// BlockByHash mocks base method.
|
||||
func (m *MockRPSLimitedEthClientInterface) BlockByHash(ctx context.Context, hash common.Hash) (*types.Block, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "BlockByHash", ctx, hash)
|
||||
ret0, _ := ret[0].(*types.Block)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// BlockByHash indicates an expected call of BlockByHash.
|
||||
func (mr *MockRPSLimitedEthClientInterfaceMockRecorder) BlockByHash(ctx, hash any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BlockByHash", reflect.TypeOf((*MockRPSLimitedEthClientInterface)(nil).BlockByHash), ctx, hash)
|
||||
}
|
||||
|
||||
// BlockByNumber mocks base method.
|
||||
func (m *MockRPSLimitedEthClientInterface) BlockByNumber(ctx context.Context, number *big.Int) (*types.Block, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "BlockByNumber", ctx, number)
|
||||
ret0, _ := ret[0].(*types.Block)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// BlockByNumber indicates an expected call of BlockByNumber.
|
||||
func (mr *MockRPSLimitedEthClientInterfaceMockRecorder) BlockByNumber(ctx, number any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BlockByNumber", reflect.TypeOf((*MockRPSLimitedEthClientInterface)(nil).BlockByNumber), ctx, number)
|
||||
}
|
||||
|
||||
// BlockNumber mocks base method.
|
||||
func (m *MockRPSLimitedEthClientInterface) BlockNumber(ctx context.Context) (uint64, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "BlockNumber", ctx)
|
||||
ret0, _ := ret[0].(uint64)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// BlockNumber indicates an expected call of BlockNumber.
|
||||
func (mr *MockRPSLimitedEthClientInterfaceMockRecorder) BlockNumber(ctx any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BlockNumber", reflect.TypeOf((*MockRPSLimitedEthClientInterface)(nil).BlockNumber), ctx)
|
||||
}
|
||||
|
||||
// CallBlockHashByTransaction mocks base method.
|
||||
func (m *MockRPSLimitedEthClientInterface) CallBlockHashByTransaction(ctx context.Context, blockNumber *big.Int, index uint) (common.Hash, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "CallBlockHashByTransaction", ctx, blockNumber, index)
|
||||
ret0, _ := ret[0].(common.Hash)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// CallBlockHashByTransaction indicates an expected call of CallBlockHashByTransaction.
|
||||
func (mr *MockRPSLimitedEthClientInterfaceMockRecorder) CallBlockHashByTransaction(ctx, blockNumber, index any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CallBlockHashByTransaction", reflect.TypeOf((*MockRPSLimitedEthClientInterface)(nil).CallBlockHashByTransaction), ctx, blockNumber, index)
|
||||
}
|
||||
|
||||
// CallContext mocks base method.
|
||||
func (m *MockRPSLimitedEthClientInterface) CallContext(ctx context.Context, result any, method string, args ...any) error {
|
||||
m.ctrl.T.Helper()
|
||||
varargs := []any{ctx, result, method}
|
||||
for _, a := range args {
|
||||
varargs = append(varargs, a)
|
||||
}
|
||||
ret := m.ctrl.Call(m, "CallContext", varargs...)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// CallContext indicates an expected call of CallContext.
|
||||
func (mr *MockRPSLimitedEthClientInterfaceMockRecorder) CallContext(ctx, result, method any, args ...any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
varargs := append([]any{ctx, result, method}, args...)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CallContext", reflect.TypeOf((*MockRPSLimitedEthClientInterface)(nil).CallContext), varargs...)
|
||||
}
|
||||
|
||||
// CallContract mocks base method.
|
||||
func (m *MockRPSLimitedEthClientInterface) CallContract(ctx context.Context, call ethereum.CallMsg, blockNumber *big.Int) ([]byte, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "CallContract", ctx, call, blockNumber)
|
||||
ret0, _ := ret[0].([]byte)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// CallContract indicates an expected call of CallContract.
|
||||
func (mr *MockRPSLimitedEthClientInterfaceMockRecorder) CallContract(ctx, call, blockNumber any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CallContract", reflect.TypeOf((*MockRPSLimitedEthClientInterface)(nil).CallContract), ctx, call, blockNumber)
|
||||
}
|
||||
|
||||
// Close mocks base method.
|
||||
func (m *MockRPSLimitedEthClientInterface) Close() {
|
||||
m.ctrl.T.Helper()
|
||||
m.ctrl.Call(m, "Close")
|
||||
}
|
||||
|
||||
// Close indicates an expected call of Close.
|
||||
func (mr *MockRPSLimitedEthClientInterfaceMockRecorder) Close() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Close", reflect.TypeOf((*MockRPSLimitedEthClientInterface)(nil).Close))
|
||||
}
|
||||
|
||||
// CodeAt mocks base method.
|
||||
func (m *MockRPSLimitedEthClientInterface) CodeAt(ctx context.Context, account common.Address, blockNumber *big.Int) ([]byte, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "CodeAt", ctx, account, blockNumber)
|
||||
ret0, _ := ret[0].([]byte)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// CodeAt indicates an expected call of CodeAt.
|
||||
func (mr *MockRPSLimitedEthClientInterfaceMockRecorder) CodeAt(ctx, account, blockNumber any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CodeAt", reflect.TypeOf((*MockRPSLimitedEthClientInterface)(nil).CodeAt), ctx, account, blockNumber)
|
||||
}
|
||||
|
||||
// CopyWithName mocks base method.
|
||||
func (m *MockRPSLimitedEthClientInterface) CopyWithName(name string) ethclient.RPSLimitedEthClientInterface {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "CopyWithName", name)
|
||||
ret0, _ := ret[0].(ethclient.RPSLimitedEthClientInterface)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// CopyWithName indicates an expected call of CopyWithName.
|
||||
func (mr *MockRPSLimitedEthClientInterfaceMockRecorder) CopyWithName(name any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CopyWithName", reflect.TypeOf((*MockRPSLimitedEthClientInterface)(nil).CopyWithName), name)
|
||||
}
|
||||
|
||||
// EstimateGas mocks base method.
|
||||
func (m *MockRPSLimitedEthClientInterface) EstimateGas(ctx context.Context, call ethereum.CallMsg) (uint64, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "EstimateGas", ctx, call)
|
||||
ret0, _ := ret[0].(uint64)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// EstimateGas indicates an expected call of EstimateGas.
|
||||
func (mr *MockRPSLimitedEthClientInterfaceMockRecorder) EstimateGas(ctx, call any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EstimateGas", reflect.TypeOf((*MockRPSLimitedEthClientInterface)(nil).EstimateGas), ctx, call)
|
||||
}
|
||||
|
||||
// FeeHistory mocks base method.
|
||||
func (m *MockRPSLimitedEthClientInterface) FeeHistory(ctx context.Context, blockCount uint64, lastBlock *big.Int, rewardPercentiles []float64) (*ethereum.FeeHistory, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "FeeHistory", ctx, blockCount, lastBlock, rewardPercentiles)
|
||||
ret0, _ := ret[0].(*ethereum.FeeHistory)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// FeeHistory indicates an expected call of FeeHistory.
|
||||
func (mr *MockRPSLimitedEthClientInterfaceMockRecorder) FeeHistory(ctx, blockCount, lastBlock, rewardPercentiles any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FeeHistory", reflect.TypeOf((*MockRPSLimitedEthClientInterface)(nil).FeeHistory), ctx, blockCount, lastBlock, rewardPercentiles)
|
||||
}
|
||||
|
||||
// FilterLogs mocks base method.
|
||||
func (m *MockRPSLimitedEthClientInterface) FilterLogs(ctx context.Context, q ethereum.FilterQuery) ([]types.Log, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "FilterLogs", ctx, q)
|
||||
ret0, _ := ret[0].([]types.Log)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// FilterLogs indicates an expected call of FilterLogs.
|
||||
func (mr *MockRPSLimitedEthClientInterfaceMockRecorder) FilterLogs(ctx, q any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FilterLogs", reflect.TypeOf((*MockRPSLimitedEthClientInterface)(nil).FilterLogs), ctx, q)
|
||||
}
|
||||
|
||||
// GetBaseFeeFromBlock mocks base method.
|
||||
func (m *MockRPSLimitedEthClientInterface) GetBaseFeeFromBlock(ctx context.Context, blockNumber *big.Int) (string, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetBaseFeeFromBlock", ctx, blockNumber)
|
||||
ret0, _ := ret[0].(string)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// GetBaseFeeFromBlock indicates an expected call of GetBaseFeeFromBlock.
|
||||
func (mr *MockRPSLimitedEthClientInterfaceMockRecorder) GetBaseFeeFromBlock(ctx, blockNumber any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetBaseFeeFromBlock", reflect.TypeOf((*MockRPSLimitedEthClientInterface)(nil).GetBaseFeeFromBlock), ctx, blockNumber)
|
||||
}
|
||||
|
||||
// GetLimiter mocks base method.
|
||||
func (m *MockRPSLimitedEthClientInterface) GetLimiter() *rpclimiter.RPCRpsLimiter {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetLimiter")
|
||||
ret0, _ := ret[0].(*rpclimiter.RPCRpsLimiter)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// GetLimiter indicates an expected call of GetLimiter.
|
||||
func (mr *MockRPSLimitedEthClientInterfaceMockRecorder) GetLimiter() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetLimiter", reflect.TypeOf((*MockRPSLimitedEthClientInterface)(nil).GetLimiter))
|
||||
}
|
||||
|
||||
// GetName mocks base method.
|
||||
func (m *MockRPSLimitedEthClientInterface) GetName() string {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetName")
|
||||
ret0, _ := ret[0].(string)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// GetName indicates an expected call of GetName.
|
||||
func (mr *MockRPSLimitedEthClientInterfaceMockRecorder) GetName() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetName", reflect.TypeOf((*MockRPSLimitedEthClientInterface)(nil).GetName))
|
||||
}
|
||||
|
||||
// HeaderByHash mocks base method.
|
||||
func (m *MockRPSLimitedEthClientInterface) HeaderByHash(ctx context.Context, hash common.Hash) (*types.Header, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "HeaderByHash", ctx, hash)
|
||||
ret0, _ := ret[0].(*types.Header)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// HeaderByHash indicates an expected call of HeaderByHash.
|
||||
func (mr *MockRPSLimitedEthClientInterfaceMockRecorder) HeaderByHash(ctx, hash any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HeaderByHash", reflect.TypeOf((*MockRPSLimitedEthClientInterface)(nil).HeaderByHash), ctx, hash)
|
||||
}
|
||||
|
||||
// HeaderByNumber mocks base method.
|
||||
func (m *MockRPSLimitedEthClientInterface) HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "HeaderByNumber", ctx, number)
|
||||
ret0, _ := ret[0].(*types.Header)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// HeaderByNumber indicates an expected call of HeaderByNumber.
|
||||
func (mr *MockRPSLimitedEthClientInterfaceMockRecorder) HeaderByNumber(ctx, number any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HeaderByNumber", reflect.TypeOf((*MockRPSLimitedEthClientInterface)(nil).HeaderByNumber), ctx, number)
|
||||
}
|
||||
|
||||
// NonceAt mocks base method.
|
||||
func (m *MockRPSLimitedEthClientInterface) NonceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (uint64, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "NonceAt", ctx, account, blockNumber)
|
||||
ret0, _ := ret[0].(uint64)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// NonceAt indicates an expected call of NonceAt.
|
||||
func (mr *MockRPSLimitedEthClientInterfaceMockRecorder) NonceAt(ctx, account, blockNumber any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NonceAt", reflect.TypeOf((*MockRPSLimitedEthClientInterface)(nil).NonceAt), ctx, account, blockNumber)
|
||||
}
|
||||
|
||||
// PendingBalanceAt mocks base method.
|
||||
func (m *MockRPSLimitedEthClientInterface) PendingBalanceAt(ctx context.Context, account common.Address) (*big.Int, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "PendingBalanceAt", ctx, account)
|
||||
ret0, _ := ret[0].(*big.Int)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// PendingBalanceAt indicates an expected call of PendingBalanceAt.
|
||||
func (mr *MockRPSLimitedEthClientInterfaceMockRecorder) PendingBalanceAt(ctx, account any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PendingBalanceAt", reflect.TypeOf((*MockRPSLimitedEthClientInterface)(nil).PendingBalanceAt), ctx, account)
|
||||
}
|
||||
|
||||
// PendingCallContract mocks base method.
|
||||
func (m *MockRPSLimitedEthClientInterface) PendingCallContract(ctx context.Context, call ethereum.CallMsg) ([]byte, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "PendingCallContract", ctx, call)
|
||||
ret0, _ := ret[0].([]byte)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// PendingCallContract indicates an expected call of PendingCallContract.
|
||||
func (mr *MockRPSLimitedEthClientInterfaceMockRecorder) PendingCallContract(ctx, call any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PendingCallContract", reflect.TypeOf((*MockRPSLimitedEthClientInterface)(nil).PendingCallContract), ctx, call)
|
||||
}
|
||||
|
||||
// PendingCodeAt mocks base method.
|
||||
func (m *MockRPSLimitedEthClientInterface) PendingCodeAt(ctx context.Context, account common.Address) ([]byte, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "PendingCodeAt", ctx, account)
|
||||
ret0, _ := ret[0].([]byte)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// PendingCodeAt indicates an expected call of PendingCodeAt.
|
||||
func (mr *MockRPSLimitedEthClientInterfaceMockRecorder) PendingCodeAt(ctx, account any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PendingCodeAt", reflect.TypeOf((*MockRPSLimitedEthClientInterface)(nil).PendingCodeAt), ctx, account)
|
||||
}
|
||||
|
||||
// PendingNonceAt mocks base method.
|
||||
func (m *MockRPSLimitedEthClientInterface) PendingNonceAt(ctx context.Context, account common.Address) (uint64, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "PendingNonceAt", ctx, account)
|
||||
ret0, _ := ret[0].(uint64)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// PendingNonceAt indicates an expected call of PendingNonceAt.
|
||||
func (mr *MockRPSLimitedEthClientInterfaceMockRecorder) PendingNonceAt(ctx, account any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PendingNonceAt", reflect.TypeOf((*MockRPSLimitedEthClientInterface)(nil).PendingNonceAt), ctx, account)
|
||||
}
|
||||
|
||||
// PendingStorageAt mocks base method.
|
||||
func (m *MockRPSLimitedEthClientInterface) PendingStorageAt(ctx context.Context, account common.Address, key common.Hash) ([]byte, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "PendingStorageAt", ctx, account, key)
|
||||
ret0, _ := ret[0].([]byte)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// PendingStorageAt indicates an expected call of PendingStorageAt.
|
||||
func (mr *MockRPSLimitedEthClientInterfaceMockRecorder) PendingStorageAt(ctx, account, key any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PendingStorageAt", reflect.TypeOf((*MockRPSLimitedEthClientInterface)(nil).PendingStorageAt), ctx, account, key)
|
||||
}
|
||||
|
||||
// PendingTransactionCount mocks base method.
|
||||
func (m *MockRPSLimitedEthClientInterface) PendingTransactionCount(ctx context.Context) (uint, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "PendingTransactionCount", ctx)
|
||||
ret0, _ := ret[0].(uint)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// PendingTransactionCount indicates an expected call of PendingTransactionCount.
|
||||
func (mr *MockRPSLimitedEthClientInterfaceMockRecorder) PendingTransactionCount(ctx any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PendingTransactionCount", reflect.TypeOf((*MockRPSLimitedEthClientInterface)(nil).PendingTransactionCount), ctx)
|
||||
}
|
||||
|
||||
// SendTransaction mocks base method.
|
||||
func (m *MockRPSLimitedEthClientInterface) SendTransaction(ctx context.Context, tx *types.Transaction) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "SendTransaction", ctx, tx)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// SendTransaction indicates an expected call of SendTransaction.
|
||||
func (mr *MockRPSLimitedEthClientInterfaceMockRecorder) SendTransaction(ctx, tx any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendTransaction", reflect.TypeOf((*MockRPSLimitedEthClientInterface)(nil).SendTransaction), ctx, tx)
|
||||
}
|
||||
|
||||
// StorageAt mocks base method.
|
||||
func (m *MockRPSLimitedEthClientInterface) StorageAt(ctx context.Context, account common.Address, key common.Hash, blockNumber *big.Int) ([]byte, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "StorageAt", ctx, account, key, blockNumber)
|
||||
ret0, _ := ret[0].([]byte)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// StorageAt indicates an expected call of StorageAt.
|
||||
func (mr *MockRPSLimitedEthClientInterfaceMockRecorder) StorageAt(ctx, account, key, blockNumber any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StorageAt", reflect.TypeOf((*MockRPSLimitedEthClientInterface)(nil).StorageAt), ctx, account, key, blockNumber)
|
||||
}
|
||||
|
||||
// SubscribeFilterLogs mocks base method.
|
||||
func (m *MockRPSLimitedEthClientInterface) SubscribeFilterLogs(ctx context.Context, q ethereum.FilterQuery, ch chan<- types.Log) (ethereum.Subscription, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "SubscribeFilterLogs", ctx, q, ch)
|
||||
ret0, _ := ret[0].(ethereum.Subscription)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// SubscribeFilterLogs indicates an expected call of SubscribeFilterLogs.
|
||||
func (mr *MockRPSLimitedEthClientInterfaceMockRecorder) SubscribeFilterLogs(ctx, q, ch any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SubscribeFilterLogs", reflect.TypeOf((*MockRPSLimitedEthClientInterface)(nil).SubscribeFilterLogs), ctx, q, ch)
|
||||
}
|
||||
|
||||
// SuggestGasPrice mocks base method.
|
||||
func (m *MockRPSLimitedEthClientInterface) SuggestGasPrice(ctx context.Context) (*big.Int, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "SuggestGasPrice", ctx)
|
||||
ret0, _ := ret[0].(*big.Int)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// SuggestGasPrice indicates an expected call of SuggestGasPrice.
|
||||
func (mr *MockRPSLimitedEthClientInterfaceMockRecorder) SuggestGasPrice(ctx any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SuggestGasPrice", reflect.TypeOf((*MockRPSLimitedEthClientInterface)(nil).SuggestGasPrice), ctx)
|
||||
}
|
||||
|
||||
// SuggestGasTipCap mocks base method.
|
||||
func (m *MockRPSLimitedEthClientInterface) SuggestGasTipCap(ctx context.Context) (*big.Int, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "SuggestGasTipCap", ctx)
|
||||
ret0, _ := ret[0].(*big.Int)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// SuggestGasTipCap indicates an expected call of SuggestGasTipCap.
|
||||
func (mr *MockRPSLimitedEthClientInterfaceMockRecorder) SuggestGasTipCap(ctx any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SuggestGasTipCap", reflect.TypeOf((*MockRPSLimitedEthClientInterface)(nil).SuggestGasTipCap), ctx)
|
||||
}
|
||||
|
||||
// SyncProgress mocks base method.
|
||||
func (m *MockRPSLimitedEthClientInterface) SyncProgress(ctx context.Context) (*ethereum.SyncProgress, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "SyncProgress", ctx)
|
||||
ret0, _ := ret[0].(*ethereum.SyncProgress)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// SyncProgress indicates an expected call of SyncProgress.
|
||||
func (mr *MockRPSLimitedEthClientInterfaceMockRecorder) SyncProgress(ctx any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SyncProgress", reflect.TypeOf((*MockRPSLimitedEthClientInterface)(nil).SyncProgress), ctx)
|
||||
}
|
||||
|
||||
// TransactionByHash mocks base method.
|
||||
func (m *MockRPSLimitedEthClientInterface) TransactionByHash(ctx context.Context, txHash common.Hash) (*types.Transaction, bool, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "TransactionByHash", ctx, txHash)
|
||||
ret0, _ := ret[0].(*types.Transaction)
|
||||
ret1, _ := ret[1].(bool)
|
||||
ret2, _ := ret[2].(error)
|
||||
return ret0, ret1, ret2
|
||||
}
|
||||
|
||||
// TransactionByHash indicates an expected call of TransactionByHash.
|
||||
func (mr *MockRPSLimitedEthClientInterfaceMockRecorder) TransactionByHash(ctx, txHash any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "TransactionByHash", reflect.TypeOf((*MockRPSLimitedEthClientInterface)(nil).TransactionByHash), ctx, txHash)
|
||||
}
|
||||
|
||||
// TransactionReceipt mocks base method.
|
||||
func (m *MockRPSLimitedEthClientInterface) TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "TransactionReceipt", ctx, txHash)
|
||||
ret0, _ := ret[0].(*types.Receipt)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// TransactionReceipt indicates an expected call of TransactionReceipt.
|
||||
func (mr *MockRPSLimitedEthClientInterfaceMockRecorder) TransactionReceipt(ctx, txHash any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "TransactionReceipt", reflect.TypeOf((*MockRPSLimitedEthClientInterface)(nil).TransactionReceipt), ctx, txHash)
|
||||
}
|
||||
|
||||
// TransactionSender mocks base method.
|
||||
func (m *MockRPSLimitedEthClientInterface) TransactionSender(ctx context.Context, tx *types.Transaction, block common.Hash, index uint) (common.Address, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "TransactionSender", ctx, tx, block, index)
|
||||
ret0, _ := ret[0].(common.Address)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// TransactionSender indicates an expected call of TransactionSender.
|
||||
func (mr *MockRPSLimitedEthClientInterfaceMockRecorder) TransactionSender(ctx, tx, block, index any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "TransactionSender", reflect.TypeOf((*MockRPSLimitedEthClientInterface)(nil).TransactionSender), ctx, tx, block, index)
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package chain
|
||||
package rpclimiter
|
||||
|
||||
import (
|
||||
"database/sql"
|
@ -1,4 +1,4 @@
|
||||
package chain
|
||||
package rpclimiter
|
||||
|
||||
import (
|
||||
"database/sql"
|
@ -1,4 +1,4 @@
|
||||
package chain
|
||||
package rpclimiter
|
||||
|
||||
import (
|
||||
"testing"
|
13
rpc/chain/tagger/tagger.go
Normal file
13
rpc/chain/tagger/tagger.go
Normal file
@ -0,0 +1,13 @@
|
||||
package tagger
|
||||
|
||||
type Tagger interface {
|
||||
Tag() string
|
||||
SetTag(tag string)
|
||||
GroupTag() string
|
||||
SetGroupTag(tag string)
|
||||
DeepCopyTag() Tagger
|
||||
}
|
||||
|
||||
func DeepCopyTagger(t Tagger) Tagger {
|
||||
return t.DeepCopyTag()
|
||||
}
|
@ -14,13 +14,14 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/ethereum/go-ethereum/ethclient"
|
||||
"github.com/ethereum/go-ethereum/log"
|
||||
gethrpc "github.com/ethereum/go-ethereum/rpc"
|
||||
|
||||
appCommon "github.com/status-im/status-go/common"
|
||||
"github.com/status-im/status-go/params"
|
||||
"github.com/status-im/status-go/rpc/chain"
|
||||
"github.com/status-im/status-go/rpc/chain/ethclient"
|
||||
"github.com/status-im/status-go/rpc/chain/rpclimiter"
|
||||
"github.com/status-im/status-go/rpc/network"
|
||||
"github.com/status-im/status-go/services/rpcstats"
|
||||
"github.com/status-im/status-go/services/wallet/common"
|
||||
@ -72,7 +73,7 @@ func init() {
|
||||
type Handler func(context.Context, uint64, ...interface{}) (interface{}, error)
|
||||
|
||||
type ClientInterface interface {
|
||||
AbstractEthClient(chainID common.ChainID) (chain.BatchCallClient, error)
|
||||
AbstractEthClient(chainID common.ChainID) (ethclient.BatchCallClient, error)
|
||||
EthClient(chainID uint64) (chain.ClientInterface, error)
|
||||
EthClients(chainIDs []uint64) (map[uint64]chain.ClientInterface, error)
|
||||
CallContext(context context.Context, result interface{}, chainID uint64, method string, args ...interface{}) error
|
||||
@ -96,7 +97,7 @@ type Client struct {
|
||||
rpcClientsMutex sync.RWMutex
|
||||
rpcClients map[uint64]chain.ClientInterface
|
||||
rpsLimiterMutex sync.RWMutex
|
||||
limiterPerProvider map[string]*chain.RPCRpsLimiter
|
||||
limiterPerProvider map[string]*rpclimiter.RPCRpsLimiter
|
||||
|
||||
router *router
|
||||
NetworkManager *network.Manager
|
||||
@ -136,7 +137,7 @@ func NewClient(client *gethrpc.Client, upstreamChainID uint64, upstream params.U
|
||||
NetworkManager: networkManager,
|
||||
handlers: make(map[string]Handler),
|
||||
rpcClients: make(map[uint64]chain.ClientInterface),
|
||||
limiterPerProvider: make(map[string]*chain.RPCRpsLimiter),
|
||||
limiterPerProvider: make(map[string]*rpclimiter.RPCRpsLimiter),
|
||||
log: log,
|
||||
providerConfigs: providerConfigs,
|
||||
}
|
||||
@ -168,7 +169,10 @@ func NewClient(client *gethrpc.Client, upstreamChainID uint64, upstream params.U
|
||||
// Include the chain-id in the rpc client
|
||||
rpcName := fmt.Sprintf("%s-chain-id-%d", hostPortUpstream, upstreamChainID)
|
||||
|
||||
c.upstream = chain.NewSimpleClient(*chain.NewEthClient(ethclient.NewClient(upstreamClient), limiter, upstreamClient, rpcName), upstreamChainID)
|
||||
ethClients := []ethclient.RPSLimitedEthClientInterface{
|
||||
ethclient.NewRPSLimitedEthClient(upstreamClient, limiter, rpcName),
|
||||
}
|
||||
c.upstream = chain.NewClient(ethClients, upstreamChainID)
|
||||
}
|
||||
|
||||
c.router = newRouter(c.upstreamEnabled)
|
||||
@ -197,13 +201,13 @@ func extractHostFromURL(inputURL string) (string, error) {
|
||||
return parsedURL.Host, nil
|
||||
}
|
||||
|
||||
func (c *Client) getRPCRpsLimiter(key string) (*chain.RPCRpsLimiter, error) {
|
||||
func (c *Client) getRPCRpsLimiter(key string) (*rpclimiter.RPCRpsLimiter, error) {
|
||||
c.rpsLimiterMutex.Lock()
|
||||
defer c.rpsLimiterMutex.Unlock()
|
||||
if limiter, ok := c.limiterPerProvider[key]; ok {
|
||||
return limiter, nil
|
||||
}
|
||||
limiter := chain.NewRPCRpsLimiter()
|
||||
limiter := rpclimiter.NewRPCRpsLimiter()
|
||||
c.limiterPerProvider[key] = limiter
|
||||
return limiter, nil
|
||||
}
|
||||
@ -241,12 +245,12 @@ func (c *Client) getClientUsingCache(chainID uint64) (chain.ClientInterface, err
|
||||
}
|
||||
|
||||
client := chain.NewClient(ethClients, chainID)
|
||||
client.WalletNotifier = c.walletNotifier
|
||||
client.SetWalletNotifier(c.walletNotifier)
|
||||
c.rpcClients[chainID] = client
|
||||
return client, nil
|
||||
}
|
||||
|
||||
func (c *Client) getEthClients(network *params.Network) []*chain.EthClient {
|
||||
func (c *Client) getEthClients(network *params.Network) []ethclient.RPSLimitedEthClientInterface {
|
||||
urls := make(map[string]string)
|
||||
keys := make([]string, 0)
|
||||
authMap := make(map[string]string)
|
||||
@ -270,10 +274,10 @@ func (c *Client) getEthClients(network *params.Network) []*chain.EthClient {
|
||||
urls["main"] = network.RPCURL
|
||||
urls["fallback"] = network.FallbackURL
|
||||
|
||||
ethClients := make([]*chain.EthClient, 0)
|
||||
ethClients := make([]ethclient.RPSLimitedEthClientInterface, 0)
|
||||
for index, key := range keys {
|
||||
var rpcClient *gethrpc.Client
|
||||
var rpcLimiter *chain.RPCRpsLimiter
|
||||
var rpcLimiter *rpclimiter.RPCRpsLimiter
|
||||
var err error
|
||||
var hostPort string
|
||||
url := urls[key]
|
||||
@ -312,7 +316,7 @@ func (c *Client) getEthClients(network *params.Network) []*chain.EthClient {
|
||||
c.log.Error("get RPC limiter "+key, "error", err)
|
||||
}
|
||||
|
||||
ethClients = append(ethClients, chain.NewEthClient(ethclient.NewClient(rpcClient), rpcLimiter, rpcClient, circuitKey))
|
||||
ethClients = append(ethClients, ethclient.NewRPSLimitedEthClient(rpcClient, rpcLimiter, circuitKey))
|
||||
}
|
||||
}
|
||||
|
||||
@ -330,7 +334,7 @@ func (c *Client) EthClient(chainID uint64) (chain.ClientInterface, error) {
|
||||
}
|
||||
|
||||
// AbstractEthClient returns a partial abstraction used by new components for testing purposes
|
||||
func (c *Client) AbstractEthClient(chainID common.ChainID) (chain.BatchCallClient, error) {
|
||||
func (c *Client) AbstractEthClient(chainID common.ChainID) (ethclient.BatchCallClient, error) {
|
||||
client, err := c.getClientUsingCache(uint64(chainID))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -378,7 +382,11 @@ func (c *Client) UpdateUpstreamURL(url string) error {
|
||||
if err != nil {
|
||||
hostPortUpstream = "upstream"
|
||||
}
|
||||
c.upstream = chain.NewSimpleClient(*chain.NewEthClient(ethclient.NewClient(rpcClient), rpsLimiter, rpcClient, hostPortUpstream), c.UpstreamChainID)
|
||||
|
||||
ethClients := []ethclient.RPSLimitedEthClientInterface{
|
||||
ethclient.NewRPSLimitedEthClient(rpcClient, rpsLimiter, hostPortUpstream),
|
||||
}
|
||||
c.upstream = chain.NewClient(ethClients, c.UpstreamChainID)
|
||||
c.upstreamURL = url
|
||||
c.Unlock()
|
||||
|
||||
|
@ -1,5 +1,10 @@
|
||||
// Code generated by MockGen. DO NOT EDIT.
|
||||
// Source: rpc/client.go
|
||||
//
|
||||
// Generated by this command:
|
||||
//
|
||||
// mockgen -package=mock_rpcclient -destination=rpc/mock/client/client.go -source=rpc/client.go
|
||||
//
|
||||
|
||||
// Package mock_rpcclient is a generated GoMock package.
|
||||
package mock_rpcclient
|
||||
@ -9,6 +14,7 @@ import (
|
||||
reflect "reflect"
|
||||
|
||||
chain "github.com/status-im/status-go/rpc/chain"
|
||||
ethclient "github.com/status-im/status-go/rpc/chain/ethclient"
|
||||
network "github.com/status-im/status-go/rpc/network"
|
||||
common "github.com/status-im/status-go/services/wallet/common"
|
||||
gomock "go.uber.org/mock/gomock"
|
||||
@ -38,24 +44,24 @@ func (m *MockClientInterface) EXPECT() *MockClientInterfaceMockRecorder {
|
||||
}
|
||||
|
||||
// AbstractEthClient mocks base method.
|
||||
func (m *MockClientInterface) AbstractEthClient(chainID common.ChainID) (chain.BatchCallClient, error) {
|
||||
func (m *MockClientInterface) AbstractEthClient(chainID common.ChainID) (ethclient.BatchCallClient, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "AbstractEthClient", chainID)
|
||||
ret0, _ := ret[0].(chain.BatchCallClient)
|
||||
ret0, _ := ret[0].(ethclient.BatchCallClient)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// AbstractEthClient indicates an expected call of AbstractEthClient.
|
||||
func (mr *MockClientInterfaceMockRecorder) AbstractEthClient(chainID interface{}) *gomock.Call {
|
||||
func (mr *MockClientInterfaceMockRecorder) AbstractEthClient(chainID any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AbstractEthClient", reflect.TypeOf((*MockClientInterface)(nil).AbstractEthClient), chainID)
|
||||
}
|
||||
|
||||
// Call mocks base method.
|
||||
func (m *MockClientInterface) Call(result interface{}, chainID uint64, method string, args ...interface{}) error {
|
||||
func (m *MockClientInterface) Call(result any, chainID uint64, method string, args ...any) error {
|
||||
m.ctrl.T.Helper()
|
||||
varargs := []interface{}{result, chainID, method}
|
||||
varargs := []any{result, chainID, method}
|
||||
for _, a := range args {
|
||||
varargs = append(varargs, a)
|
||||
}
|
||||
@ -65,16 +71,16 @@ func (m *MockClientInterface) Call(result interface{}, chainID uint64, method st
|
||||
}
|
||||
|
||||
// Call indicates an expected call of Call.
|
||||
func (mr *MockClientInterfaceMockRecorder) Call(result, chainID, method interface{}, args ...interface{}) *gomock.Call {
|
||||
func (mr *MockClientInterfaceMockRecorder) Call(result, chainID, method any, args ...any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
varargs := append([]interface{}{result, chainID, method}, args...)
|
||||
varargs := append([]any{result, chainID, method}, args...)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Call", reflect.TypeOf((*MockClientInterface)(nil).Call), varargs...)
|
||||
}
|
||||
|
||||
// CallContext mocks base method.
|
||||
func (m *MockClientInterface) CallContext(context context.Context, result interface{}, chainID uint64, method string, args ...interface{}) error {
|
||||
func (m *MockClientInterface) CallContext(context context.Context, result any, chainID uint64, method string, args ...any) error {
|
||||
m.ctrl.T.Helper()
|
||||
varargs := []interface{}{context, result, chainID, method}
|
||||
varargs := []any{context, result, chainID, method}
|
||||
for _, a := range args {
|
||||
varargs = append(varargs, a)
|
||||
}
|
||||
@ -84,9 +90,9 @@ func (m *MockClientInterface) CallContext(context context.Context, result interf
|
||||
}
|
||||
|
||||
// CallContext indicates an expected call of CallContext.
|
||||
func (mr *MockClientInterfaceMockRecorder) CallContext(context, result, chainID, method interface{}, args ...interface{}) *gomock.Call {
|
||||
func (mr *MockClientInterfaceMockRecorder) CallContext(context, result, chainID, method any, args ...any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
varargs := append([]interface{}{context, result, chainID, method}, args...)
|
||||
varargs := append([]any{context, result, chainID, method}, args...)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CallContext", reflect.TypeOf((*MockClientInterface)(nil).CallContext), varargs...)
|
||||
}
|
||||
|
||||
@ -99,7 +105,7 @@ func (m *MockClientInterface) CallRaw(body string) string {
|
||||
}
|
||||
|
||||
// CallRaw indicates an expected call of CallRaw.
|
||||
func (mr *MockClientInterfaceMockRecorder) CallRaw(body interface{}) *gomock.Call {
|
||||
func (mr *MockClientInterfaceMockRecorder) CallRaw(body any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CallRaw", reflect.TypeOf((*MockClientInterface)(nil).CallRaw), body)
|
||||
}
|
||||
@ -114,7 +120,7 @@ func (m *MockClientInterface) EthClient(chainID uint64) (chain.ClientInterface,
|
||||
}
|
||||
|
||||
// EthClient indicates an expected call of EthClient.
|
||||
func (mr *MockClientInterfaceMockRecorder) EthClient(chainID interface{}) *gomock.Call {
|
||||
func (mr *MockClientInterfaceMockRecorder) EthClient(chainID any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EthClient", reflect.TypeOf((*MockClientInterface)(nil).EthClient), chainID)
|
||||
}
|
||||
@ -129,7 +135,7 @@ func (m *MockClientInterface) EthClients(chainIDs []uint64) (map[uint64]chain.Cl
|
||||
}
|
||||
|
||||
// EthClients indicates an expected call of EthClients.
|
||||
func (mr *MockClientInterfaceMockRecorder) EthClients(chainIDs interface{}) *gomock.Call {
|
||||
func (mr *MockClientInterfaceMockRecorder) EthClients(chainIDs any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EthClients", reflect.TypeOf((*MockClientInterface)(nil).EthClients), chainIDs)
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ import (
|
||||
|
||||
"github.com/status-im/status-go/appdatabase"
|
||||
"github.com/status-im/status-go/multiaccounts/accounts"
|
||||
"github.com/status-im/status-go/rpc/chain"
|
||||
ethclient "github.com/status-im/status-go/rpc/chain/ethclient"
|
||||
mock_rpcclient "github.com/status-im/status-go/rpc/mock/client"
|
||||
"github.com/status-im/status-go/services/wallet/bigint"
|
||||
"github.com/status-im/status-go/services/wallet/common"
|
||||
@ -83,7 +83,7 @@ func setupTestService(tb testing.TB) (state testState) {
|
||||
|
||||
state.chainClient = transactions.NewMockChainClient()
|
||||
state.rpcClient = mock_rpcclient.NewMockClientInterface(mockCtrl)
|
||||
state.rpcClient.EXPECT().AbstractEthClient(gomock.Any()).DoAndReturn(func(chainID common.ChainID) (chain.BatchCallClient, error) {
|
||||
state.rpcClient.EXPECT().AbstractEthClient(gomock.Any()).DoAndReturn(func(chainID common.ChainID) (ethclient.BatchCallClient, error) {
|
||||
return state.chainClient.AbstractEthClient(chainID)
|
||||
}).AnyTimes()
|
||||
|
||||
|
@ -15,6 +15,7 @@ import (
|
||||
nodetypes "github.com/status-im/status-go/eth-node/types"
|
||||
"github.com/status-im/status-go/multiaccounts/accounts"
|
||||
"github.com/status-im/status-go/rpc/chain"
|
||||
"github.com/status-im/status-go/rpc/chain/rpclimiter"
|
||||
"github.com/status-im/status-go/services/wallet/async"
|
||||
"github.com/status-im/status-go/services/wallet/balance"
|
||||
"github.com/status-im/status-go/services/wallet/blockchainstate"
|
||||
@ -1120,8 +1121,8 @@ func (c *loadBlocksAndTransfersCommand) fetchHistoryBlocksForAccount(group *asyn
|
||||
}
|
||||
|
||||
if len(ranges) > 0 {
|
||||
storage := chain.NewLimitsDBStorage(c.db.client)
|
||||
limiter := chain.NewRequestLimiter(storage)
|
||||
storage := rpclimiter.NewLimitsDBStorage(c.db.client)
|
||||
limiter := rpclimiter.NewRequestLimiter(storage)
|
||||
chainClient, _ := createChainClientWithLimiter(c.chainClient, account, limiter)
|
||||
if chainClient == nil {
|
||||
chainClient = c.chainClient
|
||||
@ -1310,7 +1311,7 @@ func accountLimiterTag(account common.Address) string {
|
||||
return transferHistoryTag + "_" + account.String()
|
||||
}
|
||||
|
||||
func createChainClientWithLimiter(client chain.ClientInterface, account common.Address, limiter chain.RequestLimiter) (chain.ClientInterface, error) {
|
||||
func createChainClientWithLimiter(client chain.ClientInterface, account common.Address, limiter rpclimiter.RequestLimiter) (chain.ClientInterface, error) {
|
||||
// Each account has its own limit and a global limit for all accounts
|
||||
accountTag := accountLimiterTag(account)
|
||||
chainClient := chain.ClientWithTag(client, accountTag, transferHistoryTag)
|
||||
@ -1328,7 +1329,7 @@ func createChainClientWithLimiter(client chain.ClientInterface, account common.A
|
||||
|
||||
limit, _ := limiter.GetLimit(accountTag)
|
||||
if limit == nil {
|
||||
err := limiter.SetLimit(accountTag, transferHistoryLimitPerAccount, chain.LimitInfinitely)
|
||||
err := limiter.SetLimit(accountTag, transferHistoryLimitPerAccount, rpclimiter.LimitInfinitely)
|
||||
if err != nil {
|
||||
log.Error("fetchHistoryBlocksForAccount SetLimit", "error", err, "accountTag", accountTag)
|
||||
}
|
||||
|
@ -29,8 +29,9 @@ import (
|
||||
"github.com/status-im/status-go/contracts/ethscan"
|
||||
"github.com/status-im/status-go/contracts/ierc20"
|
||||
ethtypes "github.com/status-im/status-go/eth-node/types"
|
||||
"github.com/status-im/status-go/rpc/chain"
|
||||
ethclient "github.com/status-im/status-go/rpc/chain/ethclient"
|
||||
mock_client "github.com/status-im/status-go/rpc/chain/mock/client"
|
||||
"github.com/status-im/status-go/rpc/chain/rpclimiter"
|
||||
mock_rpcclient "github.com/status-im/status-go/rpc/mock/client"
|
||||
"github.com/status-im/status-go/server"
|
||||
"github.com/status-im/status-go/services/wallet/async"
|
||||
@ -67,7 +68,7 @@ type TestClient struct {
|
||||
rw sync.RWMutex
|
||||
callsCounter map[string]int
|
||||
currentBlock uint64
|
||||
limiter chain.RequestLimiter
|
||||
limiter rpclimiter.RequestLimiter
|
||||
tag string
|
||||
groupTag string
|
||||
}
|
||||
@ -314,10 +315,7 @@ func (tc *TestClient) CallBlockHashByTransaction(ctx context.Context, blockNumbe
|
||||
|
||||
func (tc *TestClient) GetBaseFeeFromBlock(ctx context.Context, blockNumber *big.Int) (string, error) {
|
||||
err := tc.countAndlog("GetBaseFeeFromBlock")
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return "", nil
|
||||
return "", err
|
||||
}
|
||||
|
||||
func (tc *TestClient) NetworkID() uint64 {
|
||||
@ -582,10 +580,7 @@ func (tc *TestClient) prepareTokenBalanceHistory(toBlock int) {
|
||||
|
||||
func (tc *TestClient) CallContext(ctx context.Context, result interface{}, method string, args ...interface{}) error {
|
||||
err := tc.countAndlog("CallContext")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return err
|
||||
}
|
||||
|
||||
func (tc *TestClient) GetWalletNotifier() func(chainId uint64, message string) {
|
||||
@ -603,74 +598,47 @@ func (tc *TestClient) SetWalletNotifier(notifier func(chainId uint64, message st
|
||||
|
||||
func (tc *TestClient) EstimateGas(ctx context.Context, call ethereum.CallMsg) (gas uint64, err error) {
|
||||
err = tc.countAndlog("EstimateGas")
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return 0, nil
|
||||
return 0, err
|
||||
}
|
||||
|
||||
func (tc *TestClient) PendingCodeAt(ctx context.Context, account common.Address) ([]byte, error) {
|
||||
err := tc.countAndlog("PendingCodeAt")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, nil
|
||||
return nil, err
|
||||
}
|
||||
|
||||
func (tc *TestClient) PendingCallContract(ctx context.Context, call ethereum.CallMsg) ([]byte, error) {
|
||||
err := tc.countAndlog("PendingCallContract")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, nil
|
||||
return nil, err
|
||||
}
|
||||
|
||||
func (tc *TestClient) PendingNonceAt(ctx context.Context, account common.Address) (uint64, error) {
|
||||
err := tc.countAndlog("PendingNonceAt")
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return 0, nil
|
||||
return 0, err
|
||||
}
|
||||
|
||||
func (tc *TestClient) SuggestGasPrice(ctx context.Context) (*big.Int, error) {
|
||||
err := tc.countAndlog("SuggestGasPrice")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, nil
|
||||
return nil, err
|
||||
}
|
||||
|
||||
func (tc *TestClient) SendTransaction(ctx context.Context, tx *types.Transaction) error {
|
||||
err := tc.countAndlog("SendTransaction")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return err
|
||||
}
|
||||
|
||||
func (tc *TestClient) SuggestGasTipCap(ctx context.Context) (*big.Int, error) {
|
||||
err := tc.countAndlog("SuggestGasTipCap")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, nil
|
||||
return nil, err
|
||||
}
|
||||
|
||||
func (tc *TestClient) BatchCallContextIgnoringLocalHandlers(ctx context.Context, b []rpc.BatchElem) error {
|
||||
err := tc.countAndlog("BatchCallContextIgnoringLocalHandlers")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return err
|
||||
}
|
||||
|
||||
func (tc *TestClient) CallContextIgnoringLocalHandlers(ctx context.Context, result interface{}, method string, args ...interface{}) error {
|
||||
err := tc.countAndlog("CallContextIgnoringLocalHandlers")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return err
|
||||
}
|
||||
|
||||
func (tc *TestClient) CallRaw(data string) string {
|
||||
@ -684,35 +652,62 @@ func (tc *TestClient) GetChainID() *big.Int {
|
||||
|
||||
func (tc *TestClient) SubscribeFilterLogs(ctx context.Context, q ethereum.FilterQuery, ch chan<- types.Log) (ethereum.Subscription, error) {
|
||||
err := tc.countAndlog("SubscribeFilterLogs")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, nil
|
||||
return nil, err
|
||||
}
|
||||
|
||||
func (tc *TestClient) TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error) {
|
||||
err := tc.countAndlog("TransactionReceipt")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
func (tc *TestClient) TransactionByHash(ctx context.Context, txHash common.Hash) (*types.Transaction, bool, error) {
|
||||
err := tc.countAndlog("TransactionByHash")
|
||||
return nil, false, err
|
||||
}
|
||||
|
||||
func (tc *TestClient) BlockNumber(ctx context.Context) (uint64, error) {
|
||||
err := tc.countAndlog("BlockNumber")
|
||||
return 0, err
|
||||
}
|
||||
|
||||
func (tc *TestClient) FeeHistory(ctx context.Context, blockCount uint64, lastBlock *big.Int, rewardPercentiles []float64) (*ethereum.FeeHistory, error) {
|
||||
err := tc.countAndlog("FeeHistory")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (tc *TestClient) TransactionByHash(ctx context.Context, txHash common.Hash) (*types.Transaction, bool, error) {
|
||||
err := tc.countAndlog("TransactionByHash")
|
||||
if err != nil {
|
||||
return nil, false, err
|
||||
}
|
||||
return nil, false, nil
|
||||
func (tc *TestClient) PendingBalanceAt(ctx context.Context, account common.Address) (*big.Int, error) {
|
||||
err := tc.countAndlog("PendingBalanceAt")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
func (tc *TestClient) BlockNumber(ctx context.Context) (uint64, error) {
|
||||
err := tc.countAndlog("BlockNumber")
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return 0, nil
|
||||
func (tc *TestClient) PendingStorageAt(ctx context.Context, account common.Address, key common.Hash) ([]byte, error) {
|
||||
err := tc.countAndlog("PendingStorageAt")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
func (tc *TestClient) PendingTransactionCount(ctx context.Context) (uint, error) {
|
||||
err := tc.countAndlog("PendingTransactionCount")
|
||||
return 0, err
|
||||
}
|
||||
|
||||
func (tc *TestClient) StorageAt(ctx context.Context, account common.Address, key common.Hash, blockNumber *big.Int) ([]byte, error) {
|
||||
err := tc.countAndlog("StorageAt")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
func (tc *TestClient) SyncProgress(ctx context.Context) (*ethereum.SyncProgress, error) {
|
||||
err := tc.countAndlog("SyncProgress")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
func (tc *TestClient) TransactionSender(ctx context.Context, tx *types.Transaction, block common.Hash, index uint) (common.Address, error) {
|
||||
err := tc.countAndlog("TransactionSender")
|
||||
return common.Address{}, err
|
||||
}
|
||||
|
||||
func (tc *TestClient) SetIsConnected(value bool) {
|
||||
if tc.traceAPICalls {
|
||||
tc.t.Log("SetIsConnected")
|
||||
@ -727,14 +722,20 @@ func (tc *TestClient) IsConnected() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (tc *TestClient) GetLimiter() chain.RequestLimiter {
|
||||
func (tc *TestClient) GetLimiter() rpclimiter.RequestLimiter {
|
||||
return tc.limiter
|
||||
}
|
||||
|
||||
func (tc *TestClient) SetLimiter(limiter chain.RequestLimiter) {
|
||||
func (tc *TestClient) SetLimiter(limiter rpclimiter.RequestLimiter) {
|
||||
tc.limiter = limiter
|
||||
}
|
||||
|
||||
func (tc *TestClient) Close() {
|
||||
if tc.traceAPICalls {
|
||||
tc.t.Log("Close")
|
||||
}
|
||||
}
|
||||
|
||||
type testERC20Transfer struct {
|
||||
block *big.Int
|
||||
address common.Address
|
||||
@ -1057,11 +1058,11 @@ func setupFindBlocksCommand(t *testing.T, accountAddress common.Address, fromBlo
|
||||
if tc.GetLimiter() != nil {
|
||||
if allow, _ := tc.GetLimiter().Allow(tc.tag); !allow {
|
||||
t.Log("ERROR: requests over limit")
|
||||
return chain.ErrRequestsOverLimit
|
||||
return rpclimiter.ErrRequestsOverLimit
|
||||
}
|
||||
if allow, _ := tc.GetLimiter().Allow(tc.groupTag); !allow {
|
||||
t.Log("ERROR: requests over limit for group tag")
|
||||
return chain.ErrRequestsOverLimit
|
||||
return rpclimiter.ErrRequestsOverLimit
|
||||
}
|
||||
}
|
||||
|
||||
@ -1187,7 +1188,7 @@ func TestFindBlocksCommandWithLimiter(t *testing.T) {
|
||||
balances := map[common.Address][][]int{accountAddress: {{5, 1, 0}, {20, 2, 0}, {45, 1, 1}, {46, 50, 0}, {75, 0, 1}}}
|
||||
fbc, tc, blockChannel, _ := setupFindBlocksCommand(t, accountAddress, big.NewInt(0), big.NewInt(20), rangeSize, balances, nil, nil, nil, nil)
|
||||
|
||||
limiter := chain.NewRequestLimiter(chain.NewInMemRequestsMapStorage())
|
||||
limiter := rpclimiter.NewRequestLimiter(rpclimiter.NewInMemRequestsMapStorage())
|
||||
err := limiter.SetLimit(transferHistoryTag, maxRequests, time.Hour)
|
||||
require.NoError(t, err)
|
||||
tc.SetLimiter(limiter)
|
||||
@ -1202,7 +1203,7 @@ func TestFindBlocksCommandWithLimiter(t *testing.T) {
|
||||
t.Log("ERROR")
|
||||
case <-group.WaitAsync():
|
||||
close(blockChannel)
|
||||
require.Error(t, chain.ErrRequestsOverLimit, group.Error())
|
||||
require.Error(t, rpclimiter.ErrRequestsOverLimit, group.Error())
|
||||
require.Equal(t, maxRequests, tc.getCounter())
|
||||
}
|
||||
}
|
||||
@ -1216,7 +1217,7 @@ func TestFindBlocksCommandWithLimiterTagDifferentThanTransfers(t *testing.T) {
|
||||
incomingERC20Transfers := map[common.Address][]testERC20Transfer{accountAddress: {{big.NewInt(6), tokenTXXAddress, big.NewInt(1), walletcommon.Erc20TransferEventType}}}
|
||||
|
||||
fbc, tc, blockChannel, _ := setupFindBlocksCommand(t, accountAddress, big.NewInt(0), big.NewInt(20), rangeSize, balances, outgoingERC20Transfers, incomingERC20Transfers, nil, nil)
|
||||
limiter := chain.NewRequestLimiter(chain.NewInMemRequestsMapStorage())
|
||||
limiter := rpclimiter.NewRequestLimiter(rpclimiter.NewInMemRequestsMapStorage())
|
||||
err := limiter.SetLimit("some-other-tag-than-transfer-history", maxRequests, time.Hour)
|
||||
require.NoError(t, err)
|
||||
tc.SetLimiter(limiter)
|
||||
@ -1247,14 +1248,14 @@ func TestFindBlocksCommandWithLimiterForMultipleAccountsSameGroup(t *testing.T)
|
||||
incomingERC20Transfers := map[common.Address][]testERC20Transfer{account2: {{big.NewInt(6), tokenTXXAddress, big.NewInt(1), walletcommon.Erc20TransferEventType}}}
|
||||
|
||||
// Limiters share the same storage
|
||||
storage := chain.NewInMemRequestsMapStorage()
|
||||
storage := rpclimiter.NewInMemRequestsMapStorage()
|
||||
|
||||
// Set up the first account
|
||||
fbc, tc, blockChannel, _ := setupFindBlocksCommand(t, account1, big.NewInt(0), big.NewInt(20), rangeSize, balances, outgoingERC20Transfers, nil, nil, nil)
|
||||
tc.tag = transferHistoryTag + account1.String()
|
||||
tc.groupTag = transferHistoryTag
|
||||
|
||||
limiter1 := chain.NewRequestLimiter(storage)
|
||||
limiter1 := rpclimiter.NewRequestLimiter(storage)
|
||||
err := limiter1.SetLimit(transferHistoryTag, maxRequestsTotal, time.Hour)
|
||||
require.NoError(t, err)
|
||||
err = limiter1.SetLimit(transferHistoryTag+account1.String(), limit1, time.Hour)
|
||||
@ -1265,7 +1266,7 @@ func TestFindBlocksCommandWithLimiterForMultipleAccountsSameGroup(t *testing.T)
|
||||
fbc2, tc2, _, _ := setupFindBlocksCommand(t, account2, big.NewInt(0), big.NewInt(20), rangeSize, balances, nil, incomingERC20Transfers, nil, nil)
|
||||
tc2.tag = transferHistoryTag + account2.String()
|
||||
tc2.groupTag = transferHistoryTag
|
||||
limiter2 := chain.NewRequestLimiter(storage)
|
||||
limiter2 := rpclimiter.NewRequestLimiter(storage)
|
||||
err = limiter2.SetLimit(transferHistoryTag, maxRequestsTotal, time.Hour)
|
||||
require.NoError(t, err)
|
||||
err = limiter2.SetLimit(transferHistoryTag+account2.String(), limit2, time.Hour)
|
||||
@ -1309,7 +1310,7 @@ func newMockChainClient() *MockChainClient {
|
||||
}
|
||||
}
|
||||
|
||||
func (m *MockChainClient) AbstractEthClient(chainID walletcommon.ChainID) (chain.BatchCallClient, error) {
|
||||
func (m *MockChainClient) AbstractEthClient(chainID walletcommon.ChainID) (ethclient.BatchCallClient, error) {
|
||||
if _, ok := m.clients[chainID]; !ok {
|
||||
panic(fmt.Sprintf("no mock client for chainID %d", chainID))
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ import (
|
||||
"github.com/ethereum/go-ethereum/log"
|
||||
statusaccounts "github.com/status-im/status-go/multiaccounts/accounts"
|
||||
"github.com/status-im/status-go/rpc"
|
||||
"github.com/status-im/status-go/rpc/chain"
|
||||
"github.com/status-im/status-go/rpc/chain/rpclimiter"
|
||||
"github.com/status-im/status-go/services/accounts/accountsevent"
|
||||
"github.com/status-im/status-go/services/wallet/balance"
|
||||
"github.com/status-im/status-go/services/wallet/blockchainstate"
|
||||
@ -260,7 +260,7 @@ func (c *Controller) cleanUpRemovedAccount(address common.Address) {
|
||||
log.Error("Failed to delete multitransactions", "error", err)
|
||||
}
|
||||
|
||||
rpcLimitsStorage := chain.NewLimitsDBStorage(c.db.client)
|
||||
rpcLimitsStorage := rpclimiter.NewLimitsDBStorage(c.db.client)
|
||||
err = rpcLimitsStorage.Delete(accountLimiterTag(address))
|
||||
if err != nil {
|
||||
log.Error("Failed to delete limits", "error", err)
|
||||
|
@ -16,7 +16,7 @@ import (
|
||||
"github.com/status-im/status-go/account"
|
||||
"github.com/status-im/status-go/eth-node/types"
|
||||
"github.com/status-im/status-go/rpc"
|
||||
"github.com/status-im/status-go/rpc/chain"
|
||||
"github.com/status-im/status-go/rpc/chain/ethclient"
|
||||
mock_rpcclient "github.com/status-im/status-go/rpc/mock/client"
|
||||
wallet_common "github.com/status-im/status-go/services/wallet/common"
|
||||
"github.com/status-im/status-go/services/wallet/router/pathprocessor"
|
||||
@ -239,7 +239,7 @@ func TestWatchTransaction(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
rpcClient := mock_rpcclient.NewMockClientInterface(ctrl)
|
||||
rpcClient.EXPECT().AbstractEthClient(wallet_common.ChainID(chainID)).DoAndReturn(func(chainID wallet_common.ChainID) (chain.BatchCallClient, error) {
|
||||
rpcClient.EXPECT().AbstractEthClient(wallet_common.ChainID(chainID)).DoAndReturn(func(chainID wallet_common.ChainID) (ethclient.BatchCallClient, error) {
|
||||
return chainClient.AbstractEthClient(chainID)
|
||||
}).AnyTimes()
|
||||
eventFeed := &event.Feed{}
|
||||
@ -291,7 +291,7 @@ func TestWatchTransaction_Timeout(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
rpcClient := mock_rpcclient.NewMockClientInterface(gomock.NewController(t))
|
||||
rpcClient.EXPECT().AbstractEthClient(wallet_common.ChainID(chainID)).DoAndReturn(func(chainID wallet_common.ChainID) (chain.BatchCallClient, error) {
|
||||
rpcClient.EXPECT().AbstractEthClient(wallet_common.ChainID(chainID)).DoAndReturn(func(chainID wallet_common.ChainID) (ethclient.BatchCallClient, error) {
|
||||
return chainClient.AbstractEthClient(chainID)
|
||||
}).AnyTimes()
|
||||
eventFeed := &event.Feed{}
|
||||
|
@ -17,7 +17,7 @@ import (
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/event"
|
||||
"github.com/ethereum/go-ethereum/rpc"
|
||||
"github.com/status-im/status-go/rpc/chain"
|
||||
"github.com/status-im/status-go/rpc/chain/ethclient"
|
||||
mock_rpcclient "github.com/status-im/status-go/rpc/mock/client"
|
||||
|
||||
"github.com/status-im/status-go/services/wallet/common"
|
||||
@ -43,7 +43,7 @@ func setupTestTransactionDB(t *testing.T, checkInterval *time.Duration) (*Pendin
|
||||
rpcClient.EXPECT().EthClient(common.EthereumMainnet).Return(chainClient, nil).AnyTimes()
|
||||
|
||||
// Delegate the call to the fake implementation
|
||||
rpcClient.EXPECT().AbstractEthClient(gomock.Any()).DoAndReturn(func(chainID common.ChainID) (chain.BatchCallClient, error) {
|
||||
rpcClient.EXPECT().AbstractEthClient(gomock.Any()).DoAndReturn(func(chainID common.ChainID) (ethclient.BatchCallClient, error) {
|
||||
return chainClient.AbstractEthClient(chainID)
|
||||
}).AnyTimes()
|
||||
return NewPendingTxTracker(db, rpcClient, nil, eventFeed, pendingCheckInterval), func() {
|
||||
|
@ -10,6 +10,7 @@ import (
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/rpc"
|
||||
"github.com/status-im/status-go/rpc/chain"
|
||||
"github.com/status-im/status-go/rpc/chain/ethclient"
|
||||
mock_client "github.com/status-im/status-go/rpc/chain/mock/client"
|
||||
"github.com/status-im/status-go/services/wallet/bigint"
|
||||
"github.com/status-im/status-go/services/wallet/common"
|
||||
@ -22,7 +23,7 @@ type MockETHClient struct {
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
var _ chain.BatchCallClient = (*MockETHClient)(nil)
|
||||
var _ ethclient.BatchCallClient = (*MockETHClient)(nil)
|
||||
|
||||
func (m *MockETHClient) BatchCallContext(ctx context.Context, b []rpc.BatchElem) error {
|
||||
args := m.Called(ctx, b)
|
||||
@ -53,7 +54,7 @@ func (m *MockChainClient) SetAvailableClients(chainIDs []common.ChainID) *MockCh
|
||||
return m
|
||||
}
|
||||
|
||||
func (m *MockChainClient) AbstractEthClient(chainID common.ChainID) (chain.BatchCallClient, error) {
|
||||
func (m *MockChainClient) AbstractEthClient(chainID common.ChainID) (ethclient.BatchCallClient, error) {
|
||||
if _, ok := m.Clients[chainID]; !ok {
|
||||
panic(fmt.Sprintf("no mock client for chainID %d", chainID))
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user