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

Contract Pipeline Scripts #561

Merged
merged 55 commits into from
Oct 16, 2024
Merged

Contract Pipeline Scripts #561

merged 55 commits into from
Oct 16, 2024

Conversation

Primata
Copy link
Contributor

@Primata Primata commented Sep 11, 2024

Summary

  • RFCs: $\emptyset$.
  • Categories: scripts.

Handles contract deployment, upgrades and stores it using Foundry script.

Changelog

  • MovementDeployer.s.sol - Script to handle deployment of all solidity contracts.
  • MCRDeployer.s.sol - Script to handle MCR deployment and upgrade.
  • StlMoveDeployer.s.sol - Script to handle StlMove deployment and upgrade.
  • StakingDeployer.s.sol - Script to handle Staking deployment and upgrade.
  • MoveDeployer.s.sol - Pending from other branch
  • upgrader/ - cotains a bash script and typescript file to proposeTransaction to MovementLabs safe multisig.

Testing

Relying on previous tests. Deployment is valid and stored values are valid.

If there are previous deployments, tests are run on top of existent deployments on specific environments.
Existent deployments are specified in protocol-units/settlement/mcr/contracts/script/helpers/deployments.json. If running on foundry localchain, all contracts will be deployed and upgraded.

E.g. Simulate deployment on top of Sepolia existent contracts:

forge script CoreDeployer --fork-url https://eth-sepolia.api.onfinality.io/public

"11155111": {
        "mcr": "0x0000000000000000000000000000000000000000",
        "mcrAdmin": "0x0000000000000000000000000000000000000000",
        "move": "0x0000000000000000000000000000000000000000",
        "moveAdmin": "0x0000000000000000000000000000000000000000",
        "movementAnchorage": "0x0000000000000000000000000000000000000000",
        "movementDeployerSafe": "0xDfBe79c22944b25beDF690Af3FC7CC9289E946f1",
        "movementFoundationSafe": "0x00db70A9e12537495C359581b7b3Bc3a69379A00",
        "movementLabsSafe": "0x493516F6dB02c9b7f649E650c5de244646022Aa0",
        "staking": "0x0000000000000000000000000000000000000000",
        "stakingAdmin": "0x0000000000000000000000000000000000000000",
        "stlMove": "0x0000000000000000000000000000000000000000",
        "stlMoveAdmin": "0x0000000000000000000000000000000000000000",
        "timelock": "0xC5B4Ca6E12144dE0e8e666F738A289476bebBc02"
    },

because safes and timelock exist on this environment, they will be skipped. All subsequent contracts should be deployed.

Outstanding issues

  • parameters are currently hardcoded, we might want to add flexibility for upgrades.
  • Versioning is currently not supported.

