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

chore: Ironfish rust refactor add change #4572

Merged
merged 1 commit into from
Jan 22, 2024

Conversation

jowparks
Copy link
Contributor

@jowparks jowparks commented Jan 19, 2024

Summary

Adds change notes as a method that is executed if the transaction is a miners fee (only special type of transaction that doesn't balance). The only reason this method exists is so that no change notes are added for miner fee transactions, otherwise it would always be run inside the build() method.

Testing Plan

tests pass

Documentation

Does this change require any updates to the Iron Fish Docs (ex. the RPC API
Reference
)? If yes, link a
related documentation pull request for the website.

[ ] Yes

Breaking Change

Is this a breaking change? If yes, add notes below on why this is breaking and
what additional work is required, if any.

[ ] Yes

@jowparks jowparks changed the base branch from master to staging January 19, 2024 22:38
@jowparks jowparks force-pushed the ironfish-rust-refactor-add-change branch from 400e0e4 to 018a4a7 Compare January 19, 2024 22:39
@jowparks jowparks marked this pull request as ready for review January 19, 2024 22:41
@jowparks jowparks requested a review from a team as a code owner January 19, 2024 22:41
Copy link
Contributor

@hughy hughy left a comment

Choose a reason for hiding this comment

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

Should add_change_notes ever be called outside of build?

Can we add a test for the behavior of calling build incorrectly without an address for change?

@jowparks jowparks force-pushed the ironfish-rust-refactor-add-change branch 2 times, most recently from 6207043 to fcd5183 Compare January 20, 2024 01:22
@jowparks
Copy link
Contributor Author

jowparks commented Jan 20, 2024

Should add_change_notes ever be called outside of build?

Can we add a test for the behavior of calling build incorrectly without an address for change?

Good call! It shouldn't ever be called outside of build, so I will just make the method private, also I will add a test to verify an invalid balance is returned when change notes are not passed when they should be (ie a standard transaction post where change is present)

@jowparks jowparks force-pushed the ironfish-rust-refactor-add-change branch from fcd5183 to 12f12dd Compare January 20, 2024 01:23
@jowparks
Copy link
Contributor Author

The most canonical use case of a transaction is post, which handles this case automatically. Only when you are building intermediate UnsignedTransactions do you need to worry about this.

@jowparks jowparks force-pushed the ironfish-rust-refactor-add-change branch from 12f12dd to 8e21ed9 Compare January 20, 2024 03:09
@jowparks
Copy link
Contributor Author

Ok so I decided the most full proof method is determining if we should add the change note based on whether the transaction is a miners fee transaction (which can be determined by the outputs). This way it is impossible to call the method incorrectly. Miners fee with a Some() change_goes_to will still succeed, just skips adding change notes.

@jowparks jowparks requested a review from hughy January 20, 2024 03:11
…edTransaction`. Makes it so no new method is required for build layer
@jowparks jowparks force-pushed the ironfish-rust-refactor-add-change branch from 8e21ed9 to 9cf1c78 Compare January 20, 2024 03:12
@@ -191,7 +191,7 @@ impl ProposedTransaction {
Ok(())
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This should never be called outside of this file.

@jowparks jowparks merged commit cd02987 into staging Jan 22, 2024
13 checks passed
@jowparks jowparks deleted the ironfish-rust-refactor-add-change branch January 22, 2024 21:00
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.

2 participants