-
Notifications
You must be signed in to change notification settings - Fork 359
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
Add derive.assets.all #4509
Add derive.assets.all #4509
Conversation
const initialBlockHash = api.rpc.chain.subscribeNewHeads() | ||
.pipe(take(1)) | ||
.pipe((val) => val.pipe(map(({ hash }) => hash))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rpc.chain.getHeader
returns the latest, no sub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean changing to:
const initBlockHash = api.rpc.chain.getHeader().pipe(val => val.pipe(map(({ hash }) => hash)))
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed. api.rpc.chain.getHeader().pipe(map(({ hash }) => hash))
switchMap((blockHash: Hash) => | ||
combineLatest([ | ||
api.query.assets.asset.entriesAt(blockHash), | ||
api.query.assets.metadata.entriesAt(blockHash) | ||
]) | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a very, very heavy operation. Basically you refresh everything no matter what has changed on which id. The events actually have the ids of those changed, so should pin-point to those and only update those.
(crowdloans is an example of this - it tries to not get everything each time something has changed, rather it only refreshes based on the events received. As the state grows, this approach would just become slower and slower...)
For the initial load, 100% - we need all, on subsequent changes, this is the hammer approach and exceptionally ineffective and adding a lot of load.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Understood. Though still not sure how to solve it. Reason we use entriesAt
is initially that multi
did not get the updates from latest (non-finalized) block (polkadot-js/apps#6874 (comment)). As there is no entriesAt(blockHash, keys)
, I understand we need to load all, and then update state based on data from events (asset and metadata changes)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So if we can get a minimal reproducable sample with API code, can actually log that on Substrate. (There could obviously be an issue with the apps UI implementation itself)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Take a look at this issue, which is also parachain-related - /~https://github.com/paritytech/substrate/issues/10743
Would love a sample on a single connection where -
(a) event is available
(b) query for that item is not updated
I honestly cannot replicate this (relating to assets) on a stand-alone node.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As commented - we need a scalpel, not a hammer :)
Closing as-is. (However, this may not be an issue anymore in the apps UI, I know it had some significant changes on asset handling a while ago, which could have benefited here) |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
No description provided.