Skip to content
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] Implement CRSNs in the Diem Framework #8403

Closed
wants to merge 1 commit into from

Conversation

tzakian
Copy link
Contributor

@tzakian tzakian commented May 18, 2021

This PR implements CRSNs as defined in DIP-168, along with the transactions to opt-in to CRSNs, and force expire CRSNs.

This will need to be plumbed into the account prologue (CRSN::check) and epilogue (CRSN::record). But that will be done later in a separate PR.

Testing

Added a number of Move unit tests to the CRSN module

@@ -0,0 +1,310 @@
/// A module implementing conflict-resistant sequence numbers (CRSNs).
/// The specification, and formal description of the acceptance and rejection
/// criteria, force expiration and window shifting of CRSNs is described in DIP-168.
Copy link
Contributor

Choose a reason for hiding this comment

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

Hyperlink to the DIP could be useful (once it lands)

Copy link
Contributor

@sblackshear sblackshear left a comment

Choose a reason for hiding this comment

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

Looks pretty excellent to me! One related question: what is the migration plan for SlidingNonce?

/// The specification, and formal description of the acceptance and rejection
/// criteria, force expiration and window shifting of CRSNs is described in DIP-168.
module 0x1::CRSN {
use 0x1::BitVector::{Self, BitVector};
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can still call BitVector methods without the Self important (but could be wrong)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Still need the Self import in order to call BitVector functions -- this is similar to self imports in Rust.

language/diem-framework/modules/CRSN.move Outdated Show resolved Hide resolved
language/diem-framework/modules/CRSN.move Show resolved Hide resolved
language/diem-framework/modules/CRSN.move Outdated Show resolved Hide resolved
language/diem-framework/modules/CRSN.move Outdated Show resolved Hide resolved
@@ -0,0 +1,314 @@

Copy link
Contributor

Choose a reason for hiding this comment

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

File name looks wrong here--checked in by mistake?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Woops...I'll remove

@tzakian
Copy link
Contributor Author

tzakian commented May 18, 2021

What is the migration plan for SlidingNonce?

Good question. My thinking is:

  1. AOS publishes the CRSN, keep using sliding nonce and sequence numbers as they today (this should work fine).
  2. Switch over to using sequence nonces, and using those (so no longer using sequence numbers). Freeze all sliding nonce numbers sent to existing transaction scripts at 0 (sliding nonce does no checking/recording in this case).

Later on, we can update all of the scripts, and remove the sliding nonce module/remove the resource, but I think that would be better to be done separately from the switchover, otherwise step 2 will also involve switching to an entirely new set of scripts simultaneously.

What are your thoughts on this migration strategy?

@sblackshear
Copy link
Contributor

What are your thoughts on this migration strategy?

Yep, that sounds like a good plan to me! I was initially thinking that trying to combine the code might make sense, but I think having both + deprecating is much more sensible.

@tzakian
Copy link
Contributor Author

tzakian commented May 19, 2021

/land

@bors-libra bors-libra moved this from In Review to Queued in bors May 19, 2021
bors-libra pushed a commit that referenced this pull request May 19, 2021
@bors-libra bors-libra moved this from Queued to Testing in bors May 19, 2021
@github-actions
Copy link

Cluster Test Result

Test runner setup time spent 273 secs
Compatibility test results for land_280dd3b2 ==> land_765444da (PR)
1. All instances running land_280dd3b2, generating some traffic on network
2. First full node land_280dd3b2 ==> land_765444da, to validate new full node to old validator node traffic
3. First Validator node land_280dd3b2 ==> land_765444da, to validate storage compatibility
4. First batch validators (14) land_280dd3b2 ==> land_765444da, to test consensus and traffic between old full nodes and new validator node
5. First batch full nodes (14) land_280dd3b2 ==> land_765444da
6. Second batch validators (15) land_280dd3b2 ==> land_765444da, to upgrade rest of the validators
7. Second batch of full nodes (15) land_280dd3b2 ==> land_765444da, to finish the network upgrade, time spent 715 secs
all up : 890 TPS, 5115 ms latency, 6000 ms p99 latency, no expired txns, time spent 251 secs
Logs: http://kibana.ct-1-k8s-testnet.aws.hlw3truzy4ls.com/app/kibana#/discover?_g=(time:(from:'2021-05-19T00:33:24Z',to:'2021-05-19T00:57:25Z'))
Dashboard: http://grafana.ct-1-k8s-testnet.aws.hlw3truzy4ls.com/d/performance/performance?from=1621384404000&to=1621385845000
Validator 1 logs: http://kibana.ct-1-k8s-testnet.aws.hlw3truzy4ls.com/app/kibana#/discover?_g=(time:(from:'2021-05-19T00:33:24Z',to:'2021-05-19T00:57:25Z'))&_a=(columns:!(log),query:(language:kuery,query:'kubernetes.pod_name:"val-1"'),sort:!(!('@timestamp',desc)))

Repro cmd:

./scripts/cti --tag land_280dd3b2 --cluster-test-tag land_765444da -E BATCH_SIZE=15 -E UPDATE_TO_TAG=land_765444da --report report.json --suite land_blocking_compat

🎉 Land-blocking cluster test passed! 👌

@bors-libra
Copy link
Contributor

💔 Test Failed - ci-test

@bors-libra bors-libra moved this from Testing to In Review in bors May 19, 2021
@tzakian tzakian force-pushed the dense_sliding_nonce branch 3 times, most recently from f224348 to 91ddcc9 Compare May 19, 2021 18:31
@stale
Copy link

stale bot commented Jul 19, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale Stale Issue or PR. Used by probot/stale Github App label Jul 19, 2021
@stale stale bot closed this Jul 26, 2021
@bors-libra bors-libra removed this from In Review in bors Jul 26, 2021
@bob-wilson
Copy link
Contributor

@tzakian We should reopen this, right? (I'm not sure if it might have been copied to a different version of the PR or I would just do it myself.)

@tzakian
Copy link
Contributor Author

tzakian commented Aug 3, 2021

@tzakian We should reopen this, right? (I'm not sure if it might have been copied to a different version of the PR or I would just do it myself.)

@bob-wilson Good question. This PR has been rolled into #8528 so I'm planning on landing (/would prefer to land) these changes in that PR since there were some additional changes needed to make things work with mempool/prologue/epilogue that only work in context with the other changes. So I think keeping this PR closed makes sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed stale Stale Issue or PR. Used by probot/stale Github App
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants