Skip to content

Commit

Permalink
Merge branch 'master' into feat/ts-monorepo
Browse files Browse the repository at this point in the history
  • Loading branch information
timbrinded authored Dec 10, 2024
2 parents 8aac3db + 2ae249a commit b48c999
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 36 deletions.
25 changes: 20 additions & 5 deletions test/helpers/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,16 @@ export const RUNTIME_CONSTANTS = {
GENESIS_FEE_MULTIPLIER: 8_000_000_000_000_000_000n,
MIN_FEE_MULTIPLIER: 100_000_000_000_000_000n,
MAX_FEE_MULTIPLIER: 100_000_000_000_000_000_000_000n,
WEIGHT_FEE: (50n * KILOWEI * MOONBASE_CONSTANTS.SUPPLY_FACTOR) / 4n,
WEIGHT_FEE: new RuntimeConstant({
3400: (50n * KILOWEI * MOONBASE_CONSTANTS.SUPPLY_FACTOR) / 4n,
0: 50n * KILOWEI * MOONBASE_CONSTANTS.SUPPLY_FACTOR,
}),

GENESIS_BASE_FEE: new RuntimeConstant({ 3400: 2_500_000_000n, 0: 10_000_000_000n }),
MIN_BASE_FEE: new RuntimeConstant({ 3400: 312_500_000n, 0: 1_250_000_000n }),
MAX_BASE_FEE: new RuntimeConstant({ 3400: 31_250_000_000_000n, 0: 125_000_000_000_000n }),
// (MinimumMultiplier = 0.1) * WEIGHT_FEE * WEIGHT_PER_GAS
MIN_BASE_FEE: new RuntimeConstant({ 3400: 31_250_000n, 0: 125_000_000n }),
// (MaximumMultiplier = 100_000) * WEIGHT_FEE * WEIGHT_PER_GAS
MAX_BASE_FEE: new RuntimeConstant({ 3400: 3_125_000_000_000n, 0: 12_500_000_000_000n }),

TARGET_FILL_PERMILL: new RuntimeConstant({ 3000: 350_000n, 2801: 500_000n, 0: 250_000n }),
// Deadline for block production in milliseconds
Expand All @@ -107,10 +112,15 @@ export const RUNTIME_CONSTANTS = {
GENESIS_FEE_MULTIPLIER: 10_000_000_000_000_000_000n,
MIN_FEE_MULTIPLIER: 1_000_000_000_000_000_000n,
MAX_FEE_MULTIPLIER: 100_000_000_000_000_000_000_000n,
WEIGHT_FEE: (50n * KILOWEI * MOONRIVER_CONSTANTS.SUPPLY_FACTOR) / 4n,
WEIGHT_FEE: new RuntimeConstant({
3400: (50n * KILOWEI * MOONRIVER_CONSTANTS.SUPPLY_FACTOR) / 4n,
0: 50n * KILOWEI * MOONRIVER_CONSTANTS.SUPPLY_FACTOR,
}),

GENESIS_BASE_FEE: new RuntimeConstant({ 3400: 3_125_000_000n, 0: 12_500_000_000n }),
// (MinimumMultiplier = 1) * WEIGHT_FEE * WEIGHT_PER_GAS
MIN_BASE_FEE: new RuntimeConstant({ 3400: 312_500_000n, 0: 1_250_000_000n }),
// (MaximumMultiplier = 100_000) * WEIGHT_FEE * WEIGHT_PER_GAS
MAX_BASE_FEE: new RuntimeConstant({ 3400: 31_250_000_000_000n, 0: 125_000_000_000_000n }),

TARGET_FILL_PERMILL: new RuntimeConstant({ 3000: 350_000n, 2801: 500_000n, 0: 250_000n }),
Expand Down Expand Up @@ -139,10 +149,15 @@ export const RUNTIME_CONSTANTS = {
GENESIS_FEE_MULTIPLIER: 8_000_000_000_000_000_000n,
MIN_FEE_MULTIPLIER: 1_000_000_000_000_000_000n,
MAX_FEE_MULTIPLIER: 100_000_000_000_000_000_000_000n,
WEIGHT_FEE: (50n * KILOWEI * MOONBEAM_CONSTANTS.SUPPLY_FACTOR) / 4n,
WEIGHT_FEE: new RuntimeConstant({
3400: (50n * KILOWEI * MOONBEAM_CONSTANTS.SUPPLY_FACTOR) / 4n,
0: 50n * KILOWEI * MOONBEAM_CONSTANTS.SUPPLY_FACTOR,
}),

GENESIS_BASE_FEE: new RuntimeConstant({ 3400: 250_000_000_000n, 0: 1_000_000_000_000n }),
// (MinimumMultiplier = 1) * WEIGHT_FEE * WEIGHT_PER_GAS
MIN_BASE_FEE: new RuntimeConstant({ 3400: 31_250_000_000n, 0: 125_000_000_000n }),
// (MaximumMultiplier = 100_000) * WEIGHT_FEE * WEIGHT_PER_GAS
MAX_BASE_FEE: new RuntimeConstant({ 3400: 3_125_000_000_000_000n, 0: 12_500_000_000_000_000n }),

TARGET_FILL_PERMILL: new RuntimeConstant({ 3000: 350_000n, 2801: 500_000n, 0: 250_000n }),
Expand Down
35 changes: 4 additions & 31 deletions test/suites/smoke/test-dynamic-fees.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import "@moonbeam-network/api-augment/moonbase";
import { beforeAll, describeSuite, expect } from "@moonwall/cli";
import { WEIGHT_PER_GAS, getBlockArray, WEIGHT_FEE } from "@moonwall/util";
import { WEIGHT_PER_GAS, getBlockArray } from "@moonwall/util";
import { ApiPromise } from "@polkadot/api";
import { GenericExtrinsic } from "@polkadot/types";
import type { u128, u32 } from "@polkadot/types-codec";
Expand Down Expand Up @@ -123,25 +123,6 @@ describeSuite({
const specName = version.specName;
runtime = specName.toUpperCase() as any;

if (
specVersion.toNumber() < 2200 &&
(specName.toString() == "moonbase" || specName.toString() == "moonriver")
) {
log(
`Runtime ${specName.toString()} version ` +
`${specVersion.toString()} is less than 2200, skipping test suite.`
);
skipAll = true;
}

if (specVersion.toNumber() < 2300 && specName.toString() == "moonbeam") {
log(
`Runtime ${specName.toString()} version ` +
`${specVersion.toString()} is less than 2300, skipping test suite.`
);
skipAll = true;
}

targetFillPermill = RUNTIME_CONSTANTS[runtime].TARGET_FILL_PERMILL.get(
specVersion.toNumber()
);
Expand Down Expand Up @@ -323,22 +304,14 @@ describeSuite({
log("Skipping test suite due to runtime version");
return;
}
const supplyFactor = ConstantStore(context).SUPPLY_FACTOR;
const weightFee = ConstantStore(context).WEIGHT_FEE;
const weightFee = ConstantStore(context).WEIGHT_FEE.get(specVersion.toNumber());

const failures = blockData
.map(({ blockNum, nextFeeMultiplier, baseFeePerGasInGwei }) => {
const baseFeePerGasInWei = ethers.parseUnits(baseFeePerGasInGwei, "gwei");

let expectedBaseFeePerGasInWei =
(nextFeeMultiplier.toBigInt() * WEIGHT_FEE * WEIGHT_PER_GAS * supplyFactor) /
ethers.parseEther("1");
// The min_gas_price was divided by 4 on runtime 3400
if (specVersion.toNumber() > 3300) {
expectedBaseFeePerGasInWei =
(nextFeeMultiplier.toBigInt() * weightFee * WEIGHT_PER_GAS) /
ethers.parseEther("1");
}
const expectedBaseFeePerGasInWei =
(nextFeeMultiplier.toBigInt() * weightFee * WEIGHT_PER_GAS) / ethers.parseEther("1");

const valid = baseFeePerGasInWei == expectedBaseFeePerGasInWei;
return { blockNum, baseFeePerGasInGwei, valid, expectedBaseFeePerGasInWei };
Expand Down

0 comments on commit b48c999

Please sign in to comment.