Skip to content

Commit

Permalink
chore: nuked OptionallyRevealedData (#4456)
Browse files Browse the repository at this point in the history
Nuked deprecated `OptionallyRevealedData`.
  • Loading branch information
benesjan authored Feb 7, 2024
1 parent 0a8905a commit 83a3136
Show file tree
Hide file tree
Showing 15 changed files with 1,587 additions and 2,781 deletions.
1 change: 0 additions & 1 deletion l1-contracts/src/core/libraries/ConstantsGen.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ library Constants {
uint256 internal constant MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX = 16;
uint256 internal constant MAX_PUBLIC_DATA_READS_PER_TX = 16;
uint256 internal constant MAX_NEW_CONTRACTS_PER_TX = 1;
uint256 internal constant MAX_OPTIONALLY_REVEALED_DATA_LENGTH_PER_TX = 4;
uint256 internal constant MAX_READ_REQUESTS_PER_TX = 128;
uint256 internal constant MAX_NULLIFIER_KEY_VALIDATION_REQUESTS_PER_TX = 4;
uint256 internal constant NUM_ENCRYPTED_LOGS_HASHES_PER_TX = 1;
Expand Down
1 change: 0 additions & 1 deletion yarn-project/circuits.js/src/constants.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export const MAX_NEW_L2_TO_L1_MSGS_PER_TX = 2;
export const MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX = 16;
export const MAX_PUBLIC_DATA_READS_PER_TX = 16;
export const MAX_NEW_CONTRACTS_PER_TX = 1;
export const MAX_OPTIONALLY_REVEALED_DATA_LENGTH_PER_TX = 4;
export const MAX_READ_REQUESTS_PER_TX = 128;
export const MAX_NULLIFIER_KEY_VALIDATION_REQUESTS_PER_TX = 4;
export const NUM_ENCRYPTED_LOGS_HASHES_PER_TX = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
MAX_NEW_NULLIFIERS_PER_TX,
MAX_NEW_NULLIFIERS_PER_TX_META,
MAX_NULLIFIER_KEY_VALIDATION_REQUESTS_PER_TX,
MAX_OPTIONALLY_REVEALED_DATA_LENGTH_PER_TX,
MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX,
MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX,
MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX_META,
Expand All @@ -23,7 +22,6 @@ import {
NUM_FIELDS_PER_SHA256,
} from '../../constants.gen.js';
import { CallRequest } from '../call_request.js';
import { FunctionData } from '../function_data.js';
import { NullifierKeyValidationRequestContext } from '../nullifier_key_validation_request.js';
import { SideEffect, SideEffectLinkedToNoteHash } from '../side_effects.js';

Expand Down Expand Up @@ -67,105 +65,6 @@ export class NewContractData {
}
}

/**
* Info which a user might want to reveal to the world.
* Note: Currently not used (2023-05-12).
*/
export class OptionallyRevealedData {
/**
* Address of the portal contract corresponding to the L2 contract on which the function above was invoked.
*
* TODO(AD): refactor this later
* currently there is a kludge with circuits cpp as it emits an AztecAddress
*/
public portalContractAddress: EthAddress;
constructor(
/**
* Hash of the call stack item from which this info was originates.
*/
public callStackItemHash: Fr,
/**
* Function data of a function call from which this info originates.
*/
public functionData: FunctionData,
/**
* Verification key hash of the function call from which this info originates.
*/
public vkHash: Fr,
/**
* Address of the portal contract corresponding to the L2 contract on which the function above was invoked.
*
* TODO(AD): refactor this later
* currently there is a kludge with circuits cpp as it emits an AztecAddress
*/
portalContractAddress: EthAddress | AztecAddress,
/**
* Whether the fee was paid from the L1 account of the user.
*/
public payFeeFromL1: boolean,
/**
* Whether the fee was paid from a public account on L2.
*/
public payFeeFromPublicL2: boolean,
/**
* Whether the function call was invoked from L1.
*/
public calledFromL1: boolean,
/**
* Whether the function call was invoked from the public L2 account of the user.
*/
public calledFromPublicL2: boolean,
) {
// Handle circuits emitting this as an AztecAddress
this.portalContractAddress = EthAddress.fromField(portalContractAddress.toField());
}

toBuffer() {
return serializeToBuffer(
this.callStackItemHash,
this.functionData,
this.vkHash,
this.portalContractAddress,
this.payFeeFromL1,
this.payFeeFromPublicL2,
this.calledFromL1,
this.calledFromPublicL2,
);
}

/**
* Deserializes from a buffer or reader, corresponding to a write in cpp.
* @param buffer - Buffer or reader to read from.
* @returns The deserialized OptionallyRevealedData.
*/
static fromBuffer(buffer: Buffer | BufferReader): OptionallyRevealedData {
const reader = BufferReader.asReader(buffer);
return new OptionallyRevealedData(
Fr.fromBuffer(reader),
reader.readObject(FunctionData),
Fr.fromBuffer(reader),
reader.readObject(EthAddress),
reader.readBoolean(),
reader.readBoolean(),
reader.readBoolean(),
reader.readBoolean(),
);
}

static empty() {
return new OptionallyRevealedData(
Fr.ZERO,
FunctionData.empty(),
Fr.ZERO,
EthAddress.ZERO,
false,
false,
false,
false,
);
}
}

/**
* Read operations from the public state tree.
*/
Expand Down Expand Up @@ -332,10 +231,6 @@ export class CombinedAccumulatedData {
* All the new contracts deployed in this transaction.
*/
public newContracts: Tuple<NewContractData, typeof MAX_NEW_CONTRACTS_PER_TX>,
/**
* All the optionally revealed data in this transaction.
*/
public optionallyRevealedData: Tuple<OptionallyRevealedData, typeof MAX_OPTIONALLY_REVEALED_DATA_LENGTH_PER_TX>,
/**
* All the public data update requests made in this transaction.
*/
Expand All @@ -360,7 +255,6 @@ export class CombinedAccumulatedData {
this.encryptedLogPreimagesLength,
this.unencryptedLogPreimagesLength,
this.newContracts,
this.optionallyRevealedData,
this.publicDataUpdateRequests,
this.publicDataReads,
);
Expand Down Expand Up @@ -390,7 +284,6 @@ export class CombinedAccumulatedData {
Fr.fromBuffer(reader),
Fr.fromBuffer(reader),
reader.readArray(MAX_NEW_CONTRACTS_PER_TX, NewContractData),
reader.readArray(MAX_OPTIONALLY_REVEALED_DATA_LENGTH_PER_TX, OptionallyRevealedData),
reader.readArray(MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, PublicDataUpdateRequest),
reader.readArray(MAX_PUBLIC_DATA_READS_PER_TX, PublicDataRead),
);
Expand All @@ -410,7 +303,6 @@ export class CombinedAccumulatedData {
finalData.encryptedLogPreimagesLength,
finalData.unencryptedLogPreimagesLength,
finalData.newContracts,
finalData.optionallyRevealedData,
makeTuple(MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, PublicDataUpdateRequest.empty),
makeTuple(MAX_PUBLIC_DATA_READS_PER_TX, PublicDataRead.empty),
);
Expand Down Expand Up @@ -439,7 +331,6 @@ export class CombinedAccumulatedData {
Fr.zero(),
Fr.zero(),
makeTuple(MAX_NEW_CONTRACTS_PER_TX, NewContractData.empty),
makeTuple(MAX_OPTIONALLY_REVEALED_DATA_LENGTH_PER_TX, OptionallyRevealedData.empty),
makeTuple(MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, PublicDataUpdateRequest.empty),
makeTuple(MAX_PUBLIC_DATA_READS_PER_TX, PublicDataRead.empty),
);
Expand Down Expand Up @@ -495,10 +386,6 @@ export class FinalAccumulatedData {
* All the new contracts deployed in this transaction.
*/
public newContracts: Tuple<NewContractData, typeof MAX_NEW_CONTRACTS_PER_TX>,
/**
* All the optionally revealed data in this transaction.
*/
public optionallyRevealedData: Tuple<OptionallyRevealedData, typeof MAX_OPTIONALLY_REVEALED_DATA_LENGTH_PER_TX>,
) {}

toBuffer() {
Expand All @@ -513,7 +400,6 @@ export class FinalAccumulatedData {
this.encryptedLogPreimagesLength,
this.unencryptedLogPreimagesLength,
this.newContracts,
this.optionallyRevealedData,
);
}

Expand All @@ -539,7 +425,6 @@ export class FinalAccumulatedData {
Fr.fromBuffer(reader),
Fr.fromBuffer(reader),
reader.readArray(MAX_NEW_CONTRACTS_PER_TX, NewContractData),
reader.readArray(MAX_OPTIONALLY_REVEALED_DATA_LENGTH_PER_TX, OptionallyRevealedData),
);
}

Expand All @@ -564,7 +449,6 @@ export class FinalAccumulatedData {
Fr.zero(),
Fr.zero(),
makeTuple(MAX_NEW_CONTRACTS_PER_TX, NewContractData.empty),
makeTuple(MAX_OPTIONALLY_REVEALED_DATA_LENGTH_PER_TX, OptionallyRevealedData.empty),
);
}
}
Expand Down
22 changes: 0 additions & 22 deletions yarn-project/circuits.js/src/tests/factories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ import {
MAX_NEW_NULLIFIERS_PER_TX_META,
MAX_NULLIFIER_KEY_VALIDATION_REQUESTS_PER_CALL,
MAX_NULLIFIER_KEY_VALIDATION_REQUESTS_PER_TX,
MAX_OPTIONALLY_REVEALED_DATA_LENGTH_PER_TX,
MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL,
MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX,
MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL,
Expand All @@ -71,7 +70,6 @@ import {
NullifierKeyValidationRequest,
NullifierKeyValidationRequestContext,
NullifierLeafPreimage,
OptionallyRevealedData,
PUBLIC_DATA_SUBTREE_SIBLING_PATH_LENGTH,
PUBLIC_DATA_TREE_HEIGHT,
PartialStateReference,
Expand Down Expand Up @@ -262,7 +260,6 @@ export function makeAccumulatedData(seed = 1, full = false): CombinedAccumulated
fr(seed + 0x900), // encrypted_log_preimages_length
fr(seed + 0xa00), // unencrypted_log_preimages_length
tupleGenerator(MAX_NEW_CONTRACTS_PER_TX, makeNewContractData, seed + 0xb00),
tupleGenerator(MAX_OPTIONALLY_REVEALED_DATA_LENGTH_PER_TX, makeOptionallyRevealedData, seed + 0xc00),
tupleGenerator(MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, makePublicDataUpdateRequest, seed + 0xd00),
tupleGenerator(MAX_PUBLIC_DATA_READS_PER_TX, makePublicDataRead, seed + 0xe00),
);
Expand All @@ -287,7 +284,6 @@ export function makeFinalAccumulatedData(seed = 1, full = false): FinalAccumulat
fr(seed + 0x900), // encrypted_log_preimages_length
fr(seed + 0xa00), // unencrypted_log_preimages_length
tupleGenerator(MAX_NEW_CONTRACTS_PER_TX, makeNewContractData, seed + 0xb00),
tupleGenerator(MAX_OPTIONALLY_REVEALED_DATA_LENGTH_PER_TX, makeOptionallyRevealedData, seed + 0xc00),
);
}

Expand Down Expand Up @@ -315,24 +311,6 @@ export function makeNewContractData(seed = 1): NewContractData {
return new NewContractData(makeAztecAddress(seed), makeEthAddress(seed + 1), fr(seed + 2));
}

/**
* Creates arbitrary optionally revealed data.
* @param seed - The seed to use for generating the optionally revealed data.
* @returns An optionally revealed data.
*/
export function makeOptionallyRevealedData(seed = 1): OptionallyRevealedData {
return new OptionallyRevealedData(
fr(seed),
new FunctionData(makeSelector(seed + 1), false, true, true),
fr(seed + 2),
makeEthAddress(seed + 3),
true,
false,
true,
false,
);
}

/**
* Creates arbitrary aggregation object.
* @param seed - The seed to use for generating the aggregation object.
Expand Down
Loading

0 comments on commit 83a3136

Please sign in to comment.