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

Create a deploy script for protocol #406

Closed
0xcodercrane opened this issue Dec 19, 2022 · 15 comments · Fixed by #417 or #533
Closed

Create a deploy script for protocol #406

0xcodercrane opened this issue Dec 19, 2022 · 15 comments · Fixed by #417 or #533
Assignees
Labels
DevOps Related to CI, CD, or build related scripts.

Comments

@0xcodercrane
Copy link
Contributor

0xcodercrane commented Dec 19, 2022

Problems

We have deploy scripts written in typescript + forge create but its just for individual smart contract. It is needed for us to have a script which will deploy everything to a target network in one command and configure everything needed.

Protocol deployment script can be like the followings
yarn workspace @ubiquity/contracts run deploy:development
yarn workspace @ubiquity/contracts run deploy:staging
yarn workspace @ubiquity/contracts run deploy:production

Once the deploy script runs successfully, UI should be connected to the deployed addresses automatically and working properly.

NOTE: In case we deploy contracts to a local chain, we need to also deploy faucet contracts as well

@0x4007
Copy link
Member

0x4007 commented Dec 19, 2022

Perhaps it make sense to make a modular deployment architecture, where we have master controllers (developmentDeploymentController, stagingDeploymentController, productionDeploymentController) and then we build individual deploy scripts per smart contract that can handle each (development, staging, production) environment? I think this will allow us to separate configs but recycle the redundant deployment logic.

I think in the near future we should only focus on development to unblock the bounty hunters.

@0x4007
Copy link
Member

0x4007 commented Dec 19, 2022

You should also leave a time label on this so we can set a starting price.

@0x4007 0x4007 added Profit: <50% DevOps Related to CI, CD, or build related scripts. labels Dec 20, 2022
@0xcodercrane 0xcodercrane self-assigned this Dec 21, 2022
@0xcodercrane 0xcodercrane linked a pull request Dec 22, 2022 that will close this issue
@hashedMae
Copy link
Contributor

hashedMae commented Jan 2, 2023

For the Staking Contact in the development environment, what should be used for the migrating accounts when deploying?

@0x4007
Copy link
Member

0x4007 commented Jan 2, 2023

For the Staking Contact in the devlopment environment, what should be used for the migrating accounts when deploying?

I believe we have hard coded parameters in the old deploy scripts c @zgorizzo69 please advise

@hashedMae
Copy link
Contributor

I could use those, no issue.

@hashedMae
Copy link
Contributor

ERC20 Address 0x7fe65D99a0998Cdba8e1f749303a467dcf87e815

@0xcodercrane 0xcodercrane linked a pull request Feb 1, 2023 that will close this issue
@0x4007
Copy link
Member

0x4007 commented Feb 1, 2023

ERC20 Address 0x7fe65D99a0998Cdba8e1f749303a467dcf87e815

Before sending this I would love to verify that things are working as expected. Can you guide me to set up a local deployment with the updated contracts so that I can continue refactoring the UI with the new contract/method names?

Ideally you can post instructions here or we could collaborate over private messages if that's more convenient for you. Thanks Mae!

@hashedMae

@hashedMae
Copy link
Contributor

There's default values in the .env.example you can use for the .env. Providing your own RPC_URL is most effective but the script will use one from the random list if left empty. In a terminal, run yarn workspace @ubiquity/contracts anvil to start the local chain. If RPC_URL is left empty it may fail, run the command again to use a different RPC from the list. Once Anvil is running open a new terminal and run yarn workspace @ubiquity/contracts deploy:development. If successful it'll display the addresses to which the contracts have been deployed. It'll create a JSON with the contract addresses at packages/contracts/deployments/{ScriptContract}/{ChainID}/run-latest.json.

@0x4007
Copy link
Member

0x4007 commented Feb 2, 2023

Init f64dc4c

Currently trying to figure out how to top up the deployer wallet with Ether using cast on the anvil fork. It does not have any ether so I can't simulate the deployment.


Update #537

Made some changes to use the keys that are automatically topped up when you start Anvil. I have a new problem that I don't know how to debug:

