From c6696468d1e42634eb93bc53e3202af2659a40b6 Mon Sep 17 00:00:00 2001 From: Jack Date: Sat, 7 Nov 2026 09:13:53 +0800 Subject: [PATCH 1/3] feat(scripts): verify deployments with immutable placeholder substitution --- ...09-2026-11-07T01-09-15-627Z-immutable.json | 21 ++ ...309-2026-11-07T01-09-15-627Z-metadata.json | 1 + ...80309-2026-11-07T01-09-15-627Z-runtime.hex | 1 + ...26-11-07T01-09-15-627Z-standard-input.json | 24 ++ ...ion-12080309-2026-11-07T01-09-15-627Z.json | 292 ++++++++++++++++++ scripts/verify-deployment.mjs | 67 +++- 6 files changed, 396 insertions(+), 10 deletions(-) create mode 100644 docs/evidence/deployment/verification-12080309-2026-11-07T01-09-15-627Z-immutable.json create mode 100644 docs/evidence/deployment/verification-12080309-2026-11-07T01-09-15-627Z-metadata.json create mode 100644 docs/evidence/deployment/verification-12080309-2026-11-07T01-09-15-627Z-runtime.hex create mode 100644 docs/evidence/deployment/verification-12080309-2026-11-07T01-09-15-627Z-standard-input.json create mode 100644 docs/evidence/deployment/verification-12080309-2026-11-07T01-09-15-627Z.json diff --git a/docs/evidence/deployment/verification-12080309-2026-11-07T01-09-15-627Z-immutable.json b/docs/evidence/deployment/verification-12080309-2026-11-07T01-09-15-627Z-immutable.json new file mode 100644 index 0000000..3a42a51 --- /dev/null +++ b/docs/evidence/deployment/verification-12080309-2026-11-07T01-09-15-627Z-immutable.json @@ -0,0 +1,21 @@ +{ + "explanation": "Each slot is a two-byte immutable placeholder (zero in compiled runtime) substituted with the constructor value at deployment.", + "slots": [ + { + "position": 1024, + "onChainWord": 600 + }, + { + "position": 1076, + "onChainWord": 600 + }, + { + "position": 9354, + "onChainWord": 600 + }, + { + "position": 9461, + "onChainWord": 600 + } + ] +} diff --git a/docs/evidence/deployment/verification-12080309-2026-11-07T01-09-15-627Z-metadata.json b/docs/evidence/deployment/verification-12080309-2026-11-07T01-09-15-627Z-metadata.json new file mode 100644 index 0000000..707e724 --- /dev/null +++ b/docs/evidence/deployment/verification-12080309-2026-11-07T01-09-15-627Z-metadata.json @@ -0,0 +1 @@ +{"compiler":{"version":"0.8.24+commit.e11b9ed9"},"language":"Solidity","output":{"abi":[{"inputs":[{"internalType":"uint256","name":"approvalTimeout","type":"uint256"},{"internalType":"uint256","name":"submissionTimeout","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"projectId","type":"uint256"},{"indexed":true,"internalType":"uint8","name":"milestone","type":"uint8"},{"indexed":true,"internalType":"address","name":"backer","type":"address"},{"indexed":false,"internalType":"uint256","name":"weight","type":"uint256"}],"name":"ApprovalCast","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"projectId","type":"uint256"},{"indexed":true,"internalType":"address","name":"backer","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"ContributionReceived","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"projectId","type":"uint256"},{"indexed":true,"internalType":"uint8","name":"milestone","type":"uint8"},{"indexed":false,"internalType":"string","name":"evidence","type":"string"},{"indexed":false,"internalType":"string","name":"evidenceUrl","type":"string"}],"name":"EvidenceSubmitted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"projectId","type":"uint256"},{"indexed":true,"internalType":"address","name":"backer","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"ExcessRefunded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"projectId","type":"uint256"}],"name":"FundingFailed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"projectId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"totalRaised","type":"uint256"}],"name":"FundingSuccessful","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"projectId","type":"uint256"},{"indexed":true,"internalType":"uint8","name":"milestone","type":"uint8"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"FundsWithdrawn","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"projectId","type":"uint256"},{"indexed":true,"internalType":"uint8","name":"milestone","type":"uint8"}],"name":"MilestoneApproved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"projectId","type":"uint256"},{"indexed":true,"internalType":"uint8","name":"milestone","type":"uint8"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"MilestoneReleased","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"projectId","type":"uint256"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"PayoutClaimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"projectId","type":"uint256"}],"name":"ProjectCompleted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"projectId","type":"uint256"},{"indexed":true,"internalType":"address","name":"creator","type":"address"},{"indexed":false,"internalType":"uint256","name":"target","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"ProjectCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"projectId","type":"uint256"}],"name":"ProjectExpired","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"projectId","type":"uint256"},{"indexed":true,"internalType":"address","name":"backer","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"RefundClaimed","type":"event"},{"inputs":[],"name":"APPROVAL_TIMEOUT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SUBMISSION_TIMEOUT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"projectId","type":"uint256"},{"internalType":"uint8","name":"milestone","type":"uint8"}],"name":"approveMilestone","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"projectId","type":"uint256"}],"name":"claimExpiredRefund","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"projectId","type":"uint256"},{"internalType":"address payable","name":"recipient","type":"address"}],"name":"claimPayout","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"projectId","type":"uint256"}],"name":"claimRefund","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"claimablePayouts","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"projectId","type":"uint256"}],"name":"contribute","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"}],"name":"contributions","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"description","type":"string"},{"internalType":"uint256","name":"target","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"string","name":"firstGoal","type":"string"},{"internalType":"string","name":"secondGoal","type":"string"}],"name":"createProject","outputs":[{"internalType":"uint256","name":"projectId","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"projectId","type":"uint256"}],"name":"finalizeFunding","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"projectId","type":"uint256"},{"internalType":"address","name":"backer","type":"address"}],"name":"getExpiredRefundAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"projectId","type":"uint256"},{"internalType":"uint8","name":"milestone","type":"uint8"}],"name":"getMilestone","outputs":[{"components":[{"internalType":"string","name":"goal","type":"string"},{"internalType":"string","name":"evidence","type":"string"},{"internalType":"string","name":"evidenceUrl","type":"string"},{"internalType":"uint256","name":"approvalWeight","type":"uint256"},{"internalType":"uint256","name":"withdrawnAmount","type":"uint256"},{"internalType":"uint256","name":"submittedAt","type":"uint256"},{"internalType":"bool","name":"submitted","type":"bool"},{"internalType":"bool","name":"approved","type":"bool"},{"internalType":"bool","name":"withdrawn","type":"bool"}],"internalType":"struct MilestoneFund.Milestone","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"projectId","type":"uint256"}],"name":"getMilestoneWindow","outputs":[{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"bool","name":"open","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"projectId","type":"uint256"}],"name":"getProject","outputs":[{"components":[{"internalType":"address payable","name":"creator","type":"address"},{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"description","type":"string"},{"internalType":"uint256","name":"target","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint256","name":"totalRaised","type":"uint256"},{"internalType":"uint256","name":"escrowBalance","type":"uint256"},{"internalType":"enum MilestoneFund.ProjectStatus","name":"status","type":"uint8"},{"internalType":"uint8","name":"currentMilestone","type":"uint8"},{"internalType":"uint256","name":"successfulAt","type":"uint256"}],"internalType":"struct MilestoneFund.Project","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint8","name":"","type":"uint8"},{"internalType":"address","name":"","type":"address"}],"name":"hasApproved","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"projectCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"}],"name":"refunded","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"projectId","type":"uint256"},{"internalType":"uint8","name":"milestone","type":"uint8"}],"name":"releaseMilestone","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"projectId","type":"uint256"},{"internalType":"uint8","name":"milestone","type":"uint8"},{"internalType":"string","name":"evidence","type":"string"},{"internalType":"string","name":"evidenceUrl","type":"string"}],"name":"submitEvidence","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"projectId","type":"uint256"},{"internalType":"uint8","name":"milestone","type":"uint8"}],"name":"withdrawMilestone","outputs":[],"stateMutability":"nonpayable","type":"function"}],"devdoc":{"kind":"dev","methods":{"constructor":{"params":{"approvalTimeout":"seconds backers have to approve submitted evidence","submissionTimeout":"seconds the creator has to submit evidence"}},"getMilestoneWindow(uint256)":{"details":"A zero deadline means there is no pending submission or approval."}},"stateVariables":{"APPROVAL_TIMEOUT":{"details":"Fixed at deployment and immutable afterwards, so the rules cannot be changed later by anyone. A short value is useful for demos."}},"title":"MilestoneFund Lite - two-stage, contribution-weighted crowdfunding.","version":1},"userdoc":{"kind":"user","methods":{"APPROVAL_TIMEOUT()":{"notice":"How long backers have to approve after evidence is submitted."},"SUBMISSION_TIMEOUT()":{"notice":"How long the creator has to submit evidence after each milestone opens."},"claimExpiredRefund(uint256)":{"notice":"Reclaim a share of the remaining escrow when the current milestone times out: either backers did not approve submitted evidence, or the creator never submitted it. Each share uses the same pool, frozen before the first refund."},"claimPayout(uint256,address)":{"notice":"The creator can collect the project's released payouts at a chosen address."},"contribute(uint256)":{"notice":"Contributions are capped at the target. Anything above the remaining amount is returned in the same transaction, so totalRaised never exceeds target."},"finalizeFunding(uint256)":{"notice":"Anyone may explicitly finalize an expired, unsuccessful campaign."},"getExpiredRefundAmount(uint256,address)":{"notice":"Returns the claimable expiry refund in wei, or zero if none is available."},"getMilestoneWindow(uint256)":{"notice":"The current submission or approval deadline and whether the window is open."},"releaseMilestone(uint256,uint8)":{"notice":"Advance an approved milestone and credit its payout without sending ETH."},"withdrawMilestone(uint256,uint8)":{"notice":"Release and pay an approved milestone to the creator in one transaction."}},"notice":"Educational prototype. No owner, admin withdrawal, or fee. Anyone can release an approved milestone. Only the creator can claim the released payout.","version":1}},"settings":{"compilationTarget":{"MilestoneFund.sol":"MilestoneFund"},"evmVersion":"paris","libraries":{},"metadata":{"bytecodeHash":"ipfs"},"optimizer":{"enabled":true,"runs":200},"remappings":[]},"sources":{"MilestoneFund.sol":{"keccak256":"0xce5557edd2983accc5ab4265c5eb1c03f0e79091a3e775def3f647d2f8986058","license":"MIT","urls":["bzz-raw://c5f19a18d4d093148cf98bce33072f85f397264e0791dbd54f0579c3b96769ba","dweb:/ipfs/QmZbDePgwVN5SNJXfUC5CpwusoXAPQBphJV3V5k3Hc72UE"]}},"version":1} diff --git a/docs/evidence/deployment/verification-12080309-2026-11-07T01-09-15-627Z-runtime.hex b/docs/evidence/deployment/verification-12080309-2026-11-07T01-09-15-627Z-runtime.hex new file mode 100644 index 0000000..657c28f --- /dev/null +++ b/docs/evidence/deployment/verification-12080309-2026-11-07T01-09-15-627Z-runtime.hex @@ -0,0 +1 @@ +0x60806040526004361061012a5760003560e01c8063935e1282116100ab578063c1cbbca71161006f578063c1cbbca714610390578063f0f3f2c8146103a3578063f247a4d0146103d0578063f368342814610404578063f8a75a6614610438578063fb0f05b71461047957600080fd5b8063935e1282146102f05780639a4f2f5e14610310578063b0110cc614610330578063b7c5923314610350578063bcfcc8d51461037057600080fd5b80634f1ff459116100f25780634f1ff459146102185780635b7baf641461026357806380436b58146102835780638182254b146102b05780638e7f5ee5146102d057600080fd5b8063056da8df1461012f5780630d23e080146101655780630d76e7301461018757806336fbad26146101bc5780633d891f59146101e0575b600080fd5b34801561013b57600080fd5b5061014f61014a3660046128b0565b610499565b60405161015c9190612922565b60405180910390f35b34801561017157600080fd5b506101856101803660046128b0565b6107a4565b005b34801561019357600080fd5b506101a76101a23660046129d9565b6108c0565b6040805192835290151560208301520161015c565b3480156101c857600080fd5b506101d260005481565b60405190815260200161015c565b3480156101ec57600080fd5b506101d26101fb366004612a0a565b600360209081526000928352604080842090915290825290205481565b34801561022457600080fd5b50610253610233366004612a0a565b600560209081526000928352604080842090915290825290205460ff1681565b604051901515815260200161015c565b34801561026f57600080fd5b5061018561027e3660046129d9565b6109be565b34801561028f57600080fd5b506101d261029e3660046129d9565b60096020526000908152604090205481565b3480156102bc57600080fd5b506101856102cb366004612a83565b610bf1565b3480156102dc57600080fd5b506101856102eb3660046128b0565b610eca565b3480156102fc57600080fd5b506101d261030b366004612b0d565b610ff1565b34801561031c57600080fd5b506101d261032b366004612a0a565b611402565b34801561033c57600080fd5b5061018561034b366004612a0a565b611462565b34801561035c57600080fd5b5061018561036b3660046128b0565b6115f9565b34801561037c57600080fd5b5061018561038b3660046129d9565b61192d565b61018561039e3660046129d9565b611b76565b3480156103af57600080fd5b506103c36103be3660046129d9565b611f36565b60405161015c9190612c1f565b3480156103dc57600080fd5b506101d27f000000000000000000000000000000000000000000000000000000000000025881565b34801561041057600080fd5b506101d27f000000000000000000000000000000000000000000000000000000000000025881565b34801561044457600080fd5b50610253610453366004612cda565b600460209081526000938452604080852082529284528284209052825290205460ff1681565b34801561048557600080fd5b506101856104943660046129d9565b61212f565b6104ee6040518061012001604052806060815260200160608152602001606081526020016000815260200160008152602001600081526020016000151581526020016000151581526020016000151581525090565b8260005481106105195760405162461bcd60e51b815260040161051090612d1a565b60405180910390fd5b60028360ff16106105605760405162461bcd60e51b8152602060048201526011602482015270496e76616c6964206d696c6573746f6e6560781b6044820152606401610510565b600260008581526020019081526020016000208360ff166002811061058757610587612d43565b60070201604051806101200160405290816000820180546105a790612d59565b80601f01602080910402602001604051908101604052809291908181526020018280546105d390612d59565b80156106205780601f106105f557610100808354040283529160200191610620565b820191906000526020600020905b81548152906001019060200180831161060357829003601f168201915b5050505050815260200160018201805461063990612d59565b80601f016020809104026020016040519081016040528092919081815260200182805461066590612d59565b80156106b25780601f10610687576101008083540402835291602001916106b2565b820191906000526020600020905b81548152906001019060200180831161069557829003601f168201915b505050505081526020016002820180546106cb90612d59565b80601f01602080910402602001604051908101604052809291908181526020018280546106f790612d59565b80156107445780601f1061071957610100808354040283529160200191610744565b820191906000526020600020905b81548152906001019060200180831161072757829003601f168201915b505050918352505060038201546020820152600482015460408201526005820154606082015260069091015460ff8082161515608084015261010082048116151560a08401526201000090910416151560c09091015291505b5092915050565b8160005481106107c65760405162461bcd60e51b815260040161051090612d1a565b60065460ff16156107e95760405162461bcd60e51b815260040161051090612d8d565b6006805460ff191660019081179091556000848152602091909152604081206108159085908590612241565b90508060096000868152602001908152602001600020600082825461083a9190612dcb565b909155505060405181815260ff84169085907fb5e7231814419e5a5e888606251cb3b5325a5339501a127b8f728e49a0d866609060200160405180910390a38260ff166001036108b05760405184907f60d8df137e489b6216738e436244ca4700bd6d0c8371d3c8d9c80b54538111b990600090a25b50506006805460ff191690555050565b6000808260005481106108e55760405162461bcd60e51b815260040161051090612d1a565b600084815260016020819052604090912090600782015460ff16600481111561091057610910612be7565b1415801561093757506004600782015460ff16600481111561093457610934612be7565b14155b156109495760008093509350506109b8565b600085815260026020819052604082206007840154909161010090910460ff1690811061097857610978612d43565b6007020190508060060160019054906101000a900460ff16156109a3576000809450945050506109b8565b6109ae86838361245a565b9450844210935050505b50915091565b8060005481106109e05760405162461bcd60e51b815260040161051090612d1a565b60065460ff1615610a035760405162461bcd60e51b815260040161051090612d8d565b6006805460ff191660019081179091556000838152602091909152604090206002600782015460ff166004811115610a3d57610a3d612be7565b14610a7f5760405162461bcd60e51b8152602060048201526012602482015271141c9bda9958dd081b9bdd0819985a5b195960721b6044820152606401610510565b60008381526003602090815260408083203384529091529020548015801590610ac25750600084815260056020908152604080832033845290915290205460ff16155b610b045760405162461bcd60e51b81526020600482015260136024820152724e6f20726566756e6420617661696c61626c6560681b6044820152606401610510565b60008481526005602090815260408083203384529091528120805460ff19166001179055600683018054839290610b3c908490612dde565b9091555050604051818152339085907ff3f402280ef0a7905e124aa621b65eaeb2725c343e8b36d398ed78c29daf285c9060200160405180910390a3604051600090339083908381818185875af1925050503d8060008114610bba576040519150601f19603f3d011682016040523d82523d6000602084013e610bbf565b606091505b5050905080610be05760405162461bcd60e51b815260040161051090612df1565b50506006805460ff19169055505050565b856000548110610c135760405162461bcd60e51b815260040161051090612d1a565b600087815260016020526040902080546001600160a01b03163314610c4a5760405162461bcd60e51b815260040161051090612e1e565b6001600782015460ff166004811115610c6557610c65612be7565b14610c825760405162461bcd60e51b815260040161051090612e44565b60028760ff16108015610ca35750600781015460ff88811661010090920416145b610cbf5760405162461bcd60e51b815260040161051090612e74565b600088815260026020819052604082209060ff8a16908110610ce357610ce3612d43565b6007020190508060060160009054906101000a900460ff1615610d485760405162461bcd60e51b815260206004820152601a60248201527f45766964656e636520616c7265616479207375626d69747465640000000000006044820152606401610510565b610d5389838361245a565b4210610da15760405162461bcd60e51b815260206004820152601860248201527f5375626d697373696f6e2077696e646f7720636c6f73656400000000000000006044820152606401610510565b8515801590610db25750610fa08611155b610df15760405162461bcd60e51b815260206004820152601060248201526f496e76616c69642065766964656e636560801b6044820152606401610510565b8315801590610e0257506103e88411155b610e455760405162461bcd60e51b8152602060048201526014602482015273125b9d985b1a5908195d9a59195b98d94815549360621b6044820152606401610510565b60018101610e54878983612efb565b5060028101610e64858783612efb565b5060068101805460ff1916600117905542600582015560405160ff8916908a907f3d01ce186fd86a00dbb015b5eba62a161d6d725ca1d4fb525edb2c9e47b604b690610eb7908b908b908b908b90612fe5565b60405180910390a3505050505050505050565b816000548110610eec5760405162461bcd60e51b815260040161051090612d1a565b60065460ff1615610f0f5760405162461bcd60e51b815260040161051090612d8d565b60068054600160ff19909116811790915560008481526020919091526040902080546001600160a01b03163314610f585760405162461bcd60e51b815260040161051090612e1e565b6000610f65858584612241565b90508360ff16857f3e36457ef724bfc3f3e805fdc22d7f5feff6f8b7d4c9fa6f3665ce6c78bd584d83604051610f9d91815260200190565b60405180910390a38360ff16600103610fdc5760405185907f60d8df137e489b6216738e436244ca4700bd6d0c8371d3c8d9c80b54538111b990600090a25b8154610be0906001600160a01b031682612507565b60008915801590611003575060788a11155b61103e5760405162461bcd60e51b815260206004820152600c60248201526b496e76616c6964206e616d6560a01b6044820152606401610510565b871580159061104f5750610fa08811155b6110915760405162461bcd60e51b815260206004820152601360248201527224b73b30b634b2103232b9b1b934b83a34b7b760691b6044820152606401610510565b83158015906110a257506107d08411155b6110e35760405162461bcd60e51b8152602060048201526012602482015271125b9d985b1a5908199a5c9cdd0819dbd85b60721b6044820152606401610510565b81158015906110f457506107d08211155b6111365760405162461bcd60e51b8152602060048201526013602482015272125b9d985b1a59081cd958dbdb990819dbd85b606a1b6044820152606401610510565b600087116111865760405162461bcd60e51b815260206004820152601760248201527f546172676574206d75737420626520706f7369746976650000000000000000006044820152606401610510565b4286116111d55760405162461bcd60e51b815260206004820152601760248201527f446561646c696e65206d757374206265206675747572650000000000000000006044820152606401610510565b6000805490806111e483613017565b919050559050604051806101400160405280336001600160a01b031681526020018c8c8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250505090825250604080516020601f8d018190048102820181019092528b815291810191908c908c90819084018382808284376000920182905250938552505050602082018a905260408201899052606082018190526080820181905260a0909101908152600060208083018290526040928301829052848252600180825292909120835181546001600160a01b0319166001600160a01b039091161781559083015190918201906112e99082613030565b50604082015160028201906112fe9082613030565b50606082015181600301556080820151816004015560a0820151816005015560c0820151816006015560e08201518160070160006101000a81548160ff0219169083600481111561135157611351612be7565b02179055506101008281015160078301805461ff00191660ff909216909202179055610120909101516008909101556000818152600260205260409020611399858783612efb565b5060008181526002602052604090206007016113b6838583612efb565b506040805188815260208101889052339183917fb5d890eb2df709d2f732ed81f328b444e49c1618ed8d64c53c0a040ec4040e1e910160405180910390a39a9950505050505050505050565b60008260005481106114265760405162461bcd60e51b815260040161051090612d1a565b600084815260016020526040902061143e858261258b565b511561144e57600092505061079d565b61145985828661277d565b95945050505050565b8160005481106114845760405162461bcd60e51b815260040161051090612d1a565b60065460ff16156114a75760405162461bcd60e51b815260040161051090612d8d565b60068054600160ff199091168117909155600084815260209190915260409020546001600160a01b031633146114ef5760405162461bcd60e51b815260040161051090612e1e565b6001600160a01b0382166115455760405162461bcd60e51b815260206004820152601860248201527f496e76616c6964207061796f757420726563697069656e7400000000000000006044820152606401610510565b600083815260096020526040902054806115975760405162461bcd60e51b81526020600482015260136024820152724e6f207061796f757420617661696c61626c6560681b6044820152606401610510565b60008481526009602052604080822091909155516001600160a01b0384169085907fe97cee5a4c0549d3fdc81e322b718ddf0aeb3418ec87dce4f9a7fb28d117c312906115e79085815260200190565b60405180910390a36108b08382612507565b81600054811061161b5760405162461bcd60e51b815260040161051090612d1a565b600083815260016020819052604090912090600782015460ff16600481111561164657611646612be7565b146116635760405162461bcd60e51b815260040161051090612e44565b60028360ff161080156116845750600781015460ff84811661010090920416145b6116a05760405162461bcd60e51b815260040161051090612e74565b600084815260026020819052604082209060ff86169081106116c4576116c4612d43565b6007020190508060060160009054906101000a900460ff1680156116f257506006810154610100900460ff16155b6117325760405162461bcd60e51b815260206004820152601160248201527020b8383937bb30b6103737ba1037b832b760791b6044820152606401610510565b61173d85838361245a565b42106117845760405162461bcd60e51b8152602060048201526016602482015275105c1c1c9bdd985b081dda5b991bddc818db1bdcd95960521b6044820152606401610510565b6000858152600360209081526040808320338452909152902054806117da5760405162461bcd60e51b815260206004820152600c60248201526b4261636b657273206f6e6c7960a01b6044820152606401610510565b600086815260046020908152604080832060ff808a1685529083528184203385529092529091205416156118435760405162461bcd60e51b815260206004820152601060248201526f105b1c9958591e48185c1c1c9bdd995960821b6044820152606401610510565b600086815260046020908152604080832060ff8916845282528083203384529091528120805460ff19166001179055600383018054839290611886908490612dcb565b9091555050604051818152339060ff87169088907f094d71d4c000f8dd4cca693b241ce997610658e9df2713658824c0856472570d9060200160405180910390a4600283600501546118d89190613106565b826003015411156119255760068201805461ff00191661010017905560405160ff86169087907f5bd776d6cd4ec262a0d9b560dc43fcd23bbf8162933a60acf2b23e2aed2a7e4c90600090a35b505050505050565b80600054811061194f5760405162461bcd60e51b815260040161051090612d1a565b60065460ff16156119725760405162461bcd60e51b815260040161051090612d8d565b6006805460ff191660019081179091556000838152602091909152604081209061199c848361258b565b9050805160001481906119c25760405162461bcd60e51b8152600401610510919061311a565b5060006119d085843361277d565b905060008111611a185760405162461bcd60e51b81526020600482015260136024820152724e6f20726566756e6420617661696c61626c6560681b6044820152606401610510565b60008581526005602090815260408083203384529091529020805460ff19166001908117909155600784015460ff166004811115611a5857611a58612be7565b03611aac5760068301546000868152600760208190526040808320939093558501805460ff19166004179055905186917f1f58ad83ebbdef78bee5008c6a1261e64e23cadeaaa65721484c309a31b3dd4191a25b80836006016000828254611ac09190612dde565b9091555050604051818152339086907ff3f402280ef0a7905e124aa621b65eaeb2725c343e8b36d398ed78c29daf285c9060200160405180910390a3604051600090339083908381818185875af1925050503d8060008114611b3e576040519150601f19603f3d011682016040523d82523d6000602084013e611b43565b606091505b5050905080611b645760405162461bcd60e51b815260040161051090612df1565b50506006805460ff1916905550505050565b806000548110611b985760405162461bcd60e51b815260040161051090612d1a565b60065460ff1615611bbb5760405162461bcd60e51b815260040161051090612d8d565b6006805460ff1916600190811790915560008381526020919091526040812090600782015460ff166004811115611bf457611bf4612be7565b14611c325760405162461bcd60e51b815260206004820152600e60248201526d119d5b991a5b99c818db1bdcd95960921b6044820152606401610510565b80600401544210611c785760405162461bcd60e51b815260206004820152601060248201526f111958591b1a5b99481c995858da195960821b6044820152606401610510565b80546001600160a01b03163303611cd15760405162461bcd60e51b815260206004820152601960248201527f43726561746f722063616e6e6f7420636f6e74726962757465000000000000006044820152606401610510565b60003411611d215760405162461bcd60e51b815260206004820152601d60248201527f436f6e747269627574696f6e206d75737420626520706f7369746976650000006044820152606401610510565b600081600501548260030154611d379190612dde565b90506000813411611d485734611d4a565b815b90506000611d588234612dde565b6000878152600360209081526040808320338452909152812080549293508492909190611d86908490612dcb565b9250508190555081846005016000828254611da19190612dcb565b9250508190555081846006016000828254611dbc9190612dcb565b9091555050604051828152339087907f865c884d49c8cecaef108efb20f7d282f26c0f9b0d24dd48e5592d4e02ec658d9060200160405180910390a38015611ec657604051600090339083908381818185875af1925050503d8060008114611e40576040519150601f19603f3d011682016040523d82523d6000602084013e611e45565b606091505b5050905080611e8d5760405162461bcd60e51b8152602060048201526014602482015273115e18d95cdcc81c99599d5b990819985a5b195960621b6044820152606401610510565b604051828152339088907fe26b2dba2478a5741141a6da49466d62b0e4062c650f68f797052123302d0ea09060200160405180910390a3505b8360030154846005015403611b645742600885015560078401805460ff19166001179055600584015460405190815286907f88bfb1cb787b5a4eccce541cbd9b445a7b77c97dad63984f8db4478be569e1b69060200160405180910390a250506006805460ff1916905550505050565b611f3e61282d565b816000548110611f605760405162461bcd60e51b815260040161051090612d1a565b6000838152600160208181526040928390208351610140810190945280546001600160a01b03168452918201805491840191611f9b90612d59565b80601f0160208091040260200160405190810160405280929190818152602001828054611fc790612d59565b80156120145780601f10611fe957610100808354040283529160200191612014565b820191906000526020600020905b815481529060010190602001808311611ff757829003601f168201915b5050505050815260200160028201805461202d90612d59565b80601f016020809104026020016040519081016040528092919081815260200182805461205990612d59565b80156120a65780601f1061207b576101008083540402835291602001916120a6565b820191906000526020600020905b81548152906001019060200180831161208957829003601f168201915b50505091835250506003820154602082015260048083015460408301526005830154606083015260068301546080830152600783015460a09092019160ff16908111156120f5576120f5612be7565b600481111561210657612106612be7565b81526007820154610100900460ff16602082015260089091015460409091015291505b50919050565b8060005481106121515760405162461bcd60e51b815260040161051090612d1a565b600082815260016020526040812090600782015460ff16600481111561217957612179612be7565b146121b75760405162461bcd60e51b815260206004820152600e60248201526d119d5b991a5b99c818db1bdcd95960921b6044820152606401610510565b80600401544210156122025760405162461bcd60e51b8152602060048201526014602482015273111958591b1a5b99481b9bdd081c995858da195960621b6044820152606401610510565b60078101805460ff1916600217905560405183907fe9981212ab524b2711193a45899a72ea24566f65d0953cd9f50c0d7943401c8290600090a2505050565b60006001600783015460ff16600481111561225e5761225e612be7565b1461227b5760405162461bcd60e51b815260040161051090612e44565b60028360ff1610801561229c5750600782015460ff84811661010090920416145b6122b85760405162461bcd60e51b815260040161051090612e74565b600084815260026020819052604082209060ff86169081106122dc576122dc612d43565b6007020190508060060160019054906101000a900460ff16801561230b5750600681015462010000900460ff16155b6123575760405162461bcd60e51b815260206004820152601a60248201527f4d696c6573746f6e65206e6f7420776974686472617761626c650000000000006044820152606401610510565b60ff84161561236a5782600601546123b7565b600580846005015461237c919061312d565b612387906002613141565b6123919190613106565b600584600501546123a29190613106565b6123ad906002613141565b6123b79190612dcb565b6006808301805462ff0000191662010000179055600483018290558401805491935083916000906123e9908490612dde565b9091555050600783018054610100900460ff1690600161240883613158565b91906101000a81548160ff021916908360ff160217905550508360ff16600003612442576000858152600860205260409020429055612452565b60078301805460ff191660031790555b509392505050565b600681015460009060ff16156124a1577f0000000000000000000000000000000000000000000000000000000000000258826005015461249a9190612dcb565b9050612500565b6007830154600090610100900460ff16156124ca576000858152600860205260409020546124d0565b83600801545b90506124fc7f000000000000000000000000000000000000000000000000000000000000025882612dcb565b9150505b9392505050565b80600003612513575050565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114612560576040519150601f19603f3d011682016040523d82523d6000602084013e612565565b606091505b50509050806125865760405162461bcd60e51b815260040161051090612df1565b505050565b60606001600783015460ff1660048111156125a8576125a8612be7565b141580156125cf57506004600783015460ff1660048111156125cc576125cc612be7565b14155b15612603575060408051808201909152601281527150726f6a656374206e6f742061637469766560701b6020820152612777565b6007820154600261010090910460ff16106126465750604080518082019091526011815270141c9bda9958dd0818dbdb5c1b195d1959607a1b6020820152612777565b600083815260026020819052604082206007850154909161010090910460ff1690811061267557612675612d43565b6007020190508060060160019054906101000a900460ff16156126cd57505060408051808201909152601a81527f4d696c6573746f6e6520616c726561647920617070726f7665640000000000006020820152612777565b6126d884848361245a565b42101561276557600681015460ff16612726576040518060400160405280601c81526020017f5375626d697373696f6e2077696e646f77207374696c6c206f70656e0000000081525061275d565b6040518060400160405280601a81526020017f417070726f76616c2077696e646f77207374696c6c206f70656e0000000000008152505b915050612777565b50506040805160208101909152600081525b92915050565b60008381526005602090815260408083206001600160a01b038516845290915281205460ff16156127b057506000612500565b60006004600785015460ff1660048111156127cd576127cd612be7565b146127dc5783600601546127ec565b6000858152600760205260409020545b600585015460008781526003602090815260408083206001600160a01b038916845290915290205491925090612823908390613141565b6124fc9190613106565b60405180610140016040528060006001600160a01b031681526020016060815260200160608152602001600081526020016000815260200160008152602001600081526020016000600481111561288657612886612be7565b815260006020820181905260409091015290565b803560ff811681146128ab57600080fd5b919050565b600080604083850312156128c357600080fd5b823591506128d36020840161289a565b90509250929050565b6000815180845260005b81811015612902576020818501810151868301820152016128e6565b506000602082860101526020601f19601f83011685010191505092915050565b60208152600082516101208060208501526129416101408501836128dc565b91506020850151601f198086850301604087015261295f84836128dc565b935060408701519150808685030160608701525061297d83826128dc565b92505060608501516080850152608085015160a085015260a085015160c085015260c08501516129b160e086018215159052565b5060e08501516101006129c78187018315159052565b90950151151593019290925250919050565b6000602082840312156129eb57600080fd5b5035919050565b6001600160a01b0381168114612a0757600080fd5b50565b60008060408385031215612a1d57600080fd5b823591506020830135612a2f816129f2565b809150509250929050565b60008083601f840112612a4c57600080fd5b50813567ffffffffffffffff811115612a6457600080fd5b602083019150836020828501011115612a7c57600080fd5b9250929050565b60008060008060008060808789031215612a9c57600080fd5b86359550612aac6020880161289a565b9450604087013567ffffffffffffffff80821115612ac957600080fd5b612ad58a838b01612a3a565b90965094506060890135915080821115612aee57600080fd5b50612afb89828a01612a3a565b979a9699509497509295939492505050565b60008060008060008060008060008060c08b8d031215612b2c57600080fd5b8a3567ffffffffffffffff80821115612b4457600080fd5b612b508e838f01612a3a565b909c509a5060208d0135915080821115612b6957600080fd5b612b758e838f01612a3a565b909a50985060408d0135975060608d0135965060808d0135915080821115612b9c57600080fd5b612ba88e838f01612a3a565b909650945060a08d0135915080821115612bc157600080fd5b50612bce8d828e01612a3a565b915080935050809150509295989b9194979a5092959850565b634e487b7160e01b600052602160045260246000fd5b60058110612c1b57634e487b7160e01b600052602160045260246000fd5b9052565b60208152612c396020820183516001600160a01b03169052565b60006020830151610140806040850152612c576101608501836128dc565b91506040850151601f19858403016060860152612c7483826128dc565b92505060608501516080850152608085015160a085015260a085015160c085015260c085015160e085015260e0850151610100612cb381870183612bfd565b8601519050610120612cc98682018360ff169052565b959095015193019290925250919050565b600080600060608486031215612cef57600080fd5b83359250612cff6020850161289a565b91506040840135612d0f816129f2565b809150509250925092565b6020808252600f908201526e155b9adb9bdddb881c1c9bda9958dd608a1b604082015260600190565b634e487b7160e01b600052603260045260246000fd5b600181811c90821680612d6d57607f821691505b60208210810361212957634e487b7160e01b600052602260045260246000fd5b6020808252600e908201526d1499595b9d1c985b9d0818d85b1b60921b604082015260600190565b634e487b7160e01b600052601160045260246000fd5b8082018082111561277757612777612db5565b8181038181111561277757612777612db5565b602080825260139082015272115512081d1c985b9cd9995c8819985a5b1959606a1b604082015260600190565b6020808252600c908201526b43726561746f72206f6e6c7960a01b604082015260600190565b602080825260169082015275141c9bda9958dd081b9bdd081cdd58d8d95cdcd99d5b60521b604082015260600190565b6020808252600f908201526e57726f6e67206d696c6573746f6e6560881b604082015260600190565b634e487b7160e01b600052604160045260246000fd5b601f821115612586576000816000526020600020601f850160051c81016020861015612edc5750805b601f850160051c820191505b8181101561192557828155600101612ee8565b67ffffffffffffffff831115612f1357612f13612e9d565b612f2783612f218354612d59565b83612eb3565b6000601f841160018114612f5b5760008515612f435750838201355b600019600387901b1c1916600186901b178355612fb5565b600083815260209020601f19861690835b82811015612f8c5786850135825560209485019460019092019101612f6c565b5086821015612fa95760001960f88860031b161c19848701351681555b505060018560011b0183555b5050505050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b604081526000612ff9604083018688612fbc565b828103602084015261300c818587612fbc565b979650505050505050565b60006001820161302957613029612db5565b5060010190565b815167ffffffffffffffff81111561304a5761304a612e9d565b61305e816130588454612d59565b84612eb3565b602080601f831160018114613093576000841561307b5750858301515b600019600386901b1c1916600185901b178555611925565b600085815260208120601f198616915b828110156130c2578886015182559484019460019091019084016130a3565b50858210156130e05787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b634e487b7160e01b600052601260045260246000fd5b600082613115576131156130f0565b500490565b60208152600061250060208301846128dc565b60008261313c5761313c6130f0565b500690565b808202811582820484141761277757612777612db5565b600060ff821660ff810361316e5761316e612db5565b6001019291505056fea264697066735822122014fe20bce634f36b1e01e2cf5402852675e2c8e6113f1744d954baa6a4c04f0864736f6c63430008180033 diff --git a/docs/evidence/deployment/verification-12080309-2026-11-07T01-09-15-627Z-standard-input.json b/docs/evidence/deployment/verification-12080309-2026-11-07T01-09-15-627Z-standard-input.json new file mode 100644 index 0000000..09ff789 --- /dev/null +++ b/docs/evidence/deployment/verification-12080309-2026-11-07T01-09-15-627Z-standard-input.json @@ -0,0 +1,24 @@ +{ + "language": "Solidity", + "sources": { + "MilestoneFund.sol": { + "content": "// SPDX-License-Identifier: MIT\r\npragma solidity ^0.8.24;\r\n\r\n/// @title MilestoneFund Lite - two-stage, contribution-weighted crowdfunding.\r\n/// @notice Educational prototype. No owner, admin withdrawal, or fee. Anyone can\r\n/// release an approved milestone. Only the creator can claim the released payout.\r\ncontract MilestoneFund {\r\n enum ProjectStatus { Funding, Successful, Failed, Completed, Expired }\r\n\r\n struct Project {\r\n address payable creator;\r\n string name;\r\n string description;\r\n uint256 target;\r\n uint256 deadline;\r\n uint256 totalRaised;\r\n uint256 escrowBalance;\r\n ProjectStatus status;\r\n uint8 currentMilestone;\r\n uint256 successfulAt;\r\n }\r\n\r\n struct Milestone {\r\n string goal;\r\n string evidence;\r\n string evidenceUrl;\r\n uint256 approvalWeight;\r\n // The amount released from escrow, including funds credited for later claim.\r\n uint256 withdrawnAmount;\r\n uint256 submittedAt;\r\n bool submitted;\r\n bool approved;\r\n bool withdrawn;\r\n }\r\n\r\n /// @notice How long backers have to approve after evidence is submitted.\r\n /// @dev Fixed at deployment and immutable afterwards, so the rules cannot be\r\n /// changed later by anyone. A short value is useful for demos.\r\n uint256 public immutable APPROVAL_TIMEOUT;\r\n /// @notice How long the creator has to submit evidence after each milestone opens.\r\n uint256 public immutable SUBMISSION_TIMEOUT;\r\n\r\n uint256 public projectCount;\r\n mapping(uint256 => Project) private projects;\r\n mapping(uint256 => Milestone[2]) private milestones;\r\n mapping(uint256 => mapping(address => uint256)) public contributions;\r\n mapping(uint256 => mapping(uint8 => mapping(address => bool))) public hasApproved;\r\n mapping(uint256 => mapping(address => bool)) public refunded;\r\n bool private entered;\r\n mapping(uint256 => uint256) private expiredRefundPools;\r\n mapping(uint256 => uint256) private secondMilestoneOpenedAt;\r\n mapping(uint256 => uint256) public claimablePayouts;\r\n\r\n event ProjectCreated(uint256 indexed projectId, address indexed creator, uint256 target, uint256 deadline);\r\n event ContributionReceived(uint256 indexed projectId, address indexed backer, uint256 amount);\r\n event FundingSuccessful(uint256 indexed projectId, uint256 totalRaised);\r\n event FundingFailed(uint256 indexed projectId);\r\n event EvidenceSubmitted(uint256 indexed projectId, uint8 indexed milestone, string evidence, string evidenceUrl);\r\n event ApprovalCast(uint256 indexed projectId, uint8 indexed milestone, address indexed backer, uint256 weight);\r\n event MilestoneApproved(uint256 indexed projectId, uint8 indexed milestone);\r\n event MilestoneReleased(uint256 indexed projectId, uint8 indexed milestone, uint256 amount);\r\n event FundsWithdrawn(uint256 indexed projectId, uint8 indexed milestone, uint256 amount);\r\n event PayoutClaimed(uint256 indexed projectId, address indexed recipient, uint256 amount);\r\n event ProjectCompleted(uint256 indexed projectId);\r\n event RefundClaimed(uint256 indexed projectId, address indexed backer, uint256 amount);\r\n event ExcessRefunded(uint256 indexed projectId, address indexed backer, uint256 amount);\r\n event ProjectExpired(uint256 indexed projectId);\r\n\r\n modifier validProject(uint256 projectId) {\r\n require(projectId < projectCount, \"Unknown project\");\r\n _;\r\n }\r\n\r\n modifier nonReentrant() {\r\n require(!entered, \"Reentrant call\");\r\n entered = true;\r\n _;\r\n entered = false;\r\n }\r\n\r\n /// @param approvalTimeout seconds backers have to approve submitted evidence\r\n /// @param submissionTimeout seconds the creator has to submit evidence\r\n constructor(uint256 approvalTimeout, uint256 submissionTimeout) {\r\n require(approvalTimeout > 0 && approvalTimeout <= 30 days, \"Invalid approval timeout\");\r\n require(submissionTimeout > 0 && submissionTimeout <= 30 days, \"Invalid submission timeout\");\r\n APPROVAL_TIMEOUT = approvalTimeout;\r\n SUBMISSION_TIMEOUT = submissionTimeout;\r\n }\r\n\r\n function createProject(\r\n string calldata name,\r\n string calldata description,\r\n uint256 target,\r\n uint256 deadline,\r\n string calldata firstGoal,\r\n string calldata secondGoal\r\n ) external returns (uint256 projectId) {\r\n require(bytes(name).length > 0 && bytes(name).length <= 120, \"Invalid name\");\r\n require(bytes(description).length > 0 && bytes(description).length <= 4000, \"Invalid description\");\r\n require(bytes(firstGoal).length > 0 && bytes(firstGoal).length <= 2000, \"Invalid first goal\");\r\n require(bytes(secondGoal).length > 0 && bytes(secondGoal).length <= 2000, \"Invalid second goal\");\r\n require(target > 0, \"Target must be positive\");\r\n require(deadline > block.timestamp, \"Deadline must be future\");\r\n projectId = projectCount++;\r\n projects[projectId] = Project(payable(msg.sender), name, description, target, deadline, 0, 0, ProjectStatus.Funding, 0, 0);\r\n milestones[projectId][0].goal = firstGoal;\r\n milestones[projectId][1].goal = secondGoal;\r\n emit ProjectCreated(projectId, msg.sender, target, deadline);\r\n }\r\n\r\n /// @notice Contributions are capped at the target. Anything above the remaining\r\n /// amount is returned in the same transaction, so totalRaised never exceeds target.\r\n function contribute(uint256 projectId) external payable validProject(projectId) nonReentrant {\r\n Project storage p = projects[projectId];\r\n require(p.status == ProjectStatus.Funding, \"Funding closed\");\r\n require(block.timestamp < p.deadline, \"Deadline reached\");\r\n require(msg.sender != p.creator, \"Creator cannot contribute\");\r\n require(msg.value > 0, \"Contribution must be positive\");\r\n uint256 remaining = p.target - p.totalRaised;\r\n uint256 accepted = msg.value > remaining ? remaining : msg.value;\r\n uint256 excess = msg.value - accepted;\r\n contributions[projectId][msg.sender] += accepted;\r\n p.totalRaised += accepted;\r\n p.escrowBalance += accepted;\r\n emit ContributionReceived(projectId, msg.sender, accepted);\r\n // Accounting is committed before the external call; a failed refund reverts everything.\r\n if (excess > 0) {\r\n (bool ok,) = payable(msg.sender).call{value: excess}(\"\");\r\n require(ok, \"Excess refund failed\");\r\n emit ExcessRefunded(projectId, msg.sender, excess);\r\n }\r\n if (p.totalRaised == p.target) {\r\n p.successfulAt = block.timestamp;\r\n p.status = ProjectStatus.Successful;\r\n emit FundingSuccessful(projectId, p.totalRaised);\r\n }\r\n }\r\n\r\n /// @notice Anyone may explicitly finalize an expired, unsuccessful campaign.\r\n function finalizeFunding(uint256 projectId) external validProject(projectId) {\r\n Project storage p = projects[projectId];\r\n require(p.status == ProjectStatus.Funding, \"Funding closed\");\r\n require(block.timestamp >= p.deadline, \"Deadline not reached\");\r\n p.status = ProjectStatus.Failed;\r\n emit FundingFailed(projectId);\r\n }\r\n\r\n function submitEvidence(uint256 projectId, uint8 milestone, string calldata evidence, string calldata evidenceUrl)\r\n external validProject(projectId)\r\n {\r\n Project storage p = projects[projectId];\r\n require(msg.sender == p.creator, \"Creator only\");\r\n require(p.status == ProjectStatus.Successful, \"Project not successful\");\r\n require(milestone < 2 && milestone == p.currentMilestone, \"Wrong milestone\");\r\n Milestone storage m = milestones[projectId][milestone];\r\n require(!m.submitted, \"Evidence already submitted\");\r\n require(block.timestamp < _milestoneDeadline(projectId, p, m), \"Submission window closed\");\r\n require(bytes(evidence).length > 0 && bytes(evidence).length <= 4000, \"Invalid evidence\");\r\n require(bytes(evidenceUrl).length > 0 && bytes(evidenceUrl).length <= 1000, \"Invalid evidence URL\");\r\n m.evidence = evidence;\r\n m.evidenceUrl = evidenceUrl;\r\n m.submitted = true;\r\n m.submittedAt = block.timestamp;\r\n emit EvidenceSubmitted(projectId, milestone, evidence, evidenceUrl);\r\n }\r\n\r\n function approveMilestone(uint256 projectId, uint8 milestone) external validProject(projectId) {\r\n Project storage p = projects[projectId];\r\n require(p.status == ProjectStatus.Successful, \"Project not successful\");\r\n require(milestone < 2 && milestone == p.currentMilestone, \"Wrong milestone\");\r\n Milestone storage m = milestones[projectId][milestone];\r\n require(m.submitted && !m.approved, \"Approval not open\");\r\n require(block.timestamp < _milestoneDeadline(projectId, p, m), \"Approval window closed\");\r\n uint256 weight = contributions[projectId][msg.sender];\r\n require(weight > 0, \"Backers only\");\r\n require(!hasApproved[projectId][milestone][msg.sender], \"Already approved\");\r\n hasApproved[projectId][milestone][msg.sender] = true;\r\n m.approvalWeight += weight;\r\n emit ApprovalCast(projectId, milestone, msg.sender, weight);\r\n // Equivalent to weight * 2 > total, without multiplication overflow.\r\n if (m.approvalWeight > p.totalRaised / 2) {\r\n m.approved = true;\r\n emit MilestoneApproved(projectId, milestone);\r\n }\r\n }\r\n\r\n /// @notice Release and pay an approved milestone to the creator in one transaction.\r\n function withdrawMilestone(uint256 projectId, uint8 milestone) external validProject(projectId) nonReentrant {\r\n Project storage p = projects[projectId];\r\n require(msg.sender == p.creator, \"Creator only\");\r\n uint256 amount = _releaseMilestone(projectId, milestone, p);\r\n emit FundsWithdrawn(projectId, milestone, amount);\r\n if (milestone == 1) emit ProjectCompleted(projectId);\r\n _sendPayout(p.creator, amount);\r\n }\r\n\r\n /// @notice Advance an approved milestone and credit its payout without sending ETH.\r\n function releaseMilestone(uint256 projectId, uint8 milestone) external validProject(projectId) nonReentrant {\r\n uint256 amount = _releaseMilestone(projectId, milestone, projects[projectId]);\r\n claimablePayouts[projectId] += amount;\r\n emit MilestoneReleased(projectId, milestone, amount);\r\n if (milestone == 1) emit ProjectCompleted(projectId);\r\n }\r\n\r\n /// @notice The creator can collect the project's released payouts at a chosen address.\r\n function claimPayout(uint256 projectId, address payable recipient) external validProject(projectId) nonReentrant {\r\n require(msg.sender == projects[projectId].creator, \"Creator only\");\r\n require(recipient != address(0), \"Invalid payout recipient\");\r\n uint256 amount = claimablePayouts[projectId];\r\n require(amount > 0, \"No payout available\");\r\n claimablePayouts[projectId] = 0;\r\n emit PayoutClaimed(projectId, recipient, amount);\r\n _sendPayout(recipient, amount);\r\n }\r\n\r\n function _releaseMilestone(uint256 projectId, uint8 milestone, Project storage p)\r\n private returns (uint256 amount)\r\n {\r\n require(p.status == ProjectStatus.Successful, \"Project not successful\");\r\n require(milestone < 2 && milestone == p.currentMilestone, \"Wrong milestone\");\r\n Milestone storage m = milestones[projectId][milestone];\r\n require(m.approved && !m.withdrawn, \"Milestone not withdrawable\");\r\n // floor(total * 2 / 5), split into quotient and remainder to avoid overflow.\r\n amount = milestone == 0\r\n ? (p.totalRaised / 5) * 2 + (p.totalRaised % 5) * 2 / 5\r\n : p.escrowBalance;\r\n m.withdrawn = true;\r\n m.withdrawnAmount = amount;\r\n p.escrowBalance -= amount;\r\n p.currentMilestone++;\r\n if (milestone == 0) {\r\n secondMilestoneOpenedAt[projectId] = block.timestamp;\r\n } else {\r\n p.status = ProjectStatus.Completed;\r\n }\r\n }\r\n\r\n function _sendPayout(address payable recipient, uint256 amount) private {\r\n if (amount == 0) return;\r\n (bool sent,) = recipient.call{value: amount}(\"\");\r\n require(sent, \"ETH transfer failed\");\r\n }\r\n\r\n function claimRefund(uint256 projectId) external validProject(projectId) nonReentrant {\r\n Project storage p = projects[projectId];\r\n require(p.status == ProjectStatus.Failed, \"Project not failed\");\r\n uint256 amount = contributions[projectId][msg.sender];\r\n require(amount > 0 && !refunded[projectId][msg.sender], \"No refund available\");\r\n refunded[projectId][msg.sender] = true;\r\n p.escrowBalance -= amount;\r\n emit RefundClaimed(projectId, msg.sender, amount);\r\n (bool sent,) = payable(msg.sender).call{value: amount}(\"\");\r\n require(sent, \"ETH transfer failed\");\r\n }\r\n\r\n /// @notice Reclaim a share of the remaining escrow when the current milestone times\r\n /// out: either backers did not approve submitted evidence, or the creator never\r\n /// submitted it. Each share uses the same pool, frozen before the first refund.\r\n function claimExpiredRefund(uint256 projectId) external validProject(projectId) nonReentrant {\r\n Project storage p = projects[projectId];\r\n string memory blocker = _expiredRefundBlocker(projectId, p);\r\n require(bytes(blocker).length == 0, blocker);\r\n uint256 amount = _expiredRefundAmount(projectId, p, msg.sender);\r\n require(amount > 0, \"No refund available\");\r\n\r\n refunded[projectId][msg.sender] = true;\r\n if (p.status == ProjectStatus.Successful) {\r\n expiredRefundPools[projectId] = p.escrowBalance;\r\n p.status = ProjectStatus.Expired;\r\n emit ProjectExpired(projectId);\r\n }\r\n p.escrowBalance -= amount;\r\n emit RefundClaimed(projectId, msg.sender, amount);\r\n (bool sent,) = payable(msg.sender).call{value: amount}(\"\");\r\n require(sent, \"ETH transfer failed\");\r\n }\r\n\r\n /// @notice Returns the claimable expiry refund in wei, or zero if none is available.\r\n function getExpiredRefundAmount(uint256 projectId, address backer)\r\n external view validProject(projectId) returns (uint256)\r\n {\r\n Project storage p = projects[projectId];\r\n if (bytes(_expiredRefundBlocker(projectId, p)).length != 0) return 0;\r\n return _expiredRefundAmount(projectId, p, backer);\r\n }\r\n\r\n /// @notice The current submission or approval deadline and whether the window is open.\r\n /// @dev A zero deadline means there is no pending submission or approval.\r\n function getMilestoneWindow(uint256 projectId)\r\n external view validProject(projectId) returns (uint256 deadline, bool open)\r\n {\r\n Project storage p = projects[projectId];\r\n if (p.status != ProjectStatus.Successful && p.status != ProjectStatus.Expired) return (0, false);\r\n Milestone storage m = milestones[projectId][p.currentMilestone];\r\n if (m.approved) return (0, false);\r\n deadline = _milestoneDeadline(projectId, p, m);\r\n open = block.timestamp < deadline;\r\n }\r\n\r\n function _expiredRefundBlocker(uint256 projectId, Project storage p) private view returns (string memory) {\r\n if (p.status != ProjectStatus.Successful && p.status != ProjectStatus.Expired) return \"Project not active\";\r\n if (p.currentMilestone >= 2) return \"Project completed\";\r\n Milestone storage m = milestones[projectId][p.currentMilestone];\r\n if (m.approved) return \"Milestone already approved\";\r\n if (block.timestamp < _milestoneDeadline(projectId, p, m)) {\r\n return m.submitted ? \"Approval window still open\" : \"Submission window still open\";\r\n }\r\n return \"\";\r\n }\r\n\r\n function _milestoneDeadline(uint256 projectId, Project storage p, Milestone storage m)\r\n private view returns (uint256)\r\n {\r\n if (m.submitted) return m.submittedAt + APPROVAL_TIMEOUT;\r\n uint256 openedAt = p.currentMilestone == 0 ? p.successfulAt : secondMilestoneOpenedAt[projectId];\r\n return openedAt + SUBMISSION_TIMEOUT;\r\n }\r\n\r\n function _expiredRefundAmount(uint256 projectId, Project storage p, address backer) private view returns (uint256) {\r\n if (refunded[projectId][backer]) return 0;\r\n uint256 pool = p.status == ProjectStatus.Expired ? expiredRefundPools[projectId] : p.escrowBalance;\r\n return contributions[projectId][backer] * pool / p.totalRaised;\r\n }\r\n\r\n function getProject(uint256 projectId) external view validProject(projectId) returns (Project memory) {\r\n return projects[projectId];\r\n }\r\n\r\n function getMilestone(uint256 projectId, uint8 milestone) external view validProject(projectId) returns (Milestone memory) {\r\n require(milestone < 2, \"Invalid milestone\");\r\n return milestones[projectId][milestone];\r\n }\r\n}\r\n" + } + }, + "settings": { + "optimizer": { + "enabled": true, + "runs": 200 + }, + "evmVersion": "paris", + "outputSelection": { + "*": { + "*": [ + "abi", + "evm.deployedBytecode.object", + "metadata" + ] + } + } + } +} diff --git a/docs/evidence/deployment/verification-12080309-2026-11-07T01-09-15-627Z.json b/docs/evidence/deployment/verification-12080309-2026-11-07T01-09-15-627Z.json new file mode 100644 index 0000000..6a5c792 --- /dev/null +++ b/docs/evidence/deployment/verification-12080309-2026-11-07T01-09-15-627Z.json @@ -0,0 +1,292 @@ +{ + "schemaVersion": 1, + "observedAt": "2026-11-07T01:09:15.695Z", + "status": "immutable-substitution-match", + "chainId": 11155111, + "address": "0x5A5AeaE5553Feb5c5b27FEe5ec8b24E3ED2B964F", + "rpc": { + "origin": "https://ethereum-sepolia-rpc.publicnode.com", + "endpointSha256": "18dddd47c8f4b183a5b2322a292c534f78b4c31ed168fbbc1af18f41767f3899", + "credentialsAndPathOmitted": true + }, + "block": { + "number": 12080309, + "hash": "0x2e3a52b91ce34a87eca973ecb9d5ff4fe96e777129349002d33bb4116cbfda66", + "timestamp": 1794013740, + "timeUTC": "2026-11-07T01:09:00.000Z", + "timeBeijing": "2026-11-07 09:09:00 UTC+08:00" + }, + "source": { + "file": "contracts/MilestoneFund.sol", + "sha256": "af270b6a4389a68064871d17e626c29fdb3ef7a1633f11f528cad4938285354b", + "bytes": 17158, + "normalizedLfSha256": "072b7795986e5fdd3d9efbec3950c808fbe791f9b1829e1ecd08198a6c881bd1", + "normalizedLfBytes": 16825 + }, + "installedCompilers": [ + { + "package": "solc", + "version": "0.8.24+commit.e11b9ed9.Emscripten.clang" + }, + { + "package": "solc-deployed", + "version": "0.8.34+commit.80d5c536.Emscripten.clang" + } + ], + "onChain": { + "runtimeBytes": 12717, + "runtimeKeccak256": "0xc6c8e7749da17e6b4f18dd73312b0195eae53625685b0fbe18b727043b76b3c3", + "executableBytes": 12664, + "executableKeccak256": "0xbad2b1631e9e4788364a9189f5abd56eab3a0adb38192541ad079025bbfd3287", + "metadata": { + "recognized": true, + "cborBytes": 51, + "strippedBytes": 53, + "compilerVersion": "0.8.24", + "cborHex": "0xa264697066735822122014fe20bce634f36b1e01e2cf5402852675e2c8e6113f1744d954baa6a4c04f0864736f6c6343000818", + "fields": { + "ipfs": "0x122014fe20bce634f36b1e01e2cf5402852675e2c8e6113f1744d954baa6a4c04f08", + "solc": "0x000818" + } + } + }, + "search": { + "maxCompiles": 64, + "actualCompiles": 1, + "optimizerEnabled": [ + false, + true + ], + "optimizerRuns": [ + 200 + ], + "viaIR": false, + "compilerEvmCandidates": [ + { + "package": "solc", + "evmVersions": [ + "paris", + "shanghai", + "cancun" + ] + }, + { + "package": "solc-deployed", + "evmVersions": [ + "osaka", + "prague", + "cancun", + "shanghai", + "paris" + ] + } + ], + "metadataRefinements": { + "sourcePaths": [ + "MilestoneFund.sol", + "contracts/MilestoneFund.sol" + ], + "newlines": [ + "LF", + "CRLF" + ] + }, + "stoppedAfterFirstSourceProvenMatch": true + }, + "repositoryDefault": { + "id": 1, + "package": "solc", + "compilerVersion": "0.8.24+commit.e11b9ed9.Emscripten.clang", + "optimizer": { + "enabled": true, + "runs": 200 + }, + "evmVersion": "paris", + "viaIR": false, + "sourcePath": "MilestoneFund.sol", + "sourceVariant": "working-tree", + "sourceSha256": "af270b6a4389a68064871d17e626c29fdb3ef7a1633f11f528cad4938285354b", + "sourceBytes": 17158, + "standardInputSha256": "172eaa4e351fa6c4525f0c2d9570b4088fdf572996055dc721e41db0f9ed5cd4", + "repositoryDefault": true, + "runtimeBytes": 12717, + "runtimeKeccak256": "0x7e3ae018df0e7a7100be4775cccd5fe2460c87f3d01744e49c1a9bdc9c81cb9e", + "executableBytes": 12664, + "executableKeccak256": "0xcc2f116bad17db28135030c2843e5603f8511fedc8387168ca629e616dfe304a", + "metadata": { + "recognized": true, + "cborBytes": 51, + "strippedBytes": 53, + "compilerVersion": "0.8.24", + "cborHex": "0xa26469706673582212204ea8f70c0b1a2a6b5d9e8838c98fbdef7b9bb455ccb6fd29ad680a1548cb866664736f6c6343000818", + "fields": { + "ipfs": "0x12204ea8f70c0b1a2a6b5d9e8838c98fbdef7b9bb455ccb6fd29ad680a1548cb8666", + "solc": "0x000818" + } + }, + "fullMatch": false, + "executableMatch": false, + "immutableMatch": true, + "immutableSlots": [ + { + "position": 1024, + "onChainWord": 600 + }, + { + "position": 1076, + "onChainWord": 600 + }, + { + "position": 9354, + "onChainWord": 600 + }, + { + "position": 9461, + "onChainWord": 600 + } + ], + "abiMatchesRepository": true + }, + "matchedCandidate": { + "id": 1, + "package": "solc", + "compilerVersion": "0.8.24+commit.e11b9ed9.Emscripten.clang", + "optimizer": { + "enabled": true, + "runs": 200 + }, + "evmVersion": "paris", + "viaIR": false, + "sourcePath": "MilestoneFund.sol", + "sourceVariant": "working-tree", + "sourceSha256": "af270b6a4389a68064871d17e626c29fdb3ef7a1633f11f528cad4938285354b", + "sourceBytes": 17158, + "standardInputSha256": "172eaa4e351fa6c4525f0c2d9570b4088fdf572996055dc721e41db0f9ed5cd4", + "repositoryDefault": true, + "runtimeBytes": 12717, + "runtimeKeccak256": "0x7e3ae018df0e7a7100be4775cccd5fe2460c87f3d01744e49c1a9bdc9c81cb9e", + "executableBytes": 12664, + "executableKeccak256": "0xcc2f116bad17db28135030c2843e5603f8511fedc8387168ca629e616dfe304a", + "metadata": { + "recognized": true, + "cborBytes": 51, + "strippedBytes": 53, + "compilerVersion": "0.8.24", + "cborHex": "0xa26469706673582212204ea8f70c0b1a2a6b5d9e8838c98fbdef7b9bb455ccb6fd29ad680a1548cb866664736f6c6343000818", + "fields": { + "ipfs": "0x12204ea8f70c0b1a2a6b5d9e8838c98fbdef7b9bb455ccb6fd29ad680a1548cb8666", + "solc": "0x000818" + } + }, + "fullMatch": false, + "executableMatch": false, + "immutableMatch": true, + "immutableSlots": [ + { + "position": 1024, + "onChainWord": 600 + }, + { + "position": 1076, + "onChainWord": 600 + }, + { + "position": 9354, + "onChainWord": 600 + }, + { + "position": 9461, + "onChainWord": 600 + } + ], + "abiMatchesRepository": true + }, + "candidates": [ + { + "id": 1, + "package": "solc", + "compilerVersion": "0.8.24+commit.e11b9ed9.Emscripten.clang", + "optimizer": { + "enabled": true, + "runs": 200 + }, + "evmVersion": "paris", + "viaIR": false, + "sourcePath": "MilestoneFund.sol", + "sourceVariant": "working-tree", + "sourceSha256": "af270b6a4389a68064871d17e626c29fdb3ef7a1633f11f528cad4938285354b", + "sourceBytes": 17158, + "standardInputSha256": "172eaa4e351fa6c4525f0c2d9570b4088fdf572996055dc721e41db0f9ed5cd4", + "repositoryDefault": true, + "runtimeBytes": 12717, + "runtimeKeccak256": "0x7e3ae018df0e7a7100be4775cccd5fe2460c87f3d01744e49c1a9bdc9c81cb9e", + "executableBytes": 12664, + "executableKeccak256": "0xcc2f116bad17db28135030c2843e5603f8511fedc8387168ca629e616dfe304a", + "metadata": { + "recognized": true, + "cborBytes": 51, + "strippedBytes": 53, + "compilerVersion": "0.8.24", + "cborHex": "0xa26469706673582212204ea8f70c0b1a2a6b5d9e8838c98fbdef7b9bb455ccb6fd29ad680a1548cb866664736f6c6343000818", + "fields": { + "ipfs": "0x12204ea8f70c0b1a2a6b5d9e8838c98fbdef7b9bb455ccb6fd29ad680a1548cb8666", + "solc": "0x000818" + } + }, + "fullMatch": false, + "executableMatch": false, + "immutableMatch": true, + "immutableSlots": [ + { + "position": 1024, + "onChainWord": 600 + }, + { + "position": 1076, + "onChainWord": 600 + }, + { + "position": 9354, + "onChainWord": 600 + }, + { + "position": 9461, + "onChainWord": 600 + } + ], + "abiMatchesRepository": true + } + ], + "comparisonScope": "Full match compares every runtime byte, including validated CBOR metadata. Executable-only comparison strips only the recognized CBOR trailer and its two-byte length. An immutable-substitution match requires equal-length executables where every difference is a two-byte zero placeholder locally substituted with a non-zero on-chain constructor value; the slot positions and values are recorded in the immutable evidence file. No opcode normalization or selector-only comparison is used. This verifies runtime at the fixed block, not creation transaction provenance or security.", + "unchanged": [ + "contracts/MilestoneFund.sol", + "scripts/compile-contract.mjs", + "src/abi/MilestoneFund.json" + ], + "evidenceFiles": [ + { + "role": "on-chain-runtime", + "file": "verification-12080309-2026-11-07T01-09-15-627Z-runtime.hex", + "sha256": "832542e5f86b99bb7bb2c30bd35e82efff7846bf5e94d383fc0301c2b29a9624", + "bytes": 25437 + }, + { + "role": "matching-standard-input", + "file": "verification-12080309-2026-11-07T01-09-15-627Z-standard-input.json", + "sha256": "2ab3d822a3ad633d6c736129507691c07cbd5c1e18caf455dc1170a482c8818f", + "bytes": 18305 + }, + { + "role": "matching-compiler-metadata", + "file": "verification-12080309-2026-11-07T01-09-15-627Z-metadata.json", + "sha256": "47e71ae969ccda9dc89c3f587b45c190a1fd74f31a73f064d7e2e10e580f1376", + "bytes": 12927 + }, + { + "role": "immutable-substitution", + "file": "verification-12080309-2026-11-07T01-09-15-627Z-immutable.json", + "sha256": "3e402d1bff58555b069b95e5a64527f4029f9ff748b72a994a95bad155b59b2c", + "bytes": 415 + } + ] +} diff --git a/scripts/verify-deployment.mjs b/scripts/verify-deployment.mjs index 27e7f34..db9b835 100644 --- a/scripts/verify-deployment.mjs +++ b/scripts/verify-deployment.mjs @@ -24,7 +24,7 @@ function options() { const names = { "--rpc": "rpc", "--address": "address", "--block": "block", "--out": "out", "--timeout-ms": "timeout" }; for (let i = 2; i < process.argv.length; i++) { if (process.argv[i] === "--help") { - console.log("node scripts/verify-deployment.mjs [--rpc URL] [--address ADDRESS] [--block NUMBER|latest] [--out FILE.json] [--timeout-ms 20000]\nEnvironment: SEPOLIA_RPC_URL / VITE_SEPOLIA_RPC_URL, CONTRACT_ADDRESS / VITE_CONTRACT_ADDRESS, VERIFY_BLOCK.\nExit: 0 = full runtime match; 2 = executable-only match; 3 = no match; 1 = error. Existing output files are never overwritten."); + console.log("node scripts/verify-deployment.mjs [--rpc URL] [--address ADDRESS] [--block NUMBER|latest] [--out FILE.json] [--timeout-ms 20000]\nEnvironment: SEPOLIA_RPC_URL / VITE_SEPOLIA_RPC_URL, CONTRACT_ADDRESS / VITE_CONTRACT_ADDRESS, VERIFY_BLOCK.\nExit: 0 = full runtime match or immutable-substitution match; 2 = executable-only match; 3 = no match; 1 = error. Existing output files are never overwritten."); return null; } const key = names[process.argv[i]]; @@ -128,6 +128,31 @@ function splitRuntime(code) { } } +// Solidity emits immutable variables as two-byte zero placeholders in the +// compiled runtime; the constructor substitutes the actual values at deploy +// time. Return the placeholder slots when every executable difference is a +// zero placeholder locally with a non-zero on-chain word, otherwise null. +function immutableSubstitution(localExecutable, onChainExecutable) { + const local = Buffer.from(localExecutable.slice(2), "hex"); + const onChainBytes = Buffer.from(onChainExecutable.slice(2), "hex"); + if (local.length !== onChainBytes.length) return null; + const differences = []; + for (let i = 0; i < local.length; i++) { + if (local[i] !== onChainBytes[i]) differences.push(i); + } + if (differences.length === 0 || differences.length % 2 !== 0) return null; + const slots = []; + for (let i = 0; i < differences.length; i += 2) { + const position = differences[i]; + if (differences[i + 1] !== position + 1) return null; + if (local.readUInt16BE(position) !== 0) return null; + const onChainWord = onChainBytes.readUInt16BE(position); + if (onChainWord === 0) return null; + slots.push({ position, onChainWord }); + } + return slots; +} + async function verify(config) { const sourceFile = path.join(root, "contracts/MilestoneFund.sol"); const rawSource = fs.readFileSync(sourceFile, "utf8"); @@ -174,6 +199,8 @@ async function verify(config) { const split = splitRuntime(runtime); const fullMatch = runtime === code; const executableMatch = split.metadata.recognized && split.executable === onChain.executable; + const immutableSlots = executableMatch ? [] : immutableSubstitution(split.executable, onChain.executable); + const immutableMatch = immutableSlots !== null; const summary = { id: candidates.length + 1, package: engine.label, compilerVersion, optimizer: { enabled, runs: 200 }, evmVersion, viaIR: false, @@ -181,27 +208,31 @@ async function verify(config) { standardInputSha256: sha256(JSON.stringify(input)), repositoryDefault, runtimeBytes: (runtime.length - 2) / 2, runtimeKeccak256: keccak256(runtime), executableBytes: (split.executable.length - 2) / 2, executableKeccak256: keccak256(split.executable), - metadata: split.metadata, fullMatch, executableMatch, + metadata: split.metadata, fullMatch, executableMatch, immutableMatch, immutableSlots, abiMatchesRepository: JSON.stringify(artifact.abi) === JSON.stringify(repositoryAbi), }; candidates.push(summary); - if (fullMatch || (!best && executableMatch)) best = { summary, input, artifact }; + // Rank: full byte match 3 > immutable-substitution match 2 > executable-only 1. + const rank = fullMatch ? 3 : immutableMatch ? 2 : executableMatch ? 1 : 0; + if (rank > 0 && (!best || rank > best.rank)) best = { rank, summary, input, artifact }; return summary; } // Always record the unchanged repository compile settings first. compileCandidate(compilers[0], true, "paris", "MilestoneFund.sol", rawSource, "working-tree", true); + const sourceProven = () => best?.summary.fullMatch || best?.summary.immutableMatch; outer: for (const engine of compilers) { for (const evm of engine.evms) { for (const enabled of [false, true]) { - if (best?.summary.fullMatch) break outer; + if (sourceProven()) break outer; const result = compileCandidate(engine, enabled, evm, "MilestoneFund.sol", rawSource, "working-tree"); + if (sourceProven()) break outer; if (!result?.executableMatch || result.fullMatch) continue; // Metadata depends on source-unit path and exact bytes, including newlines. for (const sourcePath of ["MilestoneFund.sol", "contracts/MilestoneFund.sol"]) { for (const [variant, content] of [["LF", normalizedLf], ["CRLF", normalizedLf.replace(/\n/g, "\r\n")]]) { compileCandidate(engine, enabled, evm, sourcePath, content, variant); - if (best?.summary.fullMatch) break outer; + if (sourceProven()) break outer; } } } @@ -210,7 +241,13 @@ async function verify(config) { // Avoid reporting success against a block that changed during compilation. const canonical = await rpc(provider.getBlock(block.number), "recheck block hash"); if (!canonical || canonical.hash !== block.hash) throw new Error("Block hash changed during verification; rerun at a stable block."); - const status = best?.summary.fullMatch ? "full-match" : best ? "executable-only-match" : "no-match"; + const status = best?.summary.fullMatch + ? "full-match" + : best?.summary.immutableMatch + ? "immutable-substitution-match" + : best + ? "executable-only-match" + : "no-match"; const timestamp = new Date().toISOString().replace(/[:.]/g, "-"); const output = path.resolve(config.out || path.join(root, "docs/evidence/deployment", `verification-${block.number}-${timestamp}.json`)); if (!output.endsWith(".json")) throw new Error("--out must end in .json"); @@ -219,6 +256,16 @@ async function verify(config) { if (best) { files.push({ role: "matching-standard-input", file: stem + "-standard-input.json", content: json(best.input) }); files.push({ role: "matching-compiler-metadata", file: stem + "-metadata.json", content: best.artifact.metadata + "\n" }); + if (best.summary.immutableMatch && !best.summary.fullMatch) { + files.push({ + role: "immutable-substitution", + file: stem + "-immutable.json", + content: json({ + explanation: "Each slot is a two-byte immutable placeholder (zero in compiled runtime) substituted with the constructor value at deployment.", + slots: best.summary.immutableSlots, + }), + }); + } } for (const filename of [output, ...files.map((item) => item.file)]) { if (fs.existsSync(filename)) throw new Error(`Refusing to overwrite evidence: ${filename}`); @@ -231,17 +278,17 @@ async function verify(config) { source: { file: "contracts/MilestoneFund.sol", sha256: sha256(rawSource), bytes: Buffer.byteLength(rawSource), normalizedLfSha256: sha256(normalizedLf), normalizedLfBytes: Buffer.byteLength(normalizedLf) }, installedCompilers: compilers.map((item) => ({ package: item.label, version: item.compiler.version() })), onChain: { runtimeBytes: (code.length - 2) / 2, runtimeKeccak256: keccak256(code), executableBytes: (onChain.executable.length - 2) / 2, executableKeccak256: keccak256(onChain.executable), metadata: onChain.metadata }, - search: { maxCompiles: 64, actualCompiles: candidates.length, optimizerEnabled: [false, true], optimizerRuns: [200], viaIR: false, compilerEvmCandidates: compilers.map((item) => ({ package: item.label, evmVersions: item.evms })), metadataRefinements: { sourcePaths: ["MilestoneFund.sol", "contracts/MilestoneFund.sol"], newlines: ["LF", "CRLF"] }, stoppedAfterFirstFullMatch: status === "full-match" }, + search: { maxCompiles: 64, actualCompiles: candidates.length, optimizerEnabled: [false, true], optimizerRuns: [200], viaIR: false, compilerEvmCandidates: compilers.map((item) => ({ package: item.label, evmVersions: item.evms })), metadataRefinements: { sourcePaths: ["MilestoneFund.sol", "contracts/MilestoneFund.sol"], newlines: ["LF", "CRLF"] }, stoppedAfterFirstSourceProvenMatch: status === "full-match" || status === "immutable-substitution-match" }, repositoryDefault: candidates[0], matchedCandidate: best?.summary || null, candidates, - comparisonScope: "Full match compares every runtime byte, including validated CBOR metadata. Executable-only comparison strips only the recognized CBOR trailer and its two-byte length. No opcode normalization or selector-only comparison is used. This verifies runtime at the fixed block, not creation transaction provenance or security.", + comparisonScope: "Full match compares every runtime byte, including validated CBOR metadata. Executable-only comparison strips only the recognized CBOR trailer and its two-byte length. An immutable-substitution match requires equal-length executables where every difference is a two-byte zero placeholder locally substituted with a non-zero on-chain constructor value; the slot positions and values are recorded in the immutable evidence file. No opcode normalization or selector-only comparison is used. This verifies runtime at the fixed block, not creation transaction provenance or security.", unchanged: ["contracts/MilestoneFund.sol", "scripts/compile-contract.mjs", "src/abi/MilestoneFund.json"], evidenceFiles: files.map((item) => ({ role: item.role, file: path.basename(item.file), sha256: sha256(item.content), bytes: Buffer.byteLength(item.content) })), }; fs.mkdirSync(path.dirname(output), { recursive: true }); for (const item of files) fs.writeFileSync(item.file, item.content, { flag: "wx" }); fs.writeFileSync(output, json(result), { flag: "wx" }); - console.log(json({ status, blockNumber: block.number, blockHash: block.hash, onChainRuntimeBytes: result.onChain.runtimeBytes, runtimeKeccak256: result.onChain.runtimeKeccak256, chainMetadataCompiler: onChain.metadata.compilerVersion, repositoryDefaultFullMatch: candidates[0].fullMatch, repositoryDefaultExecutableMatch: candidates[0].executableMatch, matchedCandidate: best?.summary || null, evidence: output })); - return status === "full-match" ? 0 : status === "executable-only-match" ? 2 : 3; + console.log(json({ status, blockNumber: block.number, blockHash: block.hash, onChainRuntimeBytes: result.onChain.runtimeBytes, runtimeKeccak256: result.onChain.runtimeKeccak256, chainMetadataCompiler: onChain.metadata.compilerVersion, repositoryDefaultFullMatch: candidates[0].fullMatch, repositoryDefaultExecutableMatch: candidates[0].executableMatch, repositoryDefaultImmutableMatch: candidates[0].immutableMatch, matchedCandidate: best?.summary || null, evidence: output })); + return status === "full-match" || status === "immutable-substitution-match" ? 0 : status === "executable-only-match" ? 2 : 3; } finally { provider.destroy(); } From 3faacca7deeeb85c7cadae0107df0b9f13acdb1b Mon Sep 17 00:00:00 2001 From: Jack Date: Sat, 7 Nov 2026 09:13:54 +0800 Subject: [PATCH 2/3] feat(frontend): split vendor chunks to remove 500 kB warning --- vite.config.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/vite.config.js b/vite.config.js index 03069f4..811cb72 100644 --- a/vite.config.js +++ b/vite.config.js @@ -4,4 +4,16 @@ import react from "@vitejs/plugin-react"; export default defineConfig({ plugins: [react()], server: { port: 5173 }, + build: { + rollupOptions: { + output: { + // Split large vendor libraries into separate cacheable chunks so the + // app chunk stays under Vite's 500 kB warning threshold. + manualChunks: { + ethers: ["ethers"], + react: ["react", "react-dom"], + }, + }, + }, + }, }); From 0c42b01509843cbd679d127050d2d6bc10392a2a Mon Sep 17 00:00:00 2001 From: Jack Date: Sat, 7 Nov 2026 10:26:00 +0800 Subject: [PATCH 3/3] chore(scripts): default deployment verification to current Sepolia contract --- scripts/verify-deployment.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/verify-deployment.mjs b/scripts/verify-deployment.mjs index db9b835..d85aae5 100644 --- a/scripts/verify-deployment.mjs +++ b/scripts/verify-deployment.mjs @@ -9,7 +9,7 @@ import { FetchRequest, JsonRpcProvider, getAddress, keccak256 } from "ethers"; // Read-only deployment verification. No signer, wallet, send method, or ABI writes. const root = fileURLToPath(new URL("../", import.meta.url)); const defaultRpc = "https://ethereum-sepolia-rpc.publicnode.com"; -const defaultAddress = "0x9b824CA674432B390E30A5164a76c04EeAa8f686"; +const defaultAddress = "0x5A5AeaE5553Feb5c5b27FEe5ec8b24E3ED2B964F"; const sha256 = (value) => crypto.createHash("sha256").update(value).digest("hex"); const json = (value) => JSON.stringify(value, null, 2) + "\n";