Skip to content

Commit

Permalink
fix: support calamari parachain fee calculations (#749)
Browse files Browse the repository at this point in the history
* support calamari fee calculation

* lose redundant import

* calamari runtime constants

* calamari handler

* whitespace for the linter

* wasm-pack

* sorting for the linter

* minCalcFeeRuntime correction

* lint

* whitespace fix
  • Loading branch information
grenade committed Nov 4, 2021
1 parent 0a1e63e commit 1e2f4a5
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 0 deletions.
Binary file modified calc/pkg/calc_bg.wasm
Binary file not shown.
2 changes: 2 additions & 0 deletions calc/src/calc_fee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ impl Multiplier {
("dock-pos-main-runtime", _) => V2(new_u128(inner)),
("dock-pos-test-runtime", _) => V2(new_u128(inner)),

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

This comment has been minimized.

Copy link
@jsdw

jsdw Nov 5, 2021

Collaborator

Nit: I can't see why sometimes the variabel is _v and other times it's _; settle on just one?

This comment has been minimized.

Copy link
@TarikGul

TarikGul Nov 5, 2021

Member

Ahh yea thanks for the catch.

It slipped in on this addition here.

("dock-main-runtime", _) => V2(new_u128(inner)),
("dock-pos-main-runtime", _) => V2(new_u128(inner)),
("dock-pos-test-runtime", _) => V2(new_u128(inner)),

This comment has been minimized.

Copy link
@TarikGul

TarikGul Nov 5, 2021

Member

fixed it in the release


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

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

import { controllers } from '../controllers';
import { ControllerConfig } from '../types/chains-config';
import { calamariControllers } from './calamariControllers';
import { defaultControllers } from './defaultControllers';
import { dockMainnetControllers } from './dockMainnetControllers';
import { dockPoSMainnetControllers } from './dockPoSMainnetControllers';
Expand Down Expand Up @@ -37,6 +38,7 @@ const specToControllerMap = {
westmint: statemintControllers,
shiden: shidenControllers,
sora: soraControllers,
calamari: calamariControllers,
};

/**
Expand Down
9 changes: 9 additions & 0 deletions src/chains-config/metadata-consts/calamariConsts.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 calamariDefinitions: MetadataConsts[] = [
{
runtimeVersions: [1, 2, 3, 4],
extrinsicBaseWeight,
},
];
3 changes: 3 additions & 0 deletions src/chains-config/metadata-consts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
MetadataConsts,
PerClassValue,
} from '../../types/chains-config';
import { calamariDefinitions } from './calamariConsts';
import {
dockMainnetDefinitions,
dockPoSMainnetDefinitions,
Expand Down Expand Up @@ -88,6 +89,8 @@ export function getBlockWeight(specName: string): BlockWeightStore {
return generateBlockWeightStore(dockPoSTestnetDefinitions);
case 'shiden':
return generateBlockWeightStore(shidenDefinitions);
case 'calamari':
return generateBlockWeightStore(calamariDefinitions);
default:
return {};
}
Expand Down

0 comments on commit 1e2f4a5

Please sign in to comment.