Skip to content

Conversation

@fmorency
Copy link
Contributor

@fmorency fmorency commented Dec 7, 2023

The PR adds support for a flexible pricing scheme based on a fixed gas price provided by the validators. The total fees are calculated following

fees = gasPrice * gasConsumption

where gasPrice is a fixed price provided by the validators and gasConsumption is the total gas consumed by the transaction. Since the gasConsumption component is unknown before executing the transaction, the following strategy is used to determine the fees

  1. Retrieve an estimated gasConsumption' value using cosmjs client simulate() function.
  2. Calculate the final fees using cosmjs calculateFee(GAS_LIMIT, gasPrice) function, where GAS_LIMIT is gasConsumption' * LIMIT_MULTIPLIER, where LIMIT_MULTIPLIER is a pre-defined adjustment factor to allow some wiggle room as it is not rare that the gas estimation gasConsumption' is under-estimated.

The resulting behavior is that it will consume more tokens the bigger the deployment unless the gasPrice is set to 0.

E.g., deploying a 4.8MB compressed website resulting in a 23token fee, while deploying a 600kB compressed website results in a 1token fee.

The gas price and limit multiplier can be configured in the .env* files, e.g.,

...
NEXT_PUBLIC_GHOSTCLOUD_GAS_PRICE=0.000000025
NEXT_PUBLIC_GHOSTCLOUD_GAS_LIMIT_MULTIPLIER=1.5
...

Relates #10
Relates liftedinit/ghostcloud#33

@fmorency fmorency self-assigned this Dec 7, 2023
@fmorency fmorency requested a review from jgryffindor December 8, 2023 14:04
@fmorency fmorency marked this pull request as ready for review December 8, 2023 14:04
@fmorency fmorency merged commit 259c93e into liftedinit:main Dec 11, 2023
@fmorency fmorency deleted the fees branch December 11, 2023 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant