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

Handle different contract versions #130

Merged
merged 22 commits into from
Jan 1, 2021
Merged

Conversation

germartinez
Copy link
Member

No description provided.

@germartinez germartinez added the ts This issues is related to ts lib changes label Nov 3, 2020
@germartinez germartinez requested a review from cag November 3, 2020 10:06
@germartinez germartinez self-assigned this Nov 3, 2020
@germartinez germartinez linked an issue Nov 3, 2020 that may be closed by this pull request
@cag cag mentioned this pull request Nov 9, 2020
Copy link
Contributor

@cag cag left a comment

Choose a reason for hiding this comment

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

This will probably get merged, and most of it looks tight, but in particular, the configuration normalization logic should get reworked.

@@ -175,23 +146,23 @@ class CPK {
}

get contract(): Contract | undefined {
return this.#contract
return this.#contractManager?.contract
Copy link
Contributor

Choose a reason for hiding this comment

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

Way to wrap the accessor earlier so that this can be done without a change to the interface!

if (!this.#fallbackHandlerAddress) {
throw new Error('CPK fallbackHandlerAddress uninitialized')
if (!this.#contractManager) {
throw new Error('CPK contractManager uninitialized')
Copy link
Contributor

Choose a reason for hiding this comment

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

This possibly indicates a change in behavior. Whereas before, contract methods are lazily evaluated, now it may be that if the contract isn't there at init time of the CPK, it fails then, instead of inside of execTransactions.

}

export interface NetworkConfigEntry {
masterCopyAddress: Address
Copy link
Contributor

@cag cag Dec 18, 2020

Choose a reason for hiding this comment

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

I think this be an optional field. Widening the type here still respects semantic versioning, and this way, somebody using the new typing could just pass in masterCopyAddressVersions instead of masterCopyAddress. Also see my remarks in the normalization logic and in the tests where this requirement exists.

proxyFactoryAddress: networks[networkId].proxyFactoryAddress,
multiSendAddress: networks[networkId].multiSendAddress,
fallbackHandlerAddress: networks[networkId].fallbackHandlerAddress
}
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems that if the user specifies the masterCopyAddressVersions field in networks, this method will ignore the user's settings. That doesn't seem right to me.

Maybe instead use something like:

    if (networks[networkId].masterCopyAddress) {
      mcVersions = [
        {
          version: masterCopyAddressVersions[0].version,
          address: networks[networkId].masterCopyAddress
        }
      ]
    } else if (networks[networkId].masterCopyAddressVersions) {
      mcVersions = networks[networkId].masterCopyAddressVersions
    }

Also, looking at the code, it's clear that mcVersions must be nonempty in order for the CPK to function for a particular network, so a check to validate that after this may be a good thing.

const codeAtAddress = await ethLibAdapter.getCode(proxyAddress)
const isDeployed = codeAtAddress !== '0x'
if (isDeployed) {
properVersion = masterCopyVersion.version
Copy link
Contributor

@cag cag Dec 18, 2020

Choose a reason for hiding this comment

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

Maybe it would be better to set properVersion = await temporaryContract.call('VERSION', []) here? That way, if a user has upgraded the proxy, this method will switch to the more efficient module manager for the upgraded version.

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 would like to talk about this in Zoom :)

return proxyAddress
}

get contractVersionManager(): CommonContractManager | undefined {
Copy link
Contributor

Choose a reason for hiding this comment

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

moduleManager?

address: gnosisSafe2.address,
version: '1.1.1'
}
],
masterCopyAddress: gnosisSafe.address,
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd remove masterCopyAddress here because it actually overrides the masterCopyAddressVersions from what I can tell from the code. Of course, that would require making the masterCopyAddress field optional in the entry type.

@germartinez germartinez force-pushed the handle-contract-versions branch from 962fde0 to 0ffdb2d Compare December 24, 2020 14:45
@germartinez germartinez force-pushed the handle-contract-versions branch from 0ffdb2d to 06a2562 Compare December 24, 2020 14:59
@germartinez germartinez requested a review from cag December 30, 2020 17:07
Copy link
Contributor

@cag cag left a comment

Choose a reason for hiding this comment

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

Yes, I've been working off this commit so it LGTM. Merged it, so handle it from #126

@cag cag merged commit 1bfedad into contract-v1.2.0 Jan 1, 2021
@germartinez germartinez mentioned this pull request Feb 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ts This issues is related to ts lib changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Research how to best handle changing proxy addresses
2 participants