-
Notifications
You must be signed in to change notification settings - Fork 43
Fix Filecoin FEVM token sync status handling for enabled tokens #959
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
122bcca
to
5cd305e
Compare
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.
It looks like token transactions were never added to this plugin. Let's add that instead
https://filfox.info/api/v1/docs/static/index.html#/default/AddressController_tokenTransferList
5cd305e
to
0632b00
Compare
0632b00
to
9cb10a6
Compare
const ourReceiveAddresses = [] | ||
|
||
// Token transfers don't have network fees in the same way as regular messages | ||
const networkFee = '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.
Transfers have fees but the fees aren't visible in the transfers endpoint. https://filfox.info/api/v1/docs/static/index.html#/default/MessageController_info can get fees from a single transaction or https://filfox.info/api/v1/docs/static/index.html#/default/AddressController_messageTransferList produces a list of messages and the fee can be calculated (that endpoint shows total moved so you would have to subtract the amount to the recipient)
@@ -51,11 +57,25 @@ export class FilfoxAdapter extends NetworkAdapter<FilfoxAdapterConfig> { | |||
const { publicAddress: addressString } = | |||
await this.ethEngine.getFreshAddress() | |||
|
|||
const handleScanProgress = (progress: number): void => { | |||
this.logError( |
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.
Seems like leftover debug logging, remove or comment out
@@ -139,6 +177,197 @@ export class FilfoxAdapter extends NetworkAdapter<FilfoxAdapterConfig> { | |||
this.ethEngine.sendTransactionEvents() | |||
} | |||
|
|||
// Initialize sync status for all enabled tokens to 0 | |||
private initializeSyncStatusForAllTokens(): void { | |||
this.logError( |
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.
Seems like leftover debug logging, remove or comment out
let highestProcessedBlockHeight = startBlock | ||
|
||
// Initialize sync status for all enabled tokens | ||
this.initializeSyncStatusForAllTokens() |
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 don't understand this. Generally, sync status is used to describe the progress of initial sync and doesn't need to be reported once an asset reaches one. This change seems to make this.ethEngine.updateOnAddressesChecked() on line 89 run more frequently and for no benefit because once this.addressesChecked === true that line of code doesn't even do anything.
What's the point of doing this every time checkTransactions is called? It seems like
} | ||
|
||
// Skip transfers prior to the startBlock (avoids reprocessing during resync) | ||
if (tokenTransfer.height <= startBlock) { |
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 check is duplicated and can be moved to where tokenTransfer is first defined
continue | ||
} | ||
|
||
// Skip transfers prior to the last sync height |
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 check is duplicated and can be moved to where tokenTransfer is first defined
'FilfoxAdapter token transfers scanning failed', | ||
error instanceof Error ? error : new Error(String(error)) | ||
) | ||
// If token transfer scanning fails, mark all tokens as complete to avoid blocking sync |
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.
Should we try again if the fetch fails instead of faking the sync ratio?
5fc8fa7
to
9c45b00
Compare
CHANGELOG
Does this branch warrant an entry to the CHANGELOG?
Dependencies
noneDescription
none