From ed1778504e79089e4266bc5b6a98871141dd3e1e Mon Sep 17 00:00:00 2001 From: smartcontracts Date: Fri, 27 Jan 2023 01:01:18 -0500 Subject: [PATCH] fix(exec,plg): remove command line hack (#416) Removes the command line hack that was needed to fix a bug that was later fixed in upstream BaseServiceV2. Co-authored-by: sam-goldman <106038229+sam-goldman@users.noreply.github.com> --- .changeset/giant-cheetahs-hammer.md | 5 +++ .changeset/silly-trainers-invite.md | 5 +++ packages/executor/package.json | 2 +- packages/executor/src/index.ts | 17 ++++++++--- packages/plugins/src/env.ts | 27 ----------------- packages/plugins/src/executor.ts | 14 ++------- packages/plugins/src/index.ts | 1 - yarn.lock | 47 ++++++++++++++++++++++++++++- 8 files changed, 72 insertions(+), 46 deletions(-) create mode 100644 .changeset/giant-cheetahs-hammer.md create mode 100644 .changeset/silly-trainers-invite.md delete mode 100644 packages/plugins/src/env.ts diff --git a/.changeset/giant-cheetahs-hammer.md b/.changeset/giant-cheetahs-hammer.md new file mode 100644 index 000000000..2a430d7e4 --- /dev/null +++ b/.changeset/giant-cheetahs-hammer.md @@ -0,0 +1,5 @@ +--- +'@chugsplash/executor': patch +--- + +Updates the executor to use the latest version of BaseServiceV2. diff --git a/.changeset/silly-trainers-invite.md b/.changeset/silly-trainers-invite.md new file mode 100644 index 000000000..10cfd729a --- /dev/null +++ b/.changeset/silly-trainers-invite.md @@ -0,0 +1,5 @@ +--- +'@chugsplash/plugins': patch +--- + +Removes a hack for a bug that was fixed in upstream BaseServiceV2. diff --git a/packages/executor/package.json b/packages/executor/package.json index 223df7f97..9f67e82b4 100644 --- a/packages/executor/package.json +++ b/packages/executor/package.json @@ -32,7 +32,7 @@ "devDependencies": { "@chugsplash/contracts": "^0.4.1", "@chugsplash/core": "^0.4.1", - "@eth-optimism/common-ts": "^0.6.0", + "@eth-optimism/common-ts": "^0.7.1", "@eth-optimism/core-utils": "^0.9.3", "dotenv": "^16.0.3", "ethers": "^5.6.8", diff --git a/packages/executor/src/index.ts b/packages/executor/src/index.ts index 6fe46ff96..3cd538746 100644 --- a/packages/executor/src/index.ts +++ b/packages/executor/src/index.ts @@ -1,6 +1,11 @@ import * as dotenv from 'dotenv' dotenv.config() -import { BaseServiceV2, Logger, validators } from '@eth-optimism/common-ts' +import { + BaseServiceV2, + StandardOptions, + Logger, + validators, +} from '@eth-optimism/common-ts' import { ethers } from 'ethers' import { ChugSplashManagerABI, @@ -40,15 +45,17 @@ export class ChugSplashExecutor extends BaseServiceV2< ExecutorMetrics, ExecutorState > { - constructor(options?: Partial) { + constructor(options?: Partial) { super({ name: 'chugsplash-executor', // eslint-disable-next-line @typescript-eslint/no-var-requires version: require('../package.json').version, loop: true, - loopIntervalMs: 5000, - port: parseInt(process.env.EXECUTOR_PORT, 10), - options, + options: { + loopIntervalMs: 5000, + port: parseInt(process.env.EXECUTOR_PORT, 10), + ...options, + }, optionsSpec: { url: { desc: 'Target deployment network access url', diff --git a/packages/plugins/src/env.ts b/packages/plugins/src/env.ts deleted file mode 100644 index 9c501c59f..000000000 --- a/packages/plugins/src/env.ts +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Removes command line args in the `process.argv` array beginning with the first argument that - * starts with '--'. This is necessary to prevent an error that occurs when running the executor - * from within a Hardhat plugin task. This error occurs because the BaseServiceV2 (inherited by the - * executor) parses these command line arguments and throws an error when it sees an unrecognized - * argument that begins with '--'. - * - * @returns An array containing the removed command line args. - */ -export const removeFlagsFromCommandLineArgs = (): string[] => { - const indexToRemove = process.argv.findIndex((arg) => arg.startsWith('--')) - if (indexToRemove === -1) { - return [] - } - const removed = process.argv.slice(indexToRemove) - process.argv = process.argv.slice(0, indexToRemove) - return removed -} - -/** - * Adds the given array of arguments to `process.argv`. - * - * @param args The command line arguments to add. - */ -export const addCommandLineArgs = (args: string[]) => { - process.argv = process.argv.concat(args) -} diff --git a/packages/plugins/src/executor.ts b/packages/plugins/src/executor.ts index f8a89f868..0252dc990 100644 --- a/packages/plugins/src/executor.ts +++ b/packages/plugins/src/executor.ts @@ -2,18 +2,13 @@ import { ChugSplashExecutorType } from '@chugsplash/core' import { ChugSplashExecutor } from '@chugsplash/executor' import { providers } from 'ethers' -import { addCommandLineArgs, removeFlagsFromCommandLineArgs } from './env' - export const initializeExecutor = async ( provider: providers.JsonRpcProvider ): Promise => { - // We must remove the command line arguments that begin with '--' from the process.argv array, - // or else the BaseServiceV2 (inherited by the executor) will throw an error when we instantiate - // it. - const removed = removeFlagsFromCommandLineArgs() - // Instantiate the executor. - const executor = new ChugSplashExecutor() + const executor = new ChugSplashExecutor({ + useArgv: false, + }) // Setup the executor. await executor.setup( @@ -26,8 +21,5 @@ export const initializeExecutor = async ( provider ) - // Add the command line args back to the array. - addCommandLineArgs(removed) - return executor as any as ChugSplashExecutorType } diff --git a/packages/plugins/src/index.ts b/packages/plugins/src/index.ts index d102efb39..978cabfcf 100644 --- a/packages/plugins/src/index.ts +++ b/packages/plugins/src/index.ts @@ -1,3 +1,2 @@ export * from './hardhat' -export * from './env' export * from './sample-project' diff --git a/yarn.lock b/yarn.lock index c034e3768..1ba470056 100644 --- a/yarn.lock +++ b/yarn.lock @@ -472,7 +472,7 @@ minimatch "^3.1.2" strip-json-comments "^3.1.1" -"@eth-optimism/common-ts@^0.6.0", "@eth-optimism/common-ts@^0.6.7": +"@eth-optimism/common-ts@^0.6.7": version "0.6.7" resolved "https://registry.yarnpkg.com/@eth-optimism/common-ts/-/common-ts-0.6.7.tgz#f63f0e14e609215c255675183168fbaa7c641722" integrity sha512-zEJ/T58FU41tM+6hrQZvoZUec0Ce9cDJa3/Kd6jvzOfSiRjclIAHLk4BQYuFhNOx6pDNWlbuiNrBxpsWW4HCNg== @@ -495,6 +495,29 @@ prom-client "^13.1.0" qs "^6.10.5" +"@eth-optimism/common-ts@^0.7.1": + version "0.7.1" + resolved "https://registry.yarnpkg.com/@eth-optimism/common-ts/-/common-ts-0.7.1.tgz#42dd78051e7c45d40f133598c9d43bb0c02ce9b1" + integrity sha512-SNaOhoj9lYutcmGpJQJJfZiZii54eoiSB1kM8XVmbIwyhgaTkmuB8IhHOiDbzGB3QXUtbGZjDJmi6LruKkN/CA== + dependencies: + "@eth-optimism/core-utils" "0.12.0" + "@sentry/node" "^6.3.1" + bcfg "^0.1.7" + body-parser "^1.20.0" + commander "^9.0.0" + dotenv "^16.0.0" + envalid "^7.2.2" + ethers "^5.7.0" + express "^4.17.1" + express-prom-bundle "^6.4.1" + lodash "^4.17.21" + morgan "^1.10.0" + pino "^6.11.3" + pino-multi-stream "^5.3.0" + pino-sentry "^0.7.0" + prom-client "^13.1.0" + qs "^6.10.5" + "@eth-optimism/contracts-bedrock@^0.8.0": version "0.8.3" resolved "https://registry.yarnpkg.com/@eth-optimism/contracts-bedrock/-/contracts-bedrock-0.8.3.tgz#a73302b57a61d9516abf80c136bf8298327178d5" @@ -537,6 +560,28 @@ bufio "^1.0.7" chai "^4.3.4" +"@eth-optimism/core-utils@0.12.0": + version "0.12.0" + resolved "https://registry.yarnpkg.com/@eth-optimism/core-utils/-/core-utils-0.12.0.tgz#6337e4599a34de23f8eceb20378de2a2de82b0ea" + integrity sha512-qW+7LZYCz7i8dRa7SRlUKIo1VBU8lvN0HeXCxJR+z+xtMzMQpPds20XJNCMclszxYQHkXY00fOT6GvFw9ZL6nw== + dependencies: + "@ethersproject/abi" "^5.7.0" + "@ethersproject/abstract-provider" "^5.7.0" + "@ethersproject/address" "^5.7.0" + "@ethersproject/bignumber" "^5.7.0" + "@ethersproject/bytes" "^5.7.0" + "@ethersproject/constants" "^5.7.0" + "@ethersproject/contracts" "^5.7.0" + "@ethersproject/hash" "^5.7.0" + "@ethersproject/keccak256" "^5.7.0" + "@ethersproject/properties" "^5.7.0" + "@ethersproject/providers" "^5.7.0" + "@ethersproject/rlp" "^5.7.0" + "@ethersproject/transactions" "^5.7.0" + "@ethersproject/web" "^5.7.0" + bufio "^1.0.7" + chai "^4.3.4" + "@eth-optimism/core-utils@^0.10.1": version "0.10.1" resolved "https://registry.yarnpkg.com/@eth-optimism/core-utils/-/core-utils-0.10.1.tgz#44515fbca627532a24c6fd433395f00be8525832"