-
Notifications
You must be signed in to change notification settings - Fork 222
fix: reduce db calls for getTransactionReceipt RPC #3320
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 12 commits
8c125ae
d4c254f
6a20c29
fed0185
80f5190
30f03a7
9cc6037
24b0bc7
e0ca771
8a23ebe
2a265c6
d2ce1c8
3ad2039
2facc99
c8b3a0f
020af4d
7baa2a7
67d8fe5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1021,7 +1021,9 @@ func TestSubscribeTxnStatus(t *testing.T) { | |
| cache := rpccore.NewTransactionCache(cacheEntryTimeOut, cacheSize) | ||
| handler := New(mockChain, mockSyncer, nil, log).WithSubmittedTransactionsCache(cache) | ||
|
|
||
| mockChain.EXPECT().TransactionByHash(txHash).Return(nil, db.ErrKeyNotFound).AnyTimes() | ||
| mockChain.EXPECT().BlockNumberAndIndexByTxHash( | ||
| (*felt.TransactionHash)(txHash), | ||
| ).Return(uint64(0), uint64(0), db.ErrKeyNotFound).AnyTimes() | ||
| mockSyncer.EXPECT().PendingData().Return(nil, core.ErrPendingDataNotFound).AnyTimes() | ||
| mockChain.EXPECT().HeadsHeader().Return(nil, db.ErrKeyNotFound).AnyTimes() | ||
| mockSyncer.EXPECT().PendingBlock().Return(nil).AnyTimes() | ||
|
|
@@ -1049,7 +1051,9 @@ func TestSubscribeTxnStatus(t *testing.T) { | |
| txHash, err := felt.NewFromString[felt.Felt]("0x1011") | ||
| require.NoError(t, err) | ||
|
|
||
| mockChain.EXPECT().TransactionByHash(txHash).Return(nil, db.ErrKeyNotFound) | ||
| mockChain.EXPECT().BlockNumberAndIndexByTxHash( | ||
| (*felt.TransactionHash)(txHash), | ||
| ).Return(uint64(0), uint64(0), db.ErrKeyNotFound) | ||
|
|
||
| id, conn := createTestTxStatusWebsocket(t, handler, txHash) | ||
| assertNextTxnStatus( | ||
|
|
@@ -1066,7 +1070,9 @@ func TestSubscribeTxnStatus(t *testing.T) { | |
| txHash, err := felt.NewFromString[felt.Felt]("0x1010") | ||
| require.NoError(t, err) | ||
|
|
||
| mockChain.EXPECT().TransactionByHash(txHash).Return(nil, db.ErrKeyNotFound) | ||
| mockChain.EXPECT().BlockNumberAndIndexByTxHash( | ||
| (*felt.TransactionHash)(txHash), | ||
| ).Return(uint64(0), uint64(0), db.ErrKeyNotFound) | ||
| id, conn := createTestTxStatusWebsocket(t, handler, txHash) | ||
| assertNextTxnStatus( | ||
| t, | ||
|
|
@@ -1127,7 +1133,9 @@ func TestSubscribeTxnStatus(t *testing.T) { | |
| ) | ||
| require.Nil(t, addErr) | ||
| txHash := addRes.TransactionHash | ||
| mockChain.EXPECT().TransactionByHash(txHash).Return(nil, db.ErrKeyNotFound) | ||
| mockChain.EXPECT().BlockNumberAndIndexByTxHash( | ||
| (*felt.TransactionHash)(txHash), | ||
| ).Return(uint64(0), uint64(0), db.ErrKeyNotFound) | ||
| mockSyncer.EXPECT().PendingData().Return(nil, core.ErrPendingDataNotFound).Times(2) | ||
| mockChain.EXPECT().HeadsHeader().Return(nil, db.ErrKeyNotFound).Times(2) | ||
|
|
||
|
|
@@ -1143,7 +1151,9 @@ func TestSubscribeTxnStatus(t *testing.T) { | |
| "", | ||
| ) | ||
| // Candidate Status | ||
| mockChain.EXPECT().TransactionByHash(txHash).Return(nil, db.ErrKeyNotFound) | ||
| mockChain.EXPECT().BlockNumberAndIndexByTxHash( | ||
| (*felt.TransactionHash)(txHash), | ||
| ).Return(uint64(0), uint64(0), db.ErrKeyNotFound) | ||
| preConfirmed := &core.PreConfirmed{ | ||
| Block: &core.Block{ | ||
| Header: &core.Header{ | ||
|
|
@@ -1218,8 +1228,14 @@ func TestSubscribeTxnStatus(t *testing.T) { | |
| nil, | ||
| ).Times(1) | ||
| // Accepted on l2 Status | ||
| mockChain.EXPECT().TransactionByHash(txHash).Return(block.Transactions[0], nil) | ||
| mockChain.EXPECT().Receipt(txHash).Return(block.Receipts[0], block.Hash, block.Number, nil) | ||
| mockChain.EXPECT().BlockNumberAndIndexByTxHash( | ||
| (*felt.TransactionHash)(txHash), | ||
| ).Return(block.Number, uint64(0), nil) | ||
| mockChain.EXPECT().TransactionByBlockNumberAndIndex( | ||
| block.Number, uint64(0)).Return(block.Transactions[0], nil) | ||
|
||
| mockChain.EXPECT().ReceiptByBlockNumberAndIndex(block.Number, uint64(0)).Return( | ||
| block.Receipts[0], block.Hash, nil, | ||
| ) | ||
| mockChain.EXPECT().L1Head().Return(core.L1Head{}, db.ErrKeyNotFound) | ||
|
|
||
| handler.newHeads.Send(block) | ||
|
|
@@ -1238,8 +1254,14 @@ func TestSubscribeTxnStatus(t *testing.T) { | |
| nil, | ||
| ).Times(1) | ||
| l1Head := core.L1Head{BlockNumber: block.Number} | ||
| mockChain.EXPECT().TransactionByHash(txHash).Return(block.Transactions[0], nil) | ||
| mockChain.EXPECT().Receipt(txHash).Return(block.Receipts[0], block.Hash, block.Number, nil) | ||
| mockChain.EXPECT().BlockNumberAndIndexByTxHash( | ||
| (*felt.TransactionHash)(txHash), | ||
| ).Return(block.Number, uint64(0), nil) | ||
| mockChain.EXPECT().TransactionByBlockNumberAndIndex( | ||
| block.Number, uint64(0), | ||
| ).Return(block.Transactions[0], nil) | ||
| mockChain.EXPECT().ReceiptByBlockNumberAndIndex( | ||
| block.Number, uint64(0)).Return(block.Receipts[0], block.Hash, nil) | ||
|
||
| mockChain.EXPECT().L1Head().Return(l1Head, nil) | ||
| handler.l1Heads.Send(&l1Head) | ||
| assertNextTxnStatus( | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.