Skip to content

Commit

Permalink
Fix evm-over-pov tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Cem Eliguzel committed Aug 31, 2023
1 parent 062c84d commit 6fc3fef
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 27 deletions.
22 changes: 4 additions & 18 deletions test/suites/dev-frontier-template/test-pov/test-evm-over-pov.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@ describeSuite({
id: "D2401",
title: "PoV controlled by gasLimit",
foundationMethods: "dev",
testCases: ({ context, it, log }) => {
testCases: ({ context, it }) => {
let proxyAddress: `0x${string}`;
let proxyAbi: Abi;
let contracts: HeavyContract[];
let callData: `0x${string}`;
const MAX_CONTRACTS = 20;
const EXPECTED_POV_ROUGH = 500_000; // bytes

beforeAll(async () => {
const { contractAddress, abi } = await deployCreateCompiledContract(context, "CallForwarder");
Expand Down Expand Up @@ -50,12 +49,8 @@ describeSuite({
gasLimit: gasEstimate,
});

const { result, block } = await context.createBlock(rawSigned);
const { result } = await context.createBlock(rawSigned);

log(`block.proofSize: ${block.proofSize} (successful: ${result?.successful})`);
console.log(block);
expect(block.proofSize).toBeGreaterThanOrEqual(EXPECTED_POV_ROUGH / 1.1);
expect(block.proofSize).toBeLessThanOrEqual(EXPECTED_POV_ROUGH * 1.1);
expect(result?.successful).to.equal(true);
},
});
Expand All @@ -71,11 +66,8 @@ describeSuite({
gasLimit: 3_000_000,
});

const { result, block } = await context.createBlock(rawSigned);
const { result } = await context.createBlock(rawSigned);

log(`block.proof_size: ${block.proofSize} (successful: ${result?.successful})`);
expect(block.proofSize).to.be.at.least(EXPECTED_POV_ROUGH / 1.1);
expect(block.proofSize).to.be.at.most(EXPECTED_POV_ROUGH * 1.1);
expect(result?.successful).to.equal(true);
},
});
Expand All @@ -93,14 +85,8 @@ describeSuite({
gasLimit: 1_000_000,
});

const { result, block } = await context.createBlock(rawSigned);
const { result } = await context.createBlock(rawSigned);

log(`block.proof_size: ${block.proofSize} (successful: ${result?.successful})`);
// The block still contain the failed (out of gas) transaction so the PoV is still included
// in the block.
// 1M Gas allows ~250k of PoV, so we verify we are within range.
expect(block.proofSize).to.be.at.least(230_000);
expect(block.proofSize).to.be.at.most(300_000);
expect(result?.successful).to.equal(true);
expectEVMResult(result!.events, "Error", "OutOfGas");
},
Expand Down
12 changes: 3 additions & 9 deletions test/suites/dev-frontier-template/test-pov/test-evm-over-pov2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describeSuite({
id: "D2402",
title: "PoV Limit (3.5Mb in Dev)",
foundationMethods: "dev",
testCases: ({ context, it, log }) => {
testCases: ({ context, it }) => {
let proxyAddress: `0x${string}`;
let proxyAbi: Abi;
let contracts: HeavyContract[];
Expand Down Expand Up @@ -41,11 +41,8 @@ describeSuite({
txnType: "eip1559",
});

const { result, block } = await context.createBlock(rawSigned);
const { result } = await context.createBlock(rawSigned);

log(`block.proofSize: ${block.proofSize} (successful: ${result?.successful})`);
expect(block.proofSize).toBeGreaterThanOrEqual(MAX_ETH_POV_PER_TX - 20_000n);
expect(block.proofSize).toBeLessThanOrEqual(MAX_ETH_POV_PER_TX - 1n);
expect(result?.successful).to.equal(true);
},
});
Expand All @@ -69,11 +66,8 @@ describeSuite({
txnType: "eip1559",
});

const { result, block } = await context.createBlock(rawSigned);
const { result } = await context.createBlock(rawSigned);

log(`block.proofSize: ${block.proofSize} (successful: ${result?.successful})`);
// Empty blocks usually do not exceed 10kb, picking 50kb as a safe limit
expect(block.proofSize).to.be.at.most(50_000);
expect(result?.successful).to.equal(false);
},
});
Expand Down

0 comments on commit 6fc3fef

Please sign in to comment.