Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/actions/cache-evm-artifacts/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ runs:
# The job that generates the artifacts is responsible for archiving them to the cache tarball. This avoids any
# conflicts with other caching actions that might have cleaned some of cached contents.
path: evm-artifacts.tar
key: evm-artifacts-${{ runner.os }}-node-${{ steps.resolved-node.outputs.version }}-${{ hashFiles('yarn.lock', 'hardhat.config.ts', 'contracts/**/*.sol') }}
key: evm-artifacts-${{ runner.os }}-node-${{ steps.resolved-node.outputs.version }}-${{ hashFiles('yarn.lock', 'hardhat.config.ts', 'foundry.toml', 'contracts/**/*.sol') }}
- name: Unpack restored EVM artifacts
if: steps.evm-artifacts-cache.outputs.cache-hit == 'true'
shell: bash
Expand Down
16 changes: 15 additions & 1 deletion .github/actions/generate-evm-artifacts/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,23 @@ runs:
- name: Install packages
shell: bash
run: yarn install --frozen-lockfile
- name: Build EVM
- name: Build Hardhat
shell: bash
run: yarn build-evm
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
- name: Install forge dependencies
shell: bash
run: forge install
- name: Build Foundry
shell: bash
run: forge build --skip test script
- name: Generate Typechain artifacts
shell: bash
run: npx ts-node scripts/typechainArtifacts.ts
- name: Generate Typechain
shell: bash
run: npx typechain --target ethers-v5 "typechain-artifacts/**/*.json" --out-dir typechain
- name: Archive EVM artifacts (for caching)
shell: bash
env:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ out
zkout
cache-foundry

# Typechain
typechain-artifacts

# Upgradeability files
.openzeppelin

Expand Down
18 changes: 7 additions & 11 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
const { subtask } = require("hardhat/config");
const { TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS } = require("hardhat/builtin-tasks/task-names");

const isTest = process.env.IS_TEST === "true" || process.env.CI === "true";

