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

Feature/in 121 #37

Merged
merged 29 commits into from
Feb 8, 2022
Merged

Feature/in 121 #37

merged 29 commits into from
Feb 8, 2022

Conversation

n3op2
Copy link
Contributor

@n3op2 n3op2 commented Feb 4, 2022

What

  • added a new struct and a single storage map method with the process id as primary key - Version.
truct {
  process_id: [u8; 32] // process_id
  version: i32 // this should be changed to ProcessVersion type 
}
  • some unit tests for the create process method and disable_process
  • a couple of helper functions
  • some logic for prevention of spamming events

Test coverage

~/workspace/vitalam-node (feature/in-121) $ RUST_BACKTRACE=1 cargo watch -x 'test  -p pallet-process-validation -- --nocapture'
[Running 'cargo test  -p pallet-process-validation -- --nocapture']
   Compiling pallet-process-validation v1.0.0 (/Users/PMichelevicius/workspace/vitalam-node/pallets/process-validation)
    Finished test [unoptimized + debuginfo] target(s) in 4.33s
     Running unittests (target/debug/deps/pallet_process_validation-73f8bab8c750bef3)

running 12 tests
test tests::__construct_runtime_integrity_test::runtime_integrity_tests ... ok
test tests::disable_process::returns_error_if_origin_validation_fails_and_no_data_added ... ok
test tests::disable_process::returns_error_if_process_does_not_exist ... ok
test tests::create_process::updates_version_correctly_for_new_process_and_dispatches_event ... ok
test tests::create_process::updates_version_correctly_for_existing_proces_and_dispatches_event ... ok
test tests::create_process::handles_if_process_exists_for_the_new_version ... ok
test tests::create_process::for_existing_process_it_mutates_an_existing_version ... ok
test tests::disable_process::disables_process_and_dispatches_event ... ok
test tests::create_process::if_no_version_found_it_should_return_default_and_insert_new_one ... ok
test tests::disable_process::returns_error_if_process_is_already_disabled ... ok
test tests::create_process::returns_error_if_origin_validation_fails_and_no_data_added ... ok
test tests::create_process::sets_versions_correctly_for_multiple_processes ... ok

test result: ok. 12 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.01s

   Doc-tests pallet-process-validation

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

[Finished running. Exit status: 0]

TODO

  • - disable_process - will pair with Dan
  • - Errors and maybe some handling
  • - expand on unit tests coverage - create_process
  • - write unit tests for disable_process - Dan
  • - sort some types and a general clean up
  • - resolve conflicts

Copy link
Contributor

@mattdean-digicatapult mattdean-digicatapult left a comment

Choose a reason for hiding this comment

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

Alright this probably looks like a wall of changes but most of it is arround the switch to T::ProcessVersion. This is actually really close on the implmentation side, so well done! Couple of additional points:

  1. Please rebase or merge in main. There's currently some churn from the cargo fmt
  2. Tests need writing still, but I think you know that. Just a reminder

pallets/process-validation/src/lib.rs Outdated Show resolved Hide resolved
pallets/process-validation/src/lib.rs Outdated Show resolved Hide resolved
pallets/process-validation/src/lib.rs Outdated Show resolved Hide resolved
pallets/process-validation/src/lib.rs Outdated Show resolved Hide resolved
pallets/process-validation/src/lib.rs Outdated Show resolved Hide resolved
pallets/process-validation/src/lib.rs Outdated Show resolved Hide resolved
pallets/process-validation/src/lib.rs Outdated Show resolved Hide resolved
pallets/process-validation/src/lib.rs Outdated Show resolved Hide resolved
pallets/process-validation/src/lib.rs Outdated Show resolved Hide resolved
pallets/process-validation/src/lib.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@mattdean-digicatapult mattdean-digicatapult left a comment

Choose a reason for hiding this comment

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

Tests are looking good. Many points from the first review still remain but we're headed in the right direction. Few comments to look at

pallets/process-validation/src/tests/create_process.rs Outdated Show resolved Hide resolved
pallets/process-validation/src/tests/create_process.rs Outdated Show resolved Hide resolved
pallets/process-validation/src/tests/create_process.rs Outdated Show resolved Hide resolved
pallets/process-validation/src/lib.rs Outdated Show resolved Hide resolved
pallets/process-validation/src/lib.rs Outdated Show resolved Hide resolved
pallets/process-validation/src/lib.rs Outdated Show resolved Hide resolved
@n3op2 n3op2 marked this pull request as ready for review February 7, 2022 11:54
Copy link
Contributor

@danielcooperxyz danielcooperxyz left a comment

Choose a reason for hiding this comment

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

You've done really well to pick this up and make something meaningful. Well done!

I don't have much to comment regarding the logic and types/structs. I noticed there are a lot of comments, some seem anecdotal whereas some seem more formal, also the formal comments are not always consistently applied i.e. method and variable documentation.

Is there a standard for code comment documentation in rust/substrate?

pallets/process-validation/src/lib.rs Outdated Show resolved Hide resolved
pallets/process-validation/src/lib.rs Outdated Show resolved Hide resolved
pallets/process-validation/src/lib.rs Outdated Show resolved Hide resolved
pallets/process-validation/src/lib.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@mattdean-digicatapult mattdean-digicatapult left a comment

Choose a reason for hiding this comment

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

Really close couple of minor changes. Also need to consider the following:

  • bump pallet version
  • bump runtime version (including the chain runtime version to match in the runtime lib.rs)
  • bump node version

pallets/process-validation/src/lib.rs Show resolved Hide resolved
pallets/process-validation/src/lib.rs Outdated Show resolved Hide resolved
pallets/process-validation/src/lib.rs Outdated Show resolved Hide resolved
runtime/Cargo.toml Show resolved Hide resolved
node/Cargo.toml Show resolved Hide resolved
};
}

pub fn set_disabled(id: &T::ProcessIdentifier, version: &T::ProcessVersion) -> Result<bool, Error<T>> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry I didn't comment all of these but it's the same thing with unit instead of bool if you want to

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🤦 sorry been rushing a little i guess and did not see that this repeats

pallets/process-validation/src/lib.rs Outdated Show resolved Hide resolved
@@ -4,7 +4,7 @@ edition = '2018'
license = 'Apache-2.0'
repository = 'https://github.com/digicatapult/vitalam-node/'
name = 'vitalam-node-runtime'
version = '2.2.0'
version = '2.2.1'
Copy link
Contributor

Choose a reason for hiding this comment

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

@jonmattgray
Copy link
Contributor

Sorry to be the README troll, but this pallet has reached a point where it should have a section in the README? Like the sections for other pallets detailing their storage + extrinsics

@n3op2
Copy link
Contributor Author

n3op2 commented Feb 8, 2022

@jonmattgray - was actually thinking about this earlier in the morning, will add a README file

Copy link
Contributor

@mattdean-digicatapult mattdean-digicatapult left a comment

Choose a reason for hiding this comment

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

@n3op2 I think this is good to merge. Don't worry about the readme, when I jump back to finishing off #36 I'll update the readme there. Good stuff

@n3op2 n3op2 requested a review from danielcooperxyz February 8, 2022 16:23
@n3op2 n3op2 merged commit 42327ac into main Feb 8, 2022
@n3op2 n3op2 deleted the feature/in-121 branch February 8, 2022 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants