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

Martinvol/isolate 0.8 artifacts for gasPriceMinimum #10437

Merged
merged 114 commits into from
Sep 15, 2023

Conversation

martinvol
Copy link
Contributor

@martinvol martinvol commented Jul 26, 2023

Description

This PR fixes key features of our tooling to enable the tooling to be able to deploy 0.8 Solidity. The keys to the approach are:

  1. Truffle now has two folders for contracts, one for all 0.5.* contracts and other for 0.8.*. Contracts that are shared were were left in the original folder, but their pragma was made more flexible (but truffle will compile with the specified compiler).
    a. The reason to have separate folders is that if a contract is built, it compiles all its dependencies with the solidity version of the contract, but if those were already built for a different smart contract, the artifacts get overwritten, making the storage check fail.
  2. Truffle now has two configuration files, one for 0.5.* and one for 0.8.*, using automatic "pragma" setting will cause the error described in 1.a
  3. Artifacts once built also land in a separate folder to avoid collisions, this is a similar approach to the one used when removing mento contracts.
  4. A big chunk of the PR is making the tooling aware that now artifacts are in more than one folder, those a bunch of function inputs were changed to arrays
  5. Libraries were removed because they had files (name SafeMath), that were overwriting or own, and thus causing problems.
  6. Another important consideration is that GasPriceMinimum has a new solidity version and it's in a different folder, but its proxy it's still the same as before. This is because code changes will be needed to make it compatible with 0.8. For that reason, many helpers were created to specify the proxy artifact.

TODO:

  • Make it build with multiple Solidity versions going to different artifacts
  • Fix tests (at this point there's a lot of flakiness, but only a couple actually fail)
  • Make sure verify-deployed, verify-release works, make-release and check-versions work. (Volpe: I tested it but right before merging it should be done again)
  • have two truffle configs sharing a single parent
  • Clean up code, remove TODO's
  • Clean up code, remove console.log

Other changes

Describe any minor or "drive-by" changes here.

Tested

An explanation of how the changes were tested or an explanation as to why they don't need to be.

Related issues

  • Fixes #[issue number here]

Backwards compatibility

Brief explanation of why these changes are/are not backwards compatible.

Documentation

The set of community facing docs that have been added/modified because of this change

@socket-security
Copy link

socket-security bot commented Jul 26, 2023

Removed dependencies detected. Learn more about Socket for GitHub ↗︎

🚮 Removed packages: @summa-tx/[email protected]

try {
contractArtifact = await artifacts.require(contractName) // I think it won't be able to find GasPriceMinimum here
} catch {
// it wasn't found in the standar artifacts folder, check if it's
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 needs to be generalized

Copy link
Contributor

@soloseng soloseng left a comment

Choose a reason for hiding this comment

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

Looks good! Made a few comment.

To keep the protocol folder structure simple, would it be possible to organize contracts with a subdirectory for v0.5 & v0.8.

packages/protocol/truffle-config0.8.js Show resolved Hide resolved
@@ -0,0 +1,77 @@
// SPDX-License-Identifier: MIT
// Original authors: https://github.com/summa-tx/memview-sol
pragma solidity >=0.5.10;
Copy link
Contributor

Choose a reason for hiding this comment

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

should this version be updated to pragma solidity >=0.5.10 <0.8.0;?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch

@@ -68,43 +57,7 @@ contract UsingRegistry is Ownable {
emit RegistrySet(registryAddress);
}

function getAccounts() internal view returns (IAccounts) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Just wondering, why does this remove a bunch of the getters?

Also, is there a reason this is modeled after the original UsingRegistry rather than the more efficient UsingRegistryV2?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's done like this so I didn't have to make the interfaces have permissive pragmas.

Regarding the UsingRegistryV2, I'm not sure, the first implementation used this one, but I'll take a look.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

but now thinking about this, we already have flexible pragmas and everything lands in the right folder, so I guess I could bring it back. Will try that, thanks for the comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just remembered why not all getters could are there, because Mento's ones can be used with 0.8.

It is not using UsingRegistryV2 because gasPriceMinimum is using UsingRegistry.

packages/protocol/contracts-0.8/UsingRegistry8.sol Outdated Show resolved Hide resolved
packages/protocol/lib/bytecode.ts Outdated Show resolved Hide resolved
Comment on lines 140 to 141
console.log("this.addresses[library]", this.addresses[library])
console.log("address", address)
Copy link
Contributor

Choose a reason for hiding this comment

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

Debug logs to be removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After I'm done :)
(verify release still doesn't work)

packages/protocol/lib/compatibility/report.ts Outdated Show resolved Hide resolved
reportIndex.libraries[contract] = changesByContract[contract]
} else {
const report = ASTVersionedReport.create(changesByContract[contract])
reportIndex.contracts[contract] = report
}
})
console.log("made it here b")
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto here and elsewhere, but I guess it's still a WIP PR.

packages/protocol/scripts/build.ts Outdated Show resolved Hide resolved
packages/protocol/scripts/build.ts Outdated Show resolved Hide resolved
@pahor167 pahor167 requested a review from a team as a code owner September 7, 2023 13:41
@pahor167 pahor167 requested a review from ssubram11 September 7, 2023 13:41
@@ -28,7 +28,7 @@ testWithGanache('releasegold:withdraw cmd', (web3: Web3) => {
test('can withdraw released gold to beneficiary', async () => {
await testLocally(SetLiquidityProvision, ['--contract', contractAddress, '--yesreally'])
// ReleasePeriod of default contract
await timeTravel(100000000, web3)
await timeTravel(300000000, web3)
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 fix is cherry-picked from master, right @pahor167

@martinvol martinvol merged commit 277107c into martinvol/CR10Release Sep 15, 2023
32 of 37 checks passed
@martinvol martinvol deleted the martinvol/isolate-0.8-artifacts branch September 15, 2023 15:36
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.

7 participants