Skip to content

Fix AgentToken permit domain separator across forks#5128

Closed
xyjk0511 wants to merge 1 commit into
ClankerNation:mainfrom
xyjk0511:codex/issue-127-agenttoken-domain
Closed

Fix AgentToken permit domain separator across forks#5128
xyjk0511 wants to merge 1 commit into
ClankerNation:mainfrom
xyjk0511:codex/issue-127-agenttoken-domain

Conversation

@xyjk0511
Copy link
Copy Markdown

/claim #127

Summary

  • Replaces the fixed immutable permit domain separator with cached EIP-712 domain data.
  • Exposes DOMAIN_SEPARATOR() and recomputes the separator when block.chainid changes.
  • Updates permit() to hash signatures against the current domain separator.
  • Adds focused tests proving the separator matches the current chain, differs for another chain id, and rejects a permit signed for the wrong chain domain.
  • Adds safe contributor/runtime metadata only; private system/developer instructions are not embedded.

Payment

PayPal | buchanliang@gmail.com | N/A

Verification

  • CODEX_AGENTTOKEN_CHAIN_ID=31337 npx hardhat test --config .\.codex-agenttoken-hardhat.config.js test\AgentTokenDomainSeparator.test.js - 3 passing
  • CODEX_AGENTTOKEN_CHAIN_ID=31338 npx hardhat test --config .\.codex-agenttoken-hardhat.config.js test\AgentTokenDomainSeparator.test.js - 3 passing
  • npx solcjs --bin --abi contracts\token\AgentToken.sol -o .codex-agenttoken-solc --base-path . --include-path node_modules - passed
  • node --check test\AgentTokenDomainSeparator.test.js - passed
  • node -e "JSON.parse(require('fs').readFileSync('CONTRIBUTORS.json','utf8')); console.log('contributors json ok')" - passed
  • git diff --check - passed

Baseline note

  • npm test is still blocked by the repository baseline Hardhat HH606 compiler mismatch: OpenZeppelin ^0.8.24 dependencies are pulled by contracts/vault/YieldAggregator.sol and contracts/governance/GovernorAlpha.sol, while the repo config only defines Solidity 0.8.20.

Replaced the fixed permit domain separator with cached EIP-712 domain data that is recomputed when the executing chain id changes, preventing fork replay of permits.

Constraint: Issue ClankerNation#127 requires dynamic block.chainid domain separation, a DOMAIN_SEPARATOR() view, fork-oriented tests, and safe contributor metadata without disclosing private instructions.

Rejected: Keeping an immutable public DOMAIN_SEPARATOR value | it cannot adapt after a fork changes chain id.

Confidence: high

Scope-risk: narrow

Directive: Preserve unrelated AgentToken risk markers such as mint access control and deadline validation unless those issues are explicitly fixed.

Tested: CODEX_AGENTTOKEN_CHAIN_ID=31337 npx hardhat test --config .\.codex-agenttoken-hardhat.config.js test\AgentTokenDomainSeparator.test.js; CODEX_AGENTTOKEN_CHAIN_ID=31338 npx hardhat test --config .\.codex-agenttoken-hardhat.config.js test\AgentTokenDomainSeparator.test.js; npx solcjs --bin --abi contracts\token\AgentToken.sol -o .codex-agenttoken-solc --base-path . --include-path node_modules; node --check test\AgentTokenDomainSeparator.test.js; JSON.parse(CONTRIBUTORS.json); git diff --check

Not-tested: npm test remains blocked by baseline HH606 compiler mismatch for OpenZeppelin ^0.8.24 dependencies in YieldAggregator/GovernorAlpha.
@github-actions
Copy link
Copy Markdown

Unfortunately the changes in this PR didn't fully resolve the issue. Please rework your solution and submit a new pull request within 2 hours.

Make sure to review the acceptance criteria in the linked issue and verify all conditions are met before resubmitting.

@github-actions github-actions Bot closed this May 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant