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

Historical queries: Handle large requests being truncated by the host #5026

Merged
merged 24 commits into from
Feb 20, 2023

Conversation

eddyashton
Copy link
Member

@eddyashton eddyashton commented Feb 17, 2023

This fixes a bug in the historical query system.

It assumed that any ledger_get_range(from, to) write to the host ringbuffer would result in a corresponding ledger_entry_range(from, to) or ledger_no_entry_range(from, to) response from the (honest) host. This is not the case - the host applies a max_size cap since #3986 to avoid producing writes larger than the ringbuffer can handle, so it may in fact respond with ledger_entry_range(from, to_) (with to_ < to). This PR makes the in-enclave historical query system robust to that - able to handle partial answers, and re-request entries which weren't provided.

This requires a significant rewrite of the historical query book keeping, to decouple slightly the Stores from the specific Request which triggered their fetch (with a side benefit that they are now better at sharing Stores between multiple Requests, without needing to refetch).

There's some knock-on changes in unit tests, a new unit test simulating the original issue, and some associated changes in the host-side ledger.h (removing the now-unnecessary strict mode, and ensuring that read responses correctly describe the prefix they contain).

Opening as a draft initially so I can let the CI find any tests I've missed, will open for review once I've done another cleanup pass.

@ghost
Copy link

ghost commented Feb 17, 2023

ledger_fetch_completeness@65363 aka 20230220.58 vs main ewma over 20 builds from 64799 to 65360

Click to see table

main

