Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(scratch deploy): mvp of local scratch deployment #790

Merged
merged 51 commits into from
Nov 4, 2023

Conversation

arwer13
Copy link
Contributor

@arwer13 arwer13 commented Sep 11, 2023

Renovation of the scratch deploy scripts. For the README see docs/scratch-deploy.md

NB that the scripts are to undertake one more refactoring iteration during migration to TypeScript and new repo https://github.com/lidofinance/core

@TheDZhon TheDZhon requested a review from kovalgek September 11, 2023 13:19
Comment on lines +13 to +28
contract WithdrawalsManagerStub {
/**
* @dev Receives Ether.
*
* Currently this is intentionally not supported since Ethereum 2.0 withdrawals specification
* might change before withdrawals are enabled. This contract sits behind a proxy that can be
* upgraded to a new implementation contract collectively by LDO holders by performing a vote.
*
* When Ethereum 2.0 withdrawals specification is finalized, Lido DAO will prepare the new
* implementation contract and initiate a vote among LDO holders for upgrading the proxy to
* the new implementation.
*/
receive() external payable {
revert("not supported");
}
}

Check warning

Code scanning / Slither

Contracts that lock Ether

Contract locking ether found: Contract WithdrawalsManagerStub (contracts/0.8.4/WithdrawalsManagerProxy.sol#13-28) has payable functions: - WithdrawalsManagerStub.receive() (contracts/0.8.4/WithdrawalsManagerProxy.sol#25-27) But does not have a function to withdraw the ether
Comment on lines +469 to +479
function proxy_upgradeTo(address newImplementation, bytes memory setupCalldata) external {
address admin = _getAdmin();
require(admin != address(0), "proxy: ossified");
require(msg.sender == admin, "proxy: unauthorized");

_upgradeTo(newImplementation);

if (setupCalldata.length > 0) {
Address.functionDelegateCall(newImplementation, setupCalldata, "proxy: setup failed");
}
}

Check warning

Code scanning / Slither

Unused return

WithdrawalsManagerProxy.proxy_upgradeTo(address,bytes) (contracts/0.8.4/WithdrawalsManagerProxy.sol#469-479) ignores return value by Address.functionDelegateCall(newImplementation,setupCalldata,proxy: setup failed) (contracts/0.8.4/WithdrawalsManagerProxy.sol#477)
Comment on lines +326 to +332
constructor(address _logic, bytes memory _data) payable {
assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1));
_setImplementation(_logic);
if(_data.length > 0) {
Address.functionDelegateCall(_logic, _data);
}
}

Check warning

Code scanning / Slither

Unused return

