Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions noir-projects/labs/aztec-nr/aztec/src/test/helpers/mod.nr
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@ pub mod test_environment;
@[
quote { get_last_tx_effects_oracle }, // TODO: implement once we support more complex types
quote { get_last_call_offchain_effects_oracle }, // TODO: implement once we support more complex types
quote { get_last_call_context }, // TODO: implement once we support more complex types
quote { get_private_events_oracle }, // TODO: implement once we support more complex types
quote { deploy_oracle }, // TODO: implement once we support more complex types
quote { create_account }, // TODO: implement once we support more complex types
quote { add_account }, // TODO: implement once we support more complex types
quote { private_call_new_flow_oracle }, // TODO: implement once we support more complex types
quote { public_call_new_flow_oracle }, // TODO: implement once we support more complex types
quote { set_private_txe_context_oracle }, // TODO: implement once we support more complex types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ unconstrained fn get_last_call_offchain_effects_oracle() -> ([[Field; MAX_OFFCHA

/// The context of the last top-level call into TXE, as captured by the call executor. Refreshed on
/// every top-level call.
#[derive(Eq)]
pub struct TXECallContext {
/// Tx hash of the top-level call, or `None` if the call was tx-less (`execute_utility`, context
/// setters, etc.).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ impl<let O: u32> ContractDeployment<O> {
}
}

#[derive(Deserialize, Serialize)]
#[derive(Deserialize, Eq, Serialize)]
pub struct TestAccount {
pub address: AztecAddress,
pub keys: PublicKeys,
Expand Down
1 change: 1 addition & 0 deletions yarn-project/pxe/src/contract_function_simulator/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export {
PENDING_TAGGED_LOG,
POINT,
PROVIDED_SECRET,
PUBLIC_KEYS,
SCALAR,
SLOT_NUMBER,
STR,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ export const KEY_VALIDATION_REQUEST: TypeMapping<KeyValidationRequest> = STRUCT<
{ name: 'skApp', type: FIELD },
]);

