-
Notifications
You must be signed in to change notification settings - Fork 56
Sam/remove tx metadata files #689
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: master
Are you sure you want to change the base?
Conversation
| "currency-codes": "^1.5.1", | ||
| "disklet": "^0.5.2", | ||
| "edge-sync-client": "^0.2.8", | ||
| "edge-sync-client": "../edge-sync-client", |
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.
Bug: Local path dependency will break npm package
The edge-sync-client dependency is set to a local filesystem path "../edge-sync-client" instead of an npm version. This is development code that will break when the package is published to npm, as the relative path won't exist on consumer machines. The previous version ^0.2.8 was replaced with this local path.
| // eslint-disable-next-line @typescript-eslint/no-dynamic-delete | ||
| delete out[txidHash] | ||
| } | ||
| } |
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.
Bug: Empty legacy files deleted at wrong path
The empty file detection and deletion logic assumes all transaction files in out are from the new transaction/ directory. However, out may contain legacy files loaded from Transactions/ directory (if no new-format file exists for that txidHash). When such a legacy file is detected as empty, the code tries to delete from transaction/${fileName} which is incorrect - the file actually exists at Transactions/${fileName}. This results in a failed deletion attempt, but the state dispatch CURRENCY_WALLET_FILE_DELETED still removes the entry from fileNames, causing state/disk inconsistency.
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.
Yes, this looks like a legitimate path mix-up that Cursor caught.
| if (file.feeRateRequested != null) return false | ||
|
|
||
| // Check currencies map for non-empty metadata: | ||
| for (const asset of file.currencies.values()) { |
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.
We generally avoid Object.values in the core for historical reasons. It's OK if a currency plugin can't load, but if the core itself can't load, this is extremely very bad. So this would become for (const currencyCode of Object.keys(file.currencies) { const asset = file.currencies[currencyCode]; ... }. This keeps things clean on really bad Androids.
| } | ||
|
|
||
| // Check tokens map for non-empty metadata: | ||
| for (const asset of file.tokens.values()) { |
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.
Same here. for (const tokenId of Object.keys(file.tokens) { const asset = file.tokens[tokenId]; ... }
| // eslint-disable-next-line @typescript-eslint/no-dynamic-delete | ||
| delete out[txidHash] | ||
| } | ||
| } |
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.
Yes, this looks like a legitimate path mix-up that Cursor caught.
| /** Provide when this disklet is synchronized with edge-sync-client's syncRepo */ | ||
| deletedDisklet?: Disklet |
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.
This deletion logic needs to live in the edge-sync-client, as part of the wrapped disklet. The edge-sync-client needs abstract all the sync stuff (adds / changes / deletions / etc.) behind the simple Disklet API, managing the deletions folder internally.
| import { TransactionFile } from '../../../../src/core/currency/wallet/currency-wallet-cleaners' | ||
| import { isEmptyTxFile } from '../../../../src/core/currency/wallet/currency-wallet-files' | ||
|
|
||
| describe('currency wallet files', function () { |
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.
I feel like there are too many tests here. You've already covered this logic e2e style in the currency-wallet test, so I would delete these detailed tests. More tests is not more betterer - we don't need extra slop clogging the context window of both humans and machines.
The biggest danger with this new file-deletion logic happens if we add a new field to the transaction file, and forget to add it to one of the isEmpty* functions. Then users with only that field will have their data randomly disappear. However, your tests don't cover this case (and I'm not sure how you test non-existent future code), which means we are getting a lot of false confidence from these tests (wow! so detailed!) while not actually covering the really dangerous case. So yeah, please delete them.
| ).equals(true) | ||
| }) | ||
|
|
||
| it('returns false for metadata with name', function () { |
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.
Same here. I feel like these could be deleted.
CHANGELOG
Does this branch warrant an entry to the CHANGELOG?
Dependencies
noneDescription
noneNote
Deletes empty transaction metadata files during load and switches repo syncing to edge-sync-client’s syncRepo with deletion markers and tests.
isEmptyMetadataandisEmptyTxFile; detect and delete emptytransaction/*.jsonfiles duringloadTxFiles.CURRENCY_WALLET_FILE_DELETED; updatefilesandfileNamesreducers to remove deleted entries.syncClient.syncRepo; persist updatedstatus.json.encryptDiskletto supportdeletedDiskletfor sync-aware deletions; adddeletedDisklettomakeRepoPaths.syncReposignature and imports to useedge-sync-clientSyncResult.edge-sync-clientdependency (local path) and update lockfile.CHANGELOG.mdwith new behavior and sync change.Written by Cursor Bugbot for commit 840ad5a. This will update automatically on new commits. Configure here.