-
Notifications
You must be signed in to change notification settings - Fork 13
perf(contract): contract should not store full attestation submission #1663
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
base: main
Are you sure you want to change the base?
perf(contract): contract should not store full attestation submission #1663
Conversation
barakeinav1
left a comment
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.
overall look good,
I requested some changes (mainly nits, typo name etc..) ,
I also think you should add another test: (I didn't see something like it)
#[test]
fn re_verify_fails_after_allowed_hash_is_cleaned_up() {
// 1. Add allowed MPC hash H1 at time T0
// 2. Add participant attested with H1
// 3. Add new MPC hash H2 (upgrade)
// 4. Advance time > tee_upgrade_deadline_duration
// 5. cleanup_expired_hashes removes H1
// 6. re_verify_tee_participant fails
}
barakeinav1
left a comment
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.
approving with some comments to be address
We already have integration tests in place. |
netrome
left a comment
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.
A few blockers. We should understand better what's costing so much gas. Beyond this, we need to figure out how to introduce this change in a compatible way.
|
Carved out flaky test fix into #1695 |
55f3aec to
d84382b
Compare
669c61c to
ee42690
Compare
…not-store-full-attestation-submission
netrome
left a comment
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 stuff, love all the tests!
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.
Pull request overview
This PR optimizes contract storage by storing only verified attestation metadata instead of full attestation submissions. When an attestation is verified, only the extracted hash values and expiration timestamp are stored on-chain as VerifiedAttestation, reducing storage costs significantly.
Changes:
- Introduced
VerifiedAttestationtype to store compact verification results instead of fullAttestationobjects - Added
re_verify()method to validate stored attestations without requiring full attestation data - Migrated from
IterableMaptoBTreeMapfor attestation storage with lazy cleanup pattern viaStaleData
Reviewed changes
Copilot reviewed 23 out of 24 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/mpc-attestation/src/attestation.rs | Added VerifiedAttestation enum and re_verify method, refactored verify to return VerifiedAttestation |
| crates/contract/src/tee/tee_state.rs | Changed storage from IterableMap to BTreeMap, updated verification methods to use VerifiedAttestation |
| crates/contract/src/lib.rs | Added StaleData container and migrate_clear_tee for lazy cleanup of old attestations |
| crates/contract-interface/src/types/attestation.rs | Added VerifiedAttestation and VerifiedDstackAttestation DTOs |
| crates/node/src/indexer/tx_sender.rs | Updated attestation comparison logic to work with VerifiedAttestation using freshness heuristics |
| crates/contract/src/v3_0_2_state.rs | Migration logic from v3.0.2 with mock attestation assignment |
| crates/contract/src/v3_2_0_state.rs | Migration logic from v3.2.0 with mock attestation assignment |
| crates/mpc-attestation/tests/test_attestation_verification.rs | Comprehensive test coverage for verify and re_verify functionality |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
closes #1629