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

Conversation

@bkchr
Copy link
Member

@bkchr bkchr commented Jan 27, 2021

Instead of having some type definition that only was used in half of the
code or directly using u64, this adds a new unit type wrapper Slot.
This makes it especially easy for the outside api to know what type is
expected/returned.

polkadot companion: paritytech/polkadot#2345

Instead of having some type definition that only was used in half of the
code or directly using `u64`, this adds a new unit type wrapper `Slot`.
This makes it especially easy for the outside api to know what type is
expected/returned.
@bkchr bkchr added A0-please_review Pull request needs code review. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. labels Jan 27, 2021
@bkchr bkchr requested review from andresilva and octol January 27, 2021 20:56
Copy link
Contributor

@andresilva andresilva left a comment

Choose a reason for hiding this comment

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

I started suggesting all of the naming changes related to slot_number -> slot. But this is cumbersome to do on github, do you mind if I just them locally and push a commit for this?


fn generate_key_ownership_proof(
_slot_number: sp_consensus_babe::SlotNumber,
_slot_number: sp_consensus_babe::Slot,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
_slot_number: sp_consensus_babe::Slot,
_slot: sp_consensus_babe::Slot,


fn generate_key_ownership_proof(
_slot_number: sp_consensus_babe::SlotNumber,
_slot_number: sp_consensus_babe::Slot,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
_slot_number: sp_consensus_babe::Slot,
_slot: sp_consensus_babe::Slot,

pub start_slot: Slot,
/// The duration of this epoch.
pub duration: SlotNumber,
pub duration: Slot,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
pub duration: Slot,
pub duration: u64,

We define epoch_length above as u64 as well.

pub fn make_transcript(
randomness: &Randomness,
slot_number: u64,
slot_number: Slot,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
slot_number: Slot,
slot: Slot,

) -> Transcript {
let mut transcript = Transcript::new(&BABE_ENGINE_ID);
transcript.append_u64(b"slot number", slot_number);
transcript.append_u64(b"slot number", *slot_number);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
transcript.append_u64(b"slot number", *slot_number);
transcript.append_u64(b"slot number", *slot);

label: &BABE_ENGINE_ID,
items: vec![
("slot number", VRFTranscriptValue::U64(slot_number)),
("slot number", VRFTranscriptValue::U64(*slot_number)),
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
("slot number", VRFTranscriptValue::U64(*slot_number)),
("slot number", VRFTranscriptValue::U64(*slot)),

}

fn aura_pre_digest(slot_num: u64) -> Self {
fn aura_pre_digest(slot_num: Slot) -> Self {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
fn aura_pre_digest(slot_num: Slot) -> Self {
fn aura_pre_digest(slot: Slot) -> Self {


fn aura_pre_digest(slot_num: u64) -> Self {
fn aura_pre_digest(slot_num: Slot) -> Self {
DigestItem::PreRuntime(AURA_ENGINE_ID, slot_num.encode())
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
DigestItem::PreRuntime(AURA_ENGINE_ID, slot_num.encode())
DigestItem::PreRuntime(AURA_ENGINE_ID, slot.encode())


/// Construct a digest item which contains the slot number
fn aura_pre_digest(slot_num: u64) -> Self;
fn aura_pre_digest(slot_num: Slot) -> Self;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
fn aura_pre_digest(slot_num: Slot) -> Self;
fn aura_pre_digest(slot: Slot) -> Self;

bkchr added a commit to paritytech/polkadot that referenced this pull request Jan 28, 2021
Copy link
Contributor

@andresilva andresilva left a comment

Choose a reason for hiding this comment

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

Change LGTM, I pushed a commit with some extra renaming. Will give another extra look before merging to double check tiny changes.

Copy link
Contributor

@octol octol left a comment

Choose a reason for hiding this comment

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

Looking good! I guess a natural next step could be to also create a type for the slot durations?

Copy link
Contributor

@andresilva andresilva left a comment

Choose a reason for hiding this comment

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

Thanks!

@bkchr
Copy link
Member Author

bkchr commented Jan 28, 2021

bot merge

@ghost
Copy link

ghost commented Jan 28, 2021

Trying merge.

@ghost ghost merged commit 64df2f9 into master Jan 28, 2021
@ghost ghost deleted the bkchr-slot-type branch January 28, 2021 19:44
ghost pushed a commit to paritytech/polkadot that referenced this pull request Jan 28, 2021
* Companion for #7997

paritytech/substrate#7997

* rename slot_number to slot

* rename SlotNumber type in overseer docs

* "Update Substrate"

Co-authored-by: André Silva <[email protected]>
Co-authored-by: parity-processbot <>
s3krit pushed a commit to paritytech/polkadot that referenced this pull request Jan 29, 2021
* Companion for #7997

paritytech/substrate#7997

* rename slot_number to slot

* rename SlotNumber type in overseer docs

* "Update Substrate"

Co-authored-by: André Silva <[email protected]>
Co-authored-by: parity-processbot <>
ggwpez pushed a commit to ggwpez/runtimes that referenced this pull request Mar 10, 2023
* Companion for #7997

paritytech/substrate#7997

* rename slot_number to slot

* rename SlotNumber type in overseer docs

* "Update Substrate"

Co-authored-by: André Silva <[email protected]>
Co-authored-by: parity-processbot <>
ggwpez pushed a commit to ggwpez/runtimes that referenced this pull request Jul 13, 2023
* Companion for #7997

paritytech/substrate#7997

* rename slot_number to slot

* rename SlotNumber type in overseer docs

* "Update Substrate"

Co-authored-by: André Silva <[email protected]>
Co-authored-by: parity-processbot <>
This pull request was closed.
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. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants