improve: Use inventory equivalence remapping in BundleDataApproxClient, InventoryClient, TokenClient#3109
Conversation
…inance deposit matching, and floatToBN fix - TokenUtils: getInventoryEquivalentL1TokenAddress, getInventoryBalanceContributorTokens, isL2OnlyEquivalentToken - RunningBalanceUtils: getLatestRunningBalances extracted for shared use - BinanceUtils: getOutstandingBinanceDeposits for cross-L2 deposit matching, export BinanceDeposit type - BNUtils: Fix floatToBN MAX_SAFE_INTEGER overflow via string manipulation Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…t, InventoryClient, TokenClient - BundleDataApproxClient: returns values in L1 token decimals, groups deposits/refunds across inventory-equivalent L2 tokens, restores requireExecution param, fixes refund decimal conversion - InventoryClient: uses getInventoryEquivalentL1TokenAddress, getInventoryBalanceContributorTokens, getLatestRunningBalances; adds protected getTokenInfo for test mocking - TokenClient: uses getInventoryBalanceContributorTokens for L2 token discovery - Test updates: alias config for USDC, L1-decimal refunds, MockInventoryClient getTokenInfo override Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
| correspondingProposedRootBundle, | ||
| chainId, | ||
| this.chainIdList | ||
| this.protocolChainIdIndices |
There was a problem hiding this comment.
Note: this is a very important bug fix! Previously the chainIdList is not equal to the canonical chain ID indices list used on-chain by the proposer so the last validated end blocks are totally wrong for most chains
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 67fccda325
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| for (const chainId of this.chainIdList) { | ||
| const repaymentToken = this.getRemoteTokenForL1Token(l1Token, chainId); | ||
| if (!repaymentToken) { | ||
| continue; | ||
| } | ||
| const { decimals: l2TokenDecimals } = this.hubPoolClient.getTokenInfoForAddress(repaymentToken, chainId); | ||
| const refundAmount = this.getUpcomingRefunds(chainId, l1Token, this.relayer); | ||
| const convertedRefundAmount = sdkUtils.ConvertDecimals(l2TokenDecimals, l1TokenDecimals)(refundAmount); | ||
| totalRefundsPerChain[chainId] = convertedRefundAmount; | ||
| totalRefundsPerChain[chainId] = refundAmount; |
There was a problem hiding this comment.
Invalidate pre-upgrade cache before using L1-unit refunds
getCumulativeBalanceWithApproximateUpcomingRefunds now treats getUpcomingRefunds as already normalized to L1 decimals, but cache import remains schema-compatible with older persisted bundleDataState. In src/relayer/index.ts, cached inventory is imported on startup and initialization is skipped when present, so pre-change cache entries (stored in repayment-token decimals) are interpreted with the new units. On tokens where repayment-token decimals differ from L1 decimals, this can mis-scale balances by large factors and drive incorrect refund-chain / inventory decisions until cache is rebuilt. Please add cache versioning/invalidation or migrate imported values.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
@codex can you review the impact to BSC inventory decisions? Refund-chain selection mistakes don't have much impact in the short term.
|
@codex please review all unresolved threads |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1fecd57fd4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: aa34ea2408
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7dc0dc0bff
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Summary
Updates the core inventory clients to use the new utility functions from #3108 (split from #3073).
requireExecutionparam for deposit/refund lookback decoupling, fixes refund decimal conversion from origin token decimalsgetInventoryEquivalentL1TokenAddress,getInventoryBalanceContributorTokens,getLatestRunningBalances; addsprotected getTokenInfofor test mockinggetInventoryBalanceContributorTokensfor L2 token discoveryMockInventoryClient.getTokenInfooverrideUpstream dependencies
npai/utils-token-binance-bn) — must merge firstDownstream PRs
Test plan
🤖 Generated with Claude Code