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

build: add mainnet, testnet, dev migrations #842

Merged
merged 17 commits into from
Dec 4, 2023

Conversation

rndquu
Copy link
Member

@rndquu rndquu commented Nov 22, 2023

Resolves #827

This PR adds and modifies 2 commands:

  1. yarn deploy:mainnet: deploys the Diamond and Dollar contracts to ethereum mainet
  2. yarn deploy:development: deploys Diamond, Dollar, UbiquityAlgorithmicDollarManager and UbiquityGovernance contracts to local anvil instance or testnet (depending on the RPC_URL env variable)

There is no any difference between migrations to a local anvil instance and testnet so there is no separate command for testnet (i.e. there is no yarn deploy:testnet).

The only difference between yarn deploy:mainnet and yarn deploy:development is that yarn deploy:mainnet uses already deployed UbiquityAlgorithmicDollarManager and UbiquityGovernance contracts while yarn deploy:development deploys them from scratch.

The deploy diamond migration deploys not all of the facets because chances are that we're not gonna need them + it's better to deploy exactly what we're gonna use without unnecessary "dead" contracts.

Other remarks:

P.S. "Audit & Fix" workflow is failing but it is not related to the current PR, already fixed here

Copy link

ubiquibot bot commented Nov 22, 2023

@gitcoindev
Copy link
Contributor

Hi @rndquu is this still a draft or review can start?

@rndquu
Copy link
Member Author

rndquu commented Nov 22, 2023

Hi @rndquu is this still a draft or review can start?

Hey, the PR is draft

@rndquu rndquu marked this pull request as ready for review November 24, 2023 10:54
@gitcoindev
Copy link
Contributor

Hi @rndquu I started the review, checked out clean pull request, built from scratch and executed deployment on Anvil testnet.

Step 1 cp .env.example to .env, install & build

$ yarn install
$ yarn workspace @ubiquity/contracts build
  1. Started Anvil on development branch - deployment fails (correct behavior)
  2. Started Anvil on pr branch - deployment successful (correct behavior)

I used the command from readme

$ yarn workspace @ubiquity/contracts deploy:development

Therefore, the 'smoke test' passed.

I noticed that the deployment folders in broadcast folder is reported as untracked, you may want to add it to .gitignore

{feat/827} ~/work/pullrequest/ubiquity-dollar$ git status
On branch feat/827
Untracked files:
  (use "git add <file>..." to include in what will be committed)
        packages/contracts/broadcast/Deploy001_Diamond_Dollar.s.sol/
        packages/contracts/broadcast/Deploy002_Governance.s.sol/

with my current content:

packages/contracts/broadcast/
├── 05_StakingShare.s.sol
│   └── 31337
│       └── run-latest.json
├── Deploy001_Diamond_Dollar.s.sol
│   └── 31337
│       ├── run-1700834661.json
│       ├── run-1700835041.json
│       └── run-latest.json
└── Deploy002_Governance.s.sol
    └── 31337
        ├── run-1700834669.json
        ├── run-1700835046.json
        └── run-latest.json

I will now go through the commits and changes.

@gitcoindev
Copy link
Contributor

The deploy diamond migration deploys not all of the facets because chances are that we're not gonna need them + it's better to deploy exactly what we're gonna use without unnecessary "dead" contracts.

I agree. Would still be useful to see the full list of skipped facets in a commit message, stating why the given facet may not be needed. Perhaps also such information would help auditors.

Copy link
Contributor

@gitcoindev gitcoindev left a comment

Choose a reason for hiding this comment

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

I went through all changes and in general I have minor findings. After those will be addressed / answered I will approve from my side.

@rndquu
Copy link
Member Author

rndquu commented Nov 27, 2023

@gitcoindev

I noticed that the deployment folders in broadcast folder is reported as untracked, you may want to add it to .gitignore

From my point of view .gitignore is set fine:

  • we save latest transactions from a local anvil instance (because we need them in the frontend)
  • we save all mainnet and testnet transactions (in order to see a full migration history and relevant contract addresses)

@gitcoindev
Copy link
Contributor

@gitcoindev

I noticed that the deployment folders in broadcast folder is reported as untracked, you may want to add it to .gitignore

From my point of view .gitignore is set fine:

  • we save latest transactions from a local anvil instance (because we need them in the frontend)
  • we save all mainnet and testnet transactions (in order to see a full migration history and relevant contract addresses)

all right, makes sense

@molecula451
Copy link
Member

I'm performing last testing before pass @rndquu

@molecula451
Copy link
Member

I'm deploying to actual testnet (not forked) while it does deploy the contracts after another run, it fails on the first run:

Screenshot from 2023-12-02 02-01-03

but then the script re-run compilation:
Screenshot from 2023-12-02 02-07-34

but then deploys:
Screenshot from 2023-12-02 02-05-18

https://sepolia.etherscan.io/tx/0x603a56a6aa1ff3b59f80516e264f8431ab79a4aae9df3a69d2ac7cbbc4511637
https://sepolia.etherscan.io/tx/0xaaab85aa032374313bdb099b6f4314b675b43813aee0279a6ec3a42353489ea7

I have matched bytecode and the above can be find at run-latest.json

It's the script failing expected?? @rndquu

more debug needed it?

@rndquu
Copy link
Member Author

rndquu commented Dec 2, 2023

@molecula451

I'm deploying to actual testnet (not forked) while it does deploy the contracts after another run, it fails on the first run

Did you check the failing tx on etherscan? There must be some clue of why it failed

@molecula451
Copy link
Member

molecula451 commented Dec 2, 2023

Did you check the failing tx on etherscan? There must be some clue of why it failed

please check the screenshots, the revert it's when the script it's running, not when the contracts are getting deployed, so no etherscan, but yeah, would need to debug, also this happen continuously, when you run the script

@rndquu
Copy link
Member Author

rndquu commented Dec 2, 2023

Did you check the failing tx on etherscan? There must be some clue of why it failed

please check the screenshots, the revert it's when the script it's running, not when the contracts are deployed, so no etherscan, but yeah, need to debug

There is failing tx on addCollateralToken() in the screenshot so the tx must be on sepolia's etherscan, tx hash can be found in your local broadcast logs

@molecula451
Copy link
Member

molecula451 commented Dec 2, 2023

There is failing tx on addCollateralToken() in the screenshot so the tx must be on sepolia's etherscan, tx hash can be found in your local broadcast logs

that revert it's not getting shipped, it's locally happening but not getting shipped you can check the account

https://sepolia.etherscan.io/address/0x940c5d8a6ac44ba0583162d32b05c079950b1ef3

the 2 transactions are the after the second re-run, it fails on the first run, then the script goes on, and deploys

@rndquu
Copy link
Member Author

rndquu commented Dec 2, 2023

@molecula451 Do both owner and admin accounts have enough ether?

@molecula451
Copy link
Member

molecula451 commented Dec 2, 2023

@molecula451 Do both owner and admin accounts have enough ether?

yes, more than enough I'd say, 5 sepoliaETH, and it only cost less than them those 2 deployments

@molecula451
Copy link
Member

molecula451 commented Dec 2, 2023

can you reproduce it? @rndquu, indeed doesn't seem to happen on anvil fork

@molecula451
Copy link
Member

@rndquu
Copy link
Member Author

rndquu commented Dec 2, 2023

can you reproduce it? @rndquu, indeed doesn't seem to happen on anvil fork

yes, that's because LUSD is not actually deployed on sepolia testnet, I'll fix the error, thank you

@rndquu rndquu marked this pull request as draft December 2, 2023 12:21
@rndquu rndquu marked this pull request as ready for review December 2, 2023 14:00
@rndquu
Copy link
Member Author

rndquu commented Dec 2, 2023

@molecula451 @gitcoindev

Notice that I moved the collateral token address to .env file.

LUSD token (used as collateral in UbiquityPoolFacet) is not deployed to sepolia testnet so for testnet we should use some other token. I've checked the migration to testnet with DAI as collateral token and the migration executed fine.

@molecula451
Copy link
Member

so the bug was LUSD was not deployed

@rndquu
Copy link
Member Author

rndquu commented Dec 2, 2023

so the bug was LUSD was not deployed

yes

@molecula451
Copy link
Member

Hi @rndquu I started the review, checked out clean pull request, built from scratch and executed deployment on Anvil testnet.

$ yarn install
$ yarn workspace @ubiquity/contracts build


1. Started Anvil on development branch - deployment fails (correct behavior)
2. Started Anvil on pr branch - deployment successful (correct behavior)

I used the command from readme

$ yarn workspace @ubiquity/contracts deploy:development


Therefore, the 'smoke test' passed.

for your info you do not have to run all these commands, that's why we are updating the readme #843
@gitcoindev

check yarn deploy:development just do

yarn.mp4

@molecula451
Copy link
Member

aaaaaaaaaaaaaaaaaaaaaaaaaand!! @rndquu
Screenshot from 2023-12-02 11-13-31

Successfully set Dollar

@molecula451 molecula451 dismissed gitcoindev’s stale review December 2, 2023 16:00

rndqnuu just updated the contracts

@molecula451
Copy link
Member

molecula451 commented Dec 2, 2023

⚠️ This list is bound to change at this PR it's still getting testing ⚠️ ⚠️

This PR:

  • Successfully grant expected roles according to the scripts, it grants a manager role to msg.sender set at .env
  • Set Dollar Token at initial run
  • Deploys 9 facets including Diamond
  • The deployment match addresses on run-latest.json an any compatible EVM explorer (etherscan for e.g)
  • The deployment match diamond bytecode
  • Diamond facet returns correct set dollar token deployed at run
    Screenshot from 2023-12-02 15-43-10
    can be seen at https://sepolia.etherscan.io/address/0x6b16e6b2bb75d63a90a8557cc11b3832c0642629

Copy link
Member

@molecula451 molecula451 left a comment

Choose a reason for hiding this comment

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

Basically all the debug happened on this PR. This PR is more than ready to be merge

@molecula451
Copy link
Member

I'm merging this one. Please leave your Review @gitcoindev

Copy link
Contributor

@gitcoindev gitcoindev left a comment

Choose a reason for hiding this comment

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

All right! I went through all the changes and comments again and approving. Good job @rndquu . We will also test this pr in future development.

@gitcoindev gitcoindev merged commit bc36823 into ubiquity:development Dec 4, 2023
37 checks passed
@rndquu rndquu deleted the feat/827 branch December 4, 2023 07:21
@molecula451
Copy link
Member

molecula451 commented Dec 4, 2023

what a great PR and great review and feedback happened here, congrats everyone, here this appealing, and is demanding excellent

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.

Create testnet and mainnet deploy scripts
3 participants