Skip to content

Update block failed message #2418

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

Merged
merged 11 commits into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from 7 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
2 changes: 2 additions & 0 deletions packages/node-core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Fixed
- Update index block failed message (#2414)

## [10.3.2] - 2024-05-27
### Changed
Expand Down
17 changes: 15 additions & 2 deletions packages/node/src/utils/substrate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,9 @@ export async function getBlockByHeight(

const block = await api.rpc.chain.getBlock(blockHash).catch((e) => {
logger.error(
`failed to fetch Block hash="${blockHash}" height="${height}"`,
`failed to fetch Block hash="${blockHash}" height="${height}"${getApiDecodeErrMsg(
blockHash,
)}`,
);
throw ApiPromiseConnection.handleError(e);
});
Expand Down Expand Up @@ -330,7 +332,9 @@ export async function fetchEventsRange(
return Promise.all(
hashs.map((hash) =>
api.query.system.events.at(hash).catch((e) => {
logger.error(`failed to fetch events at block ${hash}`);
logger.error(
`failed to fetch events at block ${hash}${getApiDecodeErrMsg(hash)}`,
);
throw ApiPromiseConnection.handleError(e);
}),
),
Expand Down Expand Up @@ -448,3 +452,12 @@ export function calcInterval(api: ApiPromise): BN {
: DEFAULT_TIME),
);
}

function getApiDecodeErrMsg(blockHash: BlockHash): string {
return (
`\nFailed to index block ${blockHash}. This is because the block cannot be decoded. To solve this you can either:` +
'\n* Skip the block' +
'\n* Update the chain types. You can test this by viewing the block with https://polkadot.js.org/apps/' +
'\nFor further information please read the docs: https://academy.subquery.network/'
);
}
Loading