Skip to content

Update AssetSuply and SupplyInfo#128

Closed
ConstanceBeguier wants to merge 13 commits intozsa1from
update_asset_supply
Closed

Update AssetSuply and SupplyInfo#128
ConstanceBeguier wants to merge 13 commits intozsa1from
update_asset_supply

Conversation

@ConstanceBeguier
Copy link
Collaborator

@ConstanceBeguier ConstanceBeguier commented Dec 19, 2024

The amount in AssetSupply must be a NoteValue (u64) and not a ValueSum (i128).
We add reference_notes into SupplyInfo. It is a hashmap of asset bases to their respective reference note.

@QED-it QED-it deleted a comment from what-the-diff bot Dec 19, 2024
@dmidem dmidem self-requested a review December 25, 2024 08:11
dmidem
dmidem previously approved these changes Dec 25, 2024
Copy link

@dmidem dmidem left a comment

Choose a reason for hiding this comment

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

I've reviewed the changes and have a couple of minor suggestions below, which don't necessarily need to be addressed in this PR but could be handled in an additional one.

.notes
.iter()
.try_fold(ValueSum::zero(), |value_sum, &note| {
.try_fold(NoteValue::zero(), |value_sum, &note| {
Copy link

Choose a reason for hiding this comment

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

Since the NoteValue type is now used for total supply calculations instead of ValueSum, the Error variant name ValueSumOverflow might be a bit confusing. It still refers to the sum of values, but renaming it to ValueOverflow could potentially improve clarity.

Suggestion:

In issuance.rs:640, consider renaming ValueSumOverflow to ValueOverflow:

pub enum Error {
    // ...
    ValueOverflow,
}

Additionally, all occurrences of ValueSumOverflow in the code and comments need to be renamed to ValueOverflow.

Copy link
Collaborator

Choose a reason for hiding this comment

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

yes, let's do it.

src/issuance.rs Outdated
impl<T: IssueAuth> IssueBundle<T> {
/// Returns the reference notes for the `IssueBundle`.
pub fn get_reference_notes(self) -> HashMap<AssetBase, Note> {
pub fn get_reference_notes(&self) -> HashMap<AssetBase, Note> {
Copy link

Choose a reason for hiding this comment

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

I noticed that the get_reference_notes function was introduced in PR #124 within a new impl<T: IssueAuth> IssueBundle<T> { ... } block. Since there's already the same impl block above (issuance.rs#L205), maybe we could move get_reference_notes to the existing block to consolidate related implementations.

Copy link
Collaborator

Choose a reason for hiding this comment

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

yes, let's consolidate.

@dmidem
Copy link

dmidem commented Dec 25, 2024

Additionally, I would like to place here a remark for future consideration: to make it easier to reuse SupplyInfo, AssetSupply, verify_supply, and verify_issue_bundle in zebra, it would be good to consider adding the reference note as the third field of the AssetSupply structure (and possibly renaming it to AssetState). This way, the reference notes would be stored in the assets HashMap of SupplyInfo instead of in a separate reference_notes HashMap. However, as we discussed with @PaulLaux, this needs to be addressed in an additional PR, and we will keep the current implementation (with a separate reference_notes HashMap) for this PR.

PaulLaux and others added 9 commits December 25, 2024 17:20
Co-authored-by: Dmitry Demin <dmidem@users.noreply.github.com>
…e type of the value was changed from ValueSum to NoteValue
…nfig Ubuntu package to be installed"

This reverts commit c30e108.
…ich is required by the yeslogic-fontconfig-sys crate (a transitive dev dependency). The CI error started occurring after GitHub updated ubuntu-latest from Ubuntu 22.04 to 24.04.
@PaulLaux PaulLaux requested a review from dmidem January 2, 2025 08:20
@PaulLaux PaulLaux dismissed dmidem’s stale review January 5, 2025 11:54

as discussed

dmidem added 2 commits January 5, 2025 23:37
…s field from SupplyInfo, add and use get_reference_note method to IssueAction
@dmidem
Copy link

dmidem commented Jan 7, 2025

Closed in favour of #133

dmidem added a commit that referenced this pull request Jan 8, 2025
This PR is an updated copy of #128:

> The amount in AssetSupply must be a NoteValue (u64) and not a ValueSum
(i128).
> We add reference_notes into SupplyInfo. It is a hashmap of asset bases
to their respective reference note

The code was updated, `get_reference_note` method of `IssueAction` was
added and used, `get_reference_notes` was removed. Also, instead of a
separate new `reference_notes` `HashMap` in `SupplyInfo` a new field
`reference_note` was added to `AssetSupply` struct. Unit tests were
fixed accordingly.

---------

Co-authored-by: Constance Beguier <constance@qed-it.com>
Co-authored-by: Paul <3682187+PaulLaux@users.noreply.github.com>
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.

3 participants