Support fork connection.

This commit is contained in:
David Racero 2021-03-03 12:25:10 +01:00
parent befb447148
commit d9026b7122
8 changed files with 36 additions and 11 deletions

View File

@ -7,4 +7,3 @@ services:
environment:
- MNEMONIC
- ALCHEMY_KEY
- TENDERLY_FORK_ID

View File

@ -20,3 +20,4 @@ services:
TENDERLY_USERNAME: ${TENDERLY_USERNAME}
ALCHEMY_KEY: ${ALCHEMY_KEY}
TENDERLY_FORK_ID: ${TENDERLY_FORK_ID}
TENDERLY_HEAD_ID: ${TENDERLY_HEAD_ID}

View File

@ -5,8 +5,8 @@ import { HardhatUserConfig } from 'hardhat/types';
import { accounts } from './test-wallets.js';
import { eEthereumNetwork, eNetwork, ePolygonNetwork, eXDaiNetwork } from './helpers/types';
import { BUIDLEREVM_CHAINID, COVERAGE_CHAINID } from './helpers/buidler-constants';
import { NETWORKS_RPC_URL, NETWORKS_DEFAULT_GAS } from './helper-hardhat-config';
import { NETWORKS_RPC_URL, NETWORKS_DEFAULT_GAS } from './helper-hardhat-config';
require('dotenv').config();
import '@nomiclabs/hardhat-ethers';
@ -94,7 +94,7 @@ const buidlerConfig: HardhatUserConfig = {
kovan: getCommonNetworkConfig(eEthereumNetwork.kovan, 42),
ropsten: getCommonNetworkConfig(eEthereumNetwork.ropsten, 3),
main: getCommonNetworkConfig(eEthereumNetwork.main, 1),
tenderlyMain: getCommonNetworkConfig(eEthereumNetwork.main, 1),
tenderlyMain: getCommonNetworkConfig(eEthereumNetwork.tenderlyMain, 3030),
matic: getCommonNetworkConfig(ePolygonNetwork.matic, 137),
mumbai: getCommonNetworkConfig(ePolygonNetwork.mumbai, 80001),
xdai: getCommonNetworkConfig(eXDaiNetwork.xdai, 100),

View File

@ -89,7 +89,7 @@
"@nomiclabs/hardhat-ethers": "^2.0.0",
"@nomiclabs/hardhat-waffle": "^2.0.0",
"@openzeppelin/contracts": "3.1.0",
"@tenderly/hardhat-tenderly": "^1.1.0-beta.3",
"@tenderly/hardhat-tenderly": "^1.1.0-beta.4",
"@typechain/ethers-v4": "1.0.0",
"@typechain/ethers-v5": "^2.0.0",
"@typechain/truffle-v4": "2.0.2",

View File

@ -46,7 +46,10 @@ task('aave:mainnet', 'Deploy development enviroment')
if (usingTenderly()) {
const postDeployHead = DRE.tenderlyRPC.getHead();
console.log('Tenderly UUID', postDeployHead);
const postDeployFork = DRE.tenderlyRPC.getFork();
console.log('Tenderly Info');
console.log('- Head', postDeployHead);
console.log('- Fork', postDeployFork);
}
console.log('\nFinished migrations');
printContracts();

View File

@ -46,7 +46,10 @@ task('amm:mainnet', 'Deploy development enviroment')
if (usingTenderly()) {
const postDeployHead = DRE.tenderlyRPC.getHead();
console.log('Tenderly UUID', postDeployHead);
const postDeployFork = DRE.tenderlyRPC.getFork();
console.log('Tenderly Info');
console.log('- Head', postDeployHead);
console.log('- Fork', postDeployFork);
}
console.log('\nFinished migrations');
printContracts();

View File

@ -21,7 +21,7 @@ task('matic:mainnet', 'Deploy development enviroment')
await DRE.run('full:deploy-address-provider', { pool: POOL_NAME });
console.log('2. Deploy lending pool');
await DRE.run('full:deploy-lending-pool', { pool: POOL_NAME});
await DRE.run('full:deploy-lending-pool', { pool: POOL_NAME });
console.log('3. Deploy oracles');
await DRE.run('full:deploy-oracles', { pool: POOL_NAME });
@ -43,7 +43,10 @@ task('matic:mainnet', 'Deploy development enviroment')
if (usingTenderly()) {
const postDeployHead = DRE.tenderlyRPC.getHead();
console.log('Tenderly UUID', postDeployHead);
const postDeployFork = DRE.tenderlyRPC.getFork();
console.log('Tenderly Info');
console.log('- Head', postDeployHead);
console.log('- Fork', postDeployFork);
}
console.log('\nFinished migrations');
printContracts();

View File

@ -3,6 +3,8 @@ import { DRE, setDRE } from '../../helpers/misc-utils';
import { EthereumNetworkNames } from '../../helpers/types';
import { usingTenderly } from '../../helpers/tenderly-utils';
import { HardhatRuntimeEnvironment } from 'hardhat/types';
import { getFirstSigner } from '../../helpers/contracts-getters';
import { formatEther } from 'ethers/lib/utils';
task(`set-DRE`, `Inits the DRE, to have access to all the plugins' objects`).setAction(
async (_, _DRE) => {
@ -14,10 +16,24 @@ task(`set-DRE`, `Inits the DRE, to have access to all the plugins' objects`).set
process.env.TENDERLY === 'true'
) {
console.log('- Setting up Tenderly provider');
await _DRE.tenderlyRPC.initializeFork();
console.log('- Initialized Tenderly fork');
if (process.env.TENDERLY_FORK_ID && process.env.TENDERLY_HEAD_ID) {
console.log('- Connecting to a Tenderly Fork');
_DRE.tenderlyRPC.setFork(process.env.TENDERLY_FORK_ID);
_DRE.tenderlyRPC.setHead(process.env.TENDERLY_HEAD_ID);
} else {
console.log('- Creating a new Tenderly Fork');
await _DRE.tenderlyRPC.initializeFork();
}
const provider = new _DRE.ethers.providers.Web3Provider(_DRE.tenderlyRPC as any);
_DRE.ethers.provider = provider;
console.log('- Initialized Tenderly fork:');
console.log(' - Fork: ', _DRE.tenderlyRPC.getFork());
console.log(' - Head: ', _DRE.tenderlyRPC.getHead());
console.log(' - First account:', await (await _DRE.ethers.getSigners())[0].getAddress());
console.log(
' - Balance:',
formatEther(await (await _DRE.ethers.getSigners())[0].getBalance())
);
}
setDRE(_DRE);