-
Notifications
You must be signed in to change notification settings - Fork 37
feat(contract): auto-expire unused launcher image hashes #3564
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 37 commits
99f6904
d7c0c65
a8694aa
cb955fb
074a701
c435dc5
9759f11
d329413
13fbc1f
6e3039e
096dfb1
d725003
e80673a
07de77b
2aa024e
c95e32d
e1d8955
04254ac
37c0218
eb593e5
df57fd8
4485904
3fc93c7
883dfad
797407a
6ffd125
1748925
02a05c3
503a627
9cf1bd1
8591a21
9605e6e
446de39
791b06d
a657110
a74258b
87b6bc9
94a5fc5
ef6386d
118fbee
bf0148d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,6 +41,8 @@ const DEFAULT_VERIFIER_TERA_GAS: u64 = 200; | |
| /// 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; | ||
| /// Default TTL after which a launcher image hash unused by any participant is evicted. | ||
| pub(crate) const DEFAULT_LAUNCHER_HASH_UNUSED_TTL_SECONDS: u64 = 14 * 24 * 60 * 60; // 14 days | ||
|
|
||
| /// Config for V2 of the contract. | ||
| #[near(serializers=[borsh, json])] | ||
|
|
@@ -81,6 +83,8 @@ pub(crate) struct Config { | |
| pub(crate) verifier_tera_gas: u64, | ||
| /// Prepaid gas for the `resolve_verification` callback. | ||
| pub(crate) resolve_verification_tera_gas: u64, | ||
| /// TTL after which a launcher image hash unused by any participant is evicted. | ||
| pub(crate) launcher_hash_unused_ttl_seconds: u64, | ||
|
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. I see no test covering enlarging the
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.
Good point — added |
||
| } | ||
|
|
||
| impl Default for Config { | ||
|
|
@@ -110,6 +114,22 @@ impl Default for Config { | |
| 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, | ||
| launcher_hash_unused_ttl_seconds: DEFAULT_LAUNCHER_HASH_UNUSED_TTL_SECONDS, | ||
| } | ||
| } | ||
| } | ||
|
|
||
| impl Config { | ||
| /// Invariant: a launcher hash backing a still-valid attestation must never expire, | ||
| /// so its unused-TTL must be at least the attestation validity window. | ||
|
SimonRastikian marked this conversation as resolved.
|
||
| pub(crate) fn validate(&self) -> Result<(), &'static str> { | ||
| if self.launcher_hash_unused_ttl_seconds | ||
| < mpc_attestation::attestation::DEFAULT_EXPIRATION_DURATION_SECONDS | ||
| { | ||
| return Err( | ||
| "launcher_hash_unused_ttl_seconds must be >= DEFAULT_EXPIRATION_DURATION_SECONDS", | ||
| ); | ||
| } | ||
| Ok(()) | ||
| } | ||
| } | ||
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 am slightly concerned about us losing the capability of observing the expired hashes. Do we have any other way of doing so?
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.
Good point — filed #4047 to expose the launcher hashes' expiry off-chain (mirroring what
allowed_docker_image_hashes()already does), since it's a small API decision rather than in-scope here.