New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: improve zk init perfromance #1774
base: main
Are you sure you want to change the base?
Conversation
|
||
const CONTRACTS_DIR = 'contracts'; | ||
const OUTPUT_DIR = 'artifacts-zk'; | ||
const TIMESTAMP_FILE = 'last_compilation.timestamp'; // File to store the last compilation time |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think is used in multiple places, maybe you can have them in utils and import them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it follows the same logic as the lines above, then we'd want to put CONTRACTS_DIR and OUTPUT_DIR in utils as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, very good idea
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
Also kl-factory has been merged, please rebase on and merge main |
@@ -46,20 +45,7 @@ export async function externalNode(reinit: boolean = false, args: string[]) { | |||
|
|||
async function create_genesis(cmd: string) { | |||
await utils.confirmAction(); | |||
await utils.spawn(`${cmd} | tee genesis.log`); | |||
|
|||
const date = new Date(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we not keep this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a discussion where it seems that we're not using these logs anymore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mm-zk is it fine if we remove these log from here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIK yes. @Deniallugo - FYI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't think we need this function at all
98bd13e
to
5ca72d9
Compare
1aebd66
to
7f0d1e3
Compare
@@ -46,20 +45,7 @@ export async function externalNode(reinit: boolean = false, args: string[]) { | |||
|
|||
async function create_genesis(cmd: string) { | |||
await utils.confirmAction(); | |||
await utils.spawn(`${cmd} | tee genesis.log`); | |||
|
|||
const date = new Date(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIK yes. @Deniallugo - FYI.
TIMESTAMP_FILE | ||
} from './utils'; | ||
|
||
async function main() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add comment - describing what we're doing here (using some .timestamp file to record the last time that files were changed)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems that it was not done.
I'm looking for a 2-line comment, where reader can quickly see what's special about this 'build' script, without having to read the details of the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure it's the right move.
We could solve in two ways:
- Move l2 contracts compilation to foundry zksync
- Use the prebuild contracts from the repo. we do pulbish built contracts
// Determine if recompilation is needed | ||
export function needsRecompilation(folder: string, timestampFile: string): boolean { | ||
const lastCompilationTime = getLastCompilationTime(timestampFile); | ||
const latestModificationTime = getLatestModificationTime(folder); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do these sources have any dependencies on outside dirs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -9,8 +9,8 @@ | |||
"fee-test": "RUN_FEE_TEST=1 zk f jest -- fees.test.ts", | |||
"api-test": "zk f jest -- api/web3.test.ts api/debug.test.ts", | |||
"contract-verification-test": "zk f jest -- api/contract-verification.test.ts", | |||
"build": "hardhat compile", | |||
"build-yul": "hardhat run scripts/compile-yul.ts" | |||
"build": "yarn ts-node scripts/build.ts", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: do you actually have to say 'yarn' here? I thought that "ts-node XX" should be enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
both will work, however 'yarn ts-node' is a safer choice in monorepo environment as it ensure execution in the context of yarn workspace.
TIMESTAMP_FILE | ||
} from './utils'; | ||
|
||
async function main() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems that it was not done.
I'm looking for a 2-line comment, where reader can quickly see what's special about this 'build' script, without having to read the details of the code.
@@ -0,0 +1,159 @@ | |||
import * as fs from 'fs'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you are repeating the same file twice, that's not good, as it will be harder to manage and update in the future.
Could it be some shared library instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
switch to sync call, so it's 1 library
import { exec } from 'child_process'; | ||
|
||
async function main() { | ||
const timestampFilePath = path.join(process.cwd(), TIMESTAMP_FILE); // File stores the timestamp of last compilation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you are repeating this twice (as it already exists in the other build.rs) - maybe move it to a shared util instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's right, I was thinking of it, but as these are different workspaces, I was not sure if a shared util is a good idea
Folks, what's the status of this PR? |
What ❔
Avoiding unnecessary compilation of smart contracts
Fixes EVM-551
Why ❔
Hardhat cache is not working as expected or scripts are being use for compilation
Checklist
zk fmt
andzk lint
.zk spellcheck
.zk linkcheck
.