Skip to content

Commit

Permalink
fix(pg): Improve reliability of internal hardhat simulation in monorepos
Browse files Browse the repository at this point in the history
  • Loading branch information
RPate97 committed May 10, 2024
1 parent bb95c6b commit 2cdad04
Show file tree
Hide file tree
Showing 28 changed files with 2,522 additions and 1,052 deletions.
6 changes: 6 additions & 0 deletions .changeset/nasty-bags-wonder.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@sphinx-labs/plugins': patch
'@sphinx-labs/core': patch
---

Improve reliability of internal hardhat simulation in monorepos
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
command: sh ./scripts/create-placeholder.sh
- run:
name: Install dependencies
command: yarn --frozen-lockfile --link-duplicates --network-concurrency 1
command: yarn --frozen-lockfile --network-concurrency 1
- save_cache:
key: v2-cache-yarn-install-{{ checksum "yarn.lock" }}
paths:
Expand Down
3 changes: 2 additions & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@
"semver": "^7.3.8",
"solidity-ast": "^0.4.45",
"undici": "^5.21.1",
"yesno": "^0.4.0"
"yesno": "^0.4.0",
"debug": "^4.3.4"
},
"devDependencies": {
"@types/sinon": "^17.0.2",
Expand Down
10 changes: 4 additions & 6 deletions packages/core/src/actions/execute.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Logger } from '@eth-optimism/common-ts'
import { HardhatEthersProvider } from '@nomicfoundation/hardhat-ethers/internal/hardhat-ethers-provider'
import {
SphinxLeafWithProof,
ManagedServiceABI,
Expand All @@ -26,7 +25,7 @@ import {
MerkleRootStatus,
} from './types'
import { ExecutionMode } from '../constants'
import { SphinxJsonRpcProvider } from '../provider'
import { InProcessEthersProvider, SphinxJsonRpcProvider } from '../provider'
import {
addSphinxWalletsToGnosisSafeOwners,
findLeafWithProof,
Expand Down Expand Up @@ -254,7 +253,7 @@ export type DeploymentContext = {
*
* Allows us to generate and supply the rpc provider in whatever way we would like.
*/
provider: SphinxJsonRpcProvider | HardhatEthersProvider
provider: SphinxJsonRpcProvider | InProcessEthersProvider

/**
* An optional wallet.
Expand Down Expand Up @@ -1169,7 +1168,7 @@ export const fetchExecutionTransactionReceipts = async (
receipts: ethers.TransactionReceipt[],
moduleAddress: string,
merkleRoot: string,
provider: SphinxJsonRpcProvider | HardhatEthersProvider
provider: SphinxJsonRpcProvider | InProcessEthersProvider
) => {
const module = new ethers.Contract(moduleAddress, SphinxModuleABI, provider)

Expand Down Expand Up @@ -1308,7 +1307,6 @@ export const attemptDeployment = async (
const signatures: string[] = signers
.map((signer) => signer.signature)
.filter((signature) => signature !== null) as any

;({ receipts, batches, finalStatus, failureAction } =
await executeDeployment(
targetNetworkNetworkConfig,
Expand All @@ -1325,6 +1323,7 @@ export const attemptDeployment = async (
targetNetworkNetworkConfig,
failureAction
)

return {
receipts: deploymentTransactionReceipts.map(
convertEthersTransactionReceipt
Expand All @@ -1338,7 +1337,6 @@ export const attemptDeployment = async (
await deploymentContext.handleError(e, deployment)
return
}

await deploymentContext.handleSuccess(
deploymentContext,
targetNetworkNetworkConfig
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ export * from './provider'
export * from './artifacts'
export * from './types'
export * from './errors'
export * from './provider'
17 changes: 8 additions & 9 deletions packages/core/src/languages/solidity/predeploys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
getOwnerAddress,
getSphinxConstants,
} from '@sphinx-labs/contracts'
import { HardhatEthersProvider } from '@nomicfoundation/hardhat-ethers/internal/hardhat-ethers-provider'
import ora from 'ora'

import {
Expand All @@ -22,7 +21,7 @@ import {
getImpersonatedSigner,
fundAccountMaxBalance,
} from '../../utils'
import { SphinxJsonRpcProvider } from '../../provider'
import { InProcessEthersProvider, SphinxJsonRpcProvider } from '../../provider'
import { ExecutionMode, RELAYER_ROLE } from '../../constants'
import {
fetchDripSizeForNetwork,
Expand All @@ -31,7 +30,7 @@ import {
} from '../../networks'

export const ensureSphinxAndGnosisSafeDeployed = async (
provider: SphinxJsonRpcProvider | HardhatEthersProvider,
provider: SphinxJsonRpcProvider | InProcessEthersProvider,
wallet: ethers.Wallet,
executionMode: ExecutionMode,
includeManagedServiceRoles: boolean,
Expand All @@ -58,7 +57,7 @@ export const ensureSphinxAndGnosisSafeDeployed = async (

export const cancelPreviousDripVersions = async (
Drippie: Contract,
provider: SphinxJsonRpcProvider | HardhatEthersProvider,
provider: SphinxJsonRpcProvider | InProcessEthersProvider,
wallet: ethers.Signer,
executionMode: ExecutionMode,
dripName: string,
Expand Down Expand Up @@ -103,7 +102,7 @@ export const cancelPreviousDripVersions = async (
}

export const checkSystemDeployed = async (
provider: SphinxJsonRpcProvider | HardhatEthersProvider
provider: SphinxJsonRpcProvider | InProcessEthersProvider
): Promise<boolean> => {
const contracts = getSphinxConstants()

Expand All @@ -120,7 +119,7 @@ export const checkSystemDeployed = async (
}

export const assignManagedServiceRoles = async (
provider: SphinxJsonRpcProvider | HardhatEthersProvider,
provider: SphinxJsonRpcProvider | InProcessEthersProvider,
signer: ethers.Signer,
relayers: string[],
executionMode: ExecutionMode,
Expand Down Expand Up @@ -268,7 +267,7 @@ export const assignManagedServiceRoles = async (
}

export const deploySphinxSystem = async (
provider: SphinxJsonRpcProvider | HardhatEthersProvider,
provider: SphinxJsonRpcProvider | InProcessEthersProvider,
signer: ethers.Signer,
relayers: string[],
executionMode: ExecutionMode,
Expand Down Expand Up @@ -319,7 +318,7 @@ export const deploySphinxSystem = async (
}

export const getDeterministicFactoryAddress = async (
provider: SphinxJsonRpcProvider | HardhatEthersProvider
provider: SphinxJsonRpcProvider | InProcessEthersProvider
) => {
// Deploy the deterministic deployer.
if (
Expand Down Expand Up @@ -367,7 +366,7 @@ export const getDeterministicFactoryAddress = async (
}

export const doDeterministicDeploy = async (
provider: SphinxJsonRpcProvider | HardhatEthersProvider,
provider: SphinxJsonRpcProvider | InProcessEthersProvider,
executionMode: ExecutionMode,
options: {
contract: {
Expand Down
Loading

0 comments on commit 2cdad04

Please sign in to comment.