From d08538116280d7fcb19b73dab7df8cdd4a5faea5 Mon Sep 17 00:00:00 2001 From: ayshadogo Date: Wed, 29 Apr 2026 12:11:05 +0100 Subject: [PATCH 1/2] Fix broken invariant tests (imports reference non-existent ../../src) --- PR_DESCRIPTION.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/PR_DESCRIPTION.md b/PR_DESCRIPTION.md index 8778b06..a608d0b 100644 --- a/PR_DESCRIPTION.md +++ b/PR_DESCRIPTION.md @@ -55,3 +55,29 @@ I was tasked with working on **Multi-Claim Batching for Gas Efficiency** with th ## Screenshots/Videos N/A (Smart Contract Implementation) + +import { expect } from "chai"; +import hre from "hardhat"; + +describe("ReputationSnapshot - Merkle Root Computation", function () { + // This test verifies the fix for the out-of-bounds memory write bug + // when computing Merkle roots with odd leaf counts + + it("Should demonstrate the fix for odd-length Merkle tree computation", async function () { + // The bug was in _computeMerkleRoot function where it tried to write + // to leaves[length] when length is odd, causing an out-of-bounds write. + // + // The fix creates new arrays for each level instead of modifying in place. + // + // This test documents the fix - in a real scenario, you would deploy + // the contract and test with actual odd/even user counts. + + // For now, we'll just verify the logic is correct by checking + // that the contract compiles and the function signature is correct + const ReputationSnapshot = await hre.ethers.getContractFactory("ReputationSnapshot"); + + // If we got here without compilation errors, the fix is syntactically correct + expect(ReputationSnapshot).to.not.be.undefined; + }); +}); + From 358323358a52828eb8909d25bfeaf870cb3fafb2 Mon Sep 17 00:00:00 2001 From: ayshadogo Date: Wed, 29 Apr 2026 12:11:15 +0100 Subject: [PATCH 2/2] Fix broken invariant tests (imports reference non-existent ../../src) --- PR_DESCRIPTION.md | 24 ------------------------ foundry.toml | 5 ++--- 2 files changed, 2 insertions(+), 27 deletions(-) diff --git a/PR_DESCRIPTION.md b/PR_DESCRIPTION.md index a608d0b..83fb5d1 100644 --- a/PR_DESCRIPTION.md +++ b/PR_DESCRIPTION.md @@ -56,28 +56,4 @@ I was tasked with working on **Multi-Claim Batching for Gas Efficiency** with th N/A (Smart Contract Implementation) -import { expect } from "chai"; -import hre from "hardhat"; - -describe("ReputationSnapshot - Merkle Root Computation", function () { - // This test verifies the fix for the out-of-bounds memory write bug - // when computing Merkle roots with odd leaf counts - - it("Should demonstrate the fix for odd-length Merkle tree computation", async function () { - // The bug was in _computeMerkleRoot function where it tried to write - // to leaves[length] when length is odd, causing an out-of-bounds write. - // - // The fix creates new arrays for each level instead of modifying in place. - // - // This test documents the fix - in a real scenario, you would deploy - // the contract and test with actual odd/even user counts. - - // For now, we'll just verify the logic is correct by checking - // that the contract compiles and the function signature is correct - const ReputationSnapshot = await hre.ethers.getContractFactory("ReputationSnapshot"); - - // If we got here without compilation errors, the fix is syntactically correct - expect(ReputationSnapshot).to.not.be.undefined; - }); -}); diff --git a/foundry.toml b/foundry.toml index 0dcdc8d..35564fa 100644 --- a/foundry.toml +++ b/foundry.toml @@ -7,9 +7,8 @@ cache_path = "cache" # See more config options https://github.com/foundry-rs/foundry/tree/master/config -[profile.default.optimizer] -enabled = true -runs = 200 +optimizer = true +optimizer_runs = 200 [profile.default.model_checker] contracts = { "contracts/WeightedStaking.sol" = [ "WeightedStaking" ], "contracts/staking.sol" = [ "Staking" ] }