Skip to content
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

Each entry in priceRegistry needs a unique id #444

Closed
chrisli30 opened this issue Oct 6, 2023 · 3 comments · Fixed by #455
Closed

Each entry in priceRegistry needs a unique id #444

chrisli30 opened this issue Oct 6, 2023 · 3 comments · Fixed by #455
Assignees
Labels
bug Something isn't working

Comments

@chrisli30
Copy link
Member

From developer’s perspective, every data type in on-chain storage needs a unique id, otherwise there’s no way to know whether a Price has been updated. Please refer to the screenshot below, as you can see from the events the client couldn’t tell what server version the data entry is.
priceRegistry-no-unique-id

@chrisli30 chrisli30 added the bug Something isn't working label Oct 6, 2023
@v9n
Copy link
Member

v9n commented Oct 13, 2023

the pair (chain, exchange, (asset1, asset2)) is the address itself. But because of the round bug not increasing, It is confused. I will get this fixed.

On the ID, do you think we should introduce a new ID or that tuple (chain, exchange, (asset1, asset2)) is sustainable. Or if it's too verbose ?

I think let refactor to this

Before

{
round
nonce
amount
}

After

{
round: a increasing number each time we update the price
round_updated_at: epoch of blocktime we update the price
price: (rename from amount -> price, as discussion on other)
}

@chrisli30
Copy link
Member Author

Yeah, the problem was caused by round not increasing. The unique ID is determined by concatenating (chain, exchange, (asset1, asset2)) with the round value.

Regarding the After format, it looks good, but we can simplify round_updated_at to updated_at because we update everything, not just the round value.

Additionally, on second thought I agree that amount seems more intrinsic as an on-chain value than price. How about we simply call it value? I'd like to avoid naming a number something overly specific, like price.

Overall, the value of the storage should look like { round, updated_at, value }

@v9n
Copy link
Member

v9n commented Oct 13, 2023

that reasoning makes sense.

I think many of polkadot.js balances API was also using value as the parameter when doing transfer for example https://polkadot.js.org/docs/polkadot/extrinsics#balances to represent the amount of transfer.

API wise, let say we have a variable call price, then doing price.value is also more intuitive then price.amount so agree. let use value

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants