Repository navigation
Bound slash evidence, read standing and slash state alone, and verify proofs from calldata - #326
Merged
Merged
Conversation
…view - 17: initiateSlash refuses evidence longer than MAX_EVIDENCE_BYTES (256) with EvidenceTooLong. Staking gains slashState, the state of the latest proposal alone, and the Reader reads it instead of copying the whole proposal with its evidence. A trust read of an agent with a slash open falls from 86,184 gas (one byte of evidence) and 104,554 (256 bytes) to 68,501 either way. - 18: verifyEvidence checks the proof with MerkleProof.verifyCalldata instead of copying it into memory. An eleven-hash proof falls from 10,654 to 10,411 gas. - 19: identity gains standingOf (operator, status, registeredAt). Reputation's scorability check and staking's deposit, withdrawal, claim and dispute read it instead of getIdentity, about 4,900 gas less a call. Upgrade.s.sol refuses a reputation or staking upgrade against an identity without it. No storage is added or moved: forge inspect gives the same layouts for identity, reputation and staking. On testnet the order is identity, then reputation, then staking once the drill ends, then a new Reader. getIdentity and getSlashProposal stay for the keeper, SDK, site and scripts. Mutations R8 and R10 follow the renamed locals. 815 forge tests, 12 of them skipped without a fork URL. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ke, not by gas CI's forge measured the identity's reads warm under isolate, so the five bounds set between the cold figures failed there: a finalize read 177,036, the old code's cost. Each test now expects standingOf and no getIdentity, which fails on the old code in any toolchain. The measured figures stay in the comments. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
The contracts' part of the minor findings (17, 18 and 19) from the 15 November performance review. Nothing is deployed by merging: each change waits for an upgrade, in the order below.
What changes
17. Slash evidence was unbounded, and
SigvaraReader.trustcopied all of it (SigvaraStaking.sol,SigvaraReader.sol)initiateSlashrefuses evidence overMAX_EVIDENCE_BYTES(256) withEvidenceTooLong. ADR 0010's evidence form is 98 bytes, and every drill and sim slash is 98 or fewer.slashState(didHash)view returns the state alone, and the Reader reads it instead of copying the whole proposal.getSlashProposalstays for the keeper, SDK, site and scripts.18.
verifyEvidencecopied its calldata proof into memory (SigvaraReputation.sol)MerkleProof.verifyCalldata, with the same verdicts (a fuzz test compares it withverifyon genuine and altered proofs).19. The registries read the whole identity record to use three fields (
SigvaraIdentity.sol,SigvaraReputation.sol,SigvaraStaking.sol)standingOf(didHash)returns operator, status and registeredAt. Reputation's_requireScorableand staking's four call sites use it;getIdentitystays.trust, slash open, 1 byte of evidencetrust, slash open, 256 bytes of evidenceverifyEvidence, 11-hash proofdepositStakeclaimWithdrawaldisputeSlashfinalizeReputationstandingOfsaves about 4,900 gas a call, not the review's 9.4k: the two fields it skips cost two cold reads and their encoding.Deploy order on Arc testnet
standingOf.0x2921b4eE879CdF5793FA273BbDc4E7dF01ABcef8keeps working throughout, and moving the SDK and site to a new one is its own step.script/Upgrade.s.solnow refuses a reputation or staking upgrade while the identity proxy cannot answerstandingOf. An upgrade through the timelock is not checked by it, so whoever schedules one keeps this order (docs/integration.mdsays so for the Reader).Checks
forge inspect storageLayoutis identical before and after for Identity, Reputation and Staking, struct members included, and the slot-pinning tests pass.check-authz.mjsandcheck-docs.mjspass. Mutations R8 and R10 point at the renamed lines.Left alone: the Reader's own identity read in
_trustandSigvaraEpochFees's two calls could usestandingOflater.🤖 Generated with Claude Code