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 calc fee for Karura and Acala #754

Merged
merged 2 commits into from
Nov 10, 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.
3 changes: 3 additions & 0 deletions calc/src/calc_fee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ impl Multiplier {

("calamari", _v) => V2(new_u128(inner)),

("karura", _v) => V2(new_u128(inner)),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

should be a way to configure this without modify rust code. at least for common cases.

Copy link
Member

Choose a reason for hiding this comment

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

Yea we have had discussion about this, especially since parachains are going to want more and more support for fee calculations as time moves on. We thought about a plugin, and some different options. Still something to consider but I agree.

("acala", _v) => V2(new_u128(inner)),

_ => {
info!("Unsupported runtime: {}#{}", spec_name, spec_version);
return None;
Expand Down
33 changes: 33 additions & 0 deletions src/chains-config/acalaControllers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { ControllerConfig } from '../types/chains-config';
import { initLRUCache } from './cache/lruCache';
import { getBlockWeight } from './metadata-consts';

/**
* Controllers for Acala collator
*/
export const acalaControllers: ControllerConfig = {
controllers: [
'AccountsBalanceInfo',
'AccountsValidate',
'Blocks',
'BlocksExtrinsics',
'NodeNetwork',
'NodeTransactionPool',
'NodeVersion',
'PalletsStorage',
'Paras',
'RuntimeCode',
'RuntimeMetadata',
'RuntimeSpec',
'TransactionDryRun',
'TransactionFeeEstimate',
'TransactionMaterial',
'TransactionSubmit',
],
options: {
finalizes: true,
minCalcFeeRuntime: 2000,
blockWeightStore: getBlockWeight('acala'),
blockStore: initLRUCache(),
},
};
4 changes: 4 additions & 0 deletions src/chains-config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import { AbstractService } from 'src/services/AbstractService';

import { controllers } from '../controllers';
import { ControllerConfig } from '../types/chains-config';
import { acalaControllers } from './acalaControllers';
import { calamariControllers } from './calamariControllers';
import { defaultControllers } from './defaultControllers';
import { dockMainnetControllers } from './dockMainnetControllers';
import { dockPoSMainnetControllers } from './dockPoSMainnetControllers';
import { dockTestnetControllers } from './dockPoSTestnetControllers';
import { karuraControllers } from './karuraControllers';
import { kiltControllers } from './kiltControllers';
import { kulupuControllers } from './kulupuControllers';
import { kusamaControllers } from './kusamaControllers';
Expand Down Expand Up @@ -39,6 +41,8 @@ const specToControllerMap = {
shiden: shidenControllers,
sora: soraControllers,
calamari: calamariControllers,
karura: karuraControllers,
acala: acalaControllers,
};

/**
Expand Down
33 changes: 33 additions & 0 deletions src/chains-config/karuraControllers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { ControllerConfig } from '../types/chains-config';
import { initLRUCache } from './cache/lruCache';
import { getBlockWeight } from './metadata-consts';

/**
* Controllers for Karura collator
*/
export const karuraControllers: ControllerConfig = {
controllers: [
'AccountsBalanceInfo',
'AccountsValidate',
'Blocks',
'BlocksExtrinsics',
'NodeNetwork',
'NodeTransactionPool',
'NodeVersion',
'PalletsStorage',
'Paras',
'RuntimeCode',
'RuntimeMetadata',
'RuntimeSpec',
'TransactionDryRun',
'TransactionFeeEstimate',
'TransactionMaterial',
'TransactionSubmit',
],
options: {
finalizes: true,
minCalcFeeRuntime: 1000,
blockWeightStore: getBlockWeight('karura'),
blockStore: initLRUCache(),
},
};
9 changes: 9 additions & 0 deletions src/chains-config/metadata-consts/acalaConsts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { MetadataConsts } from '../../types/chains-config';
import { extrinsicBaseWeight } from './substrateConsts';

export const acalaDefinitions: MetadataConsts[] = [
{
runtimeVersions: [2000, 2001, 2002],
extrinsicBaseWeight,
},
];
6 changes: 6 additions & 0 deletions src/chains-config/metadata-consts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ import {
MetadataConsts,
PerClassValue,
} from '../../types/chains-config';
import { acalaDefinitions } from './acalaConsts';
import { calamariDefinitions } from './calamariConsts';
import {
dockMainnetDefinitions,
dockPoSMainnetDefinitions,
dockPoSTestnetDefinitions,
} from './dockConsts';
import { karuraDefinitions } from './karuraConsts';
import { kusamaDefinitions } from './kusamaConsts';
import { polkadotDefinitions } from './polkadotConsts';
import { polymeshDefinitions } from './polymeshConsts';
Expand Down Expand Up @@ -91,6 +93,10 @@ export function getBlockWeight(specName: string): BlockWeightStore {
return generateBlockWeightStore(shidenDefinitions);
case 'calamari':
return generateBlockWeightStore(calamariDefinitions);
case 'karura':
return generateBlockWeightStore(karuraDefinitions);
case 'acala':
return generateBlockWeightStore(acalaDefinitions);
default:
return {};
}
Expand Down
12 changes: 12 additions & 0 deletions src/chains-config/metadata-consts/karuraConsts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { MetadataConsts } from '../../types/chains-config';
import { extrinsicBaseWeight } from './substrateConsts';

export const karuraDefinitions: MetadataConsts[] = [
{
runtimeVersions: [
1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do we need to list all the runtime versions? Do we need to PR here if we did a runtime upgrade?

Copy link
Member

Choose a reason for hiding this comment

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

Yea and yes. If it doesnt have your new runtime version immediately thats alright, we just end up searching the decorated metadata for the weights for the missing runtime then cache it for the server instance.

1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019, 2000, 2001,
],
extrinsicBaseWeight,
},
];