Skip to content
Merged
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
1 change: 1 addition & 0 deletions e2e/src/config/tests-config/environments/local.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const config: Config = {
shomeiFrontendEndpoint: SHOMEI_FRONTEND_ENDPOINT,
sequencerEndpoint: SEQUENCER_ENDPOINT,
transactionExclusionEndpoint: TRANSACTION_EXCLUSION_ENDPOINT,
opcodeTesterAddress: "0xa50a51c09a5c451C52BB714527E1974b686D8e77",
},
};

Expand Down
18 changes: 17 additions & 1 deletion e2e/src/config/tests-config/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import {
LineaRollupV6__factory,
LineaSequencerUptimeFeed,
LineaSequencerUptimeFeed__factory,
OpcodeTester,
OpcodeTester__factory,
ProxyAdmin,
ProxyAdmin__factory,
SparseMerkleProof,
Expand Down Expand Up @@ -267,13 +269,27 @@ export default class TestSetup {
return this.config.L1.dummyContractAddress;
}

public getL2OpcodeTesterContract(signer?: Wallet): OpcodeTester {
const opcodeTester: OpcodeTester = OpcodeTester__factory.connect(
this.config.L2.opcodeTesterAddress,
this.getL2Provider(),
);

if (signer) {
return opcodeTester.connect(signer);
}

return opcodeTester;
}

private isLocalL2Config(config: L2Config): config is LocalL2Config {
return (
(config as LocalL2Config).besuNodeRpcUrl !== undefined &&
(config as LocalL2Config).sequencerEndpoint !== undefined &&
(config as LocalL2Config).shomeiEndpoint !== undefined &&
(config as LocalL2Config).shomeiFrontendEndpoint !== undefined &&
(config as LocalL2Config).transactionExclusionEndpoint !== undefined
(config as LocalL2Config).transactionExclusionEndpoint !== undefined &&
(config as LocalL2Config).opcodeTesterAddress !== undefined
);
}
}
1 change: 1 addition & 0 deletions e2e/src/config/tests-config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export type BaseL2Config = BaseConfig & {
l2TokenAddress: string;
l2SparseMerkleProofAddress: string;
l2LineaSequencerUptimeFeedAddress: string;
opcodeTesterAddress: string;
shomeiEndpoint?: URL;
shomeiFrontendEndpoint?: URL;
sequencerEndpoint?: URL;
Expand Down
43 changes: 43 additions & 0 deletions e2e/src/opcodes.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { describe, expect, it } from "@jest/globals";
import { config } from "./config/tests-config";
import { LineaEstimateGasClient } from "./common/utils";

const l2AccountManager = config.getL2AccountManager();

describe("Opcodes test suite", () => {
const lineaEstimateGasClient = new LineaEstimateGasClient(config.getL2BesuNodeEndpoint()!);

it.concurrent("Should be able to estimate the opcode execution gas using linea_estimateGas endpoint", async () => {
const account = await l2AccountManager.generateAccount();
const opcodeTester = config.getL2OpcodeTesterContract(account);

const { maxPriorityFeePerGas, maxFeePerGas, gasLimit } = await lineaEstimateGasClient.lineaEstimateGas(
account.address,
await opcodeTester.getAddress(),
opcodeTester.interface.encodeFunctionData("executeAllOpcodes"),
);
logger.debug(
`Fetched fee data. maxPriorityFeePerGas=${maxPriorityFeePerGas} maxFeePerGas=${maxFeePerGas} gasLimit=${gasLimit}`,
);

expect(maxPriorityFeePerGas).toBeGreaterThan(0n);
expect(maxFeePerGas).toBeGreaterThan(0n);
expect(gasLimit).toBeGreaterThan(0n);
});

it.concurrent("Should be able to execute all opcodes", async () => {
const account = await l2AccountManager.generateAccount();
const opcodeTester = config.getL2OpcodeTesterContract(account);

const valueBeforeExecution = await opcodeTester.rollingBlockDetailComputations();
const executeTx = await opcodeTester.executeAllOpcodes({ gasLimit: 5_000_000 });
await executeTx.wait(1, 20_000);

const valueAfterExecution = await opcodeTester.rollingBlockDetailComputations();

logger.debug(`Value before execution: ${valueBeforeExecution}, value after execution: ${valueAfterExecution}`);
expect(valueBeforeExecution).not.toEqual(valueAfterExecution);

logger.debug("All opcodes executed successfully");
});
});