Repository navigation
Conversation
…and domain-bound signatures ### Description This PR updates the deployment scripts and test fixtures within the `ai-cns/smart-contract` package to align with the newly hardened governance contracts and resolve testing configuration failures. **Vulnerabilities & Security Defects Remediated:** * **Test Fixtures and Contract Configuration (`scripts/deploy.ts`, `scripts/deploy-Agreement.ts`, `scripts/deploy-Initiatives.ts`):** The deployment sequence was previously misconfigured and failed to set up the agreement dependency. The scripts now correctly deploy the Initiatives contract first, deploy the Agreement contract against the real deployed address, and successfully configure the reciprocal relationship by calling `setAgreementContract`. * **Domain-Bound Signature Payloads (`scripts/deploy-Agreement.ts`):** The data-fill routines and test payloads have been updated to properly sign the new domain-bound payload. The `signAgreementPayload` helper now accurately hashes the contract address, chain ID, caller, profile, agent nature, and constitution hash, directly satisfying the hardened `ECDSA` recovery requirements introduced in `NetworkStateAgreement`.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Reviewed by Cursor Bugbot for commit f98575f. Configure here.
| function _requireAgreement() internal view { | ||
| require(agreementContract != address(0), "Agreement contract not configured"); | ||
| require(INetworkStateAgreement(agreementContract).hasAgreed(msg.sender), "Agreement not signed"); | ||
| } |
There was a problem hiding this comment.
Missing agreement membership check
High Severity
_requireAgreement calls hasAgreed(address) on the agreement contract, but NetworkStateAgreement never exposes that function. Membership lives only as a field on userInformation, so upvote and downvote revert once agreementContract is configured and voting stays unusable in production.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit f98575f. Configure here.
| //TODO: Call NetworkStateAgreement contract to check that the user has signed the agreement | ||
| for (uint256 i = 0; i < initiatives.length; i++) { | ||
| if (initiatives[i].id == _initiativeId) { | ||
| initiatives[i].upvotes += _votesNumber; |
There was a problem hiding this comment.
Owner captures initiative funding
Medium Severity
updateStatus is now onlyOwner, but still assigns instigator to msg.sender when the vote threshold is met. That makes the contract owner the only possible instigator, so raised initiative funds can only be withdrawn by the owner rather than an initiative lead.
Reviewed by Cursor Bugbot for commit f98575f. Configure here.


Description
This PR updates the deployment scripts and test fixtures within the
ai-cns/smart-contractpackage to align with the newly hardened governance contracts and resolve testing configuration failures.Vulnerabilities & Security Defects Remediated:
scripts/deploy.ts,scripts/deploy-Agreement.ts,scripts/deploy-Initiatives.ts): The deployment sequence was previously misconfigured and failed to set up the agreement dependency. The scripts now correctly deploy the Initiatives contract first, deploy the Agreement contract against the real deployed address, and successfully configure the reciprocal relationship by callingsetAgreementContract.scripts/deploy-Agreement.ts): The data-fill routines and test payloads have been updated to properly sign the new domain-bound payload. ThesignAgreementPayloadhelper now accurately hashes the contract address, chain ID, caller, profile, agent nature, and constitution hash, directly satisfying the hardenedECDSArecovery requirements introduced inNetworkStateAgreement.Note
High Risk
Changes on-chain access control, ETH movement, and credit/voting eligibility. The new
INetworkStateAgreementinterface also includes a function body, which will not compile as written.Overview
Hardens
NetworkStateInitiativesso voting, credits, funding, and team updates are gated and fail closed, then deploys it in lockstep with the agreement contract.Voting now requires a configured agreement contract and a signed membership check. Credits can only be set by the owner or that agreement contract. Status updates are owner-only; team membership is limited to owner/ideator/instigator. Initiative IDs use a nonce plus chain/contract domain instead of block entropy. ETH withdrawals use
callplusnonReentrant, and lookups revert if the initiative is missing.Deploy scripts now create Initiatives first, pass its address into Agreement, then call
setAgreementContract. Seed signatures hash contract, chain, signer, profile, nature, and constitution instead of signing the constitution hash alone.Reviewed by Cursor Bugbot for commit 1b20a83. Bugbot is set up for automated code reviews on this repo. Configure here.