Skip to content

Commit

Permalink
fix: confusing "Unknown complete address" error (#2967)
Browse files Browse the repository at this point in the history
1. Fixes #2951
2. Sneaked in a naming issue fix where getPublicKey was returning a
`CompleteAddress`
  • Loading branch information
benesjan authored Oct 23, 2023
1 parent fd1a1a8 commit 3a8f54a
Show file tree
Hide file tree
Showing 11 changed files with 71 additions and 107 deletions.
8 changes: 4 additions & 4 deletions docs/docs/dev_docs/contracts/common_errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ To execute a transaction, the PXE needs to know the complete address of a contra

To address the error, add the contract to the PXE by calling `server.addContracts(...)`.

### Unknown Complete Address Error
### No Public Key Registered Error
This error occurs when your contract is trying to get a public key via the `get_public_key` oracle call, but the PXE does not have the Complete Address (Complete Address contains the public key).

This is what the error typically looks like:
```
Simulation error: Unknown complete address for address 0x0d179a5f9bd4505f7dfb8ca37d64e0bd0cd31b5cb018e252fd647bdf88959b95. Add the information to PXE by calling pxe.registerRecipient(...) or pxe.registerAccount(...)
Simulation error: No public key registered for address 0x0d179a5f9bd4505f7dfb8ca37d64e0bd0cd31b5cb018e252fd647bdf88959b95. Register it by calling pxe.registerRecipient(...) or pxe.registerAccount(...)
```

Your contract typically needs a public key when it wants to send a note to a recipient because the public key is used to encrypt notes.
Your contract typically needs a note recipient's public key when it wants to send a note to because the public key is used to encrypt notes.

:::info
Manually adding the recipient to the PXE should not be required in case the recipient contract has already been deployed and the PXE is fully synced.
Expand All @@ -49,5 +49,5 @@ This is what the error typically looks like:
Could not process note because of "Error: Unknown account.". Skipping note...
```

This error might occurr when you register an account only as a recipient and not as an account.
This error might occur when you register an account only as a recipient and not as an account.
To address the error, register the account by calling `server.registerAccount(...)`.
4 changes: 2 additions & 2 deletions yarn-project/acir-simulator/src/acvm/oracle/oracle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ export class Oracle {
return [toACVMField(secretKey.low), toACVMField(secretKey.high)];
}

async getPublicKey([address]: ACVMField[]) {
const { publicKey, partialAddress } = await this.typedOracle.getPublicKey(
async getPublicKeyAndPartialAddress([address]: ACVMField[]) {
const { publicKey, partialAddress } = await this.typedOracle.getCompleteAddress(
AztecAddress.fromField(fromACVMField(address)),
);
return [publicKey.x, publicKey.y, partialAddress].map(toACVMField);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export abstract class TypedOracle {
throw new Error('Not available.');
}

getPublicKey(_address: AztecAddress): Promise<CompleteAddress> {
getCompleteAddress(_address: AztecAddress): Promise<CompleteAddress> {
throw new Error('Not available.');
}

Expand Down
2 changes: 1 addition & 1 deletion yarn-project/acir-simulator/src/client/view_data_oracle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class ViewDataOracle extends TypedOracle {
* @param address - Address to fetch the complete address for.
* @returns A complete address associated with the input address.
*/
public getPublicKey(address: AztecAddress): Promise<CompleteAddress> {
public getCompleteAddress(address: AztecAddress): Promise<CompleteAddress> {
return this.db.getCompleteAddress(address);
}

Expand Down
10 changes: 5 additions & 5 deletions yarn-project/aztec-nr/aztec/src/oracle/get_public_key.nr
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
use crate::types::point::Point;
use crate::address::compute_address;

#[oracle(getPublicKey)]
fn get_public_key_oracle(_address: Field) -> [Field; 3] {}
#[oracle(getPublicKeyAndPartialAddress)]
fn get_public_key_and_partial_address_oracle(_address: Field) -> [Field; 3] {}

unconstrained fn get_public_key_internal(address: Field) -> [Field; 3] {
get_public_key_oracle(address)
unconstrained fn get_public_key_and_partial_address_internal(address: Field) -> [Field; 3] {
get_public_key_and_partial_address_oracle(address)
}

pub fn get_public_key(address: Field) -> Point {
let result = get_public_key_internal(address);
let result = get_public_key_and_partial_address_internal(address);
let pub_key_x = result[0];
let pub_key_y = result[1];
let partial_address = result[2];
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

16 changes: 6 additions & 10 deletions yarn-project/boxes/blank-react/src/artifacts/Blank.json

Large diffs are not rendered by default.

16 changes: 6 additions & 10 deletions yarn-project/boxes/blank/src/artifacts/Blank.json

Large diffs are not rendered by default.

110 changes: 41 additions & 69 deletions yarn-project/boxes/token/src/artifacts/Token.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion yarn-project/pxe/src/simulator_oracle/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class SimulatorOracle implements DBOracle {
const completeAddress = await this.db.getCompleteAddress(address);
if (!completeAddress)
throw new Error(
`Unknown complete address for address ${address.toString()}. Add the information to PXE Service by calling server.registerRecipient(...) or server.registerAccount(...)`,
`No public key registered for address ${address.toString()}. Register it by calling pxe.registerRecipient(...) or pxe.registerAccount(...)`,
);
return completeAddress;
}
Expand Down

0 comments on commit 3a8f54a

Please sign in to comment.