Repository navigation
Keep a finalized proposal's slots for the next one to overwrite - #316
Merged
Merged
Conversation
finalizeReputation deleted the whole pending struct. That earned a refund, and then the agent's next proposal paid about 22,100 gas for each slot it filled from zero. It now clears only exists, which every reader checks first, and the next proposal writes every field, so nothing carries over. Rejecting, discarding and zeroing still delete the slot. Measured as separate transactions, the next proposal falls from 227,155 to 121,755 gas and a propose and finalize cycle from 351,082 to 252,540; the finalize alone costs 6,858 more for its smaller refund. Tests pin that nothing acts on the fields left behind or inherits them, and bound the next proposal's gas. The invariant model, mutation R26 and the docs that read a finalized slot as empty follow the change. 799 forge tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RunTimeAdmin
added a commit
that referenced
this pull request
Nov 15, 2026
Main brought #316, whose test counts share a README paragraph with this branch's. The version moves in package.json, the lockfile and server.json; the README's "use alpha.20" lines follow once alpha.21 is on npm. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Finding 11 from the 15 November performance review. The oracle, SDK and site parts of the other moderate findings are separate PRs.
What changes
finalizeReputationended withdelete pendingScores[didHash]. That earned a refund, and then the agent's next proposal paid about 22,100 gas for each of the six slots it filled from zero, where overwriting a slot that still holds a value costs about 5,000. It now clearsexistsand leaves the other fields for the next proposal to overwrite.rejectReputation,discardStrandedScoreandzeroReputationstill delete.Measured in forge with each call as its own transaction (cold storage, refunds, the 21,000 base):
lastUpdatedeach epochlastUpdated= 0What reads differently
getPendingScore(and the publicpendingScoresgetter) after a finalize returns that proposal's fields withexistsfalse, where it returned zeros. Everything in this repo checksexistsfirst: the contract's own paths, the oracle (chain.js,epoch-policy.js,index.js), the watcher, the SDK and the site's four pages. An outside reader that takesproposedAt != 0to mean "pending" would misread a finalized slot.Updated to match:
docs/incident-operator-key.mdstep 3 readproposerwithout checkingexists.oracle/RUNBOOK-second-operator.mdstep 2 looked for an empty slot; it now testsexists(word 8).docs/authorisation-matrix.mdsaid finalize deletes the proposal; threeoracle/chain.jscomments said an ended slot is zeroed.test/ReputationInvariant.t.solmodelled finalize as a delete, and the invariant that compares whole structs would have failed.scripts/mutation/mutate-invariants.sh: mutation R26 pointed at the deleted line, and would have silently mutatedrejectReputation's delete instead.Deploy
An implementation-only upgrade of
SigvaraReputation. No layout change:forge inspect storageLayoutis identical before and after, and the slot-pinning tests (test_storageLayout_*,test/Upgrade.t.sol) pass. Nothing else needs to move with it.Tests
799 forge tests: 787 run and pass, 12 skip without a fork URL (README and whitepaper updated). New, in
test/SigvaraReputation.t.sol:existsis false, and finalize, reject and discard all revertNoScorePending;🤖 Generated with Claude Code