Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Stops wallets and contracts from fetching UTxOs they already have.
Stacked on #849, which adds
CachedFetcher. Merge #849 first; this PR can then be retargeted tomain.Contents
mesh-transaction:utxoToTxIn(utxo)now also returns the UTxO's reference script size:[txHash, outputIndex, amount, address, scriptSize].txIn(...utxoToTxIn(utxo))gives the builder everything it needs, so it no longer fetches a UTxO the caller passed in full.Transaction:setNativeScriptInputand the reference-script branch ofredeemValuepass the script size.redeemValuealso passes the reference script's hash, derived fromscriptRefwhen the UTxO lacksscriptHash. Neither spend refetches its UTxOs any more.mesh-contract:txIncalls passed a full UTxO without its script size, so every script spend in every contract triggered afetchUTxOs. They now usetxIn(...utxoToTxIn(utxo)).MeshTxInitiatorwraps its fetcher inCachedFetcher.wrap. Looking up a UTxO withgetUtxoByTxHashand then spending it costs one request, shared with the builder and wallet using the same provider.content-ownershipthat the rewrite left unused.mesh-wallet:MeshWalletandAppWalletwrap their fetcher inCachedFetcher.wrap.getUtxos()followed bygetCollateral()used to fetch the same address twice; now it is one request. Address lookups are cached for 10 s.submitTxclears that short-lived cache, so UTxOs read after a submit are fetched fresh.Provider calls, before → after
Measured on
ScalusEmulatorbehind a call-recording proxy: unlockingMeshHelloWorldContract, fromgetUtxoByTxHashthrough submit (mesh-contract/test/provider-calls.test.ts):fetchUTxOsfetchAddressUTxOsThe before column is measured on #849. Measured from
main, there is also onefetchCostModelsper transaction, which #849 removes.Validation
mesh-contract: the newprovider-calls.test.tspasses. It is the package's first test and needs@meshsdk/scalus-emulatoras a devDependency, asmesh-transactionhas. The lockfile change is that one line.mesh-wallet: 34 tests pass, including the newfetcher-cache.test.ts.mesh-transaction: 160 tests pass.script-tx-fetcherandscript-tx-failfail to load under--experimental-vm-modulesonmaintoo. Both pass without the flag, as do thetest/transactionsuites.