chore: index nodes by account id & TLS key in TEE State#1120
chore: index nodes by account id & TLS key in TEE State#1120kevindeforth merged 11 commits intomainfrom
Conversation
20bc1a7 to
c972361
Compare
| pub fn get_node_uids(&self) -> BTreeSet<NodeUid> { | ||
| self.participants() | ||
| .iter() | ||
| .map(|(account_id, _, p_info)| NodeUid { | ||
| account_id: account_id.clone(), | ||
| tls_public_key: p_info.sign_pk.clone(), | ||
| }) | ||
| .collect() | ||
| } |
There was a problem hiding this comment.
We don't "need" to have this test utility in the source code as part of a test-utils feature. Nothing here relies on private attributes or methods.
So we can define this impl extension or as a function in our test utilties, for example in common.rs.
6dbad1a to
3d13120
Compare
| /// TEE accounts for accounts that are no longer in the participant list. | ||
| /// This simulates cleanup after participant removal (e.g., post-resharing). | ||
| #[test] | ||
| fn test_clean_tee_status_removes_non_participants() { |
There was a problem hiding this comment.
Can be removed, this is almost a duplicate of the one in tee.rs
There was a problem hiding this comment.
👍🏼
Also, it was discussed offline: https://nearone.slack.com/archives/C0912BTG51T/p1758033418475589.
netrome
left a comment
There was a problem hiding this comment.
I'd like to keep using testing_env! over the sandbox environment for the kickout and cleanup tests.
| } | ||
|
|
||
| Ok(false) | ||
| Ok(true) |
There was a problem hiding this comment.
Nice. I assume we have test coverage for this bug now but didn't in the past? Or did you just notice this on the fly?
There was a problem hiding this comment.
Makes you wonder what the point of these return values are if we never get them back anyway on the node :')
There was a problem hiding this comment.
We do have test coverage now, yes. But didn't before.
Edit: in fact, we tested the wrong behavior:
There was a problem hiding this comment.
I mean that the return value will never be observed by the node who is responsible for calling this method. So the return value doesn't serve any purpose.
There was a problem hiding this comment.
I mean that the return value will never be observed by the node who is responsible for calling this method. So the return value doesn't serve any purpose.
Hmm, IMO, the fact that the node doesn't track the transaction outcome does not invalidate that our methods return values. They can still be inspected in our testing frameworks and are observable through manual inspection on Nearblocks
But I do think that it would be much desired for our nodes to track return values as well.
There was a problem hiding this comment.
The tests in expired_attestation.rs need to be kept. They are not the same as the one in tee.rs
The one in tee.rs tests that the [private] attribute is set, I.E. only the contract can call the methods.
The tests in expired_attestation.rs were just added today. They test the flow of cleanups after resharing work as a result of resharing through expired attestations.
CC: @pbeza as he has more context as author of these tests
@DSharifi, my GitHub username is @pbeza. :)
I agree with @DSharifi, nothing much to add. From my perspective, these are two different tests (though somewhat similar, especially |
We keep this one: mpc/libs/chain-signatures/contract/tests/expired_attestation.rs Lines 74 to 176 in 95649d0 but we remove mpc/libs/chain-signatures/contract/tests/expired_attestation.rs Lines 178 to 241 in 95649d0 which tests the same thing as mpc/libs/chain-signatures/contract/tests/tee.rs Lines 331 to 392 in 95649d0
Yes, but that is a different test to the one we are discussing and irrelevant for this PR. You are referring to this test here: mpc/libs/chain-signatures/contract/tests/tee.rs Lines 300 to 329 in 95649d0
Not exactly. The tests in Edit: |
|
OK, I re-read the implementation of both:
These tests are quite similar conceptually (with some minor differences, like the number of participants and checking that only the contract can call the I’m not sure I follow why there’s so much insistence on removing one of them (sorry, I haven’t spent too much time looking into the context of this PR yet), but from my perspective I think this discussion might never have started if I hadn’t followed this suggestion, where I refactored a single test into two separate ones—one of which now looks very similar to the one in mpc/libs/chain-signatures/contract/tests/expired_attestation.rs Lines 134 to 146 in 68a67cc which you might not even have noticed, so it wouldn’t have raised any suspicion. :P Also, note that I had already pointed out in this comment, before this whole discussion started, that |
b44643a to
2c51fd8
Compare
2c51fd8 to
8ca6f35
Compare
netrome
left a comment
There was a problem hiding this comment.
Thank you for updating 🙏 ! Would be great if we could get this through now.
| .build()); | ||
|
|
||
| assert!(!setup.contract.verify_tee().unwrap()); | ||
| assert!(setup.contract.verify_tee().unwrap()); |
There was a problem hiding this comment.
Hmm flipping this assertion does reduce what we're able to test here. As we discussed, we should extend the return value of verify_tee to convey whether or not all attestations are valid. However, we can do that later since this is technically a bug fix in the verify_tee method.
Resolves #1084, #1119 and #1145
Introduces
NodeUidas a unique identifier for participants nodes.Reasonable assumptions about the network state are:
AccountId(existing assumption).Participantsstruct).tls_public_key(not really enforceable on the contract).Note that the following give probabilistic guarantees for point 4, if nodes run inside TEEs:
Uncovered issues:
clean_tee_status#1118