feat(core): implement infosync#495
Conversation
|
@claude review this PR |
|
Claude finished @iamquang95's task in 2m 5s —— View job Review:
|
|
For 1, keep the current implementation for parity, and it's low enhancement |
varex83
left a comment
There was a problem hiding this comment.
LGTM overall! Only a few improvements could be made
| results.push(result); | ||
|
|
||
| if results.len() >= MAX_RESULTS { | ||
| results.remove(0); |
There was a problem hiding this comment.
This is O(n) operation, better to use deque here
There was a problem hiding this comment.
Agree for clarity mostly
| .expect("infosync results mutex poisoned"); | ||
|
|
||
| let mut resp = self.local_protocols.clone(); | ||
| for result in results.iter() { |
There was a problem hiding this comment.
Since slots in the results are in increasing order, we can make this search using binary search, which gives us O(n) -> O(log(n))
There was a problem hiding this comment.
Agree on making the change just for the sake of clarity.
| .expect("infosync results mutex poisoned"); | ||
|
|
||
| let mut resp = vec![ProposalType::Full]; | ||
| for result in results.iter() { |
| } | ||
|
|
||
| /// Returns the versions as their string representations. | ||
| fn versions_to_strings(versions: &[SemVer]) -> Vec<String> { |
There was a problem hiding this comment.
Disagree, makes testing a bit easier having it separated.
| } | ||
|
|
||
| /// Returns the proposal types as their wire-format strings. | ||
| fn proposals_to_strings(proposals: &[ProposalType]) -> Vec<String> { |
There was a problem hiding this comment.
Same comment as in versions_to_strings
emlautarom1
left a comment
There was a problem hiding this comment.
LGTM, minor things only
|
|
||
| /// Returns whether the `MockAlpha` feature is globally enabled. | ||
| fn mock_alpha_enabled() -> bool { | ||
| GLOBAL_STATE |
There was a problem hiding this comment.
nit: prefer to use qualified names for variables/functions:
| GLOBAL_STATE | |
| pluto_featureset::GLOBAL_STATE |
| .expect("infosync results mutex poisoned"); | ||
|
|
||
| let mut resp = self.local_protocols.clone(); | ||
| for result in results.iter() { |
There was a problem hiding this comment.
Agree on making the change just for the sake of clarity.
| fn local_protocols(&self) -> &[String] { | ||
| &self.local_protocols | ||
| } |
There was a problem hiding this comment.
Remove the method an inline it (single usage)
| } | ||
|
|
||
| /// Returns the versions as their string representations. | ||
| fn versions_to_strings(versions: &[SemVer]) -> Vec<String> { |
There was a problem hiding this comment.
Disagree, makes testing a bit easier having it separated.
| } | ||
|
|
||
| /// Returns the proposal types as their wire-format strings. | ||
| fn proposals_to_strings(proposals: &[ProposalType]) -> Vec<String> { |
There was a problem hiding this comment.
Same comment as in versions_to_strings
| results.push(result); | ||
|
|
||
| if results.len() >= MAX_RESULTS { | ||
| results.remove(0); |
There was a problem hiding this comment.
Agree for clarity mostly
| // Trigger infosync on every host for the same slot. `trigger` blocks until | ||
| // the duty deadline / cancellation, so it runs in the background while the | ||
| // decision is observed via the capture channel. | ||
| let mut triggers = Vec::with_capacity(N); |
There was a problem hiding this comment.
Can use a JoinSet here (less bookkeeping)
| } | ||
| } | ||
| }; | ||
| timeout(Duration::from_secs(30), mesh) |
There was a problem hiding this comment.
Do we need such long timeout? Can we make do with 10s or less?
| peers.clone(), | ||
| i64::try_from(peers.len()).expect("peer count fits i64"), | ||
| consensus, | ||
| Duration::from_secs(3600), |
Fix #173
Stack on: #489
crates/infosync/src/lib.rs(+506)new/trigger/protocols(slot)/proposals(slot), aResultStore(dedup, history cap, slot-selection), and the priority subscribe callback.crates/infosync/tests/infosync_integration.rs(+356)TestInfoSync): all nodes converge on the same agreed priorities.crates/core/src/types.rs(+89)ProposalType→ open enum (Unknown(String)),as_str/From/ serde-via-String; dropsCopy.crates/infosync/src/lib.rs— self-contained. Check the store dedup/cap (>=⇒ caps at 99, matches charon),protocols/proposalsslot-selection + defaults (local/[Full]),handle_resultstopic routing,build_request(3 topics + InfoSync duty).crates/core/src/types.rs— the only shared-type change. Design call to confirm:ProposalTypeopen enum + loss ofCopy, to preserve forward-compat values from newer peers (charon's type is an open string). Only users are core's def + infosync.app.Run(infosync isn't wired into the app yet).