-
Notifications
You must be signed in to change notification settings - Fork 22
Pr/step 1 init setup & ADR 001: Relationship State Machine #240
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?
Pr/step 1 init setup & ADR 001: Relationship State Machine #240
Conversation
Signed-off-by: Jackylee2233 <[email protected]>
v0.3.5 被 didwebvh-rs v0.1.9 直接依賴
v0.4.0 被 affinidi-data-integrity v0.2.4 依賴,而後者又被 didwebvh-rs v0.1.9 依賴
項目通過編譯及全部測試通過:
cargo test
Compiling serde_json v1.0.145
Compiling sqlx-core v0.8.6
Compiling serde_with_macros v3.16.0
Compiling quinn v0.11.9
Compiling serde_with v3.16.0
Compiling affinidi-secrets-resolver v0.4.0
Compiling serde_json_canonicalizer v0.3.1
Compiling reqwest v0.12.24
Compiling affinidi-data-integrity v0.2.4
Compiling sqlx-sqlite v0.8.6
Compiling didwebvh-rs v0.1.10
Compiling sqlx v0.8.6
Compiling askar-storage v0.2.4
Compiling aries-askar v0.4.6
Compiling tsp_sdk v0.9.0-alpha2 (/home/qaoo8/Jobs/tsp/tsp_sdk)
Finished `test` profile [unoptimized + debuginfo] target(s) in 11.23s
Running unittests src/lib.rs (/home/qaoo8/Jobs/tsp/target/debug/deps/tsp_sdk-acbb1369351abb06)
running 56 tests
test cesr::packet::test::test_message_to_parts ... ignored
test cesr::packet::test::envelope_without_confidential_data ... ok
test cesr::packet::test::envelope_without_nonconfidential_data ... ok
test cesr::packet::test::envelope_with_nonconfidential_data ... ok
test cesr::packet::test::envelope_failure ... ok
test cesr::packet::test::s_envelope_with_confidential_data_failure ... ok
test cesr::packet::test::test_nested_msg ... ok
test cesr::packet::test::test_decode_send_recv ... ok
test cesr::packet::test::test_3p_refer_rel ... ok
test cesr::packet::test::test_par_refer_rel ... ok
test cesr::packet::test::mut_envelope_with_nonconfidential_data ... ok
test cesr::packet::test::trailing_data ... ok
test cesr::packet::test::test_relation_forming ... ok
test cesr::packet::test::test_routed_msg ... ok
test cesr::test::demo_example ... ok
test cesr::test::decode_and_encode ... ok
test cesr::test::dont_gen_overlong_encoding ... ok
test cesr::test::encode_and_decode ... ok
test cesr::test::identifier_failure_3 - should panic ... ok
test cesr::test::identifier_failure_1 - should panic ... ok
test cesr::test::identifier_failure_variable - should panic ... ok
test cesr::test::identifier_failure_2 - should panic ... ok
test cesr::test::index_failure - should panic ... ok
test cesr::test::long_variable_data ... ok
test cesr::test::test_primitives ... ok
test store::test::test_add_verified_vid ... ok
test store::test::test_add_private_vid ... ok
test store::test::test_remove ... ok
test crypto::tests::seal_open_message ... ok
test store::test::test_make_relationship_request ... ok
test store::test::test_open_seal ... ok
test store::test::test_make_new_identity ... ok
test store::test::test_make_referral ... ok
test store::test::test_make_relationship_accept ... ok
test store::test::test_nested_manual ... ok
test secure_storage::test::test_vault ... ok
test vid::deserialize::test::deserialize ... ok
test store::test::test_make_relationship_cancel ... ok
test vid::did::web::tests::test_resolve_document ... ok
test vid::did::peer::test::encode_decode ... ok
test vid::did::web::tests::test_resolve_url ... ok
test vid::did::webvh::tests::test_create_webvh_success ... ok
test store::test::test_routed ... ok
test store::test::test_nested_automatic_setup ... ok
test transport::tls::tests::test_tls_transport ... ok
test transport::quic::tests::test_quic_transport ... ok
test test::test_large_messages ... ok
test test::test_anycast ... ok
test test::test_direct_mode ... ok
test test::test_nested_mode ... ok
test test::test_relation_forming ... ok
test test::test_routed_mode ... ok
test test::test_unverified_receiver_in_direct_mode ... ok
test transport::tcp::test::test_tcp_transport ... ok
test cesr::test::too_long_data_failure - should panic ... ok
test test::attack_failures ... ok
test result: ok. 55 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out; finished in 1.52s
Doc-tests tsp_sdk
running 4 tests
test tsp_sdk/src/lib.rs - (line 29) ... ok
test tsp_sdk/src/async_store.rs - async_store::AsyncSecureStore (line 22) ... ok
test tsp_sdk/src/async_store.rs - async_store::AsyncSecureStore::send_relationship_request (line 282) ... ok
test tsp_sdk/src/async_store.rs - async_store::AsyncSecureStore::send (line 213) ... ok
test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 1.22s
all doctests ran in 2.49s; merged doctests compilation took 1.21s
Signed-off-by: Jackylee2233 <[email protected]>
Signed-off-by: Jackylee2233 <[email protected]>
Signed-off-by: Jackylee2233 <[email protected]>
… test wallet files, and add a `dead_code` property to the `PendingRequest` struct / 增加 CLI 测试超时时间以提高稳定性,并清理旧的测试钱包文件,同时为 PendingRequest 结构体添加 dead_code 属性。 Signed-off-by: Jackylee2233 <[email protected]>
Signed-off-by: JackyLee <[email protected]>
|
Thanks @Jackylee2233 for the PR. Here are my preliminary feedback for each of the issues separately. Let's assume the local endpoint is Alice and the remote endpoint is Bob. (1) the state "ReverseUnidirectional". (2) Concurrency when two relationship requests collide <A,B> and <B,A>, if both use the same VID pair exactly. (3) Timeout from Unidirectional to Unrelated (4) Idempotency in handling TSP relationship messages Final note: Could you please rewrite commit messages in English to be consistent with the rest of the project? AI translates are perfectly ok. |
ADR 001: Relationship State Machine
Status
Proposed
Context
The current TSP SDK implementation lacks a formal state machine for managing relationship lifecycles. This leads to several issues:
ReverseUnidirectionalstatus is defined but rarely used, leading to ambiguity when a node receives a relationship request.Unidirectionalstate, with no clear resolution path.Decision
We will implement a formal
RelationshipMachineto govern state transitions.1. State Machine Definition
The state machine will transition based on
RelationshipEvents.UnrelatedSendRequestUnidirectionalthread_idUnrelatedReceiveRequestReverseUnidirectionalthread_idUnidirectionalReceiveAcceptBidirectionalthread_idmatches.ReverseUnidirectionalSendAcceptBidirectionalthread_idmatches.BidirectionalSendCancelUnrelatedBidirectionalReceiveCancelUnrelatedUnidirectionalSendRequestUnidirectionalUnidirectionalReceiveRequest2. Concurrency Handling
When a node in
Unidirectionalstate (sent a request) receives aRequestRelationshipfrom the target (meaning they also sent a request):thread_ids: The request with the lowerthread_id(lexicographically) wins.thread_id< theirthread_id: I ignore their request (or reject it). I expect them to accept my request.thread_id> theirthread_id: I accept their request. I cancel my pending request state and transition toReverseUnidirectional(effectively accepting their flow).3. Timeout & Retry
request_timeoutfield will be added toVidContext. If aUnidirectionalstate persists beyond the timeout (e.g., 60s), it transitions back toUnrelated.4. Idempotency
ReverseUnidirectionalorBidirectionaland receive the sameRequestRelationship(samethread_id), ignore it or resend the previous response.Bidirectionaland receiveAcceptRelationshipwith the samethread_id, ignore it.Consequences
store.rslogic will become more complex.