Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
benesjan committed Jan 30, 2024
1 parent cda2d13 commit a5bd9e1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 26 deletions.
8 changes: 2 additions & 6 deletions yarn-project/aztec-node/src/aztec-node/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import {
PUBLIC_DATA_TREE_HEIGHT,
PublicDataTreeLeafPreimage,
} from '@aztec/circuits.js';
import { computeGlobalsHash, computePublicDataTreeLeafSlot } from '@aztec/circuits.js/abis';
import { computePublicDataTreeLeafSlot } from '@aztec/circuits.js/abis';
import { L1ContractAddresses, createEthereumChain } from '@aztec/ethereum';
import { AztecAddress } from '@aztec/foundation/aztec-address';
import { createDebugLogger } from '@aztec/foundation/log';
Expand Down Expand Up @@ -549,16 +549,12 @@ export class AztecNodeService implements AztecNode {
const blockNumber = (await this.blockSource.getBlockNumber()) + 1;
const newGlobalVariables = await this.globalVariableBuilder.buildGlobalVariables(new Fr(blockNumber));
const prevHeader = (await this.blockSource.getBlock(-1))?.header;
const prevGlobalVariables = prevHeader?.globalVariables ?? GlobalVariables.empty();

// Instantiate merkle trees so uncommitted updates by this simulation are local to it.
// TODO we should be able to remove this after https://github.com/AztecProtocol/aztec-packages/issues/1869
// So simulation of public functions doesn't affect the merkle trees.
const merkleTrees = new MerkleTrees(this.merkleTreesDb, this.log);
const globalVariablesHash = computeGlobalsHash(prevGlobalVariables);
await merkleTrees.init({
globalVariablesHash,
});
await merkleTrees.init(true); // TODO(benesjan): : not sure if correct

const publicProcessorFactory = new PublicProcessorFactory(
merkleTrees.asLatest(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import {
SideEffectLinkedToNoteHash,
StateReference,
} from '@aztec/circuits.js';
import { computeBlockHashWithGlobals, computeContractLeaf } from '@aztec/circuits.js/abis';
import { computeContractLeaf } from '@aztec/circuits.js/abis';
import {
fr,
makeBaseOrMergeRollupPublicInputs,
Expand Down Expand Up @@ -157,14 +157,7 @@ describe('sequencer/solo_block_builder', () => {
};

const updateArchive = async () => {
const blockHash = computeBlockHashWithGlobals(
globalVariables,
rootRollupOutput.header.state.partial.noteHashTree.root,
rootRollupOutput.header.state.partial.nullifierTree.root,
rootRollupOutput.header.state.partial.contractTree.root,
rootRollupOutput.header.state.l1ToL2MessageTree.root,
rootRollupOutput.header.state.partial.publicDataTree.root,
);
const blockHash = rootRollupOutput.header.hash();
await expectsDb.appendLeaves(MerkleTreeId.ARCHIVE, [blockHash.toBuffer()]);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ export class SoloBlockBuilder implements BlockBuilder {
// Update the root trees with the latest data and contract tree roots,
// and validate them against the output of the root circuit simulation
this.debug(`Updating and validating root trees`);
await this.db.updateArchive(globalVariablesHash);
await this.db.updateArchive(rootOutput.header);

await this.validateRootOutput(rootOutput);

Expand Down Expand Up @@ -455,16 +455,7 @@ export class SoloBlockBuilder implements BlockBuilder {
}

protected getHistoricalTreesMembershipWitnessFor(tx: ProcessedTx) {
const header = tx.data.constants.historicalHeader;
// TODO(#3941)
const blockHash = computeBlockHash(
computeGlobalsHash(header.globalVariables),
header.state.partial.noteHashTree.root,
header.state.partial.nullifierTree.root,
header.state.partial.contractTree.root,
header.state.l1ToL2MessageTree.root,
header.state.partial.publicDataTree.root,
);
const blockHash = tx.data.constants.historicalHeader.hash()
return this.getMembershipWitnessFor(blockHash, MerkleTreeId.ARCHIVE, ARCHIVE_HEIGHT);
}

Expand Down

0 comments on commit a5bd9e1

Please sign in to comment.