Skip to content
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: Use BB code hash for vk caching #7396

Merged
merged 8 commits into from
Jul 9, 2024
Merged
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
4 changes: 3 additions & 1 deletion noir-projects/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ build-contracts:
SAVE ARTIFACT noir-contracts

build-protocol-circuits:
LOCALLY
LET bb_source_hash = $(cd .. && git ls-tree -r HEAD | grep 'barretenberg/cpp' | awk '{print $3}' | git hash-object --stdin)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very clever line /s

FROM +source
RUN --secret AWS_ACCESS_KEY_ID --secret AWS_SECRET_ACCESS_KEY mkdir -p ~/.aws && \
bash -c 'echo -e "[default]\naws_access_key_id=$AWS_ACCESS_KEY_ID\naws_secret_access_key=$AWS_SECRET_ACCESS_KEY" > ~/.aws/credentials'
RUN cd noir-protocol-circuits && NARGO=nargo ./bootstrap.sh
RUN cd noir-protocol-circuits && BB_HASH=$bb_source_hash NARGO=nargo ./bootstrap.sh
SAVE ARTIFACT noir-protocol-circuits

build:
Expand Down
6 changes: 4 additions & 2 deletions noir-projects/noir-protocol-circuits/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ echo "Compiling protocol circuits..."
NARGO=${NARGO:-../../noir/noir-repo/target/release/nargo}
$NARGO compile --silence-warnings --use-legacy

BB_HASH=${BB_HASH:-$(cd ../../ && git ls-tree -r HEAD | grep 'barretenberg/cpp' | awk '{print $3}' | git hash-object --stdin)}
echo Using BB hash $BB_HASH
mkdir -p "./target/keys"

AVAILABLE_MEMORY=0
Expand All @@ -43,14 +45,14 @@ if [[ AVAILABLE_MEMORY -lt MIN_PARALLEL_VK_GENERATION_MEMORY ]]; then
echo "System does not have enough memory for parallel vk generation, falling back to sequential"

for pathname in "./target"/*.json; do
node ./scripts/generate_vk_json.js "$pathname" "./target/keys"
BB_HASH=$BB_HASH node ./scripts/generate_vk_json.js "$pathname" "./target/keys"
done

else

echo "Generating vks in parallel..."
for pathname in "./target"/*.json; do
node ./scripts/generate_vk_json.js "$pathname" "./target/keys" &
BB_HASH=$BB_HASH node ./scripts/generate_vk_json.js "$pathname" "./target/keys" &
done

for job in $(jobs -p); do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ async function getBytecodeHash(artifactPath) {
}

function getBarretenbergHash() {
if (process.env.BB_HASH) {
return Promise.resolve(process.env.BB_HASH);
}
return new Promise((res, rej) => {
const hash = crypto.createHash("md5");

Expand Down
Loading