@aztec/protocol-contracts 0.0.1-commit.1bea0213 → 0.0.1-commit.1dcfe2301
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.
- package/artifacts/AuthRegistry.json +5508 -1268
- package/artifacts/ContractClassRegistry.json +2371 -5051
- package/artifacts/ContractInstanceRegistry.json +3336 -1373
- package/artifacts/FeeJuice.json +5919 -3971
- package/artifacts/MultiCallEntrypoint.json +4113 -905
- package/artifacts/PublicChecks.json +3917 -689
- package/dest/auth-registry/index.d.ts +1 -1
- package/dest/auth-registry/index.d.ts.map +1 -1
- package/dest/auth-registry/index.js +3 -3
- package/dest/auth-registry/lazy.js +1 -1
- package/dest/class-registry/contract_class_published_event.d.ts +6 -3
- package/dest/class-registry/contract_class_published_event.d.ts.map +1 -1
- package/dest/class-registry/contract_class_published_event.js +11 -17
- package/dest/class-registry/index.d.ts +1 -3
- package/dest/class-registry/index.d.ts.map +1 -1
- package/dest/class-registry/index.js +3 -5
- package/dest/class-registry/lazy.d.ts +1 -3
- package/dest/class-registry/lazy.d.ts.map +1 -1
- package/dest/class-registry/lazy.js +1 -3
- package/dest/fee-juice/index.d.ts +1 -1
- package/dest/fee-juice/index.d.ts.map +1 -1
- package/dest/fee-juice/index.js +3 -3
- package/dest/fee-juice/lazy.js +1 -1
- package/dest/instance-registry/index.d.ts +1 -1
- package/dest/instance-registry/index.d.ts.map +1 -1
- package/dest/instance-registry/index.js +3 -3
- package/dest/instance-registry/lazy.js +1 -1
- package/dest/make_protocol_contract.d.ts +4 -4
- package/dest/make_protocol_contract.d.ts.map +1 -1
- package/dest/make_protocol_contract.js +28 -14
- package/dest/multi-call-entrypoint/index.d.ts +1 -1
- package/dest/multi-call-entrypoint/index.d.ts.map +1 -1
- package/dest/multi-call-entrypoint/index.js +3 -3
- package/dest/multi-call-entrypoint/lazy.js +1 -1
- package/dest/protocol_contract_data.d.ts +13 -1
- package/dest/protocol_contract_data.d.ts.map +1 -1
- package/dest/protocol_contract_data.js +100 -14
- package/dest/provider/bundle.js +1 -1
- package/dest/public-checks/index.d.ts +1 -1
- package/dest/public-checks/index.d.ts.map +1 -1
- package/dest/public-checks/index.js +3 -3
- package/dest/public-checks/lazy.js +1 -1
- package/dest/scripts/generate_data.js +70 -21
- package/dest/tests/fixtures.d.ts +1 -3
- package/dest/tests/fixtures.d.ts.map +1 -1
- package/dest/tests/fixtures.js +0 -10
- package/package.json +4 -4
- package/src/auth-registry/index.ts +3 -3
- package/src/auth-registry/lazy.ts +1 -1
- package/src/class-registry/contract_class_published_event.ts +11 -22
- package/src/class-registry/index.ts +3 -5
- package/src/class-registry/lazy.ts +1 -3
- package/src/fee-juice/index.ts +3 -3
- package/src/fee-juice/lazy.ts +1 -1
- package/src/instance-registry/index.ts +3 -3
- package/src/instance-registry/lazy.ts +1 -1
- package/src/make_protocol_contract.ts +37 -15
- package/src/multi-call-entrypoint/index.ts +3 -3
- package/src/multi-call-entrypoint/lazy.ts +1 -1
- package/src/protocol_contract_data.ts +77 -14
- package/src/provider/bundle.ts +1 -1
- package/src/public-checks/index.ts +3 -3
- package/src/public-checks/lazy.ts +1 -1
- package/src/tests/fixtures.ts +0 -12
- package/dest/class-registry/private_function_broadcasted_event.d.ts +0 -44
- package/dest/class-registry/private_function_broadcasted_event.d.ts.map +0 -1
- package/dest/class-registry/private_function_broadcasted_event.js +0 -85
- package/dest/class-registry/utility_function_broadcasted_event.d.ts +0 -38
- package/dest/class-registry/utility_function_broadcasted_event.d.ts.map +0 -1
- package/dest/class-registry/utility_function_broadcasted_event.js +0 -81
- package/src/class-registry/private_function_broadcasted_event.ts +0 -109
- package/src/class-registry/utility_function_broadcasted_event.ts +0 -103
package/src/provider/bundle.ts
CHANGED
|
@@ -22,6 +22,6 @@ export const ProtocolContractArtifact: Record<ProtocolContractName, ContractArti
|
|
|
22
22
|
|
|
23
23
|
export class BundledProtocolContractsProvider implements ProtocolContractsProvider {
|
|
24
24
|
getProtocolContractArtifact(name: ProtocolContractName): Promise<ProtocolContract> {
|
|
25
|
-
return makeProtocolContract(name, ProtocolContractArtifact[name]);
|
|
25
|
+
return Promise.resolve(makeProtocolContract(name, ProtocolContractArtifact[name]));
|
|
26
26
|
}
|
|
27
27
|
}
|
|
@@ -10,9 +10,9 @@ export const PublicChecksArtifact = loadContractArtifact(PublicChecksJson as Noi
|
|
|
10
10
|
let protocolContract: ProtocolContract;
|
|
11
11
|
|
|
12
12
|
/** Returns the canonical deployment of the contract. */
|
|
13
|
-
export
|
|
13
|
+
export function getCanonicalPublicChecks(): Promise<ProtocolContract> {
|
|
14
14
|
if (!protocolContract) {
|
|
15
|
-
protocolContract =
|
|
15
|
+
protocolContract = makeProtocolContract('PublicChecks', PublicChecksArtifact);
|
|
16
16
|
}
|
|
17
|
-
return protocolContract;
|
|
17
|
+
return Promise.resolve(protocolContract);
|
|
18
18
|
}
|
|
@@ -23,7 +23,7 @@ export async function getPublicChecksArtifact(): Promise<ContractArtifact> {
|
|
|
23
23
|
export async function getCanonicalPublicChecks(): Promise<ProtocolContract> {
|
|
24
24
|
if (!protocolContract) {
|
|
25
25
|
const publicChecksArtifact = await getPublicChecksArtifact();
|
|
26
|
-
protocolContract =
|
|
26
|
+
protocolContract = makeProtocolContract('PublicChecks', publicChecksArtifact);
|
|
27
27
|
}
|
|
28
28
|
return protocolContract;
|
|
29
29
|
}
|
package/src/tests/fixtures.ts
CHANGED
|
@@ -8,18 +8,6 @@ export function getSampleContractClassPublishedEventPayload(): Buffer {
|
|
|
8
8
|
return Buffer.from(readFileSync(path).toString(), 'hex');
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
// Generated from end-to-end/src/e2e_deploy_contract/contract_class_registration.test.ts with AZTEC_GENERATE_TEST_DATA=1
|
|
12
|
-
export function getSamplePrivateFunctionBroadcastedEventPayload(): Buffer {
|
|
13
|
-
const path = getPathToFixture('PrivateFunctionBroadcastedEventData.hex');
|
|
14
|
-
return Buffer.from(readFileSync(path).toString(), 'hex');
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
// Generated from end-to-end/src/e2e_deploy_contract/contract_class_registration.test.ts with AZTEC_GENERATE_TEST_DATA=1
|
|
18
|
-
export function getSampleUtilityFunctionBroadcastedEventPayload(): Buffer {
|
|
19
|
-
const path = getPathToFixture('UtilityFunctionBroadcastedEventData.hex');
|
|
20
|
-
return Buffer.from(readFileSync(path).toString(), 'hex');
|
|
21
|
-
}
|
|
22
|
-
|
|
23
11
|
// Generated from end-to-end/src/e2e_deploy_contract/contract_class_registration.test.ts with AZTEC_GENERATE_TEST_DATA=1
|
|
24
12
|
export function getSampleContractInstancePublishedEventPayload(): Buffer {
|
|
25
13
|
const path = getPathToFixture('ContractInstancePublishedEventData.hex');
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { ARTIFACT_FUNCTION_TREE_MAX_HEIGHT, FUNCTION_TREE_HEIGHT } from '@aztec/constants';
|
|
2
|
-
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
|
-
import type { Tuple } from '@aztec/foundation/serialize';
|
|
4
|
-
import { FieldReader } from '@aztec/foundation/serialize';
|
|
5
|
-
import { FunctionSelector } from '@aztec/stdlib/abi';
|
|
6
|
-
import type { ExecutablePrivateFunctionWithMembershipProof, PrivateFunction } from '@aztec/stdlib/contract';
|
|
7
|
-
import type { ContractClassLog } from '@aztec/stdlib/logs';
|
|
8
|
-
/** Event emitted from the ContractClassRegistry. */
|
|
9
|
-
export declare class PrivateFunctionBroadcastedEvent {
|
|
10
|
-
readonly contractClassId: Fr;
|
|
11
|
-
readonly artifactMetadataHash: Fr;
|
|
12
|
-
readonly utilityFunctionsTreeRoot: Fr;
|
|
13
|
-
readonly privateFunctionTreeSiblingPath: Tuple<Fr, typeof FUNCTION_TREE_HEIGHT>;
|
|
14
|
-
readonly privateFunctionTreeLeafIndex: number;
|
|
15
|
-
readonly artifactFunctionTreeSiblingPath: Tuple<Fr, typeof ARTIFACT_FUNCTION_TREE_MAX_HEIGHT>;
|
|
16
|
-
readonly artifactFunctionTreeLeafIndex: number;
|
|
17
|
-
readonly privateFunction: BroadcastedPrivateFunction;
|
|
18
|
-
constructor(contractClassId: Fr, artifactMetadataHash: Fr, utilityFunctionsTreeRoot: Fr, privateFunctionTreeSiblingPath: Tuple<Fr, typeof FUNCTION_TREE_HEIGHT>, privateFunctionTreeLeafIndex: number, artifactFunctionTreeSiblingPath: Tuple<Fr, typeof ARTIFACT_FUNCTION_TREE_MAX_HEIGHT>, artifactFunctionTreeLeafIndex: number, privateFunction: BroadcastedPrivateFunction);
|
|
19
|
-
static isPrivateFunctionBroadcastedEvent(log: ContractClassLog): boolean;
|
|
20
|
-
static fromLog(log: ContractClassLog): PrivateFunctionBroadcastedEvent;
|
|
21
|
-
static fromFields(fields: Fr[] | FieldReader): PrivateFunctionBroadcastedEvent;
|
|
22
|
-
toFunctionWithMembershipProof(): ExecutablePrivateFunctionWithMembershipProof;
|
|
23
|
-
}
|
|
24
|
-
export declare class BroadcastedPrivateFunction implements PrivateFunction {
|
|
25
|
-
/** Selector of the function. Calculated as the hash of the method name and parameters. The specification of this is not enforced by the protocol. */
|
|
26
|
-
readonly selector: FunctionSelector;
|
|
27
|
-
/** Artifact metadata hash */
|
|
28
|
-
readonly metadataHash: Fr;
|
|
29
|
-
/** Hash of the verification key associated to this private function. */
|
|
30
|
-
readonly vkHash: Fr;
|
|
31
|
-
/** ACIR and Brillig bytecode */
|
|
32
|
-
readonly bytecode: Buffer;
|
|
33
|
-
constructor(
|
|
34
|
-
/** Selector of the function. Calculated as the hash of the method name and parameters. The specification of this is not enforced by the protocol. */
|
|
35
|
-
selector: FunctionSelector,
|
|
36
|
-
/** Artifact metadata hash */
|
|
37
|
-
metadataHash: Fr,
|
|
38
|
-
/** Hash of the verification key associated to this private function. */
|
|
39
|
-
vkHash: Fr,
|
|
40
|
-
/** ACIR and Brillig bytecode */
|
|
41
|
-
bytecode: Buffer);
|
|
42
|
-
static fromFields(fields: Fr[] | FieldReader): B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UF3RTtJQUN4RCxNQUFNLEVBQUUsRUFBRTtJQUMxQixnQ0FBZ0M7SUFDaEIsUUFBUSxFQUFFLE1BQU0sRUFDOUI7SUFFSixNQUFNLENBQUMsVUFBVSxDQUFDLE1BQU0sRUFBRSxFQUFFLEVBQUUsR0FBRyxXQUFXLDhCQVMzQztDQUNGIn0=
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"private_function_broadcasted_event.d.ts","sourceRoot":"","sources":["../../src/class-registry/private_function_broadcasted_event.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iCAAiC,EAEjC,oBAAoB,EAErB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAoB,MAAM,mBAAmB,CAAC;AACvE,OAAO,KAAK,EAAE,4CAA4C,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC5G,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAI3D,oDAAoD;AACpD,qBAAa,+BAA+B;aAExB,eAAe,EAAE,EAAE;aACnB,oBAAoB,EAAE,EAAE;aACxB,wBAAwB,EAAE,EAAE;aAC5B,8BAA8B,EAAE,KAAK,CAAC,EAAE,EAAE,OAAO,oBAAoB,CAAC;aACtE,4BAA4B,EAAE,MAAM;aACpC,+BAA+B,EAAE,KAAK,CAAC,EAAE,EAAE,OAAO,iCAAiC,CAAC;aACpF,6BAA6B,EAAE,MAAM;aACrC,eAAe,EAAE,0BAA0B;IAR7D,YACkB,eAAe,EAAE,EAAE,EACnB,oBAAoB,EAAE,EAAE,EACxB,wBAAwB,EAAE,EAAE,EAC5B,8BAA8B,EAAE,KAAK,CAAC,EAAE,EAAE,OAAO,oBAAoB,CAAC,EACtE,4BAA4B,EAAE,MAAM,EACpC,+BAA+B,EAAE,KAAK,CAAC,EAAE,EAAE,OAAO,iCAAiC,CAAC,EACpF,6BAA6B,EAAE,MAAM,EACrC,eAAe,EAAE,0BAA0B,EACzD;IAEJ,MAAM,CAAC,iCAAiC,CAAC,GAAG,EAAE,gBAAgB,WAK7D;IAED,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,gBAAgB,mCAWnC;IAED,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE,EAAE,GAAG,WAAW,mCAqB3C;IAED,6BAA6B,IAAI,4CAA4C,CAY5E;CACF;AAED,qBAAa,0BAA2B,YAAW,eAAe;IAE9D,qJAAqJ;aACrI,QAAQ,EAAE,gBAAgB;IAC1C,6BAA6B;aACb,YAAY,EAAE,EAAE;IAChC,wEAAwE;aACxD,MAAM,EAAE,EAAE;IAC1B,gCAAgC;aAChB,QAAQ,EAAE,MAAM;IARlC;IACE,qJAAqJ;IACrI,QAAQ,EAAE,gBAAgB;IAC1C,6BAA6B;IACb,YAAY,EAAE,EAAE;IAChC,wEAAwE;IACxD,MAAM,EAAE,EAAE;IAC1B,gCAAgC;IAChB,QAAQ,EAAE,MAAM,EAC9B;IAEJ,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE,EAAE,GAAG,WAAW,8BAS3C;CACF"}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { ARTIFACT_FUNCTION_TREE_MAX_HEIGHT, CONTRACT_CLASS_REGISTRY_PRIVATE_FUNCTION_BROADCASTED_MAGIC_VALUE, FUNCTION_TREE_HEIGHT, MAX_PACKED_BYTECODE_SIZE_PER_PRIVATE_FUNCTION_IN_FIELDS } from '@aztec/constants';
|
|
2
|
-
import { FieldReader } from '@aztec/foundation/serialize';
|
|
3
|
-
import { FunctionSelector, bufferFromFields } from '@aztec/stdlib/abi';
|
|
4
|
-
import { ProtocolContractAddress } from '../protocol_contract_data.js';
|
|
5
|
-
/** Event emitted from the ContractClassRegistry. */ export class PrivateFunctionBroadcastedEvent {
|
|
6
|
-
contractClassId;
|
|
7
|
-
artifactMetadataHash;
|
|
8
|
-
utilityFunctionsTreeRoot;
|
|
9
|
-
privateFunctionTreeSiblingPath;
|
|
10
|
-
privateFunctionTreeLeafIndex;
|
|
11
|
-
artifactFunctionTreeSiblingPath;
|
|
12
|
-
artifactFunctionTreeLeafIndex;
|
|
13
|
-
privateFunction;
|
|
14
|
-
constructor(contractClassId, artifactMetadataHash, utilityFunctionsTreeRoot, privateFunctionTreeSiblingPath, privateFunctionTreeLeafIndex, artifactFunctionTreeSiblingPath, artifactFunctionTreeLeafIndex, privateFunction){
|
|
15
|
-
this.contractClassId = contractClassId;
|
|
16
|
-
this.artifactMetadataHash = artifactMetadataHash;
|
|
17
|
-
this.utilityFunctionsTreeRoot = utilityFunctionsTreeRoot;
|
|
18
|
-
this.privateFunctionTreeSiblingPath = privateFunctionTreeSiblingPath;
|
|
19
|
-
this.privateFunctionTreeLeafIndex = privateFunctionTreeLeafIndex;
|
|
20
|
-
this.artifactFunctionTreeSiblingPath = artifactFunctionTreeSiblingPath;
|
|
21
|
-
this.artifactFunctionTreeLeafIndex = artifactFunctionTreeLeafIndex;
|
|
22
|
-
this.privateFunction = privateFunction;
|
|
23
|
-
}
|
|
24
|
-
static isPrivateFunctionBroadcastedEvent(log) {
|
|
25
|
-
return log.contractAddress.equals(ProtocolContractAddress.ContractClassRegistry) && log.fields.fields[0].toBigInt() === CONTRACT_CLASS_REGISTRY_PRIVATE_FUNCTION_BROADCASTED_MAGIC_VALUE;
|
|
26
|
-
}
|
|
27
|
-
static fromLog(log) {
|
|
28
|
-
const reader = new FieldReader(log.fields.fields.slice(1));
|
|
29
|
-
const event = PrivateFunctionBroadcastedEvent.fromFields(reader);
|
|
30
|
-
while(!reader.isFinished()){
|
|
31
|
-
const field = reader.readField();
|
|
32
|
-
if (!field.isZero()) {
|
|
33
|
-
throw new Error(`Unexpected data after parsing PrivateFunctionBroadcastedEvent: ${field.toString()}`);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
return event;
|
|
37
|
-
}
|
|
38
|
-
static fromFields(fields) {
|
|
39
|
-
const reader = FieldReader.asReader(fields);
|
|
40
|
-
const contractClassId = reader.readField();
|
|
41
|
-
const artifactMetadataHash = reader.readField();
|
|
42
|
-
const utilityFunctionsTreeRoot = reader.readField();
|
|
43
|
-
const privateFunctionTreeSiblingPath = reader.readFieldArray(FUNCTION_TREE_HEIGHT);
|
|
44
|
-
const privateFunctionTreeLeafIndex = reader.readField().toNumber();
|
|
45
|
-
const artifactFunctionTreeSiblingPath = reader.readFieldArray(ARTIFACT_FUNCTION_TREE_MAX_HEIGHT);
|
|
46
|
-
const artifactFunctionTreeLeafIndex = reader.readField().toNumber();
|
|
47
|
-
const privateFunction = BroadcastedPrivateFunction.fromFields(reader);
|
|
48
|
-
return new PrivateFunctionBroadcastedEvent(contractClassId, artifactMetadataHash, utilityFunctionsTreeRoot, privateFunctionTreeSiblingPath, privateFunctionTreeLeafIndex, artifactFunctionTreeSiblingPath, artifactFunctionTreeLeafIndex, privateFunction);
|
|
49
|
-
}
|
|
50
|
-
toFunctionWithMembershipProof() {
|
|
51
|
-
return {
|
|
52
|
-
...this.privateFunction,
|
|
53
|
-
bytecode: this.privateFunction.bytecode,
|
|
54
|
-
functionMetadataHash: this.privateFunction.metadataHash,
|
|
55
|
-
artifactMetadataHash: this.artifactMetadataHash,
|
|
56
|
-
utilityFunctionsTreeRoot: this.utilityFunctionsTreeRoot,
|
|
57
|
-
privateFunctionTreeSiblingPath: this.privateFunctionTreeSiblingPath,
|
|
58
|
-
privateFunctionTreeLeafIndex: this.privateFunctionTreeLeafIndex,
|
|
59
|
-
artifactTreeSiblingPath: this.artifactFunctionTreeSiblingPath.filter((fr)=>!fr.isZero()),
|
|
60
|
-
artifactTreeLeafIndex: this.artifactFunctionTreeLeafIndex
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
export class BroadcastedPrivateFunction {
|
|
65
|
-
selector;
|
|
66
|
-
metadataHash;
|
|
67
|
-
vkHash;
|
|
68
|
-
bytecode;
|
|
69
|
-
constructor(/** Selector of the function. Calculated as the hash of the method name and parameters. The specification of this is not enforced by the protocol. */ selector, /** Artifact metadata hash */ metadataHash, /** Hash of the verification key associated to this private function. */ vkHash, /** ACIR and Brillig bytecode */ bytecode){
|
|
70
|
-
this.selector = selector;
|
|
71
|
-
this.metadataHash = metadataHash;
|
|
72
|
-
this.vkHash = vkHash;
|
|
73
|
-
this.bytecode = bytecode;
|
|
74
|
-
}
|
|
75
|
-
static fromFields(fields) {
|
|
76
|
-
const reader = FieldReader.asReader(fields);
|
|
77
|
-
const selector = FunctionSelector.fromField(reader.readField());
|
|
78
|
-
const metadataHash = reader.readField();
|
|
79
|
-
const vkHash = reader.readField();
|
|
80
|
-
// The '* 1' removes the 'Type instantiation is excessively deep and possibly infinite. ts(2589)' err
|
|
81
|
-
const encodedBytecode = reader.readFieldArray(MAX_PACKED_BYTECODE_SIZE_PER_PRIVATE_FUNCTION_IN_FIELDS * 1);
|
|
82
|
-
const bytecode = bufferFromFields(encodedBytecode);
|
|
83
|
-
return new BroadcastedPrivateFunction(selector, metadataHash, vkHash, bytecode);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { ARTIFACT_FUNCTION_TREE_MAX_HEIGHT } from '@aztec/constants';
|
|
2
|
-
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
|
-
import type { Tuple } from '@aztec/foundation/serialize';
|
|
4
|
-
import { FieldReader } from '@aztec/foundation/serialize';
|
|
5
|
-
import { FunctionSelector } from '@aztec/stdlib/abi';
|
|
6
|
-
import type { UtilityFunction, UtilityFunctionWithMembershipProof } from '@aztec/stdlib/contract';
|
|
7
|
-
import type { ContractClassLog } from '@aztec/stdlib/logs';
|
|
8
|
-
/** Event emitted from the ContractClassRegistry. */
|
|
9
|
-
export declare class UtilityFunctionBroadcastedEvent {
|
|
10
|
-
readonly contractClassId: Fr;
|
|
11
|
-
readonly artifactMetadataHash: Fr;
|
|
12
|
-
readonly privateFunctionsArtifactTreeRoot: Fr;
|
|
13
|
-
readonly artifactFunctionTreeSiblingPath: Tuple<Fr, typeof ARTIFACT_FUNCTION_TREE_MAX_HEIGHT>;
|
|
14
|
-
readonly artifactFunctionTreeLeafIndex: number;
|
|
15
|
-
readonly utilityFunction: BroadcastedUtilityFunction;
|
|
16
|
-
constructor(contractClassId: Fr, artifactMetadataHash: Fr, privateFunctionsArtifactTreeRoot: Fr, artifactFunctionTreeSiblingPath: Tuple<Fr, typeof ARTIFACT_FUNCTION_TREE_MAX_HEIGHT>, artifactFunctionTreeLeafIndex: number, utilityFunction: BroadcastedUtilityFunction);
|
|
17
|
-
static isUtilityFunctionBroadcastedEvent(log: ContractClassLog): boolean;
|
|
18
|
-
static fromLog(log: ContractClassLog): UtilityFunctionBroadcastedEvent;
|
|
19
|
-
static fromFields(fields: Fr[] | FieldReader): UtilityFunctionBroadcastedEvent;
|
|
20
|
-
toFunctionWithMembershipProof(): UtilityFunctionWithMembershipProof;
|
|
21
|
-
}
|
|
22
|
-
export declare class BroadcastedUtilityFunction implements UtilityFunction {
|
|
23
|
-
/** Selector of the function. Calculated as the hash of the method name and parameters. The specification of this is not enforced by the protocol. */
|
|
24
|
-
readonly selector: FunctionSelector;
|
|
25
|
-
/** Artifact metadata hash */
|
|
26
|
-
readonly metadataHash: Fr;
|
|
27
|
-
/** Brillig bytecode */
|
|
28
|
-
readonly bytecode: Buffer;
|
|
29
|
-
constructor(
|
|
30
|
-
/** Selector of the function. Calculated as the hash of the method name and parameters. The specification of this is not enforced by the protocol. */
|
|
31
|
-
selector: FunctionSelector,
|
|
32
|
-
/** Artifact metadata hash */
|
|
33
|
-
metadataHash: Fr,
|
|
34
|
-
/** Brillig bytecode */
|
|
35
|
-
bytecode: Buffer);
|
|
36
|
-
static fromFields(fields: Fr[] | FieldReader): Broadcast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UNuQixvQkFBb0IsRUFBRSxFQUFFLEVBQ3hCLGdDQUFnQyxFQUFFLEVBQUUsRUFDcEMsK0JBQStCLEVBQUUsS0FBSyxDQUFDLEVBQUUsRUFBRSxPQUFPLGlDQUFpQyxDQUFDLEVBQ3BGLDZCQUE2QixFQUFFLE1BQU0sRUFDckMsZUFBZSxFQUFFLDBCQUEwQixFQUN6RDtJQUVKLE1BQU0sQ0FBQyxpQ0FBaUMsQ0FBQyxHQUFHLEVBQUUsZ0JBQWdCLFdBSzdEO0lBRUQsTUFBTSxDQUFDLE9BQU8sQ0FBQyxHQUFHLEVBQUUsZ0JBQWdCLG1DQVduQztJQUVELE1BQU0sQ0FBQyxVQUFVLENBQUMsTUFBTSxFQUFFLEVBQUUsRUFBRSxHQUFHLFdBQVcsbUNBaUIzQztJQUVELDZCQUE2QixJQUFJLGtDQUFrQyxDQWVsRTtDQUNGO0FBRUQscUJBQWEsMEJBQTJCLFlBQVcsZUFBZTtJQUU5RCxxSkFBcUo7YUFDckksUUFBUSxFQUFFLGdCQUFnQjtJQUMxQyw2QkFBNkI7YUFDYixZQUFZLEVBQUUsRUFBRTtJQUNoQyx1QkFBdUI7YUFDUCxRQUFRLEVBQUUsTUFBTTtJQU5sQztJQUNFLHFKQUFxSjtJQUNySSxRQUFRLEVBQUUsZ0JBQWdCO0lBQzFDLDZCQUE2QjtJQUNiLFlBQVksRUFBRSxFQUFFO0lBQ2hDLHVCQUF1QjtJQUNQLFFBQVEsRUFBRSxNQUFNLEVBQzlCO0lBRUosTUFBTSxDQUFDLFVBQVUsQ0FBQyxNQUFNLEVBQUUsRUFBRSxFQUFFLEdBQUcsV0FBVyw4QkFRM0M7Q0FDRiJ9
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utility_function_broadcasted_event.d.ts","sourceRoot":"","sources":["../../src/class-registry/utility_function_broadcasted_event.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iCAAiC,EAGlC,MAAM,kBAAkB,CAA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A6B;IACb,YAAY,EAAE,EAAE;IAChC,uBAAuB;IACP,QAAQ,EAAE,MAAM,EAC9B;IAEJ,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE,EAAE,GAAG,WAAW,8BAQ3C;CACF"}
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { ARTIFACT_FUNCTION_TREE_MAX_HEIGHT, CONTRACT_CLASS_REGISTRY_UTILITY_FUNCTION_BROADCASTED_MAGIC_VALUE, MAX_PACKED_BYTECODE_SIZE_PER_UTILITY_FUNCTION_IN_FIELDS } from '@aztec/constants';
|
|
2
|
-
import { removeArrayPaddingEnd } from '@aztec/foundation/collection';
|
|
3
|
-
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
|
-
import { FieldReader } from '@aztec/foundation/serialize';
|
|
5
|
-
import { FunctionSelector, bufferFromFields } from '@aztec/stdlib/abi';
|
|
6
|
-
import { ProtocolContractAddress } from '../protocol_contract_data.js';
|
|
7
|
-
/** Event emitted from the ContractClassRegistry. */ export class UtilityFunctionBroadcastedEvent {
|
|
8
|
-
contractClassId;
|
|
9
|
-
artifactMetadataHash;
|
|
10
|
-
privateFunctionsArtifactTreeRoot;
|
|
11
|
-
artifactFunctionTreeSiblingPath;
|
|
12
|
-
artifactFunctionTreeLeafIndex;
|
|
13
|
-
utilityFunction;
|
|
14
|
-
constructor(contractClassId, artifactMetadataHash, privateFunctionsArtifactTreeRoot, artifactFunctionTreeSiblingPath, artifactFunctionTreeLeafIndex, utilityFunction){
|
|
15
|
-
this.contractClassId = contractClassId;
|
|
16
|
-
this.artifactMetadataHash = artifactMetadataHash;
|
|
17
|
-
this.privateFunctionsArtifactTreeRoot = privateFunctionsArtifactTreeRoot;
|
|
18
|
-
this.artifactFunctionTreeSiblingPath = artifactFunctionTreeSiblingPath;
|
|
19
|
-
this.artifactFunctionTreeLeafIndex = artifactFunctionTreeLeafIndex;
|
|
20
|
-
this.utilityFunction = utilityFunction;
|
|
21
|
-
}
|
|
22
|
-
static isUtilityFunctionBroadcastedEvent(log) {
|
|
23
|
-
return log.contractAddress.equals(ProtocolContractAddress.ContractClassRegistry) && log.fields.fields[0].toBigInt() === CONTRACT_CLASS_REGISTRY_UTILITY_FUNCTION_BROADCASTED_MAGIC_VALUE;
|
|
24
|
-
}
|
|
25
|
-
static fromLog(log) {
|
|
26
|
-
const reader = new FieldReader(log.fields.fields.slice(1));
|
|
27
|
-
const event = UtilityFunctionBroadcastedEvent.fromFields(reader);
|
|
28
|
-
while(!reader.isFinished()){
|
|
29
|
-
const field = reader.readField();
|
|
30
|
-
if (!field.isZero()) {
|
|
31
|
-
throw new Error(`Unexpected data after parsing UtilityFunctionBroadcastedEvent: ${field.toString()}`);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
return event;
|
|
35
|
-
}
|
|
36
|
-
static fromFields(fields) {
|
|
37
|
-
const reader = FieldReader.asReader(fields);
|
|
38
|
-
const contractClassId = reader.readField();
|
|
39
|
-
const artifactMetadataHash = reader.readField();
|
|
40
|
-
const privateFunctionsArtifactTreeRoot = reader.readField();
|
|
41
|
-
const artifactFunctionTreeSiblingPath = reader.readFieldArray(ARTIFACT_FUNCTION_TREE_MAX_HEIGHT);
|
|
42
|
-
const artifactFunctionTreeLeafIndex = reader.readField().toNumber();
|
|
43
|
-
const utilityFunction = BroadcastedUtilityFunction.fromFields(reader);
|
|
44
|
-
return new UtilityFunctionBroadcastedEvent(contractClassId, artifactMetadataHash, privateFunctionsArtifactTreeRoot, artifactFunctionTreeSiblingPath, artifactFunctionTreeLeafIndex, utilityFunction);
|
|
45
|
-
}
|
|
46
|
-
toFunctionWithMembershipProof() {
|
|
47
|
-
// We should be able to safely remove the zero elements that pad the variable-length sibling path,
|
|
48
|
-
// since a sibling with value zero can only occur on the tree leaves, so the sibling path will never end
|
|
49
|
-
// in a zero. The only exception is a tree with depth 2 with one non-zero leaf, where the sibling path would
|
|
50
|
-
// be a single zero element, but in that case the artifact tree should be just the single leaf.
|
|
51
|
-
const artifactTreeSiblingPath = removeArrayPaddingEnd(this.artifactFunctionTreeSiblingPath, Fr.isZero);
|
|
52
|
-
return {
|
|
53
|
-
...this.utilityFunction,
|
|
54
|
-
bytecode: this.utilityFunction.bytecode,
|
|
55
|
-
functionMetadataHash: this.utilityFunction.metadataHash,
|
|
56
|
-
artifactMetadataHash: this.artifactMetadataHash,
|
|
57
|
-
privateFunctionsArtifactTreeRoot: this.privateFunctionsArtifactTreeRoot,
|
|
58
|
-
artifactTreeSiblingPath,
|
|
59
|
-
artifactTreeLeafIndex: this.artifactFunctionTreeLeafIndex
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
export class BroadcastedUtilityFunction {
|
|
64
|
-
selector;
|
|
65
|
-
metadataHash;
|
|
66
|
-
bytecode;
|
|
67
|
-
constructor(/** Selector of the function. Calculated as the hash of the method name and parameters. The specification of this is not enforced by the protocol. */ selector, /** Artifact metadata hash */ metadataHash, /** Brillig bytecode */ bytecode){
|
|
68
|
-
this.selector = selector;
|
|
69
|
-
this.metadataHash = metadataHash;
|
|
70
|
-
this.bytecode = bytecode;
|
|
71
|
-
}
|
|
72
|
-
static fromFields(fields) {
|
|
73
|
-
const reader = FieldReader.asReader(fields);
|
|
74
|
-
const selector = FunctionSelector.fromField(reader.readField());
|
|
75
|
-
const metadataHash = reader.readField();
|
|
76
|
-
// The '* 1' removes the 'Type instantiation is excessively deep and possibly infinite. ts(2589)' err
|
|
77
|
-
const encodedBytecode = reader.readFieldArray(MAX_PACKED_BYTECODE_SIZE_PER_UTILITY_FUNCTION_IN_FIELDS * 1);
|
|
78
|
-
const bytecode = bufferFromFields(encodedBytecode);
|
|
79
|
-
return new BroadcastedUtilityFunction(selector, metadataHash, bytecode);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ARTIFACT_FUNCTION_TREE_MAX_HEIGHT,
|
|
3
|
-
CONTRACT_CLASS_REGISTRY_PRIVATE_FUNCTION_BROADCASTED_MAGIC_VALUE,
|
|
4
|
-
FUNCTION_TREE_HEIGHT,
|
|
5
|
-
MAX_PACKED_BYTECODE_SIZE_PER_PRIVATE_FUNCTION_IN_FIELDS,
|
|
6
|
-
} from '@aztec/constants';
|
|
7
|
-
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
8
|
-
import type { Tuple } from '@aztec/foundation/serialize';
|
|
9
|
-
import { FieldReader } from '@aztec/foundation/serialize';
|
|
10
|
-
import { FunctionSelector, bufferFromFields } from '@aztec/stdlib/abi';
|
|
11
|
-
import type { ExecutablePrivateFunctionWithMembershipProof, PrivateFunction } from '@aztec/stdlib/contract';
|
|
12
|
-
import type { ContractClassLog } from '@aztec/stdlib/logs';
|
|
13
|
-
|
|
14
|
-
import { ProtocolContractAddress } from '../protocol_contract_data.js';
|
|
15
|
-
|
|
16
|
-
/** Event emitted from the ContractClassRegistry. */
|
|
17
|
-
export class PrivateFunctionBroadcastedEvent {
|
|
18
|
-
constructor(
|
|
19
|
-
public readonly contractClassId: Fr,
|
|
20
|
-
public readonly artifactMetadataHash: Fr,
|
|
21
|
-
public readonly utilityFunctionsTreeRoot: Fr,
|
|
22
|
-
public readonly privateFunctionTreeSiblingPath: Tuple<Fr, typeof FUNCTION_TREE_HEIGHT>,
|
|
23
|
-
public readonly privateFunctionTreeLeafIndex: number,
|
|
24
|
-
public readonly artifactFunctionTreeSiblingPath: Tuple<Fr, typeof ARTIFACT_FUNCTION_TREE_MAX_HEIGHT>,
|
|
25
|
-
public readonly artifactFunctionTreeLeafIndex: number,
|
|
26
|
-
public readonly privateFunction: BroadcastedPrivateFunction,
|
|
27
|
-
) {}
|
|
28
|
-
|
|
29
|
-
static isPrivateFunctionBroadcastedEvent(log: ContractClassLog) {
|
|
30
|
-
return (
|
|
31
|
-
log.contractAddress.equals(ProtocolContractAddress.ContractClassRegistry) &&
|
|
32
|
-
log.fields.fields[0].toBigInt() === CONTRACT_CLASS_REGISTRY_PRIVATE_FUNCTION_BROADCASTED_MAGIC_VALUE
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
static fromLog(log: ContractClassLog) {
|
|
37
|
-
const reader = new FieldReader(log.fields.fields.slice(1));
|
|
38
|
-
const event = PrivateFunctionBroadcastedEvent.fromFields(reader);
|
|
39
|
-
while (!reader.isFinished()) {
|
|
40
|
-
const field = reader.readField();
|
|
41
|
-
if (!field.isZero()) {
|
|
42
|
-
throw new Error(`Unexpected data after parsing PrivateFunctionBroadcastedEvent: ${field.toString()}`);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return event;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
static fromFields(fields: Fr[] | FieldReader) {
|
|
50
|
-
const reader = FieldReader.asReader(fields);
|
|
51
|
-
const contractClassId = reader.readField();
|
|
52
|
-
const artifactMetadataHash = reader.readField();
|
|
53
|
-
const utilityFunctionsTreeRoot = reader.readField();
|
|
54
|
-
const privateFunctionTreeSiblingPath = reader.readFieldArray(FUNCTION_TREE_HEIGHT);
|
|
55
|
-
const privateFunctionTreeLeafIndex = reader.readField().toNumber();
|
|
56
|
-
const artifactFunctionTreeSiblingPath = reader.readFieldArray(ARTIFACT_FUNCTION_TREE_MAX_HEIGHT);
|
|
57
|
-
const artifactFunctionTreeLeafIndex = reader.readField().toNumber();
|
|
58
|
-
const privateFunction = BroadcastedPrivateFunction.fromFields(reader);
|
|
59
|
-
|
|
60
|
-
return new PrivateFunctionBroadcastedEvent(
|
|
61
|
-
contractClassId,
|
|
62
|
-
artifactMetadataHash,
|
|
63
|
-
utilityFunctionsTreeRoot,
|
|
64
|
-
privateFunctionTreeSiblingPath,
|
|
65
|
-
privateFunctionTreeLeafIndex,
|
|
66
|
-
artifactFunctionTreeSiblingPath,
|
|
67
|
-
artifactFunctionTreeLeafIndex,
|
|
68
|
-
privateFunction,
|
|
69
|
-
);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
toFunctionWithMembershipProof(): ExecutablePrivateFunctionWithMembershipProof {
|
|
73
|
-
return {
|
|
74
|
-
...this.privateFunction,
|
|
75
|
-
bytecode: this.privateFunction.bytecode,
|
|
76
|
-
functionMetadataHash: this.privateFunction.metadataHash,
|
|
77
|
-
artifactMetadataHash: this.artifactMetadataHash,
|
|
78
|
-
utilityFunctionsTreeRoot: this.utilityFunctionsTreeRoot,
|
|
79
|
-
privateFunctionTreeSiblingPath: this.privateFunctionTreeSiblingPath,
|
|
80
|
-
privateFunctionTreeLeafIndex: this.privateFunctionTreeLeafIndex,
|
|
81
|
-
artifactTreeSiblingPath: this.artifactFunctionTreeSiblingPath.filter(fr => !fr.isZero()),
|
|
82
|
-
artifactTreeLeafIndex: this.artifactFunctionTreeLeafIndex,
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export class BroadcastedPrivateFunction implements PrivateFunction {
|
|
88
|
-
constructor(
|
|
89
|
-
/** Selector of the function. Calculated as the hash of the method name and parameters. The specification of this is not enforced by the protocol. */
|
|
90
|
-
public readonly selector: FunctionSelector,
|
|
91
|
-
/** Artifact metadata hash */
|
|
92
|
-
public readonly metadataHash: Fr,
|
|
93
|
-
/** Hash of the verification key associated to this private function. */
|
|
94
|
-
public readonly vkHash: Fr,
|
|
95
|
-
/** ACIR and Brillig bytecode */
|
|
96
|
-
public readonly bytecode: Buffer,
|
|
97
|
-
) {}
|
|
98
|
-
|
|
99
|
-
static fromFields(fields: Fr[] | FieldReader) {
|
|
100
|
-
const reader = FieldReader.asReader(fields);
|
|
101
|
-
const selector = FunctionSelector.fromField(reader.readField());
|
|
102
|
-
const metadataHash = reader.readField();
|
|
103
|
-
const vkHash = reader.readField();
|
|
104
|
-
// The '* 1' removes the 'Type instantiation is excessively deep and possibly infinite. ts(2589)' err
|
|
105
|
-
const encodedBytecode = reader.readFieldArray(MAX_PACKED_BYTECODE_SIZE_PER_PRIVATE_FUNCTION_IN_FIELDS * 1);
|
|
106
|
-
const bytecode = bufferFromFields(encodedBytecode);
|
|
107
|
-
return new BroadcastedPrivateFunction(selector, metadataHash, vkHash, bytecode);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ARTIFACT_FUNCTION_TREE_MAX_HEIGHT,
|
|
3
|
-
CONTRACT_CLASS_REGISTRY_UTILITY_FUNCTION_BROADCASTED_MAGIC_VALUE,
|
|
4
|
-
MAX_PACKED_BYTECODE_SIZE_PER_UTILITY_FUNCTION_IN_FIELDS,
|
|
5
|
-
} from '@aztec/constants';
|
|
6
|
-
import { removeArrayPaddingEnd } from '@aztec/foundation/collection';
|
|
7
|
-
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
8
|
-
import type { Tuple } from '@aztec/foundation/serialize';
|
|
9
|
-
import { FieldReader } from '@aztec/foundation/serialize';
|
|
10
|
-
import { FunctionSelector, bufferFromFields } from '@aztec/stdlib/abi';
|
|
11
|
-
import type { UtilityFunction, UtilityFunctionWithMembershipProof } from '@aztec/stdlib/contract';
|
|
12
|
-
import type { ContractClassLog } from '@aztec/stdlib/logs';
|
|
13
|
-
|
|
14
|
-
import { ProtocolContractAddress } from '../protocol_contract_data.js';
|
|
15
|
-
|
|
16
|
-
/** Event emitted from the ContractClassRegistry. */
|
|
17
|
-
export class UtilityFunctionBroadcastedEvent {
|
|
18
|
-
constructor(
|
|
19
|
-
public readonly contractClassId: Fr,
|
|
20
|
-
public readonly artifactMetadataHash: Fr,
|
|
21
|
-
public readonly privateFunctionsArtifactTreeRoot: Fr,
|
|
22
|
-
public readonly artifactFunctionTreeSiblingPath: Tuple<Fr, typeof ARTIFACT_FUNCTION_TREE_MAX_HEIGHT>,
|
|
23
|
-
public readonly artifactFunctionTreeLeafIndex: number,
|
|
24
|
-
public readonly utilityFunction: BroadcastedUtilityFunction,
|
|
25
|
-
) {}
|
|
26
|
-
|
|
27
|
-
static isUtilityFunctionBroadcastedEvent(log: ContractClassLog) {
|
|
28
|
-
return (
|
|
29
|
-
log.contractAddress.equals(ProtocolContractAddress.ContractClassRegistry) &&
|
|
30
|
-
log.fields.fields[0].toBigInt() === CONTRACT_CLASS_REGISTRY_UTILITY_FUNCTION_BROADCASTED_MAGIC_VALUE
|
|
31
|
-
);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
static fromLog(log: ContractClassLog) {
|
|
35
|
-
const reader = new FieldReader(log.fields.fields.slice(1));
|
|
36
|
-
const event = UtilityFunctionBroadcastedEvent.fromFields(reader);
|
|
37
|
-
while (!reader.isFinished()) {
|
|
38
|
-
const field = reader.readField();
|
|
39
|
-
if (!field.isZero()) {
|
|
40
|
-
throw new Error(`Unexpected data after parsing UtilityFunctionBroadcastedEvent: ${field.toString()}`);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return event;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
static fromFields(fields: Fr[] | FieldReader) {
|
|
48
|
-
const reader = FieldReader.asReader(fields);
|
|
49
|
-
const contractClassId = reader.readField();
|
|
50
|
-
const artifactMetadataHash = reader.readField();
|
|
51
|
-
const privateFunctionsArtifactTreeRoot = reader.readField();
|
|
52
|
-
const artifactFunctionTreeSiblingPath = reader.readFieldArray(ARTIFACT_FUNCTION_TREE_MAX_HEIGHT);
|
|
53
|
-
const artifactFunctionTreeLeafIndex = reader.readField().toNumber();
|
|
54
|
-
const utilityFunction = BroadcastedUtilityFunction.fromFields(reader);
|
|
55
|
-
|
|
56
|
-
return new UtilityFunctionBroadcastedEvent(
|
|
57
|
-
contractClassId,
|
|
58
|
-
artifactMetadataHash,
|
|
59
|
-
privateFunctionsArtifactTreeRoot,
|
|
60
|
-
artifactFunctionTreeSiblingPath,
|
|
61
|
-
artifactFunctionTreeLeafIndex,
|
|
62
|
-
utilityFunction,
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
toFunctionWithMembershipProof(): UtilityFunctionWithMembershipProof {
|
|
67
|
-
// We should be able to safely remove the zero elements that pad the variable-length sibling path,
|
|
68
|
-
// since a sibling with value zero can only occur on the tree leaves, so the sibling path will never end
|
|
69
|
-
// in a zero. The only exception is a tree with depth 2 with one non-zero leaf, where the sibling path would
|
|
70
|
-
// be a single zero element, but in that case the artifact tree should be just the single leaf.
|
|
71
|
-
const artifactTreeSiblingPath = removeArrayPaddingEnd(this.artifactFunctionTreeSiblingPath, Fr.isZero);
|
|
72
|
-
return {
|
|
73
|
-
...this.utilityFunction,
|
|
74
|
-
bytecode: this.utilityFunction.bytecode,
|
|
75
|
-
functionMetadataHash: this.utilityFunction.metadataHash,
|
|
76
|
-
artifactMetadataHash: this.artifactMetadataHash,
|
|
77
|
-
privateFunctionsArtifactTreeRoot: this.privateFunctionsArtifactTreeRoot,
|
|
78
|
-
artifactTreeSiblingPath,
|
|
79
|
-
artifactTreeLeafIndex: this.artifactFunctionTreeLeafIndex,
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export class BroadcastedUtilityFunction implements UtilityFunction {
|
|
85
|
-
constructor(
|
|
86
|
-
/** Selector of the function. Calculated as the hash of the method name and parameters. The specification of this is not enforced by the protocol. */
|
|
87
|
-
public readonly selector: FunctionSelector,
|
|
88
|
-
/** Artifact metadata hash */
|
|
89
|
-
public readonly metadataHash: Fr,
|
|
90
|
-
/** Brillig bytecode */
|
|
91
|
-
public readonly bytecode: Buffer,
|
|
92
|
-
) {}
|
|
93
|
-
|
|
94
|
-
static fromFields(fields: Fr[] | FieldReader) {
|
|
95
|
-
const reader = FieldReader.asReader(fields);
|
|
96
|
-
const selector = FunctionSelector.fromField(reader.readField());
|
|
97
|
-
const metadataHash = reader.readField();
|
|
98
|
-
// The '* 1' removes the 'Type instantiation is excessively deep and possibly infinite. ts(2589)' err
|
|
99
|
-
const encodedBytecode = reader.readFieldArray(MAX_PACKED_BYTECODE_SIZE_PER_UTILITY_FUNCTION_IN_FIELDS * 1);
|
|
100
|
-
const bytecode = bufferFromFields(encodedBytecode);
|
|
101
|
-
return new BroadcastedUtilityFunction(selector, metadataHash, bytecode);
|
|
102
|
-
}
|
|
103
|
-
}
|