Skip to content
Closed
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
face309
feat(contract): async TEE attestation verification via verifier contract
pbeza Jun 24, 2026
21ad01f
Merge remote-tracking branch 'origin/main' into 3642-wire-async-tee-a…
pbeza Jun 24, 2026
23d7782
refactor(contract): address review on async attestation flow
pbeza Jun 24, 2026
9128fc9
chore(contract): sort Cargo.toml dependencies
pbeza Jun 24, 2026
0dbc1e4
refactor(contract): address review round 2 on async attestation flow
pbeza Jun 24, 2026
b4d1020
chore: drop unused test-tee-verifier workspace dependency
pbeza Jun 24, 2026
f63cc6c
docs(contract): fix public-to-private intra-doc link in resolve_verif…
pbeza Jun 24, 2026
763ad19
test(contract): regenerate ABI snapshot for resolve_verification doc
pbeza Jun 24, 2026
3596b6a
refactor(contract): address review round 3 on async attestation flow
pbeza Jun 24, 2026
f3f08ec
Merge remote-tracking branch 'origin/main' into 3642-wire-async-tee-a…
pbeza Jun 24, 2026
c1ea4d7
chore: bump test-tee-verifier to 3.13.0 in Cargo.lock
pbeza Jun 24, 2026
2ae9481
docs(contract): use intra-doc links or prose for code refs, tighten w…
pbeza Jun 24, 2026
d029573
refactor(contract): inline single-use bindings in TEE attestation code
pbeza Jun 24, 2026
79a82d6
Merge remote-tracking branch 'origin/main' into 3642-wire-async-tee-a…
pbeza Jun 29, 2026
b70354d
refactor(contract): borrow dstack in finish_dstack_verify to drop a c…
pbeza Jun 29, 2026
c3803ef
refactor(contract): JSON-serialize the attestation yield-resume payload
pbeza Jun 29, 2026
7e1fd27
refactor(contract): drop V1 suffix from pending-attestations storage key
pbeza Jun 29, 2026
fbf3ec4
refactor(contract): drop data-presence expects in the resolve path
pbeza Jun 29, 2026
e91879e
refactor(contract): rename FinalOutcome to AttestationResult
pbeza Jun 29, 2026
4558a1d
refactor(contract): map AttestationSubmissionError via #[from], not a…
pbeza Jun 29, 2026
e4dd919
style(contract): rustfmt the add_mock_participant call site
pbeza Jun 29, 2026
18d1175
refactor(contract): de-negate caller_is_participant, tidy attestation…
pbeza Jun 29, 2026
da9848c
refactor(contract): drop the add_participant test dispatcher
pbeza Jun 30, 2026
6ff5e6c
refactor(contract): return ParticipantInsertion instead of a tuple
pbeza Jun 30, 2026
6c61840
refactor(contract): address review feedback on TEE attestation tests
pbeza Jun 30, 2026
46b8c46
Merge remote-tracking branch 'origin/main' into 3642-wire-async-tee-a…
pbeza Jun 30, 2026
ad7d6d4
fix(contract): restore wire-only StubResponse mirror and fix doc links
pbeza Jun 30, 2026
e6ea55b
test(contract): expect typed TlsKeyOwnedByOtherAccount error
pbeza Jun 30, 2026
39aa289
Merge remote-tracking branch 'origin/main' into 3642-wire-async-tee-a…
pbeza Jun 30, 2026
7f656c4
revert: undo unrelated import/em-dash churn in wycheproof tests
pbeza Jun 30, 2026
6defe3b
feat(contract): give fail_attestation_submission its own gas config
pbeza Jun 30, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ members = [
"crates/test-migration-contract",
"crates/test-parallel-contract",
"crates/test-port-allocator",
"crates/test-tee-verifier",
"crates/test-utils",
"crates/threshold-signatures",
"crates/tls",
Expand Down
5 changes: 4 additions & 1 deletion crates/contract/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ abi = [
"near-mpc-contract-interface/abi",
"mpc-attestation/abi",
"mpc-primitives/abi",
"tee-verifier-interface/borsh-schema",
"schemars",
]
# This is used when running `cargo clippy --all-features`, because otherwise `abi` feat will break compilation.
Expand All @@ -74,6 +75,7 @@ __abi-generate = ["abi", "near-sdk/__abi-generate"]

[dependencies]
assert_matches = { workspace = true }
attestation = { workspace = true }
blstrs = { workspace = true }
borsh = { workspace = true }
curve25519-dalek = { workspace = true }
Expand All @@ -87,7 +89,7 @@ k256 = { workspace = true, features = [
"arithmetic",
"expose-field",
] }
mpc-attestation = { workspace = true, features = ["local-verify"] }
mpc-attestation = { workspace = true }
mpc-primitives = { workspace = true }
near-account-id = { workspace = true, features = ["serde"] }
near-mpc-bounded-collections = { workspace = true }
Expand All @@ -102,6 +104,7 @@ rand = { workspace = true, optional = true }
serde = { workspace = true }
serde_json = { workspace = true }
serde_with = { workspace = true }
tee-verifier-interface = { workspace = true }
thiserror = { workspace = true }
threshold-signatures = { workspace = true, optional = true }

Expand Down
18 changes: 18 additions & 0 deletions crates/contract/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,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;
/// 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])]
Expand Down Expand Up @@ -68,6 +77,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 {
Expand All @@ -94,6 +109,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,
}
}
}
15 changes: 15 additions & 0 deletions crates/contract/src/dto_mapping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,15 @@ impl From<near_mpc_contract_interface::types::InitConfig> for Config {
if let Some(v) = config_ext.remove_non_participant_tee_verifier_votes_tera_gas {
config.remove_non_participant_tee_verifier_votes_tera_gas = v;
}
if let Some(v) = config_ext.verifier_tera_gas {
config.verifier_tera_gas = v;
}
if let Some(v) = config_ext.resolve_verification_tera_gas {
config.resolve_verification_tera_gas = v;
}
if let Some(v) = config_ext.on_attestation_verified_tera_gas {
config.on_attestation_verified_tera_gas = v;
}

config
}
Expand Down Expand Up @@ -519,6 +528,9 @@ impl From<&Config> for near_mpc_contract_interface::types::Config {
clean_foreign_chain_data_tera_gas: value.clean_foreign_chain_data_tera_gas,
remove_non_participant_tee_verifier_votes_tera_gas: value
.remove_non_participant_tee_verifier_votes_tera_gas,
verifier_tera_gas: value.verifier_tera_gas,
resolve_verification_tera_gas: value.resolve_verification_tera_gas,
on_attestation_verified_tera_gas: value.on_attestation_verified_tera_gas,
}
}
}
Expand Down Expand Up @@ -547,6 +559,9 @@ impl From<near_mpc_contract_interface::types::Config> for Config {
clean_foreign_chain_data_tera_gas: value.clean_foreign_chain_data_tera_gas,
remove_non_participant_tee_verifier_votes_tera_gas: value
.remove_non_participant_tee_verifier_votes_tera_gas,
verifier_tera_gas: value.verifier_tera_gas,
resolve_verification_tera_gas: value.resolve_verification_tera_gas,
on_attestation_verified_tera_gas: value.on_attestation_verified_tera_gas,
}
}
}
Expand Down
8 changes: 8 additions & 0 deletions crates/contract/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ pub enum TeeError {
"Due to previously failed TEE validation, the network is not accepting new requests at this point in time. Try again later."
)]
TeeValidationFailed,
#[error(
"A Dstack attestation verification is already in flight for this account; wait for it to finish before resubmitting."
)]
VerificationAlreadyPending,
#[error(
"No TEE verifier is configured yet. Participants must vote one in via vote_tee_verifier_change before Dstack attestations can be submitted."
)]
VerifierNotConfigured,
}

#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
Expand Down
Loading
Loading