-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
refactor: rename addMissingVariables
to estimateTxDependencies
, and add docs for tx dep estimation
#924
Conversation
addMissingVariables
to estimateTxDependencies
, and add docs for tx dep estimationaddMissingVariables
to estimateTxDependencies
, and add docs for tx dep estimation
However, the SDK always automatically estimates these dependencies and double-checks if everything is in order whenever you invoke a contract function or attempt to send a transaction. | ||
|
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.
@digorithm I believe that this behaviour here in the TS SDK is slightly different from the Rust SDK. The Rust SDK doesn't seem to automatically call estimate_tx_dependencies
on each function invocation, while the TS SDK does that every single time automatically.
I feel like this would make the estimateTxDependencies
function here in the TS SDK more of an internal helper since SDK users will never have to call it manually.
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.
Yeah. I'd suggest that, in the near future, we should move to manually calling estimateTxDependencies
; the additional dry-run calls happening without the user's consent could be an undesired behavior. Or it could be an optional value we set at the call time. We can discuss that later.
Coverage report❌ An unexpected error occurred. For more details, check console
Test suite run failedFailed tests: 1/822. Failed suites: 1/126.
Report generated by 🧪jest coverage report action from 67653fe |
apps/docs/src/guide/contracts/transaction-dependency-estimation.md
Outdated
Show resolved
Hide resolved
* | ||
* If there are missing output contract IDs, those are fetched and added to the transaction. | ||
* | ||
* TODO: Add support for missing output messages |
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.
Will file a follow-up issue for this.
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.
…ts' into dp/estimate-tx-deps
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.
Nice job @Dhaiwat10 👍.
But I have one question though
* | ||
* If there are missing output contract IDs, those are fetched and added to the transaction. | ||
* |
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.
Is this functionality working? When I was rewriting the Inter-contract Calls
doc page I was always running into an error before explicitly calling the addContracts
function in the contract function chain call.
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.
@Torres-ssf there seems to be code in place that would take care of that functionality, but we don't have any tests in place for this.
fuels-ts/packages/providers/src/provider.ts
Lines 374 to 376 in dadc576
missingOutputContractIds.forEach(({ contractId }) => | |
transactionRequest.addContract(Address.fromString(contractId)) | |
); |
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.
@Dhaiwat10 I've just tried to validate that and it seems this is not working or at least for not all cases.
It seems this functionality relies on the following logic that is defined here.
receipt.type === ReceiptType.Panic &&
receipt.contractId !== '0x0000000000000000000000000000000000000000000000000000000000000000';
It seems the getReceiptsWithMissingData function loops through all receipts returned from a dryRun
call and tries to verify if the receipt type
and contractId
properties indicate that a contract ID is missing in order to a successful script call.
However, in my tests, when I try to execute a contract call that does an inter-contract call, the receipt does not come with a contractId
different than the one specified in the condition, thus, not being a valid case for missing contract ID.
{
type: 3,
id: '0x48ca0552db61b135a3731928ce77910c3d3630a554ef313949d6af14930177ba',
reason: <BN: 0x172d4d2450000000>,
pc: <BN: 0x481c>,
is: <BN: 0x4338>,
contractId: '0x0000000000000000000000000000000000000000000000000000000000000000'
},
I couldn't find out the source of the problem, maybe it could be something in the dry-run call?
Do you have any insight on that?
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.
@Torres-ssf thanks for looking into this with so much detail. Unfortunately, I don't have a lot of insight on the dry-run implementation, but this is def something we need to fix. I can file a follow-up issue for this. Does that sound good?
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.
@Dhaiwat10 Yes that sounds great
Just a side note — there are dozens of unrelated commits here. I'd guess this PR wasn't based on the |
Closing this in favor of #954. Tried rebasing this PR against |
Summary
As discussed here, this PR renames the
addMissingVariables
helper toestimateTxDependencies
for better consistency with the Rust SDK, and adds a docs page for transaction dependency estimation.I have based this PR off of @Torres-ssf's docs snippet branch since it contains the updated guides around contracts. This PR should automatically change base to
master
once his PR is merged.Closes #701