forked from visoftsolutions/noir_rs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Contract classes and instances (AztecProtocol#4192)
Adds `ContractInstance` and `ContractClass` interfaces as specified in the yellow paper, with the addition of `PublicFunctions` in `ContractClasses` until we remove them as first class citizens from the protocol. Also includes hashes for contract classes and artifacts. Stores contract classes and instances in the node in new tables, as well as artifacts and instances in the pxe. Fixes AztecProtocol#4053
- Loading branch information
1 parent
2c6ce71
commit b2fb0ec
Showing
44 changed files
with
2,729 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
yarn-project/archiver/src/archiver/kv_archiver_store/contract_class_store.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { Fr } from '@aztec/foundation/fields'; | ||
import { AztecKVStore, AztecMap } from '@aztec/kv-store'; | ||
import { ContractClassWithId, SerializableContractClass } from '@aztec/types/contracts'; | ||
|
||
/** | ||
* LMDB implementation of the ArchiverDataStore interface. | ||
*/ | ||
export class ContractClassStore { | ||
#contractClasses: AztecMap<string, Buffer>; | ||
|
||
constructor(db: AztecKVStore) { | ||
this.#contractClasses = db.createMap('archiver_contract_classes'); | ||
} | ||
|
||
addContractClass(contractClass: ContractClassWithId): Promise<boolean> { | ||
return this.#contractClasses.set( | ||
contractClass.id.toString(), | ||
new SerializableContractClass(contractClass).toBuffer(), | ||
); | ||
} | ||
|
||
getContractClass(id: Fr): ContractClassWithId | undefined { | ||
const contractClass = this.#contractClasses.get(id.toString()); | ||
return contractClass && SerializableContractClass.fromBuffer(contractClass).withId(id); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
yarn-project/archiver/src/archiver/kv_archiver_store/contract_instance_store.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { AztecAddress } from '@aztec/circuits.js'; | ||
import { AztecKVStore, AztecMap } from '@aztec/kv-store'; | ||
import { ContractInstanceWithAddress, SerializableContractInstance } from '@aztec/types/contracts'; | ||
|
||
/** | ||
* LMDB implementation of the ArchiverDataStore interface. | ||
*/ | ||
export class ContractInstanceStore { | ||
#contractInstances: AztecMap<string, Buffer>; | ||
|
||
constructor(db: AztecKVStore) { | ||
this.#contractInstances = db.createMap('archiver_contract_instances'); | ||
} | ||
|
||
addContractInstance(contractInstance: ContractInstanceWithAddress): Promise<boolean> { | ||
return this.#contractInstances.set( | ||
contractInstance.address.toString(), | ||
new SerializableContractInstance(contractInstance).toBuffer(), | ||
); | ||
} | ||
|
||
getContractInstance(address: AztecAddress): ContractInstanceWithAddress | undefined { | ||
const contractInstance = this.#contractInstances.get(address.toString()); | ||
return contractInstance && SerializableContractInstance.fromBuffer(contractInstance).withAddress(address); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,9 @@ | |
}, | ||
{ | ||
"path": "../l1-artifacts" | ||
}, | ||
{ | ||
"path": "../types" | ||
} | ||
], | ||
"include": ["src"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.