-
Notifications
You must be signed in to change notification settings - Fork 209
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
feat: cache transaction receipts #2181
base: master
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
…e into fs-1093/cache-tx-receipt
import { BigNumber } from 'ethers' | ||
|
||
const cacheKey = `arbitrum:bridge:tx-receipts` | ||
const cacheLogs = false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to be removed when ready for review
@@ -107,7 +108,8 @@ const getProviderForChainCache: { | |||
|
|||
function createProviderWithCache(chainId: ChainId) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getProviderForChainId
's provider is passed down to almost everywhere in the code, especially in Tx history. Hence, changing this provider to EnhancedProvider should upgrade it across our codebase.
…e into fs-1093/cache-tx-receipt
…e into fs-1093/cache-tx-receipt
…e into fs-1093/cache-tx-receipt
…e into fs-1093/cache-tx-receipt
|
||
const cacheKey = `arbitrum:bridge:tx-receipts-cache` | ||
const enableCaching = true | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
txReceiptToString(txReceipt: TransactionReceipt): string
txReceiptFromString(stringified: string): TransactionReceipt
|
||
type CachedReceipts = Record<string, TransactionReceipt> | ||
|
||
const cacheKey = `arbitrum:bridge:tx-receipts-cache` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const cacheKey = `arbitrum:bridge:tx-receipts-cache` | |
const localStorageKey = `arbitrum:bridge:tx-receipts-cache` |
if (!enableCaching) return false | ||
|
||
// Don't cache failed transactions | ||
if (typeof txReceipt.status !== 'undefined' && txReceipt.status === 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (typeof txReceipt.status !== 'undefined' && txReceipt.status === 0) { | |
if (txReceipt.status === 0) { |
// Finality checks to avoid caching re-org'ed transactions | ||
if ( | ||
(chainId === ChainId.Ethereum && txReceipt.confirmations < 65) || | ||
(chainId === ChainId.Sepolia && txReceipt.confirmations < 5) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add holesky
No description provided.