Skip to content
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

chore!: made ResourceCache consider resource owner #3697

Open
wants to merge 19 commits into
base: st/chore/[email protected]
Choose a base branch
from

Conversation

Torres-ssf
Copy link
Contributor

@Torres-ssf Torres-ssf commented Feb 11, 2025

Summary

This PR addresses 2 things:

1 - Resources IDs are now cached considering their owner.

2 - A check has been added to prevent Provider.getResourcesToSpend from being called with more cached resource IDs than the max_inputs value.

Breaking Changes

//before
provider.cache?.getActiveData()

provider.cache?.isCached(key: string)
//after
provider.cache?.getActiveData(wallet.address.toB256())

provider.cache?.isCached(key: string, wallet.address.toB256())

Checklist

  • All changes are covered by tests (or not applicable)
  • All changes are documented (or not applicable)
  • I reviewed the entire PR myself (preferably, on GH UI)
  • I described all Breaking Changes (or there's none)

@Torres-ssf Torres-ssf self-assigned this Feb 11, 2025
Copy link

vercel bot commented Feb 11, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
fuels-template ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 19, 2025 11:09am
ts-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 19, 2025 11:09am
ts-docs-api ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 19, 2025 11:09am

@Torres-ssf Torres-ssf changed the title chore: made ResourceCache consider resource owner chore!: made ResourceCache consider resource owner Feb 16, 2025
if (cached.utxos.length || cached.messages.length) {
const {
consensusParameters: {
txParameters: { maxInputs },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have we questions the client team about using the maxInputs as the configurable for the maximum number of excludedIds?

This could become an issue when attempting to consolidate UTXOs.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@arboleya arboleya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lintfix needed.

Copy link
Contributor

Coverage Report:

Lines Branches Functions Statements
77.11%(-0.04%) 70.75%(+0.06%) 75.19%(-0.11%) 77.11%(-0.04%)
Changed Files:
Ok File (✨=New File) Lines Branches Functions Statements
🔴 ✨ packages/abi-coder/src/utils/scriptData.ts 0%
(+0%)
0%
(+0%)
0%
(+0%)
0%
(+0%)
🔴 packages/account/src/account.ts 81.03%
(+0.45%)
72%
(+0.77%)
82.5%
(+0%)
80.79%
(+0.45%)
🔴 packages/account/src/connectors/fuel-connector.ts 30%
(+1.43%)
100%
(+0%)
4.54%
(-0.22%)
30%
(+1.43%)
🔴 packages/account/src/connectors/fuel.ts 96.75%
(+0.02%)
90.66%
(+0%)
93.33%
(+0%)
96.87%
(+0.02%)
🔴 packages/account/src/providers/provider.ts 67.91%
(+0.96%)
60.56%
(+3.49%)
68.62%
(+0.58%)
67.74%
(+1.01%)
🔴 packages/account/src/providers/generated/operations.ts 92.54%
(-1%)
100%
(+0%)
77.77%
(-2.62%)
93.1%
(-0.94%)
🔴 packages/account/src/providers/transaction-request/transaction-request.ts 87.5%
(-1.07%)
75.3%
(-2.78%)
84%
(+0%)
87.75%
(-1.06%)
🔴 packages/account/src/providers/utils/handle-gql-error-message.ts 85.71%
(-4.29%)
76.92%
(-6.41%)
80%
(+0%)
82.6%
(-3.76%)
🔴 packages/errors/src/test-utils/expect-to-throw-fuel-error.ts 91.66%
(-0.34%)
88.88%
(+0%)
100%
(+0%)
91.66%
(-0.34%)
🔴 packages/transactions/src/coders/policy.ts 97.91%
(+0.24%)
95%
(+0.89%)
100%
(+0%)
98%
(+0.23%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore Issue is a chore
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make ResourceCache Owner-Aware
3 participants