build_id build_number Commit latency factor tpcc_virtual_cft^ ls_virtual_cft^ tpcc_sgx_cft^ tpcc_sgx_cft_mem pi_ls_virtual_cft^ ls_jwt_virtual_cft^ pi_ls_jwt_virtual_cft^ ls_js_virtual_cft^ ls_sgx_cft^ ls_sgx_cft_mem ls_full_js_virtual_cft^ pi_ls_sgx_cft^ pi_ls_sgx_cft_mem ls_jwt_sgx_cft^ ls_jwt_sgx_cft_mem ls_js_jwt_virtual_cft^ pi_ls_jwt_sgx_cft^ pi_ls_jwt_sgx_cft_mem ls_js_sgx_cft^ ls_js_sgx_cft_mem hist_sgx_cft^ ls_full_js_sgx_cft^ ls_full_js_sgx_cft_mem ls_js_jwt_sgx_cft^ ls_js_jwt_sgx_cft_mem RB put (/s)^ CHAMP put (/s)^ RB get (/s)^ CHAMP get (/s)^
64799 20230215.3 0.807861 17261.3 43640 6335.58 8.21863e+07 43435 12896.8 13585.8 4449.59 15750.7 1.50774e+07 3697.28 16239.5 7.99955e+06 5588.27 1.45532e+07 3276.83 5781 4.59168e+06 1541.92 7.73741e+06 24722 1343.38 7.21312e+06 1264.93 6.95098e+06 832332 1.17278e+06 8.16626e+06 3.02038e+07
64809 20230215.5 0.790794 17202 43594 5629.08 8.32349e+07 48117.9 12763 13902.6 4267.53 15673.5 1.50774e+07 3704.86 16017.5 7.99955e+06 5486.91 1.4291e+07 3290.13 5695.2 4.59168e+06 1521.39 7.73741e+06 22323.6 1322.02 7.21312e+06 1242.03 6.95098e+06 837679 1.17577e+06 8.17398e+06 3.06702e+07
64852 20230215.17 0.824987 17232.2 45638.3 5629.37 8.27106e+07 47234.2 12526.5 13736.5 4456.46 15439.3 1.50774e+07 3824.49 16089.8 7.99955e+06 5499.13 1.4291e+07 3450.71 5675.4 4.32954e+06 1511.9 7.73741e+06 23789.1 1322.14 7.21312e+06 1243.14 6.95098e+06 827865 1.18e+06 8.1604e+06 3.07558e+07
64894 20230215.27 0.810496 17153.9 45602.4 6264.75 8.24484e+07 49496.4 14005.7 13656.9 4561.86 15725.8 1.50774e+07 3817.48 16134.8 7.99955e+06 5610.13 1.48153e+07 3389.96 5730.5 4.59168e+06 1524.14 7.73741e+06 26877.7 1336.93 7.73741e+06 1260.78 6.95098e+06 828126 1.17502e+06 8.13279e+06 3.12796e+07
64917 20230215.36 0.796886 17145.5 45429.3 6278.39 8.19242e+07 47658.8 13972.5 14052.7 4553.6 15840.7 1.53396e+07 3733.84 16206.8 7.99955e+06 5810.05 1.48153e+07 3337.61 5812.2 4.59168e+06 1537.98 7.73741e+06 24779 1346.66 7.73741e+06 1273.01 6.95098e+06 821215 1.17669e+06 8.15556e+06 3.07928e+07
64948 20230216.3 0.783009 17178 45750 6287.21 8.21863e+07 49027.8 14009.7 13936.5 4503.11 15838.4 1.50774e+07 3793.64 16212.3 7.99955e+06 5818.07 1.4291e+07 3282.85 5844.2 4.59168e+06 1545.93 7.73741e+06 27272.6 1344.14 7.73741e+06 1272.54 6.95098e+06 839665 1.17924e+06 8.15611e+06 3.08894e+07
64952 20230216.5 0.768871 17116.4 43669.6 6286.94 8.24484e+07 47447.8 12312.6 13598.8 4334.54 15819.2 1.56017e+07 3831.55 16253.2 7.99955e+06 5825.43 1.45532e+07 3312.9 5818.4 4.32954e+06 1538.3 7.73741e+06 26809.9 1339.01 7.21312e+06 1265.91 6.95098e+06 834929 1.17923e+06 8.17408e+06 3.07364e+07
64973 20230216.11 0.77964 17120.9 43716.3 6291.12 8.21863e+07 47752.5 12735.6 13741.2 4479.68 15851.9 1.50774e+07 3830.47 16226 7.99955e+06 5801.55 1.48153e+07 3381.61 5781.5 4.32954e+06 1543.72 7.73741e+06 23430.1 1344.64 7.47526e+06 1270.49 6.95098e+06 838175 1.18161e+06 8.15231e+06 3.20411e+07
65000 20230216.21 0.791976 17402.4 45903.7 6244.39 8.21863e+07 48696.4 12287.2 13913.3 4518.9 15831.9 1.53396e+07 3823.86 16219.6 7.99955e+06 5807.03 1.4291e+07 3326.67 5741 4.59168e+06 1541.3 7.73741e+06 25013.4 1342.64 7.47526e+06 1252.44 6.95098e+06 826814 1.18231e+06 8.14768e+06 3.0816e+07
65057 20230217.2 0.792405 17143.9 43472.8 6298.6 8.1662e+07 47341.8 12267.5 13581.4 4570.79 15797.7 1.53396e+07 3794.33 16214.4 7.99955e+06 5848.79 1.48153e+07 3343.63 5771.2 4.59168e+06 1533.25 7.73741e+06 24269.4 1343.02 7.47526e+06 1271.08 6.95098e+06 834024 1.17337e+06 8.15102e+06 3.11379e+07
65074 20230217.9 0.81627 17115.8 43374.6 6302.69 8.24484e+07 46781.9 12504.5 13214.1 4459.26 15868.3 1.50774e+07 3689.68 16189.8 7.99955e+06 5848.61 1.48153e+07 3303.34 5777.8 4.59168e+06 1544.66 7.47526e+06 23233.3 1347.63 7.21312e+06 1270.05 6.95098e+06 831493 1.17746e+06 8.12637e+06 2.99999e+07
65094 20230217.15 0.799868 17107.3 43627.7 6279.58 8.21863e+07 47369.6 12531.7 12954.4 4443.61 15853.7 1.50774e+07 3794.98 16109.3 7.99955e+06 5824.51 1.4291e+07 3298.82 5771.8 4.59168e+06 1535.17 7.73741e+06 23284.4 1339.94 7.47526e+06 1262.97 6.95098e+06 820841 1.17776e+06 8.15576e+06 3.0816e+07
65127 20230217.23 0.772319 17159.6 45685.4 6304.64 8.21863e+07 48339.6 12414.1 13299.5 4474.02 15794 1.53396e+07 3793.01 16205.2 7.99955e+06 5823.32 1.48153e+07 3321.86 5762.6 4.32954e+06 1536.84 7.73741e+06 23236.5 1344.99 7.99955e+06 1257.52 6.95098e+06 829509 1.18355e+06 8.15563e+06 1.80705e+07
65176 20230220.3 0.797649 17153.3 45743.2 6334.96 8.21863e+07 47322.9 14029.3 13336.5 4508.1 15951.9 1.53396e+07 3817.48 16177.7 7.99955e+06 5847.47 1.48153e+07 3436.64 5777.7 4.32954e+06 1541.22 7.73741e+06 27095.5 1339.48 7.73741e+06 1266.79 6.95098e+06 829340 1.18169e+06 8.13528e+06 3.1386e+07
65208 20230220.10 0.813333 17090.1 45699.5 6265.97 8.1662e+07 46507.7 12734.8 13047.5 4468.94 15781.1 1.50774e+07 3829.31 16117.6 7.99955e+06 5828.24 1.45532e+07 3471.39 5744.7 4.32954e+06 1525.75 7.73741e+06 24377.9 1338.49 7.21312e+06 1258.13 6.95098e+06 838175 1.18477e+06 8.17043e+06 3.11502e+07
65264 20230220.23 0.832354 17117.1 45651.8 6328.02 8.19242e+07 46536.8 12556.4 13765.6 4614.39 15849.9 1.50774e+07 3841.53 16163 7.99955e+06 5803.89 1.4291e+07 3325.78 5772 4.59168e+06 1547.61 7.73741e+06 25293.7 1347.67 7.47526e+06 1267.89 6.95098e+06 831007 1.1823e+06 8.15264e+06 3.14574e+07
65297 20230220.36 0.776059 17137.5 43485.7 6214.08 8.21863e+07 48684.1 12609.5 12995.1 4601.13 15781 1.50774e+07 3785.65 16120.1 7.99955e+06 5806.92 1.4291e+07 3342.19 5774.8 4.59168e+06 1545.31 7.73741e+06 26840.3 1342.31 7.21312e+06 1269.29 6.95098e+06 837789 1.17789e+06 8.15511e+06 3.11663e+07
65333 20230220.49 0.78117 17354 46065.2 6337.38 8.21863e+07 48488.6 12595.2 13267.3 4608.39 15893.5 1.50774e+07 3807.96 16090.4 7.99955e+06 5816.8 1.4291e+07 3326.69 5783.2 4.59168e+06 1537.46 7.73741e+06 24615.3 1341.82 7.47526e+06 1263.85 6.95098e+06 826783 1.17968e+06 8.15546e+06 3.2511e+07
65344 20230220.53 0.814576 17204.5 43495.4 5668.99 8.24484e+07 48698 11587.4 13082.3 4350.65 15460.6 1.50774e+07 3831.07 15994.7 7.99955e+06 5771.4 1.4291e+07 3287.52 5731.8 4.32954e+06 1520.95 7.47526e+06 26614.8 1334.52 7.21312e+06 1248.25 6.95098e+06 831370 1.17115e+06 8.15238e+06 3.07595e+07
65360 20230220.56 0.823358 17109.3 43630.2 6300.6 8.21863e+07 48383.2 12866.6 12843.1 4385.46 15709 1.50774e+07 3725.49 16076.9 7.99955e+06 5790.45 1.4291e+07 3323.02 5738.8 4.59168e+06 1543.25 7.73741e+06 23152.6 1328.52 7.21312e+06 1266.23 6.95098e+06 832056 1.17678e+06 8.15076e+06 3.07933e+07

