Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

seal: Refactor ext_gas_price #6478

Merged
4 commits merged into from
Jun 24, 2020
Merged

seal: Refactor ext_gas_price #6478

4 commits merged into from
Jun 24, 2020

Conversation

athei
Copy link
Member

@athei athei commented Jun 23, 2020

Subset of: #6355

Overview

This PR changes the signature of ext_gas_price from

fn ext_gas_price() -> BalanceOf<T>

to

fn ext_gas_price(gas: Gas) -> BalanceOf<T>

In addition to that we remove the dependency of seal on pallet_transaction_payment by adding those two elements to the Trait:

/// The currency in which fees are paid and contract balances are held.
type Currency: Currency<Self::AccountId>;

/// Used to supply contracts with the current gas price. This is **not** used to
/// calculate the actual fee and is only for informational purposes.
type WeightPrice: Convert<Weight, BalanceOf<Self>>

Motivation

There is no longer something like gas. We merely keep the term around for historical reasons. Costs are measured in weight. Currently, we provide gas price as the costs for one weight. Calculating the costs for a single weight is subject to rounding errors because the costs for one weight can be below one. In addition to that a fixed point adjustment is applied to the fee. Both of that makes calculating the costs for one weight very brittle. Contracts should therefore pass in higher amounts of gas to get a useful result.

* Remove seals dependency on pallet_transaction_payment
* Add weight as an argument to ext_gas_price
@athei athei added A0-please_review Pull request needs code review. B3-apinoteworthy C1-low PR touches the given topic and has a low impact on builders. labels Jun 23, 2020
@athei athei requested review from pepyakin and kianenigma June 23, 2020 07:59
@athei athei requested a review from Robbepop as a code owner June 23, 2020 07:59
@parity-cla-bot
Copy link

It looks like @athei signed our Contributor License Agreement. 👍

Many thanks,

Parity Technologies CLA Bot

frame/contracts/src/exec.rs Show resolved Hide resolved
frame/contracts/src/lib.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@Robbepop Robbepop left a comment

Choose a reason for hiding this comment

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

LGTM on a high-level

Eager to implement on ink! side soon.

@athei athei added A8-mergeoncegreen and removed A0-please_review Pull request needs code review. A7-needspolkadotpr labels Jun 24, 2020
@pepyakin
Copy link
Contributor

bot merge

@ghost
Copy link

ghost commented Jun 24, 2020

Trying merge.

This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
C1-low PR touches the given topic and has a low impact on builders.
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

5 participants