Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Update for maximumBlockWeight
  • Loading branch information
jacogr committed Dec 8, 2020
commit 7adfeada49466a7b476c3d302324beee5b054bf0
6 changes: 4 additions & 2 deletions packages/api-contract/src/base/Contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import type { SubmittableExtrinsic } from '@polkadot/api/submittable/types';
import type { ApiTypes, DecorateMethod } from '@polkadot/api/types';
import type { Bytes } from '@polkadot/types';
import type { AccountId, ContractExecResult, EventRecord } from '@polkadot/types/interfaces';
import type { AccountId, ContractExecResult, EventRecord, Weight } from '@polkadot/types/interfaces';
import type { AnyJson, CodecArg, ISubmittableResult, Registry } from '@polkadot/types/types';
import type { AbiMessage, ContractCallOutcome, ContractOptions, DecodedEvent } from '../types';
import type { ContractCallResult, ContractCallSend, ContractGeneric, ContractQuery, ContractTx, MapMessageQuery, MapMessageTx } from './types';
Expand Down Expand Up @@ -145,7 +145,9 @@ export class Contract<ApiType extends ApiTypes> extends Base<ApiType> {
return gasLimit.lten(0)
? isCall
? MAX_CALL_GAS
: this.api.consts.system.maximumBlockWeight.muln(64).divn(100)
: this.api.consts.system.blockWeights
? this.api.consts.system.blockWeights.perClass.normal.maxExtrinsic.sub(this.api.consts.system.blockWeights.perClass.normal.baseExtrinsic)
: (this.api.consts.system.maximumBlockWeight as Weight).muln(64).divn(100)
: gasLimit;
}

Expand Down
23 changes: 6 additions & 17 deletions packages/api/src/augment/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@

import type { Vec, u16, u32, u64 } from '@polkadot/types';
import type { Codec } from '@polkadot/types/types';
import type { Balance, BalanceOf, BlockNumber, LockIdentifier, ModuleId, Moment, Perbill, Percent, Permill, RuntimeDbWeight, Weight } from '@polkadot/types/interfaces/runtime';
import type { Balance, BalanceOf, BlockNumber, LockIdentifier, ModuleId, Moment, Perbill, Percent, Permill, RuntimeDbWeight } from '@polkadot/types/interfaces/runtime';
import type { SessionIndex } from '@polkadot/types/interfaces/session';
import type { EraIndex } from '@polkadot/types/interfaces/staking';
import type { WeightToFeeCoefficient } from '@polkadot/types/interfaces/support';
import type { BlockWeights } from '@polkadot/types/interfaces/system';
import type { ApiTypes } from '@polkadot/api/types';

