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 gas price factor. #343

Merged
merged 2 commits into from
Jun 10, 2022
Merged

Add gas price factor. #343

merged 2 commits into from
Jun 10, 2022

Conversation

adlerjohn
Copy link
Contributor

@adlerjohn adlerjohn commented Jun 9, 2022

Fixes #342

Adds a new consensus constant, GAS_PRICE_FACTOR (suggested to be set to 1 billion), that allows gas price to be provided with a precision of 1/GAS_PRICE_FACTOR of the base asset's unit.

Gas used is rounded up to the nearest unit, and gas refunded in rounded down. Note gas and byte costs are accounted for separately. Therefore, the minimum non-zero used balance is 2 coins: one for gas and one for bytes.

E.g. if the base asset is ETH at 9 decimals, then its units are gwei. This change allows gas prices to be specified in wei. If a tx costs less than 1 gwei of gas price * gas limit / GAS_PRICE_FACTOR, then it rounds up to costing 1 gwei.

Some considerations around parameter choice: a script that uses 10M gas can have a gas price of ~100B before you have to start worrying about overflow. Assuming ETH as the base asset:

  1. With a factor of 1B, the maximum gas price is ~100 gwei. In the long run, this doesn't leave much room for a robust fee market.
  2. With a factor of 1M, the maximum gas price is ~10,000 gwei. Lots of breathing room.
  3. With a factor of 1,000, the gas price is 0.001 gwei. This might not be cheap enough. Transactions may still cost on the order of cents even at the lowest gas price.

I'm inclined towards a factor of 1M from the above, but would like to hear what @Voxelot @vlopes11 and @rakita think.

Implementation:

@adlerjohn adlerjohn added comp:FVM Component: FuelVM comp:VAL Component: Transaction Validity outside the Fuel VM labels Jun 9, 2022
@adlerjohn adlerjohn requested review from Voxelot, vlopes11 and rakita June 9, 2022 20:50
@adlerjohn adlerjohn self-assigned this Jun 9, 2022
@vlopes11
Copy link
Contributor

vlopes11 commented Jun 10, 2022

I think its a good call to use the same ratio as gwei since also the community is very familiar with that. Since this won't impact the gas calculation itself but only the assets manipulation, I see this as an improvement without potential problems/concerns.

Recommended steps to implement:

  • Implement the constant as consensus parameter in fuel-tx
  • Perform the conversion in transaction initialization/post-execution in fuel-vm

Copy link
Contributor

@vlopes11 vlopes11 left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:FVM Component: FuelVM comp:VAL Component: Transaction Validity outside the Fuel VM
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Allow sub-unit gas prices
3 participants