-
Notifications
You must be signed in to change notification settings - Fork 310
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce classes and instances and populate in node
- Loading branch information
1 parent
5006228
commit 9a98343
Showing
26 changed files
with
650 additions
and
7 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
29 changes: 29 additions & 0 deletions
29
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,29 @@ | ||
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()); | ||
if (!contractClass) { | ||
return undefined; | ||
} | ||
return { ...SerializableContractClass.fromBuffer(contractClass), id }; | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
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,29 @@ | ||
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()); | ||
if (!contractInstance) { | ||
return undefined; | ||
} | ||
return { ...SerializableContractInstance.fromBuffer(contractInstance), 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.