-
Notifications
You must be signed in to change notification settings - Fork 37
feat(contract): async TEE attestation verification, drop dcap-qvl
#3714
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
Changes from 6 commits
29dc047
16ce226
68837a1
43e3be6
79dc9fe
cde4a47
c21a4db
fd2291f
e15bc3d
74e9f72
5e4ea28
87937db
029f1d8
d9d5066
486d463
9c1a346
290b3dc
c1a8d07
b4fa873
6a6a1a9
9b0851e
6d27650
ee9f82e
8563815
aa46261
d11cb85
721dc6c
756c598
a44b6b2
64a3e94
8e75745
f2f470a
6d228ab
67d6388
de63ecf
43d1fb8
01d9cea
91a7891
2b4ea85
812488f
386d6cd
8ab4f4c
195d7b3
90693be
f950275
22b50b0
8710f65
28f9b90
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,6 +21,8 @@ const DEFAULT_RETURN_SIGNATURE_AND_CLEAN_STATE_ON_SUCCESS_CALL_TERA_GAS: u64 = 7 | |
| const DEFAULT_RETURN_CK_AND_CLEAN_STATE_ON_SUCCESS_CALL_TERA_GAS: u64 = 7; | ||
| /// Prepaid gas for a `fail_on_timeout` call | ||
| const DEFAULT_FAIL_ON_TIMEOUT_TERA_GAS: u64 = 2; | ||
| /// Prepaid gas for a `fail_attestation_submission` call | ||
| const DEFAULT_FAIL_ATTESTATION_SUBMISSION_TERA_GAS: u64 = 2; | ||
| /// Prepaid gas for a `clean_tee_status` call | ||
| const DEFAULT_CLEAN_TEE_STATUS_TERA_GAS: u64 = 10; | ||
| /// Prepaid gas for the reshare-time `clean_invalid_attestations` promise. | ||
|
|
@@ -34,6 +36,15 @@ const DEFAULT_REMOVE_NON_PARTICIPANT_UPDATE_VOTES_TERA_GAS: u64 = 5; | |
| const DEFAULT_CLEAN_FOREIGN_CHAIN_DATA_TERA_GAS: u64 = 5; | ||
| /// Prepaid gas for a `remove_non_participant_tee_verifier_votes` call | ||
| const DEFAULT_REMOVE_NON_PARTICIPANT_TEE_VERIFIER_VOTES_TERA_GAS: u64 = 5; | ||
| /// Gas attached to the cross-contract `verify_quote` call on the TEE verifier. | ||
| const DEFAULT_VERIFIER_TERA_GAS: u64 = 100; | ||
| /// Prepaid gas for the `resolve_verification` callback. Carries the bulk of the | ||
| /// post-DCAP work (allowlist match, RTMR3 replay, app-compose validation, store). | ||
| const DEFAULT_RESOLVE_VERIFICATION_TERA_GAS: u64 = 60; | ||
|
Comment on lines
+39
to
+43
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. note: That's expensive. How does it compare to the current costs?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I never benchmarked it, and I think we have quite a few other unbenchmarked constants too, for example here: #3641 (comment), although that one is in the e2e tests. I’d defer this to #3715 (noted here), where I added the tests. Perhaps we can benchmark it there, or in a follow-up if it’s not trivial. |
||
| /// Prepaid gas for the `on_attestation_verified` yield-callback. Sized for its | ||
| /// heaviest (timeout) branch, which removes the pending entry and schedules both | ||
| /// a refund transfer and the `fail_attestation_submission` promise. | ||
| const DEFAULT_ON_ATTESTATION_VERIFIED_TERA_GAS: u64 = 10; | ||
|
|
||
| /// Config for V2 of the contract. | ||
| #[near(serializers=[borsh, json])] | ||
|
|
@@ -56,6 +67,8 @@ pub(crate) struct Config { | |
| pub(crate) return_ck_and_clean_state_on_success_call_tera_gas: u64, | ||
| /// Prepaid gas for a `fail_on_timeout` call. | ||
| pub(crate) fail_on_timeout_tera_gas: u64, | ||
| /// Prepaid gas for a `fail_attestation_submission` call. | ||
| pub(crate) fail_attestation_submission_tera_gas: u64, | ||
| /// Prepaid gas for a `clean_tee_status` call. | ||
| pub(crate) clean_tee_status_tera_gas: u64, | ||
| /// Prepaid gas for the reshare-time `clean_invalid_attestations` promise. | ||
|
|
@@ -68,6 +81,12 @@ pub(crate) struct Config { | |
| pub(crate) clean_foreign_chain_data_tera_gas: u64, | ||
| /// Prepaid gas for a `remove_non_participant_tee_verifier_votes` call. | ||
| pub(crate) remove_non_participant_tee_verifier_votes_tera_gas: u64, | ||
| /// Gas attached to the cross-contract `verify_quote` call on the verifier. | ||
| pub(crate) verifier_tera_gas: u64, | ||
| /// Prepaid gas for the `resolve_verification` callback. | ||
| pub(crate) resolve_verification_tera_gas: u64, | ||
| /// Prepaid gas for the `on_attestation_verified` yield-callback. | ||
| pub(crate) on_attestation_verified_tera_gas: u64, | ||
| } | ||
|
|
||
| impl Default for Config { | ||
|
|
@@ -85,6 +104,7 @@ impl Default for Config { | |
| return_ck_and_clean_state_on_success_call_tera_gas: | ||
| DEFAULT_RETURN_CK_AND_CLEAN_STATE_ON_SUCCESS_CALL_TERA_GAS, | ||
| fail_on_timeout_tera_gas: DEFAULT_FAIL_ON_TIMEOUT_TERA_GAS, | ||
| fail_attestation_submission_tera_gas: DEFAULT_FAIL_ATTESTATION_SUBMISSION_TERA_GAS, | ||
| clean_tee_status_tera_gas: DEFAULT_CLEAN_TEE_STATUS_TERA_GAS, | ||
| clean_invalid_attestations_tera_gas: DEFAULT_CLEAN_INVALID_ATTESTATIONS_TERA_GAS, | ||
| cleanup_orphaned_node_migrations_tera_gas: | ||
|
|
@@ -94,6 +114,9 @@ impl Default for Config { | |
| clean_foreign_chain_data_tera_gas: DEFAULT_CLEAN_FOREIGN_CHAIN_DATA_TERA_GAS, | ||
| remove_non_participant_tee_verifier_votes_tera_gas: | ||
| DEFAULT_REMOVE_NON_PARTICIPANT_TEE_VERIFIER_VOTES_TERA_GAS, | ||
| verifier_tera_gas: DEFAULT_VERIFIER_TERA_GAS, | ||
| resolve_verification_tera_gas: DEFAULT_RESOLVE_VERIFICATION_TERA_GAS, | ||
| on_attestation_verified_tera_gas: DEFAULT_ON_ATTESTATION_VERIFIED_TERA_GAS, | ||
| } | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
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.
Heads-up — this default looks too low for real on-chain DCAP.
Testing this branch end-to-end on a real localnet TDX cluster (real dstack quotes, stock release-v3.13 node, this contract + the real
tee-verifier), attestation never gets through. The cross-contractverify_quotecall runs out of gas — the receipt fails withExceeded the prepaid gas, so realdcap_qvl::verifyseems to need more than 100 Tgas. After it OOGs the contract hitsverifier did not respond within the yield-resume window, thepending_attestationgets stuck, and every retry then fails withalready in flight— so no node becomes attested and keygen stalls.I don't know the exact figure yet — still testing to pin down how much DCAP actually needs (and whether it fits under the 300 Tgas tx cap once you add the resolve + callback gas). Flagging early. Note the sandbox tests in #3715 use the real verifier but only feed a malformed quote that's rejected at parse (≈no gas), so the expensive full-verification path that blows this budget isn't exercised.
Uh oh!
There was an error while loading. Please reload this page.
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 measured 173 Tgas, but we should probably use a higher number (note, that we max tag is 300, and we need at least 70 for the rest of the method, so 200-220 tgas sounds good) in case we want to upgrade the verifier without change the const.
just thinking out loud
updating the const is a config update vote, correct? so it should be easy enough to update it.
wandering if we should add this to the verifier contract id vote (so it can be done in one vote instead of 2), but I don't think this is crtical.
Uh oh!
There was an error while loading. Please reload this page.
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 used 200 tgas- and the test passed!
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.
Bumped it here: 90693be. ✅