-
Notifications
You must be signed in to change notification settings - Fork 17
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
improve(BundleDataClient,SpokePoolClient): Log about duplicate events and delete getLatestProposedBundleData
#884
Changes from all commits
b0a7a23
55783b7
9850552
1ab05cc
7c30e1a
8c066af
ce0be1d
bf3bae6
faebdb8
42fb574
04d3592
7545cf2
2df77cf
3f802dc
f2429b8
2b6a8dd
34ce1e0
ea48db5
331dd34
fafbbb3
9e3090b
e1c8599
29b9464
30a1abb
c90cb2f
d2e23df
00e1d7b
6e3ca4d
d6b2a36
54741d6
7264854
412fa8f
337adc8
988356a
34b6010
aab61e9
329d44c
4333390
70773e2
502ed7f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,7 @@ import { | |
Deposit, | ||
DepositWithBlock, | ||
} from "../../interfaces"; | ||
import { AcrossConfigStoreClient, SpokePoolClient } from ".."; | ||
import { SpokePoolClient } from ".."; | ||
import { | ||
BigNumber, | ||
bnZero, | ||
|
@@ -41,18 +41,17 @@ import { | |
isZeroValueFillOrSlowFillRequest, | ||
chainIsEvm, | ||
isValidEvmAddress, | ||
duplicateEvent, | ||
} from "../../utils"; | ||
import winston from "winston"; | ||
import { | ||
_buildPoolRebalanceRoot, | ||
BundleData, | ||
BundleDataSS, | ||
getEndBlockBuffers, | ||
getRefundInformationFromFill, | ||
getRefundsFromBundle, | ||
getWidestPossibleExpectedBlockRange, | ||
isChainDisabled, | ||
PoolRebalanceRoot, | ||
prettyPrintV3SpokePoolEvents, | ||
V3DepositWithBlock, | ||
V3FillWithBlock, | ||
|
@@ -431,52 +430,6 @@ export class BundleDataClient { | |
}, toBN(0)); | ||
} | ||
|
||
private async getLatestProposedBundleData(): Promise<{ bundleData: LoadDataReturnValue; blockRanges: number[][] }> { | ||
const hubPoolClient = this.clients.hubPoolClient; | ||
// Determine which bundle we should fetch from arweave, either the pending bundle or the latest | ||
// executed one. Both should have arweave data but if for some reason the arweave data is missing, | ||
// this function will have to compute the bundle data from scratch which will be slow. We have to fallback | ||
// to computing the bundle from scratch since this function needs to return the full bundle data so that | ||
// it can be used to get the running balance proposed using its data. | ||
const bundleBlockRanges = getImpliedBundleBlockRanges( | ||
hubPoolClient, | ||
this.clients.configStoreClient, | ||
hubPoolClient.hasPendingProposal() | ||
? hubPoolClient.getLatestProposedRootBundle() | ||
: hubPoolClient.getLatestFullyExecutedRootBundle(hubPoolClient.latestBlockSearched)! // ! because we know there is a bundle | ||
); | ||
return { | ||
blockRanges: bundleBlockRanges, | ||
bundleData: await this.loadData( | ||
bundleBlockRanges, | ||
this.spokePoolClients, | ||
true // this bundle data should have been published to arweave | ||
), | ||
}; | ||
} | ||
|
||
async getLatestPoolRebalanceRoot(): Promise<{ root: PoolRebalanceRoot; blockRanges: number[][] }> { | ||
const { bundleData, blockRanges } = await this.getLatestProposedBundleData(); | ||
const hubPoolClient = this.clients.hubPoolClient; | ||
const root = _buildPoolRebalanceRoot( | ||
hubPoolClient.latestBlockSearched, | ||
blockRanges[0][1], | ||
bundleData.bundleDepositsV3, | ||
bundleData.bundleFillsV3, | ||
bundleData.bundleSlowFillsV3, | ||
bundleData.unexecutableSlowFills, | ||
bundleData.expiredDepositsToRefundV3, | ||
{ | ||
hubPoolClient, | ||
configStoreClient: hubPoolClient.configStoreClient as AcrossConfigStoreClient, | ||
} | ||
); | ||
return { | ||
root, | ||
blockRanges, | ||
}; | ||
} | ||
|
||
// @dev This function should probably be moved to the InventoryClient since it bypasses loadData completely now. | ||
// Return refunds from the next valid bundle. This will contain any refunds that have been sent but are not included | ||
// in a valid bundle with all of its leaves executed. This contains refunds from: | ||
|
@@ -867,6 +820,14 @@ export class BundleDataClient { | |
"Not using correct bundle deposit hash key" | ||
); | ||
if (deposit.blockNumber >= originChainBlockRange[0]) { | ||
if (bundleDepositsV3?.[originChainId]?.[deposit.inputToken]?.find((d) => duplicateEvent(deposit, d))) { | ||
this.logger.debug({ | ||
at: "BundleDataClient#loadData", | ||
message: "Duplicate deposit detected", | ||
deposit, | ||
}); | ||
throw new Error("Duplicate deposit detected"); | ||
} | ||
bundleDepositHashes.push(newBundleDepositHash); | ||
updateBundleDepositsV3(bundleDepositsV3, deposit); | ||
} else if (deposit.blockNumber < originChainBlockRange[0]) { | ||
|
@@ -978,6 +939,11 @@ export class BundleDataClient { | |
} | ||
} | ||
} else { | ||
this.logger.debug({ | ||
at: "BundleDataClient#loadData", | ||
message: "Duplicate fill detected", | ||
fill, | ||
}); | ||
Comment on lines
+942
to
+946
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This and the subsequent There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. creates a big diff but good point: 9e3090b There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @pxrl I've decided to revert back to this implementation becaues the diff is so big and hard to verify. |
||
throw new Error("Duplicate fill detected"); | ||
} | ||
return; | ||
|
@@ -1099,6 +1065,11 @@ export class BundleDataClient { | |
validatedBundleSlowFills.push(matchedDeposit); | ||
} | ||
} else { | ||
this.logger.debug({ | ||
at: "BundleDataClient#loadData", | ||
message: "Duplicate slow fill request detected", | ||
slowFillRequest, | ||
}); | ||
throw new Error("Duplicate slow fill request detected."); | ||
} | ||
return; | ||
|
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 no longer need these functions in across-protocol/relayer#2085