Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions l1-contracts/src/core/Rollup.sol
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,10 @@ contract Rollup is IStaking, IValidatorSelection, IRollup, RollupCore {
return rollupStore.provingCostPerMana;
}

function getSlashFactory() external view override(IRollup) returns (address) {
return rollupStore.slashFactory;
}

function getProvingCostPerManaInFeeAsset()
external
view
Expand Down
4 changes: 4 additions & 0 deletions l1-contracts/src/core/RollupCore.sol
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,10 @@ contract RollupCore is
return accumulatedRewards;
}

function setSlashFactory(address _slashFactory) external override(IRollupCore) onlyOwner {
rollupStore.slashFactory = _slashFactory;
}

function deposit(address _attester, address _proposer, address _withdrawer, uint256 _amount)
external
override(IStakingCore)
Expand Down
5 changes: 5 additions & 0 deletions l1-contracts/src/core/interfaces/IRollup.sol
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ struct EpochRewards {
// The below blobPublicInputsHashes are filled when proposing a block, then used to verify an epoch proof.
// TODO(#8955): When implementing batched kzg proofs, store one instance per epoch rather than block
struct RollupStore {
address slashFactory;
mapping(uint256 blockNumber => BlockLog log) blocks;
mapping(uint256 blockNumber => bytes32) blobPublicInputsHashes;
ChainTips tips;
Expand Down Expand Up @@ -109,6 +110,8 @@ interface IRollupCore {

function setProvingCostPerMana(EthValue _provingCostPerMana) external;

function setSlashFactory(address _slashFactory) external;

function propose(
ProposeArgs calldata _args,
Signature[] memory _signatures,
Expand Down Expand Up @@ -201,4 +204,6 @@ interface IRollup is IRollupCore {
function getProvingCostPerManaInEth() external view returns (EthValue);

function getProvingCostPerManaInFeeAsset() external view returns (FeeAssetValue);

function getSlashFactory() external view returns (address);
}
10 changes: 5 additions & 5 deletions l1-contracts/src/governance/Governance.sol
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ contract Governance is IGovernance {

configuration = DataStructures.Configuration({
proposeConfig: DataStructures.ProposeConfiguration({
lockDelay: Timestamp.wrap(3600),
lockDelay: Timestamp.wrap(360),
lockAmount: 1000e18
}),
votingDelay: Timestamp.wrap(3600),
votingDuration: Timestamp.wrap(3600),
executionDelay: Timestamp.wrap(3600),
gracePeriod: Timestamp.wrap(3600),
votingDelay: Timestamp.wrap(360),
votingDuration: Timestamp.wrap(360),
executionDelay: Timestamp.wrap(360),
gracePeriod: Timestamp.wrap(360),
quorum: 0.1e18,
voteDifferential: 0.04e18,
minimumVotes: 1000e18
Expand Down
2 changes: 1 addition & 1 deletion l1-contracts/src/governance/libraries/ConfigurationLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ library ConfigurationLib {

uint256 internal constant VOTES_LOWER = 1;

Timestamp internal constant TIME_LOWER = Timestamp.wrap(3600);
Timestamp internal constant TIME_LOWER = Timestamp.wrap(360);
Timestamp internal constant TIME_UPPER = Timestamp.wrap(30 * 24 * 3600);

function withdrawalDelay(DataStructures.Configuration storage _self)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// 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";

/**
* @title RegisterNewRollupVersionPayload
* @author Aztec Labs
* @notice A payload that registers a new rollup version.
*/
contract RegisterNewRollupVersionPayload is IPayload {
IRegistry public immutable REGISTRY;
address public immutable ROLLUP;

constructor(IRegistry _registry, address _rollup) {
REGISTRY = _registry;
ROLLUP = _rollup;
}

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

res[0] = Action({
target: address(REGISTRY),
data: abi.encodeWithSelector(IRegistry.upgrade.selector, ROLLUP)
});

return res;
}
}
2 changes: 2 additions & 0 deletions spartan/aztec-network/values/1-validators.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ telemetry:

validator:
replicas: 1
sequencer:
minTxsPerBlock: 0
validator:
disabled: false

Expand Down
58 changes: 58 additions & 0 deletions yarn-project/cli/src/cmds/l1/deploy_new_rollup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { getInitialTestAccounts } from '@aztec/accounts/testing';
import { getL1ContractsConfigEnvVars } from '@aztec/ethereum';
import { type EthAddress } from '@aztec/foundation/eth-address';
import { type LogFn, type Logger } from '@aztec/foundation/log';
import { getGenesisValues } from '@aztec/world-state/testing';

import { deployNewRollupContracts } from '../../utils/aztec.js';

export async function deployNewRollup(
registryAddress: EthAddress,
rpcUrl: string,
chainId: number,
privateKey: string | undefined,
mnemonic: string,
mnemonicIndex: number,
salt: number | undefined,
testAccounts: boolean,
json: boolean,
initialValidators: EthAddress[],
log: LogFn,
debugLogger: Logger,
) {
const config = getL1ContractsConfigEnvVars();

const initialFundedAccounts = testAccounts ? await getInitialTestAccounts() : [];
const { genesisBlockHash, genesisArchiveRoot } = await getGenesisValues(initialFundedAccounts.map(a => a.address));

const { payloadAddress, rollup } = await deployNewRollupContracts(
registryAddress,
rpcUrl,
chainId,
privateKey,
mnemonic,
mnemonicIndex,
salt,
initialValidators,
genesisArchiveRoot,
genesisBlockHash,
config,
debugLogger,
);

if (json) {
log(
JSON.stringify(
{
payloadAddress: payloadAddress.toString(),
rollupAddress: rollup.address,
},
null,
2,
),
);
} else {
log(`Payload Address: ${payloadAddress.toString()}`);
log(`Rollup Address: ${rollup.address}`);
}
}
42 changes: 42 additions & 0 deletions yarn-project/cli/src/cmds/l1/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,48 @@ export function injectCommands(program: Command, log: LogFn, debugLogger: Logger
);
});

program
.command('deploy-new-rollup')
.description('Deploys a new rollup contract and a payload to upgrade the registry with it.')
.requiredOption('-r, --registry-address <string>', 'The address of the registry contract', parseEthereumAddress)
.requiredOption(
'-u, --rpc-url <string>',
'Url of the ethereum host. Chain identifiers localhost and testnet can be used',
ETHEREUM_HOST,
)
.option('-pk, --private-key <string>', 'The private key to use for deployment', PRIVATE_KEY)
.option('--validators <string>', 'Comma separated list of validators')
.option(
'-m, --mnemonic <string>',
'The mnemonic to use in deployment',
'test test test test test test test test test test test junk',
)
.option('-i, --mnemonic-index <number>', 'The index of the mnemonic to use in deployment', arg => parseInt(arg), 0)
.addOption(l1ChainIdOption)
.option('--salt <number>', 'The optional salt to use in deployment', arg => parseInt(arg))
.option('--json', 'Output the contract addresses in JSON format')
.option('--test-accounts', 'Populate genesis state with initial fee juice for test accounts')
.action(async options => {
const { deployNewRollup } = await import('./deploy_new_rollup.js');

const initialValidators =
options.validators?.split(',').map((validator: string) => EthAddress.fromString(validator)) || [];
await deployNewRollup(
options.registryAddress,
options.rpcUrl,
options.l1ChainId,
options.privateKey,
options.mnemonic,
options.mnemonicIndex,
options.salt,
options.testAccounts,
options.json,
initialValidators,
log,
debugLogger,
);
});

program
.command('generate-l1-account')
.description('Generates a new private key for an account on L1.')
Expand Down
47 changes: 46 additions & 1 deletion yarn-project/cli/src/utils/aztec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { type ContractArtifact, type FunctionArtifact, loadContractArtifact } from '@aztec/aztec.js/abi';
import { type PXE } from '@aztec/circuit-types';
import { type DeployL1Contracts, type L1ContractsConfig } from '@aztec/ethereum';
import { type DeployL1Contracts, type L1ContractsConfig, type RollupContract } from '@aztec/ethereum';
import { FunctionType } from '@aztec/foundation/abi';
import { type EthAddress } from '@aztec/foundation/eth-address';
import { type Fr } from '@aztec/foundation/fields';
Expand Down Expand Up @@ -87,6 +87,51 @@ export async function deployAztecContracts(
);
}

export async function deployNewRollupContracts(
registryAddress: EthAddress,
rpcUrl: string,
chainId: number,
privateKey: string | undefined,
mnemonic: string,
mnemonicIndex: number,
salt: number | undefined,
initialValidators: EthAddress[],
genesisArchiveRoot: Fr,
genesisBlockHash: Fr,
config: L1ContractsConfig,
logger: Logger,
): Promise<{ payloadAddress: EthAddress; rollup: RollupContract }> {
const { createEthereumChain, deployRollupAndUpgradePayload } = await import('@aztec/ethereum');
const { mnemonicToAccount, privateKeyToAccount } = await import('viem/accounts');
const { getVKTreeRoot } = await import('@aztec/noir-protocol-circuits-types/vks');

const account = !privateKey
? mnemonicToAccount(mnemonic!, { addressIndex: mnemonicIndex })
: privateKeyToAccount(`${privateKey.startsWith('0x') ? '' : '0x'}${privateKey}` as `0x${string}`);
const chain = createEthereumChain(rpcUrl, chainId);

const { payloadAddress, rollup } = await deployRollupAndUpgradePayload(
chain.rpcUrl,
chain.chainInfo,
account,
{
salt,
vkTreeRoot: getVKTreeRoot(),
protocolContractTreeRoot,
l2FeeJuiceAddress: ProtocolContractAddress.FeeJuice,
genesisArchiveRoot,
genesisBlockHash,
initialValidators,
...config,
},
registryAddress,
logger,
config,
);

return { payloadAddress, rollup };
}

/** Sets the assumed proven block number on the rollup contract on L1 */
export async function setAssumeProvenThrough(
blockNumber: number,
Expand Down
46 changes: 14 additions & 32 deletions yarn-project/end-to-end/src/fixtures/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,7 @@ import getPort from 'get-port';
import { tmpdir } from 'os';
import * as path from 'path';
import { inspect } from 'util';
import {
type Account,
type Chain,
type HDAccount,
type Hex,
type HttpTransport,
type PrivateKeyAccount,
createPublicClient,
createWalletClient,
getContract,
http,
} from 'viem';
import { type Chain, type HDAccount, type Hex, type PrivateKeyAccount, getContract } from 'viem';
import { mnemonicToAccount, privateKeyToAccount } from 'viem/accounts';
import { foundry } from 'viem/chains';

Expand Down Expand Up @@ -210,7 +199,7 @@ export async function setupPXEService(
* @returns Private eXecution Environment (PXE) client, viem wallets, contract addresses etc.
*/
async function setupWithRemoteEnvironment(
account: Account,
account: HDAccount | PrivateKeyAccount,
config: AztecNodeConfig,
logger: Logger,
numberOfAccounts: number,
Expand All @@ -226,15 +215,8 @@ async function setupWithRemoteEnvironment(
logger.verbose(`Retrieving contract addresses from ${PXE_URL}`);
const l1Contracts = (await pxeClient.getNodeInfo()).l1ContractAddresses;

const walletClient = createWalletClient<HttpTransport, Chain, HDAccount>({
account,
chain: foundry,
transport: http(config.l1RpcUrl),
});
const publicClient = createPublicClient({
chain: foundry,
transport: http(config.l1RpcUrl),
});
const { walletClient, publicClient } = createL1Clients(config.l1RpcUrl, account, foundry);

const deployL1ContractsValues: DeployL1Contracts = {
l1ContractAddresses: l1Contracts,
walletClient,
Expand Down Expand Up @@ -597,21 +579,21 @@ export async function setup(

return {
aztecNode,
proverNode,
pxe,
deployL1ContractsValues,
blobSink,
cheatCodes,
config,
dateProvider,
deployL1ContractsValues,
initialFundedAccounts,
wallet: wallets[0],
wallets,
logger,
cheatCodes,
proverNode,
pxe,
sequencer,
watcher,
dateProvider,
blobSink,
telemetryClient: telemetry,
teardown,
telemetryClient: telemetry,
wallet: wallets[0],
wallets,
watcher,
};
}

Expand Down
Loading
Loading