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

feat: verify spend in cli and auditing all the way to genesis #1014

Merged
merged 3 commits into from Nov 29, 2023

Conversation

grumbach
Copy link
Member

@grumbach grumbach commented Nov 28, 2023

Description

  • verify spends in cli with safe wallet verify <spend_address/unique_pubkey>
  • option to verify them all the way to genesis (for auditing) safe wallet verify --genesis <spend_address/unique_pubkey>
  • make spends logging actionable by printing the spend_address and unique_pubkey in hex (copy/pastable to the cli)
  • reinforce Tx verification code

Summary generated by Reviewpad on 28 Nov 23 11:45 UTC

This pull request includes the following changes:

  1. In the client.rs file, the function verify() has been replaced with verify_cashnote(). This change improves the clarity and accuracy of the code.

  2. In the address.rs file, several changes have been made:

    • Import statements for Error and Result have been added.
    • New methods to_hex() and from_hex() have been added to the SpendAddress struct.
    • The Debug trait has been implemented for the SpendAddress struct.
    • A unit test for hex conversions of SpendAddress has been added.
  3. In the wallet.rs file, the following changes have been made:

    • Import statements for SpendAddress have been added.
    • A debug log statement has been added to print the spend key being marked as spent on the Network.
    • The verify() function has been renamed to verify_cashnote() and its documentation has been updated.
    • A new function verify_spend() has been added to verify a spend and its ancestors on the network.
    • Minor changes have been made to debug log messages.
  4. In the sn_cli/src/subcommands/wallet.rs file, the following changes have been made:

    • Import statements have been modified to include new types and modules: MainPubkey, SpendAddress, and UniquePubkey.
    • A new subcommand Verify has been added, which can be used to verify a spend on the network.
    • A new function parse_pubkey_address has been added to parse a spend address or a unique pubkey address.
    • The verify function has been implemented to verify a spend on the network.
    • Additional test cases have been added for the parse_pubkey_address function.
  5. In the sn_cli/src/networking/api.rs file, the following changes have been made:

    • The import statement for UniquePubkey has been removed.
    • The function get_spend_from_network now takes an argument of type SpendAddress instead of unique_pubkey.
    • The variable cash_note_addr has been renamed to address in the put_spend_to_network function.
    • The function get_spend_from_network now takes an argument of type SpendAddress instead of unique_pubkey.
    • Log messages have been updated to include the address instead of unique_pubkey.
  6. In the sn_network/src/transfers.rs file, the following change has been made:

    • The method call from_cash_note_address has been changed to from_spend_address when obtaining a key from a NetworkAddress.
  7. In the common/mod.rs file, the following change has been made:

    • The method client.verify has been replaced with client.verify_cashnote.
  8. In the sn_transfers/src/cashnotes/signed_spend.rs file, the following changes have been made:

    • The GENESIS_CASHNOTE has been imported from the crate.
    • The method cashnote_creation_tx_hash has been renamed to parent_tx_hash.
    • The verify method has been modified to handle cases where the spent_tx_hash does not match self.spent_tx_hash().
    • The comments have been updated to reflect the changes.
  9. In the unique_keys.rs file, the following changes have been made:

    • Import statements for Error and Result have been added.
    • New methods to_hex() and from_hex() have been added to the UniquePubkey and MainPubkey structs.
    • The Debug trait has been implemented for both structs.
    • A new function bls_public_from_hex() has been added.
    • Test cases have been added for the key conversion functions.
  10. In the sn_node/src/spends.rs file, the following changes have been made:

    • The code now checks if a spent CashNote is Genesis using signed_spend.spend.parent_tx instead of signed_spend.spend.cashnote_creation_tx.
    • The code now checks if a spent CashNote is an output of the parent tx using signed_spend.spend.parent_tx.outputs instead of signed_spend.spend.cashnote_creation_tx.outputs.
    • The variable tx_our_cash_note_was_created_in now gets the value of signed_spend.parent_tx_hash() instead of signed_spend.cashnote_creation_tx_hash().
    • The code compares tx_our_cash_note_was_created_in with tx_its_parents_where_spent_in instead of tx_our_cash_note_was_created_in with tx_its_parents_where_spent_in.
    • The code now verifies the CashNote was created in a valid tx using signed_spend.parent_tx.verify_against_inputs_spent(parent_spends) instead of signed_spend.cashnote_creation_tx.verify_against_inputs_spent(parent_spends).
  11. The Cargo.lock file has been modified to add the eyre dependency.

  12. The Cargo.toml file has been modified to add the eyre crate as a development dependency with version 0.6.8.

  13. In the data_with_churn.rs file, the verify() method call has been changed to verify_cashnote() on the client object. The exact intention behind this change is unclear from the diff alone.

  14. In the sequential_transfers.rs file, the method call verify() has been replaced with verify_cashnote() in the cash_note_transfer_multiple_sequential_succeed() and cash_note_transfer_double_spend_fail() functions.

  15. In the wallet/mod.rs file, the import of the parse_main_pubkey function has been removed, and the import of the bls_secret_from_hex function has been modified.

  16. In the main.rs file, the import of the parse_main_pubkey function has

@reviewpad reviewpad bot requested a review from bochaco November 28, 2023 11:45
@reviewpad reviewpad bot added Large Large sized PR waiting-for-review labels Nov 28, 2023
@grumbach grumbach changed the title Verify spend cli feat: verify spend in cli Nov 28, 2023
@grumbach grumbach changed the title feat: verify spend in cli feat: verify spend in cli and auditing all the way to genesis Nov 28, 2023
@grumbach grumbach changed the title feat: verify spend in cli and auditing all the way to genesis WIP: feat: verify spend in cli and auditing all the way to genesis Nov 28, 2023
@grumbach grumbach changed the title WIP: feat: verify spend in cli and auditing all the way to genesis feat: verify spend in cli and auditing all the way to genesis Nov 29, 2023
@grumbach grumbach added this pull request to the merge queue Nov 29, 2023
@grumbach grumbach removed this pull request from the merge queue due to a manual request Nov 29, 2023
@grumbach grumbach added this pull request to the merge queue Nov 29, 2023
Merged via the queue into maidsafe:main with commit 56e6bdf Nov 29, 2023
29 checks passed
@grumbach grumbach deleted the verify_spend_cli branch November 29, 2023 09:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Large Large sized PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants