Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(EVM): Support EVM emulator as optional feature #3151

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
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
7 changes: 5 additions & 2 deletions infrastructure/zk/src/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,12 @@ export async function erc20BridgeFinish(args: any[] = []): Promise<void> {

export async function registerHyperchain({
baseTokenName,
deploymentMode
deploymentMode,
allowEvmEmulator
}: {
baseTokenName?: string;
deploymentMode?: DeploymentMode;
allowEvmEmulator?: boolean;
}): Promise<void> {
await utils.confirmAction();

Expand All @@ -241,7 +243,8 @@ export async function registerHyperchain({
privateKey ? `--private-key ${privateKey}` : '',
baseTokenName ? `--base-token-name ${baseTokenName}` : '',
deploymentMode == DeploymentMode.Validium ? '--validium-mode' : '',
tokenMultiplierSetterAddress ? `--token-multiplier-setter-address ${tokenMultiplierSetterAddress}` : ''
tokenMultiplierSetterAddress ? `--token-multiplier-setter-address ${tokenMultiplierSetterAddress}` : '',
allowEvmEmulator ? '--allow-evm-emulation' : ''
];
await utils.spawn(`yarn l1-contracts register-hyperchain ${args.join(' ')} | tee registerHyperchain.log`);
const deployLog = fs.readFileSync('registerHyperchain.log').toString();
Expand Down
25 changes: 19 additions & 6 deletions infrastructure/zk/src/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,19 @@ type InitHyperchainOptions = {
baseTokenName?: string;
localLegacyBridgeTesting?: boolean;
deploymentMode: DeploymentMode;
allowEvmEmulator?: boolean;
};
const initHyperchain = async ({
includePaymaster,
baseTokenName,
localLegacyBridgeTesting,
deploymentMode
deploymentMode,
allowEvmEmulator
}: InitHyperchainOptions): Promise<void> => {
await announced('Registering Hyperchain', contract.registerHyperchain({ baseTokenName, deploymentMode }));
await announced(
'Registering Hyperchain',
contract.registerHyperchain({ baseTokenName, deploymentMode, allowEvmEmulator })
);
await announced('Reloading env', env.reload());
await announced('Running server genesis setup', server.genesisFromSources());
await announced(
Expand Down Expand Up @@ -146,6 +151,7 @@ type InitDevCmdActionOptions = InitSetupOptions & {
validiumMode?: boolean;
localLegacyBridgeTesting?: boolean;
shouldCheckPostgres: boolean; // Whether to perform `cargo sqlx prepare --check`
allowEvmEmulator?: boolean;
};
export const initDevCmdAction = async ({
skipEnvSetup,
Expand All @@ -157,7 +163,8 @@ export const initDevCmdAction = async ({
runObservability,
validiumMode,
localLegacyBridgeTesting,
shouldCheckPostgres
shouldCheckPostgres,
allowEvmEmulator
}: InitDevCmdActionOptions): Promise<void> => {
if (localLegacyBridgeTesting) {
await makeEraChainIdSameAsCurrent();
Expand All @@ -181,7 +188,8 @@ export const initDevCmdAction = async ({
includePaymaster: true,
baseTokenName,
localLegacyBridgeTesting,
deploymentMode
deploymentMode,
allowEvmEmulator
});
if (localLegacyBridgeTesting) {
await makeEraAddressSameAsCurrent();
Expand Down Expand Up @@ -214,13 +222,15 @@ type InitHyperCmdActionOptions = {
baseTokenName?: string;
runObservability: boolean;
deploymentMode: DeploymentMode;
allowEvmEmulator?: boolean;
};
export const initHyperCmdAction = async ({
skipSetupCompletely,
bumpChainId,
baseTokenName,
runObservability,
deploymentMode
deploymentMode,
allowEvmEmulator
}: InitHyperCmdActionOptions): Promise<void> => {
if (bumpChainId) {
config.bumpChainId();
Expand All @@ -237,7 +247,8 @@ export const initHyperCmdAction = async ({
await initHyperchain({
includePaymaster: true,
baseTokenName,
deploymentMode
deploymentMode,
allowEvmEmulator
});
};

Expand All @@ -254,6 +265,7 @@ export const initCommand = new Command('init')
'used to test LegacyBridge compatibily. The chain will have the same id as the era chain id, while eraChainId in L2SharedBridge will be 0'
)
.option('--should-check-postgres', 'Whether to perform cargo sqlx prepare --check during database setup', true)
.option('--allow-evm-emulator', 'allow deployment of EVM contracts')
.description('Deploys the shared bridge and registers a hyperchain locally, as quickly as possible.')
.action(initDevCmdAction);

Expand All @@ -278,4 +290,5 @@ initCommand
.option('--base-token-name <base-token-name>', 'base token name')
.option('--validium-mode', 'deploy contracts in Validium mode')
.option('--run-observability', 'run observability suite')
.option('--allow-evm-emulator', 'allow deployment of EVM contracts')
.action(initHyperCmdAction);
Loading