Skip to content

Commit

Permalink
Merge pull request sphinx-labs#342 from chugsplash/pate/terraform
Browse files Browse the repository at this point in the history
fix(exec): Better Support for Containerized Executor
  • Loading branch information
sam-goldman authored Jan 4, 2023
2 parents 020a28d + 9076ccd commit 9bd2b0e
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 39 deletions.
6 changes: 6 additions & 0 deletions .changeset/slow-lemons-grin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@chugsplash/executor': patch
'@chugsplash/plugins': patch
---

Better support for deploying containerized executor with Terraform
3 changes: 1 addition & 2 deletions packages/executor/.dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
node_modules
dist
.env*
yarn-error.log
yarn-error.log
2 changes: 1 addition & 1 deletion packages/executor/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
dist/
.env*
cache
cache
6 changes: 1 addition & 5 deletions packages/executor/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
FROM node:16.16.0

FROM --platform=linux/amd64 node:16.16.0
COPY package.json package.json

RUN npm install

COPY . .

CMD [ "yarn", "start" ]
2 changes: 1 addition & 1 deletion packages/executor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"lint:ts:check": "eslint . --max-warnings=0",
"pre-commit": "lint-staged",
"build-container": "docker build --tag chugsplash-executor .",
"run-container": "docker run --env-file ./.env chugsplash-executor"
"container": "docker run --env-file ./.env chugsplash-executor"
},
"homepage": "https://github.com/smartcontracts/chugsplash/tree/develop/packages/executor#readme",
"license": "MIT",
Expand Down
7 changes: 2 additions & 5 deletions packages/executor/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,14 @@ type State = {
wallet: ethers.Wallet
}

// TODO: Add logging agent for docker container and connect to a managed sink such as logz.io
// Refactor chugsplash commands to decide whether to use the executor based on the target network

export class ChugSplashExecutor extends BaseServiceV2<Options, Metrics, State> {
constructor(options?: Partial<Options>) {
super({
name: 'chugsplash-executor',
// eslint-disable-next-line @typescript-eslint/no-var-requires
version: require('../package.json').version,
loop: true,
loopIntervalMs: 1000,
loopIntervalMs: 5000,
options,
optionsSpec: {
url: {
Expand Down Expand Up @@ -175,7 +172,7 @@ export class ChugSplashExecutor extends BaseServiceV2<Options, Metrics, State> {
// Get approval events in blocks after the stored block number
const newApprovalEvents = await registry.queryFilter(
registry.filters.EventAnnounced('ChugSplashBundleApproved'),
this.state.lastBlockNumber + 1,
this.state.lastBlockNumber,
latestBlockNumber
)

Expand Down
17 changes: 9 additions & 8 deletions packages/executor/src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ export const customChains = [
browserURL: 'https://goerli-optimism.etherscan.io',
},
},
{
network: 'arbitrum-goerli',
chainId: 421613,
urls: {
apiURL: 'https://api-goerli.arbiscan.io/api',
browserURL: 'https://goerli.arbiscan.io/',
},
},
]

export const etherscanApiKey = {
optimisticGoerli: process.env.OPT_ETHERSCAN_API_KEY
? process.env.OPT_ETHERSCAN_API_KEY
: '',
goerli: process.env.ETH_ETHERSCAN_API_KEY
? process.env.ETH_ETHERSCAN_API_KEY
: '',
}
export const etherscanApiKey = process.env.ETHERSCAN_API_KEY
20 changes: 8 additions & 12 deletions packages/executor/src/utils/etherscan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import {
toVerifyRequest,
toCheckStatusRequest,
} from '@nomiclabs/hardhat-etherscan/dist/src/etherscan/EtherscanVerifyContractRequest'
import { resolveEtherscanApiKey } from '@nomiclabs/hardhat-etherscan/dist/src/resolveEtherscanApiKey'
import {
retrieveContractBytecode,
getEtherscanEndpoints,
Expand Down Expand Up @@ -353,18 +352,15 @@ export const getEtherscanInfo = async (
etherscanApiKey: string
etherscanApiEndpoints: EtherscanURLs
}> => {
const { network: verificationNetwork, urls: etherscanApiEndpoints } =
await getEtherscanEndpoints(
// Todo - figure out how to fit JsonRpcProvider into EthereumProvider type without casting as any
provider as any,
networkName,
chainConfig,
customChains
)

const etherscanApiKey = resolveEtherscanApiKey(apiKey, verificationNetwork)
const { urls: etherscanApiEndpoints } = await getEtherscanEndpoints(
// Todo - figure out how to fit JsonRpcProvider into EthereumProvider type without casting as any
provider as any,
networkName,
chainConfig,
customChains
)

return { etherscanApiKey, etherscanApiEndpoints }
return { etherscanApiKey: apiKey, etherscanApiEndpoints }
}

export const linkProxyWithImplementation = async (
Expand Down
10 changes: 5 additions & 5 deletions packages/plugins/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,22 @@ const config: HardhatUserConfig = {
},
goerli: {
chainId: 5,
url: `https://goerli.infura.io/v3/${process.env.INFURA_API_KEY}`,
url: `https://eth-goerli.g.alchemy.com/v2/${process.env.ALCHEMY_API_KEY}`,
accounts,
},
ethereum: {
chainId: 1,
url: `https://optimism-mainnet.infura.io/v3/${process.env.INFURA_API_KEY}`,
url: `https://eth-mainnet.g.alchemy.com/v2/${process.env.INFURA_API_KEY}`,
accounts,
},
'optimism-goerli': {
chainId: 420,
url: `https://optimism-goerli.infura.io/v3/${process.env.INFURA_API_KEY}`,
url: `https://opt-goerli.g.alchemy.com/v2/${process.env.ALCHEMY_API_KEY}`,
accounts,
},
optimism: {
chainId: 10,
url: `https://optimism-mainnet.infura.io/v3/${process.env.INFURA_API_KEY}`,
url: `https://opt-mainnet.g.alchemy.com/v2/${process.env.ALCHEMY_API_KEY}`,
accounts,
},
arbitrum: {
Expand All @@ -52,7 +52,7 @@ const config: HardhatUserConfig = {
},
'arbitrum-goerli': {
chainId: 421613,
url: 'https://goerli-rollup.arbitrum.io/rpc',
url: `https://arb-goerli.g.alchemy.com/v2/${process.env.ALCHEMY_API_KEY}`,
accounts,
},
},
Expand Down

0 comments on commit 9bd2b0e

Please sign in to comment.