const PUBLIC_KEYS: TypeMapping<PublicKeys> = STRUCT<PublicKeys>([
export const PUBLIC_KEYS: TypeMapping<PublicKeys> = STRUCT([
{ name: 'npkMHash', type: FIELD },
{ name: 'ivpkM', type: POINT },
{ name: 'ovpkMHash', type: FIELD },
Expand Down
25 changes: 10 additions & 15 deletions yarn-project/txe/src/oracle/txe_oracle_registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ import {
type MaybePromise,
OPTION,
ORACLE_REGISTRY,
type Option,
type OracleRegistryEntry,
type OutputSlot,
PUBLIC_KEYS,
type ParamTypes,
SCALAR,
STR,
Expand Down Expand Up @@ -120,11 +122,10 @@ const PRIVATE_CONTEXT_INPUTS: TypeMapping<PrivateContextInputs> = LEAF({
shape: Array<SlotShape>(PRIVATE_CONTEXT_INPUTS_LENGTH).fill('scalar'),
});

const COMPLETE_ADDRESS: TypeMapping<CompleteAddress> = LEAF({
kind: 'complete-address',
serialization: { fn: v => [v.address.toField(), ...v.publicKeys.toFields()] },
shape: Array<SlotShape>(8).fill('scalar'), // address + 7 public-key fields
});
const COMPLETE_ADDRESS: TypeMapping<CompleteAddress> = STRUCT([
{ name: 'address', type: AZTEC_ADDRESS },
{ name: 'publicKeys', type: PUBLIC_KEYS },
]);

const TXE_TX_EFFECTS: TypeMapping<{
txHash: TxHash;
Expand Down Expand Up @@ -198,16 +199,10 @@ const TXE_OFFCHAIN_EFFECTS: TypeMapping<{ effects: Fr[][] }> = LEAF({
],
});

const TXE_CALL_CONTEXT: TypeMapping<{ txHash: Fr; anchorBlockTimestamp: bigint }> = LEAF({
kind: 'txe-call-context',
serialization: {
fn: ({ txHash, anchorBlockTimestamp }) => {
const isSome = txHash.isZero() ? 0 : 1;
return [new Fr(isSome), txHash, new Fr(anchorBlockTimestamp)];
},
},
shape: ['scalar', 'scalar', 'scalar'], // discriminant, txHash, anchor block timestamp
});
const TXE_CALL_CONTEXT: TypeMapping<{ txHash: Option<Fr>; anchorBlockTimestamp: bigint }> = STRUCT([
{ name: 'txHash', type: OPTION(FIELD) },
{ name: 'anchorBlockTimestamp', type: U64 },
]);

const CONTRACT_INSTANCE_MEMBER: TypeMapping<{ exists: boolean; member: Fr }[]> = FIXED_ARRAY(
STRUCT([
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/txe/src/oracle/txe_oracle_version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ export const TXE_ORACLE_VERSION_MINOR = 1;
* - TXE_ORACLE_VERSION_MAJOR (and reset MINOR to 0) for breaking changes, or
* - TXE_ORACLE_VERSION_MINOR for additive changes (new oracle method added).
*/
export const TXE_ORACLE_INTERFACE_HASH = '1a6c578d0a47cd8dd7dae07fd00abe781225a73920c596d873afcc061c0e4284';
export const TXE_ORACLE_INTERFACE_HASH = '86d900da6ca21d8dee76b790175aaaee9e865bf99950844e2dc727250fe14a40';

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oracles didn't change, so no need to bump versions

24 changes: 12 additions & 12 deletions yarn-project/txe/src/txe_session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,11 @@ export interface TXESessionStateHandler {
getLastCallOffchainEffects(): { effects: Fr[][] };

/**
* Returns the context of the last top-level call: its tx hash (`Fr.ZERO` if the call was tx-less) and the anchor
* Returns the context of the last top-level call: its tx hash (absent if the call was tx-less) and the anchor
* block timestamp captured at the start of the call. Does *not* mark the buffer as queried — context reads are
* metadata, not effect consumption.
*/
getLastCallContext(): { txHash: Fr; anchorBlockTimestamp: bigint };
getLastCallContext(): { txHash: Option<Fr>; anchorBlockTimestamp: bigint };
}

/**
Expand All @@ -218,10 +218,10 @@ interface LastCallState {
*/
queried: boolean;
/**
* Tx hash of the most recently completed top-level call, or `Fr.ZERO` if the call was tx-less (context setters,
* utility execution). Populated by call executor handlers after execution completes.
* Tx hash of the most recently completed top-level call, absent if the call was tx-less (context setters, utility
* execution). Populated by call executor handlers after execution completes.
*/
txHash: Fr;
txHash: Option<Fr>;
/**
* Anchor block timestamp of the most recently completed top-level call, captured from the anchor block header that
* was active when the call started. Populated by call executor handlers after execution completes.
Expand All @@ -230,7 +230,7 @@ interface LastCallState {
}

function emptyLastCallState(): LastCallState {
return { offchainEffects: [], queried: false, txHash: Fr.ZERO, anchorBlockTimestamp: 0n };
return { offchainEffects: [], queried: false, txHash: Option.none(), anchorBlockTimestamp: 0n };
}

/**
Expand Down Expand Up @@ -495,7 +495,7 @@ export class TXESession implements TXESessionStateHandler {
this.lastCallInfo.offchainEffects.push(data);
}

private setLastCallContext(txHash: Fr, anchorBlockTimestamp: bigint): void {
private setLastCallContext(txHash: Option<Fr>, anchorBlockTimestamp: bigint): void {
this.lastCallInfo.txHash = txHash;
this.lastCallInfo.anchorBlockTimestamp = anchorBlockTimestamp;
}
Expand All @@ -507,7 +507,7 @@ export class TXESession implements TXESessionStateHandler {
const anchorBlockTimestamp = (await this.stateMachine.node.getBlockData('latest'))!.header.globalVariables
.timestamp;
const { result, txHash } = await work();
this.setLastCallContext(txHash ?? Fr.ZERO, anchorBlockTimestamp);
this.setLastCallContext(txHash ? Option.some(txHash) : Option.none(), anchorBlockTimestamp);
return result;
}

Expand All @@ -525,7 +525,7 @@ export class TXESession implements TXESessionStateHandler {
return { effects };
}

getLastCallContext(): { txHash: Fr; anchorBlockTimestamp: bigint } {
getLastCallContext(): { txHash: Option<Fr>; anchorBlockTimestamp: bigint } {
const { txHash, anchorBlockTimestamp } = this.lastCallInfo;
return { txHash, anchorBlockTimestamp };
}
Expand Down Expand Up @@ -794,7 +794,7 @@ export class TXESession implements TXESessionStateHandler {

// Record the *resolved* anchor's timestamp — if the caller pinned the anchor to a past block
// via `anchorBlockNumber`, "latest" would be the wrong anchor for offchain-message semantics.
this.setLastCallContext(Fr.ZERO, anchorBlock!.globalVariables.timestamp);
this.setLastCallContext(Option.none(), anchorBlock!.globalVariables.timestamp);

return (this.oracleHandler as TXEPrivateExecutionOracle).getPrivateContextInputs();
}
Expand Down Expand Up @@ -826,7 +826,7 @@ export class TXESession implements TXESessionStateHandler {
this.logger.debug(`Entered state ${this.state.name}`);

// Public state is anchored at the latest block.
this.setLastCallContext(Fr.ZERO, latestHeader.globalVariables.timestamp);
this.setLastCallContext(Option.none(), latestHeader.globalVariables.timestamp);
}

async enterUtilityState(contractAddressOpt: Option<AztecAddress>) {
Expand Down Expand Up @@ -889,7 +889,7 @@ export class TXESession implements TXESessionStateHandler {
this.logger.debug(`Entered state ${this.state.name}`);

// Utility state anchors at whatever the anchor block store is pointing to (tracked as latest).
this.setLastCallContext(Fr.ZERO, anchorBlockHeader.globalVariables.timestamp);
this.setLastCallContext(Option.none(), anchorBlockHeader.globalVariables.timestamp);
}

private exitTopLevelState() {
Expand Down
Loading