Traces:
  [39718534] → new DevelopmentDeploy@0x5b73C5498c1E3b4dbA84de0F1833c4a029d90519
    ├─ [0] VM::envAddress(PUBLIC_KEY)
    │   └─ ← <env var value>
    ├─ [0] VM::envUint(PRIVATE_KEY)
    │   └─ ← <env var value>
    └─ ← 185079 bytes of code

  [2700738] DevelopmentDeploy::run()
    ├─ [0] VM::startBroadcast(<pk>)
    │   └─ ← ()
    ├─ [2556208] → new UbiquityDollarManager@0xD12a2EA2244c1c9Eb82ec17cBAc85f740BCb9a3a
    │   ├─ emit RoleGranted(role: 0x0000000000000000000000000000000000000000000000000000000000000000, account: 0x983b5360791547C80183Fb2c4Ec5E286AbD3767D, sender: 0x983b5360791547C80183Fb2c4Ec5E286AbD3767D)
    │   ├─ emit RoleGranted(role: 0xb82d33f41b1a8468b0a3355568595a8da603c64dc1244f7eb97e3e56cfccbe18, account: 0x983b5360791547C80183Fb2c4Ec5E286AbD3767D, sender: 0x983b5360791547C80183Fb2c4Ec5E286AbD3767D)
    │   ├─ emit RoleGranted(role: 0x65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a, account: 0x983b5360791547C80183Fb2c4Ec5E286AbD3767D, sender: 0x983b5360791547C80183Fb2c4Ec5E286AbD3767D)
    │   ├─ emit RoleGranted(role: 0x25ff7e1779512d1a833158ec96d239645270c9fdbedc91aad895443d07d0260b, account: 0x983b5360791547C80183Fb2c4Ec5E286AbD3767D, sender: 0x983b5360791547C80183Fb2c4Ec5E286AbD3767D)
    │   ├─ emit RoleGranted(role: 0xa6b5d83d32632203555cb9b2c2f68a8d94da48cadd9266ac0d17babedb52ea5b, account: 0x983b5360791547C80183Fb2c4Ec5E286AbD3767D, sender: 0x983b5360791547C80183Fb2c4Ec5E286AbD3767D)
    │   ├─ emit RoleGranted(role: 0xaf1a415cb2281de448f1771a3c8144f554e6e38bb3bc1acc8218c01a5d75721d, account: 0x983b5360791547C80183Fb2c4Ec5E286AbD3767D, sender: 0x983b5360791547C80183Fb2c4Ec5E286AbD3767D)
    │   ├─ emit RoleGranted(role: 0x921f663981c1beb7a484a4210df2eefbe89bb6e3752c925fca7a933a759dbecb, account: UbiquityDollarManager: [0xD12a2EA2244c1c9Eb82ec17cBAc85f740BCb9a3a], sender: 0x983b5360791547C80183Fb2c4Ec5E286AbD3767D)
    │   └─ ← 11907 bytes of code
    ├─ [22686] UbiquityDollarManager::setTreasuryAddress(0x983b5360791547C80183Fb2c4Ec5E286AbD3767D)
    │   └─ ← ()
    ├─ [275] UbiquityDollarManager::GOVERNANCE_TOKEN_MANAGER_ROLE() [staticcall]
    │   └─ ← 0x921f663981c1beb7a484a4210df2eefbe89bb6e3752c925fca7a933a759dbecb
    ├─ [27434] UbiquityDollarManager::grantRole(0x921f663981c1beb7a484a4210df2eefbe89bb6e3752c925fca7a933a759dbecb, 0x983b5360791547C80183Fb2c4Ec5E286AbD3767D)
    │   ├─ emit RoleGranted(role: 0x921f663981c1beb7a484a4210df2eefbe89bb6e3752c925fca7a933a759dbecb, account: 0x983b5360791547C80183Fb2c4Ec5E286AbD3767D, sender: 0x983b5360791547C80183Fb2c4Ec5E286AbD3767D)
    │   └─ ← ()
    ├─ [2508] 0x6c3F90f043a72FA612cbac8115EE7e52BDe6E490::transfer(UbiquityDollarManager: [0xD12a2EA2244c1c9Eb82ec17cBAc85f740BCb9a3a], 10000000000000000000000)
    │   └─ ← "EvmError: Revert"
    └─ ← "EvmError: Revert"


Error:
Script failed.

@0x4007 0x4007 mentioned this issue Feb 2, 2023
@hashedMae
Copy link
Contributor

Init f64dc4c

Currently trying to figure out how to top up the deployer wallet with Ether using cast on the anvil fork. It does not have any ether so I can't simulate the deployment.

The MNEMONIC in .env is so Anvil tops it up with Ether when it starts up.

Update #537

Made some changes to use the keys that are automatically topped up when you start Anvil. I have a new problem that I don't know how to debug:

Traces:
  [39718534] → new DevelopmentDeploy@0x5b73C5498c1E3b4dbA84de0F1833c4a029d90519
    ├─ [0] VM::envAddress(PUBLIC_KEY)
    │   └─ ← <env var value>
    ├─ [0] VM::envUint(PRIVATE_KEY)
    │   └─ ← <env var value>
    └─ ← 185079 bytes of code

  [2700738] DevelopmentDeploy::run()
    ├─ [0] VM::startBroadcast(<pk>)
    │   └─ ← ()
    ├─ [2556208] → new UbiquityDollarManager@0xD12a2EA2244c1c9Eb82ec17cBAc85f740BCb9a3a
    │   ├─ emit RoleGranted(role: 0x0000000000000000000000000000000000000000000000000000000000000000, account: 0x983b5360791547C80183Fb2c4Ec5E286AbD3767D, sender: 0x983b5360791547C80183Fb2c4Ec5E286AbD3767D)
    │   ├─ emit RoleGranted(role: 0xb82d33f41b1a8468b0a3355568595a8da603c64dc1244f7eb97e3e56cfccbe18, account: 0x983b5360791547C80183Fb2c4Ec5E286AbD3767D, sender: 0x983b5360791547C80183Fb2c4Ec5E286AbD3767D)
    │   ├─ emit RoleGranted(role: 0x65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a, account: 0x983b5360791547C80183Fb2c4Ec5E286AbD3767D, sender: 0x983b5360791547C80183Fb2c4Ec5E286AbD3767D)
    │   ├─ emit RoleGranted(role: 0x25ff7e1779512d1a833158ec96d239645270c9fdbedc91aad895443d07d0260b, account: 0x983b5360791547C80183Fb2c4Ec5E286AbD3767D, sender: 0x983b5360791547C80183Fb2c4Ec5E286AbD3767D)
    │   ├─ emit RoleGranted(role: 0xa6b5d83d32632203555cb9b2c2f68a8d94da48cadd9266ac0d17babedb52ea5b, account: 0x983b5360791547C80183Fb2c4Ec5E286AbD3767D, sender: 0x983b5360791547C80183Fb2c4Ec5E286AbD3767D)
    │   ├─ emit RoleGranted(role: 0xaf1a415cb2281de448f1771a3c8144f554e6e38bb3bc1acc8218c01a5d75721d, account: 0x983b5360791547C80183Fb2c4Ec5E286AbD3767D, sender: 0x983b5360791547C80183Fb2c4Ec5E286AbD3767D)
    │   ├─ emit RoleGranted(role: 0x921f663981c1beb7a484a4210df2eefbe89bb6e3752c925fca7a933a759dbecb, account: UbiquityDollarManager: [0xD12a2EA2244c1c9Eb82ec17cBAc85f740BCb9a3a], sender: 0x983b5360791547C80183Fb2c4Ec5E286AbD3767D)
    │   └─ ← 11907 bytes of code
    ├─ [22686] UbiquityDollarManager::setTreasuryAddress(0x983b5360791547C80183Fb2c4Ec5E286AbD3767D)
    │   └─ ← ()
    ├─ [275] UbiquityDollarManager::GOVERNANCE_TOKEN_MANAGER_ROLE() [staticcall]
    │   └─ ← 0x921f663981c1beb7a484a4210df2eefbe89bb6e3752c925fca7a933a759dbecb
    ├─ [27434] UbiquityDollarManager::grantRole(0x921f663981c1beb7a484a4210df2eefbe89bb6e3752c925fca7a933a759dbecb, 0x983b5360791547C80183Fb2c4Ec5E286AbD3767D)
    │   ├─ emit RoleGranted(role: 0x921f663981c1beb7a484a4210df2eefbe89bb6e3752c925fca7a933a759dbecb, account: 0x983b5360791547C80183Fb2c4Ec5E286AbD3767D, sender: 0x983b5360791547C80183Fb2c4Ec5E286AbD3767D)
    │   └─ ← ()
    ├─ [2508] 0x6c3F90f043a72FA612cbac8115EE7e52BDe6E490::transfer(UbiquityDollarManager: [0xD12a2EA2244c1c9Eb82ec17cBAc85f740BCb9a3a], 10000000000000000000000)
    │   └─ ← "EvmError: Revert"
    └─ ← "EvmError: Revert"


Error:
Script failed.

This is the 3CRV token transfer failing. Did you set the PRIVATE_KEY and ADMIN_ADDRESS in .env?

@0x4007
Copy link
Member

0x4007 commented Feb 2, 2023

In my PR I renamed ADMIN_ADDRESS to PUBLIC_KEY and yes I have both set. Technically its set in my .bashrc but I can access with an echo. I'll manually set some values in the .env but it shouldn't make a difference.

@0x4007
Copy link
Member

0x4007 commented Feb 2, 2023

No dice.

@0x4007
Copy link
Member

0x4007 commented Feb 3, 2023

@rndquu can you run this successfully?

@0x4007
Copy link
Member

0x4007 commented Feb 9, 2023

ERC20 Address 0x7fe65D99a0998Cdba8e1f749303a467dcf87e815

https://etherscan.io/tx/0x1ab7a04ed7fea4f06d5e9003762c9fd44988bb425b161af9b5fe7d4ce476b5df


Thanks for walking me through this on my PR #554. I copied your .env file and just a couple of clarifications please:

Is there any special significance for the values you had filled in for the following?

  • PRIVATE_KEY
  • PUBLIC_KEY
  • MNEMONIC

@hashedMae
Copy link
Contributor

MNEMONIC is used to fund the account(s) that will be used on Anvil. PUBLIC_KEY is used when manipulating token balances to create the curve pool. PRIVATE_KEY is required to broadcast to Anvil and launch the contracts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DevOps Related to CI, CD, or build related scripts.
Projects
None yet
3 participants