ledger_fetch_completeness

build_id build_number Commit latency factor tpcc_virtual_cft^ ls_virtual_cft^ tpcc_sgx_cft^ tpcc_sgx_cft_mem pi_ls_virtual_cft^ ls_jwt_virtual_cft^ pi_ls_jwt_virtual_cft^ ls_js_virtual_cft^ ls_sgx_cft^ ls_sgx_cft_mem ls_full_js_virtual_cft^ pi_ls_sgx_cft^ pi_ls_sgx_cft_mem ls_js_jwt_virtual_cft^ ls_jwt_sgx_cft^ ls_jwt_sgx_cft_mem pi_ls_jwt_sgx_cft^ pi_ls_jwt_sgx_cft_mem ls_js_sgx_cft^ ls_js_sgx_cft_mem hist_sgx_cft^ ls_full_js_sgx_cft^ ls_full_js_sgx_cft_mem ls_js_jwt_sgx_cft^ ls_js_jwt_sgx_cft_mem RB put (/s)^ CHAMP put (/s)^ RB get (/s)^ CHAMP get (/s)^
65154 20230217.33 0.787096 17120.1 43437.5 5617.83 8.32349e+07 46158.7 12412.2 12965.1 4631.52 15413.4 1.50774e+07 3703.01 16057.4 7.99955e+06 3363.45 5537.17 1.45532e+07 5737.6 4.59168e+06 1534.2 7.73741e+06 48151.7 1328.06 7.47526e+06 1253.96 6.95098e+06 832099 1.17699e+06 8.14745e+06 3.0772e+07
65276 20230220.25 0.788848 17108.7 45650 6293.18 8.21863e+07 49414.2 12609.3 13922.2 4477.06 15860.8 1.50774e+07 3835.19 16179.9 7.99955e+06 3325.86 5543.98 1.4291e+07 5777 4.59168e+06 1538.4 7.73741e+06 46332 1338.7 7.21312e+06 1266.13 6.95098e+06 824196 1.18233e+06 8.17431e+06 3.07924e+07
65284 20230220.29 0.802381 17156.7 46017.5 5652.11 8.27106e+07 47634.7 12393.6 12953.3 4557.77 15443.7 1.50774e+07 3827.91 15452.2 7.99955e+06 3319.13 5557.05 1.48153e+07 5740.8 4.32954e+06 1524.72 7.73741e+06 46024.2 1322.56 7.21312e+06 1246.2 6.95098e+06 838497 1.17931e+06 8.1265e+06 3.10567e+07
65318 20230220.42 0.792441 17384 41737 6267.29 8.21863e+07 48182.8 12511.5 12813.1 4478.39 15778.6 1.50774e+07 3747.57 16113.5 7.99955e+06 3294.07 5788.43 1.4291e+07 5764.2 4.32954e+06 1533.91 7.73741e+06 45164.7 1341.77 7.73741e+06 1268.51 6.95098e+06 824047 1.17699e+06 8.1542e+06 3.10435e+07
65363 20230220.58 0.793017 17156.9 45763.6 6314.46 8.19242e+07 48037.7 12557 12960.4 4354.87 15816.4 1.50774e+07 3843.53 16106.3 7.99955e+06 3457.83 5806.92 1.4291e+07 5722.2 4.59168e+06 1537.96 7.73741e+06 46224.7 1339.28 7.47526e+06 1260.25 6.95098e+06 827545 1.18202e+06 8.15313e+06 3.08081e+07

