Skip to content

Commit

Permalink
feat: sequencer cast votes
Browse files Browse the repository at this point in the history
  • Loading branch information
LHerskind committed Oct 24, 2024
1 parent b25b913 commit 2fd2f6a
Show file tree
Hide file tree
Showing 31 changed files with 682 additions and 345 deletions.
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
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
54 changes: 3 additions & 51 deletions yarn-project/aztec/src/sandbox.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,11 @@
#!/usr/bin/env -S node --no-warnings
import { type AztecNodeConfig, AztecNodeService, getConfigEnvVars } from '@aztec/aztec-node';
import { AnvilTestWatcher, EthCheatCodes, SignerlessWallet } from '@aztec/aztec.js';
import { AnvilTestWatcher, EthCheatCodes, SignerlessWallet, retryUntil } from '@aztec/aztec.js';
import { DefaultMultiCallEntrypoint } from '@aztec/aztec.js/entrypoint';
import { type AztecNode } from '@aztec/circuit-types';
import { setupCanonicalL2FeeJuice } from '@aztec/cli/misc';
import {
type DeployL1Contracts,
type L1ContractArtifactsForDeployment,
NULL_KEY,
createEthereumChain,
deployL1Contracts,
} from '@aztec/ethereum';
import { type DeployL1Contracts, NULL_KEY, createEthereumChain, deployL1Contracts } from '@aztec/ethereum';
import { createDebugLogger } from '@aztec/foundation/log';
import { retryUntil } from '@aztec/foundation/retry';
import {
FeeJuicePortalAbi,
FeeJuicePortalBytecode,
InboxAbi,
InboxBytecode,
OutboxAbi,
OutboxBytecode,
RegistryAbi,
RegistryBytecode,
RollupAbi,
RollupBytecode,
TestERC20Abi,
TestERC20Bytecode,
} from '@aztec/l1-artifacts';
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types';
import { ProtocolContractAddress, protocolContractTreeRoot } from '@aztec/protocol-contracts';
import { type PXEServiceConfig, createPXEService, getPXEServiceConfig } from '@aztec/pxe';
Expand Down Expand Up @@ -90,39 +69,12 @@ export async function deployContractsToL1(
contractDeployLogger = logger,
opts: { assumeProvenThroughBlockNumber?: number; salt?: number } = {},
) {
const l1Artifacts: L1ContractArtifactsForDeployment = {
registry: {
contractAbi: RegistryAbi,
contractBytecode: RegistryBytecode,
},
inbox: {
contractAbi: InboxAbi,
contractBytecode: InboxBytecode,
},
outbox: {
contractAbi: OutboxAbi,
contractBytecode: OutboxBytecode,
},
rollup: {
contractAbi: RollupAbi,
contractBytecode: RollupBytecode,
},
feeJuice: {
contractAbi: TestERC20Abi,
contractBytecode: TestERC20Bytecode,
},
feeJuicePortal: {
contractAbi: FeeJuicePortalAbi,
contractBytecode: FeeJuicePortalBytecode,
},
};

const chain = aztecNodeConfig.l1RpcUrl
? createEthereumChain(aztecNodeConfig.l1RpcUrl, aztecNodeConfig.l1ChainId)
: { chainInfo: localAnvil };

const l1Contracts = await waitThenDeploy(aztecNodeConfig, () =>
deployL1Contracts(aztecNodeConfig.l1RpcUrl, hdAccount, chain.chainInfo, contractDeployLogger, l1Artifacts, {
deployL1Contracts(aztecNodeConfig.l1RpcUrl, hdAccount, chain.chainInfo, contractDeployLogger, {
l2FeeJuiceAddress: ProtocolContractAddress.FeeJuice,
vkTreeRoot: getVKTreeRoot(),
protocolContractTreeRoot,
Expand Down
2 changes: 2 additions & 0 deletions yarn-project/circuit-types/src/interfaces/configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,6 @@ export interface SequencerConfig {
maxBlockSizeInBytes?: number;
/** Whether to require every tx to have a fee payer */
enforceFees?: boolean;
/** Payload address to vote for */
gerousiaPayload?: EthAddress;
}
4 changes: 4 additions & 0 deletions yarn-project/cli/src/cmds/l1/deploy_l1_contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,9 @@ export async function deployL1Contracts(
log(`L2 -> L1 Outbox Address: ${l1ContractAddresses.outboxAddress.toString()}`);
log(`Fee Juice Address: ${l1ContractAddresses.feeJuiceAddress.toString()}`);
log(`Fee Juice Portal Address: ${l1ContractAddresses.feeJuicePortalAddress.toString()}`);
log(`Nomismatokopio Address: ${l1ContractAddresses.nomismatokopioAddress.toString()}`);
log(`Sysstia Address: ${l1ContractAddresses.sysstiaAddress.toString()}`);
log(`Gerousia Address: ${l1ContractAddresses.gerousiaAddress.toString()}`);
log(`Apella Address: ${l1ContractAddresses.apellaAddress.toString()}`);
}
}
44 changes: 2 additions & 42 deletions yarn-project/cli/src/utils/aztec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { type ContractArtifact, type FunctionArtifact, loadContractArtifact } from '@aztec/aztec.js/abi';
import { type L1ContractArtifactsForDeployment } from '@aztec/aztec.js/ethereum';
import { type PXE } from '@aztec/circuit-types';
import { type DeployL1Contracts } from '@aztec/ethereum';
import { FunctionType } from '@aztec/foundation/abi';
Expand Down Expand Up @@ -61,56 +60,17 @@ export async function deployAztecContracts(
initialValidators: EthAddress[],
debugLogger: DebugLogger,
): Promise<DeployL1Contracts> {
const {
InboxAbi,
InboxBytecode,
OutboxAbi,
OutboxBytecode,
RegistryAbi,
RegistryBytecode,
RollupAbi,
RollupBytecode,
FeeJuicePortalAbi,
FeeJuicePortalBytecode,
TestERC20Abi,
TestERC20Bytecode,
} = await import('@aztec/l1-artifacts');
const { createEthereumChain, deployL1Contracts } = await import('@aztec/ethereum');
const { mnemonicToAccount, privateKeyToAccount } = await import('viem/accounts');

const account = !privateKey
? mnemonicToAccount(mnemonic!)
: privateKeyToAccount(`${privateKey.startsWith('0x') ? '' : '0x'}${privateKey}` as `0x${string}`);
const chain = createEthereumChain(rpcUrl, chainId);
const l1Artifacts: L1ContractArtifactsForDeployment = {
registry: {
contractAbi: RegistryAbi,
contractBytecode: RegistryBytecode,
},
inbox: {
contractAbi: InboxAbi,
contractBytecode: InboxBytecode,
},
outbox: {
contractAbi: OutboxAbi,
contractBytecode: OutboxBytecode,
},
rollup: {
contractAbi: RollupAbi,
contractBytecode: RollupBytecode,
},
feeJuice: {
contractAbi: TestERC20Abi,
contractBytecode: TestERC20Bytecode,
},
feeJuicePortal: {
contractAbi: FeeJuicePortalAbi,
contractBytecode: FeeJuicePortalBytecode,
},
};

const { getVKTreeRoot } = await import('@aztec/noir-protocol-circuits-types');

return await deployL1Contracts(chain.rpcUrl, account, chain.chainInfo, debugLogger, l1Artifacts, {
return await deployL1Contracts(chain.rpcUrl, account, chain.chainInfo, debugLogger, {
l2FeeJuiceAddress: ProtocolContractAddress.FeeJuice,
vkTreeRoot: getVKTreeRoot(),
protocolContractTreeRoot,
Expand Down
Loading

0 comments on commit 2fd2f6a

Please sign in to comment.