Skip to content

Commit

Permalink
Merge pull request #151 from bancorprotocol/upgrade-tenderly
Browse files Browse the repository at this point in the history
upgrade tenderly version
  • Loading branch information
ivanzhelyazkov authored Jul 1, 2024
2 parents 539b1ec + fcecaf3 commit 4c6f7ae
Show file tree
Hide file tree
Showing 11 changed files with 7,283 additions and 5,598 deletions.
12 changes: 12 additions & 0 deletions contracts/helpers/DummyProxy.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
import { OptimizedTransparentUpgradeableProxy } from "hardhat-deploy/solc_0.8/proxy/OptimizedTransparentUpgradeableProxy.sol";
import { ProxyAdmin } from "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol";

/**
* @dev Contract used to load the ProxyAdmin and OptimizedTransparentUpgradeableProxy contracts
* @dev workaround for tenderly verification issues with ethers-v5:
* @dev https://docs.tenderly.co/contract-verification/hardhat-proxy-contracts#load-the-proxy-contracts
*/
abstract contract OptimizedTransparentUpgradeableProxyAccess is OptimizedTransparentUpgradeableProxy {}
abstract contract ProxyAdminAccess is ProxyAdmin {}
2 changes: 1 addition & 1 deletion deployments/run-fork.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ fi
# Create a new dir for the deploy script files and copy them there
rm -rf deployments/tenderly && cp -rf deployments/${network_name}/. deployments/tenderly

command="TENDERLY_FORK_ID=${fork_id} TENDERLY_NETWORK_NAME=${network_name} ${@:1}"
command="TENDERLY_IS_FORK=true TENDERLY_FORK_ID=${fork_id} TENDERLY_NETWORK_NAME=${network_name} ${@:1}"

