-
Notifications
You must be signed in to change notification settings - Fork 0
Deployed all contracts and verified to Mainnet #371
Conversation
There was a problem hiding this comment.
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.
hardhat.config.ts
Outdated
gasPrice: 120*10**9, | ||
gas: 15*10**6, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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)
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}); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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 🤔
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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
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}); |
There was a problem hiding this comment.
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)
02146d5
to
7537491
Compare
Explanation of the solution
Instructions on making this work
yarn
oryarn install
to install npm dependencies