declare module '@polkadot/api/types/consts' {
Expand Down Expand Up @@ -314,30 +315,18 @@ declare module '@polkadot/api/types/consts' {
};
system: {
[key: string]: Codec;
/**
* The base weight of executing a block, independent of the transactions in the block.
**/
blockExecutionWeight: Weight & AugmentedConst<ApiType>;
/**
* The maximum number of blocks to allow in mortal eras.
**/
blockHashCount: BlockNumber & AugmentedConst<ApiType>;
/**
* The weight of runtime database operations the runtime can invoke.
**/
dbWeight: RuntimeDbWeight & AugmentedConst<ApiType>;
/**
* The base weight of an Extrinsic in the block, independent of the of extrinsic being executed.
**/
extrinsicBaseWeight: Weight & AugmentedConst<ApiType>;
/**
* The maximum length of a block (in bytes).
* The weight configuration (limits & base values) for each class of extrinsics and block.
**/
maximumBlockLength: u32 & AugmentedConst<ApiType>;
blockWeights: BlockWeights & AugmentedConst<ApiType>;
/**
* The maximum weight of a block.
* The weight of runtime database operations the runtime can invoke.
**/
maximumBlockWeight: Weight & AugmentedConst<ApiType>;
dbWeight: RuntimeDbWeight & AugmentedConst<ApiType>;
};
timestamp: {
[key: string]: Codec;
Expand Down
6 changes: 3 additions & 3 deletions packages/api/src/augment/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ import type { AuthIndex } from '@polkadot/types/interfaces/imOnline';
import type { DeferredOffenceOf, Kind, OffenceDetails, OpaqueTimeSlot, ReportIdOf } from '@polkadot/types/interfaces/offences';
import type { ProxyAnnouncement, ProxyDefinition } from '@polkadot/types/interfaces/proxy';
import type { ActiveRecovery, RecoveryConfig } from '@polkadot/types/interfaces/recovery';
import type { AccountId, AccountIndex, AssetId, Balance, BalanceOf, BlockNumber, ExtrinsicsWeight, Hash, KeyTypeId, Moment, OpaqueCall, Perbill, Releases, ValidatorId } from '@polkadot/types/interfaces/runtime';
import type { AccountId, AccountIndex, AssetId, Balance, BalanceOf, BlockNumber, Hash, KeyTypeId, Moment, OpaqueCall, Perbill, Releases, ValidatorId } from '@polkadot/types/interfaces/runtime';
import type { Scheduled, TaskAddress } from '@polkadot/types/interfaces/scheduler';
import type { Keys, SessionIndex } from '@polkadot/types/interfaces/session';
import type { Bid, BidKind, SocietyVote, StrikeCount, VouchingStatus } from '@polkadot/types/interfaces/society';
import type { ActiveEraInfo, ElectionResult, ElectionScore, ElectionStatus, EraIndex, EraRewardPoints, Exposure, Forcing, Nominations, RewardDestination, SlashingSpans, SpanIndex, SpanRecord, StakingLedger, UnappliedSlash, ValidatorPrefs } from '@polkadot/types/interfaces/staking';
import type { AccountInfo, DigestOf, EventIndex, EventRecord, LastRuntimeUpgradeInfo, Phase } from '@polkadot/types/interfaces/system';
import type { AccountInfo, ConsumedWeight, DigestOf, EventIndex, EventRecord, LastRuntimeUpgradeInfo, Phase } from '@polkadot/types/interfaces/system';
import type { Bounty, BountyIndex, OpenTip, TreasuryProposal } from '@polkadot/types/interfaces/treasury';
import type { Multiplier } from '@polkadot/types/interfaces/txpayment';
import type { Multisig } from '@polkadot/types/interfaces/utility';
Expand Down Expand Up @@ -822,7 +822,7 @@ declare module '@polkadot/api/types/storage' {
/**
* The current weight for the block.
**/
blockWeight: AugmentedQuery<ApiType, () => Observable<ExtrinsicsWeight>> & QueryableStorageEntry<ApiType>;
blockWeight: AugmentedQuery<ApiType, () => Observable<ConsumedWeight>> & QueryableStorageEntry<ApiType>;
/**
* Digest of the current block, also part of the block header.
**/
Expand Down
17 changes: 10 additions & 7 deletions packages/types/src/augment/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import type { Bid, BidKind, SocietyJudgement, SocietyVote, StrikeCount, Vouching
import type { ActiveEraInfo, CompactAssignments, CompactAssignmentsTo257, CompactScore, CompactScoreCompact, ElectionCompute, ElectionResult, ElectionScore, ElectionSize, ElectionStatus, EraIndex, EraPoints, EraRewardPoints, EraRewards, Exposure, Forcing, IndividualExposure, KeyType, MomentOf, Nominations, NominatorIndex, NominatorIndexCompact, OffchainAccuracy, OffchainAccuracyCompact, PhragmenScore, Points, RewardDestination, RewardDestinationTo257, RewardPoint, SlashJournalEntry, SlashingSpans, SlashingSpansTo204, SpanIndex, SpanRecord, StakingLedger, StakingLedgerTo223, StakingLedgerTo240, UnappliedSlash, UnappliedSlashOther, UnlockChunk, ValidatorIndex, ValidatorIndexCompact, ValidatorPrefs, ValidatorPrefsTo145, ValidatorPrefsTo196 } from '@polkadot/types/interfaces/staking';
import type { ApiId, KeyValueOption, ReadProof, RuntimeVersion, RuntimeVersionApi, StorageChangeSet } from '@polkadot/types/interfaces/state';
import type { WeightToFeeCoefficient } from '@polkadot/types/interfaces/support';
import type { AccountInfo, ApplyExtrinsicResult, BlockWeights, ChainProperties, ChainType, DigestOf, DispatchClass, DispatchError, DispatchErrorModule, DispatchErrorTo198, DispatchInfo, DispatchInfoTo190, DispatchInfoTo244, DispatchOutcome, DispatchResult, DispatchResultOf, DispatchResultTo198, Event, EventId, EventIndex, EventRecord, Health, InvalidTransaction, Key, LastRuntimeUpgradeInfo, NetworkState, NetworkStatePeerset, NetworkStatePeersetInfo, NodeRole, NotConnectedPeer, Peer, PeerEndpoint, PeerEndpointAddr, PeerInfo, PeerPing, PerDispatchClass, Phase, RawOrigin, RefCount, RefCountTo259, SyncState, SystemOrigin, TransactionValidityError, UnknownTransaction, WeightPerClass } from '@polkadot/types/interfaces/system';
import type { AccountInfo, ApplyExtrinsicResult, BlockWeights, ChainProperties, ChainType, ConsumedWeight, DigestOf, DispatchClass, DispatchError, DispatchErrorModule, DispatchErrorTo198, DispatchInfo, DispatchInfoTo190, DispatchInfoTo244, DispatchOutcome, DispatchResult, DispatchResultOf, DispatchResultTo198, Event, EventId, EventIndex, EventRecord, Health, InvalidTransaction, Key, LastRuntimeUpgradeInfo, NetworkState, NetworkStatePeerset, NetworkStatePeersetInfo, NodeRole, NotConnectedPeer, Peer, PeerEndpoint, PeerEndpointAddr, PeerInfo, PeerPing, PerDispatchClass, Phase, RawOrigin, RefCount, RefCountTo259, SyncState, SystemOrigin, TransactionValidityError, UnknownTransaction, WeightPerClass } from '@polkadot/types/interfaces/system';
import type { Bounty, BountyIndex, BountyStatus, BountyStatusActive, BountyStatusCuratorProposed, BountyStatusPendingPayout, OpenTip, OpenTipFinderTo225, OpenTipTip, OpenTipTo225, TreasuryProposal } from '@polkadot/types/interfaces/treasury';
import type { Multiplier } from '@polkadot/types/interfaces/txpayment';
import type { Multisig, Timepoint } from '@polkadot/types/interfaces/utility';
Expand Down Expand Up @@ -1167,12 +1167,6 @@ declare module '@polkadot/types/types/registry' {
ApplyExtrinsicResult: ApplyExtrinsicResult;
'Option<ApplyExtrinsicResult>': Option<ApplyExtrinsicResult>;
'Vec<ApplyExtrinsicResult>': Vec<ApplyExtrinsicResult>;
WeightPerClass: WeightPerClass;
'Option<WeightPerClass>': Option<WeightPerClass>;
'Vec<WeightPerClass>': Vec<WeightPerClass>;
PerDispatchClass: PerDispatchClass;
'Option<PerDispatchClass>': Option<PerDispatchClass>;
'Vec<PerDispatchClass>': Vec<PerDispatchClass>;
BlockWeights: BlockWeights;
'Option<BlockWeights>': Option<BlockWeights>;
'Vec<BlockWeights>': Vec<BlockWeights>;
Expand All @@ -1182,6 +1176,9 @@ declare module '@polkadot/types/types/registry' {
ChainType: ChainType;
'Option<ChainType>': Option<ChainType>;
'Vec<ChainType>': Vec<ChainType>;
ConsumedWeight: ConsumedWeight;
'Option<ConsumedWeight>': Option<ConsumedWeight>;
'Vec<ConsumedWeight>': Vec<ConsumedWeight>;
DigestOf: DigestOf;
'Option<DigestOf>': Option<DigestOf>;
'Vec<DigestOf>': Vec<DigestOf>;
Expand Down Expand Up @@ -1273,6 +1270,9 @@ declare module '@polkadot/types/types/registry' {
PeerInfo: PeerInfo;
'Option<PeerInfo>': Option<PeerInfo>;
'Vec<PeerInfo>': Vec<PeerInfo>;
PerDispatchClass: PerDispatchClass;
'Option<PerDispatchClass>': Option<PerDispatchClass>;
'Vec<PerDispatchClass>': Vec<PerDispatchClass>;
Phase: Phase;
'Option<Phase>': Option<Phase>;
'Vec<Phase>': Vec<Phase>;
Expand All @@ -1299,6 +1299,9 @@ declare module '@polkadot/types/types/registry' {
UnknownTransaction: UnknownTransaction;
'Option<UnknownTransaction>': Option<UnknownTransaction>;
'Vec<UnknownTransaction>': Vec<UnknownTransaction>;
WeightPerClass: WeightPerClass;
'Option<WeightPerClass>': Option<WeightPerClass>;
'Vec<WeightPerClass>': Vec<WeightPerClass>;
Bounty: Bounty;
'Option<Bounty>': Option<Bounty>;
'Vec<Bounty>': Vec<Bounty>;
Expand Down
3 changes: 3 additions & 0 deletions packages/types/src/interfaces/system/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ export interface ChainType extends Enum {
readonly asCustom: Text;
}

/** @name ConsumedWeight */
export interface ConsumedWeight extends PerDispatchClass {}

/** @name DigestOf */
export interface DigestOf extends Digest {}

Expand Down