Commit 2d65f0d9 authored by Mark Tyneway's avatar Mark Tyneway Committed by GitHub

state-surgery: genesis block generation (#3264)

* state-surgery: layer 2 genesis block generation

Generate the L2 or L1 genesis block given a hardhat and a deploy config.

* state-surgery: some comments

* state-surgery: delete dead comment
parent bfa22916
...@@ -420,6 +420,9 @@ jobs: ...@@ -420,6 +420,9 @@ jobs:
docker: docker:
- image: ethereumoptimism/ci-builder:latest - image: ethereumoptimism/ci-builder:latest
steps: steps:
- restore_cache:
keys:
- v2-cache-yarn-build-{{ .Revision }}
- checkout - checkout
- run: - run:
name: Check if we should run name: Check if we should run
...@@ -709,11 +712,14 @@ workflows: ...@@ -709,11 +712,14 @@ workflows:
binary_name: bss-core binary_name: bss-core
working_directory: bss-core working_directory: bss-core
build: false build: false
- state-surgery-tests:
name: state-surgery-tests
requires:
- yarn-monorepo
- geth-tests - geth-tests
- integration-tests - integration-tests
- semgrep-scan - semgrep-scan
- go-mod-tidy - go-mod-tidy
- state-surgery-tests
- docker-publish: - docker-publish:
name: op-node-publish-dev name: op-node-publish-dev
docker_file: op-node/Dockerfile docker_file: op-node/Dockerfile
......
{
"address": "0x959922bE3CAee4b8Cd9a407cc3ac1C251C2007B1",
"abi": [
{
"inputs": [
{
"internalType": "address",
"name": "_owner",
"type": "address"
}
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "user",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "newOwner",
"type": "address"
}
],
"name": "OwnerUpdated",
"type": "event"
},
{
"inputs": [],
"name": "addressManager",
"outputs": [
{
"internalType": "contract AddressManager",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address payable",
"name": "_proxy",
"type": "address"
},
{
"internalType": "address",
"name": "_newAdmin",
"type": "address"
}
],
"name": "changeProxyAdmin",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address payable",
"name": "_proxy",
"type": "address"
}
],
"name": "getProxyAdmin",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_proxy",
"type": "address"
}
],
"name": "getProxyImplementation",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "implementationName",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "isUpgrading",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "owner",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "proxyType",
"outputs": [
{
"internalType": "enum ProxyAdmin.ProxyType",
"name": "",
"type": "uint8"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "string",
"name": "_name",
"type": "string"
},
{
"internalType": "address",
"name": "_address",
"type": "address"
}
],
"name": "setAddress",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "contract AddressManager",
"name": "_address",
"type": "address"
}
],
"name": "setAddressManager",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_address",
"type": "address"
},
{
"internalType": "string",
"name": "_name",
"type": "string"
}
],
"name": "setImplementationName",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "newOwner",
"type": "address"
}
],
"name": "setOwner",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_address",
"type": "address"
},
{
"internalType": "enum ProxyAdmin.ProxyType",
"name": "_type",
"type": "uint8"
}
],
"name": "setProxyType",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "bool",
"name": "_upgrading",
"type": "bool"
}
],
"name": "setUpgrading",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address payable",
"name": "_proxy",
"type": "address"
},
{
"internalType": "address",
"name": "_implementation",
"type": "address"
}
],
"name": "upgrade",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address payable",
"name": "_proxy",
"type": "address"
},
{
"internalType": "address",
"name": "_implementation",
"type": "address"
},
{
"internalType": "bytes",
"name": "_data",
"type": "bytes"
}
],
"name": "upgradeAndCall",
"outputs": [],
"stateMutability": "payable",
"type": "function"
}
],
"transactionHash": "0xd4c554d46e4395d812e72e473415551e8c519da963bead4c776d93e36ecbfc85",
"receipt": {
"to": null,
"from": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
"contractAddress": "0x959922bE3CAee4b8Cd9a407cc3ac1C251C2007B1",
"transactionIndex": 0,
"gasUsed": "1622894",
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000020000000020000100000800000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000200000000000000000000000002000000000000000000020000000000000000000030000000000000000000000000000000000000000000000",
"blockHash": "0xaeff4c7621126c925936684083b15da29ab7a4afa0487871c2f47653592e0487",
"transactionHash": "0xd4c554d46e4395d812e72e473415551e8c519da963bead4c776d93e36ecbfc85",
"logs": [
{
"transactionIndex": 0,
"blockNumber": 17,
"transactionHash": "0xd4c554d46e4395d812e72e473415551e8c519da963bead4c776d93e36ecbfc85",
"address": "0x959922bE3CAee4b8Cd9a407cc3ac1C251C2007B1",
"topics": [
"0x8292fce18fa69edf4db7b94ea2e58241df0ae57f97e0a6c9b29067028bf92d76",
"0x0000000000000000000000000000000000000000000000000000000000000000",
"0x000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb92266"
],
"data": "0x",
"logIndex": 0,
"blockHash": "0xaeff4c7621126c925936684083b15da29ab7a4afa0487871c2f47653592e0487"
}
],
"blockNumber": 17,
"cumulativeGasUsed": "1622894",
"status": 1,
"byzantium": true
},
"args": [
"0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"
],
"numDeployments": 1,
"solcInputHash": "a94fc0e98621248a4fbd9c87bf1e6a39",
"metadata": "{\"compiler\":{\"version\":\"0.8.15+commit.e14f2714\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_owner\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnerUpdated\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"addressManager\",\"outputs\":[{\"internalType\":\"contract AddressManager\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address payable\",\"name\":\"_proxy\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_newAdmin\",\"type\":\"address\"}],\"name\":\"changeProxyAdmin\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address payable\",\"name\":\"_proxy\",\"type\":\"address\"}],\"name\":\"getProxyAdmin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_proxy\",\"type\":\"address\"}],\"name\":\"getProxyImplementation\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"implementationName\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"isUpgrading\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"proxyType\",\"outputs\":[{\"internalType\":\"enum ProxyAdmin.ProxyType\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"_name\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"_address\",\"type\":\"address\"}],\"name\":\"setAddress\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract AddressManager\",\"name\":\"_address\",\"type\":\"address\"}],\"name\":\"setAddressManager\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_address\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"_name\",\"type\":\"string\"}],\"name\":\"setImplementationName\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"setOwner\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_address\",\"type\":\"address\"},{\"internalType\":\"enum ProxyAdmin.ProxyType\",\"name\":\"_type\",\"type\":\"uint8\"}],\"name\":\"setProxyType\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bool\",\"name\":\"_upgrading\",\"type\":\"bool\"}],\"name\":\"setUpgrading\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address payable\",\"name\":\"_proxy\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_implementation\",\"type\":\"address\"}],\"name\":\"upgrade\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address payable\",\"name\":\"_proxy\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_implementation\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"}],\"name\":\"upgradeAndCall\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"changeProxyAdmin(address,address)\":{\"params\":{\"_newAdmin\":\"Address of the new proxy admin.\",\"_proxy\":\"Address of the proxy to update.\"}},\"constructor\":{\"params\":{\"_owner\":\"Address of the initial owner of this contract.\"}},\"getProxyAdmin(address)\":{\"params\":{\"_proxy\":\"Address of the proxy to get the admin of.\"},\"returns\":{\"_0\":\"Address of the admin of the proxy.\"}},\"getProxyImplementation(address)\":{\"params\":{\"_proxy\":\"Address of the proxy to get the implementation of.\"},\"returns\":{\"_0\":\"Address of the implementation of the proxy.\"}},\"isUpgrading()\":{\"custom:legacy\":\"@notice Legacy function used to tell ChugSplashProxy contracts if an upgrade is happening.\",\"returns\":{\"_0\":\"Whether or not there is an upgrade going on. May not actually tell you whether an upgrade is going on, since we don't currently plan to use this variable for anything other than a legacy indicator to fix a UX bug in the ChugSplash proxy.\"}},\"setAddress(string,address)\":{\"custom:legacy\":\"@notice Set an address in the address manager. Since only the owner of the AddressManager can directly modify addresses and the ProxyAdmin will own the AddressManager, this gives the owner of the ProxyAdmin the ability to modify addresses directly.\",\"params\":{\"_address\":\"Address to attach to the given name.\",\"_name\":\"Name to set within the AddressManager.\"}},\"setAddressManager(address)\":{\"params\":{\"_address\":\"Address of the AddressManager.\"}},\"setImplementationName(address,string)\":{\"params\":{\"_address\":\"Address of the ResolvedDelegateProxy.\",\"_name\":\"Name of the implementation for the proxy.\"}},\"setProxyType(address,uint8)\":{\"params\":{\"_address\":\"Address of the proxy.\",\"_type\":\"Type of the proxy.\"}},\"setUpgrading(bool)\":{\"custom:legacy\":\"@notice Set the upgrading status for the Chugsplash proxy type.\",\"params\":{\"_upgrading\":\"Whether or not the system is upgrading.\"}},\"upgrade(address,address)\":{\"params\":{\"_implementation\":\"Address of the new implementation address.\",\"_proxy\":\"Address of the proxy to upgrade.\"}},\"upgradeAndCall(address,address,bytes)\":{\"params\":{\"_data\":\"Data to trigger the new implementation with.\",\"_implementation\":\"Address of the new implementation address.\",\"_proxy\":\"Address of the proxy to upgrade.\"}}},\"stateVariables\":{\"addressManager\":{\"custom:legacy\":\"@notice The address of the address manager, this is required to manage the ResolvedDelegateProxy type.\"},\"implementationName\":{\"custom:legacy\":\"@notice A reverse mapping of addresses to names held in the AddressManager. This must be manually kept up to date with changes in the AddressManager for this contract to be able to work as an admin for the ResolvedDelegateProxy type.\"},\"proxyType\":{\"custom:legacy\":\"@notice A mapping of proxy types, used for backwards compatibility.\"},\"upgrading\":{\"custom:legacy\":\"@notice A legacy upgrading indicator used by the old Chugsplash Proxy.\"}},\"title\":\"ProxyAdmin\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"changeProxyAdmin(address,address)\":{\"notice\":\"Updates the admin of the given proxy address.\"},\"getProxyAdmin(address)\":{\"notice\":\"Returns the admin of the given proxy address.\"},\"getProxyImplementation(address)\":{\"notice\":\"Returns the implementation of the given proxy address.\"},\"setAddressManager(address)\":{\"notice\":\"Set the address of the AddressManager. This is required to manage legacy ResolvedDelegateProxy type proxy contracts.\"},\"setImplementationName(address,string)\":{\"notice\":\"Sets the implementation name for a given address. Only required for ResolvedDelegateProxy type proxies that have an implementation name.\"},\"setProxyType(address,uint8)\":{\"notice\":\"Sets the proxy type for a given address. Only required for non-standard (legacy) proxy types.\"},\"upgrade(address,address)\":{\"notice\":\"Changes a proxy's implementation contract.\"},\"upgradeAndCall(address,address,bytes)\":{\"notice\":\"Changes a proxy's implementation contract and delegatecalls the new implementation with some given data. Useful for atomic upgrade-and-initialize calls.\"}},\"notice\":\"This is an auxiliary contract meant to be assigned as the admin of an ERC1967 Proxy, based on the OpenZeppelin implementation. It has backwards compatibility logic to work with the various types of proxies that have been deployed by Optimism in the past.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/universal/ProxyAdmin.sol\":\"ProxyAdmin\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"none\"},\"optimizer\":{\"enabled\":true,\"runs\":999999},\"remappings\":[\":@eth-optimism/contracts-periphery/=node_modules/@eth-optimism/contracts-periphery/contracts/\",\":@openzeppelin/=node_modules/@openzeppelin/\",\":@openzeppelin/contracts-upgradeable/=node_modules/@openzeppelin/contracts-upgradeable/\",\":@openzeppelin/contracts/=node_modules/@openzeppelin/contracts/\",\":@rari-capital/=node_modules/@rari-capital/\",\":@rari-capital/solmate/=node_modules/@rari-capital/solmate/\",\":ds-test/=node_modules/ds-test/src/\",\":excessively-safe-call/=node_modules/excessively-safe-call/\",\":forge-std/=node_modules/forge-std/src/\"]},\"sources\":{\"contracts/legacy/AddressManager.sol\":{\"keccak256\":\"0x7a353d4c92eed32665fd2f0023c55054901293cf7a6e14ca108229d87c047b10\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://b92ba23601d1951271729a20db931a45639d9376b7c8e2705c23dc360833715a\",\"dweb:/ipfs/QmTKwYLNYYBKZpd31VNBANmguVUwFZifSg7joHSgLZjZCj\"]},\"contracts/legacy/L1ChugSplashProxy.sol\":{\"keccak256\":\"0x6ae7bf6ea9ac0e3511ee4cb15d946589da0dd35098ff762c0b2903d064f24875\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://02028d86c1d38563021d5ead5282271ccdf1c03a24f2eaee056ae2157f0554ee\",\"dweb:/ipfs/QmW9urkBBRTmZ8FjL5Y5zWbdnRhPDruxCCLnpr2CTkozKM\"]},\"contracts/universal/Proxy.sol\":{\"keccak256\":\"0xfa08635f1866139673ac4fe7b07330f752f93800075b895d8fcb8484f4a3f753\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://8f2247604d527f560edbb851c43b6c16b37e34972ddb305e16dd73623b8288cd\",\"dweb:/ipfs/QmfM8sLAZrxrnqyRdt1XJ5LyJh4wKbeEqk3VkvxG7BDqFj\"]},\"contracts/universal/ProxyAdmin.sol\":{\"keccak256\":\"0x94e7e76054d1b85f223daf87441e0aa7d73bcabeb029a5ec71fb5d8fda8d8a56\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://9766567fa6dbc1da3fcd008b17585852aa88a03c42a605b351f2e2c3713a4267\",\"dweb:/ipfs/QmNQJQXe9bsSFisBkgoAMLMV8YZP7mukraty5P8xVk1sx1\"]},\"node_modules/@openzeppelin/contracts/access/Ownable.sol\":{\"keccak256\":\"0x24e0364e503a9bbde94c715d26573a76f14cd2a202d45f96f52134ab806b67b9\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://e12cbaa7378fd9b62280e4e1d164bedcb4399ce238f5f98fc0eefb7e50577981\",\"dweb:/ipfs/QmXRoFGUgfsaRkoPT5bxNMtSayKTQ8GZATLPXf69HcRA51\"]},\"node_modules/@openzeppelin/contracts/utils/Context.sol\":{\"keccak256\":\"0xe2e337e6dde9ef6b680e07338c493ebea1b5fd09b43424112868e9cc1706bca7\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://6df0ddf21ce9f58271bdfaa85cde98b200ef242a05a3f85c2bc10a8294800a92\",\"dweb:/ipfs/QmRK2Y5Yc6BK7tGKkgsgn3aJEQGi5aakeSPZvS65PV8Xp3\"]},\"node_modules/@rari-capital/solmate/src/auth/Owned.sol\":{\"keccak256\":\"0x7e91c80b0dd1a14a19cb9e661b99924043adab6d9d893bbfcf3a6a3dc23a6743\",\"license\":\"AGPL-3.0-only\",\"urls\":[\"bzz-raw://515890d9fc87d6762dae2354a3a0714a26c652f0ea5bb631122be1968ef8c0e9\",\"dweb:/ipfs/QmTRpQ7uoAR1vCACKJm14Ba3oKVLqcA9reTwbHAPxawVpM\"]}},\"version\":1}",
"bytecode": "0x60806040526003805460ff60a01b1916905534801561001d57600080fd5b50604051611cdc380380611cdc83398101604081905261003c9161008b565b600080546001600160a01b0319166001600160a01b03831690811782556040518392907f8292fce18fa69edf4db7b94ea2e58241df0ae57f97e0a6c9b29067028bf92d76908290a350506100bb565b60006020828403121561009d57600080fd5b81516001600160a01b03811681146100b457600080fd5b9392505050565b611c12806100ca6000396000f3fe6080604052600436106100f35760003560e01c8063860f7cda1161008a57806399a88ec41161005957806399a88ec4146102db5780639b2ea4bd146102fb578063b79472621461031b578063f3b7dead1461035657600080fd5b8063860f7cda1461025b5780638d52d4a01461027b5780638da5cb5b1461029b5780639623609d146102c857600080fd5b8063238181ae116100c6578063238181ae146101a45780633ab76e9f146101d15780636bd9f516146101fe5780637eff275e1461023b57600080fd5b80630652b57a146100f857806307c8f7b01461011a57806313af40351461013a578063204e1c7a1461015a575b600080fd5b34801561010457600080fd5b506101186101133660046114be565b610376565b005b34801561012657600080fd5b506101186101353660046114db565b610443565b34801561014657600080fd5b506101186101553660046114be565b61050e565b34801561016657600080fd5b5061017a6101753660046114be565b6105ff565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020015b60405180910390f35b3480156101b057600080fd5b506101c46101bf3660046114be565b610820565b60405161019b9190611573565b3480156101dd57600080fd5b5060035461017a9073ffffffffffffffffffffffffffffffffffffffff1681565b34801561020a57600080fd5b5061022e6102193660046114be565b60016020526000908152604090205460ff1681565b60405161019b91906115b5565b34801561024757600080fd5b506101186102563660046115f6565b6108ba565b34801561026757600080fd5b50610118610276366004611751565b610ae6565b34801561028757600080fd5b506101186102963660046117a1565b610b96565b3480156102a757600080fd5b5060005461017a9073ffffffffffffffffffffffffffffffffffffffff1681565b6101186102d63660046117d3565b610c83565b3480156102e757600080fd5b506101186102f63660046115f6565b610f13565b34801561030757600080fd5b50610118610316366004611849565b611214565b34801561032757600080fd5b5060035474010000000000000000000000000000000000000000900460ff16604051901515815260200161019b565b34801561036257600080fd5b5061017a6103713660046114be565b611323565b60005473ffffffffffffffffffffffffffffffffffffffff1633146103fc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f554e415554484f52495a4544000000000000000000000000000000000000000060448201526064015b60405180910390fd5b600380547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b60005473ffffffffffffffffffffffffffffffffffffffff1633146104c4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f554e415554484f52495a4544000000000000000000000000000000000000000060448201526064016103f3565b6003805491151574010000000000000000000000000000000000000000027fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff909216919091179055565b60005473ffffffffffffffffffffffffffffffffffffffff16331461058f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f554e415554484f52495a4544000000000000000000000000000000000000000060448201526064016103f3565b600080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081178255604051909133917f8292fce18fa69edf4db7b94ea2e58241df0ae57f97e0a6c9b29067028bf92d769190a350565b73ffffffffffffffffffffffffffffffffffffffff811660009081526001602052604081205460ff168181600281111561063b5761063b611586565b036106b6578273ffffffffffffffffffffffffffffffffffffffff16635c60da1b6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561068b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106af9190611890565b9392505050565b60018160028111156106ca576106ca611586565b0361071a578273ffffffffffffffffffffffffffffffffffffffff1663aaf10f426040518163ffffffff1660e01b8152600401602060405180830381865afa15801561068b573d6000803e3d6000fd5b600281600281111561072e5761072e611586565b036107b85760035473ffffffffffffffffffffffffffffffffffffffff8481166000908152600260205260409081902090517fbf40fac1000000000000000000000000000000000000000000000000000000008152919092169163bf40fac19161079b91906004016118fa565b602060405180830381865afa15801561068b573d6000803e3d6000fd5b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f50726f787941646d696e3a20756e6b6e6f776e2070726f78792074797065000060448201526064016103f3565b50919050565b60026020526000908152604090208054610839906118ad565b80601f0160208091040260200160405190810160405280929190818152602001828054610865906118ad565b80156108b25780601f10610887576101008083540402835291602001916108b2565b820191906000526020600020905b81548152906001019060200180831161089557829003601f168201915b505050505081565b60005473ffffffffffffffffffffffffffffffffffffffff16331461093b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f554e415554484f52495a4544000000000000000000000000000000000000000060448201526064016103f3565b73ffffffffffffffffffffffffffffffffffffffff821660009081526001602052604081205460ff169081600281111561097757610977611586565b03610a03576040517f8f28397000000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8381166004830152841690638f283970906024015b600060405180830381600087803b1580156109e657600080fd5b505af11580156109fa573d6000803e3d6000fd5b50505050505050565b6001816002811115610a1757610a17611586565b03610a70576040517f13af403500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83811660048301528416906313af4035906024016109cc565b6002816002811115610a8457610a84611586565b036107b8576003546040517ff2fde38b00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff84811660048301529091169063f2fde38b906024016109cc565b505050565b60005473ffffffffffffffffffffffffffffffffffffffff163314610b67576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f554e415554484f52495a4544000000000000000000000000000000000000000060448201526064016103f3565b73ffffffffffffffffffffffffffffffffffffffff82166000908152600260205260409020610ae182826119e9565b60005473ffffffffffffffffffffffffffffffffffffffff163314610c17576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f554e415554484f52495a4544000000000000000000000000000000000000000060448201526064016103f3565b73ffffffffffffffffffffffffffffffffffffffff82166000908152600160208190526040909120805483927fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0090911690836002811115610c7a57610c7a611586565b02179055505050565b60005473ffffffffffffffffffffffffffffffffffffffff163314610d04576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f554e415554484f52495a4544000000000000000000000000000000000000000060448201526064016103f3565b73ffffffffffffffffffffffffffffffffffffffff831660009081526001602052604081205460ff1690816002811115610d4057610d40611586565b03610e06576040517f4f1ef28600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff851690634f1ef286903490610d9b9087908790600401611b03565b60006040518083038185885af1158015610db9573d6000803e3d6000fd5b50505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201604052610e009190810190611b3a565b50610f0d565b610e108484610f13565b60008473ffffffffffffffffffffffffffffffffffffffff163484604051610e389190611bb1565b60006040518083038185875af1925050503d8060008114610e75576040519150601f19603f3d011682016040523d82523d6000602084013e610e7a565b606091505b5050905080610f0b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f50726f787941646d696e3a2063616c6c20746f2070726f78792061667465722060448201527f75706772616465206661696c656400000000000000000000000000000000000060648201526084016103f3565b505b50505050565b60005473ffffffffffffffffffffffffffffffffffffffff163314610f94576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f554e415554484f52495a4544000000000000000000000000000000000000000060448201526064016103f3565b73ffffffffffffffffffffffffffffffffffffffff821660009081526001602052604081205460ff1690816002811115610fd057610fd0611586565b03611029576040517f3659cfe600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8381166004830152841690633659cfe6906024016109cc565b600181600281111561103d5761103d611586565b036110bc576040517f9b0b0fda0000000000000000000000000000000000000000000000000000000081527f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc600482015273ffffffffffffffffffffffffffffffffffffffff8381166024830152841690639b0b0fda906044016109cc565b60028160028111156110d0576110d0611586565b036107b85773ffffffffffffffffffffffffffffffffffffffff831660009081526002602052604081208054611105906118ad565b80601f0160208091040260200160405190810160405280929190818152602001828054611131906118ad565b801561117e5780601f106111535761010080835404028352916020019161117e565b820191906000526020600020905b81548152906001019060200180831161116157829003601f168201915b50506003546040517f9b2ea4bd00000000000000000000000000000000000000000000000000000000815294955073ffffffffffffffffffffffffffffffffffffffff1693639b2ea4bd93506111dc92508591508790600401611bcd565b600060405180830381600087803b1580156111f657600080fd5b505af115801561120a573d6000803e3d6000fd5b5050505050505050565b60005473ffffffffffffffffffffffffffffffffffffffff163314611295576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f554e415554484f52495a4544000000000000000000000000000000000000000060448201526064016103f3565b6003546040517f9b2ea4bd00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff90911690639b2ea4bd906112ed9085908590600401611bcd565b600060405180830381600087803b15801561130757600080fd5b505af115801561131b573d6000803e3d6000fd5b505050505050565b73ffffffffffffffffffffffffffffffffffffffff811660009081526001602052604081205460ff168181600281111561135f5761135f611586565b036113af578273ffffffffffffffffffffffffffffffffffffffff1663f851a4406040518163ffffffff1660e01b8152600401602060405180830381865afa15801561068b573d6000803e3d6000fd5b60018160028111156113c3576113c3611586565b03611413578273ffffffffffffffffffffffffffffffffffffffff1663893d20e86040518163ffffffff1660e01b8152600401602060405180830381865afa15801561068b573d6000803e3d6000fd5b600281600281111561142757611427611586565b036107b857600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16638da5cb5b6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561068b573d6000803e3d6000fd5b73ffffffffffffffffffffffffffffffffffffffff811681146114bb57600080fd5b50565b6000602082840312156114d057600080fd5b81356106af81611499565b6000602082840312156114ed57600080fd5b813580151581146106af57600080fd5b60005b83811015611518578181015183820152602001611500565b83811115610f0d5750506000910152565b600081518084526115418160208601602086016114fd565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b6020815260006106af6020830184611529565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b60208101600383106115f0577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b91905290565b6000806040838503121561160957600080fd5b823561161481611499565b9150602083013561162481611499565b809150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff811182821017156116a5576116a561162f565b604052919050565b600067ffffffffffffffff8211156116c7576116c761162f565b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b6000611706611701846116ad565b61165e565b905082815283838301111561171a57600080fd5b828260208301376000602084830101529392505050565b600082601f83011261174257600080fd5b6106af838335602085016116f3565b6000806040838503121561176457600080fd5b823561176f81611499565b9150602083013567ffffffffffffffff81111561178b57600080fd5b61179785828601611731565b9150509250929050565b600080604083850312156117b457600080fd5b82356117bf81611499565b915060208301356003811061162457600080fd5b6000806000606084860312156117e857600080fd5b83356117f381611499565b9250602084013561180381611499565b9150604084013567ffffffffffffffff81111561181f57600080fd5b8401601f8101861361183057600080fd5b61183f868235602084016116f3565b9150509250925092565b6000806040838503121561185c57600080fd5b823567ffffffffffffffff81111561187357600080fd5b61187f85828601611731565b925050602083013561162481611499565b6000602082840312156118a257600080fd5b81516106af81611499565b600181811c908216806118c157607f821691505b60208210810361081a577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b600060208083526000845461190e816118ad565b8084870152604060018084166000811461192f576001811461196757611995565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff008516838a01528284151560051b8a01019550611995565b896000528660002060005b8581101561198d5781548b8201860152908301908801611972565b8a0184019650505b509398975050505050505050565b601f821115610ae157600081815260208120601f850160051c810160208610156119ca5750805b601f850160051c820191505b8181101561131b578281556001016119d6565b815167ffffffffffffffff811115611a0357611a0361162f565b611a1781611a1184546118ad565b846119a3565b602080601f831160018114611a6a5760008415611a345750858301515b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600386901b1c1916600185901b17855561131b565b6000858152602081207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08616915b82811015611ab757888601518255948401946001909101908401611a98565b5085821015611af357878501517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600388901b60f8161c191681555b5050505050600190811b01905550565b73ffffffffffffffffffffffffffffffffffffffff83168152604060208201526000611b326040830184611529565b949350505050565b600060208284031215611b4c57600080fd5b815167ffffffffffffffff811115611b6357600080fd5b8201601f81018413611b7457600080fd5b8051611b82611701826116ad565b818152856020838501011115611b9757600080fd5b611ba88260208301602086016114fd565b95945050505050565b60008251611bc38184602087016114fd565b9190910192915050565b604081526000611be06040830185611529565b905073ffffffffffffffffffffffffffffffffffffffff83166020830152939250505056fea164736f6c634300080f000a",
"deployedBytecode": "0x6080604052600436106100f35760003560e01c8063860f7cda1161008a57806399a88ec41161005957806399a88ec4146102db5780639b2ea4bd146102fb578063b79472621461031b578063f3b7dead1461035657600080fd5b8063860f7cda1461025b5780638d52d4a01461027b5780638da5cb5b1461029b5780639623609d146102c857600080fd5b8063238181ae116100c6578063238181ae146101a45780633ab76e9f146101d15780636bd9f516146101fe5780637eff275e1461023b57600080fd5b80630652b57a146100f857806307c8f7b01461011a57806313af40351461013a578063204e1c7a1461015a575b600080fd5b34801561010457600080fd5b506101186101133660046114be565b610376565b005b34801561012657600080fd5b506101186101353660046114db565b610443565b34801561014657600080fd5b506101186101553660046114be565b61050e565b34801561016657600080fd5b5061017a6101753660046114be565b6105ff565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020015b60405180910390f35b3480156101b057600080fd5b506101c46101bf3660046114be565b610820565b60405161019b9190611573565b3480156101dd57600080fd5b5060035461017a9073ffffffffffffffffffffffffffffffffffffffff1681565b34801561020a57600080fd5b5061022e6102193660046114be565b60016020526000908152604090205460ff1681565b60405161019b91906115b5565b34801561024757600080fd5b506101186102563660046115f6565b6108ba565b34801561026757600080fd5b50610118610276366004611751565b610ae6565b34801561028757600080fd5b506101186102963660046117a1565b610b96565b3480156102a757600080fd5b5060005461017a9073ffffffffffffffffffffffffffffffffffffffff1681565b6101186102d63660046117d3565b610c83565b3480156102e757600080fd5b506101186102f63660046115f6565b610f13565b34801561030757600080fd5b50610118610316366004611849565b611214565b34801561032757600080fd5b5060035474010000000000000000000000000000000000000000900460ff16604051901515815260200161019b565b34801561036257600080fd5b5061017a6103713660046114be565b611323565b60005473ffffffffffffffffffffffffffffffffffffffff1633146103fc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f554e415554484f52495a4544000000000000000000000000000000000000000060448201526064015b60405180910390fd5b600380547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b60005473ffffffffffffffffffffffffffffffffffffffff1633146104c4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f554e415554484f52495a4544000000000000000000000000000000000000000060448201526064016103f3565b6003805491151574010000000000000000000000000000000000000000027fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff909216919091179055565b60005473ffffffffffffffffffffffffffffffffffffffff16331461058f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f554e415554484f52495a4544000000000000000000000000000000000000000060448201526064016103f3565b600080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081178255604051909133917f8292fce18fa69edf4db7b94ea2e58241df0ae57f97e0a6c9b29067028bf92d769190a350565b73ffffffffffffffffffffffffffffffffffffffff811660009081526001602052604081205460ff168181600281111561063b5761063b611586565b036106b6578273ffffffffffffffffffffffffffffffffffffffff16635c60da1b6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561068b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106af9190611890565b9392505050565b60018160028111156106ca576106ca611586565b0361071a578273ffffffffffffffffffffffffffffffffffffffff1663aaf10f426040518163ffffffff1660e01b8152600401602060405180830381865afa15801561068b573d6000803e3d6000fd5b600281600281111561072e5761072e611586565b036107b85760035473ffffffffffffffffffffffffffffffffffffffff8481166000908152600260205260409081902090517fbf40fac1000000000000000000000000000000000000000000000000000000008152919092169163bf40fac19161079b91906004016118fa565b602060405180830381865afa15801561068b573d6000803e3d6000fd5b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f50726f787941646d696e3a20756e6b6e6f776e2070726f78792074797065000060448201526064016103f3565b50919050565b60026020526000908152604090208054610839906118ad565b80601f0160208091040260200160405190810160405280929190818152602001828054610865906118ad565b80156108b25780601f10610887576101008083540402835291602001916108b2565b820191906000526020600020905b81548152906001019060200180831161089557829003601f168201915b505050505081565b60005473ffffffffffffffffffffffffffffffffffffffff16331461093b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f554e415554484f52495a4544000000000000000000000000000000000000000060448201526064016103f3565b73ffffffffffffffffffffffffffffffffffffffff821660009081526001602052604081205460ff169081600281111561097757610977611586565b03610a03576040517f8f28397000000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8381166004830152841690638f283970906024015b600060405180830381600087803b1580156109e657600080fd5b505af11580156109fa573d6000803e3d6000fd5b50505050505050565b6001816002811115610a1757610a17611586565b03610a70576040517f13af403500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83811660048301528416906313af4035906024016109cc565b6002816002811115610a8457610a84611586565b036107b8576003546040517ff2fde38b00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff84811660048301529091169063f2fde38b906024016109cc565b505050565b60005473ffffffffffffffffffffffffffffffffffffffff163314610b67576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f554e415554484f52495a4544000000000000000000000000000000000000000060448201526064016103f3565b73ffffffffffffffffffffffffffffffffffffffff82166000908152600260205260409020610ae182826119e9565b60005473ffffffffffffffffffffffffffffffffffffffff163314610c17576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f554e415554484f52495a4544000000000000000000000000000000000000000060448201526064016103f3565b73ffffffffffffffffffffffffffffffffffffffff82166000908152600160208190526040909120805483927fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0090911690836002811115610c7a57610c7a611586565b02179055505050565b60005473ffffffffffffffffffffffffffffffffffffffff163314610d04576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f554e415554484f52495a4544000000000000000000000000000000000000000060448201526064016103f3565b73ffffffffffffffffffffffffffffffffffffffff831660009081526001602052604081205460ff1690816002811115610d4057610d40611586565b03610e06576040517f4f1ef28600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff851690634f1ef286903490610d9b9087908790600401611b03565b60006040518083038185885af1158015610db9573d6000803e3d6000fd5b50505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201604052610e009190810190611b3a565b50610f0d565b610e108484610f13565b60008473ffffffffffffffffffffffffffffffffffffffff163484604051610e389190611bb1565b60006040518083038185875af1925050503d8060008114610e75576040519150601f19603f3d011682016040523d82523d6000602084013e610e7a565b606091505b5050905080610f0b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f50726f787941646d696e3a2063616c6c20746f2070726f78792061667465722060448201527f75706772616465206661696c656400000000000000000000000000000000000060648201526084016103f3565b505b50505050565b60005473ffffffffffffffffffffffffffffffffffffffff163314610f94576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f554e415554484f52495a4544000000000000000000000000000000000000000060448201526064016103f3565b73ffffffffffffffffffffffffffffffffffffffff821660009081526001602052604081205460ff1690816002811115610fd057610fd0611586565b03611029576040517f3659cfe600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8381166004830152841690633659cfe6906024016109cc565b600181600281111561103d5761103d611586565b036110bc576040517f9b0b0fda0000000000000000000000000000000000000000000000000000000081527f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc600482015273ffffffffffffffffffffffffffffffffffffffff8381166024830152841690639b0b0fda906044016109cc565b60028160028111156110d0576110d0611586565b036107b85773ffffffffffffffffffffffffffffffffffffffff831660009081526002602052604081208054611105906118ad565b80601f0160208091040260200160405190810160405280929190818152602001828054611131906118ad565b801561117e5780601f106111535761010080835404028352916020019161117e565b820191906000526020600020905b81548152906001019060200180831161116157829003601f168201915b50506003546040517f9b2ea4bd00000000000000000000000000000000000000000000000000000000815294955073ffffffffffffffffffffffffffffffffffffffff1693639b2ea4bd93506111dc92508591508790600401611bcd565b600060405180830381600087803b1580156111f657600080fd5b505af115801561120a573d6000803e3d6000fd5b5050505050505050565b60005473ffffffffffffffffffffffffffffffffffffffff163314611295576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f554e415554484f52495a4544000000000000000000000000000000000000000060448201526064016103f3565b6003546040517f9b2ea4bd00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff90911690639b2ea4bd906112ed9085908590600401611bcd565b600060405180830381600087803b15801561130757600080fd5b505af115801561131b573d6000803e3d6000fd5b505050505050565b73ffffffffffffffffffffffffffffffffffffffff811660009081526001602052604081205460ff168181600281111561135f5761135f611586565b036113af578273ffffffffffffffffffffffffffffffffffffffff1663f851a4406040518163ffffffff1660e01b8152600401602060405180830381865afa15801561068b573d6000803e3d6000fd5b60018160028111156113c3576113c3611586565b03611413578273ffffffffffffffffffffffffffffffffffffffff1663893d20e86040518163ffffffff1660e01b8152600401602060405180830381865afa15801561068b573d6000803e3d6000fd5b600281600281111561142757611427611586565b036107b857600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16638da5cb5b6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561068b573d6000803e3d6000fd5b73ffffffffffffffffffffffffffffffffffffffff811681146114bb57600080fd5b50565b6000602082840312156114d057600080fd5b81356106af81611499565b6000602082840312156114ed57600080fd5b813580151581146106af57600080fd5b60005b83811015611518578181015183820152602001611500565b83811115610f0d5750506000910152565b600081518084526115418160208601602086016114fd565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b6020815260006106af6020830184611529565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b60208101600383106115f0577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b91905290565b6000806040838503121561160957600080fd5b823561161481611499565b9150602083013561162481611499565b809150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff811182821017156116a5576116a561162f565b604052919050565b600067ffffffffffffffff8211156116c7576116c761162f565b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b6000611706611701846116ad565b61165e565b905082815283838301111561171a57600080fd5b828260208301376000602084830101529392505050565b600082601f83011261174257600080fd5b6106af838335602085016116f3565b6000806040838503121561176457600080fd5b823561176f81611499565b9150602083013567ffffffffffffffff81111561178b57600080fd5b61179785828601611731565b9150509250929050565b600080604083850312156117b457600080fd5b82356117bf81611499565b915060208301356003811061162457600080fd5b6000806000606084860312156117e857600080fd5b83356117f381611499565b9250602084013561180381611499565b9150604084013567ffffffffffffffff81111561181f57600080fd5b8401601f8101861361183057600080fd5b61183f868235602084016116f3565b9150509250925092565b6000806040838503121561185c57600080fd5b823567ffffffffffffffff81111561187357600080fd5b61187f85828601611731565b925050602083013561162481611499565b6000602082840312156118a257600080fd5b81516106af81611499565b600181811c908216806118c157607f821691505b60208210810361081a577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b600060208083526000845461190e816118ad565b8084870152604060018084166000811461192f576001811461196757611995565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff008516838a01528284151560051b8a01019550611995565b896000528660002060005b8581101561198d5781548b8201860152908301908801611972565b8a0184019650505b509398975050505050505050565b601f821115610ae157600081815260208120601f850160051c810160208610156119ca5750805b601f850160051c820191505b8181101561131b578281556001016119d6565b815167ffffffffffffffff811115611a0357611a0361162f565b611a1781611a1184546118ad565b846119a3565b602080601f831160018114611a6a5760008415611a345750858301515b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600386901b1c1916600185901b17855561131b565b6000858152602081207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08616915b82811015611ab757888601518255948401946001909101908401611a98565b5085821015611af357878501517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600388901b60f8161c191681555b5050505050600190811b01905550565b73ffffffffffffffffffffffffffffffffffffffff83168152604060208201526000611b326040830184611529565b949350505050565b600060208284031215611b4c57600080fd5b815167ffffffffffffffff811115611b6357600080fd5b8201601f81018413611b7457600080fd5b8051611b82611701826116ad565b818152856020838501011115611b9757600080fd5b611ba88260208301602086016114fd565b95945050505050565b60008251611bc38184602087016114fd565b9190910192915050565b604081526000611be06040830185611529565b905073ffffffffffffffffffffffffffffffffffffffff83166020830152939250505056fea164736f6c634300080f000a",
"devdoc": {
"version": 1,
"kind": "dev",
"methods": {
"changeProxyAdmin(address,address)": {
"params": {
"_newAdmin": "Address of the new proxy admin.",
"_proxy": "Address of the proxy to update."
}
},
"constructor": {
"params": {
"_owner": "Address of the initial owner of this contract."
}
},
"getProxyAdmin(address)": {
"params": {
"_proxy": "Address of the proxy to get the admin of."
},
"returns": {
"_0": "Address of the admin of the proxy."
}
},
"getProxyImplementation(address)": {
"params": {
"_proxy": "Address of the proxy to get the implementation of."
},
"returns": {
"_0": "Address of the implementation of the proxy."
}
},
"isUpgrading()": {
"returns": {
"_0": "Whether or not there is an upgrade going on. May not actually tell you whether an upgrade is going on, since we don't currently plan to use this variable for anything other than a legacy indicator to fix a UX bug in the ChugSplash proxy."
}
},
"setAddress(string,address)": {
"params": {
"_address": "Address to attach to the given name.",
"_name": "Name to set within the AddressManager."
}
},
"setAddressManager(address)": {
"params": {
"_address": "Address of the AddressManager."
}
},
"setImplementationName(address,string)": {
"params": {
"_address": "Address of the ResolvedDelegateProxy.",
"_name": "Name of the implementation for the proxy."
}
},
"setProxyType(address,uint8)": {
"params": {
"_address": "Address of the proxy.",
"_type": "Type of the proxy."
}
},
"setUpgrading(bool)": {
"params": {
"_upgrading": "Whether or not the system is upgrading."
}
},
"upgrade(address,address)": {
"params": {
"_implementation": "Address of the new implementation address.",
"_proxy": "Address of the proxy to upgrade."
}
},
"upgradeAndCall(address,address,bytes)": {
"params": {
"_data": "Data to trigger the new implementation with.",
"_implementation": "Address of the new implementation address.",
"_proxy": "Address of the proxy to upgrade."
}
}
},
"title": "ProxyAdmin"
},
"userdoc": {
"version": 1,
"kind": "user",
"methods": {
"changeProxyAdmin(address,address)": {
"notice": "Updates the admin of the given proxy address."
},
"getProxyAdmin(address)": {
"notice": "Returns the admin of the given proxy address."
},
"getProxyImplementation(address)": {
"notice": "Returns the implementation of the given proxy address."
},
"setAddressManager(address)": {
"notice": "Set the address of the AddressManager. This is required to manage legacy ResolvedDelegateProxy type proxy contracts."
},
"setImplementationName(address,string)": {
"notice": "Sets the implementation name for a given address. Only required for ResolvedDelegateProxy type proxies that have an implementation name."
},
"setProxyType(address,uint8)": {
"notice": "Sets the proxy type for a given address. Only required for non-standard (legacy) proxy types."
},
"upgrade(address,address)": {
"notice": "Changes a proxy's implementation contract."
},
"upgradeAndCall(address,address,bytes)": {
"notice": "Changes a proxy's implementation contract and delegatecalls the new implementation with some given data. Useful for atomic upgrade-and-initialize calls."
}
},
"notice": "This is an auxiliary contract meant to be assigned as the admin of an ERC1967 Proxy, based on the OpenZeppelin implementation. It has backwards compatibility logic to work with the various types of proxies that have been deployed by Optimism in the past."
},
"storageLayout": {
"storage": [
{
"astId": 28443,
"contract": "contracts/universal/ProxyAdmin.sol:ProxyAdmin",
"label": "owner",
"offset": 0,
"slot": "0",
"type": "t_address"
},
{
"astId": 24435,
"contract": "contracts/universal/ProxyAdmin.sol:ProxyAdmin",
"label": "proxyType",
"offset": 0,
"slot": "1",
"type": "t_mapping(t_address,t_enum(ProxyType)24429)"
},
{
"astId": 24440,
"contract": "contracts/universal/ProxyAdmin.sol:ProxyAdmin",
"label": "implementationName",
"offset": 0,
"slot": "2",
"type": "t_mapping(t_address,t_string_storage)"
},
{
"astId": 24444,
"contract": "contracts/universal/ProxyAdmin.sol:ProxyAdmin",
"label": "addressManager",
"offset": 0,
"slot": "3",
"type": "t_contract(AddressManager)2693"
},
{
"astId": 24448,
"contract": "contracts/universal/ProxyAdmin.sol:ProxyAdmin",
"label": "upgrading",
"offset": 20,
"slot": "3",
"type": "t_bool"
}
],
"types": {
"t_address": {
"encoding": "inplace",
"label": "address",
"numberOfBytes": "20"
},
"t_bool": {
"encoding": "inplace",
"label": "bool",
"numberOfBytes": "1"
},
"t_contract(AddressManager)2693": {
"encoding": "inplace",
"label": "contract AddressManager",
"numberOfBytes": "20"
},
"t_enum(ProxyType)24429": {
"encoding": "inplace",
"label": "enum ProxyAdmin.ProxyType",
"numberOfBytes": "1"
},
"t_mapping(t_address,t_enum(ProxyType)24429)": {
"encoding": "mapping",
"key": "t_address",
"label": "mapping(address => enum ProxyAdmin.ProxyType)",
"numberOfBytes": "32",
"value": "t_enum(ProxyType)24429"
},
"t_mapping(t_address,t_string_storage)": {
"encoding": "mapping",
"key": "t_address",
"label": "mapping(address => string)",
"numberOfBytes": "32",
"value": "t_string_storage"
},
"t_string_storage": {
"encoding": "bytes",
"label": "string",
"numberOfBytes": "32"
}
}
}
}
\ No newline at end of file
...@@ -314,7 +314,7 @@ const config: HardhatUserConfig = { ...@@ -314,7 +314,7 @@ const config: HardhatUserConfig = {
}, },
gasPriceOracleScalar: { gasPriceOracleScalar: {
type: 'number', type: 'number',
default: 1000_000, default: 1_000_000,
}, },
gasPriceOracleDecimals: { gasPriceOracleDecimals: {
type: 'number', type: 'number',
......
package genesis
import (
"encoding/json"
"math/big"
"os"
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/rpc"
"github.com/ethereum-optimism/optimism/op-bindings/predeploys"
"github.com/ethereum-optimism/optimism/state-surgery/hardhat"
"github.com/ethereum-optimism/optimism/state-surgery/state"
)
// DeployConfig represents the deployment configuration for Optimism
type DeployConfig struct {
L1StartingBlockTag rpc.BlockNumberOrHash `json:"l1StartingBlockTag"`
L1ChainID *big.Int `json:"l1ChainID"`
L2ChainID *big.Int `json:"l2ChainID"`
L2BlockTime uint `json:"l2BlockTime"`
MaxSequencerDrift uint `json:"maxSequencerDrift"`
SequencerWindowSize uint `json:"sequencerWindowSize"`
ChannelTimeout uint `json:"channelTimeout"`
P2PSequencerAddress common.Address `json:"p2pSequencerAddress"`
OptimismL2FeeRecipient common.Address `json:"optimismL2FeeRecipient"`
BatchInboxAddress common.Address `json:"batchInboxAddress"`
BatchSenderAddress common.Address `json:"batchSenderAddress"`
L2OutputOracleSubmissionInterval uint `json:"l2OutputOracleSubmissionInterval"`
L2OutputOracleStartingTimestamp int `json:"l2OutputOracleStartingTimestamp"`
L2OutputOracleProposer common.Address `json:"l2OutputOracleProposer"`
L2OutputOracleOwner common.Address `json:"l2OutputOracleOwner"`
L1BlockTime uint64 `json:"l1BlockTime"`
CliqueSignerAddress common.Address `json:"cliqueSignerAddress"`
OptimismBaseFeeRecipient common.Address `json:"optimismBaseFeeRecipient"`
OptimismL1FeeRecipient common.Address `json:"optimismL1FeeRecipient"`
ProxyAdmin common.Address `json:"proxyAdmin"`
FundDevAccounts bool `json:"fundDevAccounts"`
GasPriceOracleOwner common.Address `json:"gasPriceOracleOwner"`
GasPriceOracleOverhead uint `json:"gasPriceOracleOverhead"`
GasPriceOracleScalar uint `json:"gasPriceOracleScalar"`
GasPriceOracleDecimals uint `json:"gasPriceOracleDecimals"`
L2CrossDomainMessengerOwner common.Address `json:"l2CrossDomainMessengerOwner"`
L2GenesisBlockNonce uint64 `json:"l2GenesisBlockNonce"`
L2GenesisBlockExtraData hexutil.Bytes `json:"l2GenesisBlockExtraData"`
L2GenesisBlockGasLimit uint64 `json:"l2GenesisBlockGasLimit"`
L2GenesisBlockDifficulty *big.Int `json:"l2GenesisBlockDifficulty"`
L2GenesisBlockMixHash common.Hash `json:"l2GenesisBlockMixHash"`
L2GenesisBlockCoinbase common.Address `json:"l2GenesisBlockCoinbase"`
L2GenesisBlockNumber uint64 `json:"l2GenesisBlockNumber"`
L2GenesisBlockGasUsed uint64 `json:"l2GenesisBlockGasUsed"`
L2GenesisBlockParentHash common.Hash `json:"l2GenesisBlockParentHash"`
L2GenesisBlockBaseFeePerGas *big.Int `json:"l2GenesisBlockBaseFeePerGas"`
L1GenesisBlockTimestamp uint64 `json:"l1GenesisBlockTimestamp"`
L1GenesisBlockNonce uint64 `json:"l1GenesisBlockNonce"`
L1GenesisBlockGasLimit uint64 `json:"l1GenesisBlockGasLimit"`
L1GenesisBlockDifficulty *big.Int `json:"l1GenesisBlockDifficulty"`
L1GenesisBlockMixHash common.Hash `json:"l1GenesisBlockMixHash"`
L1GenesisBlockCoinbase common.Address `json:"l1GenesisBlockCoinbase"`
L1GenesisBlockNumber uint64 `json:"l1GenesisBlockNumber"`
L1GenesisBlockGasUsed uint64 `json:"l1GenesisBlockGasUsed"`
L1GenesisBlockParentHash common.Hash `json:"l1GenesisBlockParentHash"`
L1GenesisBlockBaseFeePerGas *big.Int `json:"l1GenesisBlockBaseFeePerGas"`
}
// NewDeployConfig reads a config file given a path on the filesystem.
func NewDeployConfig(path string) (*DeployConfig, error) {
file, err := os.ReadFile(path)
if err != nil {
return nil, err
}
var config DeployConfig
if err := json.Unmarshal(file, &config); err != nil {
return nil, err
}
return &config, nil
}
// StorageConfig represents the storage configuration for the L2 predeploy
// contracts.
type StorageConfig map[string]state.StorageValues
// NewStorageConfig will create a StorageConfig given an instance of a
// Hardhat and a DeployConfig.
func NewStorageConfig(hh *hardhat.Hardhat, config *DeployConfig, chain ethereum.ChainReader) (StorageConfig, error) {
storage := make(StorageConfig)
proxyL1StandardBridge, err := hh.GetDeployment("L1StandardBridgeProxy")
if err != nil {
return storage, err
}
proxyL1CrossDomainMessenger, err := hh.GetDeployment("L1CrossDomainMessengerProxy")
if err != nil {
return storage, err
}
block, err := getBlockFromTag(chain, config.L1StartingBlockTag)
if err != nil {
return storage, err
}
storage["L2ToL1MessagePasser"] = state.StorageValues{
"nonce": 0,
}
storage["L2CrossDomainMessenger"] = state.StorageValues{
"_initialized": 1,
"_owner": config.L2CrossDomainMessengerOwner,
// re-entrency lock
"_status": 1,
"_initializing": false,
"_paused": false,
"xDomainMsgSender": "0x000000000000000000000000000000000000dEaD",
"msgNonce": 0,
"otherMessenger": proxyL1CrossDomainMessenger.Address,
"blockedSystemAddresses": map[any]any{
predeploys.L2CrossDomainMessenger: true,
predeploys.L2ToL1MessagePasser: true,
},
}
storage["GasPriceOracle"] = state.StorageValues{
"_owner": config.GasPriceOracleOwner,
"overhead": config.GasPriceOracleOverhead,
"scalar": config.GasPriceOracleScalar,
"decimals": config.GasPriceOracleDecimals,
}
storage["L2StandardBridge"] = state.StorageValues{
"_initialized": true,
"_initializing": false,
"messenger": predeploys.L2CrossDomainMessenger,
"otherBridge": proxyL1StandardBridge.Address,
}
storage["SequencerFeeVault"] = state.StorageValues{
"l1FeeWallet": config.OptimismL1FeeRecipient,
}
storage["L1Block"] = state.StorageValues{
"number": block.Number(),
"timestamp": block.Time(),
"basefee": block.BaseFee(),
"hash": block.Hash(),
"sequenceNumber": 0,
}
storage["LegacyERC20ETH"] = state.StorageValues{
"bridge": predeploys.L2StandardBridge,
"remoteToken": common.Address{},
"_name": "Ether",
"_symbol": "ETH",
}
storage["WETH9"] = state.StorageValues{
"name": "Wrapped Ether",
"symbol": "WETH",
"decimals": 18,
}
storage["GovernanceToken"] = state.StorageValues{
"_name": "Optimism",
"_symbol": "OP",
"_owner": config.ProxyAdmin,
}
return storage, nil
}
package genesis
import (
"errors"
"math/big"
"time"
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/params"
)
// NewL2Genesis will create a new L2 genesis
func NewL2Genesis(config *DeployConfig, chain ethereum.ChainReader) (*core.Genesis, error) {
if config.L2ChainID == nil {
return nil, errors.New("must define L2 ChainID")
}
optimismChainConfig := params.ChainConfig{
ChainID: config.L2ChainID,
HomesteadBlock: big.NewInt(0),
DAOForkBlock: nil,
DAOForkSupport: false,
EIP150Block: big.NewInt(0),
EIP150Hash: common.Hash{},
EIP155Block: big.NewInt(0),
EIP158Block: big.NewInt(0),
ByzantiumBlock: big.NewInt(0),
ConstantinopleBlock: big.NewInt(0),
PetersburgBlock: big.NewInt(0),
IstanbulBlock: big.NewInt(0),
MuirGlacierBlock: big.NewInt(0),
BerlinBlock: big.NewInt(0),
LondonBlock: big.NewInt(0),
ArrowGlacierBlock: big.NewInt(0),
GrayGlacierBlock: big.NewInt(0),
MergeNetsplitBlock: big.NewInt(0),
ShanghaiBlock: nil,
CancunBlock: nil,
TerminalTotalDifficulty: big.NewInt(0),
TerminalTotalDifficultyPassed: true,
Optimism: &params.OptimismConfig{
BaseFeeRecipient: config.OptimismBaseFeeRecipient,
L1FeeRecipient: config.OptimismL2FeeRecipient,
},
}
extraData := config.L2GenesisBlockExtraData
if len(extraData) == 0 {
extraData = common.Hash{}.Bytes()
}
gasLimit := config.L2GenesisBlockGasLimit
if gasLimit == 0 {
gasLimit = uint64(15_000_000)
}
baseFee := config.L2GenesisBlockBaseFeePerGas
if baseFee == nil {
baseFee = big.NewInt(params.InitialBaseFee)
}
difficulty := config.L2GenesisBlockDifficulty
if difficulty == nil {
difficulty = big.NewInt(1)
}
block, err := getBlockFromTag(chain, config.L1StartingBlockTag)
if err != nil {
return nil, err
}
return &core.Genesis{
Config: &optimismChainConfig,
Nonce: config.L2GenesisBlockNonce,
Timestamp: block.Time(),
ExtraData: extraData,
GasLimit: gasLimit,
Difficulty: difficulty,
Mixhash: config.L2GenesisBlockMixHash,
Coinbase: config.L2GenesisBlockCoinbase,
Number: config.L2GenesisBlockNumber,
GasUsed: config.L2GenesisBlockGasUsed,
ParentHash: config.L2GenesisBlockParentHash,
BaseFee: baseFee,
Alloc: map[common.Address]core.GenesisAccount{
common.BytesToAddress([]byte{1}): {Balance: big.NewInt(1)}, // ECRecover
common.BytesToAddress([]byte{2}): {Balance: big.NewInt(1)}, // SHA256
common.BytesToAddress([]byte{3}): {Balance: big.NewInt(1)}, // RIPEMD
common.BytesToAddress([]byte{4}): {Balance: big.NewInt(1)}, // Identity
common.BytesToAddress([]byte{5}): {Balance: big.NewInt(1)}, // ModExp
common.BytesToAddress([]byte{6}): {Balance: big.NewInt(1)}, // ECAdd
common.BytesToAddress([]byte{7}): {Balance: big.NewInt(1)}, // ECScalarMul
common.BytesToAddress([]byte{8}): {Balance: big.NewInt(1)}, // ECPairing
common.BytesToAddress([]byte{9}): {Balance: big.NewInt(1)}, // BLAKE2b
},
}, nil
}
// NewL1Genesis will create a new L1 genesis config
func NewL1Genesis(config *DeployConfig) (*core.Genesis, error) {
if config.L1ChainID == nil {
return nil, errors.New("must define L1 ChainID")
}
chainConfig := *params.AllCliqueProtocolChanges
chainConfig.Clique = &params.CliqueConfig{
Period: config.L1BlockTime,
Epoch: 30000,
}
chainConfig.ChainID = config.L1ChainID
gasLimit := config.L1GenesisBlockGasLimit
if gasLimit == 0 {
gasLimit = uint64(15_000_000)
}
baseFee := config.L1GenesisBlockBaseFeePerGas
if baseFee == nil {
baseFee = big.NewInt(params.InitialBaseFee)
}
difficulty := config.L1GenesisBlockDifficulty
if difficulty == nil {
difficulty = big.NewInt(1)
}
timestamp := config.L1GenesisBlockTimestamp
if timestamp == 0 {
timestamp = uint64(time.Now().Unix())
}
extraData := append(append(make([]byte, 32), config.CliqueSignerAddress[:]...), make([]byte, crypto.SignatureLength)...)
return &core.Genesis{
Config: &chainConfig,
Nonce: config.L1GenesisBlockNonce,
Timestamp: timestamp,
ExtraData: extraData,
GasLimit: gasLimit,
Difficulty: difficulty,
Mixhash: config.L1GenesisBlockMixHash,
Coinbase: config.L1GenesisBlockCoinbase,
Number: config.L1GenesisBlockNumber,
GasUsed: config.L1GenesisBlockGasUsed,
ParentHash: config.L1GenesisBlockParentHash,
BaseFee: baseFee,
Alloc: map[common.Address]core.GenesisAccount{
common.BytesToAddress([]byte{1}): {Balance: big.NewInt(1)}, // ECRecover
common.BytesToAddress([]byte{2}): {Balance: big.NewInt(1)}, // SHA256
common.BytesToAddress([]byte{3}): {Balance: big.NewInt(1)}, // RIPEMD
common.BytesToAddress([]byte{4}): {Balance: big.NewInt(1)}, // Identity
common.BytesToAddress([]byte{5}): {Balance: big.NewInt(1)}, // ModExp
common.BytesToAddress([]byte{6}): {Balance: big.NewInt(1)}, // ECAdd
common.BytesToAddress([]byte{7}): {Balance: big.NewInt(1)}, // ECScalarMul
common.BytesToAddress([]byte{8}): {Balance: big.NewInt(1)}, // ECPairing
common.BytesToAddress([]byte{9}): {Balance: big.NewInt(1)}, // BLAKE2b
},
}, nil
}
package genesis
import (
"bytes"
"context"
"fmt"
"math/big"
"github.com/ethereum-optimism/optimism/op-bindings/predeploys"
"github.com/ethereum-optimism/optimism/state-surgery/hardhat"
"github.com/ethereum-optimism/optimism/state-surgery/immutables"
"github.com/ethereum-optimism/optimism/state-surgery/state"
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/rpc"
)
var (
// codeNamespace represents the namespace of implementations of predeploys
codeNamespace = common.HexToAddress("0xc0D3C0d3C0d3C0D3c0d3C0d3c0D3C0d3c0d30000")
// predeployNamespace represents the namespace of predeploys
predeployNamespace = common.HexToAddress("0x4200000000000000000000000000000000000000")
// bigPredeployNamespace represents the predeploy namespace as a big.Int
bigPredeployNamespace = new(big.Int).SetBytes(predeployNamespace.Bytes())
// bigCodeNamespace represents the predeploy namespace as a big.Int
bigCodeNameSpace = new(big.Int).SetBytes(codeNamespace.Bytes())
// implementationSlot represents the EIP 1967 implementation storage slot
ImplementationSlot = common.HexToHash("0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc")
// implementationSlot represents the EIP 1967 admin storage slot
AdminSlot = common.HexToHash("0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103")
)
// DevAccounts represent the standard hardhat development accounts.
// These are funded if the deploy config has funding development
// accounts enabled.
var DevAccounts = []common.Address{
common.HexToAddress("0x14dC79964da2C08b23698B3D3cc7Ca32193d9955"),
common.HexToAddress("0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65"),
common.HexToAddress("0x1CBd3b2770909D4e10f157cABC84C7264073C9Ec"),
common.HexToAddress("0x23618e81E3f5cdF7f54C3d65f7FBc0aBf5B21E8f"),
common.HexToAddress("0x2546BcD3c84621e976D8185a91A922aE77ECEc30"),
common.HexToAddress("0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC"),
common.HexToAddress("0x70997970C51812dc3A010C7d01b50e0d17dc79C8"),
common.HexToAddress("0x71bE63f3384f5fb98995898A86B02Fb2426c5788"),
common.HexToAddress("0x8626f6940E2eb28930eFb4CeF49B2d1F2C9C1199"),
common.HexToAddress("0x90F79bf6EB2c4f870365E785982E1f101E93b906"),
common.HexToAddress("0x976EA74026E726554dB657fA54763abd0C3a0aa9"),
common.HexToAddress("0x9965507D1a55bcC2695C58ba16FB37d819B0A4dc"),
common.HexToAddress("0xBcd4042DE499D14e55001CcbB24a551F3b954096"),
common.HexToAddress("0xFABB0ac9d68B0B445fB7357272Ff202C5651694a"),
common.HexToAddress("0xa0Ee7A142d267C1f36714E4a8F75612F20a79720"),
common.HexToAddress("0xbDA5747bFD65F08deb54cb465eB87D40e51B197E"),
common.HexToAddress("0xcd3B766CCDd6AE721141F452C550Ca635964ce71"),
common.HexToAddress("0xdD2FD4581271e230360230F9337D5c0430Bf44C0"),
common.HexToAddress("0xdF3e18d64BC6A983f673Ab319CCaE4f1a57C7097"),
common.HexToAddress("0xde3829a23df1479438622a08a116e8eb3f620bb5"),
common.HexToAddress("0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"),
}
// The devBalance is the amount of wei that a dev account is funded with.
var devBalance = hexutil.MustDecodeBig("0x200000000000000000000000000000000000000000000000000000000000000")
// FundDevAccounts will fund each of the development accounts.
func FundDevAccounts(db vm.StateDB) {
for _, account := range DevAccounts {
db.CreateAccount(account)
db.AddBalance(account, devBalance)
}
}
// SetProxies will set each of the proxies in the state. It requires
// a Proxy and ProxyAdmin deployment present so that the Proxy bytecode
// can be set in state and the ProxyAdmin can be set as the admin of the
// Proxy.
func SetProxies(hh *hardhat.Hardhat, db vm.StateDB) error {
proxy, err := hh.GetArtifact("Proxy")
if err != nil {
return err
}
proxyAdmin, err := hh.GetDeployment("ProxyAdmin")
if err != nil {
return err
}
for i := uint64(0); i <= 2048; i++ {
bigAddr := new(big.Int).Or(bigPredeployNamespace, new(big.Int).SetUint64(i))
addr := common.BigToAddress(bigAddr)
// There is no proxy at the governance token address
if addr == predeploys.GovernanceTokenAddr {
continue
}
db.CreateAccount(addr)
db.SetCode(addr, proxy.DeployedBytecode)
db.SetState(addr, AdminSlot, proxyAdmin.Address.Hash())
}
return nil
}
// SetImplementations will set the implmentations of the contracts in the state
// and configure the proxies to point to the implementations. It also sets
// the appropriate storage values for each contract at the proxy address.
func SetImplementations(hh *hardhat.Hardhat, db vm.StateDB, storage StorageConfig) error {
deployResults, err := immutables.BuildOptimism()
if err != nil {
return err
}
for name, address := range predeploys.Predeploys {
// Get the hardhat artifact to access the deployed bytecode
artifact, err := hh.GetArtifact(name)
if err != nil {
return err
}
// Convert the address to the code address
var addr common.Address
switch *address {
case predeploys.GovernanceTokenAddr:
addr = predeploys.GovernanceTokenAddr
case predeploys.LegacyERC20ETHAddr:
addr = predeploys.LegacyERC20ETHAddr
default:
addr, err = AddressToCodeNamespace(*address)
if err != nil {
return err
}
// Set the implmentation slot in the predeploy proxy
db.SetState(*address, ImplementationSlot, addr.Hash())
}
// Create the account
db.CreateAccount(addr)
// Use the genrated bytecode when there are immutables
// otherwise use the artifact deployed bytecode
if bytecode, ok := deployResults[name]; ok {
db.SetCode(addr, bytecode)
} else {
db.SetCode(addr, artifact.DeployedBytecode)
}
// Set the storage values
if storageConfig, ok := storage[name]; ok {
layout, err := hh.GetStorageLayout(name)
if err != nil {
return err
}
slots, err := state.ComputeStorageSlots(layout, storageConfig)
if err != nil {
return err
}
// The storage values must go in the proxy address
for _, slot := range slots {
db.SetState(*address, slot.Key, slot.Value)
}
}
code := db.GetCode(addr)
if len(code) == 0 {
return fmt.Errorf("code not set for %s", name)
}
}
return nil
}
// AddressToCodeNamespace takes a predeploy address and computes
// the implmentation address that the implementation should be deployed at
func AddressToCodeNamespace(addr common.Address) (common.Address, error) {
bytesAddr := addr.Bytes()
if !bytes.Equal(bytesAddr[0:2], []byte{0x42, 0x00}) {
return common.Address{}, fmt.Errorf("cannot handle non predeploy: %s", addr)
}
bigAddress := new(big.Int).SetBytes(bytesAddr[18:])
num := new(big.Int).Or(bigCodeNameSpace, bigAddress)
return common.BigToAddress(num), nil
}
// Get the storage layout of the L2ToL1MessagePasser
// Iterate over the storage layout to know which storage slots to ignore
// Iterate over each storage slot, compute the migration
func MigrateDepositHashes(hh *hardhat.Hardhat, db vm.StateDB) error {
layout, err := hh.GetStorageLayout("L2ToL1MessagePasser")
if err != nil {
return err
}
// Build a list of storage slots to ignore. The values in the
// mapping are guaranteed to not be in this list because they are
// hashes.
ignore := make(map[common.Hash]bool)
for _, entry := range layout.Storage {
encoded, err := state.EncodeUintValue(entry.Slot, 0)
if err != nil {
return err
}
ignore[encoded] = true
}
db.ForEachStorage(predeploys.L2ToL1MessagePasserAddr, func(key, value common.Hash) bool {
if _, ok := ignore[key]; ok {
return true
}
// TODO(tynes): Do the value migration here
return true
})
return nil
}
// getBlockFromTag will resolve a Block given an rpc block tag
func getBlockFromTag(chain ethereum.ChainReader, tag rpc.BlockNumberOrHash) (*types.Block, error) {
if hash, ok := tag.Hash(); ok {
block, err := chain.BlockByHash(context.Background(), hash)
if err != nil {
return nil, err
}
return block, nil
} else if num, ok := tag.Number(); ok {
blockNumber := new(big.Int).SetInt64(num.Int64())
block, err := chain.BlockByNumber(context.Background(), blockNumber)
if err != nil {
return nil, err
}
return block, nil
} else {
return nil, fmt.Errorf("invalid block tag: %v", tag)
}
}
package genesis
import (
"github.com/ethereum-optimism/optimism/state-surgery/hardhat"
"github.com/ethereum-optimism/optimism/state-surgery/state"
"github.com/ethereum/go-ethereum/core"
)
// TODO(tynes): need bindings for all of the L1 contracts
func BuildL1DeveloperGenesis(hh *hardhat.Hardhat, config *DeployConfig) (*core.Genesis, error) {
genesis, err := NewL1Genesis(config)
if err != nil {
return nil, err
}
db := state.NewMemoryStateDB(genesis)
if config.FundDevAccounts {
FundDevAccounts(db)
}
return db.Genesis(), nil
}
package genesis
import (
"github.com/ethereum-optimism/optimism/state-surgery/hardhat"
"github.com/ethereum-optimism/optimism/state-surgery/state"
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/core"
)
// BuildOptimismGenesis
func BuildOptimismGenesis(hh *hardhat.Hardhat, config *DeployConfig, chain ethereum.ChainReader) (*core.Genesis, error) {
genesis, err := NewL2Genesis(config, chain)
if err != nil {
return nil, err
}
db := state.NewMemoryStateDB(genesis)
if config.FundDevAccounts {
FundDevAccounts(db)
}
// TODO(tynes): need a function for clearing old, unused storage slots.
// Each deployed contract on L2 needs to have its existing storage
// inspected and then cleared if they are no longer used.
if err := SetProxies(hh, db); err != nil {
return nil, err
}
storage, err := NewStorageConfig(hh, config, chain)
if err != nil {
return nil, err
}
if err := SetImplementations(hh, db, storage); err != nil {
return nil, err
}
if err := MigrateDepositHashes(hh, db); err != nil {
return nil, err
}
return db.Genesis(), nil
}
package genesis_test
import (
"encoding/json"
"flag"
"io/ioutil"
"math/big"
"testing"
"github.com/ethereum/go-ethereum/accounts/abi/bind/backends"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum-optimism/optimism/op-bindings/predeploys"
"github.com/ethereum-optimism/optimism/state-surgery/genesis"
"github.com/ethereum-optimism/optimism/state-surgery/hardhat"
"github.com/stretchr/testify/require"
)
var writeFile bool
func init() {
flag.BoolVar(&writeFile, "write-file", false, "write the genesis file to disk")
}
var testKey, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
func TestBuildOptimismGenesis(t *testing.T) {
hh, err := hardhat.New(
"goerli",
[]string{
"../../packages/contracts-bedrock/artifacts",
"../../packages/contracts-governance/artifacts",
},
[]string{"../../packages/contracts-bedrock/deployments"},
)
require.Nil(t, err)
config, err := genesis.NewDeployConfig("../../packages/contracts-bedrock/deploy-config/devnetL1.json")
require.Nil(t, err)
backend := backends.NewSimulatedBackend(
core.GenesisAlloc{
crypto.PubkeyToAddress(testKey.PublicKey): {Balance: big.NewInt(10000000000000000)},
},
15000000,
)
gen, err := genesis.BuildOptimismGenesis(hh, config, backend)
require.Nil(t, err)
require.NotNil(t, gen)
proxyAdmin, err := hh.GetDeployment("ProxyAdmin")
require.Nil(t, err)
for name, address := range predeploys.Predeploys {
addr := *address
account, ok := gen.Alloc[addr]
require.Equal(t, ok, true)
require.Greater(t, len(account.Code), 0)
if name == "GovernanceToken" || name == "LegacyERC20ETH" {
continue
}
adminSlot, ok := account.Storage[genesis.AdminSlot]
require.Equal(t, ok, true)
require.Equal(t, adminSlot, proxyAdmin.Address.Hash())
}
if writeFile {
file, _ := json.MarshalIndent(gen, "", " ")
_ = ioutil.WriteFile("genesis.json", file, 0644)
}
}
...@@ -31,13 +31,13 @@ func EncodeStorageKeyValue(value any, entry solc.StorageLayoutEntry, storageType ...@@ -31,13 +31,13 @@ func EncodeStorageKeyValue(value any, entry solc.StorageLayoutEntry, storageType
case "bool": case "bool":
val, err := EncodeBoolValue(value, entry.Offset) val, err := EncodeBoolValue(value, entry.Offset)
if err != nil { if err != nil {
return nil, fmt.Errorf("%s bool invalid: %w", entry.Label, err) return nil, fmt.Errorf("cannot encode %s: %w", storageType.Encoding, err)
} }
encoded = append(encoded, &EncodedStorage{key, val}) encoded = append(encoded, &EncodedStorage{key, val})
case "address": case "address":
val, err := EncodeAddressValue(value, entry.Offset) val, err := EncodeAddressValue(value, entry.Offset)
if err != nil { if err != nil {
return nil, fmt.Errorf("%s address invalid: %w", entry.Label, err) return nil, fmt.Errorf("cannot encode %s: %w", storageType.Encoding, err)
} }
encoded = append(encoded, &EncodedStorage{key, val}) encoded = append(encoded, &EncodedStorage{key, val})
case "bytes": case "bytes":
...@@ -45,7 +45,7 @@ func EncodeStorageKeyValue(value any, entry solc.StorageLayoutEntry, storageType ...@@ -45,7 +45,7 @@ func EncodeStorageKeyValue(value any, entry solc.StorageLayoutEntry, storageType
case "bytes32": case "bytes32":
val, err := EncodeBytes32Value(value, entry.Offset) val, err := EncodeBytes32Value(value, entry.Offset)
if err != nil { if err != nil {
return nil, err return nil, fmt.Errorf("cannot encode %s: %w", storageType.Encoding, err)
} }
encoded = append(encoded, &EncodedStorage{key, val}) encoded = append(encoded, &EncodedStorage{key, val})
default: default:
...@@ -53,18 +53,18 @@ func EncodeStorageKeyValue(value any, entry solc.StorageLayoutEntry, storageType ...@@ -53,18 +53,18 @@ func EncodeStorageKeyValue(value any, entry solc.StorageLayoutEntry, storageType
case strings.HasPrefix(label, "contract"): case strings.HasPrefix(label, "contract"):
val, err := EncodeAddressValue(value, entry.Offset) val, err := EncodeAddressValue(value, entry.Offset)
if err != nil { if err != nil {
return nil, fmt.Errorf("%s address invalid: %w", entry.Label, err) return nil, fmt.Errorf("cannot encode %s: %w", storageType.Encoding, err)
} }
encoded = append(encoded, &EncodedStorage{key, val}) encoded = append(encoded, &EncodedStorage{key, val})
case strings.HasPrefix(label, "uint"): case strings.HasPrefix(label, "uint"):
val, err := EncodeUintValue(value, entry.Offset) val, err := EncodeUintValue(value, entry.Offset)
if err != nil { if err != nil {
return nil, err return nil, fmt.Errorf("cannot encode %s: %w", storageType.Encoding, err)
} }
encoded = append(encoded, &EncodedStorage{key, val}) encoded = append(encoded, &EncodedStorage{key, val})
default: default:
// structs are not supported // structs are not supported
return nil, fmt.Errorf("%w: %s", errUnimplemented, label) return nil, fmt.Errorf("cannot encode %s: %w", storageType.Encoding, errUnimplemented)
} }
} }
case "dynamic_array": case "dynamic_array":
...@@ -73,7 +73,7 @@ func EncodeStorageKeyValue(value any, entry solc.StorageLayoutEntry, storageType ...@@ -73,7 +73,7 @@ func EncodeStorageKeyValue(value any, entry solc.StorageLayoutEntry, storageType
case "string": case "string":
val, err := EncodeStringValue(value, entry.Offset) val, err := EncodeStringValue(value, entry.Offset)
if err != nil { if err != nil {
return nil, err return nil, fmt.Errorf("cannot encode %s: %w", storageType.Encoding, errUnimplemented)
} }
encoded = append(encoded, &EncodedStorage{key, val}) encoded = append(encoded, &EncodedStorage{key, val})
default: default:
...@@ -86,8 +86,7 @@ func EncodeStorageKeyValue(value any, entry solc.StorageLayoutEntry, storageType ...@@ -86,8 +86,7 @@ func EncodeStorageKeyValue(value any, entry solc.StorageLayoutEntry, storageType
values, ok := value.(map[any]any) values, ok := value.(map[any]any)
if !ok { if !ok {
return nil, fmt.Errorf("cannot parse mapping") return nil, fmt.Errorf("mapping must be map[any]any")
} }
keyEncoder, err := getElementEncoder(storageType, "key") keyEncoder, err := getElementEncoder(storageType, "key")
...@@ -122,7 +121,7 @@ func EncodeStorageKeyValue(value any, entry solc.StorageLayoutEntry, storageType ...@@ -122,7 +121,7 @@ func EncodeStorageKeyValue(value any, entry solc.StorageLayoutEntry, storageType
encoded = append(encoded, &EncodedStorage{key, val}) encoded = append(encoded, &EncodedStorage{key, val})
} }
default: default:
return nil, fmt.Errorf("unknown encoding: %s", storageType.Encoding) return nil, fmt.Errorf("unknown encoding %s: %w", storageType.Encoding, errUnimplemented)
} }
return encoded, nil return encoded, nil
} }
...@@ -268,7 +267,7 @@ func encodeStringValue(value any) (common.Hash, error) { ...@@ -268,7 +267,7 @@ func encodeStringValue(value any) (common.Hash, error) {
func EncodeBoolValue(value any, offset uint) (common.Hash, error) { func EncodeBoolValue(value any, offset uint) (common.Hash, error) {
val, err := encodeBoolValue(value) val, err := encodeBoolValue(value)
if err != nil { if err != nil {
return common.Hash{}, err return common.Hash{}, fmt.Errorf("invalid bool: %w", err)
} }
return handleOffset(val, offset), nil return handleOffset(val, offset), nil
} }
...@@ -308,7 +307,7 @@ func encodeBoolValue(value any) (common.Hash, error) { ...@@ -308,7 +307,7 @@ func encodeBoolValue(value any) (common.Hash, error) {
func EncodeAddressValue(value any, offset uint) (common.Hash, error) { func EncodeAddressValue(value any, offset uint) (common.Hash, error) {
val, err := encodeAddressValue(value) val, err := encodeAddressValue(value)
if err != nil { if err != nil {
return common.Hash{}, err return common.Hash{}, fmt.Errorf("invalid address: %w", err)
} }
return handleOffset(val, offset), nil return handleOffset(val, offset), nil
} }
...@@ -352,7 +351,7 @@ func encodeAddressValue(value any) (common.Hash, error) { ...@@ -352,7 +351,7 @@ func encodeAddressValue(value any) (common.Hash, error) {
func EncodeUintValue(value any, offset uint) (common.Hash, error) { func EncodeUintValue(value any, offset uint) (common.Hash, error) {
val, err := encodeUintValue(value) val, err := encodeUintValue(value)
if err != nil { if err != nil {
return common.Hash{}, err return common.Hash{}, fmt.Errorf("invalid uint: %w", err)
} }
return handleOffset(val, offset), nil return handleOffset(val, offset), nil
} }
...@@ -430,6 +429,16 @@ func encodeUintValue(value any) (common.Hash, error) { ...@@ -430,6 +429,16 @@ func encodeUintValue(value any) (common.Hash, error) {
} }
} }
return common.BigToHash(number), nil return common.BigToHash(number), nil
case "bool":
val, ok := value.(bool)
if !ok {
return common.Hash{}, errInvalidType
}
if val {
return common.Hash{31: 0x01}, nil
} else {
return common.Hash{}, nil
}
case "Int": case "Int":
val, ok := value.(*big.Int) val, ok := value.(*big.Int)
if !ok { if !ok {
......
...@@ -24,7 +24,7 @@ type EncodedStorage struct { ...@@ -24,7 +24,7 @@ type EncodedStorage struct {
// EncodedStorage will encode a storage layout // EncodedStorage will encode a storage layout
func EncodeStorage(entry solc.StorageLayoutEntry, value any, storageType solc.StorageLayoutType) ([]*EncodedStorage, error) { func EncodeStorage(entry solc.StorageLayoutEntry, value any, storageType solc.StorageLayoutType) ([]*EncodedStorage, error) {
if storageType.NumberOfBytes > 32 { if storageType.NumberOfBytes > 32 {
return nil, fmt.Errorf("%s is larger than 32 bytes", entry.Label) return nil, fmt.Errorf("%s is larger than 32 bytes", storageType.Encoding)
} }
encoded, err := EncodeStorageKeyValue(value, entry, storageType) encoded, err := EncodeStorageKeyValue(value, entry, storageType)
...@@ -60,7 +60,7 @@ func ComputeStorageSlots(layout *solc.StorageLayout, values StorageValues) ([]*E ...@@ -60,7 +60,7 @@ func ComputeStorageSlots(layout *solc.StorageLayout, values StorageValues) ([]*E
storage, err := EncodeStorage(target, value, storageType) storage, err := EncodeStorage(target, value, storageType)
if err != nil { if err != nil {
return nil, fmt.Errorf("cannot encode storage: %w", err) return nil, fmt.Errorf("cannot encode storage for %s: %w", target.Label, err)
} }
encodedStorage = append(encodedStorage, storage...) encodedStorage = append(encodedStorage, storage...)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment