Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .github/workflows/run-tests-on-push-to-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ jobs:
--package acropolis_module_genesis_bootstrapper \
--package acropolis_module_governance_state \
--package acropolis_module_mithril_snapshot_fetcher \
--package acropolis_module_parameters_state \
--package acropolis_module_snapshot_bootstrapper \
--package acropolis_module_spdd_state \
--package acropolis_module_spo_state \
Expand Down
2 changes: 1 addition & 1 deletion modules/parameters_state/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ fn fetch_text(url: &str) -> Result<String, Box<dyn std::error::Error>> {
if let Ok(file) = File::open(path) {
if let Ok(map) = from_reader::<_, HashMap<String, String>>(file) {
if let Some(path_str) = map.get(url.trim()) {
if let Ok(s) = fs::read_to_string(&Path::new(path_str).to_path_buf()) {
if let Ok(s) = fs::read_to_string(path_str) {
return Ok(s);
}
}
Expand Down
2 changes: 1 addition & 1 deletion modules/parameters_state/src/genesis_params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ mod test {

// blake2b-256
let mut hasher = Blake2b::<U32>::new();
hasher.update(&[&genesis[..]].concat());
hasher.update([&genesis[..]].concat());
let hash: [u8; 32] = hasher.finalize().into();
println!("{:?}", hex::encode(hash));
Ok(())
Expand Down
4 changes: 2 additions & 2 deletions modules/parameters_state/src/parameters_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,10 @@ impl ParametersState {
let current_params = state.current_params.get_params();

// Process GovOutcomes message on epoch transition
let new_params = state.handle_enact_state(&block, &gov).await?;
let new_params = state.handle_enact_state(block, gov).await?;

// Publish protocol params message
Self::publish_update(&config, &block, new_params.clone())?;
Self::publish_update(&config, block, new_params.clone())?;

// Commit state on params change
if current_params != new_params.params {
Expand Down
16 changes: 8 additions & 8 deletions modules/parameters_state/src/parameters_updater.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl ParametersUpdater {
}

fn cw_u32(&mut self, f: impl Fn(&mut ConwayParams) -> &mut u32, u: &Option<u64>) -> Result<()> {
self.cw_upd(f, &u.map(|x| u32::try_from(x)).transpose()?)
self.cw_upd(f, &u.map(u32::try_from).transpose()?)
}

fn update_conway_params(&mut self, p: &ProtocolParamUpdate) -> Result<()> {
Expand Down Expand Up @@ -129,7 +129,7 @@ impl ParametersUpdater {
f: impl Fn(&mut ShelleyProtocolParams) -> &mut u32,
u: &Option<u64>,
) -> Result<()> {
self.sh_upd(f, &u.map(|x| u32::try_from(x)).transpose()?)
self.sh_upd(f, &u.map(u32::try_from).transpose()?)
}

fn update_shelley_params(&mut self, p: &ProtocolParamUpdate) -> Result<()> {
Expand Down Expand Up @@ -185,7 +185,7 @@ impl ParametersUpdater {
}

fn a_u32(&mut self, f: impl Fn(&mut AlonzoParams) -> &mut u32, u: &Option<u64>) -> Result<()> {
self.a_upd(f, &u.map(|x| u32::try_from(x)).transpose()?)
self.a_upd(f, &u.map(u32::try_from).transpose()?)
}

fn update_alonzo_params(&mut self, p: &ProtocolParamUpdate) -> Result<()> {
Expand Down Expand Up @@ -215,7 +215,7 @@ impl ParametersUpdater {

fn update_committee(c: &mut Committee, cu: &CommitteeChange) {
for removed_member in cu.removed_committee_members.iter() {
if let None = c.members.remove(removed_member) {
if c.members.remove(removed_member).is_none() {
error!(
"Removing {:?}, which is not a part of the committee",
removed_member
Expand All @@ -231,7 +231,7 @@ impl ParametersUpdater {
);
}
}
c.threshold = cu.terms.clone();
c.threshold = cu.terms;
}

fn apply_alonzo_babbage_outcome_elem(&mut self, u: &AlonzoBabbageVotingOutcome) -> Result<()> {
Expand All @@ -242,14 +242,14 @@ impl ParametersUpdater {
}

fn apply_enact_state_elem(&mut self, u: &EnactStateElem) -> Result<()> {
let ref mut c = self
let c = &mut (self
.params
.conway
.as_mut()
.ok_or_else(|| anyhow!("Conway must present for enact state"))?;
.ok_or_else(|| anyhow!("Conway must present for enact state"))?);

match &u {
EnactStateElem::Params(pu) => self.update_params(&pu)?,
EnactStateElem::Params(pu) => self.update_params(pu)?,
EnactStateElem::Constitution(cu) => c.constitution = cu.clone(),
EnactStateElem::Committee(cu) => Self::update_committee(&mut c.committee, cu),
EnactStateElem::NoConfidence => c.committee.members.clear(),
Expand Down
4 changes: 2 additions & 2 deletions modules/parameters_state/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ impl State {
}

pub fn apply_genesis(&mut self, new_block: &BlockInfo) -> Result<()> {
let to_apply = Self::genesis_era_range(self.current_era.clone(), new_block.era.clone());
let to_apply = Self::genesis_era_range(self.current_era, new_block.era);
if to_apply.is_empty() {
return Ok(());
}
Expand All @@ -60,7 +60,7 @@ impl State {
msg: &GovernanceOutcomesMessage,
) -> Result<ProtocolParamsMessage> {
if self.current_era != Some(block.era) {
self.apply_genesis(&block)?;
self.apply_genesis(block)?;
}
self.current_params.apply_enact_state(msg)?;
let params_message = ProtocolParamsMessage {
Expand Down
Loading