subtask(TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS).setAction(async (_: any, __: any, runSuper: any) => {
const paths = await runSuper();

// Filter out files that cause problems when using "paris" hardfork (currently used to compile everything when IS_TEST=true)
// Reference: https://github.com/NomicFoundation/hardhat/issues/2306#issuecomment-1039452928
if (process.env.IS_TEST === "true") {
if (isTest) {
return paths.filter((p: any) => {
return (
!p.includes("contracts/periphery/mintburn") &&
Expand All @@ -28,7 +30,6 @@ import { getNodeUrl } from "./utils";

import "@nomicfoundation/hardhat-verify"; // Must be above hardhat-upgrades
import "@nomiclabs/hardhat-waffle";
import "@typechain/hardhat";
import "@matterlabs/hardhat-zksync-solc";
import "@matterlabs/hardhat-zksync-verify";
import "@matterlabs/hardhat-zksync-upgradable";
Expand Down Expand Up @@ -70,8 +71,6 @@ const tasks = [
// eslint-disable-next-line node/no-missing-require
tasks.forEach((task) => require(`./tasks/${task}`));

const isTest = process.env.IS_TEST === "true";

// To compile with zksolc, `hardhat` must be the default network and its `zksync` property must be true.
// So we allow the caller to set this environment variable to toggle compiling zk contracts or not.
// TODO: Figure out way to only compile specific contracts intended to be deployed on ZkSync (e.g. ZkSync_SpokePool) if
Expand All @@ -82,6 +81,7 @@ const solcVersion = "0.8.30";

// Hardhat 2.14.0 doesn't support prague yet, so we use paris instead (need to upgrade to v3 to use prague)
const evmVersion = isTest ? "paris" : "prague";
const revertStrings = isTest ? "debug" : "strip";

// Compilation settings are overridden for large contracts to allow them to compile without going over the bytecode
// limit.
Expand All @@ -91,7 +91,7 @@ const LARGE_CONTRACT_COMPILER_SETTINGS = {
optimizer: { enabled: true, runs: 800 },
viaIR: true,
evmVersion,
debug: { revertStrings: isTest ? "debug" : "strip" },
debug: { revertStrings },
},
};
const DEFAULT_CONTRACT_COMPILER_SETTINGS = {
Expand All @@ -101,7 +101,7 @@ const DEFAULT_CONTRACT_COMPILER_SETTINGS = {
viaIR: true,
evmVersion,
// Only strip revert strings if not testing or in ci.
debug: { revertStrings: isTest ? "debug" : "strip" },
debug: { revertStrings },
},
};
// This is only used by Blast_SpokePool for now, as it's the largest bytecode-wise
Expand All @@ -111,7 +111,7 @@ const LARGEST_CONTRACT_COMPILER_SETTINGS = {
optimizer: { enabled: true, runs: 50 },
viaIR: true,
evmVersion,
debug: { revertStrings: isTest ? "debug" : "strip" },
debug: { revertStrings },
},
};

Expand Down Expand Up @@ -396,10 +396,6 @@ const config: HardhatUserConfig = {
],
},
namedAccounts: { deployer: 0 },
typechain: {
outDir: "./typechain",
target: "ethers-v5",
},
paths: {
tests: "./test/evm/hardhat",
},
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@across-protocol/contracts",
"version": "4.1.17-beta.4",
"version": "4.1.19-alpha.3",
"author": "UMA Team",
"license": "AGPL-3.0-only",
"repository": {
Expand Down Expand Up @@ -95,7 +95,6 @@
"@openzeppelin/hardhat-upgrades": "^1.22.0",
"@pinata/sdk": "^2.1.0",
"@typechain/ethers-v5": "^11.0.0",
"@typechain/hardhat": "^8.0.0",
"@types/bn.js": "^5.1.0",
"@types/chai": "^4.3.5",
"@types/mocha": "^9.0.0",
Expand Down
46 changes: 46 additions & 0 deletions scripts/typechainArtifacts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import fs from "fs";
import path from "path";
import fg from "fast-glob";

const OUT_DIR = "out";
const STAGE_DIR = "typechain-artifacts";

function main() {
if (fs.existsSync(STAGE_DIR)) {
fs.rmdirSync(STAGE_DIR, { recursive: true });
}
fs.mkdirSync(STAGE_DIR, { recursive: true });

const files = fg.sync([`${OUT_DIR}/**/*.json`, `!${OUT_DIR}/build-info/**`], {
dot: false,
onlyFiles: true,
});

const seen = new Map<string, string>(); // contractName -> first file path kept
const dups: Array<{ name: string; kept: string; dropped: string }> = [];

for (const file of files) {
const name = file.split("/").pop()?.split(".")[0];
if (!name) continue;

const already = seen.get(name);
if (already) {
dups.push({ name, kept: already, dropped: file });
continue;
}

seen.set(name, file);

// One artifact per name => stable TypeChain inputs
const dest = path.join(STAGE_DIR, `${name}.json`);
fs.copyFileSync(file, dest);
}

if (dups.length > 0) {
console.warn(`\nTypeChain dedupe: dropped ${dups.length} duplicate contract names:\n`);
}

console.log(`Staged ${seen.size} unique artifacts into ${STAGE_DIR}/`);
}

main();
4 changes: 2 additions & 2 deletions test/evm/hardhat/chain-adapters/Arbitrum_Adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import {
MessagingReceiptStructOutput,
OFTReceiptStructOutput,
SendParamStruct,
} from "../../../../typechain/contracts/interfaces/IOFT.sol/IOFT";
import { IOFT__factory } from "../../../../typechain/factories/contracts/interfaces/IOFT.sol/IOFT__factory";
} from "../../../../typechain/IOFT";
import { IOFT__factory } from "../../../../typechain/factories/IOFT__factory";
import { hubPoolFixture, enableTokensForLP } from "../fixtures/HubPool.Fixture";
import { constructSingleChainTree } from "../MerkleLib.utils";
import { CIRCLE_DOMAIN_IDs } from "../../../../deploy/consts";
Expand Down
4 changes: 2 additions & 2 deletions test/evm/hardhat/chain-adapters/Polygon_Adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ import {
MessagingReceiptStructOutput,
OFTReceiptStructOutput,
SendParamStruct,
} from "../../../../typechain/contracts/interfaces/IOFT.sol/IOFT";
import { IOFT__factory } from "../../../../typechain/factories/contracts/interfaces/IOFT.sol/IOFT__factory";
} from "../../../../typechain/IOFT";
import { IOFT__factory } from "../../../../typechain/factories/IOFT__factory";
import { CIRCLE_DOMAIN_IDs } from "../../../../deploy/consts";
import { AdapterStore, AdapterStore__factory } from "../../../../typechain";
import { CHAIN_IDs } from "@across-protocol/constants";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import {
MessagingReceiptStructOutput,
OFTReceiptStructOutput,
SendParamStruct,
} from "../../../../typechain/contracts/interfaces/IOFT.sol/IOFT";
import { IOFT__factory } from "../../../../typechain/factories/contracts/interfaces/IOFT.sol/IOFT__factory";
} from "../../../../typechain/IOFT";
import { IOFT__factory } from "../../../../typechain/factories/IOFT__factory";
import { CHAIN_IDs } from "@across-protocol/constants";

let hubPool: Contract, arbitrumSpokePool: Contract, dai: Contract, weth: Contract, l2UsdtContract: Contract;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ import {
} from "../../../../utils/utils";
import { getOftEid } from "../../../../utils/utils";
import { CHAIN_IDs } from "@across-protocol/constants";
import { IOFT__factory } from "../../../../typechain/factories/contracts/interfaces/IOFT.sol/IOFT__factory";
import { IOFT__factory } from "../../../../typechain/factories/IOFT__factory";
import {
MessagingFeeStructOutput,
MessagingReceiptStructOutput,
OFTReceiptStructOutput,
SendParamStruct,
} from "../../../../typechain/contracts/interfaces/IOFT.sol/IOFT";
} from "../../../../typechain/IOFT";
import { hre } from "../../../../utils/utils.hre";
import { hubPoolFixture } from "../fixtures/HubPool.Fixture";
import { buildRelayerRefundLeaves, buildRelayerRefundTree, constructSingleRelayerRefundTree } from "../MerkleLib.utils";
Expand Down
9 changes: 1 addition & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3993,13 +3993,6 @@
dependencies:
ethers "^5.0.2"

"@typechain/hardhat@^8.0.0":
version "8.0.0"
resolved "https://registry.yarnpkg.com/@typechain/hardhat/-/hardhat-8.0.0.tgz#60568b7a2d0260cc741fb0830a8caee8eb06ac64"
integrity sha512-XUVbqlMx8tJTOmzZCD/r196CidtNWAnTBZRcYxjLTKgcJMvc/kHQpWBnVMMB5QHxVKpYpCiz8g07FYCpG8rrjA==
dependencies:
fs-extra "^9.1.0"

"@types/async-eventemitter@^0.2.1":
version "0.2.1"
resolved "https://registry.yarnpkg.com/@types/async-eventemitter/-/async-eventemitter-0.2.1.tgz#f8e6280e87e8c60b2b938624b0a3530fb3e24712"
Expand Down Expand Up @@ -9710,7 +9703,7 @@ fs-extra@^8.1.0:
jsonfile "^4.0.0"
universalify "^0.1.0"

fs-extra@^9.0.0, fs-extra@^9.1.0:
fs-extra@^9.0.0:
version "9.1.0"
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-9.1.0.tgz#5954460c764a8da2094ba3554bf839e6b9a7c86d"
integrity sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==
Expand Down
Loading