feat: add score-gated DOS domain policy - #6
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a score-gated domain policy and a policy-controlled registrar (DOSPolicyRegistrar and DosDomainPolicy) for .dos domain registrations on the DOS Testnet, integrating EIP-712 voucher validation. It also updates the subgraph to dynamically discover and index these new registrar sources. The review feedback suggests a gas optimization in DosDomainPolicy.sol's label validation loop by skipping the first and last characters, which are already verified as alphanumeric.
| for (uint256 i; i < length; ++i) { | ||
| bytes1 character = value[i]; | ||
| if (character != "-" && !_isAlphaNumeric(character)) { | ||
| revert InvalidLabel(label); | ||
| } | ||
| } |
There was a problem hiding this comment.
The loop in _validateLabel currently iterates over the entire label length, checking every character. However, the first character (value[0]) and the last character (value[length - 1]) are already validated to be alphanumeric on line 466. We can optimize this loop to start at index 1 and end at length - 1 to avoid redundant checks and save gas on every label validation.
for (uint256 i = 1; i < length - 1; ++i) {
bytes1 character = value[i];
if (character != "-" && !_isAlphaNumeric(character)) {
revert InvalidLabel(label);
}
}
ac1e562 to
fb73205
Compare
Summary
.dosnames.Validation
forge test --match-path test/unit/registrar/DosDomainPolicy.t.sol(23 passing)forge test --match-path test/unit/registrar/ETHRegistrar.t.sol(36 passing)