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

deploy: Delta production deployment scripts #631

Merged
merged 14 commits into from
Oct 11, 2023
Merged

Conversation

victorges
Copy link
Member

@victorges victorges commented Oct 3, 2023

What does this pull request do? Explain your changes. (required)
This is to update and create deployment scripts in order to update Delta (LIP-91 and LIP-92)
to production.

Specific updates (required)

  • Fix dotenv and contract verification, as well as create a task to verify all deployed contracts
  • Update ContractDeployer to support deploy-only (no register) mode
  • Write deploy_audit.ts script to update the contracts in question and print required governance commands

How did you test each of these updates (required)

  • Run the deploy over a local and testnets
  • Run the deploy over a fork

Does this pull request close any open issues?
Implements PRO-32

Checklist:

  • README and other documentation updated
  • All tests using yarn test pass

@victorges victorges mentioned this pull request Oct 3, 2023
2 tasks
@victorges victorges requested a review from yondonfu October 3, 2023 21:21
@victorges victorges force-pushed the vg/chore/delta-deployment branch 2 times, most recently from abfdc7b to fa54845 Compare October 5, 2023 21:37
@victorges victorges force-pushed the vg/chore/delta-deployment branch 2 times, most recently from 6fe1198 to 24ce428 Compare October 5, 2023 22:33
@victorges victorges force-pushed the vg/chore/delta-deployment branch from 24ce428 to 5346634 Compare October 6, 2023 20:28
- Allows deploying proxy without registering them on controller
- Fixes the names of the deployments that are saved/overridden
 - Deploying only the target will not set the "main" deployment file
 - Deploying with a proxy will not set the ManagerProxy deployment
The Governor already exposes an execute() function that
will call the timelock (treasury) internally, so we don't
need to expose the treasury directly to calls by anyone.
@victorges victorges force-pushed the vg/chore/delta-deployment branch from 5346634 to ff30c77 Compare October 6, 2023 20:33
@victorges
Copy link
Member Author

FTR I've created a fork on Tenderly and ran the deployment script over there to ensure the expected behavior:

Will follow-up later with simulating the governance script to register contracts on controller.

deploy/migrations.config.ts Outdated Show resolved Hide resolved
deploy/deploy_contracts.ts Show resolved Hide resolved
hardhat.config.ts Show resolved Hide resolved
doc/upgrade.md Outdated Show resolved Hide resolved
utils/deployer.ts Outdated Show resolved Hide resolved
deploy/deploy_delta_upgrade.ts Show resolved Hide resolved
deploy/deploy_delta_upgrade.ts Outdated Show resolved Hide resolved
@victorges victorges requested a review from yondonfu October 10, 2023 16:32
It doesnt want registration so just call deploy()
Good to already have pre-tested scripts for the deployment steps.
@victorges
Copy link
Member Author

@yondonfu FYI added 2 more utilities here:

  • A task to renounce the admin role from the treasury post deploy/validations
  • A document explaining all the deployment steps
    • (included a deployment validation that I made for the fork, tho haven't included the raw task script here)
    • This other fork test I made is documented in this branch tho I wasn't planning on opening a PR for it: vg/chore/delta-deployment...vg/fork-test-2

LMK if you'd suggest anything, like including that "verify delta deployment" task in here as well or if its fine like this. Tomorrow I plan on merging this and running the contract deploys. Will ping you about how we should merge this into confluence branch for the deploy.

@victorges
Copy link
Member Author

victorges commented Oct 11, 2023

FTR this is the second fork I made, where I ran both the contract deploys and the governance actions: https://dashboard.tenderly.co/shared/fork/2f6f7f38-4c86-4b24-a165-2b535747ba26/transactions

Unfortunately, controlling the block number of the fork is harder than I thought, so I couldn't advance the round to test treasury contribution. What I might do next is make a fork right at the beginning of a round, so I can initialize it myself after making the deploy.

The code changes for that deploy is on this branch: vg/chore/delta-deployment...vg/fork-test-2
Where I also wrote a task to verify the delta deployment and it is currently passing.

@yondonfu
Copy link
Member

Unfortunately, controlling the block number of the fork is harder than I thought, so I couldn't advance the round to test treasury contribution.

You should be able to control the block number using the evm_increaseBlocks Tenderly RPC call when connected to the fork JSON RPC URL.

doc/deploy_delta.md Outdated Show resolved Hide resolved
doc/deploy_delta.md Outdated Show resolved Hide resolved
doc/deploy_delta.md Outdated Show resolved Hide resolved
@victorges
Copy link
Member Author

victorges commented Oct 11, 2023

@yondonfu

You should be able to control the block number using the evm_increaseBlocks Tenderly RPC call when connected to the fork JSON RPC URL.

Yeah, I did do that and expected it to work, but it just stayed on the same block. I used this task and it has no effect no matter how many blocks I increase:

import {task} from "hardhat/config"
import {ethers} from "ethers"

const BLOCK_PERIOD = 12 // seconds

task(
    "evm-increase-blocks",
    "Helper task to increase the block number in the current EVM"
)
    .addOptionalPositionalParam(
        "blocks",
        "How many blocks to increase by (defaults to 1)"
    )
    .setAction(async (taskArgs, hre) => {
        const {network} = hre

        const provider = network.provider
        const blocks = parseInt(taskArgs.blocks ?? "1")

        await provider.send("evm_increaseBlocks", [
            ethers.utils.hexValue(blocks) // hex encoded number of blocks to increase
        ])
        // helpfully increase the time by 12s per block as well
        await provider.send("evm_increaseTime", [
            ethers.utils.hexValue(BLOCK_PERIOD * blocks) // hex encoded number of seconds
        ])
    })

Maybe it is increasing the L2 block number instead of the observed L1 block number. Couldn't find any docs on increase L1 block number on an arbitrum fork instead.

@victorges
Copy link
Member Author

victorges commented Oct 11, 2023

OK I managed to deploy an AdjustableRoundsManager as the RoundsManagerTarget on the fork, and am able to manipulate the observed L1 block number now as well :)

