fix(fortuna): correctly propagate contract reverts in simulation #2854
  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.
  
    
  
    
Summary
Fix a bug preventing contract reverts during simulation from being captured correctly.
Rationale
client.fill_transactiondoes a couple things including estimating gas usage and fetching the current gas price. If the contract reverts during the estimating gas phase via simulation, the code expects the error to be propagated as aGasUsageEstimateError(ContractError::Revert(bytes)).However, the error handler for theclient.fill_transactioncall wraps the error in aGasPriceEstimateError, which prevents the calling code from handling the contract revert properly. We can see this happening in the logs, example:This causes the wrong
reasonto get stored in the DB. Instead of storingReverted: <bytes>, it storesUnable to estimate gas price, and it prevents retry functionality from working as intended.This PR wraps the revert data in a
GasUsageEstimateErroras expected if there is revert data in the error. Else, we assume it's a gas price polling error.How has this been tested?