-
Notifications
You must be signed in to change notification settings - Fork 5
State validation for V2 Upgrade #34
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds state validation functionality to ensure contract storage data remains consistent before and after V2 upgrades. The implementation creates utility functions to read and compare contract storage layouts, then integrates these into the existing upgrade test suite.
- Added storage validation utilities for reading and comparing contract storage data
- Integrated state validation test into the zDAOToken V2 upgrade test suite
- Cleaned up configuration by removing unused imports and commenting out deprecated test networks
Reviewed Changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 9 comments.
File | Description |
---|---|
test/zDaoTokenV2.ts | Adds pre/post upgrade state validation test using new storage utilities |
scripts/utils/storage-check.ts | Implements storage layout reading and comparison utilities for upgrade validation |
package.json | Adds protocol-utils dependency and removes postinstall script |
hardhat.config.ts | Comments out deprecated network configs and removes unused task imports |
Comments suppressed due to low confidence (1)
scripts/utils/storage-check.ts:1
- [nitpick] Variable declaration should follow consistent spacing conventions. Add space before the colon:
preUpgradeState: ContractStorageData
.
import { getStorageLayout, getUnlinkedBytecode, getVersion, StorageLayout } from '@openzeppelin/upgrades-core';
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
scripts/utils/storage-check.ts
Outdated
|
||
export type ContractStorageElement = string | number | BigNumber | Array<object>; | ||
export type ContractStorageData = Array<{ | ||
[label : string] : ContractStorageElement; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Type declaration should follow consistent spacing conventions. Remove spaces around colons: [label: string]: ContractStorageElement
.
[label : string] : ContractStorageElement; | |
[label: string]: ContractStorageElement; |
Copilot uses AI. Check for mistakes.
scripts/utils/storage-check.ts
Outdated
[label : string] : ContractStorageElement; | ||
}>; | ||
export type ContractStorageDiff = Array<{ | ||
key : string; | ||
valueBefore : ContractStorageElement; | ||
valueAfter : ContractStorageElement; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Type declarations should follow consistent spacing conventions. Remove spaces around colons: key: string
, valueBefore: ContractStorageElement
, valueAfter: ContractStorageElement
.
[label : string] : ContractStorageElement; | |
}>; | |
export type ContractStorageDiff = Array<{ | |
key : string; | |
valueBefore : ContractStorageElement; | |
valueAfter : ContractStorageElement; | |
[label: string]: ContractStorageElement; | |
}>; | |
export type ContractStorageDiff = Array<{ | |
key: string; | |
valueBefore: ContractStorageElement; | |
valueAfter: ContractStorageElement; |
Copilot uses AI. Check for mistakes.
scripts/utils/storage-check.ts
Outdated
contractFactory : ContractFactory | ||
) : Promise<StorageLayout> => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Parameter and return type declarations should follow consistent spacing conventions. Remove spaces around colons: contractFactory: ContractFactory
and : Promise<StorageLayout>
.
Copilot uses AI. Check for mistakes.
scripts/utils/storage-check.ts
Outdated
contractFactory : ContractFactory, | ||
contractObj : Contract | ||
) : Promise<ContractStorageData> => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Parameter and return type declarations should follow consistent spacing conventions. Remove spaces around colons: contractFactory: ContractFactory
, contractObj: Contract
, and : Promise<ContractStorageData>
.
Copilot uses AI. Check for mistakes.
scripts/utils/storage-check.ts
Outdated
|
||
return layout.storage.reduce( | ||
async ( | ||
acc : Promise<ContractStorageData>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Parameter type declaration should follow consistent spacing conventions. Remove space around colon: acc: Promise<ContractStorageData>
.
acc : Promise<ContractStorageData>, | |
acc: Promise<ContractStorageData>, |
Copilot uses AI. Check for mistakes.
scripts/utils/storage-check.ts
Outdated
async ( | ||
acc : Promise<ContractStorageData>, | ||
{ label, type } | ||
) : Promise<ContractStorageData> => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Return type declaration should follow consistent spacing conventions. Remove space around colon: : Promise<ContractStorageData>
.
) : Promise<ContractStorageData> => { | |
): Promise<ContractStorageData> => { |
Copilot uses AI. Check for mistakes.
scripts/utils/storage-check.ts
Outdated
const value = await contractObj[(newLabel as keyof Contract)](); | ||
|
||
newAcc.push({ [label]: value }); | ||
} catch (e : unknown) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Type annotation should follow consistent spacing conventions. Remove space around colon: e: unknown
.
} catch (e : unknown) { | |
} catch (e: unknown) { |
Copilot uses AI. Check for mistakes.
scripts/utils/storage-check.ts
Outdated
dataBefore : ContractStorageData, | ||
dataAfter : ContractStorageData, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Parameter type declarations should follow consistent spacing conventions. Remove spaces around colons: dataBefore: ContractStorageData
, dataAfter: ContractStorageData
.
Copilot uses AI. Check for mistakes.
scripts/utils/storage-check.ts
Outdated
dataAfter : ContractStorageData, | ||
) => { | ||
const storageDiff = dataAfter.reduce( | ||
(acc : ContractStorageDiff | undefined, stateVar, idx) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Parameter type declaration should follow consistent spacing conventions. Remove space around colon: acc: ContractStorageDiff | undefined
.
(acc : ContractStorageDiff | undefined, stateVar, idx) => { | |
(acc: ContractStorageDiff | undefined, stateVar, idx) => { |
Copilot uses AI. Check for mistakes.
…and make a new test for full flow in upgrade
…oc. Also split and improve testing for full flow
No description provided.