@aztec/protocol-contracts 5.0.0-rc.1 → 5.0.0-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17,4 +17,4 @@ export declare class ContractClassPublishedEvent {
17
17
  toContractClassPublicWithBytecodeCommitment(): Promise<ContractClassPublicWithCommitment>;
18
18
  static extractContractClassEvents(logs: ContractClassLog[]): ContractClassPublishedEvent[];
19
19
  }
20
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29udHJhY3RfY2xhc3NfcHVibGlzaGVkX2V2ZW50LmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvY2xhc3MtcmVnaXN0cnkvY29udHJhY3RfY2xhc3NfcHVibGlzaGVkX2V2ZW50LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLE9BQU8sRUFBRSxFQUFFLEVBQUUsTUFBTSxnQ0FBZ0MsQ0FBQztBQUdwRCxPQUFPLEVBQ0wsS0FBSyxtQkFBbUIsRUFDeEIsS0FBSyxpQ0FBaUMsRUFFdkMsTUFBTSx3QkFBd0IsQ0FBQztBQUNoQyxPQUFPLEtBQUssRUFBRSxnQkFBZ0IsRUFBRSxNQUFNLG9CQUFvQixDQUFDO0FBSTNELG9EQUFvRDtBQUNwRCxxQkFBYSwyQkFBMkI7YUFFcEIsZUFBZSxFQUFFLEVBQUU7YUFDbkIsT0FBTyxFQUFFLE1BQU07YUFDZixZQUFZLEVBQUUsRUFBRTthQUNoQixvQkFBb0IsRUFBRSxFQUFFO2FBQ3hCLG9CQUFvQixFQUFFLE1BQU07SUFMOUMsWUFDa0IsZUFBZSxFQUFFLEVBQUUsRUFDbkIsT0FBTyxFQUFFLE1BQU0sRUFDZixZQUFZLEVBQUUsRUFBRSxFQUNoQixvQkFBb0IsRUFBRSxFQUFFLEVBQ3hCLG9CQUFvQixFQUFFLE1BQU0s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SxFQUFFLEVBQUUsRUFDbkIsT0FBTyxFQUFFLE1BQU0sRUFDZixZQUFZLEVBQUUsRUFBRSxFQUNoQixvQkFBb0IsRUFBRSxFQUFFLEVBQ3hCLG9CQUFvQixFQUFFLE1BQU0sRUFDMUM7SUFFSixNQUFNLENBQUMsNkJBQTZCLENBQUMsR0FBRyxFQUFFLGdCQUFnQixXQUt6RDtJQUVELE1BQU0sQ0FBQyxPQUFPLENBQUMsR0FBRyxFQUFFLGdCQUFnQiwrQkFzQm5DO0lBRUQsdUdBQXVHO0lBQ3ZHLHFCQUFxQixJQUFJLG1CQUFtQixDQVEzQztJQUVELHVGQUF1RjtJQUNqRiwyQ0FBMkMsSUFBSSxPQUFPLENBQUMsaUNBQWlDLENBQUMsQ0FHOUY7SUFFRCxPQUFjLDBCQUEwQixDQUFDLElBQUksRUFBRSxnQkFBZ0IsRUFBRSxHQUFHLDJCQUEyQixFQUFFLENBSWhHO0NBQ0YifQ==
@@ -1 +1 @@
1
- {"version":3,"file":"contract_class_published_event.d.ts","sourceRoot":"","sources":["../../src/class-registry/contract_class_published_event.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AAGpD,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,iCAAiC,EAEvC,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAI3D,oDAAoD;AACpD,qBAAa,2BAA2B;aAEpB,eAAe,EAAE,EAAE;aACnB,OAAO,EAAE,MAAM;aACf,YAAY,EAAE,EAAE;aAChB,oBAAoB,EAAE,EAAE;aACxB,oBAAoB,EAAE,MAAM;IAL9C,YACkB,eAAe,EAAE,EAAE,EACnB,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,EAAE,EAChB,oBAAoB,EAAE,EAAE,EACxB,oBAAoB,EAAE,MAAM,EAC1C;IAEJ,MAAM,CAAC,6BAA6B,CAAC,GAAG,EAAE,gBAAgB,WAKzD;IAED,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,gBAAgB,+BAiBnC;IAED,uGAAuG;IACvG,qBAAqB,IAAI,mBAAmB,CAQ3C;IAED,uFAAuF;IACjF,2CAA2C,IAAI,OAAO,CAAC,iCAAiC,CAAC,CAG9F;IAED,OAAc,0BAA0B,CAAC,IAAI,EAAE,gBAAgB,EAAE,GAAG,2BAA2B,EAAE,CAIhG;CACF"}
1
+ {"version":3,"file":"contract_class_published_event.d.ts","sourceRoot":"","sources":["../../src/class-registry/contract_class_published_event.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AAGpD,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,iCAAiC,EAEvC,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAI3D,oDAAoD;AACpD,qBAAa,2BAA2B;aAEpB,eAAe,EAAE,EAAE;aACnB,OAAO,EAAE,MAAM;aACf,YAAY,EAAE,EAAE;aAChB,oBAAoB,EAAE,EAAE;aACxB,oBAAoB,EAAE,MAAM;IAL9C,YACkB,eAAe,EAAE,EAAE,EACnB,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,EAAE,EAChB,oBAAoB,EAAE,EAAE,EACxB,oBAAoB,EAAE,MAAM,EAC1C;IAEJ,MAAM,CAAC,6BAA6B,CAAC,GAAG,EAAE,gBAAgB,WAKzD;IAED,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,gBAAgB,+BAsBnC;IAED,uGAAuG;IACvG,qBAAqB,IAAI,mBAAmB,CAQ3C;IAED,uFAAuF;IACjF,2CAA2C,IAAI,OAAO,CAAC,iCAAiC,CAAC,CAG9F;IAED,OAAc,0BAA0B,CAAC,IAAI,EAAE,gBAAgB,EAAE,GAAG,2BAA2B,EAAE,CAIhG;CACF"}
@@ -1,4 +1,5 @@
1
1
  import { CONTRACT_CLASS_PUBLISHED_MAGIC_VALUE } from '@aztec/constants';
2
+ import { Fr } from '@aztec/foundation/curves/bn254';
2
3
  import { FieldReader } from '@aztec/foundation/serialize';
3
4
  import { bufferFromFields } from '@aztec/stdlib/abi';
4
5
  import { computePublicBytecodeCommitment } from '@aztec/stdlib/contract';
@@ -27,7 +28,12 @@ import { ProtocolContractAddress } from '../protocol_contract_data.js';
27
28
  const version = reader.readField().toNumber();
28
29
  const artifactHash = reader.readField();
29
30
  const privateFunctionsRoot = reader.readField();
30
- const packedPublicBytecode = bufferFromFields(reader.readFieldArray(fieldsWithoutTag.length - reader.cursor));
31
+ const bytecodeFields = reader.readFieldArray(fieldsWithoutTag.length - reader.cursor);
32
+ // The fixed-size class log can hold at most this many packed-bytecode bytes (every payload field
33
+ // carries 31 bytes). Bound the declared length to it so a malformed log can't declare a multi-MiB
34
+ // length backed by a tiny payload and force a large allocation during early (pre-proof) validation.
35
+ const maxByteLength = (bytecodeFields.length - 1) * (Fr.SIZE_IN_BYTES - 1);
36
+ const packedPublicBytecode = bufferFromFields(bytecodeFields, maxByteLength);
31
37
  return new ContractClassPublishedEvent(contractClassId, version, artifactHash, privateFunctionsRoot, packedPublicBytecode);
32
38
  }
33
39
  /** Converts the event to a contract class, without computing or validating the bytecode commitment. */ toContractClassPublic() {
@@ -1,3 +1,4 @@
1
+ import type { Fr } from '@aztec/foundation/curves/bn254';
1
2
  import type { ContractArtifact } from '@aztec/stdlib/abi';
2
3
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
3
4
  import type { ContractClassIdPreimage, ContractClassWithId, ContractInstanceWithAddress } from '@aztec/stdlib/contract';
@@ -13,5 +14,7 @@ export interface ProtocolContract {
13
14
  address: AztecAddress;
14
15
  }
15
16
  export declare function isProtocolContract(address: AztecAddress): boolean;
17
+ /** Returns whether the given contract class id belongs to a bundled protocol contract. */
18
+ export declare function isProtocolContractClass(classId: Fr): boolean;
16
19
  export { type ProtocolContractsProvider } from './provider/protocol_contracts_provider.js';
17
- //# sour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AAM,WAAW,gBAAgB;IAC/B,mCAAmC;IACnC,QAAQ,EAAE,2BAA2B,CAAC;IACtC,uCAAuC;IACvC,aAAa,EAAE,mBAAmB,GAAG,uBAAuB,CAAC;IAC7D,kCAAkC;IAClC,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,sDAAsD;IACtD,OAAO,EAAE,YAAY,CAAC;CACvB;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,YAAY,WAEvD;AAED,OAAO,EAAE,KAAK,yBAAyB,EAAE,MAAM,2CAA2C,CAAC"}
1
+ {"version":3,"file":"protocol_contract.d.ts","sourceRoot":"","sources":["../src/protocol_contract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAIxH,uDAAuD;AACvD,MAAM,WAAW,gBAAgB;IAC/B,mCAAmC;IACnC,QAAQ,EAAE,2BAA2B,CAAC;IACtC,uCAAuC;IACvC,aAAa,EAAE,mBAAmB,GAAG,uBAAuB,CAAC;IAC7D,kCAAkC;IAClC,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,sDAAsD;IACtD,OAAO,EAAE,YAAY,CAAC;CACvB;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,YAAY,WAEvD;AAID,0FAA0F;AAC1F,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,EAAE,GAAG,OAAO,CAE5D;AAED,OAAO,EAAE,KAAK,yBAAyB,EAAE,MAAM,2CAA2C,CAAC"}
@@ -1,4 +1,8 @@
1
- import { ProtocolContractAddress } from './protocol_contract_data.js';
1
+ import { ProtocolContractAddress, ProtocolContractClassId } from './protocol_contract_data.js';
2
2
  export function isProtocolContract(address) {
3
3
  return Object.values(ProtocolContractAddress).some((a)=>a.equals(address));
4
4
  }
5
+ const protocolContractClassIds = new Set(Object.values(ProtocolContractClassId).map((id)=>id.toString()));
6
+ /** Returns whether the given contract class id belongs to a bundled protocol contract. */ export function isProtocolContractClass(classId) {
7
+ return protocolContractClassIds.has(classId.toString());
8
+ }
@@ -14,33 +14,33 @@ export const ProtocolContractSalt = {
14
14
  FeeJuice: new Fr(1)
15
15
  };
16
16
  export const ProtocolContractAddress = {
17
- ContractInstanceRegistry: AztecAddress.fromBigInt(2n),
18
- ContractClassRegistry: AztecAddress.fromBigInt(1n),
19
- FeeJuice: AztecAddress.fromBigInt(3n)
17
+ ContractInstanceRegistry: AztecAddress.fromBigIntUnsafe(2n),
18
+ ContractClassRegistry: AztecAddress.fromBigIntUnsafe(1n),
19
+ FeeJuice: AztecAddress.fromBigIntUnsafe(3n)
20
20
  };
21
21
  export const ProtocolContractDerivedAddress = {
22
- ContractInstanceRegistry: AztecAddress.fromString('0x00c8e0704ca0306dafc52ddd979ea49eca512ca4d074c5ed821a2db832ef633a'),
23
- ContractClassRegistry: AztecAddress.fromString('0x2047b7aba49ac0459ab5d75fde32bcd364e4f984f482c1ae6002cd299031bcde'),
24
- FeeJuice: AztecAddress.fromString('0x06f0f6b0d7a8835ae0d71513a6e18e0484132ab20d153af64e89b1933f68287a')
22
+ ContractInstanceRegistry: AztecAddress.fromStringUnsafe('0x06400117b682ea82bad313957460725049b29c05082fc954983c72d6500866de'),
23
+ ContractClassRegistry: AztecAddress.fromStringUnsafe('0x07172e8dd677966edbe706407e35b6897662846df1894661c8902efa56c22778'),
24
+ FeeJuice: AztecAddress.fromStringUnsafe('0x1b83996ec00ec66dce369f748e422e14abbe4e0dcd485ce82aef6e19323b4c11')
25
25
  };
26
26
  export const ProtocolContractClassId = {
27
- ContractInstanceRegistry: Fr.fromString('0x13ff35e81c6ef0457eae18472548aff892898dc9dcd476b529232a7ac6fd0441'),
28
- ContractClassRegistry: Fr.fromString('0x28308dcf38647b560a5bfc75a42fc11ac99f4f61bb3c20a942326354cfb83476'),
29
- FeeJuice: Fr.fromString('0x0bb3010637f6c717b41858a4ac705057b94f41cd75bba4201329728995805fc8')
27
+ ContractInstanceRegistry: Fr.fromString('0x2f180ecabe86459dc712b3a69a115819bdc13699cdee1fbe6eb84be5f2efdcc6'),
28
+ ContractClassRegistry: Fr.fromString('0x05968d8add5742552b128d956d82fa3ecdb46cd0893116a18c569fefd11054f1'),
29
+ FeeJuice: Fr.fromString('0x0656c2f1693bb3233d86084a0ab458ed136fdc0e66ead9679f198a251bfa6e4b')
30
30
  };
31
31
  export const ProtocolContractClassIdPreimage = {
32
32
  ContractInstanceRegistry: {
33
- artifactHash: Fr.fromString('0x1720e3349b4f0f75e242bc79d6cc01ebd90437242f221d7ddbdcd784c1adf9fc'),
33
+ artifactHash: Fr.fromString('0x14ca3d252eed7fe35d495760dbea6eb0f44b9dc586a8dbed9990a96b254a4b58'),
34
34
  privateFunctionsRoot: Fr.fromString('0x0239b0f293384aad456e2e27901eb97cd9073322a28d14b0ac7816a5297b2812'),
35
35
  publicBytecodeCommitment: Fr.fromString('0x2c79b6699098244e947caca071a31799c20aa20e7124910a2b7c918fe817d65e')
36
36
  },
37
37
  ContractClassRegistry: {
38
- artifactHash: Fr.fromString('0x0dea13afa62a71c9ee97a247aea53a64c9d05bcc48d5a56fd73c4891a46f7292'),
38
+ artifactHash: Fr.fromString('0x25af8a0fba5e72be31e2c7f0d72c78b1ae0efb07eba675c641d8dab2a555b77a'),
39
39
  privateFunctionsRoot: Fr.fromString('0x0672f623ec0753ab9fbb02a9a241df81b9bcc0dbed8628d8cab8790e0cb0c03d'),
40
40
  publicBytecodeCommitment: Fr.fromString('0x0ce4c618c3ed7f3a20410e618c06bb701e150af7fe28a3e92f68e7733809f33e')
41
41
  },
42
42
  FeeJuice: {
43
- artifactHash: Fr.fromString('0x184aee92af93d7338cda3b76e9d441559cd15560f517a1a01df541d13a6578de'),
43
+ artifactHash: Fr.fromString('0x1df228ba4645988ae80cf09734c9c05bb572809026914611bc6b66c39cce6081'),
44
44
  privateFunctionsRoot: Fr.fromString('0x247aaafc67f6bf5b06736649181a477dac9f18d3468969b14669708c3dabb275'),
45
45
  publicBytecodeCommitment: Fr.fromString('0x1d4b1a8f71b8250d4fb65f8e16a4604e9165648279f47d80e024ce2684c4bdfb')
46
46
  }
@@ -75,17 +75,17 @@ export const ProtocolContractPrivateFunctions = {
75
75
  ]
76
76
  };
77
77
  export const ProtocolContractsList = new ProtocolContracts([
78
- AztecAddress.fromString('0x2047b7aba49ac0459ab5d75fde32bcd364e4f984f482c1ae6002cd299031bcde'),
79
- AztecAddress.fromString('0x00c8e0704ca0306dafc52ddd979ea49eca512ca4d074c5ed821a2db832ef633a'),
80
- AztecAddress.fromString('0x06f0f6b0d7a8835ae0d71513a6e18e0484132ab20d153af64e89b1933f68287a'),
81
- AztecAddress.fromString('0x0000000000000000000000000000000000000000000000000000000000000000'),
82
- AztecAddress.fromString('0x0000000000000000000000000000000000000000000000000000000000000000'),
83
- AztecAddress.fromString('0x0000000000000000000000000000000000000000000000000000000000000000'),
84
- AztecAddress.fromString('0x0000000000000000000000000000000000000000000000000000000000000000'),
85
- AztecAddress.fromString('0x0000000000000000000000000000000000000000000000000000000000000000'),
86
- AztecAddress.fromString('0x0000000000000000000000000000000000000000000000000000000000000000'),
87
- AztecAddress.fromString('0x0000000000000000000000000000000000000000000000000000000000000000'),
88
- AztecAddress.fromString('0x0000000000000000000000000000000000000000000000000000000000000000')
78
+ AztecAddress.fromStringUnsafe('0x07172e8dd677966edbe706407e35b6897662846df1894661c8902efa56c22778'),
79
+ AztecAddress.fromStringUnsafe('0x06400117b682ea82bad313957460725049b29c05082fc954983c72d6500866de'),
80
+ AztecAddress.fromStringUnsafe('0x1b83996ec00ec66dce369f748e422e14abbe4e0dcd485ce82aef6e19323b4c11'),
81
+ AztecAddress.fromStringUnsafe('0x0000000000000000000000000000000000000000000000000000000000000000'),
82
+ AztecAddress.fromStringUnsafe('0x0000000000000000000000000000000000000000000000000000000000000000'),
83
+ AztecAddress.fromStringUnsafe('0x0000000000000000000000000000000000000000000000000000000000000000'),
84
+ AztecAddress.fromStringUnsafe('0x0000000000000000000000000000000000000000000000000000000000000000'),
85
+ AztecAddress.fromStringUnsafe('0x0000000000000000000000000000000000000000000000000000000000000000'),
86
+ AztecAddress.fromStringUnsafe('0x0000000000000000000000000000000000000000000000000000000000000000'),
87
+ AztecAddress.fromStringUnsafe('0x0000000000000000000000000000000000000000000000000000000000000000'),
88
+ AztecAddress.fromStringUnsafe('0x0000000000000000000000000000000000000000000000000000000000000000')
89
89
  ]);
90
- export const protocolContractsHash = Fr.fromString('0x016d8ee101b952bcb395235a0ab89707008374dda24f70c1f3911f1b0539d6c4');
90
+ export const protocolContractsHash = Fr.fromString('0x0a1f22b72996215e178699fff463a6ca5e3c7d5ffe66e183490eb766ec1c83ae');
91
91
  export const CONTRACT_INSTANCE_PUBLISHED_EVENT_TAG = Fr.fromHexString('0x1a7e1badb79abdd38c684b3c8306ffe7ecb33c69e3380d9855730aaaa83a21a8');
@@ -105,7 +105,7 @@ function generateSalts(names) {
105
105
  `;
106
106
  }
107
107
  function generateContractAddresses(names) {
108
- const addresses = names.map((name)=>`${name}: AztecAddress.fromBigInt(${contractAddressMapping[name]}n)`).join(',\n');
108
+ const addresses = names.map((name)=>`${name}: AztecAddress.fromBigIntUnsafe(${contractAddressMapping[name]}n)`).join(',\n');
109
109
  return `
110
110
  export const ProtocolContractAddress: Record<ProtocolContractName, AztecAddress> = {
111
111
  ${addresses}
@@ -115,7 +115,7 @@ function generateContractAddresses(names) {
115
115
  function generateDerivedAddresses(names, contractData) {
116
116
  return `
117
117
  export const ProtocolContractDerivedAddress = {
118
- ${contractData.map((d, i)=>`${names[i]}: AztecAddress.fromString('${d.address.toString()}')`).join(',\n')}
118
+ ${contractData.map((d, i)=>`${names[i]}: AztecAddress.fromStringUnsafe('${d.address.toString()}')`).join(',\n')}
119
119
  };
120
120
  `;
121
121
  }
@@ -155,7 +155,7 @@ async function generateProtocolContractsList(names, contractData) {
155
155
  }
156
156
  return `
157
157
  export const ProtocolContractsList = new ProtocolContracts([
158
- ${list.map((address)=>`AztecAddress.fromString('${address.toString()}')`).join(',\n')}
158
+ ${list.map((address)=>`AztecAddress.fromStringUnsafe('${address.toString()}')`).join(',\n')}
159
159
  ]);
160
160
 
161
161
  export const protocolContractsHash = Fr.fromString('${(await new ProtocolContracts(list).hash()).toString()}');
@@ -201,7 +201,7 @@ async function main() {
201
201
  const destName = destNames[i];
202
202
  const artifact = await copyArtifact(srcName, destName);
203
203
  await generateDeclarationFile(destName);
204
- contractDataList.push(await computeContractData(artifact, AztecAddress.fromBigInt(BigInt(contractAddressMapping[destName]))));
204
+ contractDataList.push(await computeContractData(artifact, AztecAddress.fromBigIntUnsafe(BigInt(contractAddressMapping[destName]))));
205
205
  }
206
206
  await generateOutputFile(destNames, contractDataList);
207
207
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@aztec/protocol-contracts",
3
3
  "homepage": "https://github.com/AztecProtocol/aztec-packages/tree/master/yarn-project/protocol-contracts",
4
4
  "description": "Canonical Noir contracts for the Aztec Network",
5
- "version": "5.0.0-rc.1",
5
+ "version": "5.0.0-rc.2",
6
6
  "type": "module",
7
7
  "exports": {
8
8
  ".": "./dest/index.js",
@@ -73,9 +73,9 @@
73
73
  ]
74
74
  },
75
75
  "dependencies": {
76
- "@aztec/constants": "5.0.0-rc.1",
77
- "@aztec/foundation": "5.0.0-rc.1",
78
- "@aztec/stdlib": "5.0.0-rc.1",
76
+ "@aztec/constants": "5.0.0-rc.2",
77
+ "@aztec/foundation": "5.0.0-rc.2",
78
+ "@aztec/stdlib": "5.0.0-rc.2",
79
79
  "lodash.chunk": "^4.2.0",
80
80
  "lodash.omit": "^4.5.0",
81
81
  "tslib": "^2.4.0"
@@ -36,7 +36,12 @@ export class ContractClassPublishedEvent {
36
36
  const version = reader.readField().toNumber();
37
37
  const artifactHash = reader.readField();
38
38
  const privateFunctionsRoot = reader.readField();
39
- const packedPublicBytecode = bufferFromFields(reader.readFieldArray(fieldsWithoutTag.length - reader.cursor));
39
+ const bytecodeFields = reader.readFieldArray(fieldsWithoutTag.length - reader.cursor);
40
+ // The fixed-size class log can hold at most this many packed-bytecode bytes (every payload field
41
+ // carries 31 bytes). Bound the declared length to it so a malformed log can't declare a multi-MiB
42
+ // length backed by a tiny payload and force a large allocation during early (pre-proof) validation.
43
+ const maxByteLength = (bytecodeFields.length - 1) * (Fr.SIZE_IN_BYTES - 1);
44
+ const packedPublicBytecode = bufferFromFields(bytecodeFields, maxByteLength);
40
45
 
41
46
  return new ContractClassPublishedEvent(
42
47
  contractClassId,
@@ -1,8 +1,9 @@
1
+ import type { Fr } from '@aztec/foundation/curves/bn254';
1
2
  import type { ContractArtifact } from '@aztec/stdlib/abi';
2
3
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
3
4
  import type { ContractClassIdPreimage, ContractClassWithId, ContractInstanceWithAddress } from '@aztec/stdlib/contract';
4
5
 
5
- import { ProtocolContractAddress } from './protocol_contract_data.js';
6
+ import { ProtocolContractAddress, ProtocolContractClassId } from './protocol_contract_data.js';
6
7
 
7
8
  /** Represents a canonical contract in the protocol. */
8
9
  export interface ProtocolContract {
@@ -20,4 +21,11 @@ export function isProtocolContract(address: AztecAddress) {
20
21
  return Object.values(ProtocolContractAddress).some(a => a.equals(address));
21
22
  }
22
23
 
24
+ const protocolContractClassIds = new Set(Object.values(ProtocolContractClassId).map(id => id.toString()));
25
+
26
+ /** Returns whether the given contract class id belongs to a bundled protocol contract. */
27
+ export function isProtocolContractClass(classId: Fr): boolean {
28
+ return protocolContractClassIds.has(classId.toString());
29
+ }
30
+
23
31
  export { type ProtocolContractsProvider } from './provider/protocol_contracts_provider.js';
@@ -25,40 +25,40 @@ FeeJuice: new Fr(1)
25
25
 
26
26
 
27
27
  export const ProtocolContractAddress: Record<ProtocolContractName, AztecAddress> = {
28
- ContractInstanceRegistry: AztecAddress.fromBigInt(2n),
29
- ContractClassRegistry: AztecAddress.fromBigInt(1n),
30
- FeeJuice: AztecAddress.fromBigInt(3n)
28
+ ContractInstanceRegistry: AztecAddress.fromBigIntUnsafe(2n),
29
+ ContractClassRegistry: AztecAddress.fromBigIntUnsafe(1n),
30
+ FeeJuice: AztecAddress.fromBigIntUnsafe(3n)
31
31
  };
32
32
 
33
33
 
34
34
 
35
35
  export const ProtocolContractDerivedAddress = {
36
- ContractInstanceRegistry: AztecAddress.fromString('0x00c8e0704ca0306dafc52ddd979ea49eca512ca4d074c5ed821a2db832ef633a'),
37
- ContractClassRegistry: AztecAddress.fromString('0x2047b7aba49ac0459ab5d75fde32bcd364e4f984f482c1ae6002cd299031bcde'),
38
- FeeJuice: AztecAddress.fromString('0x06f0f6b0d7a8835ae0d71513a6e18e0484132ab20d153af64e89b1933f68287a')
36
+ ContractInstanceRegistry: AztecAddress.fromStringUnsafe('0x06400117b682ea82bad313957460725049b29c05082fc954983c72d6500866de'),
37
+ ContractClassRegistry: AztecAddress.fromStringUnsafe('0x07172e8dd677966edbe706407e35b6897662846df1894661c8902efa56c22778'),
38
+ FeeJuice: AztecAddress.fromStringUnsafe('0x1b83996ec00ec66dce369f748e422e14abbe4e0dcd485ce82aef6e19323b4c11')
39
39
  };
40
40
 
41
41
 
42
42
 
43
43
  export const ProtocolContractClassId: Record<ProtocolContractName, Fr> = {
44
- ContractInstanceRegistry: Fr.fromString('0x13ff35e81c6ef0457eae18472548aff892898dc9dcd476b529232a7ac6fd0441'),
45
- ContractClassRegistry: Fr.fromString('0x28308dcf38647b560a5bfc75a42fc11ac99f4f61bb3c20a942326354cfb83476'),
46
- FeeJuice: Fr.fromString('0x0bb3010637f6c717b41858a4ac705057b94f41cd75bba4201329728995805fc8')
44
+ ContractInstanceRegistry: Fr.fromString('0x2f180ecabe86459dc712b3a69a115819bdc13699cdee1fbe6eb84be5f2efdcc6'),
45
+ ContractClassRegistry: Fr.fromString('0x05968d8add5742552b128d956d82fa3ecdb46cd0893116a18c569fefd11054f1'),
46
+ FeeJuice: Fr.fromString('0x0656c2f1693bb3233d86084a0ab458ed136fdc0e66ead9679f198a251bfa6e4b')
47
47
  };
48
48
 
49
49
  export const ProtocolContractClassIdPreimage: Record<ProtocolContractName, { artifactHash: Fr; privateFunctionsRoot: Fr; publicBytecodeCommitment: Fr }> = {
50
50
  ContractInstanceRegistry: {
51
- artifactHash: Fr.fromString('0x1720e3349b4f0f75e242bc79d6cc01ebd90437242f221d7ddbdcd784c1adf9fc'),
51
+ artifactHash: Fr.fromString('0x14ca3d252eed7fe35d495760dbea6eb0f44b9dc586a8dbed9990a96b254a4b58'),
52
52
  privateFunctionsRoot: Fr.fromString('0x0239b0f293384aad456e2e27901eb97cd9073322a28d14b0ac7816a5297b2812'),
53
53
  publicBytecodeCommitment: Fr.fromString('0x2c79b6699098244e947caca071a31799c20aa20e7124910a2b7c918fe817d65e'),
54
54
  },
55
55
  ContractClassRegistry: {
56
- artifactHash: Fr.fromString('0x0dea13afa62a71c9ee97a247aea53a64c9d05bcc48d5a56fd73c4891a46f7292'),
56
+ artifactHash: Fr.fromString('0x25af8a0fba5e72be31e2c7f0d72c78b1ae0efb07eba675c641d8dab2a555b77a'),
57
57
  privateFunctionsRoot: Fr.fromString('0x0672f623ec0753ab9fbb02a9a241df81b9bcc0dbed8628d8cab8790e0cb0c03d'),
58
58
  publicBytecodeCommitment: Fr.fromString('0x0ce4c618c3ed7f3a20410e618c06bb701e150af7fe28a3e92f68e7733809f33e'),
59
59
  },
60
60
  FeeJuice: {
61
- artifactHash: Fr.fromString('0x184aee92af93d7338cda3b76e9d441559cd15560f517a1a01df541d13a6578de'),
61
+ artifactHash: Fr.fromString('0x1df228ba4645988ae80cf09734c9c05bb572809026914611bc6b66c39cce6081'),
62
62
  privateFunctionsRoot: Fr.fromString('0x247aaafc67f6bf5b06736649181a477dac9f18d3468969b14669708c3dabb275'),
63
63
  publicBytecodeCommitment: Fr.fromString('0x1d4b1a8f71b8250d4fb65f8e16a4604e9165648279f47d80e024ce2684c4bdfb'),
64
64
  }
@@ -79,20 +79,20 @@ FeeJuice: [{ selector: FunctionSelector.fromField(Fr.fromString('0x0000000000000
79
79
 
80
80
 
81
81
  export const ProtocolContractsList = new ProtocolContracts([
82
- AztecAddress.fromString('0x2047b7aba49ac0459ab5d75fde32bcd364e4f984f482c1ae6002cd299031bcde'),
83
- AztecAddress.fromString('0x00c8e0704ca0306dafc52ddd979ea49eca512ca4d074c5ed821a2db832ef633a'),
84
- AztecAddress.fromString('0x06f0f6b0d7a8835ae0d71513a6e18e0484132ab20d153af64e89b1933f68287a'),
85
- AztecAddress.fromString('0x0000000000000000000000000000000000000000000000000000000000000000'),
86
- AztecAddress.fromString('0x0000000000000000000000000000000000000000000000000000000000000000'),
87
- AztecAddress.fromString('0x0000000000000000000000000000000000000000000000000000000000000000'),
88
- AztecAddress.fromString('0x0000000000000000000000000000000000000000000000000000000000000000'),
89
- AztecAddress.fromString('0x0000000000000000000000000000000000000000000000000000000000000000'),
90
- AztecAddress.fromString('0x0000000000000000000000000000000000000000000000000000000000000000'),
91
- AztecAddress.fromString('0x0000000000000000000000000000000000000000000000000000000000000000'),
92
- AztecAddress.fromString('0x0000000000000000000000000000000000000000000000000000000000000000')
82
+ AztecAddress.fromStringUnsafe('0x07172e8dd677966edbe706407e35b6897662846df1894661c8902efa56c22778'),
83
+ AztecAddress.fromStringUnsafe('0x06400117b682ea82bad313957460725049b29c05082fc954983c72d6500866de'),
84
+ AztecAddress.fromStringUnsafe('0x1b83996ec00ec66dce369f748e422e14abbe4e0dcd485ce82aef6e19323b4c11'),
85
+ AztecAddress.fromStringUnsafe('0x0000000000000000000000000000000000000000000000000000000000000000'),
86
+ AztecAddress.fromStringUnsafe('0x0000000000000000000000000000000000000000000000000000000000000000'),
87
+ AztecAddress.fromStringUnsafe('0x0000000000000000000000000000000000000000000000000000000000000000'),
88
+ AztecAddress.fromStringUnsafe('0x0000000000000000000000000000000000000000000000000000000000000000'),
89
+ AztecAddress.fromStringUnsafe('0x0000000000000000000000000000000000000000000000000000000000000000'),
90
+ AztecAddress.fromStringUnsafe('0x0000000000000000000000000000000000000000000000000000000000000000'),
91
+ AztecAddress.fromStringUnsafe('0x0000000000000000000000000000000000000000000000000000000000000000'),
92
+ AztecAddress.fromStringUnsafe('0x0000000000000000000000000000000000000000000000000000000000000000')
93
93
  ]);
94
94
 
95
- export const protocolContractsHash = Fr.fromString('0x016d8ee101b952bcb395235a0ab89707008374dda24f70c1f3911f1b0539d6c4');
95
+ export const protocolContractsHash = Fr.fromString('0x0a1f22b72996215e178699fff463a6ca5e3c7d5ffe66e183490eb766ec1c83ae');
96
96
 
97
97
 
98
98