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
[diem-framework] Add force shift event to CRSNs, add gate #9204
Conversation
31c2c8d
to
3030fb2
Compare
shift_amount: u64, | ||
/// The state of the bitvector just before the shift (NB: the sequence | ||
/// nonce of the shifting transaction will not be set). | ||
bits_at_shift: BitVector, |
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.
random thought: is there any reason why the BitVector uses a vector<bool>
? do we have a specialized compact serialization for that?
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.
nit: also maybe add a small comment on why we need the bits_at_shift
here, like "the bitvector state is needed to prove that a CRSN slot was expired and not already consumed; therefore, a user transaction at that slot can't exist (because that slot was expired)."
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.
random thought: is there any reason why the BitVector uses a vector? do we have a specialized compact serialization for that?
Good question. The underlying bitvector representation can be compacted (e.g., to use vec<u64>
), however verifying code that does computation around bitshifts is incredibly difficult, so there are issues with a more complex dense representation of these and we decided to go with vec<bool>
for now.
3030fb2
to
d933b7f
Compare
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.
LGTM!
} | ||
|
||
/// Whenever a force shift is performed a `ForceShiftEvent` is emitted. | ||
/// This is used to prove the absence of a transaction at a specific sequence nonce. | ||
struct ForceShiftEvent has drop, store { |
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.
Just to double check store
here is to work with the phantom type parameter in the event handle?
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.
Correct! it needs a T: drop + store
so this needs store
to match up with those restrictions.
/land |
* Be able to be turned on after release * To emit a `ForceShiftEvent` whenever a force shift event occurs Closes: diem#9204
Cluster Test Result
Repro cmd:
🎉 Land-blocking cluster test passed! 👌 |
d933b7f
to
5f9d241
Compare
This PR updates CRSNs to:
ForceShiftEvent
whenever a force shift event occursIt also adds tests to make sure that the gating is respected in the Framework, and that
ForceShiftEvents
are emitted when force shifting.