echo "Running:"
echo
Expand Down
4 changes: 2 additions & 2 deletions deployments/run-testnet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ trap cleanup TERM EXIT
response=$(curl -sX POST "$TENDERLY_TESTNET_API" \
-H "Content-Type: application/json" -H "X-Access-Key: ${TENDERLY_ACCESS_KEY}" \
-d '{
"displayName": "Fast Lane Testnet",
"displayName": "Carbon Contracts Testnet",
"description": "",
"visibility": "TEAM",
"tags": {
Expand Down Expand Up @@ -83,7 +83,7 @@ if [ ! -d "./deploy/scripts/${network_name}" ]; then
fi

# Create a new dir for the deploy script files and copy them there
rm -rf deployments/tenderly-testnet && cp -rf deployments/${network_name}/. deployments/tenderly-testnet
rm -rf deployments/tenderly && cp -rf deployments/${network_name}/. deployments/tenderly

command="TENDERLY_TESTNET_ID=${testnet_id} TENDERLY_TESTNET_PROVIDER_URL=${provider_url} ${@:1}"

Expand Down
8 changes: 7 additions & 1 deletion deployments/setup-fork.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Contracts from '../components/Contracts';
import { getNamedSigners, isTenderly, isTenderlyFork, isTenderlyTestnet, runPendingDeployments } from '../utils/Deploy';
import { getNamedSigners, isTenderly, runPendingDeployments } from '../utils/Deploy';
import Logger from '../utils/Logger';
import { NATIVE_TOKEN_ADDRESS, ZERO_ADDRESS } from '../utils/Constants';
import { toWei } from '../utils/Types';
Expand Down Expand Up @@ -59,6 +59,12 @@ const fundAccount = async (account: string, fundingRequests: FundingRequest[]) =
}

const tokenContract = await Contracts.ERC20.attach(fundingRequest.token);
// check if whale has enough balance
const whaleBalance = await tokenContract.balanceOf(whale.address);
if (whaleBalance.lt(fundingRequest.amount)) {
Logger.error(`Whale ${whale.address} has insufficient balance for ${fundingRequest.tokenName}`);
continue;
}
await tokenContract.connect(whale).transfer(account, fundingRequest.amount);
}
};
Expand Down
6 changes: 3 additions & 3 deletions deployments/setup-testnet.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Contracts from '../components/Contracts';
import { getNamedSigners, isTenderlyTestnet, runPendingDeployments } from '../utils/Deploy';
import { getNamedSigners, isTenderly, runPendingDeployments } from '../utils/Deploy';
import Logger from '../utils/Logger';
import { NATIVE_TOKEN_ADDRESS, ZERO_ADDRESS } from '../utils/Constants';
import { toWei } from '../utils/Types';
Expand Down Expand Up @@ -159,7 +159,7 @@ const runDeployments = async () => {
const archiveArtifacts = async () => {
const zip = new AdmZip();

const srcDir = path.resolve(path.join(__dirname, './tenderly-testnet'));
const srcDir = path.resolve(path.join(__dirname, './tenderly'));
const dest = path.resolve(path.join(__dirname, '..', 'testnets', `testnet-${testnetId}.zip`));

zip.addLocalFolder(srcDir);
Expand All @@ -170,7 +170,7 @@ const archiveArtifacts = async () => {
};

const main = async () => {
if (!isTenderlyTestnet()) {
if (!isTenderly()) {
throw new Error('Invalid network');
}

Expand Down
21 changes: 9 additions & 12 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { NamedAccounts } from './data/named-accounts';
import { DeploymentNetwork } from './utils/Constants';
import './test/Setup';
import '@nomiclabs/hardhat-ethers';
import '@nomiclabs/hardhat-etherscan';
import '@nomiclabs/hardhat-solhint';
import '@nomiclabs/hardhat-waffle';
import '@tenderly/hardhat-tenderly';
import '@nomicfoundation/hardhat-verify';
import * as tenderly from '@tenderly/hardhat-tenderly';
import '@typechain/hardhat';
import 'dotenv/config';
import 'hardhat-contract-sizer';
Expand All @@ -19,12 +19,15 @@ import 'solidity-coverage';
import chainIds from './utils/chainIds.json';
import rpcUrls from './utils/rpcUrls.json';

tenderly.setup();

interface EnvOptions {
TENDERLY_TESTNET_PROVIDER_URL?: string;
GAS_PRICE?: number | 'auto';
NIGHTLY?: boolean;
PROFILE?: boolean;
VERIFY_API_KEY?: string;
TENDERLY_IS_FORK?: boolean;
TENDERLY_FORK_ID?: string;
TENDERLY_PROJECT?: string;
TENDERLY_TEST_PROJECT?: string;
Expand All @@ -36,6 +39,7 @@ const {
TENDERLY_TESTNET_PROVIDER_URL = '',
VERIFY_API_KEY = '',
GAS_PRICE: gasPrice = 'auto',
TENDERLY_IS_FORK = false,
TENDERLY_FORK_ID = '',
TENDERLY_PROJECT = '',
TENDERLY_TEST_PROJECT = '',
Expand Down Expand Up @@ -464,15 +468,7 @@ const config: HardhatUserConfig = {
},
[DeploymentNetwork.Tenderly]: {
chainId: Number(chainIds[TENDERLY_NETWORK_NAME as keyof typeof chainIds]),
url: `https://rpc.tenderly.co/fork/${TENDERLY_FORK_ID}`,
autoImpersonate: true,
saveDeployments: true,
live: true,
deploy: [`deploy/scripts/${TENDERLY_NETWORK_NAME}`]
},
[DeploymentNetwork.TenderlyTestnet]: {
chainId: Number(chainIds[TENDERLY_NETWORK_NAME as keyof typeof chainIds]),
url: TENDERLY_TESTNET_PROVIDER_URL,
url: TENDERLY_IS_FORK ? `https://rpc.tenderly.co/fork/${TENDERLY_FORK_ID}` : TENDERLY_TESTNET_PROVIDER_URL,
autoImpersonate: true,
saveDeployments: true,
live: true,
Expand All @@ -483,7 +479,8 @@ const config: HardhatUserConfig = {
tenderly: {
forkNetwork: chainIds[TENDERLY_NETWORK_NAME as keyof typeof chainIds].toString(),
project: TENDERLY_PROJECT || TENDERLY_TEST_PROJECT,
username: TENDERLY_USERNAME
username: TENDERLY_USERNAME,
privateVerification: true
},

solidity: {
Expand Down
11 changes: 5 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,10 @@
"deploy:mainnet": "HARDHAT_NETWORK=mainnet hardhat deploy",
"verify:mainnet": "HARDHAT_NETWORK=mainnet hardhat etherscan-verify --license None --force-license",
"verify:rinkeby": "HARDHAT_NETWORK=rinkeby hardhat etherscan-verify --license None --force-license",
"setup:fork": "./deployments/run-fork.sh pnpm run:fork deployments/setup-fork.ts",
"setup:testnet": "./deployments/run-testnet.sh pnpm run:testnet deployments/setup-testnet.ts",
"setup:fork": "./deployments/run-fork.sh pnpm run:tenderly deployments/setup-fork.ts",
"setup:testnet": "./deployments/run-testnet.sh pnpm run:tenderly deployments/setup-testnet.ts",
"run:mainnet": "HARDHAT_NETWORK=mainnet hardhat run",
"run:fork": "HARDHAT_NETWORK=tenderly hardhat run",
"run:testnet": "HARDHAT_NETWORK=tenderly-testnet hardhat run",
"run:tenderly": "HARDHAT_NETWORK=tenderly hardhat run",
"pol:enable:trading:check:mainnet": "pnpm run:mainnet scripts/enableTrading.ts",
"pol:enable:trading:check:fork": "pnpm run:fork scripts/enableTrading.ts",
"pol:enable:trading:mainnet": "ENABLE_TRADING=1 pnpm run:mainnet scripts/enableTrading.ts",
Expand All @@ -69,16 +68,16 @@
"@ethersproject/providers": "^5.7.2",
"@metamask/eth-sig-util": "^5.0.2",
"@nomiclabs/hardhat-ethers": "npm:[email protected]",
"@nomiclabs/hardhat-etherscan": "^3.1.6",
"@nomiclabs/hardhat-solhint": "^3.0.1",
"@nomiclabs/hardhat-waffle": "2.0.4",
"@nomicfoundation/hardhat-verify": "^2.0.8",
"@openzeppelin/contracts": "4.9.2",
"@openzeppelin/contracts-upgradeable": "4.9.2",
"@sentry/hub": "^7.56.0",
"@sentry/node": "^7.56.0",
"@sentry/types": "^7.56.0",
"@sentry/utils": "^7.56.0",
"@tenderly/hardhat-tenderly": "1.1.6",
"@tenderly/hardhat-tenderly": "1.8.0",
"@trivago/prettier-plugin-sort-imports": "^4.0.0",
"@typechain/ethers-v5": "^11.0.0",
"@typechain/hardhat": "^6.1.5",
Expand Down
Loading

0 comments on commit 4c6f7ae

Please sign in to comment.