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

fix: support for calculating fees for statemint, and statemine and their test nets. #613

Merged
merged 3 commits into from
Jul 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Binary file modified calc/pkg/calc_bg.wasm
Binary file not shown.
1 change: 1 addition & 0 deletions calc/pkg/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"files": [
"calc_bg.wasm",
"calc.js",
"calc_bg.js",
"calc.d.ts"
],
"main": "calc.js",
Expand Down
6 changes: 6 additions & 0 deletions calc/src/calc_fee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ impl Multiplier {
("westend", v) if 10 < v && v < 31 => V1((new_i128(inner), false)),
("westend", v) if 31 <= v => V2(new_u128(inner)),

("statemine", _v) => V2(new_u128(inner)),
emostov marked this conversation as resolved.
Show resolved Hide resolved
("statemint", _v) => V2(new_u128(inner)),

("westmine", _v) => V2(new_u128(inner)),
("westmint", _v) => V2(new_u128(inner)),
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you consider swapping around the logic a bit here; just check for the weird cases and give every one else new_i128 by default?

Copy link
Member Author

@TarikGul TarikGul Jul 15, 2021

Choose a reason for hiding this comment

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

I see what you are saying. Kinda like the equivalent of ending the match statement with a

/// account for defaults
_ => V1((new_i128(inner), false)),

I did think about this, and in all honesty I am kinda on the fence on whether it would be appropriate for @substrate/calc to give a default Multiplier or not. We enforce third party chains to update their own fee configuration through the controller-configs. Meaning if they don't have a minCalcFeeRuntime in the configuration they wont calculate fees. Then they would have to add their match case inside of the rust package as well which allows for zero possible errors on our side or assumptions on another chains fee calculation.

But at the same time, as a package it makes sense for the Multiplier to have some kind of default value because then it can support more than just Polkadot, Kusama, parity testnets, and parity parachains.


("dock-main-runtime", _) => V2(new_u128(inner)),
("dock-pos-main-runtime", _) => V2(new_u128(inner)),
("dock-pos-test-runtime", _) => V2(new_u128(inner)),
Expand Down
5 changes: 3 additions & 2 deletions src/chains-config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { kusamaControllers } from './kusamaControllers';
import { mandalaControllers } from './mandalaControllers';
import { polkadotControllers } from './polkadotControllers';
import { polymeshControllers } from './polymeshControllers';
import { statemineControllers } from './statemineControllers';
import { statemintControllers } from './statemintControllers';
import { westendControllers } from './westendControllers';

Expand All @@ -28,9 +29,9 @@ const specToControllerMap = {
'dock-main-runtime': dockMainnetControllers,
'dock-pos-main-runtime': dockPoSMainnetControllers,
'dock-pos-test-runtime': dockTestnetControllers,
statemine: statemineControllers,
statemint: statemintControllers,
statemine: statemintControllers,
westmine: statemintControllers,
westmine: statemineControllers,
westmint: statemintControllers,
};

Expand Down
28 changes: 28 additions & 0 deletions src/chains-config/statemineControllers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { ControllerConfig } from '../types/chains-config';

/**
* Statemine configuration for Sidecar.
*/
export const statemineControllers: ControllerConfig = {
controllers: [
'AccountsAssets',
'Blocks',
'BlocksExtrinsics',
'NodeNetwork',
'NodeTransactionPool',
'NodeVersion',
'PalletsAssets',
'RuntimeCode',
'RuntimeMetadata',
'RuntimeSpec',
'TransactionDryRun',
'TransactionFeeEstimate',
'TransactionMaterial',
'TransactionSubmit',
],
options: {
finalizes: true,
minCalcFeeRuntime: 1,
blockWeightStore: {},
},
};