Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: refactor(rm spending counter): audit tooling | NPG-000 #663

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
Original file line number Diff line number Diff line change
Expand Up @@ -58,35 +58,14 @@ impl SpendingCounterIncreasing {
/// an error reported.
///
/// If the counter match succesfully, then the counter at this lane is incremented by one.
pub fn next_verify(&mut self, counter: SpendingCounter) -> Result<(), Error> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe make explicit in the comment why this function it just returns Ok() ?

let actual_counter = self.nexts[counter.lane()];

if actual_counter != counter {
Err(Error::SpendingCredentialInvalid {
expected: actual_counter,
actual: counter,
})
} else {
self.next_unchecked(counter);
Ok(())
}
pub fn next_verify(&mut self, _counter: SpendingCounter) -> Result<(), Error> {
// spending counter logic has been removed throughout, returning OK is the least invasive action at the moment.
// Prod chain-libs = https://github.com/input-output-hk/chain-libs/tree/catalyst-fund9-gold
Ok(())
}

/// Increases the spending counter on the given lane.
pub(crate) fn next_unchecked(&mut self, unchecked_counter: SpendingCounter) {
let lane = unchecked_counter.lane();
let counter_to_update = self.nexts[lane];
if counter_to_update != unchecked_counter {
tracing::warn!(
"Invalid spending counter, {}",
Error::SpendingCredentialInvalid {
expected: counter_to_update,
actual: unchecked_counter,
}
);
}
self.nexts[lane] = counter_to_update.increment();
}
pub(crate) fn next_unchecked(&mut self, _unchecked_counter: SpendingCounter) {}
}

// only used to print the account's ledger
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ pub fn transaction_nonexisting_account_input() {
}

#[test]
#[ignore]
pub fn transaction_with_incorrect_account_spending_counter() {
let faucet =
AddressDataValue::account_with_spending_counter(Discrimination::Test, 1, Value(1000));
Expand Down
1 change: 0 additions & 1 deletion src/chain-libs/chain-impl-mockchain/src/testing/e2e/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ pub mod mint_token;
pub mod owner_delegation;
pub mod pool_update;
pub mod rewards;
pub mod spending_counter_lanes;
pub mod stake_distribution;
pub mod transactions;
pub mod update_proposal;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@ pub fn pending_fragment_should_be_persisted() {
}

#[test]
#[ignore]
pub fn node_should_pickup_log_after_restart() {
let mut temp_dir = TempDir::new().unwrap();
let dump_folder = temp_dir.child("dump_folder");
Expand Down
Loading