Skip to content
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

Add min_fee before estimating predicates #1171

Open
hal3e opened this issue Oct 24, 2023 · 0 comments
Open

Add min_fee before estimating predicates #1171

hal3e opened this issue Oct 24, 2023 · 0 comments
Labels
tech-debt Improves code quality or safety

Comments

@hal3e
Copy link
Contributor

hal3e commented Oct 24, 2023

When estimating predicates we set the gas_price to 0 because we have no coins to cover for the min_fee. We should first estimate the min_fee add coins to cover it and then estimate Predicates and add new coins if necessary. Relevant code:

 fn estimate_predicates(
      &mut self,
      consensus_parameters: &ConsensusParameters,
      gas_costs: &GasCosts,
  ) -> Result<()> {
      let gas_price = *self.tx.gas_price();
      let gas_limit = *self.tx.gas_limit();
      *self.tx.gas_price_mut() = 0;
      *self.tx.gas_limit_mut() = consensus_parameters.max_gas_per_tx;

      self.tx
          .estimate_predicates(consensus_parameters, gas_costs)?;
      *self.tx.gas_price_mut() = gas_price;
      *self.tx.gas_limit_mut() = gas_limit;

      Ok(())
  }
@hal3e hal3e added the tech-debt Improves code quality or safety label Oct 24, 2023
@iqdecay iqdecay self-assigned this Oct 26, 2023
@iqdecay iqdecay removed their assignment Nov 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tech-debt Improves code quality or safety
Projects
None yet
Development

No branches or pull requests

2 participants