@@ -33,6 +33,7 @@ import {
33
33
type PublicFunction ,
34
34
UnconstrainedFunctionBroadcastedEvent ,
35
35
type UnconstrainedFunctionWithMembershipProof ,
36
+ computePublicBytecodeCommitment ,
36
37
isValidPrivateFunctionMembershipProof ,
37
38
isValidUnconstrainedFunctionMembershipProof ,
38
39
} from '@aztec/circuits.js' ;
@@ -706,6 +707,10 @@ export class Archiver implements ArchiveSource {
706
707
return this . store . getContractClass ( id ) ;
707
708
}
708
709
710
+ public getBytecodeCommitment ( id : Fr ) : Promise < Fr | undefined > {
711
+ return this . store . getBytecodeCommitment ( id ) ;
712
+ }
713
+
709
714
public getContract ( address : AztecAddress ) : Promise < ContractInstanceWithAddress | undefined > {
710
715
return this . store . getContractInstance ( address ) ;
711
716
}
@@ -734,7 +739,11 @@ export class Archiver implements ArchiveSource {
734
739
735
740
// TODO(#10007): Remove this method
736
741
async addContractClass ( contractClass : ContractClassPublic ) : Promise < void > {
737
- await this . store . addContractClasses ( [ contractClass ] , 0 ) ;
742
+ await this . store . addContractClasses (
743
+ [ contractClass ] ,
744
+ [ computePublicBytecodeCommitment ( contractClass . packedBytecode ) ] ,
745
+ 0 ,
746
+ ) ;
738
747
return ;
739
748
}
740
749
@@ -746,6 +755,10 @@ export class Archiver implements ArchiveSource {
746
755
return this . store . getContractArtifact ( address ) ;
747
756
}
748
757
758
+ getContractFunctionName ( address : AztecAddress , selector : FunctionSelector ) : Promise < string | undefined > {
759
+ return this . store . getContractFunctionName ( address , selector ) ;
760
+ }
761
+
749
762
async getL2Tips ( ) : Promise < L2Tips > {
750
763
const [ latestBlockNumber , provenBlockNumber ] = await Promise . all ( [
751
764
this . getBlockNumber ( ) ,
@@ -804,8 +817,12 @@ class ArchiverStoreHelper
804
817
constructor ( private readonly store : ArchiverDataStore ) { }
805
818
806
819
// TODO(#10007): Remove this method
807
- addContractClasses ( contractClasses : ContractClassPublic [ ] , blockNum : number ) : Promise < boolean > {
808
- return this . store . addContractClasses ( contractClasses , blockNum ) ;
820
+ addContractClasses (
821
+ contractClasses : ContractClassPublic [ ] ,
822
+ bytecodeCommitments : Fr [ ] ,
823
+ blockNum : number ,
824
+ ) : Promise < boolean > {
825
+ return this . store . addContractClasses ( contractClasses , bytecodeCommitments , blockNum ) ;
809
826
}
810
827
811
828
/**
@@ -820,7 +837,12 @@ class ArchiverStoreHelper
820
837
if ( contractClasses . length > 0 ) {
821
838
contractClasses . forEach ( c => this . #log. verbose ( `Registering contract class ${ c . id . toString ( ) } ` ) ) ;
822
839
if ( operation == Operation . Store ) {
823
- return await this . store . addContractClasses ( contractClasses , blockNum ) ;
840
+ // TODO: Will probably want to create some worker threads to compute these bytecode commitments as they are expensive
841
+ return await this . store . addContractClasses (
842
+ contractClasses ,
843
+ contractClasses . map ( x => computePublicBytecodeCommitment ( x . packedBytecode ) ) ,
844
+ blockNum ,
845
+ ) ;
824
846
} else if ( operation == Operation . Delete ) {
825
847
return await this . store . deleteContractClasses ( contractClasses , blockNum ) ;
826
848
}
@@ -1028,6 +1050,9 @@ class ArchiverStoreHelper
1028
1050
getContractClass ( id : Fr ) : Promise < ContractClassPublic | undefined > {
1029
1051
return this . store . getContractClass ( id ) ;
1030
1052
}
1053
+ getBytecodeCommitment ( contractClassId : Fr ) : Promise < Fr | undefined > {
1054
+ return this . store . getBytecodeCommitment ( contractClassId ) ;
1055
+ }
1031
1056
getContractInstance ( address : AztecAddress ) : Promise < ContractInstanceWithAddress | undefined > {
1032
1057
return this . store . getContractInstance ( address ) ;
1033
1058
}
@@ -1040,6 +1065,9 @@ class ArchiverStoreHelper
1040
1065
getContractArtifact ( address : AztecAddress ) : Promise < ContractArtifact | undefined > {
1041
1066
return this . store . getContractArtifact ( address ) ;
1042
1067
}
1068
+ getContractFunctionName ( address : AztecAddress , selector : FunctionSelector ) : Promise < string | undefined > {
1069
+ return this . store . getContractFunctionName ( address , selector ) ;
1070
+ }
1043
1071
getTotalL1ToL2MessageCount ( ) : Promise < bigint > {
1044
1072
return this . store . getTotalL1ToL2MessageCount ( ) ;
1045
1073
}
0 commit comments