From 4272477e9a132ba7f36c24a14a4ac15ea65f1c65 Mon Sep 17 00:00:00 2001 From: Marko Arambasic <131957563+kiriyaga-txfusion@users.noreply.github.com> Date: Thu, 5 Sep 2024 11:23:45 +0200 Subject: [PATCH] fix: add gnu toolchain for linux as default from compiler version 1.5.4 (#1359) Co-authored-by: Marko Arambasic --- packages/hardhat-zksync-vyper/src/constants.ts | 2 ++ packages/hardhat-zksync-vyper/src/utils.ts | 14 +++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/packages/hardhat-zksync-vyper/src/constants.ts b/packages/hardhat-zksync-vyper/src/constants.ts index 7d49ee439..01caa7ff8 100644 --- a/packages/hardhat-zksync-vyper/src/constants.ts +++ b/packages/hardhat-zksync-vyper/src/constants.ts @@ -37,6 +37,8 @@ export const DEFAULT_COMPILER_VERSION_INFO_CACHE_PERIOD = 24 * 60 * 60 * 1000; / export const ZKVYPER_COMPILER_MIN_VERSION_WITH_FALLBACK_OZ = '1.3.15'; +export const COMPILER_MIN_LINUX_VERSION_WITH_GNU_TOOLCHAIN = '1.5.4'; + export const COMPILER_VERSION_INFO_FILE_NOT_FOUND_ERROR = 'Could not find zkvyper compiler version info file. Please check your internet connection and try again.'; export const COMPILER_VERSION_INFO_FILE_DOWNLOAD_ERROR = diff --git a/packages/hardhat-zksync-vyper/src/utils.ts b/packages/hardhat-zksync-vyper/src/utils.ts index 442213a6e..864e8ee7c 100644 --- a/packages/hardhat-zksync-vyper/src/utils.ts +++ b/packages/hardhat-zksync-vyper/src/utils.ts @@ -9,7 +9,12 @@ import type { Dispatcher } from 'undici'; import { MultiVyperConfig } from '@nomiclabs/hardhat-vyper/dist/src/types'; import { CompilerVersionInfo } from './compile/downloader'; -import { DEFAULT_TIMEOUT_MILISECONDS, UNSUPPORTED_VYPER_VERSIONS, VYPER_VERSION_ERROR } from './constants'; +import { + COMPILER_MIN_LINUX_VERSION_WITH_GNU_TOOLCHAIN, + DEFAULT_TIMEOUT_MILISECONDS, + UNSUPPORTED_VYPER_VERSIONS, + VYPER_VERSION_ERROR, +} from './constants'; import { ZkSyncVyperPluginError } from './errors'; const TEMP_FILE_PREFIX = 'tmp-'; @@ -22,8 +27,11 @@ export function zeroxlify(hex: string): string { export function getZkvyperUrl(repo: string, version: string, isRelease: boolean = true): string { // @ts-ignore const platform = { darwin: 'macosx', linux: 'linux', win32: 'windows' }[process.platform]; - // @ts-ignore - const toolchain = { linux: '-musl', win32: '-gnu', darwin: '' }[process.platform]; + const toolchain = semver.lt(version, COMPILER_MIN_LINUX_VERSION_WITH_GNU_TOOLCHAIN) + ? // @ts-ignore + { linux: '-musl', win32: '-gnu', darwin: '' }[process.platform] + : // @ts-ignore + { linux: '-gnu', win32: '-gnu', darwin: '' }[process.platform]; const arch = process.arch === 'x64' ? 'amd64' : process.arch; const ext = process.platform === 'win32' ? '.exe' : '';