Skip to content

Commit 1ab40f8

Browse files
AztecBotAztecBotjohnathan79717suyash67iakovenkos
authored
feat: merge-train/barretenberg (#15869)
See [merge-train-readme.md](https://github.com/AztecProtocol/aztec-packages/blob/next/.github/workflows/merge-train-readme.md). BEGIN_COMMIT_OVERRIDE chore: delete unused polynomial arithmetic functions (#15864) chore: remove circuit merkle membership. (#15794) chore: assert size == virtual_size in polynomial::evaluate (#15851) chore: remove non-plookup blake2/3s (#15843) chore: refactor MergeSettings to not be used in the MegaCircuitBuilder (#15825) chore!: split aux relation into memory and nnf relations (#15811) END_COMMIT_OVERRIDE --------- Co-authored-by: AztecBot <tech@aztecprotocol.com> Co-authored-by: Jonathan Hao <jonathan@aztec-labs.com> Co-authored-by: Suyash Bagad <suyash@aztecprotocol.com> Co-authored-by: sergei iakovenko <105737703+iakovenkos@users.noreply.github.com> Co-authored-by: Lucas Xia <lucasxia01@gmail.com> Co-authored-by: maramihali <mara@aztecprotocol.com> Co-authored-by: ledwards2225 <98505400+ledwards2225@users.noreply.github.com> Co-authored-by: Maddiaa0 <47148561+Maddiaa0@users.noreply.github.com> Co-authored-by: thunkar <gregojquiros@gmail.com>
1 parent f874bfd commit 1ab40f8

File tree

131 files changed

+5978
-8096
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

131 files changed

+5978
-8096
lines changed

avm-transpiler/Cargo.lock

Lines changed: 264 additions & 531 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

barretenberg/acir_tests/bbjs-test/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const logger = pino({
88
name: "bbjs-test",
99
});
1010

11-
const UH_PROOF_FIELDS_LENGTH = 507; // length of UltraZKHonk flavor
11+
const UH_PROOF_FIELDS_LENGTH = 508; // length of UltraZKHonk flavor
1212
const BYTES_PER_FIELD = 32;
1313
const UH_PROOF_LENGTH_IN_BYTES = UH_PROOF_FIELDS_LENGTH * BYTES_PER_FIELD;
1414

barretenberg/acir_tests/sol-test/src/index.js

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import solc from "solc";
66

77
// Size excluding number of public inputs
88
const NUMBER_OF_FIELDS_IN_PLONK_PROOF = 93;
9-
const NUMBER_OF_FIELDS_IN_HONK_PROOF = 456;
10-
const NUMBER_OF_FIELDS_IN_HONK_ZK_PROOF = 507;
9+
const NUMBER_OF_FIELDS_IN_HONK_PROOF = 457;
10+
const NUMBER_OF_FIELDS_IN_HONK_ZK_PROOF = 508;
1111

1212
const WRONG_PROOF_LENGTH = "0xed74ac0a";
1313
const WRONG_PUBLIC_INPUTS_LENGTH = "0xfa066593";
@@ -165,6 +165,26 @@ const deploy = async (signer, abi, bytecode) => {
165165
return await deployed.getAddress();
166166
};
167167

168+
/**
169+
* Links a library address to bytecode
170+
* @param {string} bytecode - The bytecode with library placeholders
171+
* @param {string} libraryName - The library name
172+
* @param {string} libraryAddress - The deployed library address
173+
* @returns {string} - The linked bytecode
174+
*/
175+
const linkLibrary = (bytecode, libraryName, libraryAddress) => {
176+
// Remove 0x prefix from address if present
177+
const address = libraryAddress.replace(/^0x/, '');
178+
179+
// Library placeholder is __$<keccak256(libraryName)[0:34]>$__
180+
// We need to find and replace this placeholder with the actual address
181+
const placeholder = `__\\$[a-fA-F0-9]{34}\\$__`;
182+
const regex = new RegExp(placeholder, 'g');
183+
184+
// Replace all occurrences of the placeholder with the library address
185+
return bytecode.replace(regex, address);
186+
};
187+
168188
/**
169189
* Takes in a proof as fields, and returns the public inputs, as well as the number of public inputs
170190
* @param {Array<String>} proofAsFields
@@ -258,7 +278,31 @@ try {
258278
const provider = await getProvider(randomPort);
259279
const signer = new ethers.Wallet(key, provider);
260280

261-
const address = await deploy(signer, abi, bytecode);
281+
let finalBytecode = bytecode;
282+
283+
// Deploy ZKTranscript library if needed and link it
284+
if (testingHonk && hasZK) {
285+
// Check if there's a library placeholder in the bytecode
286+
const libraryPlaceholder = /__\$[a-fA-F0-9]{34}\$__/;
287+
if (libraryPlaceholder.test(bytecode)) {
288+
// Get the ZKTranscriptLib contract from compilation output
289+
const zkTranscriptContract = output.contracts["Verifier.sol"]["ZKTranscriptLib"];
290+
if (zkTranscriptContract) {
291+
const libraryBytecode = zkTranscriptContract.evm.bytecode.object;
292+
const libraryAbi = zkTranscriptContract.abi;
293+
294+
// Deploy the library
295+
console.log("Deploying ZKTranscriptLib library...");
296+
const libraryAddress = await deploy(signer, libraryAbi, libraryBytecode);
297+
console.log("ZKTranscriptLib deployed at:", libraryAddress);
298+
299+
// Link the library to the verifier bytecode
300+
finalBytecode = linkLibrary(bytecode, "ZKTranscriptLib", libraryAddress);
301+
}
302+
}
303+
}
304+
305+
const address = await deploy(signer, abi, finalBytecode);
262306
const contract = new ethers.Contract(address, abi, signer);
263307

264308
const result = await contract.test(proofStr, publicInputs);

barretenberg/cpp/scripts/analyze_client_ivc_bench.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ def print_contributions(prefix, ivc_bench_json, bench_name, components):
119119
"Lookup::accumulate(t)",
120120
"DeltaRange::accumulate(t)",
121121
"Elliptic::accumulate(t)",
122-
"Auxiliary::accumulate(t)",
122+
"Memory::accumulate(t)",
123+
"NonNativeField::accumulate(t)",
123124
"EccOp::accumulate(t)",
124125
"DatabusRead::accumulate(t)",
125126
"PoseidonExt::accumulate(t)",

barretenberg/cpp/scripts/test_civc_standalone_vks_havent_changed.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ cd ..
1111
# - Generate a hash for versioning: sha256sum bb-civc-inputs.tar.gz
1212
# - Upload the compressed results: aws s3 cp bb-civc-inputs.tar.gz s3://aztec-ci-artifacts/protocol/bb-civc-inputs-[hash(0:8)].tar.gz
1313
# Note: In case of the "Test suite failed to run ... Unexpected token 'with' " error, need to run: docker pull aztecprotocol/build:3.0
14-
pinned_civc_inputs_url="https://aztec-ci-artifacts.s3.us-east-2.amazonaws.com/protocol/bb-civc-inputs-c373cc52.tar.gz"
14+
pinned_civc_inputs_url="https://aztec-ci-artifacts.s3.us-east-2.amazonaws.com/protocol/bb-civc-inputs-c0333b8c.tar.gz"
1515

1616
# For easily rerunning the inputs generation
1717
if [[ "${1:-}" == "--update_inputs" ]]; then

barretenberg/cpp/src/barretenberg/benchmark/goblin_bench/eccvm.bench.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ Builder generate_trace(size_t target_num_gates)
3737
op_queue->add_accumulate(a);
3838
op_queue->mul_accumulate(b, x);
3939
op_queue->eq_and_reset();
40+
op_queue->merge();
4041
}
4142

4243
Builder builder{ op_queue };

barretenberg/cpp/src/barretenberg/benchmark/relations_bench/relations.bench.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ template <typename Flavor, typename Relation> void execute_relation_for_pg_univa
6565
BENCHMARK(execute_relation_for_pg_univariates<UltraFlavor, UltraArithmeticRelation<Fr>>);
6666
BENCHMARK(execute_relation_for_pg_univariates<UltraFlavor, DeltaRangeConstraintRelation<Fr>>);
6767
BENCHMARK(execute_relation_for_pg_univariates<UltraFlavor, EllipticRelation<Fr>>);
68-
BENCHMARK(execute_relation_for_pg_univariates<UltraFlavor, AuxiliaryRelation<Fr>>);
68+
BENCHMARK(execute_relation_for_pg_univariates<UltraFlavor, MemoryRelation<Fr>>);
69+
BENCHMARK(execute_relation_for_pg_univariates<UltraFlavor, NonNativeFieldRelation<Fr>>);
6970
BENCHMARK(execute_relation_for_pg_univariates<UltraFlavor, LogDerivLookupRelation<Fr>>);
7071
BENCHMARK(execute_relation_for_pg_univariates<UltraFlavor, UltraPermutationRelation<Fr>>);
7172

@@ -79,7 +80,8 @@ BENCHMARK(execute_relation_for_pg_univariates<MegaFlavor, Poseidon2InternalRelat
7980
BENCHMARK(execute_relation_for_univariates<UltraFlavor, UltraArithmeticRelation<Fr>>);
8081
BENCHMARK(execute_relation_for_univariates<UltraFlavor, DeltaRangeConstraintRelation<Fr>>);
8182
BENCHMARK(execute_relation_for_univariates<UltraFlavor, EllipticRelation<Fr>>);
82-
BENCHMARK(execute_relation_for_univariates<UltraFlavor, AuxiliaryRelation<Fr>>);
83+
BENCHMARK(execute_relation_for_univariates<UltraFlavor, MemoryRelation<Fr>>);
84+
BENCHMARK(execute_relation_for_univariates<UltraFlavor, NonNativeFieldRelation<Fr>>);
8385
BENCHMARK(execute_relation_for_univariates<UltraFlavor, LogDerivLookupRelation<Fr>>);
8486
BENCHMARK(execute_relation_for_univariates<UltraFlavor, UltraPermutationRelation<Fr>>);
8587

@@ -93,7 +95,8 @@ BENCHMARK(execute_relation_for_univariates<MegaFlavor, Poseidon2InternalRelation
9395
BENCHMARK(execute_relation_for_values<UltraFlavor, UltraArithmeticRelation<Fr>>);
9496
BENCHMARK(execute_relation_for_values<UltraFlavor, DeltaRangeConstraintRelation<Fr>>);
9597
BENCHMARK(execute_relation_for_values<UltraFlavor, EllipticRelation<Fr>>);
96-
BENCHMARK(execute_relation_for_values<UltraFlavor, AuxiliaryRelation<Fr>>);
98+
BENCHMARK(execute_relation_for_values<UltraFlavor, MemoryRelation<Fr>>);
99+
BENCHMARK(execute_relation_for_values<UltraFlavor, NonNativeFieldRelation<Fr>>);
97100
BENCHMARK(execute_relation_for_values<UltraFlavor, LogDerivLookupRelation<Fr>>);
98101
BENCHMARK(execute_relation_for_values<UltraFlavor, UltraPermutationRelation<Fr>>);
99102

@@ -122,4 +125,4 @@ BENCHMARK(execute_relation_for_values<ECCVMFlavor, ECCVMBoolsRelation<Fq>>);
122125

123126
} // namespace bb::benchmark::relations
124127

125-
BENCHMARK_MAIN();
128+
BENCHMARK_MAIN();

barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/mega_honk.bench.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,6 @@ BENCHMARK_CAPTURE(construct_proof_megahonk,
4949
ecdsa_verification,
5050
&stdlib::generate_ecdsa_verification_test_circuit<MegaCircuitBuilder>)
5151
->Unit(kMillisecond);
52-
BENCHMARK_CAPTURE(construct_proof_megahonk,
53-
merkle_membership,
54-
&stdlib::generate_merkle_membership_test_circuit<MegaCircuitBuilder>)
55-
->Unit(kMillisecond);
5652

5753
BENCHMARK(get_row_power_of_2)
5854
// 2**15 gates to 2**20 gates

barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/mega_zk_honk.bench.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,6 @@ BENCHMARK_CAPTURE(construct_proof_megahonk_zk,
3838
ecdsa_verification,
3939
&stdlib::generate_ecdsa_verification_test_circuit<MegaCircuitBuilder>)
4040
->Unit(kMillisecond);
41-
BENCHMARK_CAPTURE(construct_proof_megahonk_zk,
42-
merkle_membership,
43-
&stdlib::generate_merkle_membership_test_circuit<MegaCircuitBuilder>)
44-
->Unit(kMillisecond);
4541

4642
BENCHMARK(construct_proof_megahonk_power_of_2_zk)
4743
// 2**15 gates to 2**20 gates

barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/mock_circuits.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#include <benchmark/benchmark.h>
33

44
#include "barretenberg/common/assert.hpp"
5-
#include "barretenberg/crypto/merkle_tree/membership.hpp"
65
#include "barretenberg/goblin/mock_circuits.hpp"
76
#include "barretenberg/stdlib/encryption/ecdsa/ecdsa.hpp"
87
#include "barretenberg/stdlib/hash/keccak/keccak.hpp"

0 commit comments

Comments
 (0)