Skip to content
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
b981a7f
more tests, tentative trace
Thunkar Mar 27, 2025
0717740
Increase capacity to 17 kernels
codygunton Mar 27, 2025
789dd62
better test org
Thunkar Mar 27, 2025
50a1962
restored trace
Thunkar Mar 27, 2025
c2ab6b4
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar Mar 27, 2025
8e913f6
Merge branch 'cg/bump-translator' of github.com:AztecProtocol/aztec-p…
Thunkar Mar 27, 2025
462e622
magic trace
Thunkar Mar 28, 2025
aac2f41
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar Mar 28, 2025
9a4a279
monke
Thunkar Mar 28, 2025
7cfef13
Revert "Increase capacity to 17 kernels"
Thunkar Mar 28, 2025
084f0a1
bb so fast I had to batch logs in playground
Thunkar Mar 28, 2025
48987af
skip permutation relation when possible
Mar 28, 2025
0957ad2
allocate and deallocate full commitment key
Mar 28, 2025
dc21609
add worktodo and comments about constants
Mar 28, 2025
3e37928
Merge branch 'cg/bump-translator' of github.com:AztecProtocol/aztec-p…
Thunkar Mar 28, 2025
d7232f2
don't deallocate at then end
Mar 28, 2025
9e616fd
Merge branch 'cg/bump-translator' of github.com:AztecProtocol/aztec-p…
Thunkar Mar 28, 2025
672001d
benchmark parametrization
Thunkar Mar 28, 2025
f0046f3
wtf
Thunkar Mar 28, 2025
8d9c2a3
allow pointing bb.js node to any bb wasm
Thunkar Mar 28, 2025
6470771
Fix extra import
nventuro Mar 28, 2025
04a079d
use actual circuit content to size translator polynomials
ledwards2225 Mar 31, 2025
40a9af8
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar Mar 31, 2025
ba92312
Merge branch 'cg/bump-translator' of github.com:AztecProtocol/aztec-p…
Thunkar Mar 31, 2025
fef826a
Update barretenberg/cpp/src/barretenberg/eccvm/eccvm_flavor.hpp
Thunkar Mar 31, 2025
541aeb9
separated config
Thunkar Mar 31, 2025
e82166f
Merge branch 'gj/more_benchmarks' of github.com:AztecProtocol/aztec-p…
Thunkar Mar 31, 2025
b889e70
add comments
Thunkar Mar 31, 2025
1685c1f
Merge branch 'master' into gj/more_benchmarks
Thunkar Mar 31, 2025
34f566b
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar Mar 31, 2025
30625c9
reverted bb changes
Thunkar Mar 31, 2025
0dd7588
error from another branch
Thunkar Mar 31, 2025
c006784
removed unused var
Thunkar Mar 31, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ void ClientIVC::accumulate(ClientCircuit& circuit,

// The commitment key is initialised with the number of points determined by the trace_settings' dyadic size. If a
// circuit overflows past the dyadic size the commitment key will not have enough points so we need to increase it
// WORKTODO: we need to check that the size we set here is also enough to commit to the polynomials in translator
if (proving_key->proving_key.circuit_size > trace_settings.dyadic_size()) {
bn254_commitment_key = std::make_shared<CommitmentKey<curve::BN254>>(proving_key->proving_key.circuit_size);
goblin.commitment_key = bn254_commitment_key;
Expand Down
2 changes: 2 additions & 0 deletions barretenberg/cpp/src/barretenberg/eccvm/eccvm_flavor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ class ECCVMFlavor {
// Indicates that this flavor runs with ZK Sumcheck.
static constexpr bool HasZK = true;
// Fixed size of the ECCVM circuits used in ClientIVC
// Important: these constants cannot be arbitrarily changes - please consult with a member of the Crypto team if
// they become too small.
static constexpr size_t ECCVM_FIXED_SIZE = 1UL << CONST_ECCVM_LOG_N;

static constexpr size_t NUM_WIRES = 85;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,15 +331,15 @@ static constexpr TraceStructure EXAMPLE_20{ .ecc_op = 1 << 11,
* @brief Structuring tailored to the full e2e TS test (TO BE UPDATED ACCORDINGLY)
*/
static constexpr TraceStructure E2E_FULL_TEST_STRUCTURE{ .ecc_op = 1 << 10,
.busread = 6000,
.lookup = 200000,
.pub_inputs = 4000,
.arithmetic = 200000,
.delta_range = 25000,
.elliptic = 80000,
.aux = 100000,
.poseidon2_external = 45192,
.poseidon2_internal = 258000,
.busread = 5000,
.lookup = 15000,
.pub_inputs = 2000,
.arithmetic = 56000,
.delta_range = 18000,
.elliptic = 6000,
.aux = 26000,
.poseidon2_external = 17000,
.poseidon2_internal = 92000,
.overflow = 0 };

template <typename T>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@ template <typename FF_> class TranslatorPermutationRelationImpl {
3 // left-shiftable polynomial sub-relation
};

/**
* @brief Returns true if the contribution from all subrelations for the provided inputs is identically zero
*
*/
template <typename AllEntities> inline static bool skip(const AllEntities& in)
{
// If z_perm == z_perm_shift, this implies that none of the wire values for the present input are involved in
// non-trivial copy constraints.
return (in.z_perm - in.z_perm_shift).is_zero();
}

inline static auto& get_grand_product_polynomial(auto& in) { return in.z_perm; }
inline static auto& get_shifted_grand_product_polynomial(auto& in) { return in.z_perm_shift; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@ class TranslatorFlavor {

// A minicircuit of such size allows for 10 rounds of folding (i.e. 20 circuits).
// Lowest possible size for the translator circuit (this sets the mini_circuit_size)
// Important: these constants cannot be arbitrarily changes - please consult with a member of the Crypto team if
// they become too small.
static constexpr size_t MINIMUM_MINI_CIRCUIT_SIZE = 2048;
static constexpr size_t TRANSLATOR_VM_FIXED_SIZE = 8192;
static constexpr size_t TRANSLATOR_VM_FIXED_SIZE = 16384;
static_assert(TRANSLATOR_VM_FIXED_SIZE >= MINIMUM_MINI_CIRCUIT_SIZE);

// The size of the circuit which is filled with non-zero values for most polynomials. Most relations (everything
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,14 @@ void TranslatorProver::execute_relation_check_rounds()
gate_challenges[idx] = transcript->template get_challenge<FF>("Sumcheck:gate_challenge_" + std::to_string(idx));
}

const size_t log_subgroup_size = static_cast<size_t>(numeric::get_msb(Flavor::Curve::SUBGROUP_SIZE));
// Create a temporary commitment key that is only used to initialise the ZKSumcheckData
// If proving in WASM, the commitment key that is part of the Translator proving key remains deallocated
// until we enter the PCS round
auto ck = std::make_shared<CommitmentKey>(1 << (log_subgroup_size + 1));

// // create masking polynomials for sumcheck round univariates and auxiliary data
zk_sumcheck_data = ZKData(key->proving_key->log_circuit_size, transcript, key->proving_key->commitment_key);
zk_sumcheck_data = ZKData(key->proving_key->log_circuit_size, transcript, ck);

sumcheck_output =
sumcheck.prove(key->proving_key->polynomials, relation_parameters, alpha, gate_challenges, zk_sumcheck_data);
Expand All @@ -154,11 +160,12 @@ void TranslatorProver::execute_pcs_rounds()
using SmallSubgroupIPA = SmallSubgroupIPAProver<Flavor>;
using PolynomialBatcher = GeminiProver_<Curve>::PolynomialBatcher;

SmallSubgroupIPA small_subgroup_ipa_prover(zk_sumcheck_data,
sumcheck_output.challenge,
sumcheck_output.claimed_libra_evaluation,
transcript,
key->proving_key->commitment_key);
// Check whether the commitment key has been deallocated and reinitialise it if necessary
auto& ck = key->proving_key->commitment_key;
ck = ck ? ck : std::make_shared<CommitmentKey>(key->proving_key->circuit_size);

SmallSubgroupIPA small_subgroup_ipa_prover(
zk_sumcheck_data, sumcheck_output.challenge, sumcheck_output.claimed_libra_evaluation, transcript, ck);
small_subgroup_ipa_prover.prove();

PolynomialBatcher polynomial_batcher(key->proving_key->circuit_size);
Expand All @@ -171,11 +178,11 @@ void TranslatorProver::execute_pcs_rounds()
ShpleminiProver_<Curve>::prove(key->proving_key->circuit_size,
polynomial_batcher,
sumcheck_output.challenge,
key->proving_key->commitment_key,
ck,
transcript,
small_subgroup_ipa_prover.get_witness_polynomials());

PCS::compute_opening_proof(key->proving_key->commitment_key, prover_opening_claim, transcript);
PCS::compute_opening_proof(ck, prover_opening_claim, transcript);
}

HonkProof TranslatorProver::export_proof()
Expand All @@ -198,6 +205,11 @@ HonkProof TranslatorProver::construct_proof()
// Compute grand product(s) and commitments.
execute_grand_product_computation_round();

// #ifndef __wasm__
// Free the commitment key
key->proving_key->commitment_key = nullptr;
// #endif

// Fiat-Shamir: alpha
// Run sumcheck subprotocol.
execute_relation_check_rounds();
Expand All @@ -206,7 +218,6 @@ HonkProof TranslatorProver::construct_proof()
// Execute Shplemini PCS
execute_pcs_rounds();
vinfo("computed opening proof");

return export_proof();
}

Expand Down
17 changes: 14 additions & 3 deletions barretenberg/ts/src/barretenberg_wasm/fetch_code/node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,18 @@ function getCurrentDir() {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export async function fetchCode(multithreaded: boolean, wasmPath?: string) {
const path = wasmPath ?? getCurrentDir() + '/../../barretenberg-threads.wasm.gz';
const compressedData = await readFile(path);
const decompressedData = pako.ungzip(new Uint8Array(compressedData));
return decompressedData.buffer;
const maybeCompressedData = await readFile(path);
const buffer = new Uint8Array(maybeCompressedData);
const isGzip =
// Check magic number
buffer[0] === 0x1f &&
buffer[1] === 0x8b &&
// Check compression method:
buffer[2] === 0x08;
if (isGzip) {
const decompressedData = pako.ungzip(buffer);
return decompressedData.buffer;
} else {
return buffer;
}
}
39 changes: 29 additions & 10 deletions playground/src/aztecEnv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ import { NetworkDB, WalletDB } from './utils/storage';
import { type ContractFunctionInteractionTx } from './utils/txs';

const logLevel = ['silent', 'fatal', 'error', 'warn', 'info', 'verbose', 'debug', 'trace'] as const;
type LogLevel = (typeof logLevel)[number];

type Log = {
type: (typeof logLevel)[number];
id: string;
type: LogLevel;
timestamp: number;
prefix: string;
message: string;
Expand All @@ -30,10 +32,23 @@ export class WebLogger {
private static instance: WebLogger;
private logs: Log[] = [];

private constructor(private setLogs: (logs: Log[]) => void) {}
private static updateIntervalMs = 1000;
private static readonly MAX_LOGS_TO_KEEP = 200;

private pendingUpdate = true;

private constructor() {}

static create(setLogs: (logs: Log[]) => void) {
WebLogger.instance = new WebLogger(setLogs);
if (!WebLogger.instance) {
WebLogger.instance = new WebLogger();
setInterval(() => {
const instance = WebLogger.getInstance();
const newLogs = instance.logs.slice(0, WebLogger.MAX_LOGS_TO_KEEP).sort((a, b) => b.timestamp - a.timestamp);
setLogs(newLogs);
instance.pendingUpdate = false;
}, WebLogger.updateIntervalMs);
}
}

static getInstance() {
Expand All @@ -44,12 +59,11 @@ export class WebLogger {
return new Proxy(createLogger(prefix), {
get: (target, prop) => {
if (logLevel.includes(prop as (typeof logLevel)[number])) {
return function () {
// eslint-disable-next-line prefer-rest-params
const args = [prop, prefix, ...arguments] as Parameters<WebLogger['handleLog']>;
return function (this: Logger, ...data: Parameters<Logger[LogLevel]>) {
const loggingFn = prop as LogLevel;
const args = [loggingFn, prefix, ...data] as Parameters<WebLogger['handleLog']>;
WebLogger.getInstance().handleLog(...args);
// eslint-disable-next-line prefer-rest-params
target[prop].apply(this, arguments);
target[loggingFn].call(this, ...[data[0], data[1]]);
};
} else {
return target[prop];
Expand All @@ -65,8 +79,13 @@ export class WebLogger {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
data: any,
) {
this.logs.unshift({ type, prefix, message, data, timestamp: Date.now() });
this.setLogs([...this.logs]);
this.logs.unshift({ id: this.randomId(), type, prefix, message, data, timestamp: Date.now() });
this.pendingUpdate = true;
}

private randomId(): string {
const uint32 = window.crypto.getRandomValues(new Uint32Array(1))[0];
return uint32.toString(16);
}
}

Expand Down
2 changes: 1 addition & 1 deletion playground/src/components/logPanel/logPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export function LogPanel() {
</StyledBox>
<StyledBox sx={{ px: 0.5, height: '100%', overflow: 'auto' }}>
{logs.map((log, index) => (
<div key={`${log.timestamp}-${log.message}`} css={logContainer}>
<div key={log.id} css={logContainer}>
<div css={logPrefix}>
<Typography variant="subtitle2">{log.prefix}:&nbsp;</Typography>
</div>
Expand Down
Loading
Loading