-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
feat: OVM #491
feat: OVM #491
Conversation
This reverts commit 7a4e277. -> Temporary revert. TODO: Load wallets conditionally on `--network optimism`
Waffle event emitter seems to be having problems with Optimism
The try/catch pattern does not yield the revert msg when used with geth. We would need to use the `expect(tx).to.be.revertedWith` pattern
9a9d213
to
e5c8912
Compare
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.
can we do something about the modifiers -> functions change?
run: yarn optimism-up | ||
|
||
- name: Run unit tests | ||
run: UPDATE_SNAPSHOT=1 yarn test:ovm |
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.
ditto
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.
We'd need to generate 2 different snapshots since gas costs differ between EVM and OVM (due to including L1 data publishing costs). I don't think the snapshot plugin supports that right now. I changed this to test the snapshot for the EVM tests however, to ensure that the baseline performance is ~same as the one we have in main.
did a first pass, nothing jumped out to me as a big problem, though i echo what moody already pointed out |
@@ -256,3 +257,12 @@ export function createMultiPoolFunctions({ | |||
swapForExact1Multi, | |||
} | |||
} | |||
|
|||
/** | |||
* @notice The OVM emits an additional `Transfer` event due to its usage of WETH instead of native ETH. As a result, |
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.
is this transfer the payment of gas?
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.
Yes
Summary
The OVM is a sandboxed environment for the EVM which allows execution of smart contract code on L2, with the ability to dispute it on L1 via a fraud proof. Solidity code can be compiled directly to OVM code instead of EVM code by using "optimistic solc", a fork of the well-known solc. The OVM bytecode is ~30% larger than EVM bytecode, which may result in the bytecode being larger than the 24kb size limit for smart contracts.
This PR refactors the codebase to allow it to fit in the 24kb limit, and does a minimal diff to the test suite so that tests can pass when ran against an instance of go-ethereum running the OVM. I suspect the test suite changes around waiting for txs to be confirmed would've been required anyway if we wanted to test against geth or any full node impl.
Explanation of code changes
.wait()
. This is because tests are run against go-ethereum which does not insta-mine, hence receipts are not immediately available in tests.hardhat
optimism
hardhat-ovm
which allows compiling to the OVM when the target network has theovm: true
flag setscripts/run-optimism.sh
script which will clone the Optimism monorepo, build it, and bring up the networkinternal
functions topublic
, so that they get deployed as separate contracts and do not contribute to the bytecode of the "main" contract. Certain functions were also batched together to minimize the number ofdelegatecall
s needed (e.g.updateBoth
).Status
All tests pass both in the EVM and in the OVM! Due to the lack of snapshots and running against a real node, tests take much longer, ~90mins.
The linter fails due to perms, but I formatted everything in the last commit.
h/t to @mds1 and @elenadimitrova for the help :)