This repository has been archived by the owner on Aug 18, 2020. It is now read-only.
[RCD-46] fix Prefiltering not ignoring txIds from Inputs #3855
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.
Description
Prefiltering seems to totally ignore txIds from Inputs while creating blockMeta. On the other hand it uses TxIns to see which utxos are used. This means that if an account has only inputs in a tx, the tx will apear as Failed. This can happens when it creates a tx and uses a utxo entirely (no changes). QA testing found this bug while trying to empty the wallet, which is a special case of the above.
Before the fix, we can see the Prefiltered Block of a failed Transaction which empties the wallet:
PrefilteredBlock. There is no _blockMetaSlotId.
{
pfbInputs = fromList [TxInUtxo (AbstractHash a3cf538a8390fda0cf5477bbdf49da68415a44f45db14ad9b8c2dd9ea62219d6) 0],
pfbOutputs = fromList [],
pfbAddrs = [],
pfbMeta = LocalBlockMeta {localBlockMeta = BlockMeta {_blockMetaSlotId = InDb {_fromDb = fromList []}, _blockMetaAddressMeta = fromList []}},
pfbContext = BlockContext {_bcSlotId = InDb {_fromDb = SlotId {siEpoch = EpochIndex {getEpochIndex = 82}, siSlot = UnsafeLocalSlotIndex {getSlotIndex = 16153}}}, _bcHash = InDb {_fromDb = AbstractHash be62ec0264cc0346ca2a70e789f3aa016854ba04e9d46adc72a25eba4a64700d}, _bcPrevMain = Just (InDb {_fromDb = AbstractHash 2673c69268b00dc8c969e9bf81348c7f4def139ad199ed69f95ead38872203c2})}}),(HdAccountId {_hdAccountIdParent = HdRootId {getHdRootId = InDb {_fromDb = Address {addrRoot = AbstractHash bf3db4cc8c9dd5533d35cc52e16cca39e1845484a548c03fa8beba74, addrAttributes = Attributes { data: AddrAttributes {aaPkDerivationPath = Nothing, aaStakeDistribution = BootstrapEraDistr, aaNetworkMagic = NetworkMainOrStage} }, addrType = ATPubKey}}}, _hdAccountIdIx = HdAccountIx {getHdAccountIx = 2147483648}},
After the fix we have the txId (search pfbMeta and _blockMetaSlotId):
PrefilteredBlock {
pfbInputs = fromList [TxInUtxo (AbstractHash 525a73a963652b3e542bc499efe942f419af8664e602471ddd36b81e7ff49754) 0],
pfbOutputs = fromList [], pfbAddrs = [],
pfbMeta = LocalBlockMeta {localBlockMeta = BlockMeta {_blockMetaSlotId = InDb {_fromDb = fromList [(AbstractHash cd6c848cff95214492822ba94da174f07a264305d9a1223bf6e11395bce0ff13,SlotId {siEpoch = EpochIndex {getEpochIndex = 82}, siSlot = UnsafeLocalSlotIndex {getSlotIndex = 16691}})]}, _blockMetaAddressMeta = fromList []}},
pfbContext = BlockContext {_bcSlotId = InDb {_fromDb = SlotId {siEpoch = EpochIndex {getEpochIndex = 82}, siSlot = UnsafeLocalSlotIndex {getSlotIndex = 16691}}}, _bcHash = InDb {_fromDb = AbstractHash 97b5fae902dc4b4b070c1308007e19d2d2107f0fe9425f0bdc06b9bd870e712a}, _bcPrevMain = Just (InDb {_fromDb = AbstractHash 2a487cce352083ff755b737cb8c8d52cb0f29a4af6070c95207ee30a65bd9b2e})}}),(HdAccountId {_hdAccountIdParent = HdRootId {getHdRootId = InDb {_fromDb = Address {addrRoot = AbstractHash bf3db4cc8c9dd5533d35cc52e16cca39e1845484a548c03fa8beba74, addrAttributes = Attributes { data: AddrAttributes {aaPkDerivationPath = Nothing, aaStakeDistribution = BootstrapEraDistr, aaNetworkMagic = NetworkMainOrStage} }, addrType = ATPubKey}}}, _hdAccountIdIx = HdAccountIx {getHdAccountIx = 2147483648}},
As a final test, I have a wallet with a failed txs as a result of the previous bug. I will try to restore:
Restored succesfully:
Linked issue
https://iohk.myjetbrains.com/youtrack/issue/RCD-46
Type of change
QA Steps
try to empty a wallet by following the fee estimation and no ada is left to the wallet.