Skip to content

Conversation

cgewecke
Copy link
Contributor

@cgewecke cgewecke commented Apr 28, 2021

DO NOT MERGE: PR TARGETS #81

PR:

  • selects the initial set of core contracts and test contract deps for Optimism L2
  • adds optimism's hardhat plugin and hardhat sizer dependencies (b/c size limits are critical)
  • add two OpenZeppelin contracts modified to be ovm-compatible:
    • SafeERC20.sol
    • Address.sol
  • adds misc. scripts to get everything running.
  • minimizes the circleci config to build. We will need to add custom setup as it becomes available. Some things like coverage are not currently possible with an OVM client.

Additional notes

The new Zeppelin contracts are ported from derekbar90/optimism-openzeppelin-compat. Optimism does not support the BALANCE opcode. Instead balances are checked by querying an address's native WETH balance on the Optimism network. These contracts are updated to reflect that.

Optimism:

  • Their hardhat compiler plugin has a bug I've written a patch for here and reported at eth-optimism/optimism 64.
  • The compiler substantially increases the size of contracts (network size constraints are the same as Mainnet: ~24kb)
  • The OVM has a lower gas limit (9_000_000) and large deployments can easily burn through it because the OVM runs additional logic in contract constructors to verify that no illegal opcodes are in the contract bytecode.

The initial contract set is below. Work to get everything structured so that it will deploy is ongoing.

Contracts Deploys to L2 Notes
Controller Yes  
IntegrationRegistry Yes  
PriceOracle Yes  
SetToken Yes  Restructuring WIP
SetTokenCreator No Size limit must be < 22.57 to avoid OOG
SetValuer WIP Probably ok
BasicIssuance WIP Probably ok
StreamingFeeModule WIP Probably ok
TradeModule WIP Probably ok

import "solidity-coverage";
import "hardhat-deploy";
import "hardhat-contract-sizer";
import "@eth-optimism/plugins/hardhat/compiler";
Copy link

Choose a reason for hiding this comment

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

The latest one is @eth-optimism/hardhat-ovm: https://www.npmjs.com/package/@eth-optimism/hardhat-ovm

Comment on lines +74 to 77
paths: {
artifacts: OVM ? "./artifacts-ovm" : "./artifacts",
cache: OVM ? "./cache-ovm" : "./cache",
},
Copy link

Choose a reason for hiding this comment

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

Should not be needed if you use hardhat-ovm

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 project consumes its bytecode out of typechain factories rather than hardhat artifacts. The typechain plugin reads paths.artifacts here.

Note to self: check what this value is in the typechain plugin compile hook.

cache definitely removable.

@cgewecke
Copy link
Contributor Author

cgewecke commented Oct 6, 2021

Closing for the moment, will revisit when support for Optimism is scheduled

@cgewecke cgewecke closed this Oct 6, 2021
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.

2 participants