@@ -39,6 +39,7 @@ type BlockAPI struct {
3939 keeper * keeper.Keeper
4040 ctxProvider func (int64 ) sdk.Context
4141 txConfigProvider func (int64 ) client.TxConfig
42+ earliestVersion func () int64
4243 connectionType ConnectionType
4344 namespace string
4445 includeShellReceipts bool
@@ -52,12 +53,22 @@ type SeiBlockAPI struct {
5253 isPanicTx func (ctx context.Context , hash common.Hash ) (bool , error )
5354}
5455
55- func NewBlockAPI (tmClient rpcclient.Client , k * keeper.Keeper , ctxProvider func (int64 ) sdk.Context , txConfigProvider func (int64 ) client.TxConfig , connectionType ConnectionType , globalBlockCache BlockCache , cacheCreationMutex * sync.Mutex ) * BlockAPI {
56+ func NewBlockAPI (
57+ tmClient rpcclient.Client ,
58+ k * keeper.Keeper ,
59+ ctxProvider func (int64 ) sdk.Context ,
60+ txConfigProvider func (int64 ) client.TxConfig ,
61+ earliestVersion func () int64 ,
62+ connectionType ConnectionType ,
63+ globalBlockCache BlockCache ,
64+ cacheCreationMutex * sync.Mutex ,
65+ ) * BlockAPI {
5666 return & BlockAPI {
5767 tmClient : tmClient ,
5868 keeper : k ,
5969 ctxProvider : ctxProvider ,
6070 txConfigProvider : txConfigProvider ,
71+ earliestVersion : earliestVersion ,
6172 connectionType : connectionType ,
6273 includeShellReceipts : false ,
6374 includeBankTransfers : false ,
@@ -72,6 +83,7 @@ func NewSeiBlockAPI(
7283 k * keeper.Keeper ,
7384 ctxProvider func (int64 ) sdk.Context ,
7485 txConfigProvider func (int64 ) client.TxConfig ,
86+ earliestVersion func () int64 ,
7587 connectionType ConnectionType ,
7688 isPanicTx func (ctx context.Context , hash common.Hash ) (bool , error ),
7789 globalBlockCache BlockCache ,
@@ -82,6 +94,7 @@ func NewSeiBlockAPI(
8294 keeper : k ,
8395 ctxProvider : ctxProvider ,
8496 txConfigProvider : txConfigProvider ,
97+ earliestVersion : earliestVersion ,
8598 connectionType : connectionType ,
8699 includeShellReceipts : true ,
87100 includeBankTransfers : false ,
@@ -100,12 +113,13 @@ func NewSei2BlockAPI(
100113 k * keeper.Keeper ,
101114 ctxProvider func (int64 ) sdk.Context ,
102115 txConfigProvider func (int64 ) client.TxConfig ,
116+ earliestVersion func () int64 ,
103117 connectionType ConnectionType ,
104118 isPanicTx func (ctx context.Context , hash common.Hash ) (bool , error ),
105119 globalBlockCache BlockCache ,
106120 cacheCreationMutex * sync.Mutex ,
107121) * SeiBlockAPI {
108- blockAPI := NewSeiBlockAPI (tmClient , k , ctxProvider , txConfigProvider , connectionType , isPanicTx , globalBlockCache , cacheCreationMutex )
122+ blockAPI := NewSeiBlockAPI (tmClient , k , ctxProvider , txConfigProvider , earliestVersion , connectionType , isPanicTx , globalBlockCache , cacheCreationMutex )
109123 blockAPI .namespace = Sei2Namespace
110124 blockAPI .includeBankTransfers = true
111125 return blockAPI
@@ -161,7 +175,24 @@ func (a *BlockAPI) getBlockByHash(ctx context.Context, blockHash common.Hash, fu
161175 if err != nil {
162176 return nil , err
163177 }
164- return EncodeTmBlock (a .ctxProvider , a .txConfigProvider , block , blockRes , a .keeper , fullTx , a .includeBankTransfers , includeSyntheticTxs , isPanicTx , a .globalBlockCache , a .cacheCreationMutex )
178+ encodedBlock , err := EncodeTmBlock (
179+ a .ctxProvider ,
180+ a .txConfigProvider ,
181+ a .earliestVersion ,
182+ block ,
183+ blockRes ,
184+ a .keeper ,
185+ fullTx ,
186+ a .includeBankTransfers ,
187+ includeSyntheticTxs ,
188+ isPanicTx ,
189+ a .globalBlockCache ,
190+ a .cacheCreationMutex ,
191+ )
192+ if err != nil {
193+ return nil , err
194+ }
195+ return encodedBlock , nil
165196}
166197
167198func (a * BlockAPI ) GetBlockByNumber (ctx context.Context , number rpc.BlockNumber , fullTx bool ) (result map [string ]interface {}, returnErr error ) {
@@ -216,7 +247,24 @@ func (a *BlockAPI) getBlockByNumber(
216247 if err != nil {
217248 return nil , err
218249 }
219- return EncodeTmBlock (a .ctxProvider , a .txConfigProvider , block , blockRes , a .keeper , fullTx , a .includeBankTransfers , includeSyntheticTxs , isPanicTx , a .globalBlockCache , a .cacheCreationMutex )
250+ encodedBlock , err := EncodeTmBlock (
251+ a .ctxProvider ,
252+ a .txConfigProvider ,
253+ a .earliestVersion ,
254+ block ,
255+ blockRes ,
256+ a .keeper ,
257+ fullTx ,
258+ a .includeBankTransfers ,
259+ includeSyntheticTxs ,
260+ isPanicTx ,
261+ a .globalBlockCache ,
262+ a .cacheCreationMutex ,
263+ )
264+ if err != nil {
265+ return nil , err
266+ }
267+ return encodedBlock , nil
220268}
221269
222270func (a * BlockAPI ) GetBlockReceipts (ctx context.Context , blockNrOrHash rpc.BlockNumberOrHash ) (result []map [string ]interface {}, returnErr error ) {
@@ -235,9 +283,19 @@ func (a *BlockAPI) GetBlockReceipts(ctx context.Context, blockNrOrHash rpc.Block
235283
236284 // Get all tx hashes for the block
237285 height := block .Block .Height
238-
239- txHashes := getTxHashesFromBlock (a .ctxProvider , a .txConfigProvider , a .keeper , block , shouldIncludeSynthetic (a .namespace ), a .cacheCreationMutex , a .globalBlockCache )
240-
286+ txHashes , err := getTxHashesFromBlock (
287+ a .ctxProvider ,
288+ a .txConfigProvider ,
289+ a .earliestVersion ,
290+ a .keeper ,
291+ block ,
292+ shouldIncludeSynthetic (a .namespace ),
293+ a .cacheCreationMutex ,
294+ a .globalBlockCache ,
295+ )
296+ if err != nil {
297+ return nil , err
298+ }
241299 // Get tx receipts for all hashes in parallel
242300 wg := sync.WaitGroup {}
243301 mtx := sync.Mutex {}
@@ -256,7 +314,17 @@ func (a *BlockAPI) GetBlockReceipts(ctx context.Context, blockNrOrHash rpc.Block
256314 mtx .Unlock ()
257315 }
258316 } else {
259- encodedReceipt , err := encodeReceipt (a .ctxProvider , a .txConfigProvider , receipt , a .keeper , block , a .includeShellReceipts , a .globalBlockCache , a .cacheCreationMutex )
317+ encodedReceipt , err := encodeReceipt (
318+ a .ctxProvider ,
319+ a .txConfigProvider ,
320+ a .earliestVersion ,
321+ receipt ,
322+ a .keeper ,
323+ block ,
324+ a .includeShellReceipts ,
325+ a .globalBlockCache ,
326+ a .cacheCreationMutex ,
327+ )
260328 if err != nil {
261329 mtx .Lock ()
262330 returnErr = err
@@ -285,6 +353,7 @@ func (a *BlockAPI) GetBlockReceipts(ctx context.Context, blockNrOrHash rpc.Block
285353func EncodeTmBlock (
286354 ctxProvider func (int64 ) sdk.Context ,
287355 txConfigProvider func (int64 ) client.TxConfig ,
356+ earliestVersion func () int64 ,
288357 block * coretypes.ResultBlock ,
289358 blockRes * coretypes.ResultBlockResults ,
290359 k * keeper.Keeper ,
@@ -315,7 +384,10 @@ func EncodeTmBlock(
315384 transactions := []interface {}{}
316385 latestCtx := ctxProvider (LatestCtxHeight )
317386
318- msgs := filterTransactions (k , ctxProvider , txConfigProvider , block , includeSyntheticTxs , includeBankTransfers , cacheCreationMutex , globalBlockCache )
387+ msgs , err := filterTransactions (k , ctxProvider , txConfigProvider , earliestVersion , block , includeSyntheticTxs , includeBankTransfers , cacheCreationMutex , globalBlockCache )
388+ if err != nil {
389+ return nil , err
390+ }
319391
320392 blockBloom := make ([]byte , ethtypes .BloomByteLength )
321393 for _ , msg := range msgs {
0 commit comments