Skip to content

refactor[contracts]: Port OVM_ProxyEOA to use ovm-solc#545

Merged
smartcontracts merged 3 commits intomasterfrom
ovm-solc/proxy-eoa
Apr 22, 2021
Merged

refactor[contracts]: Port OVM_ProxyEOA to use ovm-solc#545
smartcontracts merged 3 commits intomasterfrom
ovm-solc/proxy-eoa

Conversation

@smartcontracts
Copy link
Copy Markdown
Contributor

Description
Continuation of the work started in #475. Ports OVM_ProxyEOA to use ovm-solc. This introduces an interesting problem because OVM_ExecutionManager uses the standard solc and can therefore no longer reference OVM_ProxyEOA directly in order to create a new version of it during ovmCREATEEOA. Instead, we deploy a template version of OVM_ProxyEOA that can be duplicated during ovmCREATEEOA. This is a bit less efficient, not exactly sure how much less efficient but I doubt it'll matter very much.

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 21, 2021

🦋 Changeset detected

Latest commit: 2e405df

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@eth-optimism/contracts Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@smartcontracts smartcontracts marked this pull request as draft April 21, 2021 20:29

this.contracts.OVM_DeployerWhitelist = DeployerWhitelist

this.contracts.OVM_ProxyEOA = await getContractFactory(
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Here we deploy the reference version of the OVM_ProxyEOA which is duplicated by the OVM_ExecutionManager.

@smartcontracts smartcontracts marked this pull request as ready for review April 21, 2021 21:35
Copy link
Copy Markdown
Contributor

@karlfloersch karlfloersch left a comment

Choose a reason for hiding this comment

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

I didn't catch anything so seeeeemed to look good. However, definitely would like another set of eyes on this! Especially with raw opcode writing -- cc @ben-chain

// PUSH1 0x00
// CODECOPY # copy everything after prefix into memory at pos 0
// PUSH1 0x00
// RETURN # return the copied code
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@ben-chain would love to have your eyes here

// PUSH1 0x00
// RETURN # return the copied code
address proxyEOA = Lib_EthUtils.createContract(abi.encodePacked(
hex"600D380380600D6000396000f3",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Confirmed that this does indeed decompile to the opcodes in the comment above

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This bytestring looks good; it would also be super obvious from integration tests if it weren't looking. Since we do not have constructors, then this code could obviously also be put in place without a constructor. I assume we are going this way for ease of implementation in geth, right @smartcontracts? if so, we could use the ovmSETCODE upgrade path in the future.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Good call on using SETCODE for this in the future

@smartcontracts smartcontracts changed the title Port OVM_ProxyEOA to use ovm-solc refactor[contracts]: Port OVM_ProxyEOA to use ovm-solc Apr 21, 2021
Copy link
Copy Markdown
Collaborator

@ben-chain ben-chain left a comment

Choose a reason for hiding this comment

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

This LGTM!

*************/

address constant DEFAULT_IMPLEMENTATION = 0x4200000000000000000000000000000000000003;
bytes32 constant IMPLEMENTATION_KEY = 0xdeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddead;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Maybe for a separate PR, but harping again that this should really use this EIP here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I agree that we should use that EIP, note that this will also break our regenesis script
https://github.com/ethereum-optimism/scripts/blob/main/scripts/state-surgery.js
Will add an issue over there

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Created an issue here: #550

IMPLEMENTATION_KEY,
Lib_Bytes32Utils.fromAddress(_implementation)
);
bytes32 addr32 = Lib_Bytes32Utils.fromAddress(_implementation);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I double checked the test files to make sure these are aligned correctly, looks good.

address proxyEOA = Lib_EthUtils.createContract(abi.encodePacked(
hex"600D380380600D6000396000f3",
ovmEXTCODECOPY(
0x4200000000000000000000000000000000000009,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Recommend to resolve these addresses

// PUSH1 0x00
// RETURN # return the copied code
address proxyEOA = Lib_EthUtils.createContract(abi.encodePacked(
hex"600D380380600D6000396000f3",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This bytestring looks good; it would also be super obvious from integration tests if it weren't looking. Since we do not have constructors, then this code could obviously also be put in place without a constructor. I assume we are going this way for ease of implementation in geth, right @smartcontracts? if so, we could use the ovmSETCODE upgrade path in the future.

factory: getContractFactory('ERC1820Registry'),
},
OVM_ProxyEOA: {
factory: getContractFactory('OVM_ProxyEOA', undefined, true),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What are these additional arguments? undefined is probably a provider, what is true? imo Python kwargs are handy for this kind of thing which can be replicated by making the second argument an object

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agree that we should make these additional arguments an object. Although probably deserves its own issue.

Copy link
Copy Markdown
Contributor

@tynes tynes left a comment

Choose a reason for hiding this comment

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

Please add a changeset and is this safe to merge to master?

@smartcontracts
Copy link
Copy Markdown
Contributor Author

Yes, safe to merge. Will add a changeset.

@smartcontracts
Copy link
Copy Markdown
Contributor Author

Changeset added.

@smartcontracts smartcontracts merged commit edb4346 into master Apr 22, 2021
@smartcontracts smartcontracts deleted the ovm-solc/proxy-eoa branch April 22, 2021 18:00
InoMurko referenced this pull request in omgnetwork/optimism May 25, 2021
* Port OVM_ProxyEOA to use ovm-solc

* Remove all constructor logic from ProxyEOA

* chore[contracts]: add changeset
theochap pushed a commit that referenced this pull request Jan 15, 2026
…e` and `Safe`->`CrossSafe` (#545)

Updates `SafetyLevel` variant names to match Go impl

Ref ethereum-optimism/specs#717
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.

5 participants