@@ -3,6 +3,7 @@ package evmrpc
33import (
44 "context"
55 "strings"
6+ "sync"
67
78 "github.com/cosmos/cosmos-sdk/baseapp"
89 "github.com/cosmos/cosmos-sdk/client"
@@ -60,22 +61,23 @@ func NewEVMHTTPServer(
6061 EVMTimeout : config .SimulationEVMTimeout ,
6162 MaxConcurrentSimulationCalls : config .MaxConcurrentSimulationCalls ,
6263 }
63- sendAPI := NewSendAPI (tmClient , txConfigProvider , & SendConfig {slow : config .Slow }, k , ctxProvider , homeDir , simulateConfig , app , antehandler , ConnectionTypeHTTP )
64+ globalBlockCache := NewBlockCache (3000 )
65+ cacheCreationMutex := & sync.Mutex {}
66+ sendAPI := NewSendAPI (tmClient , txConfigProvider , & SendConfig {slow : config .Slow }, k , ctxProvider , homeDir , simulateConfig , app , antehandler , ConnectionTypeHTTP , globalBlockCache , cacheCreationMutex )
6467
6568 ctx := ctxProvider (LatestCtxHeight )
6669
67- txAPI := NewTransactionAPI (tmClient , k , ctxProvider , txConfigProvider , homeDir , ConnectionTypeHTTP )
68- debugAPI := NewDebugAPI (tmClient , k , ctxProvider , txConfigProvider , simulateConfig , app , antehandler , ConnectionTypeHTTP , config )
70+ txAPI := NewTransactionAPI (tmClient , k , ctxProvider , txConfigProvider , homeDir , ConnectionTypeHTTP , globalBlockCache , cacheCreationMutex )
71+ debugAPI := NewDebugAPI (tmClient , k , ctxProvider , txConfigProvider , simulateConfig , app , antehandler , ConnectionTypeHTTP , config , globalBlockCache , cacheCreationMutex )
6972 if isPanicOrSyntheticTxFunc == nil {
7073 isPanicOrSyntheticTxFunc = func (ctx context.Context , hash common.Hash ) (bool , error ) {
7174 return debugAPI .isPanicOrSyntheticTx (ctx , hash )
7275 }
7376 }
74- seiTxAPI := NewSeiTransactionAPI (tmClient , k , ctxProvider , txConfigProvider , homeDir , ConnectionTypeHTTP , isPanicOrSyntheticTxFunc )
75- seiDebugAPI := NewSeiDebugAPI (tmClient , k , ctxProvider , txConfigProvider , simulateConfig , app , antehandler , ConnectionTypeHTTP , config )
77+ seiTxAPI := NewSeiTransactionAPI (tmClient , k , ctxProvider , txConfigProvider , homeDir , ConnectionTypeHTTP , isPanicOrSyntheticTxFunc , globalBlockCache , cacheCreationMutex )
78+ seiDebugAPI := NewSeiDebugAPI (tmClient , k , ctxProvider , txConfigProvider , simulateConfig , app , antehandler , ConnectionTypeHTTP , config , globalBlockCache , cacheCreationMutex )
7679
7780 dbReadSemaphore := make (chan struct {}, MaxDBReadConcurrency )
78- globalBlockCache := NewBlockCache (3000 )
7981 globalLogSlicePool := NewLogSlicePool ()
8082 apis := []rpc.API {
8183 {
@@ -84,15 +86,15 @@ func NewEVMHTTPServer(
8486 },
8587 {
8688 Namespace : "eth" ,
87- Service : NewBlockAPI (tmClient , k , ctxProvider , txConfigProvider , ConnectionTypeHTTP ),
89+ Service : NewBlockAPI (tmClient , k , ctxProvider , txConfigProvider , ConnectionTypeHTTP , globalBlockCache , cacheCreationMutex ),
8890 },
8991 {
9092 Namespace : "sei" ,
91- Service : NewSeiBlockAPI (tmClient , k , ctxProvider , txConfigProvider , ConnectionTypeHTTP , isPanicOrSyntheticTxFunc ),
93+ Service : NewSeiBlockAPI (tmClient , k , ctxProvider , txConfigProvider , ConnectionTypeHTTP , isPanicOrSyntheticTxFunc , globalBlockCache , cacheCreationMutex ),
9294 },
9395 {
9496 Namespace : "sei2" ,
95- Service : NewSei2BlockAPI (tmClient , k , ctxProvider , txConfigProvider , ConnectionTypeHTTP , isPanicOrSyntheticTxFunc ),
97+ Service : NewSei2BlockAPI (tmClient , k , ctxProvider , txConfigProvider , ConnectionTypeHTTP , isPanicOrSyntheticTxFunc , globalBlockCache , cacheCreationMutex ),
9698 },
9799 {
98100 Namespace : "eth" ,
@@ -116,7 +118,7 @@ func NewEVMHTTPServer(
116118 },
117119 {
118120 Namespace : "eth" ,
119- Service : NewSimulationAPI (ctxProvider , k , txConfigProvider , tmClient , simulateConfig , app , antehandler , ConnectionTypeHTTP ),
121+ Service : NewSimulationAPI (ctxProvider , k , txConfigProvider , tmClient , simulateConfig , app , antehandler , ConnectionTypeHTTP , globalBlockCache , cacheCreationMutex ),
120122 },
121123 {
122124 Namespace : "net" ,
@@ -134,6 +136,7 @@ func NewEVMHTTPServer(
134136 "eth" ,
135137 dbReadSemaphore ,
136138 globalBlockCache ,
139+ cacheCreationMutex ,
137140 globalLogSlicePool ,
138141 ),
139142 },
@@ -149,6 +152,7 @@ func NewEVMHTTPServer(
149152 "sei" ,
150153 dbReadSemaphore ,
151154 globalBlockCache ,
155+ cacheCreationMutex ,
152156 globalLogSlicePool ,
153157 ),
154158 },
@@ -227,6 +231,7 @@ func NewEVMWebSocketServer(
227231 }
228232 dbReadSemaphore := make (chan struct {}, MaxDBReadConcurrency )
229233 globalBlockCache := NewBlockCache (3000 )
234+ cacheCreationMutex := & sync.Mutex {}
230235 globalLogSlicePool := NewLogSlicePool ()
231236 apis := []rpc.API {
232237 {
@@ -235,11 +240,11 @@ func NewEVMWebSocketServer(
235240 },
236241 {
237242 Namespace : "eth" ,
238- Service : NewBlockAPI (tmClient , k , ctxProvider , txConfigProvider , ConnectionTypeWS ),
243+ Service : NewBlockAPI (tmClient , k , ctxProvider , txConfigProvider , ConnectionTypeWS , globalBlockCache , cacheCreationMutex ),
239244 },
240245 {
241246 Namespace : "eth" ,
242- Service : NewTransactionAPI (tmClient , k , ctxProvider , txConfigProvider , homeDir , ConnectionTypeWS ),
247+ Service : NewTransactionAPI (tmClient , k , ctxProvider , txConfigProvider , homeDir , ConnectionTypeWS , globalBlockCache , cacheCreationMutex ),
243248 },
244249 {
245250 Namespace : "eth" ,
@@ -251,11 +256,11 @@ func NewEVMWebSocketServer(
251256 },
252257 {
253258 Namespace : "eth" ,
254- Service : NewSendAPI (tmClient , txConfigProvider , & SendConfig {slow : config .Slow }, k , ctxProvider , homeDir , simulateConfig , app , antehandler , ConnectionTypeWS ),
259+ Service : NewSendAPI (tmClient , txConfigProvider , & SendConfig {slow : config .Slow }, k , ctxProvider , homeDir , simulateConfig , app , antehandler , ConnectionTypeWS , globalBlockCache , cacheCreationMutex ),
255260 },
256261 {
257262 Namespace : "eth" ,
258- Service : NewSimulationAPI (ctxProvider , k , txConfigProvider , tmClient , simulateConfig , app , antehandler , ConnectionTypeWS ),
263+ Service : NewSimulationAPI (ctxProvider , k , txConfigProvider , tmClient , simulateConfig , app , antehandler , ConnectionTypeWS , globalBlockCache , cacheCreationMutex ),
259264 },
260265 {
261266 Namespace : "net" ,
@@ -270,6 +275,7 @@ func NewEVMWebSocketServer(
270275 txConfigProvider : txConfigProvider ,
271276 dbReadSemaphore : dbReadSemaphore ,
272277 globalBlockCache : globalBlockCache ,
278+ cacheCreationMutex : cacheCreationMutex ,
273279 globalLogSlicePool : globalLogSlicePool ,
274280 }, & SubscriptionConfig {subscriptionCapacity : 100 , newHeadLimit : config .MaxSubscriptionsNewHead }, & FilterConfig {timeout : config .FilterTimeout , maxLog : config .MaxLogNoBlock , maxBlock : config .MaxBlocksForLog }, ConnectionTypeWS ),
275281 },
0 commit comments