-
Notifications
You must be signed in to change notification settings - Fork 227
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: compiler path issue with compiler breakable changes (#1212)
* fix: compiler path issue with compiler breakable changes * fix: update tests with env values and provide amd url for the compiler * fix: update tests and revert older validation for breakable compiler version * chore: spell fix * fix: revert validation to be consistent --------- Co-authored-by: Marko Arambasic <[email protected]>
- Loading branch information
1 parent
a7b57f6
commit c4231d9
Showing
23 changed files
with
507 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module.exports = { | ||
extends: [`${__dirname}/../../config/eslint/eslintrc.cjs`], | ||
parserOptions: { | ||
project: `${__dirname}/tsconfig.json`, | ||
sourceType: "module", | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
cache | ||
artifacts | ||
contracts/tmp | ||
deployments |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# ZKsync Era deploy environment example | ||
|
||
This project demonstrates how to compile and deploy your contracts in ZKsync Era using the Hardhat plugins. | ||
|
||
## Prerequisites | ||
|
||
- node.js 16.x or later. | ||
- yarn. | ||
|
||
## Configuration | ||
|
||
Plugin configuration is located in [`hardhat.config.ts`](./hardhat.config.ts). | ||
You should only change the ZKsync network configuration. | ||
|
||
`hardhat.config.ts` example with ZKsync network configured with the name `ZKsyncNetwork` and `ethNetwork` used as the underlying layer 1 network: | ||
```ts | ||
import "@matterlabs/hardhat-zksync-deploy"; | ||
import { HardhatUserConfig } from 'hardhat/types'; | ||
|
||
const config: HardhatUserConfig = { | ||
networks: { | ||
ethNetwork: { | ||
url: 'http://0.0.0.0:8545', | ||
}, | ||
ZKsyncNetwork: { | ||
url: 'http://0.0.0.0:3050', | ||
ethNetwork: 'ethNetwork', | ||
zksync: true, | ||
deployPaths: ['deploy-ZKsync', 'deploy'], | ||
accounts: ['0xac1e735be8536c6534bb4f17f06f6afc73b2b5ba84ac2cfb12f7461b20c0bbe3', '0x28a574ab2de8a00364d5dd4b07c4f2f574ef7fcc2a86a197f65abaec836d1959'], | ||
}, | ||
} | ||
}; | ||
|
||
export default config; | ||
``` | ||
|
||
## Usage | ||
|
||
Before using plugins, you need to build them first | ||
|
||
```sh | ||
# Run the following in the *root* of the repo. | ||
yarn | ||
yarn build | ||
``` | ||
Setup your `ZKSOLC_PATH` path inside your `.env` file | ||
|
||
After that you should be able to run plugins: | ||
|
||
```sh | ||
# Run the following in `examples/basic-example` folder. | ||
yarn | ||
yarn hardhat compile | ||
yarn hardhat deploy-zksync | ||
``` | ||
|
||
- `yarn hardhat compile`: compiles all the contracts in the `contracts` folder. | ||
- `yarn hardhat deploy-zksync`: runs all the deploy scripts. | ||
- To run a specific script, add the `--script` argument, e.g. `--script 002_deploy.ts`. | ||
- To run on a specific ZKsync network, use standard hardhat `--network` argument, e.g. `--network ZKsyncNetworkV2` | ||
(with `ZKsyncNetwork` network specified in the `hardhat.config` networks section, with the `zksync` flag set to `true` and `ethNetwork` specified). | ||
|
||
If you don't specify ZKsync network (`--network`), `local-setup` with <http://localhost:8545> (Ethereum RPC URL) and <http://localhost:3050> (ZKsync RPC URL) will be used. |
12 changes: 12 additions & 0 deletions
12
examples/download-with-compiler-origin/contracts/Constant.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.0; | ||
|
||
contract Constant { | ||
uint c = 42; | ||
constructor() {} | ||
|
||
function getValue() public view returns (uint) { | ||
return c; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.0; | ||
|
||
contract Foo { | ||
string public name = "Foo"; | ||
} |
18 changes: 18 additions & 0 deletions
18
examples/download-with-compiler-origin/contracts/Greeter.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.0; | ||
|
||
contract Greeter { | ||
string greeting; | ||
constructor(string memory _greeting) { | ||
greeting = _greeting; | ||
} | ||
|
||
function greet() public view returns (string memory) { | ||
return greeting; | ||
} | ||
|
||
function setGreeting(string memory _greeting) public { | ||
greeting = _greeting; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
examples/download-with-compiler-origin/deploy/003_deploy.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { HardhatRuntimeEnvironment } from 'hardhat/types'; | ||
import chalk from 'chalk'; | ||
|
||
const deployScript = async function (hre: HardhatRuntimeEnvironment) { | ||
console.info(chalk.yellow(`Running deploy script for the Constant contract from deploy folder`)); | ||
|
||
// Load the artifact we want to deploy. | ||
|
||
// Deploy this contract. The returned object will be of a `Contract` type, similarly to ones in `ethers`. | ||
// This contract has no constructor arguments. | ||
const factoryContract = await hre.deployer.deploy('Constant'); | ||
|
||
// Show the contract info. | ||
const contractAddress = await factoryContract.getAddress(); | ||
console.info(chalk.green(`Constant was deployed to ${contractAddress}!`)); | ||
}; | ||
|
||
export default deployScript; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import '@matterlabs/hardhat-zksync-deploy'; | ||
import '@matterlabs/hardhat-zksync-solc'; | ||
|
||
import { HardhatUserConfig } from 'hardhat/config'; | ||
require('dotenv').config(); | ||
|
||
const config: HardhatUserConfig = { | ||
zksolc: { | ||
compilerSource: 'binary', | ||
settings: { | ||
compilerPath: process.env.ZKSOLC_PATH, | ||
enableEraVMExtensions: true, | ||
optimizer: { | ||
enabled: true, | ||
}, | ||
} | ||
}, | ||
deployerAccounts: { | ||
'ZKsyncNetwork': 1 | ||
}, | ||
defaultNetwork: "ZKsyncNetwork", | ||
networks: { | ||
hardhat: { | ||
zksync: true, | ||
}, | ||
ethNetwork: { | ||
url: 'http://0.0.0.0:8545', | ||
}, | ||
ZKsyncNetwork: { | ||
url: 'http://0.0.0.0:3050', | ||
ethNetwork: 'ethNetwork', | ||
zksync: true, | ||
accounts: ['0xac1e735be8536c6534bb4f17f06f6afc73b2b5ba84ac2cfb12f7461b20c0bbe3', '0x28a574ab2de8a00364d5dd4b07c4f2f574ef7fcc2a86a197f65abaec836d1959'], | ||
}, | ||
}, | ||
// Docker image only works for solidity ^0.8.0. | ||
// For earlier versions you need to use binary releases of zksolc. | ||
solidity: { | ||
version: '0.8.17', | ||
}, | ||
}; | ||
|
||
export default config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
{ | ||
"name": "hardhat-zksync-example-compiler-origin", | ||
"version": "0.1.0", | ||
"author": "Matter Labs", | ||
"license": "MIT", | ||
"scripts": { | ||
"lint": "pnpm eslint", | ||
"prettier:check": "pnpm prettier --check", | ||
"lint:fix": "pnpm eslint --fix", | ||
"fmt": "pnpm prettier --write", | ||
"eslint": "eslint deploy/*.ts", | ||
"prettier": "prettier deploy/*.ts", | ||
"test": "mocha test/tests.ts --exit", | ||
"build": "tsc --build .", | ||
"clean": "rimraf dist" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^18.11.17", | ||
"@typescript-eslint/eslint-plugin": "^7.12.0", | ||
"@typescript-eslint/parser": "^7.12.0", | ||
"eslint": "^8.56.0", | ||
"eslint-config-prettier": "^9.1.0", | ||
"eslint-plugin-import": "^2.29.1", | ||
"eslint-plugin-no-only-tests": "^3.1.0", | ||
"eslint-plugin-prettier": "^5.0.1", | ||
"prettier": "3.3.0", | ||
"rimraf": "^5.0.7", | ||
"ts-node": "^10.9.2", | ||
"typescript": "^5.3.0", | ||
"dotenv": "^16.4.5" | ||
}, | ||
"dependencies": { | ||
"@matterlabs/hardhat-zksync-deploy": "workspace:^", | ||
"@matterlabs/hardhat-zksync-solc": "workspace:^", | ||
"chalk": "^4.1.2", | ||
"hardhat": "^2.22.5", | ||
"ethers": "^6.12.2", | ||
"zksync-ethers": "^6.8.0" | ||
}, | ||
"prettier": { | ||
"tabWidth": 4, | ||
"printWidth": 120, | ||
"parser": "typescript", | ||
"singleQuote": true, | ||
"bracketSpacing": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es5", | ||
"module": "commonjs", | ||
"strict": true, | ||
"esModuleInterop": true, | ||
"moduleResolution": "node", | ||
"forceConsistentCasingInFileNames": true, | ||
"outDir": "dist" | ||
}, | ||
"include": [ | ||
"./hardhat.config.ts", | ||
"./scripts", | ||
"./test", | ||
"typechain/**/*", | ||
"deploy/*", | ||
"deploy-ZKsync/*" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.