Skip to content

Commit 4f94e1a

Browse files
muXxeralexsporn
authored andcommitted
feat(protocol): PCR-2 iota-proxy (#5461)
1 parent d120a47 commit 4f94e1a

File tree

3 files changed

+29
-7
lines changed

3 files changed

+29
-7
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/iota-proxy/src/peers.rs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,13 @@ impl IotaNodeProvider {
116116
&mut self.active_validator_nodes
117117
}
118118
fn update_active_validator_set(&self, summary: &IotaSystemStateSummary) {
119-
let validators = extract_validators_from_summaries(&summary.active_validators);
119+
let validator_summaries = match &summary {
120+
IotaSystemStateSummary::V1(summary) => summary.active_validators.clone(),
121+
IotaSystemStateSummary::V2(summary) => summary.active_validators.clone(),
122+
_ => panic!("unsupported IotaSystemStateSummary"),
123+
};
124+
125+
let validators = extract_validators_from_summaries(&validator_summaries);
120126
let mut allow = self.active_validator_nodes.write().unwrap();
121127
allow.clear();
122128
allow.extend(validators);
@@ -205,9 +211,19 @@ impl IotaNodeProvider {
205211
cloned_self.update_active_validator_set(&system_state);
206212
info!("Successfully updated active validators");
207213

214+
let pending_active_validators_id = match &system_state {
215+
IotaSystemStateSummary::V1(system_state) => {
216+
system_state.pending_active_validators_id
217+
}
218+
IotaSystemStateSummary::V2(system_state) => {
219+
system_state.pending_active_validators_id
220+
}
221+
_ => panic!("unsupported IotaSystemStateSummary"),
222+
};
223+
208224
match Self::get_pending_validators(
209225
&client,
210-
system_state.pending_active_validators_id,
226+
pending_active_validators_id,
211227
)
212228
.await
213229
{

crates/iota-types/src/iota_system_state/iota_system_state_summary.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -711,9 +711,9 @@ pub struct IotaValidatorSummary {
711711
pub exchange_rates_size: u64,
712712
}
713713

714-
impl Default for IotaSystemStateSummary {
714+
impl Default for IotaSystemStateSummaryV2 {
715715
fn default() -> Self {
716-
Self::V2(IotaSystemStateSummaryV2 {
716+
IotaSystemStateSummaryV2 {
717717
epoch: 0,
718718
protocol_version: 1,
719719
system_state_version: 1,
@@ -749,7 +749,13 @@ impl Default for IotaSystemStateSummary {
749749
validator_candidates_size: 0,
750750
at_risk_validators: vec![],
751751
validator_report_records: vec![],
752-
})
752+
}
753+
}
754+
}
755+
756+
impl Default for IotaSystemStateSummary {
757+
fn default() -> Self {
758+
Self::V2(Default::default())
753759
}
754760
}
755761

0 commit comments

Comments
 (0)