ERC1967Proxy.constructor(address,bytes) (contracts/0.8.4/WithdrawalsManagerProxy.sol#326-332) ignores return value by Address.functionDelegateCall(_logic,_data) (contracts/0.8.4/WithdrawalsManagerProxy.sol#330)
@arwer13 arwer13 requested review from avsetsin and TheDZhon October 12, 2023 07:29
@TheDZhon TheDZhon requested a review from loga4 October 12, 2023 08:59
@arwer13 arwer13 requested a review from krogla October 16, 2023 09:03
Copy link
Contributor

Choose a reason for hiding this comment

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

the json files are quite different for different networks, for example this is how the accounting oracle section looks like for goerli and holesky:

"accountingOracle": {
  "parameters": {
  "deployParameters": {
    "consensusVersion": 1
  },
  "contract": "AccountingOracle",
  "implementation": "0xC94ad2eb129146235f71cc35f7FbFec7fe404DF9",
  "address": "0x76f358A842defa0E179a8970767CFf668Fc134d6",
  "constructorArgs": [
    "0x1eDf09b5023DC86737b59dE68a8130De878984f5",
    "0x1643E812aE58766192Cf7D2Cf9567dF2C37e9B7F",
    "0x24d8451BC07e7aF4Ba94F69aCDD9ad3c6579D9FB",
    12,
    1616508000
  ]
},
"accountingOracle": {
  "deployParameters": {
    "consensusVersion": 1
  },
  "proxy": {
    "contract": "contracts/0.8.9/proxy/OssifiableProxy.sol",
    "address": "0x4E97A3972ce8511D87F334dA17a2C332542a5246",
    "constructorArgs": [
      "0x6AcA050709469F1f98d8f40f68b1C83B533cd2b2",
      "0x22896Bfc68814BFD855b1a167255eE497006e730",
      "0x"
    ]
  },
  "implementation": {
    "contract": "contracts/0.8.9/oracle/AccountingOracle.sol",
    "address": "0x6AcA050709469F1f98d8f40f68b1C83B533cd2b2",
    "constructorArgs": [
      "0x28FAB2059C713A7F9D8c86Db49f9bb0e96Af1ef8",
      "0x3F1c547b21f65e10480dE3ad8E19fAAC46C95034",
      "0x072f72BE3AcFE2c52715829F2CD9061A6C8fF019",
      12,
      1695902400
    ]
  }
},

May we bring them to the same format and make a uniform order (maybe sort the keys alphabetically)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm pro for the unified order and for the alphabetical one: seems to be the most seamless among other options.

Copy link
Contributor

Choose a reason for hiding this comment

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

I support the suggestion by @avsetsin 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor

@loga4 loga4 left a comment

Choose a reason for hiding this comment

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

maybe remove cli folder at all?

Copy link
Member

@krogla krogla left a comment

Choose a reason for hiding this comment

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

couple of minor remarks. otherwise lgtm

address: contract.address,
constructorArgs: constructorArgs,
}
persistNetworkState2(network.name, netId, state)
Copy link
Member

Choose a reason for hiding this comment

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

persistNetworkState2 -> persistNetworkState ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed duplicate function, left the more straightforward version of it

@@ -1,4 +1,4 @@
const { readNetworkState, persistNetworkState2 } = require('./persisted-network-state')
const { readNetworkState, persistNetworkState, persistNetworkState2 } = require('./persisted-network-state')
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need 2 funcs like persistNetworkState ?
or maybe rename persist Network State 2 to understand the difference with persistNetworkState ?

Copy link
Member

Choose a reason for hiding this comment

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

actually, we don't )
persistNetworkState2 was introduced by me once upon a time to maintain compatibility with all other existing scripts, but I also agree that it is a bit redundant

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed duplicate function, left the more straightforward version of it

Copy link
Contributor

@TheDZhon TheDZhon left a comment

Choose a reason for hiding this comment

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

Wow, this is huge 👏

I'd suggest implementing some changes and updating the README file as well to properly refer to the new scratch deployment approach.

Copy link
Contributor

Choose a reason for hiding this comment

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

I support the suggestion by @avsetsin 👍


if (implementation === null) {
console.log(`Deploying implementation for proxy of ${artifactName}`)
process.stdout.write(`Deploying implementation for proxy of ${artifactName}... `)
Copy link
Contributor

Choose a reason for hiding this comment

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

why sometimes console.log but here process.stdout?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

process.stdout.write is for printing without end of line (just to save some space on the screen)

@TheDZhon
Copy link
Contributor

@arwer13 could you please explicitly secure the quorum-sufficient TESTLDO amount to reside on the Agent's balance during the deployment

That would ease governance-related test fixtures greatly.

@bulbozaur proposes the idea, and I'd suggest implementing it

@arwer13
Copy link
Contributor Author

arwer13 commented Oct 31, 2023

could you please explicitly secure the quorum-sufficient TESTLDO amount to reside on the Agent's balance during the deployment
Added.

The other comments are processed as well.
Ready for merge, imho.

@arwer13 arwer13 dismissed TheDZhon’s stale review November 4, 2023 06:58

TheDZhon is OoO, but he approved beforehand in messanger.

@arwer13 arwer13 merged commit 9677230 into develop Nov 4, 2023
@arwer13 arwer13 deleted the feat/scratch-holesky branch November 4, 2023 06:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants