Skip to content

Commit

Permalink
merged master & resolved conflicts
Browse files Browse the repository at this point in the history
- rebuilt docs
- removed moonbeam specific code from xcm decoder
  • Loading branch information
Imod7 committed Jan 2, 2024
2 parents b8e28e8 + 36b4416 commit 68afb73
Show file tree
Hide file tree
Showing 9 changed files with 241 additions and 130 deletions.
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,31 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## [17.3.3](https://github.com/paritytech/substrate-api-sidecar/compare/v17.3.2..v17.3.3) (2023-12-21)

**NOTE** This release focuses on improving the performance of the tool resolving a regression where `blocks` were overwhelmed with transactions. The `noFees` query parameter focuses on removing fee info for the blocks if the user does not intend on needing fees. For more general cases where fees are necessary we have increased the performance of querying `/blocks` while also calculating fees. This was done with 2 cases: ensuring `transactionPaidFee`, and `ExtrinsicSuccess` or `ExtrinsicFailure` info is used to its fullest so we can avoid making any additional rpc calls, as well as ensuring the extrinsic's are called concurrently.
### Perf

- perf: transactionPaidFee event optimization ([#1367](https://github.com/paritytech/substrate-api-sidecar/pull/1367)) ([2883249](https://github.com/paritytech/substrate-api-sidecar/commit/288324918b7445fce8be6c4606c41058c66cdf69))
- perf: add concurrency to fee calls ([#1368](https://github.com/paritytech/substrate-api-sidecar/pull/1368)) ([0980d1e](https://github.com/paritytech/substrate-api-sidecar/commit/0980d1e0766f1e416883c8e68ebcf04ca8ecd2fc))

### Fix

- fix: add finalizedKey query param to /blocks/{blockId} ([#1362](https://github.com/paritytech/substrate-api-sidecar/pull/1362)) ([ecd1518](https://github.com/paritytech/substrate-api-sidecar/commit/ecd1518a1e7f6b4465e90cd7ff8f6fd7a115b88b))
- fix: added query to calc fees ([#1366](https://github.com/paritytech/substrate-api-sidecar/pull/1366)) ([203a257](https://github.com/paritytech/substrate-api-sidecar/commit/203a257bea3c150ac09d7b7fa956d68e524969bc))
NOTE: this added the noFees={bool} query param to specify whether to retrieve or not the fees information of the block for the `/blocks/*` endpoint

### Test

- test(e2e): replace tests pointing to deprecated pallets ([#1363](https://github.com/paritytech/substrate-api-sidecar/pull/1363)) ([2a38b2e](https://github.com/paritytech/substrate-api-sidecar/commit/2a38b2e652bf621bf6cc450ce5fdacf5656d9c8c))

## Compatibility

Tested against:
- Polkadot v10400
- Kusama v10400
- Westend v10400

## [17.3.2](https://github.com/paritytech/substrate-api-sidecar/compare/v17.3.1..v17.3.2) (2023-11-26)

### Fix
Expand Down
2 changes: 1 addition & 1 deletion docs/dist/app.bundle.js

Large diffs are not rendered by default.

23 changes: 22 additions & 1 deletion docs/src/openapi-v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ info:
license:
name: GPL-3.0-or-later
url: https://github.com/paritytech/substrate-api-sidecar/blob/master/LICENSE
version: 17.3.2
version: 17.3.3
servers:
- url: https://polkadot-public-sidecar.parity-chains.parity.io/
description: Polkadot Parity public sidecar
Expand Down Expand Up @@ -576,6 +576,13 @@ paths:
schema:
type: boolean
default: false
- name: noFees
in: query
description: When set to `true`, the fee won't be calculated for the extrinsics.
required: false
schema:
type: boolean
default: false
responses:
"200":
description: successful operation
Expand Down Expand Up @@ -621,6 +628,13 @@ paths:
schema:
type: boolean
default: false
- name: noFees
in: query
description: When set to `true`, the fee won't be calculated for the extrinsics.
required: false
schema:
type: boolean
default: false
- name: finalizedKey
in: query
description: When set to false, this will override the chain-config, and omit the
Expand Down Expand Up @@ -772,6 +786,13 @@ paths:
schema:
type: boolean
default: false
- name: noFees
in: query
description: When set to `true`, the fee won't be calculated for the extrinsics.
required: false
schema:
type: boolean
default: false
responses:
"200":
description: successful operation
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "17.3.2",
"version": "17.3.3",
"name": "@substrate/api-sidecar",
"description": "REST service that makes it easy to interact with blockchain nodes built using Substrate's FRAME framework.",
"homepage": "https://github.com/paritytech/substrate-api-sidecar#readme",
Expand Down
12 changes: 9 additions & 3 deletions src/controllers/blocks/BlocksController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export default class BlocksController extends AbstractController<BlocksService>
* @param _req Express Request
* @param res Express Response
*/
private getLatestBlock: RequestHandler = async ({ query: { eventDocs, extrinsicDocs, finalized } }, res) => {
private getLatestBlock: RequestHandler = async ({ query: { eventDocs, extrinsicDocs, finalized, noFees } }, res) => {
const eventDocsArg = eventDocs === 'true';
const extrinsicDocsArg = extrinsicDocs === 'true';

Expand All @@ -138,13 +138,15 @@ export default class BlocksController extends AbstractController<BlocksService>
queryFinalizedHead = false;
hash = await this.api.rpc.chain.getFinalizedHead();
}
const noFeesArg = noFees === 'true';

const options = {
eventDocs: eventDocsArg,
extrinsicDocs: extrinsicDocsArg,
checkFinalized: false,
queryFinalizedHead,
omitFinalizedTag,
noFees: noFeesArg,
};

const historicApi = await this.api.at(hash);
Expand All @@ -159,7 +161,7 @@ export default class BlocksController extends AbstractController<BlocksService>
* @param res Express Response
*/
private getBlockById: RequestHandler<INumberParam> = async (
{ params: { number }, query: { eventDocs, extrinsicDocs, finalizedKey, decodedXcmMsgs, paraId } },
{ params: { number }, query: { eventDocs, extrinsicDocs, noFees, finalizedKey, decodedXcmMsgs, paraId } },
res,
): Promise<void> => {
const checkFinalized = isHex(number);
Expand All @@ -172,6 +174,7 @@ export default class BlocksController extends AbstractController<BlocksService>
const finalizeOverride = finalizedKey === 'false';

const queryFinalizedHead = !this.options.finalizes ? false : true;
const noFeesArg = noFees === 'true';
let omitFinalizedTag = !this.options.finalizes ? true : false;

if (finalizeOverride) {
Expand All @@ -184,6 +187,7 @@ export default class BlocksController extends AbstractController<BlocksService>
checkFinalized,
queryFinalizedHead,
omitFinalizedTag,
noFees: noFeesArg,
};

// HistoricApi to fetch any historic information that doesnt include the current runtime
Expand Down Expand Up @@ -229,7 +233,7 @@ export default class BlocksController extends AbstractController<BlocksService>
* @param res Express Response
*/
private getBlocks: RequestHandler<unknown, unknown, unknown, IRangeQueryParam> = async (
{ query: { range, eventDocs, extrinsicDocs } },
{ query: { range, eventDocs, extrinsicDocs, noFees } },
res,
): Promise<void> => {
if (!range) throw new BadRequest('range query parameter must be inputted.');
Expand All @@ -241,12 +245,14 @@ export default class BlocksController extends AbstractController<BlocksService>
const extrinsicDocsArg = extrinsicDocs === 'true';
const queryFinalizedHead = !this.options.finalizes ? false : true;
const omitFinalizedTag = !this.options.finalizes ? true : false;
const noFeesArg = noFees === 'true';
const options = {
eventDocs: eventDocsArg,
extrinsicDocs: extrinsicDocsArg,
checkFinalized: false,
queryFinalizedHead,
omitFinalizedTag,
noFees: noFeesArg,
};

const pQueue = new PromiseQueue(4);
Expand Down
4 changes: 3 additions & 1 deletion src/controllers/blocks/BlocksExtrinsicsController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,22 @@ export default class BlocksExtrinsicsController extends AbstractController<Block
* @param res Express Response
*/
private getExtrinsicByTimepoint: RequestHandler<INumberParam> = async (
{ params: { blockId, extrinsicIndex }, query: { eventDocs, extrinsicDocs } },
{ params: { blockId, extrinsicIndex }, query: { eventDocs, extrinsicDocs, noFees } },
res,
): Promise<void> => {
const hash = await this.getHashForBlock(blockId);

const eventDocsArg = eventDocs === 'true';
const extrinsicDocsArg = extrinsicDocs === 'true';
const noFeesArg = noFees === 'true';

const options = {
eventDocs: eventDocsArg,
extrinsicDocs: extrinsicDocsArg,
checkFinalized: true,
queryFinalizedHead: false,
omitFinalizedTag: true,
noFees: noFeesArg,
};

const historicApi = await this.api.at(hash);
Expand Down
5 changes: 5 additions & 0 deletions src/services/blocks/BlocksService.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ describe('BlocksService', () => {
checkFinalized: false,
queryFinalizedHead: false,
omitFinalizedTag: false,
noFees: false,
};

expect(sanitizeNumbers(await blocksService.fetchBlock(blockHash789629, mockHistoricApi, options))).toMatchObject(
Expand All @@ -146,6 +147,7 @@ describe('BlocksService', () => {
checkFinalized: false,
queryFinalizedHead: false,
omitFinalizedTag: false,
noFees: false,
};
const tempGetBlock = mockApi.rpc.chain.getBlock;
mockApi.rpc.chain.getBlock = (() =>
Expand All @@ -170,6 +172,7 @@ describe('BlocksService', () => {
checkFinalized: false,
queryFinalizedHead: false,
omitFinalizedTag: true,
noFees: false,
};

const block = await blocksService.fetchBlock(blockHash789629, mockHistoricApi, options);
Expand Down Expand Up @@ -357,6 +360,7 @@ describe('BlocksService', () => {
checkFinalized: false,
queryFinalizedHead: false,
omitFinalizedTag: false,
noFees: false,
};

it('Returns the correct extrinisics object for block 789629', async () => {
Expand Down Expand Up @@ -442,6 +446,7 @@ describe('BlocksService', () => {
checkFinalized: false,
queryFinalizedHead: false,
omitFinalizedTag: false,
noFees: false,
};

it('Should correctly store the most recent queried blocks', async () => {
Expand Down
Loading

0 comments on commit 68afb73

Please sign in to comment.