MCR newMCRImplementation = new MCR();
timelock.schedule(
address(deployment.mcrAdmin),
0,
Copy link
Collaborator

Choose a reason for hiding this comment

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

This just informs the hash of the operation. Right now, we would want these to collide to avoid redundant upgrades, right? Does that take care of everything? In what case would this take a nonce value?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This actually schedules a transaction on the Timelock contract. It performs the call.
It's not feasible for us to include handling the execution of the timelock transaction imo. We'll be using the safe FE anyway, it takes way less time, it populates the transaction for us, handles signature for all the parties involved, etc.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I mean the 0: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/cae60c595b37b1e7ed7dd50ad0257387ec07c0cf/contracts/governance/TimelockController.sol#L266

The delay should be the actual time-lock no? The value is just used for the operation hash?

Copy link
Collaborator

Choose a reason for hiding this comment

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

safe FE

I don't recall agreeing on this. This supposed to be dispatched from CI.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

safe FE

I don't recall agreeing on this. This supposed to be dispatched from CI.

The 0 was for value in eth to be transactioned

Copy link
Collaborator

Choose a reason for hiding this comment

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

The 0 was for value in eth to be transactioned

Wdym?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

during deployment you have the option of passing a certain amount of eth to subsequent calls because you might want to pay for something. This does not happen here.

@l-monninger
Copy link
Collaborator

Relying on previous tests. Deployment is valid and stored values are valid.

Can you expand?

@l-monninger
Copy link
Collaborator

This PR should be renamed something like "Contract Pipeline Deployment Scripts" for clarity. It doesn't include the actual automation, checks, etc., ofc.

@l-monninger
Copy link
Collaborator

If I run back-to-back deployments on Holesky naively, I get new proxies. The intended usage needs to be documented.

forge script -f https://ethereum-holesky-rpc.publicnode.com ./script/MovementDeployer.s.sol --legacy --broadcast
[⠊] Compiling...
[⠘] Compiling 79 files with 0.8.26
[⠒] Solc 0.8.26 finished in 3.94s
Compiler run successful with warnings:
Warning (2519): This declaration shadows an existing declaration.
   --> script/MovementDeployer.s.sol:119:56:
    |
119 |     function _storeAdminDeployment() internal returns (address admin) {
    |                                                        ^^^^^^^^^^^^^
Note: The shadowed declaration is here:
  --> script/MovementDeployer.s.sol:23:5:
   |
23 |     ProxyAdmin public admin;
   |     ^^^^^^^^^^^^^^^^^^^^^^^

Warning (2072): Unused local variable.
   --> script/MovementDeployer.s.sol:106:9:
    |
106 |         string memory a = json.serialize("move", deployment.move);
    |         ^^^^^^^^^^^^^^^

Warning (2072): Unused local variable.
   --> script/MovementDeployer.s.sol:107:9:
    |
107 |         string memory b = json.serialize("moveAdmin", deployment.moveAdmin);
    |         ^^^^^^^^^^^^^^^

Warning (2072): Unused local variable.
   --> script/MovementDeployer.s.sol:108:9:
    |
108 |         string memory c = json.serialize("staking", deployment.staking);
    |         ^^^^^^^^^^^^^^^

Warning (2072): Unused local variable.
   --> script/MovementDeployer.s.sol:109:9:
    |
109 |         string memory d = json.serialize("stakingAdmin", deployment.stakingAdmin);
    |         ^^^^^^^^^^^^^^^

Warning (2072): Unused local variable.
   --> script/MovementDeployer.s.sol:110:9:
    |
110 |         string memory e = json.serialize("stlMove", deployment.stlMove);
    |         ^^^^^^^^^^^^^^^

Warning (2072): Unused local variable.
   --> script/MovementDeployer.s.sol:111:9:
    |
111 |         string memory f = json.serialize("stlMoveAdmin", deployment.stlMoveAdmin);
    |         ^^^^^^^^^^^^^^^

Warning (2072): Unused local variable.
   --> script/MovementDeployer.s.sol:112:9:
    |
112 |         string memory g = json.serialize("mcr", deployment.mcr);
    |         ^^^^^^^^^^^^^^^

Warning (2072): Unused local variable.
   --> script/MovementDeployer.s.sol:113:9:
    |
113 |         string memory h = json.serialize("mcrAdmin", deployment.mcrAdmin);
    |         ^^^^^^^^^^^^^^^

Warning (2072): Unused local variable.
   --> script/MovementDeployer.s.sol:114:9:
    |
114 |         string memory i = json.serialize("timelock", deployment.timelock);
    |         ^^^^^^^^^^^^^^^

Warning (2018): Function state mutability can be restricted to pure
 --> script/helpers/Helper.sol:6:5:
  |
6 |     function s2a(bytes memory str) public returns (address addr) {
  |     ^ (Relevant source part starts here and spans across multiple lines).

Script ran successfully.

== Logs ==
  MOVE: deploying
  MOVE deployment records:
  proxy 0x80A4A809194d89D325229479ed02dEEB922caae4
  admin 0x006aB345C1081F4Dd014AF754AEFE5959C91bcBD
  STAKING: deploying
  STAKING deployment records:
  proxy 0x9D5f6E7C56c23D6cd2960A250F05A5431B171C63
  admin 0xf38a9783C6dE8bE85aD41877231630225d7605C6
  STL: deploying
  STL deployment records:
  proxy 0x8b4579B3B3f409b6F929c9C6fAf41C1f841d6507
  admin 0xeD9E92053B03215E95886b801A7C11C51137430e
  MCR: deploying
  MCR deployment records:
  proxy 0xDF3e5F48EA297E3474ABf4D3F3A8Bad9C295901B
  admin 0xb1BC25E99def9bB8e5d707E922C133267eA07933

## Setting up 1 EVM.

==========================

Chain 17000

Estimated gas price: 0.63325118 gwei

Estimated total gas used for script: 17649737

Estimated amount required: 0.01117671678193966 ETH

==========================
##
Sending transactions [0 - 8].
⠲ [00:00:01] [###################################################################] 9/9 txes (0.0s)##
Waiting for receipts.
⠴ [00:00:08] [###############################################################] 9/9 receipts (0.0s)
##### holesky
✅  [Success]Hash: 0x56d5255f27a3a159816b65694a877469a780b7f6d90ff0c9cef916387f00f784
Contract Address: 0x2fC44E40F1766d5Fa7244d5ccb15F9837c204270
Block: 2313672
Paid: 0.00114510684229164 ETH (1808298 gas * 0.63325118 gwei)


##### holesky
✅  [Success]Hash: 0x237f75de6e20bef1b1a4a59b783642cfdf429b7092d5d1a7786859502cf8c3aa
Contract Address: 0x0eF3Ed7f9C2A813E9Fb50fb898fdc9F15Efe3A04
Block: 2313672
Paid: 0.0009482588132351 ETH (1497445 gas * 0.63325118 gwei)


##### holesky
✅  [Success]Hash: 0x5492c225863551fa0a99b3c049c8b3e6db3070162984a32554e6d928c40066f5
Contract Address: 0x80A4A809194d89D325229479ed02dEEB922caae4
Block: 2313672
Paid: 0.00052918204782762 ETH (835659 gas * 0.63325118 gwei)


##### holesky
✅  [Success]Hash: 0x1c7cbd1609967c0ea6f7442e9ff8885af43e17ca947070d165a6f28570cfb906
Contract Address: 0x6b018aaB9dD55DCb287B848713fC5263Cc9EDF70
Block: 2313672
Paid: 0.00152987659177144 ETH (2415908 gas * 0.63325118 gwei)


##### holesky
✅  [Success]Hash: 0x1ceb6a1e43d71f2635a8b3501f4d4b6b7974229a828fbc9ea2aca33f8baf477f
Contract Address: 0x9D5f6E7C56c23D6cd2960A250F05A5431B171C63
Block: 2313672
Paid: 0.00045363708180716 ETH (716362 gas * 0.63325118 gwei)


##### holesky
✅  [Success]Hash: 0x5ad9c462f47d4d1ec5790137fab994df914b5fdd04e08712a459dacb2b06a576
Contract Address: 0xa9c363A99d24c9de8650EDEEeb5bDD8ffae26C5f
Block: 2313672
Paid: 0.0015126185973629 ETH (2388655 gas * 0.63325118 gwei)


##### holesky
✅  [Success]Hash: 0xa7302222e99d40d219d8917b2c9e73b1e62b786121222fc7088f7572324f4fc0
Contract Address: 0x8b4579B3B3f409b6F929c9C6fAf41C1f841d6507
Block: 2313672
Paid: 0.00063890801279094 ETH (1008933 gas * 0.63325118 gwei)


##### holesky
✅  [Success]Hash: 0xf4fa72cb7e6986d183ccb7dd9cd3b6de416122d74e9d5520832d9d403620da1e
Contract Address: 0x95092381eAF91804362D27F1f7aE6C642CDAA85F
Block: 2313672
Paid: 0.00117883886614788 ETH (1861566 gas * 0.63325118 gwei)


##### holesky
✅  [Success]Hash: 0x3eef916e2da01aed913900d11d6f5f8e6df5af96254914563d91f53b1201447f
Contract Address: 0xDF3e5F48EA297E3474ABf4D3F3A8Bad9C295901B
Block: 2313672
Paid: 0.00066105027355082 ETH (1043899 gas * 0.63325118 gwei)



==========================

ONCHAIN EXECUTION COMPLETE & SUCCESSFUL.
Total Paid: 0.0085974771267855 ETH (13576725 gas * avg 0.63325118 gwei)

Transactions saved to: /Users/l-monninger/dev/movement/protocol-units/settlement/mcr/contracts/broadcast/MovementDeployer.s.sol/17000/run-latest.json

Sensitive values saved to: /Users/l-monninger/dev/movement/protocol-units/settlement/mcr/contracts/cache/MovementDeployer.s.sol/17000/run-latest.json

l-monninger@Liams-MBP contracts % forge script -f https://ethereum-holesky-rpc.publicnode.com ./script/MovementDeployer.s.sol --legacy --broadcast
[⠊] Compiling...
[⠘] Compiling 79 files with 0.8.26
[⠒] Solc 0.8.26 finished in 3.88s
Compiler run successful with warnings:
Warning (2519): This declaration shadows an existing declaration.
   --> script/MovementDeployer.s.sol:119:56:
    |
119 |     function _storeAdminDeployment() internal returns (address admin) {
    |                                                        ^^^^^^^^^^^^^
Note: The shadowed declaration is here:
  --> script/MovementDeployer.s.sol:23:5:
   |
23 |     ProxyAdmin public admin;
   |     ^^^^^^^^^^^^^^^^^^^^^^^

Warning (2072): Unused local variable.
   --> script/MovementDeployer.s.sol:106:9:
    |
106 |         string memory a = json.serialize("move", deployment.move);
    |         ^^^^^^^^^^^^^^^

Warning (2072): Unused local variable.
   --> script/MovementDeployer.s.sol:107:9:
    |
107 |         string memory b = json.serialize("moveAdmin", deployment.moveAdmin);
    |         ^^^^^^^^^^^^^^^

Warning (2072): Unused local variable.
   --> script/MovementDeployer.s.sol:108:9:
    |
108 |         string memory c = json.serialize("staking", deployment.staking);
    |         ^^^^^^^^^^^^^^^

Warning (2072): Unused local variable.
   --> script/MovementDeployer.s.sol:109:9:
    |
109 |         string memory d = json.serialize("stakingAdmin", deployment.stakingAdmin);
    |         ^^^^^^^^^^^^^^^

Warning (2072): Unused local variable.
   --> script/MovementDeployer.s.sol:110:9:
    |
110 |         string memory e = json.serialize("stlMove", deployment.stlMove);
    |         ^^^^^^^^^^^^^^^

Warning (2072): Unused local variable.
   --> script/MovementDeployer.s.sol:111:9:
    |
111 |         string memory f = json.serialize("stlMoveAdmin", deployment.stlMoveAdmin);
    |         ^^^^^^^^^^^^^^^

Warning (2072): Unused local variable.
   --> script/MovementDeployer.s.sol:112:9:
    |
112 |         string memory g = json.serialize("mcr", deployment.mcr);
    |         ^^^^^^^^^^^^^^^

Warning (2072): Unused local variable.
   --> script/MovementDeployer.s.sol:113:9:
    |
113 |         string memory h = json.serialize("mcrAdmin", deployment.mcrAdmin);
    |         ^^^^^^^^^^^^^^^

Warning (2072): Unused local variable.
   --> script/MovementDeployer.s.sol:114:9:
    |
114 |         string memory i = json.serialize("timelock", deployment.timelock);
    |         ^^^^^^^^^^^^^^^

Warning (2018): Function state mutability can be restricted to pure
 --> script/helpers/Helper.sol:6:5:
  |
6 |     function s2a(bytes memory str) public returns (address addr) {
  |     ^ (Relevant source part starts here and spans across multiple lines).

Script ran successfully.

== Logs ==
  MOVE: deploying
  MOVE deployment records:
  proxy 0xa58A2d3e2758790D82EeA037f631Cb3B3294f7CF
  admin 0x17403E753AF2bCA605a7124dfAA341622077eA9E
  STAKING: deploying
  STAKING deployment records:
  proxy 0x2C5a0030EE52aB399052E414a49D503F89dEB1eA
  admin 0x049BD09f3c4D635A8BA04229bB3bDD76D3447bE2
  STL: deploying
  STL deployment records:
  proxy 0x64117df2D83E0FB56eD66923BA69db04F6A1Db39
  admin 0xAeb51cb845d55D889a9e5027a631199aFc862ab0
  MCR: deploying
  MCR deployment records:
  proxy 0x27BCB551F739E63f556EbB1792a7aF6bf8b58af7
  admin 0x69938308c7A72A524bf83671e977955967A2921d

## Setting up 1 EVM.

==========================

Chain 17000

Estimated gas price: 0.633251181 gwei

Estimated total gas used for script: 17649722

Estimated amount required: 0.011176707300821682 ETH

==========================
##
Sending transactions [0 - 8].
⠲ [00:00:00] [###################################################################] 9/9 txes (0.0s)##
Waiting for receipts.
⠴ [00:00:35] [###############################################################] 9/9 receipts (0.0s)
##### holesky
✅  [Success]Hash: 0x687d0ee4cb3bc659b62a86eb6fdd3291e907f7fa75a687d739a2180105abfcc7
Contract Address: 0xce5Ce43fCa9EbABd75B2b22031323c64Afa49F03
Block: 2313674
Paid: 0.001145106844099938 ETH (1808298 gas * 0.633251181 gwei)


##### holesky
✅  [Success]Hash: 0x97b4f4cbcae0d8cdfa24087c33d5b2d71a73ff370fbf5b889709622533f0a94c
Contract Address: 0xf9d0f288eAb168CE3D22B1D4B25993D41A021c0f
Block: 2313674
Paid: 0.000948258814732545 ETH (1497445 gas * 0.633251181 gwei)


##### holesky
✅  [Success]Hash: 0x10cbbc1c726debb5b4657e3e84f80d14a0a30fefd1283d8eaf22d844d1757a44
Contract Address: 0xa58A2d3e2758790D82EeA037f631Cb3B3294f7CF
Block: 2313674
Paid: 0.000529182048663279 ETH (835659 gas * 0.633251181 gwei)


##### holesky
✅  [Success]Hash: 0x76f4048a37de8f5b9d1b2854f7a534c2e1851d774c3bb62550a6772ec991e115
Contract Address: 0x0c807c18B1b26B336045cAA2B547498D053cA5EB
Block: 2313674
Paid: 0.001529876594187348 ETH (2415908 gas * 0.633251181 gwei)


##### holesky
✅  [Success]Hash: 0xc2f193e9d58562a811c797632cd43d5357fa3e42ff44bb81b4ddfcfea5cebe12
Contract Address: 0x2C5a0030EE52aB399052E414a49D503F89dEB1eA
Block: 2313674
Paid: 0.000453637082523522 ETH (716362 gas * 0.633251181 gwei)


##### holesky
✅  [Success]Hash: 0x05cd1d8ec9130065d616bc080bb43e9b3eaa7535490abd92a2a69ccdec4a0013
Contract Address: 0xaf2F35f2A03e149f290f3ca44CBF836E249B029D
Block: 2313675
Paid: 0.001512618599751555 ETH (2388655 gas * 0.633251181 gwei)


##### holesky
✅  [Success]Hash: 0xa6e2568414a3acd2d082c934fd2ad2aca9d0c7f8100e70c07fc07b7ac03d51ea
Contract Address: 0x64117df2D83E0FB56eD66923BA69db04F6A1Db39
Block: 2313675
Paid: 0.000638908013799873 ETH (1008933 gas * 0.633251181 gwei)


##### holesky
✅  [Success]Hash: 0x0ae01df1f6bf2430b3a5c6ac823feb01a8e4a819a772c4d9efeb807087d5c179
Contract Address: 0x043c15f2DA93a851c9718B5aDFb84F3f8016D0A2
Block: 2313675
Paid: 0.001178838868009446 ETH (1861566 gas * 0.633251181 gwei)


##### holesky
✅  [Success]Hash: 0x464a947d042ae57b6e63037ca20d8ee2eead6b0afbe76d6a4a4df2e1c11e3fc6
Contract Address: 0x27BCB551F739E63f556EbB1792a7aF6bf8b58af7
Block: 2313675
Paid: 0.000661042675580547 ETH (1043887 gas * 0.633251181 gwei)



==========================

ONCHAIN EXECUTION COMPLETE & SUCCESSFUL.
Total Paid: 0.008597469541348053 ETH (13576713 gas * avg 0.633251181 gwei)

Transactions saved to: /Users/l-monninger/dev/movement/protocol-units/settlement/mcr/contracts/broadcast/MovementDeployer.s.sol/17000/run-latest.json

Sensitive values saved to: /Users/l-monninger/dev/movement/protocol-units/settlement/mcr/contracts/cache/MovementDeployer.s.sol/17000/run-latest.json

@l-monninger
Copy link
Collaborator

For one shot, this appears to be correct, but we need some basic e2e checks.

@Primata Primata changed the title Contract Pipeline Contract Pipeline Scripts Sep 11, 2024
@l-monninger
Copy link
Collaborator

@0xPrimata what are the objectives for this PR? As we've discussed elsewhere, it's not supposed to be the complete pipeline nor even the final scripts. How do we want to determine success?

@Primata
Copy link
Contributor Author

Primata commented Sep 12, 2024

@0xPrimata what are the objectives for this PR? As we've discussed elsewhere, it's not supposed to be the complete pipeline nor even the final scripts. How do we want to determine success?

I think that this is final once instead of scheduling a transaction, I call the safe API by proposing a transaction: https://docs.safe.global/sdk/api-kit#propose-a-transaction-to-the-service

Believe this is also blocked by the MOVEToken merge.

@l-monninger
Copy link
Collaborator

I think that this is final once instead of scheduling a transaction, I call the safe API by proposing a transaction: https://docs.safe.global/sdk/api-kit#propose-a-transaction-to-the-service

Yeah, so usage of Safe is underspecified. This pipeline work should last into next week at least. For the MOVEToken deployment--which is on a tighter timeline--I would go with whatever you're most comfortable with.

@Primata Primata force-pushed the primata/contract-pipeline branch from 9f6a054 to 8f52a3d Compare September 16, 2024 19:01
console.log("STAKING: deploying");
MovementStaking stakingImplementation = new MovementStaking();
vm.recordLogs();
stakingProxy = new TransparentUpgradeableProxy(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not UUPS?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

UUPS is not as commonly implemented, especially for tokens. Since all of them should follow a similar workflow and there is one danger to UUPS:
image

@@ -0,0 +1,43 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

Copy link
Contributor

Choose a reason for hiding this comment

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

You got a link to what this was based on?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Primata Primata requested a review from l-monninger October 15, 2024 22:20
@0xmovses 0xmovses self-requested a review October 15, 2024 22:20
Copy link
Contributor

@0xmovses 0xmovses left a comment

Choose a reason for hiding this comment

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

🚢

@Primata Primata merged commit 7aa85be into main Oct 16, 2024
86 checks passed
@andygolay
Copy link
Contributor

andygolay commented Oct 17, 2024

Head up @0xPrimata @l-monninger #703 (error running local Suzuka + bridge after this was merged).

I haven't investigated beyond trying to run Suzuka + bridge locally, will look deeper into it after getting L1 --> L2 E2E tests against framework done (working against commit right before 561 was merged, because local Suzuka + bridge works for that commit).

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.

4 participants