3

If the System.ExtrinsicFailed event was emitted within a given extrinsic, does it mean that all other events that were also emitted within it can be considered invalid and should not be taken into account?

Example link: In extrinsic balances.transfer, the events balances.Withdraw and balances.Deposit were triggered, which indicate a change in the balance of two addresses. The system.ExtrinsicFailed event was also called which indicates that extrinsic failed. Should balance changes in this case be taken into account or should they be ignored?

1 Answer 1

3

If the System.ExtrinsicFailed event was emitted within a given extrinsic, does it mean that all other events that were also emitted within it can be considered invalid and should not be taken into account?

All dispatchables are executed in storage transactions and when the dispatchable returns an error, the storage transaction is thrown away. Events are stored in the storage as well. This means when your dispatchable returns an error, also the events send by this dispatchable are thrown away.

Example link: In extrinsic balances.transfer, the events balances.Withdraw and balances.Deposit were triggered, which indicate a change in the balance of two addresses. The system.ExtrinsicFailed event was also called which indicates that extrinsic failed. Should balance changes in this case be taken into account or should they be ignored?

The balance events you are seeing there are coming from the transaction payment signed extension. These operations are done on purpose outside of the dispatch of the actual as they are ensuring that your chain is not open to dos attacks. The sender should pay for each extrinsic that is applied on chain, even if the outcome is an error.

1
  • > "All dispatchables are executed in storage transactions and when the dispatchable returns an error, the storage transaction is thrown away." ---> Is it the case for all dispatchables or only the one marked as transactionnal? Commented Dec 1, 2023 at 13:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.