Skip to content

Commit

Permalink
Remove V5 from e2e + allow multiple runs no deploy (#411)
Browse files Browse the repository at this point in the history
  • Loading branch information
thedarkjester authored Dec 9, 2024
1 parent 1b14ed3 commit 8cf2866
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 176 deletions.
14 changes: 7 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ compile-contracts-no-cache:
cd contracts/; \
make force-compile

deploy-linea-rollup: L1_CONTRACT_VERSION:=5
deploy-linea-rollup: L1_CONTRACT_VERSION:=6
deploy-linea-rollup:
# WARNING: FOR LOCAL DEV ONLY - DO NOT REUSE THESE KEYS ELSEWHERE
cd contracts/; \
Expand Down Expand Up @@ -161,38 +161,38 @@ restart-shomei:
docker compose -f docker/compose.yml -f docker/compose-local-dev.overrides.yml up zkbesu-shomei shomei -d

fresh-start-all: COMPOSE_PROFILES:="l1,l2"
fresh-start-all: L1_CONTRACT_VERSION:=5
fresh-start-all: L1_CONTRACT_VERSION:=6
fresh-start-all:
make clean-environment
make start-all L1_CONTRACT_VERSION=$(L1_CONTRACT_VERSION) COMPOSE_PROFILES=$(COMPOSE_PROFILES)

fresh-start-all-traces-v2: COMPOSE_PROFILES:="l1,l2"
fresh-start-all-traces-v2: L1_CONTRACT_VERSION:=5
fresh-start-all-traces-v2: L1_CONTRACT_VERSION:=6
fresh-start-all-traces-v2:
make clean-environment
$(MAKE) start-all-traces-v2 L1_CONTRACT_VERSION=$(L1_CONTRACT_VERSION) COMPOSE_PROFILES=$(COMPOSE_PROFILES)

start-all: COMPOSE_PROFILES:=l1,l2
start-all: L1_CONTRACT_VERSION:=5
start-all: L1_CONTRACT_VERSION:=6
start-all:
L1_GENESIS_TIME=$(get_future_time) make start-whole-environment COMPOSE_PROFILES=$(COMPOSE_PROFILES)
make deploy-contracts L1_CONTRACT_VERSION=$(L1_CONTRACT_VERSION)

start-all-traces-v2: COMPOSE_PROFILES:="l1,l2"
start-all-traces-v2: L1_CONTRACT_VERSION:=5
start-all-traces-v2: L1_CONTRACT_VERSION:=6
start-all-traces-v2:
L1_GENESIS_TIME=$(get_future_time) make start-whole-environment-traces-v2 COMPOSE_PROFILES=$(COMPOSE_PROFILES)
$(MAKE) deploy-contracts L1_CONTRACT_VERSION=$(L1_CONTRACT_VERSION)

deploy-contracts: L1_CONTRACT_VERSION:=5
deploy-contracts: L1_CONTRACT_VERSION:=6
deploy-contracts:
cd contracts/; \
export L1_NONCE=$$(npx ts-node local-deployments-artifacts/get-wallet-nonce.ts --wallet-priv-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 --rpc-url http://localhost:8445) && \
export L2_NONCE=$$(npx ts-node local-deployments-artifacts/get-wallet-nonce.ts --wallet-priv-key 0x1dd171cec7e2995408b5513004e8207fe88d6820aeff0d82463b3e41df251aae --rpc-url http://localhost:8545) && \
cd .. && \
$(MAKE) -j6 deploy-linea-rollup-v$(L1_CONTRACT_VERSION) deploy-token-bridge-l1 deploy-l1-test-erc20 deploy-l2messageservice deploy-token-bridge-l2 deploy-l2-test-erc20

deploy-contracts-minimal: L1_CONTRACT_VERSION:=5
deploy-contracts-minimal: L1_CONTRACT_VERSION:=6
deploy-contracts-minimal:
cd contracts/; \
export L1_NONCE=$$(npx ts-node local-deployments-artifacts/get-wallet-nonce.ts --wallet-priv-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 --rpc-url http://localhost:8445) && \
Expand Down
2 changes: 1 addition & 1 deletion e2e/src/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const VERIFIER_SETTER_ROLE = "0x32937fd5162e282df7e9a14a5073a2425321c7966
export const MESSAGE_SENT_EVENT_SIGNATURE = "0xe856c2b8bd4eb0027ce32eeaf595c21b0b6b4644b326e5b7bd80a1cf8db72e6c";

export const HASH_ZERO = ethers.ZeroHash;

export const EMPTY_CONTRACT_CODE = "0x";
export const TRANSACTION_CALLDATA_LIMIT = 30_000;

export const PAUSE_ALL_ROLE = generateKeccak256(["string"], ["PAUSE_ALL_ROLE"], true);
Expand Down
8 changes: 4 additions & 4 deletions e2e/src/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import assert from "assert";
import { AbstractSigner, BaseContract, BlockTag, TransactionReceipt, TransactionRequest, Wallet, ethers } from "ethers";
import path from "path";
import { exec } from "child_process";
import { L2MessageService, TokenBridge, LineaRollupV5, LineaRollupV6 } from "../typechain";
import { L2MessageService, TokenBridge, LineaRollupV6 } from "../typechain";
import { PayableOverrides, TypedContractEvent, TypedDeferredTopicFilter, TypedEventLog } from "../typechain/common";
import { MessageEvent, SendMessageArgs } from "./types";

Expand Down Expand Up @@ -148,7 +148,7 @@ export async function getBlockByNumberOrBlockTag(rpcUrl: URL, blockTag: BlockTag
}

export async function getEvents<
TContract extends LineaRollupV5 | LineaRollupV6 | L2MessageService | TokenBridge,
TContract extends LineaRollupV6 | L2MessageService | TokenBridge,
TEvent extends TypedContractEvent,
>(
contract: TContract,
Expand All @@ -171,7 +171,7 @@ export async function getEvents<
}

export async function waitForEvents<
TContract extends LineaRollupV5 | LineaRollupV6 | L2MessageService | TokenBridge,
TContract extends LineaRollupV6 | L2MessageService | TokenBridge,
TEvent extends TypedContractEvent,
>(
contract: TContract,
Expand Down Expand Up @@ -297,7 +297,7 @@ export function getMessageSentEventFromLogs<T extends BaseContract>(
});
}

export const sendMessage = async <T extends LineaRollupV5 | L2MessageService>(
export const sendMessage = async <T extends LineaRollupV6 | L2MessageService>(
signer: AbstractSigner,
contract: T,
args: SendMessageArgs,
Expand Down
25 changes: 18 additions & 7 deletions e2e/src/config/jest/global-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,29 @@ import { config } from "../tests-config";
import { deployContract } from "../../common/deployments";
import { DummyContract__factory, TestContract__factory } from "../../typechain";
import { etherToWei, sendTransactionsToGenerateTrafficWithInterval } from "../../common/utils";
import { EMPTY_CONTRACT_CODE } from "../../common/constants";

declare global {
var stopL2TrafficGeneration: () => void;
}

export default async (): Promise<void> => {
const dummyContractCode = await config.getL1Provider().getCode(config.getL1DummyContractAddress());

// If this is empty, we have not deployed and prerequisites or configured token bridges.
if (dummyContractCode === EMPTY_CONTRACT_CODE) {
console.log("Configuring once-off prerequisite contracts");
await configureOnceOffPrerequisities();
}

console.log("Generating L2 traffic...");
const pollingAccount = await config.getL2AccountManager().generateAccount(etherToWei("200"));
const stopPolling = await sendTransactionsToGenerateTrafficWithInterval(pollingAccount, 2_000);

global.stopL2TrafficGeneration = stopPolling;
};

async function configureOnceOffPrerequisities() {
const l1AccountManager = config.getL1AccountManager();
const l2AccountManager = config.getL2AccountManager();

Expand Down Expand Up @@ -55,10 +72,4 @@ export default async (): Promise<void> => {
console.log(`L1 Dummy contract deployed at address: ${await dummyContract.getAddress()}`);
console.log(`L2 Dummy contract deployed at address: ${await l2DummyContract.getAddress()}`);
console.log(`L2 Test contract deployed at address: ${await l2TestContract.getAddress()}`);

console.log("Generating L2 traffic...");
const pollingAccount = await config.getL2AccountManager().generateAccount(etherToWei("200"));
const stopPolling = await sendTransactionsToGenerateTrafficWithInterval(pollingAccount, 2_000);

global.stopL2TrafficGeneration = stopPolling;
};
}
12 changes: 8 additions & 4 deletions e2e/src/config/tests-config/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import {
DummyContract__factory,
L2MessageService,
L2MessageService__factory,
LineaRollupV5,
LineaRollupV5__factory,
LineaRollupV6,
LineaRollupV6__factory,
ProxyAdmin,
ProxyAdmin__factory,
TestContract,
Expand Down Expand Up @@ -81,8 +81,8 @@ export default class TestSetup {
return this.config.L2.transactionExclusionEndpoint;
}

public getLineaRollupContract(signer?: AbstractSigner): LineaRollupV5 {
const lineaRollup: LineaRollupV5 = LineaRollupV5__factory.connect(
public getLineaRollupContract(signer?: AbstractSigner): LineaRollupV6 {
const lineaRollup: LineaRollupV6 = LineaRollupV6__factory.connect(
this.config.L1.lineaRollupAddress,
this.getL1Provider(),
);
Expand Down Expand Up @@ -227,6 +227,10 @@ export default class TestSetup {
return this.config.L2.accountManager;
}

public getL1DummyContractAddress(): string {
return this.config.L1.dummyContractAddress;
}

private isLocalL2Config(config: L2Config): config is LocalL2Config {
return (
(config as LocalL2Config).besuNodeRpcUrl !== undefined &&
Expand Down
28 changes: 14 additions & 14 deletions e2e/src/restart.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,49 +46,49 @@ describe("Coordinator restart test suite", () => {
const l1Provider = config.getL1Provider();
// await for a finalization to happen on L1
const [dataSubmittedEventsBeforeRestart, dataFinalizedEventsBeforeRestart] = await Promise.all([
waitForEvents(lineaRollup, lineaRollup.filters.DataSubmittedV2(), 0, "latest"),
waitForEvents(lineaRollup, lineaRollup.filters.DataFinalized(), 0, "latest"),
waitForEvents(lineaRollup, lineaRollup.filters.DataSubmittedV3(), 0, "latest"),
waitForEvents(lineaRollup, lineaRollup.filters.DataFinalizedV3(), 0, "latest"),
]);

const lastDataSubmittedEventBeforeRestart = dataSubmittedEventsBeforeRestart.slice(-1)[0];
const lastDataFinalizedEventsBeforeRestart = dataFinalizedEventsBeforeRestart.slice(-1)[0];

// Just some sanity checks
// Check that the coordinator has submitted and finalized data before the restart
expect(lastDataSubmittedEventBeforeRestart.args.endBlock).toBeGreaterThan(0n);
expect(lastDataFinalizedEventsBeforeRestart.args.lastBlockFinalized).toBeGreaterThan(0n);
expect(lastDataSubmittedEventBeforeRestart.blockNumber).toBeGreaterThan(0n);
expect(lastDataFinalizedEventsBeforeRestart.args.endBlockNumber).toBeGreaterThan(0n);

await waitForCoordinatorRestart();

const currentBlockNumberAfterRestart = await l1Provider.getBlockNumber();

console.log("Waiting for DataSubmittedV2 event after coordinator restart...");
const [dataSubmittedV2EventAfterRestart] = await waitForEvents(
console.log("Waiting for DataSubmittedV3 event after coordinator restart...");
const [dataSubmittedV3EventAfterRestart] = await waitForEvents(
lineaRollup,
lineaRollup.filters.DataSubmittedV2(),
lineaRollup.filters.DataSubmittedV3(),
1_000,
currentBlockNumberAfterRestart,
"latest",
async (events) =>
events.filter((event) => event.args.startBlock > lastDataSubmittedEventBeforeRestart.args.endBlock),
async (events) => events.filter((event) => event.blockNumber > lastDataSubmittedEventBeforeRestart.blockNumber),
);
console.log(`New DataSubmittedV2 event found: event=${JSON.stringify(dataSubmittedV2EventAfterRestart)}`);
console.log(`New DataSubmittedV3 event found: event=${JSON.stringify(dataSubmittedV3EventAfterRestart)}`);

console.log("Waiting for DataFinalized event after coordinator restart...");
const [dataFinalizedEventAfterRestart] = await waitForEvents(
lineaRollup,
lineaRollup.filters.DataFinalized(),
lineaRollup.filters.DataFinalizedV3(),
1_000,
currentBlockNumberAfterRestart,
"latest",
async (events) =>
events.filter(
(event) => event.args.lastBlockFinalized > lastDataFinalizedEventsBeforeRestart.args.lastBlockFinalized,
(event) => event.args.endBlockNumber > lastDataFinalizedEventsBeforeRestart.args.endBlockNumber,
),
);
console.log(`New DataFinalized event found: event=${JSON.stringify(dataFinalizedEventAfterRestart)}`);

expect(dataFinalizedEventAfterRestart.args.lastBlockFinalized).toBeGreaterThan(
lastDataFinalizedEventsBeforeRestart.args.lastBlockFinalized,
expect(dataFinalizedEventAfterRestart.args.endBlockNumber).toBeGreaterThan(
lastDataFinalizedEventsBeforeRestart.args.endBlockNumber,
);
},
150_000,
Expand Down
Loading

0 comments on commit 8cf2866

Please sign in to comment.