-
Notifications
You must be signed in to change notification settings - Fork 862
[STO-308] New receiptDB receipt-specific interface #2701
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?
Conversation
|
The latest Buf updates on your PR. Results from workflow Buf / buf (pull_request).
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2701 +/- ##
==========================================
- Coverage 43.96% 41.89% -2.07%
==========================================
Files 1978 1015 -963
Lines 162479 84542 -77937
==========================================
- Hits 71439 35422 -36017
+ Misses 84544 45797 -38747
+ Partials 6496 3323 -3173
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>
|
|
||
| // Generate a random percentage (between 0% and 100%) of the fixed interval as a delay | ||
| randomPercentage := rand.Float64() | ||
| randomDelay := int64(float64(pruneInterval) * randomPercentage) |
Check notice
Code scanning / CodeQL
Floating point arithmetic Note
- 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
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.