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

Extract type requirements from old code for staged contracts #1705

Merged
merged 6 commits into from
Aug 28, 2024

Conversation

SupunS
Copy link
Member

@SupunS SupunS commented Aug 23, 2024

Work towards supporting onflow/cadence#3527 in Flow CLI.

i.e: integrating onflow/flow-go#6341 to the CLI.

Description

Depends on onflow/flow-go#6395


For contributor use:

  • Targeted PR against master branch
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work
  • Code follows the standards mentioned here
  • Updated relevant documentation
  • Re-reviewed Files changed in the Github PR explorer
  • Added appropriate labels

@@ -187,10 +190,12 @@ func (v *stagingValidatorImpl) Validate(stagedContracts []stagedContractUpdate)

v.stagedContracts = make(map[common.AddressLocation]stagedContractUpdate)
for _, stagedContract := range stagedContracts {
v.stagedContracts[stagedContract.DeployLocation] = stagedContract
stagedContractLocation := stagedContract.DeployLocation
Copy link
Member Author

Choose a reason for hiding this comment

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

contract update validator relies on typeIDs. So had to use the DeployLocation in all places, instead of SourceLocation

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Added a dedicated test for ^above: bd87b9f

@SupunS SupunS requested a review from turbolent August 23, 2024 22:46
@SupunS SupunS self-assigned this Aug 23, 2024
@SupunS SupunS added the Improvement Technical work without new features, refactoring, improving tests label Aug 23, 2024
@SupunS SupunS changed the title Extract type requirements from old code Extract type requirements from old code for staged contracts Aug 23, 2024
@SupunS SupunS force-pushed the supun/support-type-requirements branch from 7c5d6c1 to 68d9ad5 Compare August 23, 2024 22:50
@SupunS SupunS force-pushed the supun/support-type-requirements branch from 68d9ad5 to 091c693 Compare August 23, 2024 22:58
typeRequirements := &migrations.LegacyTypeRequirements{}

// Extract type requirements from the old codes for all staged contracts.
for _, contract := range v.stagedContracts {
Copy link
Member Author

Choose a reason for hiding this comment

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

Actual improvement is this block: extract type requirements from old code

Comment on lines -561 to -598
// If the contract one of our staged contract updates, use the source location
if stagedUpdate, ok := v.stagedContracts[resovledAddrLocation]; ok {
resolvedLocation = stagedUpdate.SourceLocation
} else {
resolvedLocation = resovledAddrLocation
}

Copy link
Member Author

Choose a reason for hiding this comment

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

I think there is no need to separate the staged contracts vs other contracts now, given staged contracts also uses DeployLocation, which is an address location.

Copy link

@SupunS SupunS marked this pull request as ready for review August 27, 2024 16:45
Copy link
Member

@turbolent turbolent left a comment

Choose a reason for hiding this comment

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

Nice work!

@jribbink can you PTAL?

@codecov-commenter
Copy link

codecov-commenter commented Aug 27, 2024

Codecov Report

Attention: Patch coverage is 93.10345% with 4 lines in your changes missing coverage. Please review.

Project coverage is 34.15%. Comparing base (763e01c) to head (bd87b9f).

Files Patch % Lines
internal/migrate/staging_validator.go 93.10% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1705      +/-   ##
==========================================
- Coverage   34.32%   34.15%   -0.18%     
==========================================
  Files         100      100              
  Lines        6368     6386      +18     
==========================================
- Hits         2186     2181       -5     
- Misses       3894     3922      +28     
+ Partials      288      283       -5     
Flag Coverage Δ
unittests 34.15% <93.10%> (-0.18%) ⬇️

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.

@SupunS SupunS merged commit 5dd8fdd into master Aug 28, 2024
5 checks passed
@SupunS SupunS deleted the supun/support-type-requirements branch August 28, 2024 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Improvement Technical work without new features, refactoring, improving tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants