Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

core: fix overflow and panic in priority fee estimation #839

Merged
merged 1 commit into from
Jan 29, 2022

Conversation

juniorbeef
Copy link
Contributor

The U256 priority fees were being coerced into u32, which was not big
enough for actual values. The overflow was happening but not checked.
This led to a possible divide-by-zero panic in this code as well.

This change does the math as I256 -- overkill, but it works.

Motivation

This is a simple bug fix for the issue described above, which could lead in some
cases to somewhat incorrect gas estimation and the occasional panic.

Solution

The fix just uses I256 math instead.

PR Checklist

  • [ x] Added Tests
  • [ x] Added Documentation
  • [ x] Updated the changelog

The U256 priority fees were being coerced into u32, which was not big
enough for actual values. The overflow was happening but not checked.
This led to a possible divide-by-zero panic in this code as well.

This change does the math as I256 -- overkill, but it works.
Copy link
Owner

@gakonst gakonst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch

@gakonst gakonst merged commit 97744b8 into gakonst:master Jan 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants