Skip to content

Commit

Permalink
Make pov tests pass
Browse files Browse the repository at this point in the history
  • Loading branch information
Cem Eliguzel committed Oct 17, 2023
1 parent 6820150 commit 7d530ff
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
10 changes: 5 additions & 5 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 @@ -15,7 +15,7 @@ describeSuite({
let contracts: HeavyContract[];
let callData: `0x${string}`;
const MAX_CONTRACTS = 20;
const EXPECTED_POV_ROUGH = 500_000; // bytes
const EXPECTED_POV_ROUGH = 50_000; // bytes

beforeAll(async () => {
const { contractAddress, abi } = await deployCreateCompiledContract(context, "CallForwarder");
Expand Down Expand Up @@ -54,7 +54,7 @@ describeSuite({

log(`block.proofSize: ${block.proofSize} (successful: ${result?.successful})`);
console.log(block);
expect(block.proofSize).toBeGreaterThanOrEqual(EXPECTED_POV_ROUGH / 1.1);
expect(block.proofSize).toBeGreaterThanOrEqual(EXPECTED_POV_ROUGH / 2.0);
expect(block.proofSize).toBeLessThanOrEqual(EXPECTED_POV_ROUGH * 1.1);
expect(result?.successful).to.equal(true);
},
Expand All @@ -74,7 +74,7 @@ describeSuite({
const { result, block } = 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.least(EXPECTED_POV_ROUGH / 2.0);
expect(block.proofSize).to.be.at.most(EXPECTED_POV_ROUGH * 1.1);
expect(result?.successful).to.equal(true);
},
Expand All @@ -99,8 +99,8 @@ describeSuite({
// 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(block.proofSize).to.be.at.least(23_000);
expect(block.proofSize).to.be.at.most(50_000);
expect(result?.successful).to.equal(true);
expectEVMResult(result!.events, "Error", "OutOfGas");
},
Expand Down
11 changes: 6 additions & 5 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 @@ -12,21 +12,22 @@ describeSuite({
let proxyAddress: `0x${string}`;
let proxyAbi: Abi;
let contracts: HeavyContract[];
const max_eth_pov_per_tx = MAX_ETH_POV_PER_TX / 100n;

beforeAll(async () => {
const { contractAddress, abi } = await deployCreateCompiledContract(context, "CallForwarder");
proxyAddress = contractAddress;
proxyAbi = abi;

// Deploy heavy contracts (test won't use more than what is needed for reaching max pov)
contracts = await deployHeavyContracts(context, 6000, Number(6000n + MAX_ETH_POV_PER_TX / 24_000n + 1n));
contracts = await deployHeavyContracts(context, 6000, Number(6000n + max_eth_pov_per_tx / 24_000n + 1n));
});

it({
id: "T01",
title: "should allow to produce block just under the PoV Limit",
test: async function () {
const calculatedMax = MAX_ETH_POV_PER_TX / 24_000n - 1n;
const calculatedMax = max_eth_pov_per_tx / 24_000n - 1n;

const callData = encodeFunctionData({
abi: proxyAbi,
Expand All @@ -44,8 +45,8 @@ describeSuite({
const { result, block } = 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(block.proofSize).toBeGreaterThanOrEqual(max_eth_pov_per_tx - 30_000n);
expect(block.proofSize).toBeLessThanOrEqual(max_eth_pov_per_tx - 1n);
expect(result?.successful).to.equal(true);
},
});
Expand All @@ -54,7 +55,7 @@ describeSuite({
id: "T02",
title: "should prevent a transaction reaching just over the PoV",
test: async function () {
const calculatedMax = MAX_ETH_POV_PER_TX / 24_000n;
const calculatedMax = max_eth_pov_per_tx / 24_000n;

const callData = encodeFunctionData({
abi: proxyAbi,
Expand Down

0 comments on commit 7d530ff

Please sign in to comment.