Skip to content

Commit

Permalink
feat: sequencer cast votes (#9247)
Browse files Browse the repository at this point in the history
Update to make the sequencer cast votes when it is considering block production.
  • Loading branch information
LHerskind authored Oct 24, 2024
1 parent 407f8b4 commit bd05d87
Show file tree
Hide file tree
Showing 45 changed files with 723 additions and 385 deletions.
8 changes: 7 additions & 1 deletion cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"acvm",
"addrs",
"alphanet",
"Apella",
"archiver",
"assignement",
"asyncify",
Expand Down Expand Up @@ -101,6 +102,7 @@
"fullpath",
"fuzzer",
"fuzzers",
"Gerousia",
"gitmodules",
"gitrepo",
"Gossipable",
Expand Down Expand Up @@ -167,6 +169,7 @@
"nodebuffer",
"noirc",
"noirup",
"Nomismatokopio",
"nullifer",
"offchain",
"onchain",
Expand Down Expand Up @@ -247,6 +250,7 @@
"subrepo",
"subroot",
"suyash",
"Sysstia",
"templating",
"tldr",
"toplevel",
Expand Down Expand Up @@ -314,5 +318,7 @@
"lib",
"*.cmake"
],
"flagWords": ["anonymous"]
"flagWords": [
"anonymous"
]
}
1 change: 1 addition & 0 deletions l1-contracts/.rebuild_patterns
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
^l1-contracts/src/.*\.sol$
^l1-contracts/test/governance/scenario/NewGerousiaPayload.sol$
36 changes: 36 additions & 0 deletions l1-contracts/terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,39 @@ variable "FEE_JUICE_PORTAL_CONTRACT_ADDRESS" {
output "FEE_JUICE_PORTAL_CONTRACT_ADDRESS" {
value = var.FEE_JUICE_PORTAL_CONTRACT_ADDRESS
}

variable "NOMISMATOKOPIO_CONTRACT_ADDRESS" {
type = string
default = ""
}

output "NOMISMATOKOPIO_CONTRACT_ADDRESS" {
value = var.NOMISMATOKOPIO_CONTRACT_ADDRESS
}

variable "SYSSTIA_CONTRACT_ADDRESS" {
type = string
default = ""
}

output "SYSSTIA_CONTRACT_ADDRESS" {
value = var.SYSSTIA_CONTRACT_ADDRESS
}

variable "GEROUSIA_CONTRACT_ADDRESS" {
type = string
default = ""
}

output "GEROUSIA_CONTRACT_ADDRESS" {
value = var.GEROUSIA_CONTRACT_ADDRESS
}

variable "APELLA_CONTRACT_ADDRESS" {
type = string
default = ""
}

output "APELLA_CONTRACT_ADDRESS" {
value = var.APELLA_CONTRACT_ADDRESS
}
35 changes: 35 additions & 0 deletions l1-contracts/test/governance/scenario/NewGerousiaPayload.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity >=0.8.27;

import {IPayload} from "@aztec/governance/interfaces/IPayload.sol";
import {IRegistry} from "@aztec/governance/interfaces/IRegistry.sol";
import {Apella} from "@aztec/governance/Apella.sol";
import {Gerousia} from "@aztec/governance/Gerousia.sol";

/**
* @title NewGerousiaPayload
* @author Aztec Labs
* @notice A payload that upgrades the Gerousia contract to a new version.
*/
contract NewGerousiaPayload is IPayload {
IRegistry public immutable REGISTRY;
address public immutable NEW_GEROUSIA;

constructor(IRegistry _registry) {
REGISTRY = _registry;
NEW_GEROUSIA = address(new Gerousia(_registry, 667, 1000));
}

function getActions() external view override(IPayload) returns (IPayload.Action[] memory) {
IPayload.Action[] memory res = new IPayload.Action[](1);

Apella apella = Apella(REGISTRY.getApella());

res[0] = Action({
target: address(apella),
data: abi.encodeWithSelector(apella.updateGerousia.selector, NEW_GEROUSIA)
});

return res;
}
}
30 changes: 1 addition & 29 deletions l1-contracts/test/governance/scenario/UpgradeGerousia.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ pragma solidity >=0.8.27;
import {IPayload} from "@aztec/governance/interfaces/IPayload.sol";
import {TestBase} from "@test/base/Base.sol";
import {IMintableERC20} from "@aztec/governance/interfaces/IMintableERC20.sol";
import {IRegistry} from "@aztec/governance/interfaces/IRegistry.sol";
import {Rollup} from "@aztec/core/Rollup.sol";
import {Apella} from "@aztec/governance/Apella.sol";
import {Gerousia} from "@aztec/governance/Gerousia.sol";
Expand All @@ -17,34 +16,7 @@ import {MockFeeJuicePortal} from "@aztec/mock/MockFeeJuicePortal.sol";
import {Slot} from "@aztec/core/libraries/TimeMath.sol";
import {ProposalLib} from "@aztec/governance/libraries/ProposalLib.sol";
import {Errors} from "@aztec/governance/libraries/Errors.sol";

/**
* @title NewGerousiaPayload
* @author Aztec Labs
* @notice A payload that upgrades the Gerousia contract to a new version.
*/
contract NewGerousiaPayload is IPayload {
IRegistry public immutable REGISTRY;
address public immutable NEW_GEROUSIA;

constructor(IRegistry _registry) {
REGISTRY = _registry;
NEW_GEROUSIA = address(new Gerousia(_registry, 667, 1000));
}

function getActions() external view override(IPayload) returns (IPayload.Action[] memory) {
IPayload.Action[] memory res = new IPayload.Action[](1);

Apella apella = Apella(REGISTRY.getApella());

res[0] = Action({
target: address(apella),
data: abi.encodeWithSelector(apella.updateGerousia.selector, NEW_GEROUSIA)
});

return res;
}
}
import {NewGerousiaPayload} from "./NewGerousiaPayload.sol";

/**
* @title UpgradeGerousiaTest
Expand Down
9 changes: 8 additions & 1 deletion spartan/aztec-network/files/config/config-prover-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ inbox_address=$(echo "$output" | grep -oP 'L1 -> L2 Inbox Address: \K0x[a-fA-F0-
outbox_address=$(echo "$output" | grep -oP 'L2 -> L1 Outbox Address: \K0x[a-fA-F0-9]{40}')
fee_juice_address=$(echo "$output" | grep -oP 'Fee Juice Address: \K0x[a-fA-F0-9]{40}')
fee_juice_portal_address=$(echo "$output" | grep -oP 'Fee Juice Portal Address: \K0x[a-fA-F0-9]{40}')

nomismatokopio_address=$(echo "$output" | grep -oP 'Nomismatokopio Address: \K0x[a-fA-F0-9]{40}')
sysstia_address=$(echo "$output" | grep -oP 'Sysstia Address: \K0x[a-fA-F0-9]{40}')
gerousia_address=$(echo "$output" | grep -oP 'Gerousia Address: \K0x[a-fA-F0-9]{40}')
apella_address=$(echo "$output" | grep -oP 'Apella Address: \K0x[a-fA-F0-9]{40}')

# Write the addresses to a file in the shared volume
cat <<EOF > /shared/contracts.env
Expand All @@ -27,6 +30,10 @@ export INBOX_CONTRACT_ADDRESS=$inbox_address
export OUTBOX_CONTRACT_ADDRESS=$outbox_address
export FEE_JUICE_CONTRACT_ADDRESS=$fee_juice_address
export FEE_JUICE_PORTAL_CONTRACT_ADDRESS=$fee_juice_portal_address
export NOMISMATOKOPIO_CONTRACT_ADDRESS=$nomismatokopio_address
export SYSSTIA_CONTRACT_ADDRESS=$sysstia_address
export GEROUSIA_CONTRACT_ADDRESS=$gerousia_address
export APELLA_CONTRACT_ADDRESS=$apella_address
EOF

cat /shared/contracts.env
9 changes: 8 additions & 1 deletion spartan/aztec-network/files/config/config-validator-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ inbox_address=$(echo "$output" | grep -oP 'L1 -> L2 Inbox Address: \K0x[a-fA-F0-
outbox_address=$(echo "$output" | grep -oP 'L2 -> L1 Outbox Address: \K0x[a-fA-F0-9]{40}')
fee_juice_address=$(echo "$output" | grep -oP 'Fee Juice Address: \K0x[a-fA-F0-9]{40}')
fee_juice_portal_address=$(echo "$output" | grep -oP 'Fee Juice Portal Address: \K0x[a-fA-F0-9]{40}')

nomismatokopio_address=$(echo "$output" | grep -oP 'Nomismatokopio Address: \K0x[a-fA-F0-9]{40}')
sysstia_address=$(echo "$output" | grep -oP 'Sysstia Address: \K0x[a-fA-F0-9]{40}')
gerousia_address=$(echo "$output" | grep -oP 'Gerousia Address: \K0x[a-fA-F0-9]{40}')
apella_address=$(echo "$output" | grep -oP 'Apella Address: \K0x[a-fA-F0-9]{40}')
# We assume that there is an env var set for validator keys from the config map
# We get the index in the config map from the pod name, which will have the validator index within it

Expand All @@ -33,6 +36,10 @@ export INBOX_CONTRACT_ADDRESS=$inbox_address
export OUTBOX_CONTRACT_ADDRESS=$outbox_address
export FEE_JUICE_CONTRACT_ADDRESS=$fee_juice_address
export FEE_JUICE_PORTAL_CONTRACT_ADDRESS=$fee_juice_portal_address
export NOMISMATOKOPIO_CONTRACT_ADDRESS=$nomismatokopio_address
export SYSSTIA_CONTRACT_ADDRESS=$sysstia_address
export GEROUSIA_CONTRACT_ADDRESS=$gerousia_address
export APELLA_CONTRACT_ADDRESS=$apella_address
export VALIDATOR_PRIVATE_KEY=$private_key
export L1_PRIVATE_KEY=$private_key
export SEQ_PUBLISHER_PRIVATE_KEY=$private_key
Expand Down
8 changes: 8 additions & 0 deletions spartan/aztec-network/files/config/deploy-l1-contracts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ inbox_address=$(echo "$output" | grep -oP 'L1 -> L2 Inbox Address: \K0x[a-fA-F0-
outbox_address=$(echo "$output" | grep -oP 'L2 -> L1 Outbox Address: \K0x[a-fA-F0-9]{40}')
fee_juice_address=$(echo "$output" | grep -oP 'Fee Juice Address: \K0x[a-fA-F0-9]{40}')
fee_juice_portal_address=$(echo "$output" | grep -oP 'Fee Juice Portal Address: \K0x[a-fA-F0-9]{40}')
nomismatokopio_address=$(echo "$output" | grep -oP 'Nomismatokopio Address: \K0x[a-fA-F0-9]{40}')
sysstia_address=$(echo "$output" | grep -oP 'Sysstia Address: \K0x[a-fA-F0-9]{40}')
gerousia_address=$(echo "$output" | grep -oP 'Gerousia Address: \K0x[a-fA-F0-9]{40}')
apella_address=$(echo "$output" | grep -oP 'Apella Address: \K0x[a-fA-F0-9]{40}')

# Write the addresses to a file in the shared volume
cat <<EOF > /shared/contracts.env
Expand All @@ -30,6 +34,10 @@ export INBOX_CONTRACT_ADDRESS=$inbox_address
export OUTBOX_CONTRACT_ADDRESS=$outbox_address
export FEE_JUICE_CONTRACT_ADDRESS=$fee_juice_address
export FEE_JUICE_PORTAL_CONTRACT_ADDRESS=$fee_juice_portal_address
export NOMISMATOKOPIO_CONTRACT_ADDRESS=$nomismatokopio_address
export SYSSTIA_CONTRACT_ADDRESS=$sysstia_address
export GEROUSIA_CONTRACT_ADDRESS=$gerousia_address
export APELLA_CONTRACT_ADDRESS=$apella_address
EOF

cat /shared/contracts.env
4 changes: 3 additions & 1 deletion spartan/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ From the repo root:
# one time setup
./spartan/scripts/setup_local_k8s.sh
./spartan/scripts/create_k8s_dashboard.sh
./spartan/metrics/install.sh
# Go into spartan/metrics
./install.sh
# forward ports (in separate terminals)
./spartan/scripts/forward_k8s_dashboard.sh
Expand Down
1 change: 0 additions & 1 deletion yarn-project/aztec-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
"@aztec/ethereum": "workspace:^",
"@aztec/foundation": "workspace:^",
"@aztec/kv-store": "workspace:^",
"@aztec/l1-artifacts": "workspace:^",
"@aztec/merkle-tree": "workspace:^",
"@aztec/p2p": "workspace:^",
"@aztec/protocol-contracts": "workspace:^",
Expand Down
3 changes: 0 additions & 3 deletions yarn-project/aztec-node/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@
{
"path": "../kv-store"
},
{
"path": "../l1-artifacts"
},
{
"path": "../merkle-tree"
},
Expand Down
7 changes: 1 addition & 6 deletions yarn-project/aztec.js/src/api/ethereum.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
export {
deployL1Contract,
deployL1Contracts,
DeployL1Contracts,
L1ContractArtifactsForDeployment,
} from '@aztec/ethereum';
export { deployL1Contract, deployL1Contracts, DeployL1Contracts } from '@aztec/ethereum';
4 changes: 4 additions & 0 deletions yarn-project/aztec.js/src/contract/contract.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ describe('Contract Class', () => {
outboxAddress: EthAddress.random(),
feeJuiceAddress: EthAddress.random(),
feeJuicePortalAddress: EthAddress.random(),
apellaAddress: EthAddress.random(),
nomismatokopioAddress: EthAddress.random(),
sysstiaAddress: EthAddress.random(),
gerousiaAddress: EthAddress.random(),
};
const mockNodeInfo: NodeInfo = {
nodeVersion: 'vx.x.x',
Expand Down
7 changes: 1 addition & 6 deletions yarn-project/aztec.js/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,7 @@ export { elapsed } from '@aztec/foundation/timer';
export { type FieldsOf } from '@aztec/foundation/types';
export { fileURLToPath } from '@aztec/foundation/url';

export {
type DeployL1Contracts,
type L1ContractArtifactsForDeployment,
deployL1Contract,
deployL1Contracts,
} from '@aztec/ethereum';
export { type DeployL1Contracts, deployL1Contract, deployL1Contracts } from '@aztec/ethereum';

// Start of section that exports public api via granular api.
// Here you *can* do `export *` as the granular api defacto exports things explicitly.
Expand Down
1 change: 0 additions & 1 deletion yarn-project/aztec/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
"@aztec/ethereum": "workspace:^",
"@aztec/foundation": "workspace:^",
"@aztec/kv-store": "workspace:^",
"@aztec/l1-artifacts": "workspace:^",
"@aztec/noir-contracts.js": "workspace:^",
"@aztec/noir-protocol-circuits-types": "workspace:^",
"@aztec/p2p": "workspace:^",
Expand Down
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
Loading

0 comments on commit bd05d87

Please sign in to comment.