Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Frame: Agile Coretime Broker pallet (RFC-1)#14568

Merged
paritytech-processbot[bot] merged 143 commits into
masterfrom
gav-broker
Aug 24, 2023
Merged

Frame: Agile Coretime Broker pallet (RFC-1)#14568
paritytech-processbot[bot] merged 143 commits into
masterfrom
gav-broker

Conversation

@gavofyork

@gavofyork gavofyork commented Jul 12, 2023

Copy link
Copy Markdown
Member

The implementation of polkadot-fellows/RFCs#1.

TODO

  • Events for all disptchables
  • Events for do_tick stuff
  • Final docs & RFC update
  • Tests for dropping out of date storage
  • Tests for core count changes
  • Comprehensive tests
  • Benchmarks
  • Weights

For consideration:

  • Consolidation of InstaPoolHistory records as long as contributors don't change

@gavofyork gavofyork added A0-please_review Pull request needs code review. and removed A3-in_progress Pull request is in progress. No review needed at this stage. labels Aug 22, 2023
@gavofyork gavofyork closed this Aug 22, 2023
@gavofyork gavofyork reopened this Aug 22, 2023

@ggwpez ggwpez left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Some comments... not through yet

Comment on lines +37 to +38
fn leadin_factor_at(_: FixedU64) -> FixedU64 {
FixedU64::one()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The argument could be a Perbill to prevent underflows.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Bit ugly to pass in a Perbill and require a FixedU64 out, but sure I guess.

pub fn complete() -> Self {
Self([255u8; 10])
}
pub fn is_void(&self) -> bool {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We have a Clear trait with docs "Trait for things that can be clear (have no bits set). For numeric types, essentially the same as Zero". Not sure if you want to use that, but then the clear function here would need to be renamed to unset or so.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

No opinion.

Comment thread frame/broker/src/core_mask.rs Outdated
/// operation, the Relay-chain SHOULD send a `notify_core_count(count)` message back.
fn request_core_count(count: CoreIndex);

/// Requests that the Relay-chain send a `notify_revenue` message back at or soon after

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Does this make assumptions about an ordered communication channel?
Otherwise it could be useful to also include the when into the notify_revenue message.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Does this make assumptions about an ordered communication channel?

Yes.

when is included in the notify_revenue message (it gets returned as the first param of the check_notify_revenue_info result).

// 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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
#![deny(missing_docs)]

Looks like a good candidate for this.

fn check_notify_core_count() -> Option<u16>;

/// Provide the amount of revenue accumulated from Instantaneous Coretime Sales from Relay-chain
/// block number `last_until` to `until`, not including `until` itself. `last_until` is defined

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

last_until is explained, but what is until?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

until is the first item of the result.

@ggwpez ggwpez left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Only two non-nit comments about adapt_price and do_configure.

ensure!(check_owner == region.owner, Error::<T>::NotOwner);
}
let pivot = region_id.begin.saturating_add(pivot_offset);
ensure!(pivot < region.end, Error::<T>::PivotTooLate);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe also checking that pivot is not zero?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think with pivot_offset==0 it is possible to clone the region.
Will adda check against it.

region.owner = new_owner;
Regions::<T>::insert(&region_id, &region);
let duration = region.end.saturating_sub(region_id.begin);
Self::deposit_event(Event::Transferred {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think the edge-case where the owner sends to themselves should not emit a Transferred event.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

That case could be an early-exit, I guess.

Comment thread frame/broker/src/dispatchable_impls.rs Outdated
Comment on lines +206 to +208
let new_region_ids = (region_id, RegionId { begin: pivot, ..region_id.clone() });

Regions::<T>::insert(&new_region_ids.0, &RegionRecord { end: pivot, ..region.clone() });

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Would this not cause an overlap of the regions for pivot since its the end of region 0 and the begin or region 1?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

regions are begin..end, not begin..=end, so they don't include the end block.

Comment thread frame/broker/src/dispatchable_impls.rs
Comment thread frame/broker/src/tick_impls.rs Outdated
Comment thread frame/broker/src/dispatchable_impls.rs
T::PalletId::get().into_account_truncating()
}

pub fn sale_price(sale: &SaleInfoRecordOf<T>, now: BlockNumberFor<T>) -> BalanceOf<T> {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It has the invariant that leadin_length != 0, dont know if that is always the case.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes it's expected to be. But perhaps should be rewritten to be safe in case not.

Comment thread frame/broker/src/adapt_price.rs
_ => return Weight::zero(),
};

let mut meter = WeightMeter::max_limit();

@ggwpez ggwpez Aug 24, 2023

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think it will need a proper weight limit eventually, or?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes - I guess this should be zero. @gupnik ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Indeed, thanks for catching this. Will fix this in the monorepo.

ggwpez added 13 commits August 24, 2023 19:06
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
zepter format features

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
@ggwpez

ggwpez commented Aug 24, 2023

Copy link
Copy Markdown
Member

bot merge

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

A0-please_review Pull request needs code review. B1-note_worthy Changes should be noted in the release notes C1-low PR touches the given topic and has a low impact on builders. D2-notlive 💤 PR contains changes in a runtime directory that is not deployed to a chain that requires an audit. T1-runtime This PR/Issue is related to the topic “runtime”.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants