Skip to content

Commit

Permalink
chore: delete faulty unnecessary address extraction
Browse files Browse the repository at this point in the history
  • Loading branch information
LHerskind committed Oct 24, 2024
1 parent 81d1478 commit 009f1a0
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 37 deletions.
3 changes: 1 addition & 2 deletions yarn-project/aztec/src/cli/cmds/start_node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
import { mnemonicToAccount, privateKeyToAccount } from 'viem/accounts';

import { createAztecNode, deployContractsToL1 } from '../../sandbox.js';
import { extractL1ContractAddresses, extractNamespacedOptions, extractRelevantOptions } from '../util.js';
import { extractNamespacedOptions, extractRelevantOptions } from '../util.js';

export const startNode = async (
options: any,
Expand All @@ -28,7 +28,6 @@ export const startNode = async (
// All options that are relevant to the Aztec Node
const nodeConfig = {
...extractRelevantOptions(options, aztecNodeConfigMappings, 'node'),
l1Contracts: extractL1ContractAddresses(options),
};

if (options.proverNode) {
Expand Down
3 changes: 1 addition & 2 deletions yarn-project/aztec/src/cli/cmds/start_prover_node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { createAndStartTelemetryClient, telemetryClientConfigMappings } from '@a

import { mnemonicToAccount } from 'viem/accounts';

import { extractL1ContractAddresses, extractRelevantOptions } from '../util.js';
import { extractRelevantOptions } from '../util.js';

export const startProverNode = async (
options: any,
Expand All @@ -32,7 +32,6 @@ export const startProverNode = async (
const proverConfig = {
...getProverNodeConfigFromEnv(), // get default config from env
...extractRelevantOptions<ProverNodeConfig>(options, proverNodeConfigMappings, 'proverNode'), // override with command line options
l1Contracts: extractL1ContractAddresses(options),
};

if (!options.archiver && !proverConfig.archiverUrl) {
Expand Down
19 changes: 0 additions & 19 deletions yarn-project/aztec/src/cli/util.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { type AccountManager, type Fr } from '@aztec/aztec.js';
import { type L1ContractAddresses, l1ContractsNames } from '@aztec/ethereum';
import { type ConfigMappingsType } from '@aztec/foundation/config';
import { EthAddress } from '@aztec/foundation/eth-address';
import { type ServerList } from '@aztec/foundation/json-rpc/server';
import { type LogFn } from '@aztec/foundation/log';
import { type PXEService } from '@aztec/pxe';
Expand Down Expand Up @@ -176,23 +174,6 @@ export const extractNamespacedOptions = (options: Record<string, any>, namespace
return namespacedOptions;
};

/**
* Extracts L1 contract addresses from a key-value map.
* @param options - Key-value map of options.
* @returns L1 contract addresses.
*/
export const extractL1ContractAddresses = (options: Record<string, any>): L1ContractAddresses => {
const contractAddresses: L1ContractAddresses = l1ContractsNames.reduce((acc, cn) => {
const key = cn as keyof L1ContractAddresses;
if (options[key]) {
return { ...acc, [key]: EthAddress.fromString(options[key]) };
}
return acc;
}, {} as L1ContractAddresses);

return contractAddresses;
};

/**
* Extracts relevant options from a key-value map.
* @template T - The type of the relevant options.
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

20 changes: 13 additions & 7 deletions yarn-project/sequencer-client/src/publisher/l1-publisher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,10 @@ export class L1Publisher {
typeof RollupAbi,
WalletClient<HttpTransport, chains.Chain, PrivateKeyAccount>
>;
private gerousiaContract: GetContractReturnType<
private gerousiaContract?: GetContractReturnType<
typeof GerousiaAbi,
WalletClient<HttpTransport, chains.Chain, PrivateKeyAccount>
>;
> = undefined;

private publicClient: PublicClient<HttpTransport, chains.Chain>;
private walletClient: WalletClient<HttpTransport, chains.Chain, PrivateKeyAccount>;
Expand Down Expand Up @@ -188,11 +188,13 @@ export class L1Publisher {
client: this.walletClient,
});

this.gerousiaContract = getContract({
address: getAddress(l1Contracts.gerousiaAddress.toString()),
abi: GerousiaAbi,
client: this.walletClient,
});
if (l1Contracts.gerousiaAddress) {
this.gerousiaContract = getContract({
address: getAddress(l1Contracts.gerousiaAddress.toString()),
abi: GerousiaAbi,
client: this.walletClient,
});
}
}

public getPayLoad() {
Expand Down Expand Up @@ -379,6 +381,10 @@ export class L1Publisher {
return false;
}

if (!this.gerousiaContract) {
return false;
}

if (this.myLastVote >= slotNumber) {
return false;
}
Expand Down
6 changes: 3 additions & 3 deletions yarn-project/sequencer-client/src/sequencer/sequencer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ describe('sequencer', () => {
blockBuilder.setBlockCompleted.mockResolvedValue(block);
publisher.proposeL2Block.mockResolvedValueOnce(true);

globalVariableBuilder.buildGlobalVariables.mockResolvedValueOnce(mockedGlobalVariables);
globalVariableBuilder.buildGlobalVariables.mockResolvedValue(mockedGlobalVariables);

sequencer.updateConfig({ minTxsPerBlock: 4 });

Expand Down Expand Up @@ -402,7 +402,7 @@ describe('sequencer', () => {
blockBuilder.setBlockCompleted.mockResolvedValue(block);
publisher.proposeL2Block.mockResolvedValueOnce(true);

globalVariableBuilder.buildGlobalVariables.mockResolvedValueOnce(mockedGlobalVariables);
globalVariableBuilder.buildGlobalVariables.mockResolvedValue(mockedGlobalVariables);

sequencer.updateConfig({ minTxsPerBlock: 4 });

Expand Down Expand Up @@ -443,7 +443,7 @@ describe('sequencer', () => {
blockBuilder.setBlockCompleted.mockResolvedValue(block);
publisher.proposeL2Block.mockResolvedValueOnce(true);

globalVariableBuilder.buildGlobalVariables.mockResolvedValueOnce(mockedGlobalVariables);
globalVariableBuilder.buildGlobalVariables.mockResolvedValue(mockedGlobalVariables);

sequencer.updateConfig({ minTxsPerBlock: 4 });

Expand Down

0 comments on commit 009f1a0

Please sign in to comment.