Skip to content

Configurable Gas Price#6

Open
nkuba wants to merge 1 commit intodeploymentfrom
configure-gas-price
Open

Configurable Gas Price#6
nkuba wants to merge 1 commit intodeploymentfrom
configure-gas-price

Conversation

@nkuba
Copy link
Copy Markdown
Member

@nkuba nkuba commented Feb 16, 2021

We let DEFAULT_GAS_PRICE used for transaction submission and MAX_GAS_PRICE used as a limit for gas price bumps to be configurable instead of hardcoding them.

The default values will be set the same as previously hardcoded:
DEFAULT_GAS_PRICE = 100 Gwei
MAX_GAS_PRICE = 600 Gwei

Having it configurable is better from a multi-environment perspective, as it doesn't make sense to start with 100 Gwei on Ropsten.

It also gives a possibility to easily tweak settings for the mainnet without the need to rebuild the code.

The following properties can be used to configure it: DEFAULT_GAS_PRICE_GWEI and MAX_GAS_PRICE_GWEI. Note that configured values are expected to be provided in Gwei (not wei!).

We let DEFAULT_GAS_PRICE used for transaction submission and
MAX_GAS_PRICE used as a limit for gas price bumps to be configurable
instead of hardcoding them.

The default values will be set the same as previously hardcoded:
DEFAULT_GAS_PRICE = 100 Gwei
MAX_GAS_PRICE = 600 Gwei

Having it configurable is better from multi-environment perspective, as
it doesn't make sense to start with 100 Gwei on Ropsten.

It also gives possibility to easily tweak settings for mainnet without
the need to rebuild the code.

Following properties can be used to configure it:
DEFAULT_GAS_PRICE_GWEI and MAX_GAS_PRICE_GWEI. Note that configured
values are expected to be provided in Gwei (not wei!).
def _compute_tx_gas_price(tx_nonce, tx_ticks):
'''Compute the proper gas price, adjusting for other pending txes and how
long this tx has been pending, taking the max gas price into account.'''
defaultGasPrice = int(config.get()['DEFAULT_GAS_PRICE_GWEI']) * GWEI
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Minor remark:
Local variables seem to follow underscore notation, so perhaps "default_gas_price"?

async def init() -> None:
'''Set up a connection to the interwebs'''
global CONNECTION
global MAX_GAS_PRICE
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I've noticed that configurable variables are generally read from config wherever they are needed and not stored globally in Relay Maintainer, e.g:
URL = config.get()['BCOIN_URL']

Perhaps we could limit the number of global variables by doing the same with MAX_GAS_PRICE?
Just a suggestion.

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.

2 participants