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

Use transaction-payment's congestion modifier for Ethereum base-fee #1765

Merged
merged 82 commits into from
Jan 17, 2023
Merged
Changes from 1 commit
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
a0fc51b
Convert transaction-payments congestion modifier to replace Ethereum'…
notlesh Aug 19, 2022
52bf3f8
Remove outdated comment
notlesh Aug 19, 2022
a182d56
fix precision bug
nbaztec Sep 2, 2022
2bdfb9e
import
nbaztec Sep 2, 2022
b3e84c4
use saturating mul, improve doc
nbaztec Sep 5, 2022
3af5c6c
update fee parameters, add tests
nbaztec Sep 9, 2022
94e6e0e
make tests similar
nbaztec Sep 9, 2022
a83778d
add tests to all runtimes
nbaztec Sep 9, 2022
cac3a2e
fix tests
nbaztec Sep 9, 2022
167d566
Merge branch 'master' into notlesh-use-transaction-payment-for-base-fee
notlesh Oct 6, 2022
4b58131
Add transaction-payment GenesisConfig to initialize its Multiplier
notlesh Oct 6, 2022
66a1d9b
Merge branch 'master' into notlesh-use-transaction-payment-for-base-fee
notlesh Oct 10, 2022
86e6d41
Fix some moonbase tests
notlesh Oct 10, 2022
e55c392
Rename FixedGasPrice -> TransactionPaymentAsGasPrice
notlesh Oct 10, 2022
ccce143
fmt
notlesh Oct 10, 2022
751bede
More ts test fixes
notlesh Oct 10, 2022
55058d5
Merge branch 'master' into notlesh-use-transaction-payment-for-base-fee
Oct 10, 2022
25fdd29
Fixes staking locks
Oct 11, 2022
928a03e
Merge branch 'master' into notlesh-use-transaction-payment-for-base-fee
Oct 11, 2022
4675940
Fix existential balance tests
notlesh Oct 11, 2022
6382888
Fix length fee tests
notlesh Oct 11, 2022
c29b28e
Merge branch 'notlesh-use-transaction-payment-for-base-fee' of github…
Oct 11, 2022
da46a52
Query base_fee in createTransaction when needed
notlesh Oct 11, 2022
5d403fb
Fixes gasPrice for existential test
Oct 11, 2022
3240bcd
Merge branch 'notlesh-use-transaction-payment-for-base-fee' of github…
Oct 11, 2022
dd71c93
Fix deposit/fee check for multiple deposit
Oct 11, 2022
efa30ac
Merge branch 'master' into notlesh-use-transaction-payment-for-base-fee
notlesh Oct 27, 2022
e97ed70
Fix merge issue
notlesh Oct 27, 2022
4648b30
Use legacy txns for some tests that expect full gas_price to be charged
notlesh Nov 2, 2022
90a7029
Bump gas price for tests
notlesh Nov 2, 2022
8fdc4b1
Update tests to reflect createTransfer default
notlesh Nov 2, 2022
6a8f12c
Use constant for DEFAULT_TXN_MAX_BASE_FEE
notlesh Nov 3, 2022
840f0f3
Reflect txn values to reflect base_fee change
notlesh Nov 3, 2022
78b3dfb
Prefer constant over literal value
notlesh Nov 3, 2022
3867c06
Overhaul fee calculations in verifyBlockFees
notlesh Nov 4, 2022
9b45a6a
Bound effectiveTipPerGas to 0
notlesh Nov 7, 2022
0b3b938
Fix substrate-based fees
notlesh Nov 7, 2022
6291c7d
Overestimate delegation count weight hint
notlesh Nov 9, 2022
50c275d
Use legacy txns and expect full gas_price to be paid as fee
notlesh Nov 9, 2022
ab6a537
Use constant for gas limit value
notlesh Nov 9, 2022
43d9c97
Start test case for max possible fee conditions
notlesh Nov 9, 2022
029f83e
Clean up
notlesh Nov 9, 2022
a5eb9d3
Add runtime-upgrade test
notlesh Nov 9, 2022
62c355a
prettier
notlesh Nov 9, 2022
a6b186e
First look at max possible fee
notlesh Nov 9, 2022
15271c1
fix auto-compound delegation tx order flakiness
nbaztec Nov 10, 2022
0e6a7f4
prettier
notlesh Nov 10, 2022
05313b3
Remove cargo override (oops)
notlesh Nov 10, 2022
174aad7
Hack to fix race condition
notlesh Nov 10, 2022
4cfd346
prettier
notlesh Nov 10, 2022
240efa8
Use beforeEach for setting max multiplier
notlesh Nov 10, 2022
a80e059
Test multiplier against Fibonacci contract
notlesh Nov 14, 2022
4d4f14d
prettier
notlesh Nov 14, 2022
9456ed9
Merge branch 'master' into notlesh-use-transaction-payment-for-base-fee
notlesh Nov 28, 2022
bafec82
prettier
notlesh Nov 28, 2022
284ece4
fmt
notlesh Nov 28, 2022
6d3cd9f
Various minor fixes
notlesh Nov 28, 2022
c95da99
Add some fee multiplier scenarios
notlesh Dec 12, 2022
683feff
Merge branch 'master' into notlesh-use-transaction-payment-for-base-fee
notlesh Dec 13, 2022
ea1c5b3
Don't use EXTRINSIC_BASE_WEIGHT in gas calc
notlesh Dec 13, 2022
a847654
Don't expect genesis value at each beforeAll
notlesh Dec 13, 2022
98d7374
Bump expectation of CREATE cost
notlesh Dec 13, 2022
9da3ce9
Slightly change length fee assumptions
notlesh Dec 13, 2022
3d0ecb6
Use higher gas price
notlesh Dec 13, 2022
0a9f1be
Remove base_fee test
notlesh Dec 13, 2022
370c19f
fmt
notlesh Dec 13, 2022
1c2c5ec
toml sort
notlesh Dec 13, 2022
5bb3b49
Resolve compiler warnings
notlesh Dec 13, 2022
5f2511d
More compiler warning fixes
notlesh Dec 13, 2022
fc0ab3d
Fix receipt/status test
tgmichel Dec 14, 2022
86978cf
Remove irrelevant tests
notlesh Dec 14, 2022
84b9f5d
Use maxDelegationCount for weight hint
notlesh Dec 14, 2022
0c3866e
Remove comment
notlesh Jan 6, 2023
d56ea3f
Remove ignored tests
notlesh Jan 6, 2023
14f9b7a
Move fee tests to integration_tests.rs
notlesh Jan 8, 2023
5988fb2
Merge branch 'master' into notlesh-use-transaction-payment-for-base-fee
notlesh Jan 8, 2023
0890e92
Re-remove ignored test
notlesh Jan 8, 2023
160f82f
Move moonbeam runtime fee tests to integration_tests
notlesh Jan 8, 2023
23c9942
Move moonriver runtime fee tests to integration_tests
notlesh Jan 8, 2023
d84a467
fmt
notlesh Jan 8, 2023
16fa4e8
Use base fee constant for gas price
notlesh Jan 8, 2023
dd5b4cf
Revert test name change...
notlesh Jan 17, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 32 additions & 5 deletions runtime/moonbase/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,13 +411,18 @@ impl FeeCalculator for FixedGasPrice {
// scaled by the multiplier, which means its multiplier will be overstated when
// applied to an ethereum transaction
// note: transaction-payment uses both a congestion modifier (next_fee_multiplier, which is
// updated once per block in on_initialize) and a 'WeightToFee' implementation. Our
// updated once per block in on_finalize) and a 'WeightToFee' implementation. Our
// runtime implements this as a 'ConstantModifier', so we can get away with a simple
// multiplication here.
let total_weight_multiplier =
TransactionPayment::next_fee_multiplier().saturating_mul_int(currency::WEIGHT_FEE);
let gas_price = total_weight_multiplier * WEIGHT_PER_GAS as u128;
(gas_price.into(), 0u64.into())
// It is imperative that `saturating_mul_int` be performed as late as possible in the
// expression since it involves fixed point arithmetic with division, and will lead to
notlesh marked this conversation as resolved.
Show resolved Hide resolved
// precision loss if performed too early. This can lead to min_gas_price being same across
// blocks even if the multiplier changes. There will be still some precision loss when the
// final `gas_price` (used_gas * min_gas_price) will be computed in frontier, but that's
// currently unavoidable.
let min_gas_price = TransactionPayment::next_fee_multiplier()
.saturating_mul_int(currency::WEIGHT_FEE * WEIGHT_PER_GAS as u128);
notlesh marked this conversation as resolved.
Show resolved Hide resolved
(min_gas_price.into(), 0u64.into())
}
}

Expand Down Expand Up @@ -1587,4 +1592,26 @@ mod tests {
);
}
}

#[test]
fn test_min_gas_price_has_no_precision_loss_from_saturating_mul_int() {
let t = frame_system::GenesisConfig::default()
.build_storage::<Runtime>()
.expect("Frame system builds valid default genesis config");
let mut ext = sp_io::TestExternalities::new(t);
ext.execute_with(|| {
let multiplier_1 = sp_runtime::FixedU128::from_float(0.999593900000000000);
let multiplier_2 = sp_runtime::FixedU128::from_float(0.999593200000000000);

<NextFeeMultiplier<Runtime>>::set(multiplier_1);
let a = FixedGasPrice::min_gas_price();
<NextFeeMultiplier<Runtime>>::set(multiplier_2);
let b = FixedGasPrice::min_gas_price();

assert_ne!(
a, b,
"both gas prices were equal, unexpected precision loss incurred"
);
});
}
}