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

Use relay chain block number in the broker pallet instead of block number #5656

Merged
merged 34 commits into from
Nov 11, 2024

Conversation

davidk-pt
Copy link
Contributor

@davidk-pt davidk-pt commented Sep 10, 2024

Based on #3331
Related to #3268

Implements migrations with customizable block number to relay height number translation function.

Adds block to relay height migration code for rococo and westend.

@davidk-pt davidk-pt added the T2-pallets This PR/Issue is related to a particular pallet. label Sep 10, 2024
@davidk-pt davidk-pt force-pushed the davidk/use-relay-blocknumber-in-broker branch from 8ae1688 to c928b8a Compare September 11, 2024 08:39
@davidk-pt davidk-pt force-pushed the davidk/use-relay-blocknumber-in-broker branch from 3b7ba18 to 60c5662 Compare September 12, 2024 08:44
@xlc
Copy link
Contributor

xlc commented Sep 12, 2024

this will break all the UI and indexers and I am not sure if there exists a good solution...

@paritytech-cicd-pr
Copy link

The CI pipeline was cancelled due to failure one of the required jobs.
Job name: test-linux-stable 3/3
Logs: https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/7340522

@davidk-pt davidk-pt marked this pull request as ready for review September 16, 2024 07:10
@davidk-pt davidk-pt requested a review from a team as a code owner September 16, 2024 07:10
@kianenigma
Copy link
Contributor

this will break all the UI and indexers and I am not sure if there exists a good solution...

Yeah, only solution that comes to mind is something like polkadot-api/polkadot-api#689

@xlc
Copy link
Contributor

xlc commented Sep 16, 2024

a backward compatible approach will be use relaychain block number / 2 + offset so we don’t need complicated migration and existing dapps will still be functional without changes

@joepetrowski
Copy link
Contributor

a backward compatible approach will be use relaychain block number / 2 + offset so we don’t need complicated migration and existing dapps will still be functional without changes

Why would you use the RC block number? The offset should account for the difference in block height, but the coefficient (here, 1/2) should be w/r/t the block time.

@xlc
Copy link
Contributor

xlc commented Sep 17, 2024

the idea is simulate 12s block time regardless local block time so the meaning of the block numbers in storage stays the same and keep UI compatible

@joepetrowski
Copy link
Contributor

I still don't understand from that description. So you are saying that if a parachain goes 24 second between two blocks, that those would be n and n+2?

if let Some(config_record) = v3::Configuration::<T>::get() {
(config_record.interlude_length, config_record.leadin_length)
} else {
((0 as u32).into(), (0 as u32).into())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any correct scenario in which this Configuration does not exist? should we not err, or panic here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking deeper into the code it seems that it is indeed possible, if configure call on the pallet is not called yet then Configuration will be none

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, then what you have done could make sense!

but it is also worth taking it into account: this pallet is only used in coretime chain, what is the live state of the coretime chain right now?

log::info!(target: LOG_TARGET, "Configuration Pre-Migration: Interlude Length {:?}->{:?} Leadin Length {:?}->{:?}", interlude_length, updated_interlude_length, configuration_leadin_length, updated_leadin_length);

let (sale_start, sale_info_leadin_length) =
if let Some(sale_info_record) = v3::SaleInfo::<T>::get() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In #[try-runtime] feature, you might as well feel free to panic.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SaleInfo might not exist if start_sales pallet call is not called yet

Copy link
Contributor

@kianenigma kianenigma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small nits on the migration, otherwise ready for approval.

@davidk-pt
Copy link
Contributor Author

davidk-pt commented Oct 31, 2024

small nits on the migration, otherwise ready for approval.

After more thorough code inspection I have left the graceful handling of Configuration and SaleInfo records for cases where they are None.
I imagine a case where someone creates a runtime with broker pallet from example and simply neglects it, I don't think we want to panic in case broker pallet wasn't initialized yet, even in try-runtime tests

@kianenigma
Copy link
Contributor

I imagine a case where someone creates a runtime with broker pallet from example and simply neglects it, I don't think we want to panic in case broker pallet wasn't initialized yet, even in try-runtime tests

Indeed, I was leaning a bit toward the fact that the broker pallet not really a general pallet, but rather made ONLY for the polkadot relay chain or coretime chain. But your poitn is also valid; thanks for clarifying!

Copy link
Contributor

@seadanda seadanda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Finished my last pass. LGTM

@davidk-pt davidk-pt force-pushed the davidk/use-relay-blocknumber-in-broker branch from 76a02f6 to 48d96c8 Compare November 11, 2024 15:26
@davidk-pt davidk-pt added this pull request to the merge queue Nov 11, 2024
Merged via the queue into master with commit 1b0cbe9 Nov 11, 2024
194 of 197 checks passed
@davidk-pt davidk-pt deleted the davidk/use-relay-blocknumber-in-broker branch November 11, 2024 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T2-pallets This PR/Issue is related to a particular pallet.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants