Skip to content
This repository has been archived by the owner on Oct 6, 2023. It is now read-only.

Deployed all contracts and verified to Mainnet #371

Merged
merged 3 commits into from
Sep 8, 2023

Conversation

stevieraykatz
Copy link
Contributor

Explanation of the solution

Instructions on making this work

  • run yarn or yarn install to install npm dependencies

@linear
Copy link

linear bot commented Sep 8, 2023

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@misicnenad I added this dumb delay to avoid some odd race conditions I was hitting on mainnet.

My leading theory is that Alchemy doesn't know about the new published block at the time that we submit the transcation to link the proxy to the implementation. This causes the proxy deployment to fail because the "target address isn't a contract". I was also sporadically running into other odd errors that weren't repeatable further hinting at race conditions.

This delay fixed all of the inconsistencies but I also know that it's not the cleanest solution. Open to any and all permanent suggestions.

Comment on lines 52 to 53
gasPrice: 120*10**9,
gas: 15*10**6,
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 was necessary since gas prices were fluctuating wildly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And now I think that we may want to define them dynamically so that we can accommodate network conditions when we're about to run tasks on Mainnet

Copy link
Contributor

Choose a reason for hiding this comment

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

This won't work, see #371 (comment)

@stevieraykatz stevieraykatz self-assigned this Sep 8, 2023
Comment on lines +17 to +23
owner: SignerWithAddress | Wallet,
destination: string,
data: BytesLike
): Promise<boolean> {
logger.out(`Submitting transaction to Multisig at address: ${msAddress}...`);
const multisig = IMultiSigGeneric__factory.connect(msAddress, owner);
const tx = await multisig.submitTransaction(destination, 0, data, "0x");
const tx = await multisig.submitTransaction(destination, 0, data, "0x", {gasPrice: 120*10**9});
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 was necessary since Hardhat throws Account ... is not managed by the node you are connected to in its current form on Mainnet. However, we don't need the signer to be a SignerWithAddress to submit txs. Luckily this works! But the manual/static gas price is gross. Open to suggestions or I will clean it up tomorrow to match the hardhat network config opts.

Copy link
Contributor

Choose a reason for hiding this comment

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

Seems that Hardhat does not support setting project-wide gas configurations when running with ethers, see:
https://hardhat.org/hardhat-network/docs/reference#gas
NomicFoundation/hardhat#2406

There's an open issue to make this possible NomicFoundation/hardhat#3496

This means we need to hardcode/calculate gas values ourselves 😑 We could create a helper func that wraps this, and pass its result to all "send Tx" calls.

P.S. it maybe works with ethers-v6, but we can't use it yet, so not useful to us
NomicFoundation/hardhat#3496 (comment)

@@ -23,6 +23,7 @@ export async function deploy<T extends ContractFactory>(
try {
const contract = await factory.deploy(...(constructorArguments ?? []));
await contract.deployed();
await delay(1000)
Copy link
Contributor

Choose a reason for hiding this comment

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

What issues popped up here? 😄
Whatever they were, delaying by a certain number of blocks instead might be more helpful in avoiding the issue 🤔

Copy link
Contributor

@0xNeshi 0xNeshi Sep 8, 2023

Choose a reason for hiding this comment

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

Ah I see your explanation above now #371 (comment)

If this works then it's fine by me, but a more "lasting" solution could still be waiting a certain number of blocks, we can use:

await contract.deployTransaction.wait(2) // waits for Tx to be included in 2 blocks

Note: I see some people recommending 3 or even 5 blocks, which might be safer than 2.
Note 2: this is not an issue with ethers-v6, too bad we can't use it 😑 (I forget why we can't, but it's something related to one of our packages not supporting it yet)

Copy link
Contributor

Choose a reason for hiding this comment

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

I like that wait(n) blocks idea better than delay. 👍 It does work though!

const signer = new Wallet(pkey, hre.ethers.provider);
return hre.ethers.getSigner(signer.address);
): Promise<Wallet> {
return new Wallet(pkey, hre.ethers.provider);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is even better as it's more generic than using SignerWithAddress

@@ -13,13 +14,13 @@ import {filterEvents, logger} from "utils";
*/
export async function submitMultiSigTx(
msAddress: string,
owner: SignerWithAddress,
owner: SignerWithAddress | Wallet,
Copy link
Contributor

@0xNeshi 0xNeshi Sep 8, 2023

Choose a reason for hiding this comment

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

We can switch all SignerWithAddress uses to Signer as it's more generic in some followup PR (Signer is inherited by both SignerWithAddress and Wallet), created an issue for that https://linear.app/angel-protocol/issue/AP-781/switch-from-using-signerwithaddress-to-signer-in-all-scriptstasks

Comment on lines +17 to +23
owner: SignerWithAddress | Wallet,
destination: string,
data: BytesLike
): Promise<boolean> {
logger.out(`Submitting transaction to Multisig at address: ${msAddress}...`);
const multisig = IMultiSigGeneric__factory.connect(msAddress, owner);
const tx = await multisig.submitTransaction(destination, 0, data, "0x");
const tx = await multisig.submitTransaction(destination, 0, data, "0x", {gasPrice: 120*10**9});
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems that Hardhat does not support setting project-wide gas configurations when running with ethers, see:
https://hardhat.org/hardhat-network/docs/reference#gas
NomicFoundation/hardhat#2406

There's an open issue to make this possible NomicFoundation/hardhat#3496

This means we need to hardcode/calculate gas values ourselves 😑 We could create a helper func that wraps this, and pass its result to all "send Tx" calls.

P.S. it maybe works with ethers-v6, but we can't use it yet, so not useful to us
NomicFoundation/hardhat#3496 (comment)

@0xNeshi 0xNeshi force-pushed the AP-723-Mainnet-Deploy branch from 02146d5 to 7537491 Compare September 8, 2023 10:36
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants