-
Notifications
You must be signed in to change notification settings - Fork 95
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
Return TxId
when error in checking of transactions
#897
base: master
Are you sure you want to change the base?
Conversation
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.
Copilot reviewed 5 out of 11 changed files in this pull request and generated no comments.
Files not reviewed (6)
- fuel-tx/src/transaction/types/blob.rs: Evaluated as low risk
- fuel-tx/src/transaction/types/create.rs: Evaluated as low risk
- fuel-tx/src/transaction/types/mint.rs: Evaluated as low risk
- fuel-tx/src/transaction/types/script.rs: Evaluated as low risk
- fuel-tx/src/transaction/types/upload.rs: Evaluated as low risk
- fuel-vm/src/checked_transaction.rs: Evaluated as low risk
Comments suppressed due to low confidence (3)
fuel-tx/src/transaction/types/upgrade.rs:16
- The error should return
(TxId, ValidityError)
instead of justValidityError
to match the new error handling pattern.
Err(ValidityError::TransactionUpgradeConsensusParametersChecksumMismatch)?;
fuel-vm/src/tests/upload.rs:280
- The error message should be updated to reflect the new return type, ensuring clarity and consistency.
.expect_err("Should fail to generate checked tx")
fuel-vm/src/tests/upload.rs:307
- The error message should be updated to reflect the new return type, ensuring clarity and consistency.
.expect_err("Should fail to generate checked tx")
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.
It would be nice to make this change non breaking. I tried to play with generics, but it still produces breaking code in some cases: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=5f70213c55d0cf6e17abf2cd3e5f17fe
Alternative solution will be to add one more function like into_checked_basic_with_metadata
and this one will return metadata in the case of error.
I improved your playground code to be more close to reality and I have something that is breaking only because you need to specify the error type. I don't know if we can still consider this breaking I think so but I would like to have your thoughts. Link : https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=d256580f356615cd7ff3979bcd2e3706 |
Yeah, it is why I'm saying it is not good solution because it is still breaking=D So because of that I'm more in favor of the |
Okey will do that but it will be |
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.
I just got an idea of how we can do it better. Instead of adding new methods, we can add a new type Immutable<Tx>
, where Immutable
only calculates the metadata but doesn't have any validation logic. Any Immutable
can be converted into checked without calculation of the metadata.
In this case, you can have an id before the validation, and for actual validation, you can leave for STF. In this case, splitting also will be faster
Okey but the problem is that creating metadata can throw error too so the signature to create a new I don't understand why it's faster because the computation of the I'll try to implement that in an other PR but I don't really understand how is it better. |
I tried to implement something but in any case you will need to compute the I tried a PR : #906 but it's not compiling because of the Checked that wants a |
When we try to turn a
Tx
in aChecked<Tx>
, errors can happens, but we always start by computing theTxId
and this can never fails. If something else, fails afterwards it's super useful to have theTxId
to link the error with the transaction associated.Currently, in the existing code calling
into_checked()
, if we have an error we are computing theTxId
ourself again to link it to theCheckError
which creates a double computation.Breaking change
The
TxId
is now returned with the error.Before :
Now :
Breaking change notes
I didn't placed this behind a feature flag because I think it's always valuable, however if we want to avoid breaking for now and have this information under a special feature I'm ok with this. Inputs from reviewers would be super valuable on that.
Checklist
Before requesting review
After merging, notify other teams