From 48622c08157af58288990d69419d6f3b0699ee21 Mon Sep 17 00:00:00 2001 From: RnkSngh Date: Tue, 27 Aug 2024 03:40:25 -0400 Subject: [PATCH] remove unused scripts + specs --- package.json | 2 - specs/contracts.setup.spec.yaml | 29 -------- specs/contracts.spec.yaml | 94 -------------------------- specs/upgrade.spec.yaml | 35 ---------- src/deploy.ts | 60 ---------------- src/index.ts | 4 -- src/scripts/deploy-script.ts | 23 ------- src/scripts/setup-dispatcher-script.ts | 31 --------- src/tx.ts | 50 -------------- tsup.config.ts | 2 - 10 files changed, 330 deletions(-) delete mode 100644 specs/contracts.setup.spec.yaml delete mode 100644 specs/contracts.spec.yaml delete mode 100644 specs/upgrade.spec.yaml delete mode 100644 src/scripts/deploy-script.ts delete mode 100644 src/scripts/setup-dispatcher-script.ts diff --git a/package.json b/package.json index 85fd7eb8..c9a6e441 100644 --- a/package.json +++ b/package.json @@ -4,9 +4,7 @@ "main": "dist/index.js", "bin": { "verify-vibc-core-smart-contracts": "./dist/scripts/verify-contract-script.js", - "deploy-vibc-core-smart-contracts": "./dist/scripts/deploy-script.js", "update-vibc-core-smart-contracts": "./dist/scripts/update-contracts-script.js", - "setup-vibc-core-dispatcher": "./dist/scripts/setup-dispatcher-script.js", "vibc-core-deploy-test": "./dist/scripts/fork-deployment-test.js", "vibc-core-deploy-multisig": "./dist/scripts/deploy-multisig.js", "vibc-core-execute-multisig-tx": "./dist/scripts/execute-multisig-tx.js" diff --git a/specs/contracts.setup.spec.yaml b/specs/contracts.setup.spec.yaml deleted file mode 100644 index 033bd683..00000000 --- a/specs/contracts.setup.spec.yaml +++ /dev/null @@ -1,29 +0,0 @@ -# This file contains a tx spec for setting the right connections in the dispatcher contract. This spec needs to be run before the e2e test suite after deploying contracts. - -## The following arguments can be specified in tx spec: -# name: name of entry that will be stored in tx registry -# description: description in tx registry -# factoryName: factory to use to read abi to send tx -# deployer: can be set in the accounts.yaml -# address: address of contract to call method on -# signature: signature of method to call for this tx -# args: args to make the function call with, need to be compatible with the signature -- name: DispatcherClientSetup-Connection-0 - description: 'Setup client for dispatcher contracts' - deployer: 'KEY_DEPLOYER' - signature: "setClientForConnection(string,address)" - address: '{{DispatcherProxy}}' - factoryName: "Dispatcher" - args: - - 'connection-0' - - '{{LightClient}}' - -- name: DispatcherClientSetup-Connection-1 - description: 'Setup client for dispatcher contracts' - deployer: 'KEY_DEPLOYER' - signature: "setClientForConnection(string,address)" - address: '{{DispatcherProxy}}' - factoryName: "Dispatcher" - args: - - 'connection-2' - - '{{LightClient}}' \ No newline at end of file diff --git a/specs/contracts.spec.yaml b/specs/contracts.spec.yaml deleted file mode 100644 index fdca6212..00000000 --- a/specs/contracts.spec.yaml +++ /dev/null @@ -1,94 +0,0 @@ -# spec for deploying contracts -# {{name}} is replaced with one of the following, whichever matches first -# - the deployed contract address whose name matches `name` (not factoryName) -# - variables of the running chain, e.g. {{chain.chainName}}, {{chain.chainId}} -# - deployment factory names from written deployment files -# NOTE: order of the contracts matters, as some contracts depend on others -# contracts with no deps should be placed before those with deps - -## The following arguments can be specified in contracts spec: -# name: name of key that will be stored in the contract registry -# deployer: must be # name of key that will be stored in the contract registry a valid name in accountRegistry; default to 'default' if not specified -# description: description to be stored in the contract registry -# factoryName: the name of the typechain factory used to deploy the contract -# deployer: deployer key, should correspond to either a private key or one that can be looked up in the evm.accounts.yaml -# libraries: if a contract depends on libraries, the location of the library file & the deployed library address can be specified here, as an array with 2 elements -# deployArgs: The arguments that will be called in the contract constructor. Note: if $INITARGS is passed in as an argument, it will be abi.encode the arguments passed to the init paramater -# init: any arguments that need to be abi encoded (e.g. for calling upgradeToAndCall for ERC1967Proxy). These will be rendered in the place of $INITARGS - - -- name: LightClient - description: 'DummyLightClient' - factoryName: 'DummyLightClient' - deployer: 'KEY_DEPLOYER' - -- name: Ibc - description: 'IBC library' - factoryName: 'Ibc' - deployer: 'KEY_DEPLOYER' - -- name: IbcUtils - description: 'IBC utils library' - factoryName: 'IbcUtils' - deployer: 'KEY_DEPLOYER' - -- name: Dispatcher - description: 'IBC Core contract' - factoryName: 'Dispatcher' - libraries: - - name: 'contracts/libs/Ibc.sol:Ibc' - address: '{{Ibc}}' - - name: 'contracts/libs/IbcUtils.sol:IbcUtils' - address: '{{IbcUtils}}' - deployer: 'KEY_DEPLOYER' - -- name: FeeVault - description: 'FeeVault' - factoryName: 'FeeVault' - deployer: 'KEY_DEPLOYER' - -- name: DispatcherProxy - description: 'Dispatcher proxy contract' - factoryName: 'ERC1967Proxy' - deployArgs: - - '{{Dispatcher}}' - - '$INITARGS' - init: - signature: 'initialize(string,address)' - args: - - 'polyibc.{{chain.chainName}}.' - - '{{FeeVault}}' - deployer: 'KEY_DEPLOYER' - -- name: UC - description: 'Universal Chanel IBC-middleware contract' - factoryName: 'UniversalChannelHandler' - deployer: 'KEY_DEPLOYER' - libraries: - - name: 'contracts/libs/IbcUtils.sol:IbcUtils' - address: '{{IbcUtils}}' - -- name: UCProxy - description: 'Universal Chanel IBC-middleware proxy' - factoryName: 'ERC1967Proxy' - deployer: 'KEY_DEPLOYER' - deployArgs: - - '{{UC}}' - - '$INITARGS' - init: - signature: 'initialize(address)' - args: - - '{{DispatcherProxy}}' - -# dApp contracts for testing and as examples -- name: Mars - description: 'Mars contract directly owns a IBC channel' - deployArgs: - - '{{DispatcherProxy}}' - deployer: 'KEY_DAPP1' - -- name: Earth - description: 'Earth contract uses shared universal channel' - deployArgs: - - '{{UCProxy}}' - deployer: 'KEY_DAPP2' diff --git a/specs/upgrade.spec.yaml b/specs/upgrade.spec.yaml deleted file mode 100644 index f2972c09..00000000 --- a/specs/upgrade.spec.yaml +++ /dev/null @@ -1,35 +0,0 @@ -# This file contains a sample spec for sending Txs to contracts. -# This spec can be used for sending any tx to a contract, including proxy upgrades, calling setters, transferring ownership, etc. -# similar to in contract specs, {{name}} is replaced with one of the following, whichever matches first -# - the deployed contract address whose name matches `name` (not factoryName) -# - variables of the running chain, e.g. {{chain.chainName}}, {{chain.chainId}} -# - deployment factory names from written deployment files -# NOTE: order of the txs matters, as some txs might depend on others -# deployer: must be a valid name in accountRegistry; default to 'default' if not specified - -## The following arguments can be specified in tx spec: -# name: name of entry that will be stored in tx registry -# description: description in tx registry -# factoryName: factory to use to read abi to send tx -# deployer: can be set in the accounts.yaml -# address: address of contract to call method on -# signature: signature of method to call for this tx -# args: args to make the function call with, need to be compatible with the signature - -- name: DispatcherUpgrade - description: 'UUPS Upgrade for dispatcher contract implementation' - deployer: 'KEY_DEPLOYER' - signature: "upgradeTo(address)" - address: '{{DispatcherProxy}}' - factoryName: "Dispatcher" - args: - - '{{Dispatcher}}' - -- name: UCH Upgrade - description: 'Upgrade for uch contract' - deployer: 'KEY_DEPLOYER' - signature: "upgradeTo(address)" - address: '{{ UCProxy }}' - factoryName: "UC" - args: - - '{{UC}}' \ No newline at end of file diff --git a/src/deploy.ts b/src/deploy.ts index c5564ff3..d1178d15 100644 --- a/src/deploy.ts +++ b/src/deploy.ts @@ -175,63 +175,3 @@ export const deployContract = async ( throw err; } }; - -export async function deployToChain( - chain: Chain, - accountRegistry: AccountRegistry, - deploySpec: ContractRegistry, - logger: Logger, - dryRun = false, - forceDeployNewContracts = false, // True if you want to use existing deployments when possible - writeContracts: boolean = true, // True if you want to save persisted artifact files. - extraContractFactories: Record = {} -) { - logger.info( - `deploying ${deploySpec.size} contract(s) to chain ${chain.chainName}-${ - chain.deploymentEnvironment - } with contractNames: [${deploySpec.keys()}]` - ); - - let nonces: Record = {}; // maps addresses to nonces - if (!dryRun) { - accountRegistry = connectProviderAccounts(accountRegistry, chain.rpc); - } - - // @ts-ignore - const env: StringToStringMap = { ...process.env, chain }; - if (!forceDeployNewContracts) { - // Only read from existing contract files if we want to deploy new ones - await readDeploymentFilesIntoEnv(env, chain); - } - - // result is the final contract registry after deployment, modified in place - const cleanedSourceSpec = ContractRegistryLoader.loadSingle( - JSON.parse(JSON.stringify(deploySpec.serialize())) - ); - - const result = ContractRegistryLoader.emptySingle(); // Contains the filled in deployed addresses - - for (const contract of cleanedSourceSpec.values()) { - const deployedContract = await deployContract( - chain, - accountRegistry, - contract, - logger, - dryRun, - writeContracts, - extraContractFactories, - nonces, - env - ); - result.set(deployedContract.name, deployedContract); - } - - logger.info( - `[${chain.chainName}-${chain.deploymentEnvironment}]: finished deploying ${result.size} contracts` - ); - - return { - chainName: chain.chainName, - contracts: result, - }; -} diff --git a/src/index.ts b/src/index.ts index 4b5d729a..8f3aebfc 100644 --- a/src/index.ts +++ b/src/index.ts @@ -4,13 +4,9 @@ import { Registry } from "./utils/registry"; import { ContractRegistryLoader } from "./evm/schemas/contract"; import { parseObjFromFile } from "./utils/io"; import { loadEvmAccounts } from "./evm/schemas/account"; -import { deployToChain } from "./deploy"; -import { sendTxToChain } from "./tx"; import { updateContractsForChain } from "./updateContract"; export { - deployToChain, - sendTxToChain, updateContractsForChain, Chain, Registry, diff --git a/src/scripts/deploy-script.ts b/src/scripts/deploy-script.ts deleted file mode 100644 index b8aec277..00000000 --- a/src/scripts/deploy-script.ts +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env node -import { ContractRegistryLoader, deployToChain, parseObjFromFile } from ".."; - -import { getMainLogger } from "../utils/cli"; -import { DEPLOY_SPECS_PATH } from "../utils/constants"; -import { parseArgsFromCLI } from "../utils/io"; - -async function main() { - const { chain, accounts, args, deploySpecs } = await parseArgsFromCLI(); - const contracts = ContractRegistryLoader.loadSingle( - parseObjFromFile(deploySpecs) - ); - deployToChain( - chain, - accounts.mustGet(chain.chainName), - contracts.subset(), - getMainLogger(), - false, - false, - true - ); -} -main(); diff --git a/src/scripts/setup-dispatcher-script.ts b/src/scripts/setup-dispatcher-script.ts deleted file mode 100644 index 1502acec..00000000 --- a/src/scripts/setup-dispatcher-script.ts +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env node -import { - AccountRegistry, - Chain, - ContractRegistryLoader, - parseObjFromFile, -} from ".."; -import { loadTxRegistry } from "../evm/schemas/tx"; -import { sendTxToChain } from "../tx"; - -import { getOutputLogger } from "../utils/cli"; -import { DISPATCHER_SETUP_SPECS_PATH } from "../utils/constants"; -import { parseArgsFromCLI } from "../utils/io"; - -async function main() { - const { chain, accounts, args } = await parseArgsFromCLI(); - const txSpecs = - (args.DISPATCHER_SETUP_SPECS_PATH as string) || DISPATCHER_SETUP_SPECS_PATH; - - const upgradeTxs = loadTxRegistry(parseObjFromFile(txSpecs)); - - sendTxToChain( - chain, - accounts.mustGet(chain.chainName), - ContractRegistryLoader.emptySingle(), - upgradeTxs.subset(), - getOutputLogger(), - false - ); -} -main(); diff --git a/src/tx.ts b/src/tx.ts index dc078806..b41719a9 100644 --- a/src/tx.ts +++ b/src/tx.ts @@ -121,53 +121,3 @@ export async function sendTx( throw err; } } - -/** - * Send a tx to an existing contract. Reads contract from the _existingContracts args. Can be used for upgrading proxy to new implementation contracts as well - */ -export async function sendTxToChain( - chain: Chain, // existing contract registry for this chain - accountRegistry: AccountRegistry, // Set of accounts to send txs from - existingContracts: ContractRegistry, // Used as a supplementary address source for tests where the contract address is not saved as artifacts - transactionSpec: TxRegistry, // The txs to send - logger: Logger, - dryRun = false -) { - logger.debug( - `sending ${transactionSpec.size} transaction(s) to chain ${ - chain.chainName - }-${ - chain.deploymentEnvironment - } with contractNames: [${transactionSpec.keys()}]` - ); - - if (!dryRun) { - accountRegistry = connectProviderAccounts(accountRegistry, chain.rpc); - } - - // result is the final contract registry after deployment, modified in place - const result = loadTxRegistry( - JSON.parse(JSON.stringify(transactionSpec.serialize())) - ); - const existingContractAddresses: Record = {}; - existingContracts.toList().forEach((item) => { - existingContractAddresses[item.name] = item.address ? item.address : "0x"; - }); - - // @ts-ignore - let env = await readDeploymentFilesIntoEnv({}, chain); // Read from existing deployment files first, then overwrite with explicitly given contract addresses - env = { ...env, ...existingContractAddresses, chain }; - - for (const tx of result.values()) { - await sendTx( - chain, - accountRegistry, - existingContracts, - tx, - logger, - dryRun, - {}, - env - ); - } -} diff --git a/tsup.config.ts b/tsup.config.ts index add0159c..5fecee97 100644 --- a/tsup.config.ts +++ b/tsup.config.ts @@ -11,11 +11,9 @@ export default defineConfig({ "src/evm/chain.ts", "src/evm/contracts/*.ts", "src/evm/schemas/*.ts", - "src/scripts/deploy-script.ts", "src/scripts/update-contracts-script.ts", "src/scripts/verify-contract-script.ts", "src/scripts/fork-deployment-test.ts", - "src/scripts/setup-dispatcher-script.ts", "src/scripts/deploy-multisig.ts", "src/scripts/execute-multisig-tx.ts", ],