[STO-308] New receiptDB receipt-specific interface#2701
Conversation
|
The latest Buf updates on your PR. Results from workflow Buf / buf (pull_request).
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #2701 +/- ##
==========================================
+ Coverage 43.81% 43.87% +0.06%
==========================================
Files 1986 1987 +1
Lines 162963 163187 +224
==========================================
+ Hits 71396 71599 +203
- Misses 85069 85072 +3
- Partials 6498 6516 +18
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
| } | ||
| go func() { | ||
| for { | ||
| pruneStartTime := time.Now() |
Check warning
Code scanning / CodeQL
Calling the system time Warning
| go func() { | ||
| for { | ||
| pruneStartTime := time.Now() | ||
| latestVersion := db.GetLatestVersion() | ||
| pruneVersion := latestVersion - keepRecent | ||
| if pruneVersion > 0 { | ||
| // prune all versions up to and including the pruneVersion | ||
| if err := db.Prune(pruneVersion); err != nil { | ||
| log.Error("failed to prune receipt store till", "version", pruneVersion, "err", err) | ||
| } | ||
| log.Info(fmt.Sprintf("Pruned receipt store till version %d took %s\n", pruneVersion, time.Since(pruneStartTime))) | ||
| } | ||
|
|
||
| // Generate a random percentage (between 0% and 100%) of the fixed interval as a delay | ||
| randomPercentage := rand.Float64() | ||
| randomDelay := int64(float64(pruneInterval) * randomPercentage) | ||
| time.Sleep(time.Duration(pruneInterval+randomDelay) * time.Second) | ||
| } | ||
| }() |
Check notice
Code scanning / CodeQL
Spawning a Go routine Note
- Add sentinel errors ErrNotFound and ErrNotConfigured for consistent error checking - Add shutdown mechanism for pruning goroutine with stopPruning channel - Update Close() to signal pruning goroutine to stop using sync.Once - Update x/evm/keeper/receipt.go to use sentinel errors and errors.Is() - Replace string-based error comparison with errors.Is() for better error handling Co-authored-by: jeremy <jeremy@seinetwork.io>
- Rename StoreReceipts to SetReceipts for consistency - Rename LatestHeight to LatestVersion - Rename SetLatestHeight to SetLatestVersion - Rename SetEarliestHeight to SetEarliestVersion - Update all usages in keeper, evmrpc, and tests Co-authored-by: jeremy <jeremy@seinetwork.io>
| closeOnce sync.Once | ||
| } | ||
|
|
||
| func NewReceiptStore(log dbLogger.Logger, config dbconfig.StateStoreConfig, storeKey sdk.StoreKey) (ReceiptStore, error) { |
There was a problem hiding this comment.
Would recommend we create a ReceiptStoreConfig instead of reusing the StateStoreConfig
| return ErrNotConfigured | ||
| } | ||
|
|
||
| pairs := make([]*iavl.KVPair, 0, len(receipts)) |
There was a problem hiding this comment.
How do we plan to add Parquet based backend logic in the future? These logic are all specific to Pebble backend now, do we plan to do another refactor in the next PR to wrap these logic into a separate function?
There was a problem hiding this comment.
will have parquet implementation implement the same interface
|
|
||
| for _, block := range batch { | ||
| f.GetLogsForBlockPooled(block, crit, bloomIndexes, &localLogs) | ||
| f.GetLogsForBlockPooled(block, crit, &localLogs) |
There was a problem hiding this comment.
Can we explain why we remove the bloomIndexes here? Would this impact correctness?
There was a problem hiding this comment.
we calculate it inside FilterLogs from the filter criteria but it doesn't make sense to include it in the interface.
## Describe your changes and provide context This PR converts the current ReceiptDB interface from StateStore interface to using a receipt-specific interface. In a future PR, we will add in the new Parquet implementation for receipts. ## Testing performed to validate your change unit tests. --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: jeremy <jeremy@seinetwork.io>
This PR converts the current ReceiptDB interface from StateStore interface to using a receipt-specific interface. In a future PR, we will add in the new Parquet implementation for receipts. unit tests. --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: jeremy <jeremy@seinetwork.io>
Describe your changes and provide context
This PR converts the current ReceiptDB interface from StateStore interface to using a receipt-specific interface. In a future PR, we will add in the new Parquet implementation for receipts.
Testing performed to validate your change
unit tests.