Skip to content

Commit 1bb068f

Browse files
author
AztecBot
committed
Merge branch 'next' into ad/chore/ci-release-pr-canary
2 parents 2dd559c + d8c49fc commit 1bb068f

File tree

9 files changed

+55
-37
lines changed

9 files changed

+55
-37
lines changed

noir-projects/aztec-nr/aztec/src/note/note_getter.nr

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,13 +164,26 @@ where
164164
let filtered_notes = filter_fn(maybe_hinted_notes, filter_args);
165165

166166
let hinted_notes = array::collapse(filtered_notes);
167-
let mut confirmed_notes = BoundedVec::new();
168167

169168
// We have now collapsed the sparse array of Options into a BoundedVec. This is a more ergonomic type and also
170169
// results in reduced gate counts when setting a limit value, since we guarantee that the limit is an upper bound
171170
// for the runtime length, and can therefore have fewer loop iterations.
172171
assert(hinted_notes.len() <= options.limit, "Got more notes than limit.");
173172

173+
// What remains is to iterate over the hinted notes, assert their existence, and convert them into confirmed notes.
174+
// Naively, we would construct a `BoundedVec<ConfirmedNote, _>` and simply `push` into it as we process each hinted
175+
// note. We cannot use `BoundedVec::map` as the user specified the maximum number of notes in `options.limit`
176+
// instead of a numeric type parameter (which is more ergonomic), and `map` requires the latter.
177+
// Unfortunately, this results in terrible proving time performance. This is because the compiler is not smart
178+
// enough to understand the structure of looping over the `BoundedVec<HintedNote, _>`: it treats every `push` as a
179+
// conditional write to the confirmed array, resulting in runtime write indices (e.g. iteration 1 could write to
180+
// indices either 0 or 1, beucase iteration 0 might not push).
181+
// The loop does however have an interesting structure that we can reason about to achieve better performance:
182+
// because we're just going over a `BoundedVec`, the first `vec.len()` iterations will result in writes, and the
183+
// rest will not. Hence, we can just _unconditionally_ write to a raw storage array at the iteration index: we know
184+
// the resulting array will have no gaps. Because of this, we can then manually create a correct `BoundedVec`.
185+
let mut confirmed_notes_bvec_storage: [ConfirmedNote<_>; _] = std::mem::zeroed();
186+
174187
let mut prev_packed_note = [0; M];
175188
for i in 0..options.limit {
176189
if i < hinted_notes.len() {
@@ -204,11 +217,14 @@ where
204217

205218
let note_existence_request = compute_note_existence_request(hinted_note);
206219
context.assert_note_exists(note_existence_request);
207-
confirmed_notes.push(ConfirmedNote::new(hinted_note, note_existence_request.note_hash()));
220+
221+
confirmed_notes_bvec_storage[i] = ConfirmedNote::new(hinted_note, note_existence_request.note_hash());
208222
};
209223
}
210224

211-
confirmed_notes
225+
// We can use `from_parts_unchecked` instead of `from_parts` because we know that `confirmed_notes_bvec_storage`
226+
// contains all zeroes past `hinted_notes.len()` due to how it was initialized.
227+
BoundedVec::from_parts_unchecked(confirmed_notes_bvec_storage, hinted_notes.len())
212228
}
213229

214230
pub unconstrained fn view_note<Note>(owner: Option<AztecAddress>, storage_slot: Field) -> HintedNote<Note>

noir-projects/noir-protocol-circuits/crates/blob/src/abis/batching_blob_commitment.nr

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use bigcurve::BigCurve;
44
use bignum::{BigNum, BLS12_381_Fq};
55
use types::{
66
constants::BLS12_POINT_COMPRESSED_BYTES,
7-
traits::Empty,
87
utils::{arrays::subarray, field::field_from_bytes},
98
};
109

@@ -40,9 +39,3 @@ impl Eq for BatchingBlobCommitment {
4039
(self.point.eq(other.point)) & (self.compressed.eq(other.compressed))
4140
}
4241
}
43-
44-
impl Empty for BatchingBlobCommitment {
45-
fn empty() -> Self {
46-
Self { point: BLSPoint::point_at_infinity(), compressed: [0; BLS12_POINT_COMPRESSED_BYTES] }
47-
}
48-
}

playground/src/components/navbar/components/WalletHub.tsx

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,9 @@ export function WalletHub() {
167167
establishSecureChannel: async () => {
168168
throw new Error('Embedded wallet should use directConnect');
169169
},
170+
disconnect: async () => {},
171+
onDisconnect: () => () => {},
172+
isDisconnected: () => false,
170173
callback: () => {
171174
setOpenWalletModal(true);
172175
},
@@ -200,7 +203,7 @@ export function WalletHub() {
200203
setLoading(true);
201204
setOpen(false);
202205

203-
if (selectedProvider && selectedProvider.disconnect) {
206+
if (selectedProvider) {
204207
if (disconnectUnsubscribeRef.current) {
205208
disconnectUnsubscribeRef.current();
206209
disconnectUnsubscribeRef.current = null;
@@ -255,15 +258,13 @@ export function WalletHub() {
255258
setSelectedProvider(pendingProvider);
256259
setIsEmbeddedWalletSelected(false);
257260

258-
if (pendingProvider.onDisconnect) {
259-
disconnectUnsubscribeRef.current = pendingProvider.onDisconnect(() => {
260-
setWallet(null);
261-
setSelectedProvider(null);
262-
setFrom(null);
263-
disconnectUnsubscribeRef.current = null;
264-
discoverWallets();
265-
});
266-
}
261+
disconnectUnsubscribeRef.current = pendingProvider.onDisconnect(() => {
262+
setWallet(null);
263+
setSelectedProvider(null);
264+
setFrom(null);
265+
disconnectUnsubscribeRef.current = null;
266+
discoverWallets();
267+
});
267268

268269
setWallet(connectedWallet);
269270
setConnectionPhase('idle');

spartan/metrics/values.tmp.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ grafana:
125125
NEXT_NET_REGEX: "next-net"
126126
TESTNET_NAMESPACES_REGEX: "testnet|v[0-9]+-testnet"
127127
MAINNET_NAMESPACES_REGEX: "mainnet|v[0-9]+-mainnet|ignition"
128-
DEVNET_NAMESPACES_REGEX: "devnet"
128+
DEVNET_NAMESPACES_REGEX: ".*devnet.*"
129129
SLACK_WEBHOOK_URL: "http://127.0.0.1" # dummy value
130130
SLACK_WEBHOOK_STAGING_PUBLIC_URL: "http://127.0.0.1" # dummy value
131131
SLACK_WEBHOOK_STAGING_IGNITION_URL: "http://127.0.0.1" # dummy value

spartan/scripts/deploy_network.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,7 @@ SLASH_FACTORY_CONTRACT_ADDRESS = "${SLASH_FACTORY_ADDRESS}"
498498
FEE_ASSET_HANDLER_CONTRACT_ADDRESS = "${FEE_ASSET_HANDLER_ADDRESS}"
499499
VALIDATOR_MNEMONIC = "${LABS_INFRA_MNEMONIC}"
500500
VALIDATOR_MNEMONIC_START_INDEX = ${VALIDATOR_MNEMONIC_START_INDEX}
501+
VALIDATOR_PUBLISHER_MNEMONIC_START_INDEX = ${VALIDATOR_PUBLISHER_MNEMONIC_START_INDEX}
501502
VALIDATORS_PER_NODE = ${VALIDATORS_PER_NODE}
502503
VALIDATOR_REPLICAS = ${VALIDATOR_REPLICAS}
503504
VALIDATOR_PUBLISHERS_PER_VALIDATOR_KEY = ${PUBLISHERS_PER_VALIDATOR_KEY}

yarn-project/bootstrap.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ function bench_cmds {
239239
echo "$hash BENCH_OUTPUT=bench-out/kv_store.bench.json yarn-project/scripts/run_test.sh kv-store/src/bench/map_bench.test.ts"
240240
echo "$hash BENCH_OUTPUT=bench-out/tx_pool.bench.json yarn-project/scripts/run_test.sh p2p/src/mem_pools/tx_pool/tx_pool_bench.test.ts"
241241
echo "$hash BENCH_OUTPUT=bench-out/tx_pool_v2.bench.json yarn-project/scripts/run_test.sh p2p/src/mem_pools/tx_pool_v2/tx_pool_v2_bench.test.ts"
242+
echo "$hash BENCH_OUTPUT=bench-out/tx_validator.bench.json yarn-project/scripts/run_test.sh p2p/src/msg_validators/tx_validator/tx_validator_bench.test.ts"
242243
echo "$hash:ISOLATE=1:CPUS=16:MEM=32g:TIMEOUT=1200 BENCH_OUTPUT=bench-out/p2p_client_proposal_tx_collector.bench.json yarn-project/scripts/run_test.sh p2p/src/client/test/tx_proposal_collector/p2p_client.proposal_tx_collector.bench.test.ts"
243244
echo "$hash BENCH_OUTPUT=bench-out/tx.bench.json yarn-project/scripts/run_test.sh stdlib/src/tx/tx_bench.test.ts"
244245
echo "$hash:ISOLATE=1:CPUS=10:MEM=16g:LOG_LEVEL=silent BENCH_OUTPUT=bench-out/proving_broker.bench.json yarn-project/scripts/run_test.sh prover-client/src/test/proving_broker_testbench.test.ts"

yarn-project/wallet-sdk/src/extension/provider/extension_wallet.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export class ExtensionWallet {
109109
sharedKey: CryptoKey,
110110
chainInfo: ChainInfo,
111111
appId: string,
112-
): Wallet {
112+
): ExtensionWallet {
113113
const wallet = new ExtensionWallet(chainInfo, appId, extensionId, port, sharedKey);
114114

115115
// Set up message handler for encrypted responses and unencrypted control messages
@@ -127,8 +127,10 @@ export class ExtensionWallet {
127127
wallet.port.start();
128128

129129
return new Proxy(wallet, {
130-
get: (target, prop) => {
131-
if (schemaHasMethod(WalletSchema, prop.toString())) {
130+
get: (target, prop, receiver) => {
131+
if (prop === 'asWallet') {
132+
return () => receiver as unknown as Wallet;
133+
} else if (schemaHasMethod(WalletSchema, prop.toString())) {
132134
return async (...args: unknown[]) => {
133135
const result = await target.postMessage({
134136
type: prop.toString() as keyof FunctionsOf<Wallet>,
@@ -140,7 +142,13 @@ export class ExtensionWallet {
140142
return target[prop as keyof ExtensionWallet];
141143
}
142144
},
143-
}) as unknown as Wallet;
145+
});
146+
}
147+
148+
asWallet(): Wallet {
149+
// Overridden by the proxy in create() to return the proxy itself.
150+
// This body is never reached when accessed through create().
151+
return this as unknown as Wallet;
144152
}
145153

146154
/**

yarn-project/wallet-sdk/src/manager/types.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,18 +116,18 @@ export interface WalletProvider {
116116
* After calling this, the wallet returned from confirm() should no longer be used.
117117
* @returns A promise that resolves when disconnection is complete
118118
*/
119-
disconnect?(): Promise<void>;
119+
disconnect(): Promise<void>;
120120
/**
121121
* Registers a callback to be invoked when the wallet disconnects unexpectedly.
122122
* @param callback - Function to call when wallet disconnects
123123
* @returns A function to unregister the callback
124124
*/
125-
onDisconnect?(callback: ProviderDisconnectionCallback): () => void;
125+
onDisconnect(callback: ProviderDisconnectionCallback): () => void;
126126
/**
127127
* Returns whether the provider's wallet connection has been disconnected.
128128
* @returns true if the wallet is no longer connected
129129
*/
130-
isDisconnected?(): boolean;
130+
isDisconnected(): boolean;
131131
}
132132

133133
/**

yarn-project/wallet-sdk/src/manager/wallet_manager.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -196,15 +196,14 @@ export class WalletManager {
196196
return {
197197
verificationHash: connection.info.verificationHash!,
198198
confirm: () => {
199-
return Promise.resolve(
200-
ExtensionWallet.create(
201-
connection.info.id,
202-
connection.port,
203-
connection.sharedKey,
204-
chainInfo,
205-
connectAppId,
206-
),
199+
extensionWallet = ExtensionWallet.create(
200+
connection.info.id,
201+
connection.port,
202+
connection.sharedKey,
203+
chainInfo,
204+
connectAppId,
207205
);
206+
return Promise.resolve(extensionWallet.asWallet());
208207
},
209208
cancel: () => {
210209
// Send disconnect to terminate the session on the extension side
@@ -213,7 +212,6 @@ export class WalletManager {
213212
type: WalletMessageType.DISCONNECT,
214213
requestId: discoveredWallet.requestId,
215214
});
216-
// Don't close the port - allow retry with fresh key exchange
217215
},
218216
};
219217
},

0 commit comments

Comments
 (0)