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

RET manfiest classification update #373

Merged
merged 15 commits into from
Feb 12, 2025
Merged

RET manfiest classification update #373

merged 15 commits into from
Feb 12, 2025

Conversation

GhenadieVP
Copy link
Contributor

@GhenadieVP GhenadieVP commented Feb 6, 2025

Update to use new RET manifest summary models.

For now just mapped new models to current Sargon structure with the intent to reduce the number of changes as much as possible.

A followup PR will add additional fields/models to Sargon's ManifestSummary/ExecutionSummary to make use of new RET summary surfaced information.

Copy link

codecov bot commented Feb 6, 2025

Codecov Report

Attention: Patch coverage is 93.60269% with 19 lines in your changes missing coverage. Please review.

Project coverage is 92.77%. Comparing base (8b3f5c7) to head (f475a40).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...vel/transaction_classes/detailed_manifest_class.rs 90.69% 8 Missing ⚠️
.../resource_indicator/fungible_resource_indicator.rs 71.42% 4 Missing ⚠️
...c/low_level/execution_summary/execution_summary.rs 93.47% 3 Missing ⚠️
...rates/crypto/addresses/src/address/decl_address.rs 90.00% 2 Missing ⚠️
...ource_indicator/non_fungible_resource_indicator.rs 90.90% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #373      +/-   ##
==========================================
+ Coverage   92.68%   92.77%   +0.08%     
==========================================
  Files        1190     1190              
  Lines       26861    26907      +46     
  Branches       85       85              
==========================================
+ Hits        24896    24962      +66     
+ Misses       1954     1934      -20     
  Partials       11       11              
Flag Coverage Δ
kotlin 98.64% <ø> (ø)
rust 92.43% <93.60%> (+0.10%) ⬆️
swift 92.66% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

impl TryFrom<(ScryptoManifestResourceAddress, NetworkID)> for ResourceAddress {
type Error = CommonError;
fn try_from(
value: (ScryptoManifestResourceAddress, NetworkID),
Copy link
Contributor

Choose a reason for hiding this comment

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

an alternative spelling is: (address, network): (ScryptoManifestResourceAddress, NetworkID) which I've started to use

fn from(value: (RetNewEntities, NetworkID)) -> Self {
let (ret, network_id) = value;
impl
From<(
Copy link
Contributor

Choose a reason for hiding this comment

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

oh wow, hehe, I think maybe best do this as a named ctor on NewEntities, this is quite hard to read

return Ok(ManifestEncounteredComponentAddress::$variant(address));
}
)*

Err(CommonError::FailedToCreateAddressFromGlobalAddressAndNetworkID {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe rename the error to FailedToCreateAddressFromManifestAddressAndNetworkID { address: address.to_string() } or to_hex

@GhenadieVP GhenadieVP marked this pull request as ready for review February 7, 2025 10:52
@@ -370,6 +370,7 @@ iso8601-timestamp = { version = "0.2.16", default-features = false, features = [
] }

itertools = { version = "0.12.0", default-features = true }
either = { version = "1.13.0", default-features = false }
Copy link
Contributor

Choose a reason for hiding this comment

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

Im really not a fan of Either as ::Left gives zero glue as to what it is. Can we create a custom enum instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am using Either as it is part of iter partition_map API, might need to revisit then that implementation. Either is good for temporary types, similar to tuples.

pub(crate) fn filter_try_to_hashmap_network_aware_key<K, V, L, U>(
values: impl IntoIterator<Item = (K, V)>,
network_id: NetworkID,
) -> HashMap<L, U>
Copy link
Contributor

Choose a reason for hiding this comment

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

should we return IndexMap instead for stable sorting helpful when debugging?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah right, may be a good time to use IndexMap instead of HashMap where possible

@@ -79,7 +96,7 @@ pub struct ExecutionSummary {

/// The set of instructions encountered in the manifest that are reserved
/// and can only be included in the manifest by the wallet itself.
pub reserved_instructions: Vec<ReservedInstruction>,
pub reserved_instructions: IndexSet<ReservedInstruction>,
Copy link
Contributor

Choose a reason for hiding this comment

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

👍 ah nice with IndexSet! post break out UniFFI allows us to do this, excellent!

.or_default()
.insert(resource_address, update);
};
acc
Copy link
Contributor

Choose a reason for hiding this comment

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

if any is err. we effectively filter it out without error? should be log at least?

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 can fail only if there are named manifest addresses, which now are simply ignored.

let resource =
ResourceOrNonFungible::try_from((manifest_resource, n))
.ok()?;
Some(((account_address, resource), op))
Copy link
Contributor

Choose a reason for hiding this comment

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

log if err?

Copy link
Contributor

@CyonAlexRDX CyonAlexRDX left a comment

Choose a reason for hiding this comment

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

Great job! nothing major at all

@GhenadieVP GhenadieVP merged commit 037513b into main Feb 12, 2025
17 checks passed
@GhenadieVP GhenadieVP deleted the ret_update branch February 12, 2025 07:13
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