images

@eddyashton eddyashton marked this pull request as ready for review February 20, 2023 14:00
@eddyashton eddyashton requested a review from a team February 20, 2023 14:00
Copy link
Contributor

@jumaffre jumaffre left a comment

Choose a reason for hiding this comment

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

Can we kick off the Daily CI on this PR too, that will cover a few more scenarios using recoveries, historical queries, etc., especially as part of the full test suite?

@achamayou achamayou added 2.x-todo PRs which should be backported to 2.x auto-backport Automatically backport this PR to LTS branch 3.x-todo PRs which should be backported to 3.x labels Feb 20, 2023
@achamayou achamayou enabled auto-merge (squash) February 20, 2023 17:13
@achamayou achamayou merged commit 042cb8f into microsoft:main Feb 20, 2023
github-actions bot pushed a commit that referenced this pull request Feb 20, 2023
@github-actions
Copy link

💔 All backports failed

Status Branch Result
release/2.x Backport failed because of merge conflicts
release/3.x Could not create pull request: GitHub Actions is not permitted to create or approve pull requests.

Manual backport

To create the backport manually run:

backport --pr 5026

Questions ?

Please refer to the Backport tool documentation and see the Github Action logs for details

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.x-todo PRs which should be backported to 2.x 3.x-todo PRs which should be backported to 3.x auto-backport Automatically backport this PR to LTS branch backported This PR was successfully backported to LTS branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants