From 4d63848930d1925ad53361f05c75087e8d1e4356 Mon Sep 17 00:00:00 2001 From: Nico Chamo Date: Mon, 22 Jun 2026 19:13:47 -0300 Subject: [PATCH 1/2] refactor(stdlib)!: rename unsafe AztecAddress constructors to *Unsafe --- boxes/boxes/vanilla/app/embedded-wallet.ts | 2 +- boxes/boxes/vanilla/app/main.ts | 8 +-- .../docs/resources/migration_notes.md | 20 +++++++ .../wallet-extension/05-transactions.md | 6 +- .../src/components/GameLobby.tsx | 2 +- .../protocol-fuzzer/wallet-bridge.mjs | 6 +- .../src/components/common/FnParameter.tsx | 2 +- .../components/CreateAuthwitDialog.tsx | 2 +- .../components/CreateContractDialog.tsx | 2 +- .../components/home/components/Landing.tsx | 2 +- .../navbar/components/AccountSelector.tsx | 2 +- .../navbar/components/ContractSelector.tsx | 2 +- playground/src/utils/contracts.ts | 2 +- .../src/wallet/components/AddSenderDialog.tsx | 2 +- .../archiver/src/store/log_store.test.ts | 4 +- .../src/store/log_store_codec.test.ts | 6 +- .../archiver/src/test/mock_structs.ts | 7 ++- .../call_authorization_request.ts | 4 +- .../src/contract/interaction_options.test.ts | 2 +- .../src/contract/interaction_options.ts | 2 +- yarn-project/aztec/src/cli/cmds/standby.ts | 2 +- .../aztec/src/local-network/local-network.ts | 2 +- .../avm_check_circuit1.test.ts | 2 +- .../avm_check_circuit2.test.ts | 4 +- .../avm_check_circuit3.test.ts | 10 ++-- .../avm_contract_class_limits.test.ts | 2 +- .../avm_contract_updates.test.ts | 2 +- .../avm_proven_gadgets.test.ts | 4 +- .../avm_proving_tests/avm_proving_tester.ts | 2 +- .../avm_public_fee_payment.test.ts | 4 +- .../cli-wallet/src/utils/options/fees.ts | 2 +- yarn-project/cli-wallet/src/utils/wallet.ts | 2 +- yarn-project/cli/src/utils/commands.ts | 4 +- ...e2e_multi_validator_node_key_store.test.ts | 4 +- .../end-to-end/src/e2e_avm_simulator.test.ts | 4 +- .../e2e_l1_publisher/e2e_l1_publisher.test.ts | 2 +- .../src/e2e_publisher_funding_multi.test.ts | 2 +- .../src/e2e_sequencer/reload_keystore.test.ts | 4 +- .../src/simulators/lending_simulator.ts | 2 +- yarn-project/key-store/src/key_store.test.ts | 2 +- yarn-project/key-store/src/key_store.ts | 4 +- .../src/keystore_manager.test.ts | 6 +- .../node-keystore/src/schemas.test.ts | 6 +- .../node-keystore/src/validation.test.ts | 4 +- .../src/conversion/common.ts | 2 +- yarn-project/p2p/src/config.ts | 2 +- .../fee_payer_balance_eviction_rule.ts | 2 +- .../mem_pools/tx_pool_v2/tx_pool_v2.test.ts | 26 ++++----- .../tx_pool_v2/tx_pool_v2_bench.test.ts | 6 +- .../mem_pools/tx_pool_v2/tx_pool_v2_impl.ts | 2 +- .../tx_validator/phases_validator.test.ts | 2 +- .../tx_validator/phases_validator.ts | 4 +- .../tx_validator/tx_validator_bench.test.ts | 4 +- .../src/scripts/generate_data.ts | 10 ++-- ...ghtweight_checkpoint_builder.bench.test.ts | 4 +- .../lightweight_checkpoint_builder.test.ts | 2 +- .../prover-client/src/mocks/test_context.ts | 2 +- .../event_validation_request.test.ts | 2 +- .../noir-structs/event_validation_request.ts | 2 +- .../log_retrieval_request.test.ts | 8 +-- .../noir-structs/log_retrieval_request.ts | 2 +- .../note_validation_request.test.ts | 4 +- .../noir-structs/note_validation_request.ts | 4 +- .../oracle/note_packing_utils.test.ts | 4 +- .../oracle/oracle_type_mappings.ts | 6 +- .../oracle/private_execution.test.ts | 2 +- .../oracle/private_execution_oracle.test.ts | 2 +- .../transient_array_service.test.ts | 4 +- .../contract_sync_service.test.ts | 16 +++--- yarn-project/pxe/src/error_enriching.ts | 2 +- yarn-project/pxe/src/logs/log_service.ts | 2 +- .../src/private_kernel/batch_planner.test.ts | 2 +- .../src/private_kernel/hints/test_utils.ts | 2 +- .../private_kernel_execution_prover.test.ts | 4 +- .../schema_tests.ts | 56 +++++++++---------- .../storage/contract_store/contract_store.ts | 2 +- .../src/storage/note_store/note_store.test.ts | 16 +++--- .../sender_address_book_store.ts | 2 +- yarn-project/sequencer-client/src/config.ts | 2 +- .../public/avm/apps_tests/avm_test.test.ts | 4 +- .../avm/apps_tests/storage_proofs.test.ts | 4 +- .../src/public/avm/apps_tests/token.test.ts | 6 +- .../avm/avm_execution_environment.test.ts | 2 +- .../src/public/avm/avm_simulator.test.ts | 14 ++--- .../fixtures/base_avm_simulation_tester.ts | 2 +- .../src/public/avm/fixtures/utils.ts | 2 +- .../avm/opcodes/accrued_substate.test.ts | 4 +- .../simulator/src/public/fixtures/amm_test.ts | 4 +- .../src/public/fixtures/bulk_test.ts | 4 +- .../public/fixtures/custom_bytecode_tester.ts | 4 +- .../src/public/fixtures/token_test.ts | 6 +- .../simulator/src/public/fixtures/utils.ts | 2 +- .../apps_tests/deployments.test.ts | 6 +- .../apps_tests/timeout_race.test.ts | 2 +- .../public_processor/apps_tests/token.test.ts | 6 +- .../public_processor/public_processor.test.ts | 2 +- .../apps_tests/avm_gadgets.test.ts | 2 +- .../apps_tests/bench.test.ts | 8 +-- .../apps_tests/cpp_exception_handling.test.ts | 4 +- .../contract_provider_for_cpp.ts | 4 +- .../public_tx_simulator.test.ts | 12 ++-- .../src/public/side_effect_trace.test.ts | 28 +++++----- .../state_manager/public_storage.test.ts | 14 ++--- .../state_manager/state_manager.test.ts | 14 ++--- .../src/public/state_manager/state_manager.ts | 2 +- yarn-project/standard-contracts/src/drift.ts | 2 +- .../src/standard_contract_data.ts | 12 ++-- yarn-project/stdlib/src/abi/decoder.test.ts | 2 +- yarn-project/stdlib/src/avm/avm.ts | 2 +- .../stdlib/src/aztec-address/index.ts | 42 ++++++++++++-- .../stdlib/src/checkpoint/validate.test.ts | 4 +- .../src/contract/contract_address.test.ts | 4 +- yarn-project/stdlib/src/hash/hash.test.ts | 6 +- yarn-project/stdlib/src/hash/map_slot.test.ts | 2 +- ...build_note_hash_read_request_hints.test.ts | 2 +- ...build_nullifier_read_request_hints.test.ts | 2 +- .../hints/build_transient_data_hints.test.ts | 6 +- .../stdlib/src/kernel/hints/read_request.ts | 2 +- yarn-project/stdlib/src/kernel/log_hash.ts | 7 ++- yarn-project/stdlib/src/kernel/note_hash.ts | 2 +- yarn-project/stdlib/src/kernel/nullifier.ts | 2 +- .../stdlib/src/kernel/private_log_data.ts | 5 +- .../stdlib/src/logs/app_tagging_secret.ts | 4 +- .../src/logs/contract_class_log.test.ts | 4 +- .../src/rollup/checkpoint_header.test.ts | 4 +- yarn-project/stdlib/src/tests/factories.ts | 4 +- .../stdlib/src/tx/execution_payload.ts | 3 +- .../stdlib/src/tx/global_variables.ts | 4 +- yarn-project/stdlib/src/tx/tx.test.ts | 2 +- yarn-project/stdlib/src/tx/tx_request.test.ts | 2 +- yarn-project/txe/src/constants.ts | 2 +- .../oracle/test-resolver/default_fixtures.ts | 2 +- .../src/oracle/test-resolver/resolver.test.ts | 14 ++--- .../oracle/txe_oracle_top_level_context.ts | 2 +- .../src/checkpoint_builder.test.ts | 2 +- .../key_store/node_keystore_adapter.test.ts | 6 +- .../wallet-sdk/src/base-wallet/base_wallet.ts | 2 +- .../wallets/src/embedded/wallet_db.ts | 4 +- 138 files changed, 391 insertions(+), 317 deletions(-) diff --git a/boxes/boxes/vanilla/app/embedded-wallet.ts b/boxes/boxes/vanilla/app/embedded-wallet.ts index 0231e3516c32..0cfa283da83b 100644 --- a/boxes/boxes/vanilla/app/embedded-wallet.ts +++ b/boxes/boxes/vanilla/app/embedded-wallet.ts @@ -163,7 +163,7 @@ export class EmbeddedWallet extends EmbeddedWalletBase { if (!address) { return null; } - const parsed = AztecAddress.fromString(address); + const parsed = AztecAddress.fromStringUnsafe(address); this.connectedAccount = parsed; return this.connectedAccount; } diff --git a/boxes/boxes/vanilla/app/main.ts b/boxes/boxes/vanilla/app/main.ts index 4c35c1045b97..36902af49dcf 100644 --- a/boxes/boxes/vanilla/app/main.ts +++ b/boxes/boxes/vanilla/app/main.ts @@ -53,9 +53,9 @@ document.addEventListener('DOMContentLoaded', async () => { const instance = await getContractInstanceFromInstantiationParams( PrivateVotingContract.artifact, { - deployer: AztecAddress.fromString(deployerAddress), + deployer: AztecAddress.fromStringUnsafe(deployerAddress), salt: Fr.fromString(deploymentSalt), - constructorArgs: [AztecAddress.fromString(deployerAddress)], + constructorArgs: [AztecAddress.fromStringUnsafe(deployerAddress)], } ); await wallet.registerContract(instance, PrivateVotingContract.artifact); @@ -155,7 +155,7 @@ voteButton.addEventListener('click', async (e) => { // Prepare contract interaction const votingContract = PrivateVotingContract.at( - AztecAddress.fromString(contractAddress), + AztecAddress.fromStringUnsafe(contractAddress), wallet ); @@ -188,7 +188,7 @@ async function updateVoteTally(wallet: Wallet, from: AztecAddress) { // Prepare contract interaction const votingContract = PrivateVotingContract.at( - AztecAddress.fromString(contractAddress), + AztecAddress.fromStringUnsafe(contractAddress), wallet ); diff --git a/docs/docs-developers/docs/resources/migration_notes.md b/docs/docs-developers/docs/resources/migration_notes.md index 07b9a16eac4a..4a46a11478ce 100644 --- a/docs/docs-developers/docs/resources/migration_notes.md +++ b/docs/docs-developers/docs/resources/migration_notes.md @@ -9,6 +9,26 @@ Aztec is in active development. Each version may introduce breaking changes that ## TBD +### [Aztec.js] Unchecked `AztecAddress` constructors renamed with an `Unsafe` suffix + +The synchronous `AztecAddress` constructors that build an address from a raw value do not verify that the value is a valid address (the x-coordinate of a point on the Grumpkin curve, which is what allows it to be encrypted to). An invalid value is accepted silently and only fails later, when a transaction is sent. To make this obvious at the call site, they now carry an `Unsafe` suffix: + +| Before | After | +| --- | --- | +| `AztecAddress.fromField` | `AztecAddress.fromFieldUnsafe` | +| `AztecAddress.fromBigInt` | `AztecAddress.fromBigIntUnsafe` | +| `AztecAddress.fromNumber` | `AztecAddress.fromNumberUnsafe` | +| `AztecAddress.fromString` | `AztecAddress.fromStringUnsafe` | + +**Migration:** + +```diff +- const address = AztecAddress.fromBigInt(123n); ++ const address = AztecAddress.fromBigIntUnsafe(123n); +``` + +For a random, genuinely valid address in tests use `AztecAddress.random()`, and to check an untrusted value use `address.isValid()`. The serialization constructors `fromBuffer` and `fromFields` keep their names (they are part of the (de)serialization interface and read addresses from already-validated data), but their docs now note that they perform no validation either. + ### Cross-contract utility calls now have a `msg_sender` A utility function called by another contract (utility to utility, or private to utility) can read the calling contract's address via `self.msg_sender()`, mirroring private and public functions. A top-level utility call (e.g. invoked directly by a wallet or dapp) has no caller: `self.msg_sender()` panics, and `self.context.maybe_msg_sender()` returns `Option::none()`. diff --git a/docs/docs-developers/docs/tutorials/js_tutorials/wallet-extension/05-transactions.md b/docs/docs-developers/docs/tutorials/js_tutorials/wallet-extension/05-transactions.md index feda079c013d..ad65ec7b02d0 100644 --- a/docs/docs-developers/docs/tutorials/js_tutorials/wallet-extension/05-transactions.md +++ b/docs/docs-developers/docs/tutorials/js_tutorials/wallet-extension/05-transactions.md @@ -173,7 +173,7 @@ case 'sendTx': { // 1. Deserialize the payload const payload = deserializeExecutionPayload(executionPayload); - const fromAddress = AztecAddress.fromString(from || options.from); + const fromAddress = AztecAddress.fromStringUnsafe(from || options.from); // 2. Call wallet.sendTx (inherited from BaseWallet) const result = await wallet.sendTx(payload, { @@ -297,7 +297,7 @@ For gas estimation or validation, dApps use `simulateTx`: case 'simulateTx': { const { executionPayload, options } = args; const payload = deserializeExecutionPayload(executionPayload); - const fromAddress = AztecAddress.fromString(from || options.from); + const fromAddress = AztecAddress.fromStringUnsafe(from || options.from); const result = await wallet.simulateTx(payload, { ...options, @@ -342,7 +342,7 @@ For delegated actions (like approving token spending), the wallet creates auth w ```typescript case 'createAuthWit': { const { from: authFrom, messageHashOrIntent } = args; - const fromAddress = AztecAddress.fromString(authFrom); + const fromAddress = AztecAddress.fromStringUnsafe(authFrom); const authWit = await wallet.createAuthWit(fromAddress, messageHashOrIntent); diff --git a/docs/examples/webapp-tutorial/src/components/GameLobby.tsx b/docs/examples/webapp-tutorial/src/components/GameLobby.tsx index 05af34336f25..511614dd9827 100644 --- a/docs/examples/webapp-tutorial/src/components/GameLobby.tsx +++ b/docs/examples/webapp-tutorial/src/components/GameLobby.tsx @@ -79,7 +79,7 @@ export function GameLobby({ wallet, account, onGameJoined }: GameLobbyProps) { return; } - const contractAddr = AztecAddress.fromString(joinContractAddress); + const contractAddr = AztecAddress.fromStringUnsafe(joinContractAddress); const contract = await attachToContract( wallet, contractAddr diff --git a/noir-projects/protocol-fuzzer/wallet-bridge.mjs b/noir-projects/protocol-fuzzer/wallet-bridge.mjs index b37cc1cb6ea4..2f4d41e489bc 100644 --- a/noir-projects/protocol-fuzzer/wallet-bridge.mjs +++ b/noir-projects/protocol-fuzzer/wallet-bridge.mjs @@ -85,7 +85,7 @@ const handlers = { const w = await ensureWallet(); const { result: address, stdout } = await capturing(log => deploy( - w, node, AztecAddress.fromString(from), artifact, + w, node, AztecAddress.fromStringUnsafe(from), artifact, false, /* json */ undefined, /* publicKeys */ Array.isArray(args) ? args : [], /* args */ @@ -106,8 +106,8 @@ const handlers = { '/execute': async ({ verb, method, contract, from, args, artifact }) => { const w = await ensureWallet(); - const sender = AztecAddress.fromString(from); - const target = AztecAddress.fromString(contract); + const sender = AztecAddress.fromStringUnsafe(from); + const target = AztecAddress.fromStringUnsafe(contract); const callArgs = args || []; const { stdout } = await capturing(log => verb === 'send' diff --git a/playground/src/components/common/FnParameter.tsx b/playground/src/components/common/FnParameter.tsx index 4c5b7cf75a21..9cb5f1e93703 100644 --- a/playground/src/components/common/FnParameter.tsx +++ b/playground/src/components/common/FnParameter.tsx @@ -74,7 +74,7 @@ export function FunctionParameter({ parameter, required, onParameterChange, defa const contacts = await wallet.getAddressBook(); const contracts = (await playgroundDB.listAliases('contracts')).map( - ({ alias, item }) => ({ alias, item: AztecAddress.fromString(item) }), + ({ alias, item }) => ({ alias, item: AztecAddress.fromStringUnsafe(item) }), ); setAliasedAddresses([...accounts, ...contacts, ...contracts]); setLoading(false); diff --git a/playground/src/components/contract/components/CreateAuthwitDialog.tsx b/playground/src/components/contract/components/CreateAuthwitDialog.tsx index 0332f4ab3850..a166e48da015 100644 --- a/playground/src/components/contract/components/CreateAuthwitDialog.tsx +++ b/playground/src/components/contract/components/CreateAuthwitDialog.tsx @@ -62,7 +62,7 @@ export function CreateAuthwitDialog({ open, contract, fnName, args, isPrivate, o setCreating(true); const call = await contract.methods[fnName](...args).getFunctionCall(); const intent = { - caller: AztecAddress.fromString(caller), + caller: AztecAddress.fromStringUnsafe(caller), call, }; try { diff --git a/playground/src/components/contract/components/CreateContractDialog.tsx b/playground/src/components/contract/components/CreateContractDialog.tsx index b98a5b2e4912..2dea9d80ae5d 100644 --- a/playground/src/components/contract/components/CreateContractDialog.tsx +++ b/playground/src/components/contract/components/CreateContractDialog.tsx @@ -141,7 +141,7 @@ export function CreateContractDialog({ const registerExistingContract = async () => { setIsRegistering(true); try { - const contract = await node.getContract(AztecAddress.fromString(address)); + const contract = await node.getContract(AztecAddress.fromStringUnsafe(address)); if (!contract) { throw new Error('Contract with this address was not found in node'); } diff --git a/playground/src/components/home/components/Landing.tsx b/playground/src/components/home/components/Landing.tsx index 1b007362104c..1709737852d9 100644 --- a/playground/src/components/home/components/Landing.tsx +++ b/playground/src/components/home/components/Landing.tsx @@ -352,7 +352,7 @@ export function Landing() { const artifactAsString = await playgroundDB.retrieveAlias(`artifacts:${contract.item}`); const contractArtifact = loadContractArtifact(parse(artifactAsString)); if (contractArtifact.name === contractArtifactJSON.name) { - deployedContractAddress = AztecAddress.fromString(contract.item); + deployedContractAddress = AztecAddress.fromStringUnsafe(contract.item); break; } } diff --git a/playground/src/components/navbar/components/AccountSelector.tsx b/playground/src/components/navbar/components/AccountSelector.tsx index 80e70e05f1c2..9db2cf993b5e 100644 --- a/playground/src/components/navbar/components/AccountSelector.tsx +++ b/playground/src/components/navbar/components/AccountSelector.tsx @@ -81,7 +81,7 @@ export function AccountSelector() { onClose={() => setIsOpen(false)} onChange={e => { if (e.target.value !== '') { - handleAccountChange(AztecAddress.fromString(e.target.value)); + handleAccountChange(AztecAddress.fromStringUnsafe(e.target.value)); } }} disabled={areAccountsLoading} diff --git a/playground/src/components/navbar/components/ContractSelector.tsx b/playground/src/components/navbar/components/ContractSelector.tsx index 7ab2a0f83030..3700cc58ae69 100644 --- a/playground/src/components/navbar/components/ContractSelector.tsx +++ b/playground/src/components/navbar/components/ContractSelector.tsx @@ -108,7 +108,7 @@ export function ContractSelector() { } else { const artifactAsString = await playgroundDB.retrieveAlias(`artifacts:${contractValue}`); const contractArtifact = loadContractArtifact(parse(artifactAsString)); - setCurrentContractAddress(AztecAddress.fromString(contractValue)); + setCurrentContractAddress(AztecAddress.fromStringUnsafe(contractValue)); setCurrentContractArtifact(contractArtifact); setSelectedPredefinedContract(undefined); setShowContractInterface(true); diff --git a/playground/src/utils/contracts.ts b/playground/src/utils/contracts.ts index 3216b8b4a4d2..1ddbbd9c67d0 100644 --- a/playground/src/utils/contracts.ts +++ b/playground/src/utils/contracts.ts @@ -8,7 +8,7 @@ export async function filterDeployedAliasedContracts( const deployed = ( await Promise.all( aliasedContracts.map(async contract => { - const { isContractPublished } = await wallet.getContractMetadata(AztecAddress.fromString(contract.item)); + const { isContractPublished } = await wallet.getContractMetadata(AztecAddress.fromStringUnsafe(contract.item)); return { ...contract, deployed: isContractPublished }; }), ) diff --git a/playground/src/wallet/components/AddSenderDialog.tsx b/playground/src/wallet/components/AddSenderDialog.tsx index fc2335162fc7..fef434ad85fa 100644 --- a/playground/src/wallet/components/AddSenderDialog.tsx +++ b/playground/src/wallet/components/AddSenderDialog.tsx @@ -24,7 +24,7 @@ export function AddSendersDialog({ const addSender = async () => { try { - const parsed = AztecAddress.fromString(sender); + const parsed = AztecAddress.fromStringUnsafe(sender); onClose(parsed, alias); } catch (e) { setError('Invalid Aztec address'); diff --git a/yarn-project/archiver/src/store/log_store.test.ts b/yarn-project/archiver/src/store/log_store.test.ts index 1b684535f063..54b899569a04 100644 --- a/yarn-project/archiver/src/store/log_store.test.ts +++ b/yarn-project/archiver/src/store/log_store.test.ts @@ -40,7 +40,7 @@ async function buildChainedCheckpointsWithLogs( return checkpoints; } -const CONTRACT = AztecAddress.fromNumber(543254); +const CONTRACT = AztecAddress.fromNumberUnsafe(543254); describe('LogStore', () => { let blockStore: BlockStore; @@ -468,7 +468,7 @@ describe('LogStore', () => { await logStore.addLogs([ckpt.checkpoint.blocks[0]]); // Same tag, different contract → no hits. - const otherContract = AztecAddress.fromNumber(99); + const otherContract = AztecAddress.fromNumberUnsafe(99); const [missing] = await logStore.getPublicLogsByTags({ contractAddress: otherContract, tags: [tag] }); expect(missing).toEqual([]); diff --git a/yarn-project/archiver/src/store/log_store_codec.test.ts b/yarn-project/archiver/src/store/log_store_codec.test.ts index b087312746e1..25ee762ee106 100644 --- a/yarn-project/archiver/src/store/log_store_codec.test.ts +++ b/yarn-project/archiver/src/store/log_store_codec.test.ts @@ -45,7 +45,7 @@ describe('log_store_codec', () => { }); it('strips 0x prefix for AztecAddress', () => { - const addr = AztecAddress.fromNumber(12345); + const addr = AztecAddress.fromNumberUnsafe(12345); const hex = fieldHex(addr); expect(hex).toHaveLength(64); expect(hex).not.toMatch(/^0x/); @@ -69,7 +69,7 @@ describe('log_store_codec', () => { }); it('round-trips a public-style prefix (contract-tag)', () => { - const contractHex = fieldHex(AztecAddress.fromNumber(99)); + const contractHex = fieldHex(AztecAddress.fromNumberUnsafe(99)); const tagHex = fieldHex(new Fr(0x5678n)); const prefix = encodePublicPrefix(contractHex, tagHex); const key = encodeKey(prefix, 10, 0, 2); @@ -242,7 +242,7 @@ describe('log_store_codec', () => { describe('encodePublicPrefix', () => { it('produces contractHex-tagHex', () => { - const contractHex = fieldHex(AztecAddress.fromNumber(1)); + const contractHex = fieldHex(AztecAddress.fromNumberUnsafe(1)); const tagHex = fieldHex(new Fr(2n)); expect(encodePublicPrefix(contractHex, tagHex)).toBe(`${contractHex}-${tagHex}`); }); diff --git a/yarn-project/archiver/src/test/mock_structs.ts b/yarn-project/archiver/src/test/mock_structs.ts index 0888d717218c..91145fcfcb11 100644 --- a/yarn-project/archiver/src/test/mock_structs.ts +++ b/yarn-project/archiver/src/test/mock_structs.ts @@ -269,7 +269,10 @@ export function makePublicLogTag(blockNumber: number, txIndex: number, logIndex: } /** Creates a PublicLog with fields derived from the tag. */ -export function makePublicLog(tag: Tag, contractAddress: AztecAddress = AztecAddress.fromNumber(543254)): PublicLog { +export function makePublicLog( + tag: Tag, + contractAddress: AztecAddress = AztecAddress.fromNumberUnsafe(543254), +): PublicLog { return PublicLog.from({ contractAddress, fields: new Array(10).fill(null).map((_, i) => (!i ? tag.value : new Fr(tag.value.toBigInt() + BigInt(i)))), @@ -281,7 +284,7 @@ export function makePublicLogs( blockNumber: number, txIndex: number, numLogsPerTx: number, - contractAddress: AztecAddress = AztecAddress.fromNumber(543254), + contractAddress: AztecAddress = AztecAddress.fromNumberUnsafe(543254), ): PublicLog[] { return times(numLogsPerTx, logIndex => { const tag = makePublicLogTag(blockNumber, txIndex, logIndex); diff --git a/yarn-project/aztec.js/src/authorization/call_authorization_request.ts b/yarn-project/aztec.js/src/authorization/call_authorization_request.ts index 0b15b70fdde9..c2238e5eb843 100644 --- a/yarn-project/aztec.js/src/authorization/call_authorization_request.ts +++ b/yarn-project/aztec.js/src/authorization/call_authorization_request.ts @@ -81,8 +81,8 @@ export class CallAuthorizationRequest { const request = new CallAuthorizationRequest( selector, reader.readField(), // inner_hash - AztecAddress.fromField(reader.readField()), // on_behalf_of - AztecAddress.fromField(reader.readField()), // msg_sender + AztecAddress.fromFieldUnsafe(reader.readField()), // on_behalf_of + AztecAddress.fromFieldUnsafe(reader.readField()), // msg_sender FunctionSelector.fromField(reader.readField()), // fn_selector reader.readField(), // args_hash reader.readFieldArray(reader.remainingFields()), // args diff --git a/yarn-project/aztec.js/src/contract/interaction_options.test.ts b/yarn-project/aztec.js/src/contract/interaction_options.test.ts index 71bb49634ac9..2bcc2852378f 100644 --- a/yarn-project/aztec.js/src/contract/interaction_options.test.ts +++ b/yarn-project/aztec.js/src/contract/interaction_options.test.ts @@ -9,7 +9,7 @@ describe('extractOffchainOutput', () => { const makeEffect = (data: Fr[], contractAddress?: AztecAddress): OffchainEffect => ({ data, - contractAddress: contractAddress ?? AztecAddress.fromField(Fr.random()), + contractAddress: contractAddress ?? AztecAddress.fromFieldUnsafe(Fr.random()), }); const makeMessageEffect = async (recipient?: AztecAddress, payload?: Fr[], contractAddress?: AztecAddress) => diff --git a/yarn-project/aztec.js/src/contract/interaction_options.ts b/yarn-project/aztec.js/src/contract/interaction_options.ts index 92d48488c1c2..5a7ae4d0ba06 100644 --- a/yarn-project/aztec.js/src/contract/interaction_options.ts +++ b/yarn-project/aztec.js/src/contract/interaction_options.ts @@ -191,7 +191,7 @@ export function extractOffchainOutput(effects: OffchainEffect[], anchorBlockTime for (const effect of effects) { if (effect.data.length >= 2 && effect.data[0].equals(OFFCHAIN_MESSAGE_IDENTIFIER)) { offchainMessages.push({ - recipient: AztecAddress.fromField(effect.data[1]), + recipient: AztecAddress.fromFieldUnsafe(effect.data[1]), payload: effect.data.slice(2), contractAddress: effect.contractAddress, anchorBlockTimestamp, diff --git a/yarn-project/aztec/src/cli/cmds/standby.ts b/yarn-project/aztec/src/cli/cmds/standby.ts index d2769d36788d..720c72596bd2 100644 --- a/yarn-project/aztec/src/cli/cmds/standby.ts +++ b/yarn-project/aztec/src/cli/cmds/standby.ts @@ -23,7 +23,7 @@ const ROLLUP_POLL_INTERVAL_S = 60; export async function computeExpectedGenesisRoot(config: GenesisStateConfig, userLog: LogFn) { const testAccounts = config.testAccounts ? (await getInitialTestAccountsData()).map(a => a.address) : []; const sponsoredFPCAccounts = config.sponsoredFPC ? [await getSponsoredFPCAddress()] : []; - const prefundAddresses = (config.prefundAddresses ?? []).map(a => AztecAddress.fromString(a)); + const prefundAddresses = (config.prefundAddresses ?? []).map(a => AztecAddress.fromStringUnsafe(a)); const initialFundedAccounts = testAccounts.concat(sponsoredFPCAccounts).concat(prefundAddresses); userLog(`Initial funded accounts: ${initialFundedAccounts.map(a => a.toString()).join(', ')}`); diff --git a/yarn-project/aztec/src/local-network/local-network.ts b/yarn-project/aztec/src/local-network/local-network.ts index a285c029b2cf..d0a06b77cf0b 100644 --- a/yarn-project/aztec/src/local-network/local-network.ts +++ b/yarn-project/aztec/src/local-network/local-network.ts @@ -166,7 +166,7 @@ export async function createLocalNetwork(config: Partial = { const bananaFPC = await getBananaFPCAddress(initialAccounts); const sponsoredFPC = await getSponsoredFPCAddress(); - const prefundAddresses = (aztecNodeConfig.prefundAddresses ?? []).map(a => AztecAddress.fromString(a)); + const prefundAddresses = (aztecNodeConfig.prefundAddresses ?? []).map(a => AztecAddress.fromStringUnsafe(a)); const fundedAddresses = [ ...initialAccounts.map(a => a.address), ...(initialAccounts.length ? [bananaFPC, sponsoredFPC] : []), diff --git a/yarn-project/bb-prover/src/avm_proving_tests/avm_check_circuit1.test.ts b/yarn-project/bb-prover/src/avm_proving_tests/avm_check_circuit1.test.ts index b74cb0f18dcc..fc961b0f733f 100644 --- a/yarn-project/bb-prover/src/avm_proving_tests/avm_check_circuit1.test.ts +++ b/yarn-project/bb-prover/src/avm_proving_tests/avm_check_circuit1.test.ts @@ -26,7 +26,7 @@ describe('AVM check-circuit – unhappy paths 1', () => { tester = await AvmProvingTester.new(worldStateService, /*checkCircuitOnly*/ true); avmTestContractInstance = await tester.registerAndDeployContract( /*constructorArgs=*/ [], - /*deployer=*/ AztecAddress.fromNumber(420), + /*deployer=*/ AztecAddress.fromNumberUnsafe(420), AvmTestContractArtifact, ); }); diff --git a/yarn-project/bb-prover/src/avm_proving_tests/avm_check_circuit2.test.ts b/yarn-project/bb-prover/src/avm_proving_tests/avm_check_circuit2.test.ts index 555c6bfb4bc7..4f174bac0b92 100644 --- a/yarn-project/bb-prover/src/avm_proving_tests/avm_check_circuit2.test.ts +++ b/yarn-project/bb-prover/src/avm_proving_tests/avm_check_circuit2.test.ts @@ -10,7 +10,7 @@ import { AvmProvingTester } from './avm_proving_tester.js'; const TIMEOUT = 30_000; describe('AVM check-circuit – unhappy paths 2', () => { - const sender = AztecAddress.fromNumber(42); + const sender = AztecAddress.fromNumberUnsafe(42); let avmTestContractInstance: ContractInstanceWithAddress; let tester: AvmProvingTester; let worldStateService: NativeWorldStateService; @@ -20,7 +20,7 @@ describe('AVM check-circuit – unhappy paths 2', () => { tester = await AvmProvingTester.new(worldStateService, /*checkCircuitOnly*/ true); avmTestContractInstance = await tester.registerAndDeployContract( /*constructorArgs=*/ [], - /*deployer=*/ AztecAddress.fromNumber(420), + /*deployer=*/ AztecAddress.fromNumberUnsafe(420), AvmTestContractArtifact, ); }); diff --git a/yarn-project/bb-prover/src/avm_proving_tests/avm_check_circuit3.test.ts b/yarn-project/bb-prover/src/avm_proving_tests/avm_check_circuit3.test.ts index b5648bcea5de..e8a2e46287da 100644 --- a/yarn-project/bb-prover/src/avm_proving_tests/avm_check_circuit3.test.ts +++ b/yarn-project/bb-prover/src/avm_proving_tests/avm_check_circuit3.test.ts @@ -13,7 +13,7 @@ import { AvmProvingTester } from './avm_proving_tester.js'; const TIMEOUT = 100_000; describe('AVM check-circuit – unhappy paths 3', () => { - const sender = AztecAddress.fromNumber(42); + const sender = AztecAddress.fromNumberUnsafe(42); let avmTestContractInstance: ContractInstanceWithAddress; let tester: AvmProvingTester; let worldStateService: NativeWorldStateService; @@ -23,7 +23,7 @@ describe('AVM check-circuit – unhappy paths 3', () => { tester = await AvmProvingTester.new(worldStateService, /*checkCircuitOnly*/ true); avmTestContractInstance = await tester.registerAndDeployContract( /*constructorArgs=*/ [], - /*deployer=*/ AztecAddress.fromNumber(420), + /*deployer=*/ AztecAddress.fromNumberUnsafe(420), AvmTestContractArtifact, ); }); @@ -137,15 +137,15 @@ describe('AVM check-circuit – unhappy paths 3', () => { l2ToL1Msgs: [ new ScopedL2ToL1Message( new L2ToL1Message(EthAddress.fromNumber(0x1111), new Fr(0xdddd)), - AztecAddress.fromNumber(0x1111), + AztecAddress.fromNumberUnsafe(0x1111), ), new ScopedL2ToL1Message( new L2ToL1Message(EthAddress.fromNumber(0x2222), new Fr(0xeeee)), - AztecAddress.fromNumber(0x2222), + AztecAddress.fromNumberUnsafe(0x2222), ), new ScopedL2ToL1Message( new L2ToL1Message(EthAddress.fromNumber(0x3333), new Fr(0xffff)), - AztecAddress.fromNumber(0x3333), + AztecAddress.fromNumberUnsafe(0x3333), ), ], }, diff --git a/yarn-project/bb-prover/src/avm_proving_tests/avm_contract_class_limits.test.ts b/yarn-project/bb-prover/src/avm_proving_tests/avm_contract_class_limits.test.ts index 961cd3655e23..fbb93782c534 100644 --- a/yarn-project/bb-prover/src/avm_proving_tests/avm_contract_class_limits.test.ts +++ b/yarn-project/bb-prover/src/avm_proving_tests/avm_contract_class_limits.test.ts @@ -9,7 +9,7 @@ import { AvmProvingTester } from './avm_proving_tester.js'; const TIMEOUT = 300_000; describe('AVM check-circuit - contract class limits', () => { - const deployer = AztecAddress.fromNumber(42); + const deployer = AztecAddress.fromNumberUnsafe(42); let instances: ContractInstanceWithAddress[]; let tester: AvmProvingTester; let avmTestContractAddress: AztecAddress; diff --git a/yarn-project/bb-prover/src/avm_proving_tests/avm_contract_updates.test.ts b/yarn-project/bb-prover/src/avm_proving_tests/avm_contract_updates.test.ts index b043f8793b8b..33515961f285 100644 --- a/yarn-project/bb-prover/src/avm_proving_tests/avm_contract_updates.test.ts +++ b/yarn-project/bb-prover/src/avm_proving_tests/avm_contract_updates.test.ts @@ -17,7 +17,7 @@ import { AvmProvingTester } from './avm_proving_tester.js'; const TIMEOUT = 60_000; describe('AVM check-circuit - contract updates', () => { - const sender = AztecAddress.fromNumber(42); + const sender = AztecAddress.fromNumberUnsafe(42); const avmTestContractClassSeed = 0; let avmTestContractInstance: ContractInstanceWithAddress; diff --git a/yarn-project/bb-prover/src/avm_proving_tests/avm_proven_gadgets.test.ts b/yarn-project/bb-prover/src/avm_proving_tests/avm_proven_gadgets.test.ts index 1765487d6383..23f49bb1d25e 100644 --- a/yarn-project/bb-prover/src/avm_proving_tests/avm_proven_gadgets.test.ts +++ b/yarn-project/bb-prover/src/avm_proving_tests/avm_proven_gadgets.test.ts @@ -18,7 +18,7 @@ describe.skip('AVM proven gadgets test', () => { const metrics = new TestExecutorMetrics(); let worldStateService: NativeWorldStateService; - const sender = AztecAddress.fromNumber(42); + const sender = AztecAddress.fromNumberUnsafe(42); let avmGadgetsTestContract: ContractInstanceWithAddress; beforeEach(async () => { @@ -107,7 +107,7 @@ describe('AVM proven gadgets test: test vectors', () => { let tester: AvmProvingTester; let worldStateService: NativeWorldStateService; - const sender = AztecAddress.fromNumber(42); + const sender = AztecAddress.fromNumberUnsafe(42); let avmGadgetsTestContract: ContractInstanceWithAddress; beforeEach(async () => { diff --git a/yarn-project/bb-prover/src/avm_proving_tests/avm_proving_tester.ts b/yarn-project/bb-prover/src/avm_proving_tests/avm_proving_tester.ts index 53d2a0fc5e71..4b4638c4ea42 100644 --- a/yarn-project/bb-prover/src/avm_proving_tests/avm_proving_tester.ts +++ b/yarn-project/bb-prover/src/avm_proving_tests/avm_proving_tester.ts @@ -192,7 +192,7 @@ export class AvmProvingTester extends PublicTxSimulationTester { gasLimits?: Gas, ) { await this.simProveVerify( - /*sender=*/ AztecAddress.fromNumber(42), + /*sender=*/ AztecAddress.fromNumberUnsafe(42), /*setupCalls=*/ [], [appCall], undefined, diff --git a/yarn-project/bb-prover/src/avm_proving_tests/avm_public_fee_payment.test.ts b/yarn-project/bb-prover/src/avm_proving_tests/avm_public_fee_payment.test.ts index ff6145055b89..56444bb2ec5f 100644 --- a/yarn-project/bb-prover/src/avm_proving_tests/avm_public_fee_payment.test.ts +++ b/yarn-project/bb-prover/src/avm_proving_tests/avm_public_fee_payment.test.ts @@ -9,7 +9,7 @@ import { AvmProvingTester } from './avm_proving_tester.js'; const TIMEOUT = 60_000; describe('AVM check-circuit – public fee payment', () => { - const sender = AztecAddress.fromNumber(42); + const sender = AztecAddress.fromNumberUnsafe(42); const feePayer = sender; const initialFeeJuiceBalance = new Fr(20000); @@ -25,7 +25,7 @@ describe('AVM check-circuit – public fee payment', () => { avmTestContractInstance = await tester.registerAndDeployContract( /*constructorArgs=*/ [], - /*deployer=*/ AztecAddress.fromNumber(420), + /*deployer=*/ AztecAddress.fromNumberUnsafe(420), AvmTestContractArtifact, ); }); diff --git a/yarn-project/cli-wallet/src/utils/options/fees.ts b/yarn-project/cli-wallet/src/utils/options/fees.ts index 5628955fc5a2..867e8b833735 100644 --- a/yarn-project/cli-wallet/src/utils/options/fees.ts +++ b/yarn-project/cli-wallet/src/utils/options/fees.ts @@ -137,7 +137,7 @@ export function parsePaymentMethod( if (!parsed.asset) { throw new Error('Missing "asset" in payment option'); } - return AztecAddress.fromString(parsed.asset); + return AztecAddress.fromStringUnsafe(parsed.asset); }; return async (wallet: Wallet, from: AztecAddress, gasSettings: GasSettings) => { diff --git a/yarn-project/cli-wallet/src/utils/wallet.ts b/yarn-project/cli-wallet/src/utils/wallet.ts index f4cb9f60a738..ffb0832a1110 100644 --- a/yarn-project/cli-wallet/src/utils/wallet.ts +++ b/yarn-project/cli-wallet/src/utils/wallet.ts @@ -95,7 +95,7 @@ export class CLIWallet extends BaseWallet { return Promise.resolve( accounts.map(({ key, value }) => { const alias = key.includes(':') ? key.slice(key.indexOf(':') + 1) : key; - return { alias, item: AztecAddress.fromString(value) }; + return { alias, item: AztecAddress.fromStringUnsafe(value) }; }), ); } diff --git a/yarn-project/cli/src/utils/commands.ts b/yarn-project/cli/src/utils/commands.ts index 1a3c7e1d6cb1..f4c35cc816a3 100644 --- a/yarn-project/cli/src/utils/commands.ts +++ b/yarn-project/cli/src/utils/commands.ts @@ -101,7 +101,7 @@ export async function getTxSender(pxe: PXE, _from?: string) { let from: AztecAddress; if (_from) { try { - from = AztecAddress.fromString(_from); + from = AztecAddress.fromStringUnsafe(_from); } catch { throw new InvalidArgumentError(`Invalid option 'from' passed: ${_from}`); } @@ -195,7 +195,7 @@ export function parseFieldFromHexString(str: string): Fr { */ export function parseAztecAddress(address: string): AztecAddress { try { - return AztecAddress.fromString(address); + return AztecAddress.fromStringUnsafe(address); } catch { throw new InvalidArgumentError(`Invalid Aztec address: ${address}`); } diff --git a/yarn-project/end-to-end/src/composed/web3signer/e2e_multi_validator_node_key_store.test.ts b/yarn-project/end-to-end/src/composed/web3signer/e2e_multi_validator_node_key_store.test.ts index af674e9dcdad..ba87f9540a02 100644 --- a/yarn-project/end-to-end/src/composed/web3signer/e2e_multi_validator_node_key_store.test.ts +++ b/yarn-project/end-to-end/src/composed/web3signer/e2e_multi_validator_node_key_store.test.ts @@ -80,7 +80,7 @@ async function createKeyFiles() { }); const feeRecipientAddresses = Array.from({ length: VALIDATOR_COUNT }, (_, i) => { - return AztecAddress.fromNumber(i + 1); + return AztecAddress.fromNumberUnsafe(i + 1); }); await createKeyFile1( @@ -202,7 +202,7 @@ describe('e2e_multi_validator_node', () => { .toString() .toLowerCase(); expectedCoinbaseAddresses.set(validatorAddress.toLowerCase(), coinbase); - const feeRecipient = AztecAddress.fromNumber(i + 1) + const feeRecipient = AztecAddress.fromNumberUnsafe(i + 1) .toString() .toLowerCase(); expectedFeeRecipientAddresses.set(validatorAddress.toLowerCase(), feeRecipient); diff --git a/yarn-project/end-to-end/src/e2e_avm_simulator.test.ts b/yarn-project/end-to-end/src/e2e_avm_simulator.test.ts index 554e336ea56a..ee3c6add14f1 100644 --- a/yarn-project/end-to-end/src/e2e_avm_simulator.test.ts +++ b/yarn-project/end-to-end/src/e2e_avm_simulator.test.ts @@ -193,7 +193,7 @@ describe('e2e_avm_simulator', () => { }); it('Modifies storage (Map)', async () => { - const address = AztecAddress.fromBigInt(9090n); + const address = AztecAddress.fromBigIntUnsafe(9090n); await avmContract.methods.set_storage_map(address, 100).send({ from: defaultAccountAddress }); await avmContract.methods.add_storage_map(address, 100).send({ from: defaultAccountAddress }); expect( @@ -202,7 +202,7 @@ describe('e2e_avm_simulator', () => { }); it('Preserves storage across enqueued public calls', async () => { - const address = AztecAddress.fromBigInt(9090n); + const address = AztecAddress.fromBigIntUnsafe(9090n); // This will create 1 tx with 2 public calls in it. await new BatchCall(wallet, [ avmContract.methods.set_storage_map(address, 100), diff --git a/yarn-project/end-to-end/src/e2e_l1_publisher/e2e_l1_publisher.test.ts b/yarn-project/end-to-end/src/e2e_l1_publisher/e2e_l1_publisher.test.ts index 53ac2043cfbb..7837570a3794 100644 --- a/yarn-project/end-to-end/src/e2e_l1_publisher/e2e_l1_publisher.test.ts +++ b/yarn-project/end-to-end/src/e2e_l1_publisher/e2e_l1_publisher.test.ts @@ -520,7 +520,7 @@ describe('L1Publisher integration', () => { const l1BlockNumber = await l1Client.getBlockNumber(); // random recipient address, just kept consistent for easy testing ts/sol. - const recipientAddress = AztecAddress.fromString( + const recipientAddress = AztecAddress.fromStringUnsafe( '0x1647b194c649f5dd01d7c832f89b0f496043c9150797923ea89e93d5ac619a93', ); diff --git a/yarn-project/end-to-end/src/e2e_publisher_funding_multi.test.ts b/yarn-project/end-to-end/src/e2e_publisher_funding_multi.test.ts index 940174e33e24..b8f5f09965ac 100644 --- a/yarn-project/end-to-end/src/e2e_publisher_funding_multi.test.ts +++ b/yarn-project/end-to-end/src/e2e_publisher_funding_multi.test.ts @@ -66,7 +66,7 @@ describe('e2e_publisher_funding_multi', () => { attester: attesterKey, publisher: [publisherKey1, publisherKey2], coinbase: EthAddress.fromNumber(42).toChecksumString(), - feeRecipient: AztecAddress.fromNumber(42).toString(), + feeRecipient: AztecAddress.fromNumberUnsafe(42).toString(), }, ], fundingAccount: funderKey, diff --git a/yarn-project/end-to-end/src/e2e_sequencer/reload_keystore.test.ts b/yarn-project/end-to-end/src/e2e_sequencer/reload_keystore.test.ts index 601785e53a36..2b9966eac169 100644 --- a/yarn-project/end-to-end/src/e2e_sequencer/reload_keystore.test.ts +++ b/yarn-project/end-to-end/src/e2e_sequencer/reload_keystore.test.ts @@ -101,7 +101,7 @@ describe('e2e_reload_keystore', () => { let publisherKey: EthPrivateKey; const initialCoinbase = EthAddress.fromNumber(42); - const initialFeeRecipient = AztecAddress.fromNumber(42); + const initialFeeRecipient = AztecAddress.fromNumberUnsafe(42); const artifact = StatefulTestContractArtifact; @@ -200,7 +200,7 @@ describe('e2e_reload_keystore', () => { // Write updated keystore and reload // Each validator gets its own new coinbase so we can verify per-validator updates. const newCoinbases = VALIDATOR_KEY_INDICES.map((_, i) => EthAddress.fromNumber(100 + i)); - const newFeeRecipients = VALIDATOR_KEY_INDICES.map((_, i) => AztecAddress.fromNumber(100 + i)); + const newFeeRecipients = VALIDATOR_KEY_INDICES.map((_, i) => AztecAddress.fromNumberUnsafe(100 + i)); // Build updated keystore: all 4 validators (including the previously-excluded validator 4) const updatedKeystore = { diff --git a/yarn-project/end-to-end/src/simulators/lending_simulator.ts b/yarn-project/end-to-end/src/simulators/lending_simulator.ts index defcc7965273..5d29f144481c 100644 --- a/yarn-project/end-to-end/src/simulators/lending_simulator.ts +++ b/yarn-project/end-to-end/src/simulators/lending_simulator.ts @@ -208,7 +208,7 @@ export class LendingSimulator { expect(interestAccumulator).toEqual(this.accumulator); expect(asset['last_updated_ts']).toEqual(BigInt(this.time)); - for (const key of [this.account.address, AztecAddress.fromField(await this.account.key())]) { + for (const key of [this.account.address, AztecAddress.fromFieldUnsafe(await this.account.key())]) { const { result: privatePos } = await this.lendingContract.methods .get_position(key) .simulate({ from: this.account.address }); diff --git a/yarn-project/key-store/src/key_store.test.ts b/yarn-project/key-store/src/key_store.test.ts index e061279b1fee..74df521e1a0d 100644 --- a/yarn-project/key-store/src/key_store.test.ts +++ b/yarn-project/key-store/src/key_store.test.ts @@ -42,7 +42,7 @@ describe('KeyStore', () => { expect(masterIncomingViewingSecretKey.equals(keys.masterIncomingViewingSecretKey)).toBe(true); // Arbitrary app contract address - const appAddress = AztecAddress.fromBigInt(624n); + const appAddress = AztecAddress.fromBigIntUnsafe(624n); const { pkMHash: obtainedNpkMHash, skApp: appNullifierHidingKey } = await keyStore.getKeyValidationRequest( computedMasterNullifierPublicKeyHash, diff --git a/yarn-project/key-store/src/key_store.ts b/yarn-project/key-store/src/key_store.ts index 3c3c05ada9c2..d347c4f863b7 100644 --- a/yarn-project/key-store/src/key_store.ts +++ b/yarn-project/key-store/src/key_store.ts @@ -109,7 +109,7 @@ export class KeyStore { const allMapKeys = await toArray(this.#keys.keysAsync()); // We return account addresses based on the map keys that end with '-ivsk_m' const accounts = allMapKeys.filter(key => key.endsWith('-ivsk_m')).map(key => key.split('-')[0]); - return accounts.map(account => AztecAddress.fromString(account)); + return accounts.map(account => AztecAddress.fromStringUnsafe(account)); } /** Checks whether an account is registered in the key store. */ @@ -340,7 +340,7 @@ export class KeyStore { if (Buffer.from(val).equals(valueBuffer)) { for (const prefix of KEY_PREFIXES) { if (key.includes(`-${prefix}`)) { - const account = AztecAddress.fromString(key.split('-')[0]); + const account = AztecAddress.fromStringUnsafe(key.split('-')[0]); return [prefix, account]; } } diff --git a/yarn-project/node-keystore/src/keystore_manager.test.ts b/yarn-project/node-keystore/src/keystore_manager.test.ts index 85f355b5fcc2..a0bcf268d5cf 100644 --- a/yarn-project/node-keystore/src/keystore_manager.test.ts +++ b/yarn-project/node-keystore/src/keystore_manager.test.ts @@ -95,7 +95,9 @@ describe('KeystoreManager', () => { validators: [ { attester: EthAddress.random(), - feeRecipient: AztecAddress.fromString('0x1111111111111111111111111111111111111111111111111111111111111111'), + feeRecipient: AztecAddress.fromStringUnsafe( + '0x1111111111111111111111111111111111111111111111111111111111111111', + ), }, ], }; @@ -105,7 +107,7 @@ describe('KeystoreManager', () => { expect( feeRecipient.equals( - AztecAddress.fromString('0x1111111111111111111111111111111111111111111111111111111111111111'), + AztecAddress.fromStringUnsafe('0x1111111111111111111111111111111111111111111111111111111111111111'), ), ).toBeTruthy(); }); diff --git a/yarn-project/node-keystore/src/schemas.test.ts b/yarn-project/node-keystore/src/schemas.test.ts index 8f56315d535d..a0c53a330568 100644 --- a/yarn-project/node-keystore/src/schemas.test.ts +++ b/yarn-project/node-keystore/src/schemas.test.ts @@ -30,7 +30,7 @@ describe('Keystore Schema Validation', () => { expect(parsed.validators![0].attester).toBe('0x1234567890123456789012345678901234567890123456789012345678901234'); expect( parsed.validators![0].feeRecipient?.equals( - AztecAddress.fromString('0x1234567890123456789012345678901234567890123456789012345678901234'), + AztecAddress.fromStringUnsafe('0x1234567890123456789012345678901234567890123456789012345678901234'), ), ).toBeTruthy(); }); @@ -190,7 +190,7 @@ describe('Keystore Schema Validation', () => { expect(parsed.coinbase?.equals(EthAddress.fromString('0x1111111111111111111111111111111111111111'))).toBeTruthy(); expect( parsed.feeRecipient?.equals( - AztecAddress.fromString('0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef'), + AztecAddress.fromStringUnsafe('0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef'), ), ).toBeTruthy(); } @@ -210,7 +210,7 @@ describe('Keystore Schema Validation', () => { ).toBeTruthy(); expect( parsed.validators![2].feeRecipient?.equals( - AztecAddress.fromString('0x0bcdef0bcdef0bcdef0bcdef0bcdef0bcdef0bcdef0bcdef0bcdef0bcdef0bcd'), + AztecAddress.fromStringUnsafe('0x0bcdef0bcdef0bcdef0bcdef0bcdef0bcdef0bcdef0bcdef0bcdef0bcdef0bcd'), ), ).toBeTruthy(); }); diff --git a/yarn-project/node-keystore/src/validation.test.ts b/yarn-project/node-keystore/src/validation.test.ts index 02aefa06de84..e04b6fd01f47 100644 --- a/yarn-project/node-keystore/src/validation.test.ts +++ b/yarn-project/node-keystore/src/validation.test.ts @@ -371,7 +371,7 @@ describe('Keystore Duplication Validation', () => { expect(v0.publisher).toBeDefined(); // array including private key, address, remote signer account, json v3 dir expect( (v0.feeRecipient as AztecAddress).equals( - AztecAddress.fromString('0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef'), + AztecAddress.fromStringUnsafe('0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef'), ), ).toBeTruthy(); expect(typeof v0.remoteSigner === 'string').toBe(true); @@ -382,7 +382,7 @@ describe('Keystore Duplication Validation', () => { expect(v1.publisher).toBeDefined(); // mnemonic config expect( (v1.feeRecipient as AztecAddress).equals( - AztecAddress.fromString('0x0bcdef0bcdef0bcdef0bcdef0bcdef0bcdef0bcdef0bcdef0bcdef0bcdef0bcd'), + AztecAddress.fromStringUnsafe('0x0bcdef0bcdef0bcdef0bcdef0bcdef0bcdef0bcdef0bcdef0bcdef0bcdef0bcd'), ), ).toBeTruthy(); expect(v1.fundingAccount).toBeDefined(); diff --git a/yarn-project/noir-protocol-circuits-types/src/conversion/common.ts b/yarn-project/noir-protocol-circuits-types/src/conversion/common.ts index 5868f473ca49..92f3dcd6d62f 100644 --- a/yarn-project/noir-protocol-circuits-types/src/conversion/common.ts +++ b/yarn-project/noir-protocol-circuits-types/src/conversion/common.ts @@ -225,7 +225,7 @@ export function mapAztecAddressToNoir(address: AztecAddress): NoirAztecAddress { * @returns The aztec address. */ export function mapAztecAddressFromNoir(address: NoirAztecAddress): AztecAddress { - return AztecAddress.fromField(mapFieldFromNoir(address.inner)); + return AztecAddress.fromFieldUnsafe(mapFieldFromNoir(address.inner)); } /** diff --git a/yarn-project/p2p/src/config.ts b/yarn-project/p2p/src/config.ts index e05747c8b1e3..cd34de88bade 100644 --- a/yarn-project/p2p/src/config.ts +++ b/yarn-project/p2p/src/config.ts @@ -740,7 +740,7 @@ export function parseAllowList(value: string): AllowedElement[] { if (typeString === 'I') { entries.push({ - address: AztecAddress.fromString(identifierString), + address: AztecAddress.fromStringUnsafe(identifierString), selector, ...flags, }); diff --git a/yarn-project/p2p/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts b/yarn-project/p2p/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts index 6badaf736d0a..4f116dfb8d56 100644 --- a/yarn-project/p2p/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts +++ b/yarn-project/p2p/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts @@ -86,7 +86,7 @@ export class FeePayerBalanceEvictionRule implements EvictionRule { publicStateSource: DatabasePublicStateSource, pool: PoolOperations, ): Promise { - const feePayer = AztecAddress.fromString(feePayerStr); + const feePayer = AztecAddress.fromStringUnsafe(feePayerStr); const initialBalance = ( await publicStateSource.storageRead( ProtocolContractAddress.FeeJuice, diff --git a/yarn-project/p2p/src/mem_pools/tx_pool_v2/tx_pool_v2.test.ts b/yarn-project/p2p/src/mem_pools/tx_pool_v2/tx_pool_v2.test.ts index 53f0ec8d9be5..6d6adbd073d1 100644 --- a/yarn-project/p2p/src/mem_pools/tx_pool_v2/tx_pool_v2.test.ts +++ b/yarn-project/p2p/src/mem_pools/tx_pool_v2/tx_pool_v2.test.ts @@ -1036,7 +1036,7 @@ describe('TxPoolV2', () => { }); it('pre-protected tx bypasses insufficient balance pre-add rule', async () => { - const sharedFeePayer = AztecAddress.fromBigInt(999n); + const sharedFeePayer = AztecAddress.fromBigIntUnsafe(999n); // Set balance to 0 - normally tx would be ignored setFeePayerBalanceForPreProtect(0n); @@ -1129,7 +1129,7 @@ describe('TxPoolV2', () => { }); it('pre-protected tx does not trigger post-add eviction rules', async () => { - const sharedFeePayer = AztecAddress.fromBigInt(999n); + const sharedFeePayer = AztecAddress.fromBigIntUnsafe(999n); // Balance covers only one tx setFeePayerBalanceForPreProtect(DEFAULT_TX_FEE_LIMIT + DEFAULT_TX_FEE_LIMIT / 2n); @@ -1294,7 +1294,7 @@ describe('TxPoolV2', () => { }); it('tx ignored due to insufficient balance succeeds after pre-protection', async () => { - const sharedFeePayer = AztecAddress.fromBigInt(999n); + const sharedFeePayer = AztecAddress.fromBigIntUnsafe(999n); // Set balance to 0 setFeePayerBalanceForPreProtect(0n); @@ -3441,7 +3441,7 @@ describe('TxPoolV2', () => { }); it('high priority tx evicts lower priority tx from same fee payer', async () => { - const sharedFeePayer = AztecAddress.fromBigInt(999n); + const sharedFeePayer = AztecAddress.fromBigIntUnsafe(999n); // Set balance to cover only one tx setFeePayerBalance(DEFAULT_TX_FEE_LIMIT + DEFAULT_TX_FEE_LIMIT / 2n); @@ -3470,7 +3470,7 @@ describe('TxPoolV2', () => { }); it('low priority tx ignored when fee payer balance exhausted by existing tx', async () => { - const sharedFeePayer = AztecAddress.fromBigInt(999n); + const sharedFeePayer = AztecAddress.fromBigIntUnsafe(999n); // Balance covers only one tx setFeePayerBalance(DEFAULT_TX_FEE_LIMIT + DEFAULT_TX_FEE_LIMIT / 2n); @@ -3498,7 +3498,7 @@ describe('TxPoolV2', () => { }); it('batch from same fee payer - only top N by priority accepted', async () => { - const sharedFeePayer = AztecAddress.fromBigInt(999n); + const sharedFeePayer = AztecAddress.fromBigIntUnsafe(999n); // Balance covers exactly 2 tx fee limits setFeePayerBalance(DEFAULT_TX_FEE_LIMIT * 2n + DEFAULT_TX_FEE_LIMIT / 2n); @@ -3546,7 +3546,7 @@ describe('TxPoolV2', () => { }; it('evicts low-priority txs after BLOCK_MINED when balance is insufficient', async () => { - const sharedFeePayer = AztecAddress.fromBigInt(999n); + const sharedFeePayer = AztecAddress.fromBigIntUnsafe(999n); // Initial balance covers all 3 txs setFeePayerBalance(DEFAULT_TX_FEE_LIMIT * 3n + DEFAULT_TX_FEE_LIMIT / 2n); @@ -3587,7 +3587,7 @@ describe('TxPoolV2', () => { }); it('evicts low-priority txs after CHAIN_PRUNED when balance is insufficient', async () => { - const sharedFeePayer = AztecAddress.fromBigInt(999n); + const sharedFeePayer = AztecAddress.fromBigIntUnsafe(999n); // Initial balance covers both txs setFeePayerBalance(DEFAULT_TX_FEE_LIMIT * 2n + DEFAULT_TX_FEE_LIMIT / 2n); @@ -3621,7 +3621,7 @@ describe('TxPoolV2', () => { }); it('priority ordering is correct - highest priority funded first', async () => { - const sharedFeePayer = AztecAddress.fromBigInt(999n); + const sharedFeePayer = AztecAddress.fromBigIntUnsafe(999n); // Initial balance covers all 3 txs setFeePayerBalance(DEFAULT_TX_FEE_LIMIT * 3n + DEFAULT_TX_FEE_LIMIT / 2n); @@ -3663,7 +3663,7 @@ describe('TxPoolV2', () => { }); it('does not evict when balance is sufficient', async () => { - const sharedFeePayer = AztecAddress.fromBigInt(999n); + const sharedFeePayer = AztecAddress.fromBigIntUnsafe(999n); // Balance covers all txs setFeePayerBalance(BigInt(1e18)); @@ -4737,7 +4737,7 @@ describe('TxPoolV2', () => { }); it('fee payer balance + nullifier conflict - higher priority wins both', async () => { - const sharedFeePayer = AztecAddress.fromBigInt(999n); + const sharedFeePayer = AztecAddress.fromBigIntUnsafe(999n); // Set balance to only cover 1 tx db.getLeafPreimage.mockImplementation((tree, index) => { if (tree === MerkleTreeId.PUBLIC_DATA_TREE) { @@ -4781,8 +4781,8 @@ describe('TxPoolV2', () => { }); it('batch with nullifier conflicts across different fee payers', async () => { - const feePayerA = AztecAddress.fromBigInt(111n); - const feePayerB = AztecAddress.fromBigInt(222n); + const feePayerA = AztecAddress.fromBigIntUnsafe(111n); + const feePayerB = AztecAddress.fromBigIntUnsafe(222n); // tx1 (fee payer A, low priority) and tx2 (fee payer B, high priority) share nullifier const tx1 = await mockTx(1, { diff --git a/yarn-project/p2p/src/mem_pools/tx_pool_v2/tx_pool_v2_bench.test.ts b/yarn-project/p2p/src/mem_pools/tx_pool_v2/tx_pool_v2_bench.test.ts index b018afcecbfb..c2399cf02084 100644 --- a/yarn-project/p2p/src/mem_pools/tx_pool_v2/tx_pool_v2_bench.test.ts +++ b/yarn-project/p2p/src/mem_pools/tx_pool_v2/tx_pool_v2_bench.test.ts @@ -37,7 +37,11 @@ describe('TxPoolV2: benchmarks', () => { const metrics = new TxPoolBenchMetrics(); // Use a fixed set of fee payers to test fee payer index with multiple txs per payer - const feePayers = [AztecAddress.fromBigInt(1n), AztecAddress.fromBigInt(2n), AztecAddress.fromBigInt(3n)]; + const feePayers = [ + AztecAddress.fromBigIntUnsafe(1n), + AztecAddress.fromBigIntUnsafe(2n), + AztecAddress.fromBigIntUnsafe(3n), + ]; // Pre-created transaction pools for different sizes const POOL_SIZES = [10, 100, 1000] as const; diff --git a/yarn-project/p2p/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts b/yarn-project/p2p/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts index 8cfb4a7c24ab..13397cc4476f 100644 --- a/yarn-project/p2p/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +++ b/yarn-project/p2p/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts @@ -1139,7 +1139,7 @@ export class TxPoolV2Impl { const publicStateSource = new DatabasePublicStateSource(db); const balance = await publicStateSource.storageRead( ProtocolContractAddress.FeeJuice, - await computeFeePayerBalanceStorageSlot(AztecAddress.fromString(feePayer)), + await computeFeePayerBalanceStorageSlot(AztecAddress.fromStringUnsafe(feePayer)), ); return balance.toBigInt(); }, diff --git a/yarn-project/p2p/src/msg_validators/tx_validator/phases_validator.test.ts b/yarn-project/p2p/src/msg_validators/tx_validator/phases_validator.test.ts index 2d94c2f4e65d..1e374af572e7 100644 --- a/yarn-project/p2p/src/msg_validators/tx_validator/phases_validator.test.ts +++ b/yarn-project/p2p/src/msg_validators/tx_validator/phases_validator.test.ts @@ -427,7 +427,7 @@ describe('PhasesTxValidator', () => { }); describe('rejectNullMsgSender validation', () => { - const nullMsgSender = AztecAddress.fromBigInt(NULL_MSG_SENDER_CONTRACT_ADDRESS); + const nullMsgSender = AztecAddress.fromBigIntUnsafe(NULL_MSG_SENDER_CONTRACT_ADDRESS); let rejectNullContract: AztecAddress; let rejectNullSelector: FunctionSelector; let noRejectNullContract: AztecAddress; diff --git a/yarn-project/p2p/src/msg_validators/tx_validator/phases_validator.ts b/yarn-project/p2p/src/msg_validators/tx_validator/phases_validator.ts index 39362bd39dd2..4156b3b91770 100644 --- a/yarn-project/p2p/src/msg_validators/tx_validator/phases_validator.ts +++ b/yarn-project/p2p/src/msg_validators/tx_validator/phases_validator.ts @@ -97,7 +97,7 @@ export class PhasesTxValidator implements TxValidator { } if ( entry.rejectNullMsgSender && - publicCall.request.msgSender.equals(AztecAddress.fromBigInt(NULL_MSG_SENDER_CONTRACT_ADDRESS)) + publicCall.request.msgSender.equals(AztecAddress.fromBigIntUnsafe(NULL_MSG_SENDER_CONTRACT_ADDRESS)) ) { return TX_ERROR_SETUP_NULL_MSG_SENDER; } @@ -130,7 +130,7 @@ export class PhasesTxValidator implements TxValidator { } if ( entry.rejectNullMsgSender && - publicCall.request.msgSender.equals(AztecAddress.fromBigInt(NULL_MSG_SENDER_CONTRACT_ADDRESS)) + publicCall.request.msgSender.equals(AztecAddress.fromBigIntUnsafe(NULL_MSG_SENDER_CONTRACT_ADDRESS)) ) { return TX_ERROR_SETUP_NULL_MSG_SENDER; } diff --git a/yarn-project/p2p/src/msg_validators/tx_validator/tx_validator_bench.test.ts b/yarn-project/p2p/src/msg_validators/tx_validator/tx_validator_bench.test.ts index c4bc38f7103f..967fac31ab46 100644 --- a/yarn-project/p2p/src/msg_validators/tx_validator/tx_validator_bench.test.ts +++ b/yarn-project/p2p/src/msg_validators/tx_validator/tx_validator_bench.test.ts @@ -105,7 +105,7 @@ describe('TxValidator: Benchmarks', () => { ccLogFields = ContractClassLogFields.random(); const logHash = await ccLogFields.hash(); const scopedLogHash = LogHash.from({ value: logHash, length: CONTRACT_CLASS_LOG_SIZE_IN_FIELDS }).scope( - AztecAddress.fromNumber(1), + AztecAddress.fromNumberUnsafe(1), ); ccLogTx.contractClassLogFields.push(ccLogFields); ccLogTx.data.forPublic!.nonRevertibleAccumulatedData.contractClassLogsHashes[0] = scopedLogHash; @@ -172,7 +172,7 @@ describe('TxValidator: Benchmarks', () => { phasesPrivateTx = await mockTxForRollup(10); // PhasesTxValidator - public tx with allowed setup - const allowedAddress = AztecAddress.fromNumber(999); + const allowedAddress = AztecAddress.fromNumberUnsafe(999); const allowedSelector = makeSelector(1); phasesPublicTx = await mockTx(11, { numberOfNonRevertiblePublicCallRequests: 1 }); await patchNonRevertibleFn(phasesPublicTx, 0, { address: allowedAddress, selector: allowedSelector }); diff --git a/yarn-project/protocol-contracts/src/scripts/generate_data.ts b/yarn-project/protocol-contracts/src/scripts/generate_data.ts index e97b2909b948..c734ba42c641 100644 --- a/yarn-project/protocol-contracts/src/scripts/generate_data.ts +++ b/yarn-project/protocol-contracts/src/scripts/generate_data.ts @@ -132,7 +132,9 @@ function generateSalts(names: string[]) { } function generateContractAddresses(names: string[]) { - const addresses = names.map(name => `${name}: AztecAddress.fromBigInt(${contractAddressMapping[name]}n)`).join(',\n'); + const addresses = names + .map(name => `${name}: AztecAddress.fromBigIntUnsafe(${contractAddressMapping[name]}n)`) + .join(',\n'); return ` export const ProtocolContractAddress: Record = { ${addresses} @@ -143,7 +145,7 @@ function generateContractAddresses(names: string[]) { function generateDerivedAddresses(names: string[], contractData: ContractData[]) { return ` export const ProtocolContractDerivedAddress = { - ${contractData.map((d, i) => `${names[i]}: AztecAddress.fromString('${d.address.toString()}')`).join(',\n')} + ${contractData.map((d, i) => `${names[i]}: AztecAddress.fromStringUnsafe('${d.address.toString()}')`).join(',\n')} }; `; } @@ -200,7 +202,7 @@ async function generateProtocolContractsList(names: string[], contractData: Cont return ` export const ProtocolContractsList = new ProtocolContracts([ - ${list.map(address => `AztecAddress.fromString('${address.toString()}')`).join(',\n')} + ${list.map(address => `AztecAddress.fromStringUnsafe('${address.toString()}')`).join(',\n')} ]); export const protocolContractsHash = Fr.fromString('${(await new ProtocolContracts(list).hash()).toString()}'); @@ -257,7 +259,7 @@ async function main() { const artifact = await copyArtifact(srcName, destName); await generateDeclarationFile(destName); contractDataList.push( - await computeContractData(artifact, AztecAddress.fromBigInt(BigInt(contractAddressMapping[destName]))), + await computeContractData(artifact, AztecAddress.fromBigIntUnsafe(BigInt(contractAddressMapping[destName]))), ); } diff --git a/yarn-project/prover-client/src/light/lightweight_checkpoint_builder.bench.test.ts b/yarn-project/prover-client/src/light/lightweight_checkpoint_builder.bench.test.ts index 907368ea83ab..a44f01610f14 100644 --- a/yarn-project/prover-client/src/light/lightweight_checkpoint_builder.bench.test.ts +++ b/yarn-project/prover-client/src/light/lightweight_checkpoint_builder.bench.test.ts @@ -41,7 +41,7 @@ describe('LightweightCheckpointBuilder benchmarks', () => { const toGithubActionBenchmarkJSON = (indent = 2) => JSON.stringify(results, null, indent); beforeEach(async () => { - feePayer = AztecAddress.fromNumber(42222); + feePayer = AztecAddress.fromNumberUnsafe(42222); feePayerBalance = new Fr(10n ** 20n); const feePayerSlot = await computeFeePayerBalanceLeafSlot(feePayer); const genesis: GenesisData = { @@ -120,7 +120,7 @@ describe('LightweightCheckpointBuilder benchmarks', () => { // Add a full contract class log (CONTRACT_CLASS_LOG_SIZE_IN_FIELDS = 3,023 blob fields). tx.txEffect.contractClassLogs = [ new ContractClassLog( - AztecAddress.fromNumber(seed), + AztecAddress.fromNumberUnsafe(seed), ContractClassLogFields.random(CONTRACT_CLASS_LOG_SIZE_IN_FIELDS), CONTRACT_CLASS_LOG_SIZE_IN_FIELDS, ), diff --git a/yarn-project/prover-client/src/light/lightweight_checkpoint_builder.test.ts b/yarn-project/prover-client/src/light/lightweight_checkpoint_builder.test.ts index 7ed3e2623b23..2ab1c908f2b2 100644 --- a/yarn-project/prover-client/src/light/lightweight_checkpoint_builder.test.ts +++ b/yarn-project/prover-client/src/light/lightweight_checkpoint_builder.test.ts @@ -28,7 +28,7 @@ describe('LightweightCheckpointBuilder', () => { beforeEach(async () => { // Set up fee payer with balance - feePayer = AztecAddress.fromNumber(42222); + feePayer = AztecAddress.fromNumberUnsafe(42222); feePayerBalance = new Fr(10n ** 20n); const feePayerSlot = await computeFeePayerBalanceLeafSlot(feePayer); const genesis: GenesisData = { diff --git a/yarn-project/prover-client/src/mocks/test_context.ts b/yarn-project/prover-client/src/mocks/test_context.ts index 065e19142844..24096fe0aa99 100644 --- a/yarn-project/prover-client/src/mocks/test_context.ts +++ b/yarn-project/prover-client/src/mocks/test_context.ts @@ -86,7 +86,7 @@ export class TestContext { ) { const directoriesToCleanup: string[] = []; - const feePayer = AztecAddress.fromNumber(42222); + const feePayer = AztecAddress.fromNumberUnsafe(42222); const initialFeePayerBalance = new Fr(10n ** 20n); const feePayerSlot = await computeFeePayerBalanceLeafSlot(feePayer); const genesis: GenesisData = { diff --git a/yarn-project/pxe/src/contract_function_simulator/noir-structs/event_validation_request.test.ts b/yarn-project/pxe/src/contract_function_simulator/noir-structs/event_validation_request.test.ts index b7a6eaf9ce96..dc614c8f8354 100644 --- a/yarn-project/pxe/src/contract_function_simulator/noir-structs/event_validation_request.test.ts +++ b/yarn-project/pxe/src/contract_function_simulator/noir-structs/event_validation_request.test.ts @@ -29,7 +29,7 @@ describe('EventValidationRequest', () => { const request = EventValidationRequest.fromFields(serialized); - expect(request.contractAddress).toEqual(AztecAddress.fromBigInt(1n)); + expect(request.contractAddress).toEqual(AztecAddress.fromBigIntUnsafe(1n)); expect(request.eventTypeId).toEqual(new EventSelector(2)); expect(request.randomness).toEqual(new Fr(3)); expect(request.serializedEvent).toEqual([new Fr(4), new Fr(5)]); diff --git a/yarn-project/pxe/src/contract_function_simulator/noir-structs/event_validation_request.ts b/yarn-project/pxe/src/contract_function_simulator/noir-structs/event_validation_request.ts index 4a48bf4805fd..21b3823f4164 100644 --- a/yarn-project/pxe/src/contract_function_simulator/noir-structs/event_validation_request.ts +++ b/yarn-project/pxe/src/contract_function_simulator/noir-structs/event_validation_request.ts @@ -21,7 +21,7 @@ export class EventValidationRequest { static fromFields(fields: Fr[] | FieldReader): EventValidationRequest { const reader = FieldReader.asReader(fields); - const contractAddress = AztecAddress.fromField(reader.readField()); + const contractAddress = AztecAddress.fromFieldUnsafe(reader.readField()); const eventTypeId = EventSelector.fromField(reader.readField()); const randomness = reader.readField(); diff --git a/yarn-project/pxe/src/contract_function_simulator/noir-structs/log_retrieval_request.test.ts b/yarn-project/pxe/src/contract_function_simulator/noir-structs/log_retrieval_request.test.ts index 175f7f906bcb..4ce60ac76e72 100644 --- a/yarn-project/pxe/src/contract_function_simulator/noir-structs/log_retrieval_request.test.ts +++ b/yarn-project/pxe/src/contract_function_simulator/noir-structs/log_retrieval_request.test.ts @@ -19,7 +19,7 @@ describe('LogRetrievalRequest', () => { const request = LogRetrievalRequest.fromFields(serialized); - expect(request.contractAddress).toEqual(AztecAddress.fromBigInt(1n)); + expect(request.contractAddress).toEqual(AztecAddress.fromBigIntUnsafe(1n)); expect(request.tag).toEqual(new Tag(new Fr(2))); expect(request.source).toEqual(LogSource.PUBLIC_AND_PRIVATE); expect(request.fromBlock).toBeUndefined(); @@ -39,7 +39,7 @@ describe('LogRetrievalRequest', () => { const request = LogRetrievalRequest.fromFields(serialized); - expect(request.contractAddress).toEqual(AztecAddress.fromBigInt(1n)); + expect(request.contractAddress).toEqual(AztecAddress.fromBigIntUnsafe(1n)); expect(request.tag).toEqual(new Tag(new Fr(2))); expect(request.source).toEqual(LogSource.PUBLIC); expect(request.fromBlock).toEqual(BlockNumber(10)); @@ -62,7 +62,7 @@ describe('LogRetrievalRequest', () => { it('accepts all valid LogSource values', () => { for (const source of [LogSource.PRIVATE, LogSource.PUBLIC, LogSource.PUBLIC_AND_PRIVATE]) { - const fields = new LogRetrievalRequest(AztecAddress.fromBigInt(1n), new Tag(new Fr(2)), source).toFields(); + const fields = new LogRetrievalRequest(AztecAddress.fromBigIntUnsafe(1n), new Tag(new Fr(2)), source).toFields(); const restored = LogRetrievalRequest.fromFields(fields); expect(restored.source).toEqual(source); } @@ -70,7 +70,7 @@ describe('LogRetrievalRequest', () => { it('round-trips through toFields and fromFields', () => { const original = new LogRetrievalRequest( - AztecAddress.fromBigInt(42n), + AztecAddress.fromBigIntUnsafe(42n), new Tag(new Fr(99)), LogSource.PRIVATE, BlockNumber(5), diff --git a/yarn-project/pxe/src/contract_function_simulator/noir-structs/log_retrieval_request.ts b/yarn-project/pxe/src/contract_function_simulator/noir-structs/log_retrieval_request.ts index 549b452d2d39..d2a6a189c1f9 100644 --- a/yarn-project/pxe/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +++ b/yarn-project/pxe/src/contract_function_simulator/noir-structs/log_retrieval_request.ts @@ -39,7 +39,7 @@ export class LogRetrievalRequest { static fromFields(fields: Fr[] | FieldReader): LogRetrievalRequest { const reader = FieldReader.asReader(fields); - const contractAddress = AztecAddress.fromField(reader.readField()); + const contractAddress = AztecAddress.fromFieldUnsafe(reader.readField()); const tag = new Tag(reader.readField()); const sourceNum = reader.readField().toNumber(); if (!(sourceNum in LogSource)) { diff --git a/yarn-project/pxe/src/contract_function_simulator/noir-structs/note_validation_request.test.ts b/yarn-project/pxe/src/contract_function_simulator/noir-structs/note_validation_request.test.ts index 6c1b4384b3e6..4912c772f1b5 100644 --- a/yarn-project/pxe/src/contract_function_simulator/noir-structs/note_validation_request.test.ts +++ b/yarn-project/pxe/src/contract_function_simulator/noir-structs/note_validation_request.test.ts @@ -29,8 +29,8 @@ describe('NoteValidationRequest', () => { const request = NoteValidationRequest.fromFields(serialized); - expect(request.contractAddress).toEqual(AztecAddress.fromBigInt(1n)); - expect(request.owner).toEqual(AztecAddress.fromBigInt(50n)); + expect(request.contractAddress).toEqual(AztecAddress.fromBigIntUnsafe(1n)); + expect(request.owner).toEqual(AztecAddress.fromBigIntUnsafe(50n)); expect(request.storageSlot).toEqual(new Fr(2)); expect(request.randomness).toEqual(new Fr(42)); expect(request.noteNonce).toEqual(new Fr(3)); diff --git a/yarn-project/pxe/src/contract_function_simulator/noir-structs/note_validation_request.ts b/yarn-project/pxe/src/contract_function_simulator/noir-structs/note_validation_request.ts index 82099f6e65ef..29217123838a 100644 --- a/yarn-project/pxe/src/contract_function_simulator/noir-structs/note_validation_request.ts +++ b/yarn-project/pxe/src/contract_function_simulator/noir-structs/note_validation_request.ts @@ -23,8 +23,8 @@ export class NoteValidationRequest { static fromFields(fields: Fr[] | FieldReader): NoteValidationRequest { const reader = FieldReader.asReader(fields); - const contractAddress = AztecAddress.fromField(reader.readField()); - const owner = AztecAddress.fromField(reader.readField()); + const contractAddress = AztecAddress.fromFieldUnsafe(reader.readField()); + const owner = AztecAddress.fromFieldUnsafe(reader.readField()); const storageSlot = reader.readField(); const randomness = reader.readField(); const noteNonce = reader.readField(); diff --git a/yarn-project/pxe/src/contract_function_simulator/oracle/note_packing_utils.test.ts b/yarn-project/pxe/src/contract_function_simulator/oracle/note_packing_utils.test.ts index 45aa99434acb..d881fb9d6215 100644 --- a/yarn-project/pxe/src/contract_function_simulator/oracle/note_packing_utils.test.ts +++ b/yarn-project/pxe/src/contract_function_simulator/oracle/note_packing_utils.test.ts @@ -7,8 +7,8 @@ import { packAsHintedNote } from './note_packing_utils.js'; it('packs hinted note', () => { const noteInfo = { - contractAddress: AztecAddress.fromField(new Fr(1n)), - owner: AztecAddress.fromField(new Fr(5n)), + contractAddress: AztecAddress.fromFieldUnsafe(new Fr(1n)), + owner: AztecAddress.fromFieldUnsafe(new Fr(5n)), randomness: new Fr(42n), storageSlot: new Fr(100n), noteNonce: new Fr(2n), diff --git a/yarn-project/pxe/src/contract_function_simulator/oracle/oracle_type_mappings.ts b/yarn-project/pxe/src/contract_function_simulator/oracle/oracle_type_mappings.ts index 931eb11c5302..8ea4824fb41c 100644 --- a/yarn-project/pxe/src/contract_function_simulator/oracle/oracle_type_mappings.ts +++ b/yarn-project/pxe/src/contract_function_simulator/oracle/oracle_type_mappings.ts @@ -173,7 +173,7 @@ export const STR: TypeMapping = { export const AZTEC_ADDRESS: TypeMapping = { serialization: { fn: v => [v.toField()] }, - deserialization: { fn: ([reader]) => AztecAddress.fromField(reader.readField()), slots: 1 }, + deserialization: { fn: ([reader]) => AztecAddress.fromFieldUnsafe(reader.readField()), slots: 1 }, }; export const BLOCK_HASH: TypeMapping = { @@ -291,7 +291,7 @@ export const PUBLIC_KEYS_AND_PARTIAL_ADDRESS: TypeMapping<{ export const CONTRACT_CLASS_LOG_INPUT: TypeMapping = { deserialization: { fn: ([addrReader, fieldsReader, lengthReader]) => { - const addr = AztecAddress.fromField(addrReader.readField()); + const addr = AztecAddress.fromFieldUnsafe(addrReader.readField()); const fields = new ContractClassLogFields([...fieldsReader.readFieldArray(fieldsReader.remainingFields())]); const length = lengthReader.readField().toNumber(); return new ContractClassLog(addr, fields, length); @@ -473,7 +473,7 @@ export function BOUNDED_VEC( * Wraps an inner TypeMapping in Noir-style `Option`. Adds a discriminant slot and uses the handler-provided * `Option.none(shape)` template to produce a correctly-sized zero-filled output for the None case. * - * @example Serializing `Option.some(AztecAddress.fromField(Fr(42)))` with `OPTION(AZTEC_ADDRESS)`: + * @example Serializing `Option.some(AztecAddress.fromFieldUnsafe(Fr(42)))` with `OPTION(AZTEC_ADDRESS)`: * ``` * slot 0: Fr(1) // discriminant: Some * slot 1: Fr(42) // inner value diff --git a/yarn-project/pxe/src/contract_function_simulator/oracle/private_execution.test.ts b/yarn-project/pxe/src/contract_function_simulator/oracle/private_execution.test.ts index d019ec71a001..daffbb77869a 100644 --- a/yarn-project/pxe/src/contract_function_simulator/oracle/private_execution.test.ts +++ b/yarn-project/pxe/src/contract_function_simulator/oracle/private_execution.test.ts @@ -534,7 +534,7 @@ describe('Private Execution test suite', () => { anchorBlockHeader, functionName: 'constructor', contractAddress: instance.address, - msgSender: AztecAddress.fromNumber(1234), + msgSender: AztecAddress.fromNumberUnsafe(1234), }); const result = executionResult.entrypoint.nestedExecutionResults[0]; diff --git a/yarn-project/pxe/src/contract_function_simulator/oracle/private_execution_oracle.test.ts b/yarn-project/pxe/src/contract_function_simulator/oracle/private_execution_oracle.test.ts index b5705dad2af8..365c08e6fda1 100644 --- a/yarn-project/pxe/src/contract_function_simulator/oracle/private_execution_oracle.test.ts +++ b/yarn-project/pxe/src/contract_function_simulator/oracle/private_execution_oracle.test.ts @@ -37,7 +37,7 @@ describe('PrivateExecutionOracle', () => { beforeAll(async () => { contractAddress = await AztecAddress.random(); callContext = new CallContext( - AztecAddress.fromField(Fr.MAX_FIELD_VALUE), + AztecAddress.fromFieldUnsafe(Fr.MAX_FIELD_VALUE), contractAddress, FunctionSelector.empty(), false, diff --git a/yarn-project/pxe/src/contract_function_simulator/transient_array_service.test.ts b/yarn-project/pxe/src/contract_function_simulator/transient_array_service.test.ts index beed9990f050..84b877132d91 100644 --- a/yarn-project/pxe/src/contract_function_simulator/transient_array_service.test.ts +++ b/yarn-project/pxe/src/contract_function_simulator/transient_array_service.test.ts @@ -5,8 +5,8 @@ import { TransientArrayService } from './transient_array_service.js'; describe('TransientArrayService', () => { let service: TransientArrayService; - const contractA = AztecAddress.fromField(new Fr(0xaa)); - const contractB = AztecAddress.fromField(new Fr(0xbb)); + const contractA = AztecAddress.fromFieldUnsafe(new Fr(0xaa)); + const contractB = AztecAddress.fromFieldUnsafe(new Fr(0xbb)); const slot = Fr.fromString('0x01'); const otherSlot = Fr.fromString('0x02'); diff --git a/yarn-project/pxe/src/contract_sync/contract_sync_service.test.ts b/yarn-project/pxe/src/contract_sync/contract_sync_service.test.ts index ad59004f7f91..97f4f4177f6e 100644 --- a/yarn-project/pxe/src/contract_sync/contract_sync_service.test.ts +++ b/yarn-project/pxe/src/contract_sync/contract_sync_service.test.ts @@ -21,9 +21,9 @@ describe('ContractSyncService', () => { let service: ContractSyncService; let utilityExecutor: jest.Mock<(call: FunctionCall, scopes: AztecAddress[]) => Promise>; - const contractAddress = AztecAddress.fromBigInt(100n); - const scopeA = AztecAddress.fromBigInt(200n); - const scopeB = AztecAddress.fromBigInt(201n); + const contractAddress = AztecAddress.fromBigIntUnsafe(100n); + const scopeA = AztecAddress.fromBigIntUnsafe(200n); + const scopeB = AztecAddress.fromBigIntUnsafe(201n); const jobId = 'job-1'; const anchorBlockHeader = makeBlockHeader(0); const classId = Fr.fromHexString('0xdeadbeef'); @@ -145,10 +145,10 @@ describe('ContractSyncService', () => { // acquire one. Per-call limiters give the nested syncs their own slots, so the batch completes. it('does not deadlock when concurrent syncs each trigger a nested sync', async () => { const outerContracts = Array.from({ length: MAX_CONCURRENT_SCOPE_SYNCS }, (_, i) => - AztecAddress.fromBigInt(1000n + BigInt(i)), + AztecAddress.fromBigIntUnsafe(1000n + BigInt(i)), ); const nestedContracts = Array.from({ length: MAX_CONCURRENT_SCOPE_SYNCS }, (_, i) => - AztecAddress.fromBigInt(2000n + BigInt(i)), + AztecAddress.fromBigIntUnsafe(2000n + BigInt(i)), ); const nestedByOuter = new Map(outerContracts.map((outer, i) => [outer.toString(), nestedContracts[i]])); @@ -170,7 +170,7 @@ describe('ContractSyncService', () => { it('bounds the number of concurrently syncing scopes within a single call', async () => { const scopes = Array.from({ length: MAX_CONCURRENT_SCOPE_SYNCS + 3 }, (_, i) => - AztecAddress.fromBigInt(500n + BigInt(i)), + AztecAddress.fromBigIntUnsafe(500n + BigInt(i)), ); let inFlight = 0; @@ -252,7 +252,7 @@ describe('ContractSyncService', () => { }); describe('class ID verification deduplication', () => { - const contract2 = AztecAddress.fromBigInt(300n); + const contract2 = AztecAddress.fromBigIntUnsafe(300n); it('verifies class ID only once per contract across scope batches', async () => { await service.ensureContractSynced(contractAddress, null, utilityExecutor, anchorBlockHeader, jobId, [scopeA]); @@ -354,7 +354,7 @@ describe('ContractSyncService', () => { }); describe('invalidateContractForScopes', () => { - const contract2 = AztecAddress.fromBigInt(300n); + const contract2 = AztecAddress.fromBigIntUnsafe(300n); it('only invalidates the targeted scope', async () => { await service.ensureContractSynced(contractAddress, null, utilityExecutor, anchorBlockHeader, jobId, [ diff --git a/yarn-project/pxe/src/error_enriching.ts b/yarn-project/pxe/src/error_enriching.ts index 0bd889147cb2..78343df6a213 100644 --- a/yarn-project/pxe/src/error_enriching.ts +++ b/yarn-project/pxe/src/error_enriching.ts @@ -29,7 +29,7 @@ export async function enrichSimulationError(err: SimulationError, contractStore: await Promise.all( [...mentionedFunctions.entries()].map(async ([contractAddress, fnSelectors]) => { - const parsedContractAddress = AztecAddress.fromString(contractAddress); + const parsedContractAddress = AztecAddress.fromStringUnsafe(contractAddress); const contract = await contractStore.getContract(parsedContractAddress); if (contract) { err.enrichWithContractName(parsedContractAddress, contract.name); diff --git a/yarn-project/pxe/src/logs/log_service.ts b/yarn-project/pxe/src/logs/log_service.ts index 0b9ed0dbe282..d408e2255253 100644 --- a/yarn-project/pxe/src/logs/log_service.ts +++ b/yarn-project/pxe/src/logs/log_service.ts @@ -210,7 +210,7 @@ export class LogService { // We deduplicate the senders by adding them to a set and then converting the set back to an array const deduplicatedSenders = Array.from(new Set(allSenders.map(sender => sender.toString()))).map(sender => - AztecAddress.fromString(sender), + AztecAddress.fromStringUnsafe(sender), ); return Promise.all( diff --git a/yarn-project/pxe/src/private_kernel/batch_planner.test.ts b/yarn-project/pxe/src/private_kernel/batch_planner.test.ts index 9999e6202864..d150b76044d2 100644 --- a/yarn-project/pxe/src/private_kernel/batch_planner.test.ts +++ b/yarn-project/pxe/src/private_kernel/batch_planner.test.ts @@ -12,7 +12,7 @@ import times from 'lodash.times'; import { BatchPlanner } from './batch_planner.js'; import { PrivateCircuitPublicInputsBuilder, PrivateKernelCircuitPublicInputsBuilder } from './hints/test_utils.js'; -const contractAddress = AztecAddress.fromBigInt(987654n); +const contractAddress = AztecAddress.fromBigIntUnsafe(987654n); /** * Wraps a `PrivateCircuitPublicInputs` in a `PrivateCallExecutionResult` with the given children. diff --git a/yarn-project/pxe/src/private_kernel/hints/test_utils.ts b/yarn-project/pxe/src/private_kernel/hints/test_utils.ts index 9a1fba6009ed..ff7e98bf4130 100644 --- a/yarn-project/pxe/src/private_kernel/hints/test_utils.ts +++ b/yarn-project/pxe/src/private_kernel/hints/test_utils.ts @@ -36,7 +36,7 @@ import { PrivateLog } from '@aztec/stdlib/logs'; import { PrivateCallExecutionResult } from '@aztec/stdlib/tx'; import { VerificationKeyData } from '@aztec/stdlib/vks'; -const DEFAULT_CONTRACT_ADDRESS = AztecAddress.fromBigInt(987654n); +const DEFAULT_CONTRACT_ADDRESS = AztecAddress.fromBigIntUnsafe(987654n); /** * Builds a ClaimedLengthArray from a list of items, padding to the required size. diff --git a/yarn-project/pxe/src/private_kernel/private_kernel_execution_prover.test.ts b/yarn-project/pxe/src/private_kernel/private_kernel_execution_prover.test.ts index a44bab2ad2fc..3c3a0f466d0a 100644 --- a/yarn-project/pxe/src/private_kernel/private_kernel_execution_prover.test.ts +++ b/yarn-project/pxe/src/private_kernel/private_kernel_execution_prover.test.ts @@ -39,7 +39,7 @@ describe('Private Kernel Sequencer', () => { let prover: PrivateKernelExecutionProver; let dependencies: { [name: string]: string[] } = {}; - const contractAddress = AztecAddress.fromBigInt(987654n); + const contractAddress = AztecAddress.fromBigIntUnsafe(987654n); const blockTimestamp = 12345n; const expirationTimestamp = blockTimestamp + BigInt(MAX_TX_LIFETIME); @@ -414,7 +414,7 @@ describe('Private Kernel Sequencer', () => { }); it('fetches updated class id hints once per unique contract address', async () => { - const contractAddressB = AztecAddress.fromBigInt(111111n); + const contractAddressB = AztecAddress.fromBigIntUnsafe(111111n); // a { b {} c {} } // a and c use contractAddress, b uses contractAddressB → 2 unique contracts, 3 executions. diff --git a/yarn-project/pxe/src/storage/backwards_compatibility_tests/schema_tests.ts b/yarn-project/pxe/src/storage/backwards_compatibility_tests/schema_tests.ts index 593591b994c0..c5b3914f47e8 100644 --- a/yarn-project/pxe/src/storage/backwards_compatibility_tests/schema_tests.ts +++ b/yarn-project/pxe/src/storage/backwards_compatibility_tests/schema_tests.ts @@ -106,7 +106,7 @@ export const SCHEMA_TESTS: readonly SchemaTest[] = [ SlotNumber(47), 53n, EthAddress.fromField(new Fr(59n)), - AztecAddress.fromBigInt(61n), + AztecAddress.fromBigIntUnsafe(61n), new GasFees(67n, 71n), ), new Fr(73n), @@ -125,8 +125,8 @@ export const SCHEMA_TESTS: readonly SchemaTest[] = [ const capsuleStore = new CapsuleStore(kvStore); const jobId = 'fixture-job'; - const contractAddress = AztecAddress.fromBigInt(2n); - const scope = AztecAddress.fromBigInt(3n); + const contractAddress = AztecAddress.fromBigIntUnsafe(2n); + const scope = AztecAddress.fromBigIntUnsafe(3n); // Three setCapsule calls (2-element, 1-element, 0-element value vector) pin every value-encoding length case. capsuleStore.setCapsule(contractAddress, new Fr(5n), [new Fr(7n), new Fr(11n)], jobId, scope); @@ -188,7 +188,7 @@ export const SCHEMA_TESTS: readonly SchemaTest[] = [ new SerializableContractInstance({ version: 2, salt: new Fr(73n), - deployer: AztecAddress.fromBigInt(79n), + deployer: AztecAddress.fromBigIntUnsafe(79n), currentContractClassId: new Fr(83n), originalContractClassId: new Fr(89n), initializationHash: new Fr(97n), @@ -204,7 +204,7 @@ export const SCHEMA_TESTS: readonly SchemaTest[] = [ new Fr(71n), new Fr(73n), ), - }).withAddress(AztecAddress.fromBigInt(101n)), + }).withAddress(AztecAddress.fromBigIntUnsafe(101n)), ); }, snapshotStore: async kvStore => ({ @@ -243,7 +243,7 @@ export const SCHEMA_TESTS: readonly SchemaTest[] = [ SlotNumber(19), 23n, EthAddress.fromField(new Fr(29n)), - AztecAddress.fromBigInt(31n), + AztecAddress.fromBigIntUnsafe(31n), new GasFees(37n, 41n), new Fr(43n), new Fr(47n), @@ -293,17 +293,17 @@ export const SCHEMA_TESTS: readonly SchemaTest[] = [ // Two contracts so `note_nullifiers_by_contract` exhibits both a multi-value row (contractA → {n1, n2}) and a // single-value row (contractB → {n3}). - const contractA = AztecAddress.fromBigInt(2n); - const contractB = AztecAddress.fromBigInt(3n); - const scopeX = AztecAddress.fromBigInt(5n); - const scopeY = AztecAddress.fromBigInt(7n); + const contractA = AztecAddress.fromBigIntUnsafe(2n); + const contractB = AztecAddress.fromBigIntUnsafe(3n); + const scopeX = AztecAddress.fromBigIntUnsafe(5n); + const scopeY = AztecAddress.fromBigIntUnsafe(7n); // note1: active, will be added under two scopes to exercise the multi-element scopes vector encoding in // `StoredNote.toBuffer`. const note1 = new NoteDao( new Note([new Fr(13n), new Fr(17n), new Fr(19n)]), contractA, - AztecAddress.fromBigInt(23n), + AztecAddress.fromBigIntUnsafe(23n), new Fr(29n), new Fr(31n), new Fr(37n), @@ -320,7 +320,7 @@ export const SCHEMA_TESTS: readonly SchemaTest[] = [ const note2 = new NoteDao( new Note([new Fr(71n), new Fr(73n), new Fr(79n)]), contractA, - AztecAddress.fromBigInt(83n), + AztecAddress.fromBigIntUnsafe(83n), new Fr(89n), new Fr(97n), new Fr(101n), @@ -338,7 +338,7 @@ export const SCHEMA_TESTS: readonly SchemaTest[] = [ const note3 = new NoteDao( new Note([new Fr(139n), new Fr(149n), new Fr(151n)]), contractB, - AztecAddress.fromBigInt(157n), + AztecAddress.fromBigIntUnsafe(157n), new Fr(163n), new Fr(167n), new Fr(173n), @@ -391,12 +391,12 @@ export const SCHEMA_TESTS: readonly SchemaTest[] = [ // Two (contract, selector) pairs and two block numbers so each multimap exhibits both a multi-value row // (contractA/selectorA → {e1, e2} and blockN1 → {e1, e2}) and a contrasting single-value row. - const contractA = AztecAddress.fromBigInt(2n); - const contractB = AztecAddress.fromBigInt(3n); + const contractA = AztecAddress.fromBigIntUnsafe(2n); + const contractB = AztecAddress.fromBigIntUnsafe(3n); const selectorA = EventSelector.fromField(new Fr(5n)); const selectorB = EventSelector.fromField(new Fr(7n)); - const scopeX = AztecAddress.fromBigInt(11n); - const scopeY = AztecAddress.fromBigInt(13n); + const scopeX = AztecAddress.fromBigIntUnsafe(11n); + const scopeY = AztecAddress.fromBigIntUnsafe(13n); const blockN1 = BlockNumber(17); const blockN2 = BlockNumber(19); @@ -491,8 +491,8 @@ export const SCHEMA_TESTS: readonly SchemaTest[] = [ const recipientTaggingStore = new RecipientTaggingStore(kvStore); const jobId = 'fixture-job'; - const secretA = new AppTaggingSecret(new Fr(2n), AztecAddress.fromBigInt(3n)); - const secretB = new AppTaggingSecret(new Fr(5n), AztecAddress.fromBigInt(7n)); + const secretA = new AppTaggingSecret(new Fr(2n), AztecAddress.fromBigIntUnsafe(3n)); + const secretB = new AppTaggingSecret(new Fr(5n), AztecAddress.fromBigIntUnsafe(7n)); await recipientTaggingStore.updateHighestFinalizedIndex(secretA, 11, jobId); await recipientTaggingStore.updateHighestAgedIndex(secretA, 13, jobId); @@ -510,9 +510,9 @@ export const SCHEMA_TESTS: readonly SchemaTest[] = [ writeToStore: async kvStore => { const senderAddressBookStore = new SenderAddressBookStore(kvStore); - await senderAddressBookStore.addSender(AztecAddress.fromBigInt(2n)); - await senderAddressBookStore.addSender(AztecAddress.fromBigInt(3n)); - await senderAddressBookStore.addSender(AztecAddress.fromBigInt(5n)); + await senderAddressBookStore.addSender(AztecAddress.fromBigIntUnsafe(2n)); + await senderAddressBookStore.addSender(AztecAddress.fromBigIntUnsafe(3n)); + await senderAddressBookStore.addSender(AztecAddress.fromBigIntUnsafe(5n)); }, snapshotStore: async kvStore => ({ address_book: await snapshotMap(kvStore.openMap('address_book')), @@ -525,9 +525,9 @@ export const SCHEMA_TESTS: readonly SchemaTest[] = [ const senderTaggingStore = new SenderTaggingStore(kvStore); const jobId = 'fixture-job'; - const secretA = new AppTaggingSecret(new Fr(2n), AztecAddress.fromBigInt(3n)); - const secretB = new AppTaggingSecret(new Fr(5n), AztecAddress.fromBigInt(7n)); - const secretC = new AppTaggingSecret(new Fr(11n), AztecAddress.fromBigInt(13n)); + const secretA = new AppTaggingSecret(new Fr(2n), AztecAddress.fromBigIntUnsafe(3n)); + const secretB = new AppTaggingSecret(new Fr(5n), AztecAddress.fromBigIntUnsafe(7n)); + const secretC = new AppTaggingSecret(new Fr(11n), AztecAddress.fromBigIntUnsafe(13n)); const txHashA = TxHash.fromBigInt(17n); const txHashB = TxHash.fromBigInt(19n); const txHashC = TxHash.fromBigInt(23n); @@ -621,7 +621,7 @@ function buildL2Block(): L2Block { SlotNumber(181), 191n, EthAddress.fromField(new Fr(193n)), - AztecAddress.fromBigInt(197n), + AztecAddress.fromBigIntUnsafe(197n), new GasFees(199n, 211n), ), new Fr(223n), @@ -642,10 +642,10 @@ function buildL2Block(): L2Block { 3, ), ], - [new PublicLog(AztecAddress.fromBigInt(281n), [new Fr(283n), new Fr(293n)])], + [new PublicLog(AztecAddress.fromBigIntUnsafe(281n), [new Fr(283n), new Fr(293n)])], [ new ContractClassLog( - AztecAddress.fromBigInt(307n), + AztecAddress.fromBigIntUnsafe(307n), new ContractClassLogFields(paddedFrs([311n, 313n, 317n], CONTRACT_CLASS_LOG_SIZE_IN_FIELDS)), 3, ), diff --git a/yarn-project/pxe/src/storage/contract_store/contract_store.ts b/yarn-project/pxe/src/storage/contract_store/contract_store.ts index 57cd75b229a6..5b3e9efdf97f 100644 --- a/yarn-project/pxe/src/storage/contract_store/contract_store.ts +++ b/yarn-project/pxe/src/storage/contract_store/contract_store.ts @@ -215,7 +215,7 @@ export class ContractStore { getContractsAddresses(): Promise { return this.#store.transactionAsync(async () => { const keys = await toArray(this.#contractInstances.keysAsync()); - return keys.map(AztecAddress.fromString); + return keys.map(AztecAddress.fromStringUnsafe); }); } diff --git a/yarn-project/pxe/src/storage/note_store/note_store.test.ts b/yarn-project/pxe/src/storage/note_store/note_store.test.ts index bf1bbd8b388d..6c372345b902 100644 --- a/yarn-project/pxe/src/storage/note_store/note_store.test.ts +++ b/yarn-project/pxe/src/storage/note_store/note_store.test.ts @@ -10,11 +10,13 @@ import { NoteStore } from './note_store.js'; // ----------------------------------------------------------------------------- // Shared constants for deterministic fixtures // ----------------------------------------------------------------------------- -const CONTRACT_A = AztecAddress.fromString('0x0eadbeef00000000000000000000000000000000000000000000000000000000'); -const CONTRACT_B = AztecAddress.fromString('0x0eedface00000000000000000000000000000000000000000000000000000000'); -const SCOPE_1 = AztecAddress.fromString('0x0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a'); -const SCOPE_2 = AztecAddress.fromString('0x0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b'); -const FAKE_ADDRESS = AztecAddress.fromString('0x1111111111111111111111111111111111111111111111111111111111111111'); +const CONTRACT_A = AztecAddress.fromStringUnsafe('0x0eadbeef00000000000000000000000000000000000000000000000000000000'); +const CONTRACT_B = AztecAddress.fromStringUnsafe('0x0eedface00000000000000000000000000000000000000000000000000000000'); +const SCOPE_1 = AztecAddress.fromStringUnsafe('0x0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a'); +const SCOPE_2 = AztecAddress.fromStringUnsafe('0x0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b'); +const FAKE_ADDRESS = AztecAddress.fromStringUnsafe( + '0x1111111111111111111111111111111111111111111111111111111111111111', +); const SLOT_X = Fr.fromString('0x01'); const SLOT_Y = Fr.fromString('0x02'); const NON_EXISTING_SLOT = Fr.fromString('0xabad1dea'); @@ -753,8 +755,8 @@ describe('NoteStore', () => { describe('NoteStore.rollback', () => { const JOB = 'note-store-test-job'; - const scope = AztecAddress.fromBigInt(1n); - const contract = AztecAddress.fromBigInt(100n); + const scope = AztecAddress.fromBigIntUnsafe(1n); + const contract = AztecAddress.fromBigIntUnsafe(100n); let kv: Awaited>; let store: NoteStore; diff --git a/yarn-project/pxe/src/storage/tagging_store/sender_address_book_store.ts b/yarn-project/pxe/src/storage/tagging_store/sender_address_book_store.ts index 540a7334b457..1223e07032c9 100644 --- a/yarn-project/pxe/src/storage/tagging_store/sender_address_book_store.ts +++ b/yarn-project/pxe/src/storage/tagging_store/sender_address_book_store.ts @@ -30,7 +30,7 @@ export class SenderAddressBookStore { getSenders(): Promise { return this.#store.transactionAsync(async () => { - return (await toArray(this.#addressBook.keysAsync())).map(AztecAddress.fromString); + return (await toArray(this.#addressBook.keysAsync())).map(AztecAddress.fromStringUnsafe); }); } diff --git a/yarn-project/sequencer-client/src/config.ts b/yarn-project/sequencer-client/src/config.ts index 0d1d24e52b92..3e88d931f4e3 100644 --- a/yarn-project/sequencer-client/src/config.ts +++ b/yarn-project/sequencer-client/src/config.ts @@ -144,7 +144,7 @@ export const sequencerConfigMappings: ConfigMappingsType = { }, feeRecipient: { env: 'FEE_RECIPIENT', - parseEnv: (val: string) => AztecAddress.fromString(val), + parseEnv: (val: string) => AztecAddress.fromStringUnsafe(val), description: 'Address to receive fees.', }, acvmWorkingDirectory: { diff --git a/yarn-project/simulator/src/public/avm/apps_tests/avm_test.test.ts b/yarn-project/simulator/src/public/avm/apps_tests/avm_test.test.ts index d61fba0c8f46..004facc6e5ce 100644 --- a/yarn-project/simulator/src/public/avm/apps_tests/avm_test.test.ts +++ b/yarn-project/simulator/src/public/avm/apps_tests/avm_test.test.ts @@ -9,8 +9,8 @@ import { NativeWorldStateService } from '@aztec/world-state'; import { AvmSimulationTester } from '../fixtures/avm_simulation_tester.js'; describe('AVM simulator apps tests: AvmTestContract', () => { - const deployer = AztecAddress.fromNumber(42); - const sender = AztecAddress.fromNumber(4200); + const deployer = AztecAddress.fromNumberUnsafe(42); + const sender = AztecAddress.fromNumberUnsafe(4200); let testContractAddress: AztecAddress; let instances: ContractInstanceWithAddress[]; let worldStateService: NativeWorldStateService; diff --git a/yarn-project/simulator/src/public/avm/apps_tests/storage_proofs.test.ts b/yarn-project/simulator/src/public/avm/apps_tests/storage_proofs.test.ts index 15373f14ee83..a46098fa3bab 100644 --- a/yarn-project/simulator/src/public/avm/apps_tests/storage_proofs.test.ts +++ b/yarn-project/simulator/src/public/avm/apps_tests/storage_proofs.test.ts @@ -16,8 +16,8 @@ import { AvmSimulationTester } from '../fixtures/avm_simulation_tester.js'; const __dirname = dirname(fileURLToPath(import.meta.url)); describe('AVM simulator apps tests: StorageProof', () => { - const deployer = AztecAddress.fromNumber(42); - const sender = AztecAddress.fromNumber(4200); + const deployer = AztecAddress.fromNumberUnsafe(42); + const sender = AztecAddress.fromNumberUnsafe(4200); let storageProver: ContractInstanceWithAddress; let worldStateService: NativeWorldStateService; let simTester: AvmSimulationTester; diff --git a/yarn-project/simulator/src/public/avm/apps_tests/token.test.ts b/yarn-project/simulator/src/public/avm/apps_tests/token.test.ts index c4c71ce8e844..6f5da061cf36 100644 --- a/yarn-project/simulator/src/public/avm/apps_tests/token.test.ts +++ b/yarn-project/simulator/src/public/avm/apps_tests/token.test.ts @@ -7,9 +7,9 @@ import { NativeWorldStateService } from '@aztec/world-state'; import { AvmSimulationTester } from '../fixtures/avm_simulation_tester.js'; describe('AVM simulator apps tests: TokenContract', () => { - const admin = AztecAddress.fromNumber(42); - const sender = AztecAddress.fromNumber(111); - const receiver = AztecAddress.fromNumber(222); + const admin = AztecAddress.fromNumberUnsafe(42); + const sender = AztecAddress.fromNumberUnsafe(111); + const receiver = AztecAddress.fromNumberUnsafe(222); let token: ContractInstanceWithAddress; let worldStateService: NativeWorldStateService; diff --git a/yarn-project/simulator/src/public/avm/avm_execution_environment.test.ts b/yarn-project/simulator/src/public/avm/avm_execution_environment.test.ts index a98e7f0dad2f..87f21a0d67df 100644 --- a/yarn-project/simulator/src/public/avm/avm_execution_environment.test.ts +++ b/yarn-project/simulator/src/public/avm/avm_execution_environment.test.ts @@ -6,7 +6,7 @@ import { initExecutionEnvironment } from './fixtures/initializers.js'; import { allSameExcept } from './fixtures/utils.js'; describe('Execution Environment', () => { - const newAddress = AztecAddress.fromNumber(123456); + const newAddress = AztecAddress.fromNumberUnsafe(123456); const calldata = new CallDataArray([new Fr(1n), new Fr(2n), new Fr(3n)]); it('New call should fork execution environment correctly', () => { diff --git a/yarn-project/simulator/src/public/avm/avm_simulator.test.ts b/yarn-project/simulator/src/public/avm/avm_simulator.test.ts index b6285108b102..03209fcaeb6a 100644 --- a/yarn-project/simulator/src/public/avm/avm_simulator.test.ts +++ b/yarn-project/simulator/src/public/avm/avm_simulator.test.ts @@ -89,7 +89,7 @@ import { const siloAddress = (contractAddress: AztecAddress) => { const contractAddressNullifier = siloNullifier( - AztecAddress.fromNumber(CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS), + AztecAddress.fromNumberUnsafe(CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS), contractAddress.toField(), ); return contractAddressNullifier; @@ -159,7 +159,7 @@ describe('AVM simulator: transpiled Noir contracts', () => { it('execution of a non-existent contract immediately reverts and consumes all allocated gas', async () => { const treesDB = mock(); const persistableState = initPersistableStateManager({ treesDB }); - const address = AztecAddress.fromNumber(1234); + const address = AztecAddress.fromNumberUnsafe(1234); const env = initExecutionEnvironment({ address }); const context = initContext({ env, persistableState }); mockCheckNullifierExists(treesDB, false); @@ -581,8 +581,8 @@ describe('AVM simulator: transpiled Noir contracts', () => { }); describe('Side effects, world state, nested calls', () => { - const address = AztecAddress.fromNumber(1); - const sender = AztecAddress.fromNumber(42); + const address = AztecAddress.fromNumberUnsafe(1); + const sender = AztecAddress.fromNumberUnsafe(42); const leafIndex = 7n; const slotNumber = 1; // must update Noir contract if changing this const slot = new Fr(slotNumber); @@ -909,7 +909,7 @@ describe('AVM simulator: transpiled Noir contracts', () => { const contractInstance = new SerializableContractInstance({ version: 2 as const, salt: new Fr(0x123), - deployer: AztecAddress.fromBigInt(0x456n), + deployer: AztecAddress.fromBigIntUnsafe(0x456n), currentContractClassId: new Fr(0x789), originalContractClassId: new Fr(0x789), initializationHash: new Fr(0x101112), @@ -1175,8 +1175,8 @@ describe('AVM simulator: transpiled Noir contracts', () => { }); describe('Side effects including merkle checks', () => { - const address = AztecAddress.fromNumber(1); - const sender = AztecAddress.fromNumber(42); + const address = AztecAddress.fromNumberUnsafe(1); + const sender = AztecAddress.fromNumberUnsafe(42); const value0 = new Fr(420); diff --git a/yarn-project/simulator/src/public/avm/fixtures/base_avm_simulation_tester.ts b/yarn-project/simulator/src/public/avm/fixtures/base_avm_simulation_tester.ts index d239c9ad1e52..467fef56f186 100644 --- a/yarn-project/simulator/src/public/avm/fixtures/base_avm_simulation_tester.ts +++ b/yarn-project/simulator/src/public/avm/fixtures/base_avm_simulation_tester.ts @@ -149,7 +149,7 @@ export abstract class BaseAvmSimulationTester { private async insertContractAddressNullifier(contractAddress: AztecAddress) { const contractAddressNullifier = await siloNullifier( - AztecAddress.fromNumber(CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS), + AztecAddress.fromNumberUnsafe(CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS), contractAddress.toField(), ); await this.merkleTrees.sequentialInsert(MerkleTreeId.NULLIFIER_TREE, [contractAddressNullifier.toBuffer()]); diff --git a/yarn-project/simulator/src/public/avm/fixtures/utils.ts b/yarn-project/simulator/src/public/avm/fixtures/utils.ts index 382fdd2a9764..b4aa338b078e 100644 --- a/yarn-project/simulator/src/public/avm/fixtures/utils.ts +++ b/yarn-project/simulator/src/public/avm/fixtures/utils.ts @@ -146,7 +146,7 @@ export async function createContractClassAndInstance( }); const contractAddressNullifier = await siloNullifier( - AztecAddress.fromNumber(CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS), + AztecAddress.fromNumberUnsafe(CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS), contractInstance.address.toField(), ); diff --git a/yarn-project/simulator/src/public/avm/opcodes/accrued_substate.test.ts b/yarn-project/simulator/src/public/avm/opcodes/accrued_substate.test.ts index 6958a5c15bc3..be3a59468e9c 100644 --- a/yarn-project/simulator/src/public/avm/opcodes/accrued_substate.test.ts +++ b/yarn-project/simulator/src/public/avm/opcodes/accrued_substate.test.ts @@ -35,8 +35,8 @@ describe('Accrued Substate', () => { let persistableState: PublicPersistableStateManager; let context: AvmContext; - const address = AztecAddress.fromNumber(1); - const sender = AztecAddress.fromNumber(42); + const address = AztecAddress.fromNumberUnsafe(1); + const sender = AztecAddress.fromNumberUnsafe(42); const value0 = new Fr(69); // noteHash or nullifier... const value0Offset = 100; const value1 = new Fr(420); diff --git a/yarn-project/simulator/src/public/fixtures/amm_test.ts b/yarn-project/simulator/src/public/fixtures/amm_test.ts index 5b78faf274c8..e359e7c71a23 100644 --- a/yarn-project/simulator/src/public/fixtures/amm_test.ts +++ b/yarn-project/simulator/src/public/fixtures/amm_test.ts @@ -25,8 +25,8 @@ export async function ammTest( ) { const timer = new Timer(); - const admin = AztecAddress.fromNumber(42); - const sender = AztecAddress.fromNumber(111); + const admin = AztecAddress.fromNumberUnsafe(42); + const sender = AztecAddress.fromNumberUnsafe(111); logger.debug(`Deploying tokens`); const token0 = await setUpToken(tester, tokenArtifact, admin, expectToBeTrue, /*seed=*/ 0); diff --git a/yarn-project/simulator/src/public/fixtures/bulk_test.ts b/yarn-project/simulator/src/public/fixtures/bulk_test.ts index 650b142b0633..b0f755ed57be 100644 --- a/yarn-project/simulator/src/public/fixtures/bulk_test.ts +++ b/yarn-project/simulator/src/public/fixtures/bulk_test.ts @@ -13,7 +13,7 @@ export async function bulkTest( ) { const timer = new Timer(); - const deployer = AztecAddress.fromNumber(42); + const deployer = AztecAddress.fromNumberUnsafe(42); const avmTestContract = await tester.registerAndDeployContract( /*constructorArgs=*/ [], deployer, @@ -114,7 +114,7 @@ export async function megaBulkTest( ) { const timer = new Timer(); - const deployer = AztecAddress.fromNumber(42); + const deployer = AztecAddress.fromNumberUnsafe(42); const avmTestContract = await tester.registerAndDeployContract( /*constructorArgs=*/ [], deployer, diff --git a/yarn-project/simulator/src/public/fixtures/custom_bytecode_tester.ts b/yarn-project/simulator/src/public/fixtures/custom_bytecode_tester.ts index 53e0975fd337..07f7dde5e574 100644 --- a/yarn-project/simulator/src/public/fixtures/custom_bytecode_tester.ts +++ b/yarn-project/simulator/src/public/fixtures/custom_bytecode_tester.ts @@ -17,7 +17,7 @@ export async function deployCustomBytecode( bytecode: Buffer, tester: PublicTxSimulationTester, contractName: string = 'CustomBytecodeContract', - deployer: AztecAddress = AztecAddress.fromNumber(42), + deployer: AztecAddress = AztecAddress.fromNumberUnsafe(42), ): Promise { const contractArtifact = emptyContractArtifact(); contractArtifact.name = contractName; @@ -75,7 +75,7 @@ export async function deployAndExecuteCustomBytecode( tester: PublicTxSimulationTester, txLabel: string = 'CustomBytecodeTest', contractName: string = 'CustomBytecodeContract', - deployer: AztecAddress = AztecAddress.fromNumber(42), + deployer: AztecAddress = AztecAddress.fromNumberUnsafe(42), calldata: any[] = [], ): Promise { const testContract = await deployCustomBytecode(bytecode, tester, contractName, deployer); diff --git a/yarn-project/simulator/src/public/fixtures/token_test.ts b/yarn-project/simulator/src/public/fixtures/token_test.ts index eb1d3ee2dc18..213a0b870629 100644 --- a/yarn-project/simulator/src/public/fixtures/token_test.ts +++ b/yarn-project/simulator/src/public/fixtures/token_test.ts @@ -21,9 +21,9 @@ export async function tokenTest( ) { const timer = new Timer(); - const admin = AztecAddress.fromNumber(42); - const sender = AztecAddress.fromNumber(111); - const receiver = AztecAddress.fromNumber(222); + const admin = AztecAddress.fromNumberUnsafe(42); + const sender = AztecAddress.fromNumberUnsafe(111); + const receiver = AztecAddress.fromNumberUnsafe(222); const token = await setUpToken(tester, tokenArtifact, admin, expectToBeTrue); diff --git a/yarn-project/simulator/src/public/fixtures/utils.ts b/yarn-project/simulator/src/public/fixtures/utils.ts index ae94a9b49f34..ea1525a824b3 100644 --- a/yarn-project/simulator/src/public/fixtures/utils.ts +++ b/yarn-project/simulator/src/public/fixtures/utils.ts @@ -255,7 +255,7 @@ export async function addNewContractInstanceToTx( ); const contractAddressNullifier = await siloNullifier( - AztecAddress.fromNumber(CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS), + AztecAddress.fromNumberUnsafe(CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS), contractInstance.address.toField(), ); diff --git a/yarn-project/simulator/src/public/public_processor/apps_tests/deployments.test.ts b/yarn-project/simulator/src/public/public_processor/apps_tests/deployments.test.ts index d8a6353581f3..532f5b348ed8 100644 --- a/yarn-project/simulator/src/public/public_processor/apps_tests/deployments.test.ts +++ b/yarn-project/simulator/src/public/public_processor/apps_tests/deployments.test.ts @@ -23,8 +23,8 @@ describe.each([ { useCppSimulator: false, simulatorName: 'TS Simulator' }, { useCppSimulator: true, simulatorName: 'Cpp Simulator' }, ])('Public processor contract registration/deployment tests ($simulatorName)', ({ useCppSimulator }) => { - const admin = AztecAddress.fromNumber(42); - const sender = AztecAddress.fromNumber(111); + const admin = AztecAddress.fromNumberUnsafe(42); + const sender = AztecAddress.fromNumberUnsafe(111); let worldStateService: NativeWorldStateService; let contractsDB: PublicContractsDB; @@ -196,7 +196,7 @@ describe.each([ // the contract data source. // Second transaction - deploys second token but fails during transfer - const receiver = AztecAddress.fromNumber(222); + const receiver = AztecAddress.fromNumberUnsafe(222); const transferAmount = 10n; const authwitNonce = new Fr(0); const failingConstructorTx = await tester.createTx( diff --git a/yarn-project/simulator/src/public/public_processor/apps_tests/timeout_race.test.ts b/yarn-project/simulator/src/public/public_processor/apps_tests/timeout_race.test.ts index 2d16e26e602f..b9df2d33cfef 100644 --- a/yarn-project/simulator/src/public/public_processor/apps_tests/timeout_race.test.ts +++ b/yarn-project/simulator/src/public/public_processor/apps_tests/timeout_race.test.ts @@ -50,7 +50,7 @@ describe('PublicProcessor C++ Timeout Race Condition', () => { const logger = createLogger('public-processor-timeout-race'); - const admin = AztecAddress.fromNumber(42); + const admin = AztecAddress.fromNumberUnsafe(42); let worldStateService: NativeWorldStateService; diff --git a/yarn-project/simulator/src/public/public_processor/apps_tests/token.test.ts b/yarn-project/simulator/src/public/public_processor/apps_tests/token.test.ts index 2e10ec87d23e..0c971b76ea96 100644 --- a/yarn-project/simulator/src/public/public_processor/apps_tests/token.test.ts +++ b/yarn-project/simulator/src/public/public_processor/apps_tests/token.test.ts @@ -24,8 +24,8 @@ describe.each([ const logger = createLogger('public-processor-apps-tests-token'); const NUM_TRANSFERS = 10; - const admin = AztecAddress.fromNumber(42); - const sender = AztecAddress.fromNumber(111); + const admin = AztecAddress.fromNumberUnsafe(42); + const sender = AztecAddress.fromNumberUnsafe(111); let token: ContractInstanceWithAddress; let worldStateService: NativeWorldStateService; @@ -113,7 +113,7 @@ describe.each([ const transferTxs = []; for (let i = 0; i < NUM_TRANSFERS; i++) { - const receiver = AztecAddress.fromNumber(200 + i); // different receiver each time + const receiver = AztecAddress.fromNumberUnsafe(200 + i); // different receiver each time transferTxs.push( await tester.createTx( /*sender=*/ sender, diff --git a/yarn-project/simulator/src/public/public_processor/public_processor.test.ts b/yarn-project/simulator/src/public/public_processor/public_processor.test.ts index a4c33e92a576..1fdd96ebfbb4 100644 --- a/yarn-project/simulator/src/public/public_processor/public_processor.test.ts +++ b/yarn-project/simulator/src/public/public_processor/public_processor.test.ts @@ -315,7 +315,7 @@ describe('public_processor', () => { }); describe('with fee payer', () => { - const feePayer = AztecAddress.fromBigInt(123123n); + const feePayer = AztecAddress.fromBigIntUnsafe(123123n); const initialBalance = new Fr(1000); beforeEach(async () => { diff --git a/yarn-project/simulator/src/public/public_tx_simulator/apps_tests/avm_gadgets.test.ts b/yarn-project/simulator/src/public/public_tx_simulator/apps_tests/avm_gadgets.test.ts index 0af13f737b10..d6d8461e7714 100644 --- a/yarn-project/simulator/src/public/public_tx_simulator/apps_tests/avm_gadgets.test.ts +++ b/yarn-project/simulator/src/public/public_tx_simulator/apps_tests/avm_gadgets.test.ts @@ -12,7 +12,7 @@ describe('Public TX simulator apps tests: gadgets', () => { { useCppSimulator: false, simulatorName: 'TS Simulator' }, { useCppSimulator: true, simulatorName: 'Cpp Simulator' }, ])('Public TX simulator apps tests: gadgets (via $simulatorName)', ({ useCppSimulator }) => { - const deployer = AztecAddress.fromNumber(42); + const deployer = AztecAddress.fromNumberUnsafe(42); let worldStateService: NativeWorldStateService; let tester: PublicTxSimulationTester; diff --git a/yarn-project/simulator/src/public/public_tx_simulator/apps_tests/bench.test.ts b/yarn-project/simulator/src/public/public_tx_simulator/apps_tests/bench.test.ts index dd3fd8d1ddce..a731c6378864 100644 --- a/yarn-project/simulator/src/public/public_tx_simulator/apps_tests/bench.test.ts +++ b/yarn-project/simulator/src/public/public_tx_simulator/apps_tests/bench.test.ts @@ -114,7 +114,7 @@ describe('Public TX simulator apps tests: benchmarks', () => { it('AVM large calldata test', async () => { tester.setMetricsPrefix(`${metricsPrefixPrefix}AvmTest contract tests`); - const deployer = AztecAddress.fromNumber(42); + const deployer = AztecAddress.fromNumberUnsafe(42); const avmTestContract = await tester.registerAndDeployContract( /*constructorArgs=*/ [], @@ -140,7 +140,7 @@ describe('Public TX simulator apps tests: benchmarks', () => { it('PublicFnsWithEmitRepro contract test', async () => { // See comments on the contract source for motivation as to including this contract in our benchmarks. tester.setMetricsPrefix(`${metricsPrefixPrefix}PublicFnsWithEmitRepro contract tests`); - const deployer = AztecAddress.fromNumber(42); + const deployer = AztecAddress.fromNumberUnsafe(42); const reproContract = await tester.registerAndDeployContract( /*constructorArgs=*/ [], @@ -165,7 +165,7 @@ describe('Public TX simulator apps tests: benchmarks', () => { it('Storage proof test', async () => { tester.setMetricsPrefix(`${metricsPrefixPrefix}StorageProof contract tests`); - const deployer = AztecAddress.fromNumber(42); + const deployer = AztecAddress.fromNumberUnsafe(42); const storageProofContract = await tester.registerAndDeployContract( /*constructorArgs=*/ [], @@ -200,7 +200,7 @@ describe('Public TX simulator apps tests: benchmarks', () => { }); describe('AVM gadgets tests', () => { - const deployer = AztecAddress.fromNumber(42); + const deployer = AztecAddress.fromNumberUnsafe(42); let worldStateService: NativeWorldStateService; let tester: PublicTxSimulationTester; diff --git a/yarn-project/simulator/src/public/public_tx_simulator/apps_tests/cpp_exception_handling.test.ts b/yarn-project/simulator/src/public/public_tx_simulator/apps_tests/cpp_exception_handling.test.ts index 12cd90a8b4ac..d14526dcc087 100644 --- a/yarn-project/simulator/src/public/public_tx_simulator/apps_tests/cpp_exception_handling.test.ts +++ b/yarn-project/simulator/src/public/public_tx_simulator/apps_tests/cpp_exception_handling.test.ts @@ -6,7 +6,7 @@ import { NativeWorldStateService } from '@aztec/world-state/native'; import { PublicTxSimulationTester } from '../../fixtures/public_tx_simulation_tester.js'; describe('C++ Exception Handling during Public Tx Simulation', () => { - const sender = AztecAddress.fromNumber(42); + const sender = AztecAddress.fromNumberUnsafe(42); let avmTestContractInstance: ContractInstanceWithAddress; let tester: PublicTxSimulationTester; let worldStateService: NativeWorldStateService; @@ -21,7 +21,7 @@ describe('C++ Exception Handling during Public Tx Simulation', () => { ); avmTestContractInstance = await tester.registerAndDeployContract( /*constructorArgs=*/ [], - /*deployer=*/ AztecAddress.fromNumber(420), + /*deployer=*/ AztecAddress.fromNumberUnsafe(420), AvmTestContractArtifact, ); }); diff --git a/yarn-project/simulator/src/public/public_tx_simulator/contract_provider_for_cpp.ts b/yarn-project/simulator/src/public/public_tx_simulator/contract_provider_for_cpp.ts index 21b195484d66..952031b8c3da 100644 --- a/yarn-project/simulator/src/public/public_tx_simulator/contract_provider_for_cpp.ts +++ b/yarn-project/simulator/src/public/public_tx_simulator/contract_provider_for_cpp.ts @@ -23,7 +23,7 @@ export class ContractProviderForCpp implements ContractProvider { public getContractInstance = async (address: string): Promise => { this.log.trace(`Contract provider callback: getContractInstance(${address})`); - const aztecAddr = AztecAddress.fromString(address); + const aztecAddr = AztecAddress.fromStringUnsafe(address); const instance = await this.contractsDB.getContractInstance(aztecAddr, this.globalVariables.timestamp); @@ -88,7 +88,7 @@ export class ContractProviderForCpp implements ContractProvider { this.log.trace(`Contract provider callback: getDebugFunctionName(${address}, ${selector})`); // Parse address and selector strings - const aztecAddr = AztecAddress.fromString(address); + const aztecAddr = AztecAddress.fromStringUnsafe(address); const selectorFr = Fr.fromString(selector); const functionSelector = FunctionSelector.fromFieldOrUndefined(selectorFr); diff --git a/yarn-project/simulator/src/public/public_tx_simulator/public_tx_simulator.test.ts b/yarn-project/simulator/src/public/public_tx_simulator/public_tx_simulator.test.ts index 64a6cf8b585b..72081df63bda 100644 --- a/yarn-project/simulator/src/public/public_tx_simulator/public_tx_simulator.test.ts +++ b/yarn-project/simulator/src/public/public_tx_simulator/public_tx_simulator.test.ts @@ -104,18 +104,18 @@ describe('public_tx_simulator', () => { tx.data.forPublic!.nonRevertibleAccumulatedData.noteHashes[1] = new Fr(0xaaaa); tx.data.forPublic!.nonRevertibleAccumulatedData.l2ToL1Msgs[0] = new ScopedL2ToL1Message( new L2ToL1Message(EthAddress.fromNumber(0x5555), new Fr(0xbbbb)), - AztecAddress.fromField(new Fr(0x6666)), + AztecAddress.fromFieldUnsafe(new Fr(0x6666)), ); tx.data.forPublic!.nonRevertibleAccumulatedData.l2ToL1Msgs[1] = new ScopedL2ToL1Message( new L2ToL1Message(EthAddress.fromNumber(0x6666), new Fr(0xcccc)), - AztecAddress.fromField(new Fr(0x7777)), + AztecAddress.fromFieldUnsafe(new Fr(0x7777)), ); tx.data.forPublic!.revertibleAccumulatedData.nullifiers[0] = new Fr(0x9999); tx.data.forPublic!.revertibleAccumulatedData.noteHashes[0] = new Fr(0xbbbb); tx.data.forPublic!.revertibleAccumulatedData.l2ToL1Msgs[0] = new ScopedL2ToL1Message( new L2ToL1Message(EthAddress.fromNumber(0x7777), new Fr(0xdddd)), - AztecAddress.fromField(new Fr(0x8888)), + AztecAddress.fromFieldUnsafe(new Fr(0x8888)), ); tx.data.gasUsed = privateGasUsed; @@ -1203,7 +1203,7 @@ describe('public_tx_simulator', () => { tx.data.forPublic!.revertibleAccumulatedData.l2ToL1Msgs[0] = new ScopedL2ToL1Message( new L2ToL1Message(EthAddress.fromNumber(123), new Fr(456)), - AztecAddress.fromNumber(789), + AztecAddress.fromNumberUnsafe(789), ); mockPublicExecutor([ @@ -1283,7 +1283,7 @@ describe('public_tx_simulator', () => { tx.data.forPublic!.revertibleAccumulatedData.l2ToL1Msgs[0] = new ScopedL2ToL1Message( new L2ToL1Message(EthAddress.fromNumber(123), new Fr(456)), - AztecAddress.fromNumber(789), + AztecAddress.fromNumberUnsafe(789), ); mockPublicExecutor([ @@ -1379,7 +1379,7 @@ describe('public_tx_simulator', () => { tx.data.forPublic!.revertibleAccumulatedData.l2ToL1Msgs[0] = new ScopedL2ToL1Message( new L2ToL1Message(EthAddress.fromNumber(123), new Fr(456)), - AztecAddress.fromNumber(789), + AztecAddress.fromNumberUnsafe(789), ); mockPublicExecutor([ diff --git a/yarn-project/simulator/src/public/side_effect_trace.test.ts b/yarn-project/simulator/src/public/side_effect_trace.test.ts index 0f55ea827cb5..befe67e4ff7d 100644 --- a/yarn-project/simulator/src/public/side_effect_trace.test.ts +++ b/yarn-project/simulator/src/public/side_effect_trace.test.ts @@ -106,11 +106,11 @@ describe('Public Side Effect Trace', () => { await trace.tracePublicStorageWrite(address, slot.add(new Fr(i)), value.add(new Fr(1)), false); } await expect( - trace.tracePublicStorageWrite(AztecAddress.fromNumber(42), new Fr(42), value, false), + trace.tracePublicStorageWrite(AztecAddress.fromNumberUnsafe(42), new Fr(42), value, false), ).rejects.toThrow(SideEffectLimitReachedError); // Still allows protocol writes await expect( - trace.tracePublicStorageWrite(AztecAddress.fromNumber(42), new Fr(42), value, true), + trace.tracePublicStorageWrite(AztecAddress.fromNumberUnsafe(42), new Fr(42), value, true), ).resolves.not.toThrow(); }); @@ -118,12 +118,12 @@ describe('Public Side Effect Trace', () => { for (let i = 0; i < PROTOCOL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX; i++) { await trace.tracePublicStorageWrite(address, slot, value, true); } - await expect(trace.tracePublicStorageWrite(AztecAddress.fromNumber(42), new Fr(42), value, true)).rejects.toThrow( - SideEffectLimitReachedError, - ); + await expect( + trace.tracePublicStorageWrite(AztecAddress.fromNumberUnsafe(42), new Fr(42), value, true), + ).rejects.toThrow(SideEffectLimitReachedError); // Still allows user writes await expect( - trace.tracePublicStorageWrite(AztecAddress.fromNumber(42), new Fr(42), value, false), + trace.tracePublicStorageWrite(AztecAddress.fromNumberUnsafe(42), new Fr(42), value, false), ).resolves.not.toThrow(); }); @@ -143,9 +143,9 @@ describe('Public Side Effect Trace', () => { it('Should enforce maximum number of new l2 to l1 messages', () => { for (let i = 0; i < MAX_L2_TO_L1_MSGS_PER_TX; i++) { - trace.traceNewL2ToL1Message(AztecAddress.fromNumber(i), new Fr(i), new Fr(i)); + trace.traceNewL2ToL1Message(AztecAddress.fromNumberUnsafe(i), new Fr(i), new Fr(i)); } - expect(() => trace.traceNewL2ToL1Message(AztecAddress.fromNumber(42), new Fr(42), new Fr(42))).toThrow( + expect(() => trace.traceNewL2ToL1Message(AztecAddress.fromNumberUnsafe(42), new Fr(42), new Fr(42))).toThrow( SideEffectLimitReachedError, ); }); @@ -153,10 +153,10 @@ describe('Public Side Effect Trace', () => { it('Should enforce maximum number of log fields', () => { // Fill the payload with one super large log trace.tracePublicLog( - AztecAddress.fromNumber(42), + AztecAddress.fromNumberUnsafe(42), new Array(FLAT_PUBLIC_LOGS_PAYLOAD_LENGTH - PUBLIC_LOG_HEADER_LENGTH).fill(new Fr(42)), ); - expect(() => trace.tracePublicLog(AztecAddress.fromNumber(42), [])).toThrow(SideEffectLimitReachedError); + expect(() => trace.tracePublicLog(AztecAddress.fromNumberUnsafe(42), [])).toThrow(SideEffectLimitReachedError); }); it('Should enforce maximum number of unique contract class IDs', async () => { @@ -209,17 +209,17 @@ describe('Public Side Effect Trace', () => { ), ); await expect( - trace.tracePublicStorageWrite(AztecAddress.fromNumber(42), new Fr(42), new Fr(42), false), + trace.tracePublicStorageWrite(AztecAddress.fromNumberUnsafe(42), new Fr(42), new Fr(42), false), ).rejects.toThrow(SideEffectLimitReachedError); await expect( - trace.tracePublicStorageWrite(AztecAddress.fromNumber(42), new Fr(42), new Fr(42), true), + trace.tracePublicStorageWrite(AztecAddress.fromNumberUnsafe(42), new Fr(42), new Fr(42), true), ).rejects.toThrow(SideEffectLimitReachedError); expect(() => trace.traceNewNoteHash(new Fr(42))).toThrow(SideEffectLimitReachedError); expect(() => trace.traceNewNullifier(new Fr(42))).toThrow(SideEffectLimitReachedError); - expect(() => trace.traceNewL2ToL1Message(AztecAddress.fromNumber(42), new Fr(42), new Fr(42))).toThrow( + expect(() => trace.traceNewL2ToL1Message(AztecAddress.fromNumberUnsafe(42), new Fr(42), new Fr(42))).toThrow( SideEffectLimitReachedError, ); - expect(() => trace.tracePublicLog(AztecAddress.fromNumber(42), [])).toThrow(SideEffectLimitReachedError); + expect(() => trace.tracePublicLog(AztecAddress.fromNumberUnsafe(42), [])).toThrow(SideEffectLimitReachedError); }); }); diff --git a/yarn-project/simulator/src/public/state_manager/public_storage.test.ts b/yarn-project/simulator/src/public/state_manager/public_storage.test.ts index 5530eaa5f1a2..6adbddfbc1fe 100644 --- a/yarn-project/simulator/src/public/state_manager/public_storage.test.ts +++ b/yarn-project/simulator/src/public/state_manager/public_storage.test.ts @@ -17,7 +17,7 @@ describe('avm public storage', () => { describe('AVM Public Storage', () => { it('Reading an unwritten slot works (gets zero & DNE)', async () => { - const contractAddress = AztecAddress.fromNumber(1); + const contractAddress = AztecAddress.fromNumberUnsafe(1); const slot = new Fr(2); // never written! publicDb.storageRead.mockResolvedValue(Fr.ZERO); @@ -28,7 +28,7 @@ describe('avm public storage', () => { }); it('Should cache storage write, reading works after write', async () => { - const contractAddress = AztecAddress.fromNumber(1); + const contractAddress = AztecAddress.fromNumberUnsafe(1); const slot = new Fr(2); const value = new Fr(3); // Write to cache @@ -40,7 +40,7 @@ describe('avm public storage', () => { }); it('Reading works on fallback to host (gets value & exists)', async () => { - const contractAddress = AztecAddress.fromNumber(1); + const contractAddress = AztecAddress.fromNumberUnsafe(1); const slot = new Fr(2); const storedValue = new Fr(420); // ensure that fallback to host gets a value @@ -53,7 +53,7 @@ describe('avm public storage', () => { }); it('Reading works on fallback to parent (gets value & exists)', async () => { - const contractAddress = AztecAddress.fromNumber(1); + const contractAddress = AztecAddress.fromNumberUnsafe(1); const slot = new Fr(2); const value = new Fr(3); const childStorage = new PublicStorage(publicDb, publicStorage); @@ -66,7 +66,7 @@ describe('avm public storage', () => { }); it('Reading works on fallback to grandparent (gets value & exists)', async () => { - const contractAddress = AztecAddress.fromNumber(1); + const contractAddress = AztecAddress.fromNumberUnsafe(1); const slot = new Fr(2); const value = new Fr(3); const childStorage = new PublicStorage(publicDb, publicStorage); @@ -81,7 +81,7 @@ describe('avm public storage', () => { it('When reading from storage, should check cache, then parent, then host', async () => { // Store a different value in storage vs the cache, and make sure the cache is returned - const contractAddress = AztecAddress.fromNumber(1); + const contractAddress = AztecAddress.fromNumberUnsafe(1); const slot = new Fr(2); const storedValue = new Fr(420); const parentValue = new Fr(69); @@ -114,7 +114,7 @@ describe('avm public storage', () => { it('Should be able to merge two public storages together', async () => { // Checking that child's writes take precedence on marge - const contractAddress = AztecAddress.fromNumber(1); + const contractAddress = AztecAddress.fromNumberUnsafe(1); const slot = new Fr(2); // value written initially in parent const value = new Fr(1); diff --git a/yarn-project/simulator/src/public/state_manager/state_manager.test.ts b/yarn-project/simulator/src/public/state_manager/state_manager.test.ts index 6c695e57c72a..cf9cdadb7bca 100644 --- a/yarn-project/simulator/src/public/state_manager/state_manager.test.ts +++ b/yarn-project/simulator/src/public/state_manager/state_manager.test.ts @@ -195,8 +195,8 @@ describe('state_manager', () => { // // merge journals // // t2 -> journal0 -> read | 2 - // const contractAddress = AztecAddress.fromNumber(1); - // const aztecContractAddress = AztecAddress.fromField(contractAddress); + // const contractAddress = AztecAddress.fromNumberUnsafe(1); + // const aztecContractAddress = AztecAddress.fromFieldUnsafe(contractAddress); // const key = new Fr(2); // const value = new Fr(1); // const valueT1 = new Fr(2); @@ -283,12 +283,12 @@ describe('state_manager', () => { // ]); // expect(journalUpdates.newLogs).toEqual([ // new UnencryptedL2Log( - // AztecAddress.fromBigInt(log.address), + // AztecAddress.fromBigIntUnsafe(log.address), // new EventSelector(log.selector), // Buffer.concat(log.data.map(f => f.toBuffer())), // ), // new UnencryptedL2Log( - // AztecAddress.fromBigInt(logT1.address), + // AztecAddress.fromBigIntUnsafe(logT1.address), // new EventSelector(logT1.selector), // Buffer.concat(logT1.data.map(f => f.toBuffer())), // ), @@ -328,8 +328,8 @@ describe('state_manager', () => { // // merge journals // // t2 -> journal0 -> read | 1 - // const contractAddress = AztecAddress.fromNumber(1); - // const aztecContractAddress = AztecAddress.fromField(contractAddress); + // const contractAddress = AztecAddress.fromNumberUnsafe(1); + // const aztecContractAddress = AztecAddress.fromFieldUnsafe(contractAddress); // const key = new Fr(2); // const value = new Fr(1); // const valueT1 = new Fr(2); @@ -437,7 +437,7 @@ describe('state_manager', () => { // // Check that rejected Accrued Substate is absent // expect(journalUpdates.newLogs).toEqual([ // new UnencryptedL2Log( - // AztecAddress.fromBigInt(log.address), + // AztecAddress.fromBigIntUnsafe(log.address), // new EventSelector(log.selector), // Buffer.concat(log.data.map(f => f.toBuffer())), // ), diff --git a/yarn-project/simulator/src/public/state_manager/state_manager.ts b/yarn-project/simulator/src/public/state_manager/state_manager.ts index ae2323bddca5..67eddb5db19d 100644 --- a/yarn-project/simulator/src/public/state_manager/state_manager.ts +++ b/yarn-project/simulator/src/public/state_manager/state_manager.ts @@ -402,7 +402,7 @@ export class PublicPersistableStateManager { // This will internally decide whether to check the nullifier tree or not depending on doMerkleOperations. const nullifierExistsInTree = await this.checkNullifierExists( - AztecAddress.fromNumber(CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS), + AztecAddress.fromNumberUnsafe(CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS), contractAddress.toField(), ); assert( diff --git a/yarn-project/standard-contracts/src/drift.ts b/yarn-project/standard-contracts/src/drift.ts index d41c67c97470..778305e4546a 100644 --- a/yarn-project/standard-contracts/src/drift.ts +++ b/yarn-project/standard-contracts/src/drift.ts @@ -37,7 +37,7 @@ function generateSalts(names: string[]) { function generateAddresses(names: string[], contractData: ContractData[]) { return ` export const StandardContractAddress: Record = { - ${contractData.map((d, i) => `${names[i]}: AztecAddress.fromString('${d.address.toString()}')`).join(',\n')} + ${contractData.map((d, i) => `${names[i]}: AztecAddress.fromStringUnsafe('${d.address.toString()}')`).join(',\n')} }; `; } diff --git a/yarn-project/standard-contracts/src/standard_contract_data.ts b/yarn-project/standard-contracts/src/standard_contract_data.ts index 5a66ea3ccc5c..ae3b0697cc5a 100644 --- a/yarn-project/standard-contracts/src/standard_contract_data.ts +++ b/yarn-project/standard-contracts/src/standard_contract_data.ts @@ -20,10 +20,14 @@ export const StandardContractSalt: Record = { }; export const StandardContractAddress: Record = { - AuthRegistry: AztecAddress.fromString('0x2df3bf0052304b37c59cfdb79eeeab7f05f8b1e197293e456dc9c7716e6fc654'), - MultiCallEntrypoint: AztecAddress.fromString('0x099e0fdbd90bed29103c75ae755dc43dc06e53c845dd25cf81ec05570a68c2fb'), - PublicChecks: AztecAddress.fromString('0x2da605de400a83f4c1750fdd1dba3a4b2977884a95549efd06f7a62ef6ae69c3'), - HandshakeRegistry: AztecAddress.fromString('0x19fca351f28a726da8bd3c66c10f22314bbe6359a61440efbbc0721e019167ef'), + AuthRegistry: AztecAddress.fromStringUnsafe('0x2df3bf0052304b37c59cfdb79eeeab7f05f8b1e197293e456dc9c7716e6fc654'), + MultiCallEntrypoint: AztecAddress.fromStringUnsafe( + '0x099e0fdbd90bed29103c75ae755dc43dc06e53c845dd25cf81ec05570a68c2fb', + ), + PublicChecks: AztecAddress.fromStringUnsafe('0x2da605de400a83f4c1750fdd1dba3a4b2977884a95549efd06f7a62ef6ae69c3'), + HandshakeRegistry: AztecAddress.fromStringUnsafe( + '0x19fca351f28a726da8bd3c66c10f22314bbe6359a61440efbbc0721e019167ef', + ), }; export const StandardContractClassId: Record = { diff --git a/yarn-project/stdlib/src/abi/decoder.test.ts b/yarn-project/stdlib/src/abi/decoder.test.ts index 2992dd4aeb30..8c8e3dd667f1 100644 --- a/yarn-project/stdlib/src/abi/decoder.test.ts +++ b/yarn-project/stdlib/src/abi/decoder.test.ts @@ -254,7 +254,7 @@ describe('decoder', () => { ], ); - expect(decoded).toEqual([1n, 2n, false, 'xyz', AztecAddress.fromBigInt(1n), { x: 1n, y: 2n }]); + expect(decoded).toEqual([1n, 2n, false, 'xyz', AztecAddress.fromBigIntUnsafe(1n), { x: 1n, y: 2n }]); }); it('decodes Option::Some as the wrapped value', () => { diff --git a/yarn-project/stdlib/src/avm/avm.ts b/yarn-project/stdlib/src/avm/avm.ts index a5f2a4963bf3..5ef89c02d0f5 100644 --- a/yarn-project/stdlib/src/avm/avm.ts +++ b/yarn-project/stdlib/src/avm/avm.ts @@ -1152,7 +1152,7 @@ export class CallStackMetadata { const { stack, leaf } = failingCall; const aztecCallStack = stack.map(call => ({ - contractAddress: AztecAddress.fromField(call.contractAddress), + contractAddress: AztecAddress.fromFieldUnsafe(call.contractAddress), functionSelector: call.calldata.length > 0 ? FunctionSelector.fromFieldOrUndefined(call.calldata[0]) : undefined, })); diff --git a/yarn-project/stdlib/src/aztec-address/index.ts b/yarn-project/stdlib/src/aztec-address/index.ts index e821d3997020..b147012430da 100644 --- a/yarn-project/stdlib/src/aztec-address/index.ts +++ b/yarn-project/stdlib/src/aztec-address/index.ts @@ -43,34 +43,64 @@ export class AztecAddress { static ZERO = new AztecAddress(Buffer.alloc(32, 0)); /** Null msg sender address. Not part of the protocol contracts tree. */ - static NULL_MSG_SENDER = AztecAddress.fromBigInt(NULL_MSG_SENDER_CONTRACT_ADDRESS); + static NULL_MSG_SENDER = AztecAddress.fromBigIntUnsafe(NULL_MSG_SENDER_CONTRACT_ADDRESS); static zero(): AztecAddress { return AztecAddress.ZERO; } - static fromField(fr: Fr) { + /** + * Builds an `AztecAddress` from a field **without checking it is a valid address** (the x-coordinate of a point on + * the Grumpkin curve, which is what lets it be encrypted to). Use {@link AztecAddress.isValid} to validate an + * untrusted one, or {@link AztecAddress.random} for valid test addresses. + */ + static fromFieldUnsafe(fr: Fr) { return new AztecAddress(fr); } + /** + * Deserializes an `AztecAddress` from a buffer. It does **not** check the value is a valid Grumpkin-curve address + * (see {@link AztecAddress.isValid}); it is meant for reading addresses from already-validated serialized data. Use + * {@link AztecAddress.random} for valid test addresses. + */ static fromBuffer(buffer: Buffer | BufferReader) { return new AztecAddress(fromBuffer(buffer, Fr)); } + /** + * Deserializes an `AztecAddress` from a field reader. It does **not** check the value is a valid Grumpkin-curve + * address (see {@link AztecAddress.isValid}); it is meant for reading addresses from already-validated serialized + * data. Use {@link AztecAddress.random} for valid test addresses. + */ static fromFields(fields: Fr[] | FieldReader) { const reader = FieldReader.asReader(fields); return new AztecAddress(reader.readField()); } - static fromBigInt(value: bigint) { + /** + * Builds an `AztecAddress` from a bigint **without checking it is a valid address** (the x-coordinate of a point on + * the Grumpkin curve, which is what lets it be encrypted to). Use {@link AztecAddress.isValid} to validate an + * untrusted one, or {@link AztecAddress.random} for valid test addresses. + */ + static fromBigIntUnsafe(value: bigint) { return new AztecAddress(new Fr(value)); } - static fromNumber(value: number) { + /** + * Builds an `AztecAddress` from a number **without checking it is a valid address** (the x-coordinate of a point on + * the Grumpkin curve, which is what lets it be encrypted to). Use {@link AztecAddress.isValid} to validate an + * untrusted one, or {@link AztecAddress.random} for valid test addresses. + */ + static fromNumberUnsafe(value: number) { return new AztecAddress(new Fr(value)); } - static fromString(buf: string) { + /** + * Builds an `AztecAddress` from a hex string **without checking it is a valid address** (the x-coordinate of a + * point on the Grumpkin curve, which is what lets it be encrypted to). Use {@link AztecAddress.isValid} to + * validate an untrusted one, or {@link AztecAddress.random} for valid test addresses. + */ + static fromStringUnsafe(buf: string) { return new AztecAddress(hexToBuffer(buf)); } @@ -89,7 +119,7 @@ export class AztecAddress { if (obj instanceof Buffer || Buffer.isBuffer(obj)) { return new AztecAddress(obj); } - return AztecAddress.fromString(obj); + return AztecAddress.fromStringUnsafe(obj); } /** diff --git a/yarn-project/stdlib/src/checkpoint/validate.test.ts b/yarn-project/stdlib/src/checkpoint/validate.test.ts index 271fe4f87779..2c81ba4a359a 100644 --- a/yarn-project/stdlib/src/checkpoint/validate.test.ts +++ b/yarn-project/stdlib/src/checkpoint/validate.test.ts @@ -18,7 +18,7 @@ describe('validateCheckpointStructure', () => { const fixedSlot = SlotNumber(42); const fixedCoinbase = EthAddress.random(); - const fixedFeeRecipient = AztecAddress.fromField(Fr.random()); + const fixedFeeRecipient = AztecAddress.fromFieldUnsafe(Fr.random()); const fixedGasFees = GasFees.random(); const fixedTimestamp = BigInt(Math.floor(Date.now() / 1000)); @@ -158,7 +158,7 @@ describe('validateCheckpoint — limits', () => { const checkpointNumber = CheckpointNumber(1); const fixedSlot = SlotNumber(42); const fixedCoinbase = EthAddress.random(); - const fixedFeeRecipient = AztecAddress.fromField(Fr.random()); + const fixedFeeRecipient = AztecAddress.fromFieldUnsafe(Fr.random()); const fixedGasFees = GasFees.random(); const fixedTimestamp = BigInt(Math.floor(Date.now() / 1000)); diff --git a/yarn-project/stdlib/src/contract/contract_address.test.ts b/yarn-project/stdlib/src/contract/contract_address.test.ts index f378473ba4ab..4a13cacfc2a0 100644 --- a/yarn-project/stdlib/src/contract/contract_address.test.ts +++ b/yarn-project/stdlib/src/contract/contract_address.test.ts @@ -27,7 +27,7 @@ describe('ContractAddress', () => { const mockInstance = { initializationHash: new Fr(1), salt: new Fr(2), - deployer: AztecAddress.fromField(new Fr(4)), + deployer: AztecAddress.fromFieldUnsafe(new Fr(4)), immutablesHash: new Fr(3), }; const result = await computeSaltedInitializationHash(mockInstance); @@ -62,7 +62,7 @@ describe('ContractAddress', () => { const contractClassId = new Fr(4n); const initializationHash = new Fr(5n); const immutablesHash = new Fr(6n); - const deployer = AztecAddress.fromField(new Fr(7)); + const deployer = AztecAddress.fromFieldUnsafe(new Fr(7)); const publicKeys = (await deriveKeys(secretKey)).publicKeys; const instance = { publicKeys, diff --git a/yarn-project/stdlib/src/hash/hash.test.ts b/yarn-project/stdlib/src/hash/hash.test.ts index 93320c17c973..85833838a098 100644 --- a/yarn-project/stdlib/src/hash/hash.test.ts +++ b/yarn-project/stdlib/src/hash/hash.test.ts @@ -99,7 +99,7 @@ describe('hash', () => { }); it('computes public data tree leaf slot', async () => { - const contractAddress = AztecAddress.fromField(new Fr(987)); + const contractAddress = AztecAddress.fromFieldUnsafe(new Fr(987)); const storageSlot = new Fr(123); const res = await computePublicDataTreeLeafSlot(contractAddress, storageSlot); expect(res.toString()).toMatchInlineSnapshot( @@ -172,7 +172,7 @@ describe('hash', () => { it('empty L2ToL1Message siloing matches Noir', () => { const nonEmptyHash = computeL2ToL1MessageHash({ - l2Sender: AztecAddress.fromField(new Fr(0)), + l2Sender: AztecAddress.fromFieldUnsafe(new Fr(0)), l1Recipient: EthAddress.fromField(new Fr(0)), content: new Fr(0), rollupVersion: new Fr(0), @@ -193,7 +193,7 @@ describe('hash', () => { it('L2ToL1Message siloing matches Noir', () => { const nonEmptyHash = computeL2ToL1MessageHash({ - l2Sender: AztecAddress.fromField(new Fr(3)), + l2Sender: AztecAddress.fromFieldUnsafe(new Fr(3)), l1Recipient: EthAddress.fromField(new Fr(1)), content: new Fr(2), rollupVersion: new Fr(4), diff --git a/yarn-project/stdlib/src/hash/map_slot.test.ts b/yarn-project/stdlib/src/hash/map_slot.test.ts index 71de81cb15de..e251a9457c91 100644 --- a/yarn-project/stdlib/src/hash/map_slot.test.ts +++ b/yarn-project/stdlib/src/hash/map_slot.test.ts @@ -7,7 +7,7 @@ import { deriveStorageSlotInMap } from './index.js'; describe('Map slot', () => { it('derived map slot matches Noir', async () => { const mapSlot = new Fr(0x132258fb6962c4387ba659d9556521102d227549a386d39f0b22d1890d59c2b5n); - const key = AztecAddress.fromString('0x302dbc2f9b50a73283d5fb2f35bc01eae8935615817a0b4219a057b2ba8a5a3f'); + const key = AztecAddress.fromStringUnsafe('0x302dbc2f9b50a73283d5fb2f35bc01eae8935615817a0b4219a057b2ba8a5a3f'); const slot = await deriveStorageSlotInMap(mapSlot, key); diff --git a/yarn-project/stdlib/src/kernel/hints/build_note_hash_read_request_hints.test.ts b/yarn-project/stdlib/src/kernel/hints/build_note_hash_read_request_hints.test.ts index 45d25ecd985a..162cc5bb73ec 100644 --- a/yarn-project/stdlib/src/kernel/hints/build_note_hash_read_request_hints.test.ts +++ b/yarn-project/stdlib/src/kernel/hints/build_note_hash_read_request_hints.test.ts @@ -13,7 +13,7 @@ import { ReadRequest, ScopedReadRequest } from './read_request.js'; import { PendingReadHint, ReadRequestAction, SettledReadHint } from './read_request_hints.js'; describe('buildNoteHashReadRequestHints', () => { - const contractAddress = AztecAddress.fromBigInt(112233n); + const contractAddress = AztecAddress.fromBigIntUnsafe(112233n); const getNoteHashValue = (index: number) => index + 9999; diff --git a/yarn-project/stdlib/src/kernel/hints/build_nullifier_read_request_hints.test.ts b/yarn-project/stdlib/src/kernel/hints/build_nullifier_read_request_hints.test.ts index 7244472f602d..9c30c30a2c16 100644 --- a/yarn-project/stdlib/src/kernel/hints/build_nullifier_read_request_hints.test.ts +++ b/yarn-project/stdlib/src/kernel/hints/build_nullifier_read_request_hints.test.ts @@ -17,7 +17,7 @@ describe('buildNullifierReadRequestHints', () => { /** * Create fixtures. */ - const contractAddress = AztecAddress.fromBigInt(112233n); + const contractAddress = AztecAddress.fromBigIntUnsafe(112233n); const innerNullifier = (index: number) => index + 1; diff --git a/yarn-project/stdlib/src/kernel/hints/build_transient_data_hints.test.ts b/yarn-project/stdlib/src/kernel/hints/build_transient_data_hints.test.ts index 91a2cbd22bdc..18112d827f08 100644 --- a/yarn-project/stdlib/src/kernel/hints/build_transient_data_hints.test.ts +++ b/yarn-project/stdlib/src/kernel/hints/build_transient_data_hints.test.ts @@ -10,7 +10,7 @@ import { ReadRequest, ScopedReadRequest } from './read_request.js'; import { TransientDataSquashingHint } from './transient_data_squashing_hint.js'; describe('buildTransientDataHints', () => { - const contractAddress = AztecAddress.fromBigInt(987654n); + const contractAddress = AztecAddress.fromBigIntUnsafe(987654n); let noteHashes: ScopedNoteHash[]; let nullifiers: ScopedNullifier[]; @@ -90,7 +90,7 @@ describe('buildTransientDataHints', () => { }); it('throws if contract address does not match', () => { - nullifiers[3].contractAddress = AztecAddress.fromBigInt(123456n); + nullifiers[3].contractAddress = AztecAddress.fromBigIntUnsafe(123456n); expect(buildHints).toThrow('Contract address of hinted note hash does not match.'); }); @@ -134,7 +134,7 @@ describe('buildTransientDataHints', () => { }); describe('countSquashedLogs', () => { - const contractAddress = AztecAddress.fromBigInt(987654n); + const contractAddress = AztecAddress.fromBigIntUnsafe(987654n); const makeLog = (noteHashCounter: number, counter: number): ScopedPrivateLogData => { const log = PrivateLogData.empty(); diff --git a/yarn-project/stdlib/src/kernel/hints/read_request.ts b/yarn-project/stdlib/src/kernel/hints/read_request.ts index 5ad51b7b85a1..fdd895270277 100644 --- a/yarn-project/stdlib/src/kernel/hints/read_request.ts +++ b/yarn-project/stdlib/src/kernel/hints/read_request.ts @@ -112,7 +112,7 @@ export class ScopedReadRequest { static fromFields(fields: Fr[] | FieldReader) { const reader = FieldReader.asReader(fields); - return new ScopedReadRequest(reader.readObject(ReadRequest), AztecAddress.fromField(reader.readField())); + return new ScopedReadRequest(reader.readObject(ReadRequest), AztecAddress.fromFieldUnsafe(reader.readField())); } /** diff --git a/yarn-project/stdlib/src/kernel/log_hash.ts b/yarn-project/stdlib/src/kernel/log_hash.ts index aafa1ceded48..ad57699ffb5d 100644 --- a/yarn-project/stdlib/src/kernel/log_hash.ts +++ b/yarn-project/stdlib/src/kernel/log_hash.ts @@ -114,7 +114,7 @@ export class ScopedLogHash { static fromFields(fields: Fr[] | FieldReader) { const reader = FieldReader.asReader(fields); - return new ScopedLogHash(reader.readObject(LogHash), AztecAddress.fromField(reader.readField())); + return new ScopedLogHash(reader.readObject(LogHash), AztecAddress.fromFieldUnsafe(reader.readField())); } isEmpty() { @@ -156,7 +156,10 @@ export class ScopedCountedLogHash { static fromFields(fields: Fr[] | FieldReader) { const reader = FieldReader.asReader(fields); - return new ScopedCountedLogHash(reader.readObject(CountedLogHash), AztecAddress.fromField(reader.readField())); + return new ScopedCountedLogHash( + reader.readObject(CountedLogHash), + AztecAddress.fromFieldUnsafe(reader.readField()), + ); } toBuffer(): Buffer; diff --git a/yarn-project/stdlib/src/kernel/note_hash.ts b/yarn-project/stdlib/src/kernel/note_hash.ts index acab10025047..b2978cb867dd 100644 --- a/yarn-project/stdlib/src/kernel/note_hash.ts +++ b/yarn-project/stdlib/src/kernel/note_hash.ts @@ -65,7 +65,7 @@ export class ScopedNoteHash implements Ordered { static fromFields(fields: Fr[] | FieldReader) { const reader = FieldReader.asReader(fields); - return new ScopedNoteHash(reader.readObject(NoteHash), AztecAddress.fromField(reader.readField())); + return new ScopedNoteHash(reader.readObject(NoteHash), AztecAddress.fromFieldUnsafe(reader.readField())); } isEmpty() { diff --git a/yarn-project/stdlib/src/kernel/nullifier.ts b/yarn-project/stdlib/src/kernel/nullifier.ts index fb0453e2836e..cf61936d501a 100644 --- a/yarn-project/stdlib/src/kernel/nullifier.ts +++ b/yarn-project/stdlib/src/kernel/nullifier.ts @@ -70,7 +70,7 @@ export class ScopedNullifier implements Ordered { static fromFields(fields: Fr[] | FieldReader) { const reader = FieldReader.asReader(fields); - return new ScopedNullifier(reader.readObject(Nullifier), AztecAddress.fromField(reader.readField())); + return new ScopedNullifier(reader.readObject(Nullifier), AztecAddress.fromFieldUnsafe(reader.readField())); } isEmpty() { diff --git a/yarn-project/stdlib/src/kernel/private_log_data.ts b/yarn-project/stdlib/src/kernel/private_log_data.ts index 9e68d6d240dd..d5055b847cc9 100644 --- a/yarn-project/stdlib/src/kernel/private_log_data.ts +++ b/yarn-project/stdlib/src/kernel/private_log_data.ts @@ -85,7 +85,10 @@ export class ScopedPrivateLogData { static fromFields(fields: Fr[] | FieldReader) { const reader = FieldReader.asReader(fields); - return new ScopedPrivateLogData(reader.readObject(PrivateLogData), AztecAddress.fromField(reader.readField())); + return new ScopedPrivateLogData( + reader.readObject(PrivateLogData), + AztecAddress.fromFieldUnsafe(reader.readField()), + ); } isEmpty() { diff --git a/yarn-project/stdlib/src/logs/app_tagging_secret.ts b/yarn-project/stdlib/src/logs/app_tagging_secret.ts index f0d441ee170a..77c92d6dcf2c 100644 --- a/yarn-project/stdlib/src/logs/app_tagging_secret.ts +++ b/yarn-project/stdlib/src/logs/app_tagging_secret.ts @@ -71,13 +71,13 @@ export class AppTaggingSecret { if (parts.length === 2) { // TODO(F-680): Remove legacy two-part parsing after stored tagging keys are migrated. const [secretStr, appStr] = parts; - return new AppTaggingSecret(Fr.fromString(secretStr), AztecAddress.fromString(appStr)); + return new AppTaggingSecret(Fr.fromString(secretStr), AztecAddress.fromStringUnsafe(appStr)); } if (parts.length === 3) { const [kindStr, secretStr, appStr] = parts; return new AppTaggingSecret( Fr.fromString(secretStr), - AztecAddress.fromString(appStr), + AztecAddress.fromStringUnsafe(appStr), appTaggingSecretKindFromString(kindStr), ); } diff --git a/yarn-project/stdlib/src/logs/contract_class_log.test.ts b/yarn-project/stdlib/src/logs/contract_class_log.test.ts index 0ef4d69f33b2..833a160b45e2 100644 --- a/yarn-project/stdlib/src/logs/contract_class_log.test.ts +++ b/yarn-project/stdlib/src/logs/contract_class_log.test.ts @@ -37,7 +37,7 @@ describe('ContractClassLog', () => { it('number of emitted blob fields is correct', () => { const smallLogFields = [new Fr(1), new Fr(2), new Fr(3)]; const smallLog = new ContractClassLog( - AztecAddress.fromField(Fr.ONE), + AztecAddress.fromFieldUnsafe(Fr.ONE), ContractClassLogFields.fromEmittedFields(smallLogFields), smallLogFields.length, ); @@ -47,7 +47,7 @@ describe('ContractClassLog', () => { Fr.random(), ); const largeLog = new ContractClassLog( - AztecAddress.fromField(Fr.ONE), + AztecAddress.fromFieldUnsafe(Fr.ONE), ContractClassLogFields.fromEmittedFields(largeLogFields), largeLogFields.length, ); diff --git a/yarn-project/stdlib/src/rollup/checkpoint_header.test.ts b/yarn-project/stdlib/src/rollup/checkpoint_header.test.ts index 14eaef5d7f53..2748572da831 100644 --- a/yarn-project/stdlib/src/rollup/checkpoint_header.test.ts +++ b/yarn-project/stdlib/src/rollup/checkpoint_header.test.ts @@ -42,7 +42,7 @@ describe('CheckpointHeader', () => { slotNumber: SlotNumber(1234), timestamp: BigInt(5678), coinbase: EthAddress.fromField(new Fr(9090)), - feeRecipient: AztecAddress.fromField(new Fr(101010)), + feeRecipient: AztecAddress.fromFieldUnsafe(new Fr(101010)), gasFees: new GasFees(100, 200), totalManaUsed: new Fr(151617), accumulatedFees: new Fr(181920), @@ -69,7 +69,7 @@ describe('CheckpointHeader', () => { slotNumber: SlotNumber(1234), timestamp: 2n ** 64n - 1n - 5678n, coinbase: EthAddress.fromField(new Fr(2n ** 160n - 1n - 9090n)), - feeRecipient: AztecAddress.fromField(new Fr(MAX_FIELD_VALUE - 101010n)), + feeRecipient: AztecAddress.fromFieldUnsafe(new Fr(MAX_FIELD_VALUE - 101010n)), gasFees: new GasFees(2n ** 128n - 1n - 100n, 2n ** 128n - 1n - 200n), totalManaUsed: new Fr(MAX_FIELD_VALUE - 151617n), accumulatedFees: new Fr(MAX_FIELD_VALUE - 181920n), diff --git a/yarn-project/stdlib/src/tests/factories.ts b/yarn-project/stdlib/src/tests/factories.ts index a4708c7578e9..9962e7f2615c 100644 --- a/yarn-project/stdlib/src/tests/factories.ts +++ b/yarn-project/stdlib/src/tests/factories.ts @@ -703,7 +703,7 @@ export function makeGlobalVariables(seed = 1, overrides: Partial { }); } - const someAddress = AztecAddress.fromField(new Fr(27)); + const someAddress = AztecAddress.fromFieldUnsafe(new Fr(27)); it('returns overhead only for tx with just a nullifier', () => { const tx = makePrivateOnlyTx(); diff --git a/yarn-project/stdlib/src/tx/tx_request.test.ts b/yarn-project/stdlib/src/tx/tx_request.test.ts index bb1e8f254108..ef6329aa1576 100644 --- a/yarn-project/stdlib/src/tx/tx_request.test.ts +++ b/yarn-project/stdlib/src/tx/tx_request.test.ts @@ -35,7 +35,7 @@ describe('TxRequest', () => { it('compute hash', async () => { const gasSettings = new GasSettings(new Gas(2, 2), new Gas(1, 1), new GasFees(4, 4), new GasFees(3, 3)); const txRequest = TxRequest.from({ - origin: AztecAddress.fromBigInt(1122n), + origin: AztecAddress.fromBigIntUnsafe(1122n), argsHash: new Fr(33), txContext: new TxContext(new Fr(44), new Fr(55), gasSettings), functionData: new FunctionData(FunctionSelector.fromField(new Fr(66n)), /*isPrivate=*/ true), diff --git a/yarn-project/txe/src/constants.ts b/yarn-project/txe/src/constants.ts index bbe9cd289d52..dec902fd9a83 100644 --- a/yarn-project/txe/src/constants.ts +++ b/yarn-project/txe/src/constants.ts @@ -1,7 +1,7 @@ import { PRIVATE_LOG_CIPHERTEXT_LEN } from '@aztec/constants'; import { AztecAddress } from '@aztec/stdlib/aztec-address'; -export const DEFAULT_ADDRESS = AztecAddress.fromNumber(42); +export const DEFAULT_ADDRESS = AztecAddress.fromNumberUnsafe(42); // This is MAX_MESSAGE_CONTENT_LEN - PRIVATE_EVENT_MSG_PLAINTEXT_RESERVED_FIELDS_LEN export const MAX_PRIVATE_EVENT_LEN = 10; diff --git a/yarn-project/txe/src/oracle/test-resolver/default_fixtures.ts b/yarn-project/txe/src/oracle/test-resolver/default_fixtures.ts index 924837b7c095..db0654fa1bb5 100644 --- a/yarn-project/txe/src/oracle/test-resolver/default_fixtures.ts +++ b/yarn-project/txe/src/oracle/test-resolver/default_fixtures.ts @@ -53,7 +53,7 @@ const TEST_VALUE_IMPLS: TestValueImpl[] = [ scalar(BIGINT, seed => BigInt(seed)), scalar(BYTE, seed => seed), scalar(BOOL, seed => seed % 2 !== 0), - scalar(AZTEC_ADDRESS, seed => AztecAddress.fromNumber(seed)), + scalar(AZTEC_ADDRESS, seed => AztecAddress.fromNumberUnsafe(seed)), scalar(FUNCTION_SELECTOR, seed => FunctionSelector.fromField(new Fr(seed))), scalar(NOTE_SELECTOR, seed => NoteSelector.fromField(new Fr(seed))), scalar(BLOCK_HASH, seed => new BlockHash(new Fr(seed))), diff --git a/yarn-project/txe/src/oracle/test-resolver/resolver.test.ts b/yarn-project/txe/src/oracle/test-resolver/resolver.test.ts index 4230904a4ac1..6ad5f0f45411 100644 --- a/yarn-project/txe/src/oracle/test-resolver/resolver.test.ts +++ b/yarn-project/txe/src/oracle/test-resolver/resolver.test.ts @@ -37,9 +37,9 @@ const TEST_REGISTRY: Record = { }; const TEST_FIXTURES: Record = { - test_single: [{ inputs: { slot: new Fr(10), addr: AztecAddress.fromNumber(1) }, output: new Fr(42) }], + test_single: [{ inputs: { slot: new Fr(10), addr: AztecAddress.fromNumberUnsafe(1) }, output: new Fr(42) }], test_multi: [ - { scenario: 'some', inputs: {}, output: Option.some(AztecAddress.fromNumber(7)) }, + { scenario: 'some', inputs: {}, output: Option.some(AztecAddress.fromNumberUnsafe(7)) }, { scenario: 'none', inputs: {}, output: Option.none(AztecAddress.ZERO) }, ], test_labeled: [ @@ -60,7 +60,7 @@ describe('OracleTestResolver', () => { }); it('resolves an oracle with a single scenario', async () => { - const result = await callOracle('test_single', [toHex(new Fr(10)), toHex(AztecAddress.fromNumber(1))]); + const result = await callOracle('test_single', [toHex(new Fr(10)), toHex(AztecAddress.fromNumberUnsafe(1))]); expect(result.values).toHaveLength(1); expect(result.values[0]).toBe(toHex(new Fr(42))); }); @@ -90,9 +90,9 @@ describe('OracleTestResolver', () => { }); it('throws when inputs do not match the fixture', async () => { - await expect(callOracle('test_single', [toHex(new Fr(777)), toHex(AztecAddress.fromNumber(1))])).rejects.toThrow( - 'Input mismatch', - ); + await expect( + callOracle('test_single', [toHex(new Fr(777)), toHex(AztecAddress.fromNumberUnsafe(1))]), + ).rejects.toThrow('Input mismatch'); }); it('labels the input-mismatch error with the scenario name', async () => { @@ -126,7 +126,7 @@ describe('OracleTestResolver', () => { it('tracks uncalled fixtures', async () => { expect(resolver.getUncalledFixtures()).toContain('test_single'); - await callOracle('test_single', [toHex(new Fr(10)), toHex(AztecAddress.fromNumber(1))]); + await callOracle('test_single', [toHex(new Fr(10)), toHex(AztecAddress.fromNumberUnsafe(1))]); expect(resolver.getUncalledFixtures()).not.toContain('test_single'); }); diff --git a/yarn-project/txe/src/oracle/txe_oracle_top_level_context.ts b/yarn-project/txe/src/oracle/txe_oracle_top_level_context.ts index 17139ca29023..7f21ccc642ab 100644 --- a/yarn-project/txe/src/oracle/txe_oracle_top_level_context.ts +++ b/yarn-project/txe/src/oracle/txe_oracle_top_level_context.ts @@ -252,7 +252,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl } private deploymentNullifier(address: AztecAddress): Promise { - return siloNullifier(AztecAddress.fromNumber(CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS), address.toField()); + return siloNullifier(AztecAddress.fromNumberUnsafe(CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS), address.toField()); } async deploy( diff --git a/yarn-project/validator-client/src/checkpoint_builder.test.ts b/yarn-project/validator-client/src/checkpoint_builder.test.ts index 6f5d48bdacff..01a07bdd46e1 100644 --- a/yarn-project/validator-client/src/checkpoint_builder.test.ts +++ b/yarn-project/validator-client/src/checkpoint_builder.test.ts @@ -60,7 +60,7 @@ describe('CheckpointBuilder', () => { slotNumber, timestamp: BigInt(Date.now()), coinbase: EthAddress.random(), - feeRecipient: AztecAddress.fromField(Fr.random()), + feeRecipient: AztecAddress.fromFieldUnsafe(Fr.random()), gasFees: GasFees.empty(), }; diff --git a/yarn-project/validator-client/src/key_store/node_keystore_adapter.test.ts b/yarn-project/validator-client/src/key_store/node_keystore_adapter.test.ts index bead4a92fdc4..2f50546dd024 100644 --- a/yarn-project/validator-client/src/key_store/node_keystore_adapter.test.ts +++ b/yarn-project/validator-client/src/key_store/node_keystore_adapter.test.ts @@ -40,9 +40,9 @@ const A = { COINBASE_1: EthAddress.fromString('0x3c44cdddb6a900fa2b585dd299e03d12fa4293bc'), COINBASE_2: EthAddress.fromString('0x90f79bf6eb2c4f870365e785982e1f101e93b906'), COINBASE_3: EthAddress.fromString('0x71be63f3384f5fb98995898a86b02fb2426c5788'), - FEE_1: AztecAddress.fromString('0x0bcd4042de499d14e55001ccbb24a551f3b95409600000000000000000000000'), - FEE_2: AztecAddress.fromString('0x071be63f3384f5fb98995898a86b02fb2426c578800000000000000000000000'), - FEE_3: AztecAddress.fromString('0x0f39fd6e51aad88f6f4ce6ab8827279cfffb9226600000000000000000000000'), + FEE_1: AztecAddress.fromStringUnsafe('0x0bcd4042de499d14e55001ccbb24a551f3b95409600000000000000000000000'), + FEE_2: AztecAddress.fromStringUnsafe('0x071be63f3384f5fb98995898a86b02fb2426c578800000000000000000000000'), + FEE_3: AztecAddress.fromStringUnsafe('0x0f39fd6e51aad88f6f4ce6ab8827279cfffb9226600000000000000000000000'), UNKNOWN: '0x9999999999999999999999999999999999999999', } as const; diff --git a/yarn-project/wallet-sdk/src/base-wallet/base_wallet.ts b/yarn-project/wallet-sdk/src/base-wallet/base_wallet.ts index 29f220531915..7e9179b7ee72 100644 --- a/yarn-project/wallet-sdk/src/base-wallet/base_wallet.ts +++ b/yarn-project/wallet-sdk/src/base-wallet/base_wallet.ts @@ -129,7 +129,7 @@ export abstract class BaseWallet implements Wallet { protected scopesFrom(from: AztecAddress | NoFrom, additionalScopes: AztecAddress[] = []): AztecAddress[] { const allScopes = from === NO_FROM ? additionalScopes : [from, ...additionalScopes]; const scopeSet = new Set(allScopes.map(address => address.toString())); - return [...scopeSet].map(AztecAddress.fromString); + return [...scopeSet].map(AztecAddress.fromStringUnsafe); } /** diff --git a/yarn-project/wallets/src/embedded/wallet_db.ts b/yarn-project/wallets/src/embedded/wallet_db.ts index e6d8e1a47491..6671cdee0171 100644 --- a/yarn-project/wallets/src/embedded/wallet_db.ts +++ b/yarn-project/wallets/src/embedded/wallet_db.ts @@ -83,7 +83,7 @@ export class WalletDB { return accountAddresses.map(addressStr => ({ alias: aliasesByAddress.get(addressStr) ?? '', - item: AztecAddress.fromString(addressStr), + item: AztecAddress.fromStringUnsafe(addressStr), })); } @@ -92,7 +92,7 @@ export class WalletDB { for await (const [alias, item] of this.aliases.entriesAsync({ start: 'senders:', end: 'senders:\uffff' })) { result.push({ alias: alias.slice('senders:'.length), - item: AztecAddress.fromString(item.toString()), + item: AztecAddress.fromStringUnsafe(item.toString()), }); } return result; From 517e5f1b218d1a687eaf3021c0545cb46ba5c233 Mon Sep 17 00:00:00 2001 From: Nico Chamo Date: Mon, 22 Jun 2026 20:13:05 -0300 Subject: [PATCH 2/2] chore: re-run CI (check bench_build_block flakiness)