Files
linea-monorepo/contracts/deploy/05_deploy_BridgedToken.ts
Andrei A. 390d6ff860 Feat/122 Add TokenBridge e2e tests (#210)
* fix: add mutex in account manager to avoid nonce issue

* fix: optimize global setup

* Limiting number of concurrent traces API requests for the local stack to avoid occasional OOM-s

* Limiting number of verticles for Traces API node

* Add E2E TokenBridge tests

* fixing test and adding concurency

* fixing test and adding concurency

* fixing test and adding concurency

* fixing test and adding concurency

* fixing nonce management

* deploying l2token for the L2 -> L1 test

* adjusting accounts for L2->L1 test

* adjusting l2TestContractAddress

* use nonce management for L1->L2 test

* adjusting the TestERC20 contract and tests

* rebasing with fix/133-improve-e2e-tests-performance

* fix: update jest config to exit even if there are open handles

* Trying out Besu untuned and raising limit per endpoint to 2 for traces

* Trying out Besu untuned and raising limit per endpoint to 2 for traces and Shomei node

* Using besu untuned for arithmetization as well

* Compile once and parallelise setRemoteTokenBridge

* feat: deploy smart contracts from artifacts + change e2e tests setup

* fix: update pnpm

* fix: remove compile contracts gradle task

* fix: remove compileContracts gradle task

* fix: refactor genesis generator dockerfile + downgrade l1-el-node besu version

* fix: move abi from e2e folder to contract folder + refactor contracts deployments scripts

* feat: add deployment script from artifacts for LineaRollupV6

* update pnpm version in get-started.md

* fix: update console log in deployment scripts

* fix: update besu version + fix deployment scripts

* correct addresses

* fix import

* use abi and bytecode for deployments

* use upgradable beacon for BridgedToken ABI deploys

* use saved abi and bytecode for TestERC20 deploy

* correct deployBridgedTokenAndTokenBridge casing

* optimize token bridge e2e calls

* use explicit message event data

* use precomputed nonces for e2e stack

---------

Co-authored-by: VGau <victorien.gauch@consensys.net>
Co-authored-by: Victorien Gauch <85494462+VGau@users.noreply.github.com>
Co-authored-by: Roman <4833306+Filter94@users.noreply.github.com>
Co-authored-by: thedarkjester <grant.southey@consensys.net>
Co-authored-by: The Dark Jester <thedarkjester@users.noreply.github.com>
2024-10-31 18:03:53 +01:00

56 lines
2.1 KiB
TypeScript

import { ethers, network, upgrades } from "hardhat";
import { DeployFunction } from "hardhat-deploy/types";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { BridgedToken } from "../typechain-types";
import {
tryVerifyContract,
getDeployedContractAddress,
tryStoreAddress,
validateDeployBranchAndTags,
} from "../common/helpers";
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { deployments } = hre;
validateDeployBranchAndTags(hre.network.name);
const contractName = "BridgedToken";
const existingContractAddress = await getDeployedContractAddress(contractName, deployments);
const chainId = (await ethers.provider.getNetwork()).chainId;
console.log(`Current network's chainId is ${chainId}`);
if (existingContractAddress === undefined) {
console.log(`Deploying initial version, NB: the address will be saved if env SAVE_ADDRESS=true.`);
} else {
console.log(`Deploying new version, NB: ${existingContractAddress} will be overwritten if env SAVE_ADDRESS=true.`);
}
// Deploy beacon for bridged token
const BridgedToken = await ethers.getContractFactory(contractName);
const bridgedToken = (await upgrades.deployBeacon(BridgedToken)) as unknown as BridgedToken;
await bridgedToken.waitForDeployment();
const bridgedTokenAddress = await bridgedToken.getAddress();
process.env.BRIDGED_TOKEN_ADDRESS = bridgedTokenAddress;
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const deployTx = bridgedToken.deployTransaction;
if (!deployTx) {
throw "Contract deployment transaction receipt not found.";
}
await tryStoreAddress(network.name, contractName, bridgedTokenAddress, deployTx.hash);
if (process.env.TOKEN_BRIDGE_L1 === "true") {
console.log(`L1 BridgedToken beacon deployed on ${network.name}, at address:`, bridgedTokenAddress);
} else {
console.log(`L2 BridgedToken beacon deployed on ${network.name}, at address:`, bridgedTokenAddress);
}
await tryVerifyContract(bridgedTokenAddress);
};
export default func;
func.tags = ["BridgedToken"];