Skip to content

Commit

Permalink
Implement proxy contract (#66)
Browse files Browse the repository at this point in the history
* Implement proxy contract

* Add check for previous events

* Add second solution

* Revert naming changes from 331c8bf to make code consistent with mainnet-deployed contracts

* Remove second solution for proxy contract. Add necessary functions

* Add tests for eth custodian proxy

* Remove leftover variables

* Remove unused code

* Convert SelectivePausable contract to namespaced storage (eip-7201)

* Combine withdraw functionality into a single function

* Add generic admin method on the proxy

* Correct deployment script

* Test corrections

* Update constant

* Fixed event name in tests

* update config

* add etherscan verififcation

* update admin scripts

* PAUSED_WITHDRAW -> PAUSED_WITHDRAW_POST_MIGRATION

* add fee for backword compatibility

* emit Deposited event in Proxy Contract

* Add gap for future implementation of ProofKeeper for the proxy

* Update gap value

* Add `updateAdminLegacy` script

* Fix verification

* Update hardhat and ethers to v6

* Fix test

* Extract block height from proof (#67)

* draft getBlockHeightFromProof

* debug

* fix extract block height from proof

* fix tests and contract

* separate BlockHeightFromProofExtractor

* add new test

* fix tests

* fix tests

* add checkPreMigration flag

* add test with switched off preMigration check

* add comments about proof structure

* add comment for withdraw function

* checkPreMigration -> receiptBlockHeight

* Add upgrade script

---------

Co-authored-by: imherefortech <[email protected]>
Co-authored-by: kiseln <[email protected]>
Co-authored-by: Olga Kunyavskaya <[email protected]>
Co-authored-by: Olga Kunyavskaya <[email protected]>
  • Loading branch information
5 people authored Sep 6, 2024
1 parent 8bf4ae7 commit 5d59591
Show file tree
Hide file tree
Showing 28 changed files with 7,034 additions and 6,579 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,12 @@ After that call: <br />
As a result of the function call you will get the address of the freshly deployed `EthCustodian` that you can put in
your `ethereum-config.json` file in the `ethConnectorAddress` field.

After `ethConnectorAddress` is set, you can run

`$ make eth-deploy-proxy`

to deploy the proxy contract and make it the admin of `EthCustodian`.

### Other scripts

For more advanced usage, please examine the `hardhat.config.js` file which contains a lot of scripts that are performed
Expand Down
350 changes: 350 additions & 0 deletions eth-custodian/.openzeppelin/sepolia.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,350 @@
{
"manifestVersion": "3.2",
"proxies": [
{
"address": "0x4C8afA2fD22dB1c6091A96c382e6546529475B5c",
"txHash": "0x5d7ff3f8b6d8b5f1ba7a4948769e35b4221f0ba451be69d66097dab976cd7545",
"kind": "uups"
}
],
"impls": {
"9346696a759d727ad8297a3bc36e68f05c2afa8a33630ff7e9e3a2378b9b093d": {
"address": "0xfCFF3475142cE152930dE7Aa6da85D855c106812",
"txHash": "0xe20ac4395ad7c790b833f3f33281f58e155d30f30c86be4070d761d3511daccf",
"layout": {
"solcVersion": "0.8.20",
"storage": [
{
"label": "__gap",
"offset": 0,
"slot": "0",
"type": "t_array(t_uint256)50_storage",
"contract": "ProofKeeperGap",
"src": "contracts/ProofKeeperGap.sol:7"
},
{
"label": "_pausedFlags",
"offset": 0,
"slot": "50",
"type": "t_uint256",
"contract": "SelectivePausableUpgradable",
"src": "contracts/SelectivePausableUpgradable.sol:37"
},
{
"label": "preMigrationProducerAccount",
"offset": 0,
"slot": "51",
"type": "t_bytes_storage",
"contract": "EthCustodianProxy",
"src": "contracts/EthCustodianProxy.sol:32"
},
{
"label": "migrationBlockHeight",
"offset": 0,
"slot": "52",
"type": "t_uint64",
"contract": "EthCustodianProxy",
"src": "contracts/EthCustodianProxy.sol:33"
},
{
"label": "ethCustodianImpl",
"offset": 8,
"slot": "52",
"type": "t_contract(EthCustodian)2135",
"contract": "EthCustodianProxy",
"src": "contracts/EthCustodianProxy.sol:35"
}
],
"types": {
"t_address": {
"label": "address",
"numberOfBytes": "20"
},
"t_bool": {
"label": "bool",
"numberOfBytes": "1"
},
"t_bytes32": {
"label": "bytes32",
"numberOfBytes": "32"
},
"t_mapping(t_address,t_bool)": {
"label": "mapping(address => bool)",
"numberOfBytes": "32"
},
"t_mapping(t_bytes32,t_struct(RoleData)25_storage)": {
"label": "mapping(bytes32 => struct AccessControlUpgradeable.RoleData)",
"numberOfBytes": "32"
},
"t_struct(AccessControlStorage)35_storage": {
"label": "struct AccessControlUpgradeable.AccessControlStorage",
"members": [
{
"label": "_roles",
"type": "t_mapping(t_bytes32,t_struct(RoleData)25_storage)",
"offset": 0,
"slot": "0"
}
],
"numberOfBytes": "32"
},
"t_struct(InitializableStorage)95_storage": {
"label": "struct Initializable.InitializableStorage",
"members": [
{
"label": "_initialized",
"type": "t_uint64",
"offset": 0,
"slot": "0"
},
{
"label": "_initializing",
"type": "t_bool",
"offset": 8,
"slot": "0"
}
],
"numberOfBytes": "32"
},
"t_struct(RoleData)25_storage": {
"label": "struct AccessControlUpgradeable.RoleData",
"members": [
{
"label": "hasRole",
"type": "t_mapping(t_address,t_bool)",
"offset": 0,
"slot": "0"
},
{
"label": "adminRole",
"type": "t_bytes32",
"offset": 0,
"slot": "1"
}
],
"numberOfBytes": "64"
},
"t_uint64": {
"label": "uint64",
"numberOfBytes": "8"
},
"t_array(t_uint256)50_storage": {
"label": "uint256[50]",
"numberOfBytes": "1600"
},
"t_bytes_storage": {
"label": "bytes",
"numberOfBytes": "32"
},
"t_contract(EthCustodian)2135": {
"label": "contract EthCustodian",
"numberOfBytes": "20"
},
"t_uint256": {
"label": "uint256",
"numberOfBytes": "32"
}
},
"namespaces": {
"erc7201:openzeppelin.storage.AccessControl": [
{
"contract": "AccessControlUpgradeable",
"label": "_roles",
"type": "t_mapping(t_bytes32,t_struct(RoleData)25_storage)",
"src": "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol:61",
"offset": 0,
"slot": "0"
}
],
"erc7201:openzeppelin.storage.Initializable": [
{
"contract": "Initializable",
"label": "_initialized",
"type": "t_uint64",
"src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:69",
"offset": 0,
"slot": "0"
},
{
"contract": "Initializable",
"label": "_initializing",
"type": "t_bool",
"src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:73",
"offset": 8,
"slot": "0"
}
]
}
}
},
"11c941e83dcf4b3077416195d38866dd6a19bfa50b4b6f48b442e18bd8d9a69a": {
"address": "0x47996EC1CE791225DcA05fDC7d7eB74e552c05e6",
"txHash": "0x647557339ffd586f4de322a9b23915952cb61c421530a6211fac13e864849db9",
"layout": {
"solcVersion": "0.8.20",
"storage": [
{
"label": "__gap",
"offset": 0,
"slot": "0",
"type": "t_array(t_uint256)50_storage",
"contract": "ProofKeeperGap",
"src": "contracts/ProofKeeperGap.sol:7"
},
{
"label": "_pausedFlags",
"offset": 0,
"slot": "50",
"type": "t_uint256",
"contract": "SelectivePausableUpgradable",
"src": "contracts/SelectivePausableUpgradable.sol:37"
},
{
"label": "preMigrationProducerAccount",
"offset": 0,
"slot": "51",
"type": "t_bytes_storage",
"contract": "EthCustodianProxy",
"src": "contracts/EthCustodianProxy.sol:33"
},
{
"label": "migrationBlockHeight",
"offset": 0,
"slot": "52",
"type": "t_uint64",
"contract": "EthCustodianProxy",
"src": "contracts/EthCustodianProxy.sol:34"
},
{
"label": "ethCustodianImpl",
"offset": 8,
"slot": "52",
"type": "t_contract(EthCustodian)2368",
"contract": "EthCustodianProxy",
"src": "contracts/EthCustodianProxy.sol:36"
}
],
"types": {
"t_address": {
"label": "address",
"numberOfBytes": "20"
},
"t_bool": {
"label": "bool",
"numberOfBytes": "1"
},
"t_bytes32": {
"label": "bytes32",
"numberOfBytes": "32"
},
"t_mapping(t_address,t_bool)": {
"label": "mapping(address => bool)",
"numberOfBytes": "32"
},
"t_mapping(t_bytes32,t_struct(RoleData)25_storage)": {
"label": "mapping(bytes32 => struct AccessControlUpgradeable.RoleData)",
"numberOfBytes": "32"
},
"t_struct(AccessControlStorage)35_storage": {
"label": "struct AccessControlUpgradeable.AccessControlStorage",
"members": [
{
"label": "_roles",
"type": "t_mapping(t_bytes32,t_struct(RoleData)25_storage)",
"offset": 0,
"slot": "0"
}
],
"numberOfBytes": "32"
},
"t_struct(InitializableStorage)95_storage": {
"label": "struct Initializable.InitializableStorage",
"members": [
{
"label": "_initialized",
"type": "t_uint64",
"offset": 0,
"slot": "0"
},
{
"label": "_initializing",
"type": "t_bool",
"offset": 8,
"slot": "0"
}
],
"numberOfBytes": "32"
},
"t_struct(RoleData)25_storage": {
"label": "struct AccessControlUpgradeable.RoleData",
"members": [
{
"label": "hasRole",
"type": "t_mapping(t_address,t_bool)",
"offset": 0,
"slot": "0"
},
{
"label": "adminRole",
"type": "t_bytes32",
"offset": 0,
"slot": "1"
}
],
"numberOfBytes": "64"
},
"t_uint64": {
"label": "uint64",
"numberOfBytes": "8"
},
"t_array(t_uint256)50_storage": {
"label": "uint256[50]",
"numberOfBytes": "1600"
},
"t_bytes_storage": {
"label": "bytes",
"numberOfBytes": "32"
},
"t_contract(EthCustodian)2368": {
"label": "contract EthCustodian",
"numberOfBytes": "20"
},
"t_uint256": {
"label": "uint256",
"numberOfBytes": "32"
}
},
"namespaces": {
"erc7201:openzeppelin.storage.AccessControl": [
{
"contract": "AccessControlUpgradeable",
"label": "_roles",
"type": "t_mapping(t_bytes32,t_struct(RoleData)25_storage)",
"src": "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol:61",
"offset": 0,
"slot": "0"
}
],
"erc7201:openzeppelin.storage.Initializable": [
{
"contract": "Initializable",
"label": "_initialized",
"type": "t_uint64",
"src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:69",
"offset": 0,
"slot": "0"
},
{
"contract": "Initializable",
"label": "_initializing",
"type": "t_bool",
"src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:73",
"offset": 8,
"slot": "0"
}
]
}
}
}
}
}
Loading

0 comments on commit 5d59591

Please sign in to comment.