Skip to content

Commit

Permalink
clean up pos VP
Browse files Browse the repository at this point in the history
  • Loading branch information
brentstone committed Feb 15, 2024
1 parent 9181fbe commit a9fdbd2
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions crates/namada/src/ledger/pos/vp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,13 @@
use std::collections::BTreeSet;

// use borsh::BorshDeserialize;
pub use namada_proof_of_stake;
pub use namada_proof_of_stake::parameters::PosParams;
// use namada_proof_of_stake::validation::validate;
use namada_proof_of_stake::storage::read_pos_params;
use namada_proof_of_stake::storage_key::is_params_key;
pub use namada_proof_of_stake::types;
// use crate::ledger::pos::{
// is_validator_address_raw_hash_key,
// is_validator_max_commission_rate_change_key,
// };
use namada_state::StorageHasher;
use namada_state::StorageRead;
use namada_tx::Tx;
use thiserror::Error;

Expand Down Expand Up @@ -76,9 +70,9 @@ where

let addr = Address::Internal(InternalAddress::PoS);
// let mut changes: Vec<DataUpdate> = vec![];
let _current_epoch = self.ctx.pre().get_block_epoch()?;
// let _current_epoch = self.ctx.pre().get_block_epoch()?;

Check warning on line 73 in crates/namada/src/ledger/pos/vp.rs

View check run for this annotation

Codecov / codecov/patch

crates/namada/src/ledger/pos/vp.rs#L73

Added line #L73 was not covered by tests

tracing::debug!("\nValidating PoS Tx\n");
tracing::debug!("\nValidating PoS storage changes\n");

Check warning on line 75 in crates/namada/src/ledger/pos/vp.rs

View check run for this annotation

Codecov / codecov/patch

crates/namada/src/ledger/pos/vp.rs#L75

Added line #L75 was not covered by tests

for key in keys_changed {
if is_params_key(key) {
Expand All @@ -95,22 +89,24 @@ where
{
return Ok(false);
}
let params = read_pos_params(&self.ctx.post())?.owned;
if !params.validate().is_empty() {
return Ok(false);
}

Check warning on line 95 in crates/namada/src/ledger/pos/vp.rs

View check run for this annotation

Codecov / codecov/patch

crates/namada/src/ledger/pos/vp.rs#L92-L95

Added lines #L92 - L95 were not covered by tests
} else if key.segments.get(0) == Some(&addr.to_db_key()) {
// Unknown changes to this address space are disallowed
// tracing::info!("PoS unrecognized key change {} rejected",
// key);
// No VP logic applied to all other PoS keys for now, as PoS txs
// are all whitelisted
tracing::debug!(
"PoS key change {} - No action is taken currently.",
key
);
// return Ok(false);
} else {
tracing::debug!("PoS unrecognized key change {}", key);
// Unknown changes anywhere else are permitted
tracing::debug!("PoS unrecognized key change {}", key);

Check warning on line 105 in crates/namada/src/ledger/pos/vp.rs

View check run for this annotation

Codecov / codecov/patch

crates/namada/src/ledger/pos/vp.rs#L105

Added line #L105 was not covered by tests
}
}

let _params = read_pos_params(&self.ctx.pre())?;
// let _params = read_pos_params(&self.ctx.pre())?;
// let errors = validate(&params, changes, current_epoch);
// Ok(if errors.is_empty() {
// true
Expand Down

0 comments on commit a9fdbd2

Please sign in to comment.