-
Notifications
You must be signed in to change notification settings - Fork 550
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
Split Global_slot.t into since-genesis and since-hard-fork types #13143
Conversation
!ci-build-me |
!ci-build-me |
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.
That was a huge PR! Looks good,
@psteckler Would you be able to open issues wrt to spans/slots uses and wrt to this remark
|
|
!ci-build-me |
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.
Few minor suggestions. LGTM
src/lib/consensus/global_slot.ml
Outdated
T.sub t.slot_number | ||
(Mina_numbers.Global_slot_span.of_uint32 @@ T.to_uint32 t'.slot_number) |
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'm not sure I get why we need the conversion for t'
and not for t
as they have the same type so I was expecting this treatment to be symmetric (old code had no conversion whatsoever)
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.
T.sub
takes a slot and a span, so t'.slot_number
needed to be converted to a span.
T.sub
used to take a slot and another slot, but I think it makes more sense to subtract a span, in the same way Time
does.
But ( - )
isn't used anywhere, so I'm going to remove it. Its uses were replaced by diff_slots
, which takes the slots from two t
s, and returns a span.
src/lib/mina_base/account.ml
Outdated
let min_vesting_end = | ||
Global_slot_span.to_uint32 vesting_period | ||
|> Unsigned.UInt32.succ |> Global_slot_since_genesis.of_uint32 | ||
in |
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 don't know how many times this pattern occur but is it worth having succ
in Global_slot_span
too?
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.
It's there already. But this is an instance where a span is converted to a slot via uint32. The succ
could be done in the span, the uint32, or the slot, and I chose the uint32. I'll change it to do it in the span.
!ci-build-me |
!ci-build-me |
!ci-build-me |
!ci-build-me |
!ci-build-me |
!ci-build-me |
!ci-build-me |
!ci-build-me |
!ci-build-me |
!ci-build-me |
!approved-for-mainnet |
The following version change from mainnet type is actually to retain the old global slot type. Rest of the version changes are for V2 types or V1 types introduced for zkApps
|
Split
Mina_numbers.Global_slot.t
intoGlobal_slot_since_genesis.t
andGlobal_slot_since_hard_fork.t
. Add new typeGlobal_slot_span.t
for vesting periods, also used as for an argument toadd
andsub
. Although all these types as an unsigned 32-bit integer, none is compatible with the others, so they can't be confused in the code.The existing uses of
Global_slot.t
have been changed to the...since_genesis.t
type. Some of them very likely need to become uses of...since_hard_fork.t
.For V1
Signed_command
s, introduceGlobal_slot_legacy
, which is identical to the oldGlobal_slot
.There were places in the code where slots were being used both as slots, as such, and as spans. In this PR, that's handled by converting the values via
uint32
. Probably that code should be cleaned up to make those roles distinct.Closes #13058.