Set historic tree roots in private circuit inputs#425
Conversation
| public async getTreeRoots(): Promise<Record<MerkleTreeId, Fr>> { | ||
| const getTreeRoot = async (id: MerkleTreeId) => | ||
| Fr.fromBuffer((await this.merkleTreeDB.getTreeInfo(id, false)).root); | ||
| console.log(`NULL TREE`, await getTreeRoot(MerkleTreeId.NULLIFIER_TREE)); |
There was a problem hiding this comment.
Should this console log be removed?
There was a problem hiding this comment.
Most definitely. Good catch.
8e344f4 to
2c2a3db
Compare
|
@PhilWindle I addressed the |
| * Returns the current committed roots for the data trees. | ||
| * @returns the current committed roots for the data trees. | ||
| */ | ||
| public async getTreeRoots(): Promise<Record<MerkleTreeId, Fr>> { |
There was a problem hiding this comment.
This information is actually already available within the AztecRPCServer as part of the L2Block download. I know we are building the Aztec Sandbox but there will come a point where we want to rely on Aztec Node for data as little as possible, so I wonder if it is worth removing this interaction in favour of taking the locally available version?
There was a problem hiding this comment.
Ah, I didn't know that! It makes a lot more sense. I'll add methods to the aztec-rpc Synchroniser to save in memory the latest roots and use those!
2c2a3db to
9811991
Compare
|
@PhilWindle I made the change to fetch the tree roots from the blocks as they are processed by the synchroniser. However, I ran into an issue: the aztec-rpc didn't have the concept of an initial sync, so any tests sending a tx once the rpc is setup would run into empty roots. To work around it, I added an initial sync that fetches the latest roots from the aztec node, which is done only once, and then these are updated as new blocks flow in. However, I'm not sure if there's a deeper problem here: shouldn't the aztec-rpc block sending any txs until it has synced to the top of the chain, so it has processed all nullifiers from the user's accounts? |
Yes, I think it should fully sync before the user starts to send txs etc. |
Do you think we could merge this one as is, and create an issue to track that bigger change? |
Yeah that's fine |
Populate historic tree roots in the inputs to the private circuit, so these are propagated to the private kernel circuit, and are sent with the tx. These are fetched from the aztec node, via a new method that returns all tree roots.
Fixes #424