Was then able to adjust the block to the next round after deploy, initialize that round and run some reward calls observing the 10% of the rewards going to the treasury [1] :)

All transactions inspectable on the fork here [2] and the corresponding code/deployment registry on that same branch [3]

Pending now only updating the deploy docs here and merging the PR into delta branch. Then we can start doing the real thing :)

[1] https://dashboard.tenderly.co/livepeer/livepeer/fork/2f6f7f38-4c86-4b24-a165-2b535747ba26/simulation/6b163c5d-9c29-46a4-9cbd-31a8ce446d87
[2] https://dashboard.tenderly.co/shared/fork/2f6f7f38-4c86-4b24-a165-2b535747ba26/transactions
[3] vg/chore/delta-deployment...vg/fork-test-2

@victorges victorges closed this Oct 11, 2023
@victorges
Copy link
Member Author

Unintended close 😅

@victorges victorges reopened this Oct 11, 2023
@victorges victorges force-pushed the vg/chore/delta-deployment branch from 0174938 to 3534c23 Compare October 11, 2023 18:39
@victorges victorges changed the title deploy: Delta production deployment deploy: Delta production deployment scripts Oct 11, 2023
@victorges victorges merged commit dbc25bc into delta Oct 11, 2023
2 checks passed
@victorges victorges deleted the vg/chore/delta-deployment branch October 11, 2023 18:43
@yondonfu
Copy link
Member

Maybe it is increasing the L2 block number instead of the observed L1 block number

Ah I think you're right that's probably what is happening.

victorges added a commit that referenced this pull request Oct 11, 2023
* hardhat: Fix .env files

* hardhat: Migrate to newer etherscan verify plugin

* tasks: Create task to verify all deployed contracts

* doc: Add instructions on how to deploy to a network

* deploy: Move treasury deploy to deploy_contracts

* deploy: Update deployer to support delta deployment

- Allows deploying proxy without registering them on controller
- Fixes the names of the deployments that are saved/overridden
 - Deploying only the target will not set the "main" deployment file
 - Deploying with a proxy will not set the ManagerProxy deployment

* deploy: Create delta deployment script

* deploy: Allow only governor to execute treasury proposals

The Governor already exposes an execute() function that
will call the timelock (treasury) internally, so we don't
need to expose the treasury directly to calls by anyone.

* utils: Split deployAndRegister func from ContractDeployer

* deploy,doc: Address other PR comments

* deploy: Fix deploy_poll script

It doesnt want registration so just call deploy()

* tasks: Create task to renounce admin role post-deploy

Good to already have pre-tested scripts for the deployment steps.

* doc: Add docs on delta deploy steps

* doc: Address comments on deploy steps doc
victorges added a commit that referenced this pull request Oct 11, 2023
* hardhat: Fix .env files

* hardhat: Migrate to newer etherscan verify plugin

* tasks: Create task to verify all deployed contracts

* doc: Add instructions on how to deploy to a network

* deploy: Move treasury deploy to deploy_contracts

* deploy: Update deployer to support delta deployment

- Allows deploying proxy without registering them on controller
- Fixes the names of the deployments that are saved/overridden
 - Deploying only the target will not set the "main" deployment file
 - Deploying with a proxy will not set the ManagerProxy deployment

* deploy: Create delta deployment script

* deploy: Allow only governor to execute treasury proposals

The Governor already exposes an execute() function that
will call the timelock (treasury) internally, so we don't
need to expose the treasury directly to calls by anyone.

* utils: Split deployAndRegister func from ContractDeployer

* deploy,doc: Address other PR comments

* deploy: Fix deploy_poll script

It doesnt want registration so just call deploy()

* tasks: Create task to renounce admin role post-deploy

Good to already have pre-tested scripts for the deployment steps.

* doc: Add docs on delta deploy steps

* doc: Address comments on deploy steps doc
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.

2 participants