Skip to content

Commit

Permalink
improve error handling for set_initial_validators
Browse files Browse the repository at this point in the history
  • Loading branch information
brentstone committed Jul 10, 2023
1 parent eaebb7b commit 1a4eb06
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions apps/src/lib/node/ledger/shell/init_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,11 +245,11 @@ where
&implicit_vp_code_path,
);
// set the initial validators set
Ok(self.set_initial_validators(
self.set_initial_validators(
&staking_token,
genesis.validators,
&genesis.pos_params,
))
)
}

/// Initialize genesis established accounts
Expand Down Expand Up @@ -460,7 +460,7 @@ where
staking_token: &Address,
validators: Vec<genesis::Validator>,
pos_params: &PosParams,
) -> response::InitChain {
) -> Result<response::InitChain> {
let mut response = response::InitChain::default();
// PoS system depends on epoch being initialized. Write the total
// genesis staking token balance to storage after
Expand All @@ -473,13 +473,11 @@ where
current_epoch,
);

let total_nam =
read_total_supply(&self.wl_storage, staking_token).unwrap();
let total_nam = read_total_supply(&self.wl_storage, staking_token)?;
// At this stage in the chain genesis, the PoS address balance is the
// same as the number of staked tokens
let total_staked_nam =
read_balance(&self.wl_storage, staking_token, &address::POS)
.unwrap();
read_balance(&self.wl_storage, staking_token, &address::POS)?;

tracing::info!(
"Genesis total native tokens: {}.",
Expand All @@ -505,7 +503,7 @@ where
.expect("Must be able to set genesis validator set");
debug_assert!(!response.validators.is_empty());

response
Ok(response)
}
}

Expand Down

0 comments on commit 1a4eb06

Please sign in to comment.