forked from ethereum-optimism/optimism
-
Notifications
You must be signed in to change notification settings - Fork 1
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: introduce OptimismSuperchainERC20Factory #30
Closed
Closed
Changes from 14 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
64dc6d4
feat: add L2 standrad bridge interop contract
agusduha de677a2
test: add L2 standard bridge interop unit tests (#13)
agusduha 593efad
fix: add generic factory interface (#14)
agusduha 014c25d
feat: modify OptimismMintableERC20Factory for convert (#17)
agusduha b8bd100
Merge branch 'develop' into sc/liquidity-migration
agusduha 809a71b
fix: PR fixes
agusduha f4d0bb3
Merge branch 'develop' into sc/liquidity-migration
agusduha 2a3a723
test: fix address assuming
agusduha 8b74736
test: fix view warning
agusduha 05a54f3
feat: add superchain erc20 factory implementation (#23)
agusduha 2534555
test: add superchain erc20 factory tests (#25)
agusduha b210604
Merge branch 'develop' into sc/superchain-erc20-factory
agusduha 49b3ca8
test: fix expect emit
agusduha 348b798
fix: remove comments
agusduha 82062b4
feat: add constructor to superchain ERC20 beacon (#34)
agusduha 563501e
Merge branch 'develop' into sc/superchain-erc20-factory
agusduha d756948
test: remove factory predeploy etch
agusduha 9a43e01
fix: set an arbitrary address for superchain erc20 impl
agusduha File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_0() (gas: 369356) | ||
GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_1() (gas: 2967496) | ||
GasBenchMark_L1StandardBridge_Deposit:test_depositERC20_benchmark_0() (gas: 564483) | ||
GasBenchMark_L1StandardBridge_Deposit:test_depositERC20_benchmark_1() (gas: 4076526) | ||
GasBenchMark_L1StandardBridge_Deposit:test_depositERC20_benchmark_0() (gas: 564489) | ||
GasBenchMark_L1StandardBridge_Deposit:test_depositERC20_benchmark_1() (gas: 4076532) | ||
GasBenchMark_L1StandardBridge_Deposit:test_depositETH_benchmark_0() (gas: 466947) | ||
GasBenchMark_L1StandardBridge_Deposit:test_depositETH_benchmark_1() (gas: 3512629) | ||
GasBenchMark_L1StandardBridge_Finalize:test_finalizeETHWithdrawal_benchmark() (gas: 72624) | ||
GasBenchMark_L2OutputOracle:test_proposeL2Output_benchmark() (gas: 92973) | ||
GasBenchMark_L2OutputOracle:test_proposeL2Output_benchmark() (gas: 92970) | ||
GasBenchMark_OptimismPortal:test_depositTransaction_benchmark() (gas: 68433) | ||
GasBenchMark_OptimismPortal:test_depositTransaction_benchmark_1() (gas: 68903) | ||
GasBenchMark_OptimismPortal:test_proveWithdrawalTransaction_benchmark() (gas: 155618) | ||
GasBenchMark_OptimismPortal:test_proveWithdrawalTransaction_benchmark() (gas: 155615) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
packages/contracts-bedrock/snapshots/abi/OptimismSuperchainERC20Beacon.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
[ | ||
{ | ||
"inputs": [], | ||
"name": "implementation", | ||
"outputs": [ | ||
{ | ||
"internalType": "address", | ||
"name": "", | ||
"type": "address" | ||
} | ||
], | ||
"stateMutability": "pure", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [], | ||
"name": "version", | ||
"outputs": [ | ||
{ | ||
"internalType": "string", | ||
"name": "", | ||
"type": "string" | ||
} | ||
], | ||
"stateMutability": "view", | ||
"type": "function" | ||
} | ||
] |
93 changes: 93 additions & 0 deletions
93
packages/contracts-bedrock/snapshots/abi/OptimismSuperchainERC20Factory.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
[ | ||
{ | ||
"inputs": [ | ||
{ | ||
"internalType": "address", | ||
"name": "_remoteToken", | ||
"type": "address" | ||
}, | ||
{ | ||
"internalType": "string", | ||
"name": "_name", | ||
"type": "string" | ||
}, | ||
{ | ||
"internalType": "string", | ||
"name": "_symbol", | ||
"type": "string" | ||
}, | ||
{ | ||
"internalType": "uint8", | ||
"name": "_decimals", | ||
"type": "uint8" | ||
} | ||
], | ||
"name": "deploy", | ||
"outputs": [ | ||
{ | ||
"internalType": "address", | ||
"name": "_superchainERC20", | ||
"type": "address" | ||
} | ||
], | ||
"stateMutability": "nonpayable", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [ | ||
{ | ||
"internalType": "address", | ||
"name": "superchainToken", | ||
"type": "address" | ||
} | ||
], | ||
"name": "deployments", | ||
"outputs": [ | ||
{ | ||
"internalType": "address", | ||
"name": "remoteToken", | ||
"type": "address" | ||
} | ||
], | ||
"stateMutability": "view", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [], | ||
"name": "version", | ||
"outputs": [ | ||
{ | ||
"internalType": "string", | ||
"name": "", | ||
"type": "string" | ||
} | ||
], | ||
"stateMutability": "view", | ||
"type": "function" | ||
}, | ||
{ | ||
"anonymous": false, | ||
"inputs": [ | ||
{ | ||
"indexed": true, | ||
"internalType": "address", | ||
"name": "superchainToken", | ||
"type": "address" | ||
}, | ||
{ | ||
"indexed": true, | ||
"internalType": "address", | ||
"name": "remoteToken", | ||
"type": "address" | ||
}, | ||
{ | ||
"indexed": false, | ||
"internalType": "address", | ||
"name": "deployer", | ||
"type": "address" | ||
} | ||
], | ||
"name": "OptimismSuperchainERC20Created", | ||
"type": "event" | ||
} | ||
] |
1 change: 1 addition & 0 deletions
1
packages/contracts-bedrock/snapshots/storageLayout/OptimismSuperchainERC20Beacon.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[] |
9 changes: 9 additions & 0 deletions
9
packages/contracts-bedrock/snapshots/storageLayout/OptimismSuperchainERC20Factory.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[ | ||
{ | ||
"bytes": "32", | ||
"label": "deployments", | ||
"offset": 0, | ||
"slot": "0", | ||
"type": "mapping(address => address)" | ||
} | ||
] |
24 changes: 24 additions & 0 deletions
24
packages/contracts-bedrock/src/L2/OptimismSuperchainERC20Beacon.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.25; | ||
|
||
import { IBeacon } from "@openzeppelin/contracts-v5/proxy/beacon/IBeacon.sol"; | ||
import { ISemver } from "src/universal/ISemver.sol"; | ||
|
||
/// @custom:proxied | ||
/// @custom:predeployed 0x4200000000000000000000000000000000000027 | ||
/// @title OptimismSuperchainERC20Beacon | ||
/// @notice OptimismSuperchainERC20Beacon is the beacon proxy for the OptimismSuperchainERC20 implementation. | ||
contract OptimismSuperchainERC20Beacon is IBeacon, ISemver { | ||
/// TODO: Replace with real implementation address | ||
/// @notice Address of the OptimismSuperchainERC20 implementation. | ||
address internal constant IMPLEMENTATION_ADDRESS = 0x0000000000000000000000000000000000000000; | ||
|
||
/// @notice Semantic version. | ||
/// @custom:semver 1.0.0-beta.1 | ||
string public constant version = "1.0.0-beta.1"; | ||
|
||
/// @inheritdoc IBeacon | ||
function implementation() external pure override returns (address) { | ||
return IMPLEMENTATION_ADDRESS; | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
packages/contracts-bedrock/src/L2/OptimismSuperchainERC20Factory.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.25; | ||
|
||
import { IOptimismERC20Factory } from "src/L2/IOptimismERC20Factory.sol"; | ||
import { ISemver } from "src/universal/ISemver.sol"; | ||
import { OptimismSuperchainERC20 } from "src/L2/OptimismSuperchainERC20.sol"; | ||
import { Predeploys } from "src/libraries/Predeploys.sol"; | ||
import { BeaconProxy } from "@openzeppelin/contracts-v5/proxy/beacon/BeaconProxy.sol"; | ||
import { CREATE3 } from "@rari-capital/solmate/src/utils/CREATE3.sol"; | ||
|
||
/// @custom:proxied | ||
/// @custom:predeployed 0x4200000000000000000000000000000000000026 | ||
/// @title OptimismSuperchainERC20Factory | ||
/// @notice OptimismSuperchainERC20Factory is a factory contract that deploys OptimismSuperchainERC20 Beacon Proxies | ||
/// using CREATE3. | ||
contract OptimismSuperchainERC20Factory is IOptimismERC20Factory, ISemver { | ||
/// @notice Mapping of the deployed OptimismSuperchainERC20 to the remote token address. | ||
/// This is used to keep track of the token deployments. | ||
mapping(address superchainToken => address remoteToken) public deployments; | ||
|
||
/// @notice Emitted when an OptimismSuperchainERC20 is deployed. | ||
/// @param superchainToken Address of the SuperchainERC20 deployment. | ||
/// @param remoteToken Address of the corresponding token on the remote chain. | ||
/// @param deployer Address of the account that deployed the token. | ||
event OptimismSuperchainERC20Created( | ||
address indexed superchainToken, address indexed remoteToken, address deployer | ||
); | ||
|
||
/// @notice Semantic version. | ||
/// @custom:semver 1.0.0-beta.1 | ||
string public constant version = "1.0.0-beta.1"; | ||
|
||
/// @notice Deploys a OptimismSuperchainERC20 Beacon Proxy using CREATE3. | ||
/// @param _remoteToken Address of the remote token. | ||
/// @param _name Name of the OptimismSuperchainERC20. | ||
/// @param _symbol Symbol of the OptimismSuperchainERC20. | ||
/// @param _decimals Decimals of the OptimismSuperchainERC20. | ||
/// @return _superchainERC20 Address of the OptimismSuperchainERC20 deployment. | ||
function deploy( | ||
address _remoteToken, | ||
string memory _name, | ||
string memory _symbol, | ||
uint8 _decimals | ||
) | ||
external | ||
returns (address _superchainERC20) | ||
{ | ||
bytes memory initCallData = | ||
abi.encodeCall(OptimismSuperchainERC20.initialize, (_remoteToken, _name, _symbol, _decimals)); | ||
|
||
bytes memory creationCode = bytes.concat( | ||
type(BeaconProxy).creationCode, abi.encode(Predeploys.OPTIMISM_SUPERCHAIN_ERC20_BEACON, initCallData) | ||
); | ||
|
||
bytes32 salt = keccak256(abi.encode(_remoteToken, _name, _symbol, _decimals)); | ||
_superchainERC20 = CREATE3.deploy({ salt: salt, creationCode: creationCode, value: 0 }); | ||
|
||
deployments[_superchainERC20] = _remoteToken; | ||
|
||
emit OptimismSuperchainERC20Created(_superchainERC20, _remoteToken, msg.sender); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This contract isn't really proxied, right?
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.
All predeploys are proxied by default, maybe we should add it to the not proxied list
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.
If this the case, then leaving it like this is okay. I had the idea that this one was just going to have different code installed on hardforks, but I really don't remember where I got that from.