Skip to content

refactor(contracts): drop the dead ERC20 test doubles; pin the storage NFT facade#314

Merged
puneet2019 merged 3 commits into
mainfrom
refactor/slim-contracts
Jul 8, 2026
Merged

refactor(contracts): drop the dead ERC20 test doubles; pin the storage NFT facade#314
puneet2019 merged 3 commits into
mainfrom
refactor/slim-contracts

Conversation

@puneet2019

@puneet2019 puneet2019 commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Part of the shrink-to-upstream campaign (#309#312). Slims contracts/ to what moca actually uses — the folder stays, matching cosmos/evm's own convention of a single top-level contracts/ package for module-consumed artifacts (their x/erc20 and x/ibc/callbacks keepers import from top-level contracts/).

Summary

Piece Action Why
4 ERC20 test doubles (MinterBurnerDecimals, Burnable, DirectBalanceManipulation, MaliciousDelayed) + .sol sources + compiled JSONs + npm manifest Delete Zero references since the x/erc20 removal (#221) — verified symbol-by-symbol repo-wide. 3 of 4 ship upstream in cosmos/evm (contracts/solidity/...) if ever needed again
ERC721NonTransferable facade + embedded artifact Stays in contracts/ (untouched; consumers untouched) Moca-specific storage-NFT facade (greenfield heritage). Caller-side ABI data — the counterpart of, not a member of, x/evm/precompiles (which are callee-side Go implementations registered at addresses)

Tests (regressions + integration)

  • New guard test (contracts/erc721NonTransferable_test.go): pins the ABI surface the storage keeper actually calls (mint(address,uint256), burn(uint256)), the six fixed token/hub addresses (protocol constants), and — surfaced by the test — that the artifact intentionally carries no bytecode: it is an ABI-only facade. Nothing deploys it and no precompile is registered at 0x…3000–3002 (verified against the static-precompile map and repo-wide); the keeper only encodes calldata against fixed addresses.
  • Existing integration coverage unchanged: x/storage/keeper tests (bucket_limit_test et al.) drive CreateBucket through the NFT mint path in-process; CI's E2E: Comprehensive exercises storage on a live chain.
  • Verified: go build ./...; go test -race over contracts/, x/storage/keeper, and the storage precompile — locally and on an amd64 box (CI's arch).

Lint wiring (had to follow the deletions)

  • Slither: target: contracts/solidity/contracts/; diff-gate **/*.solsolidity/**/*.sol; dropped the cd contracts && npm i + openzeppelin copy step (the solidity/ interfaces import no OZ — verified; and contracts/ no longer has an npm manifest).
  • solhint workflow removed with its subject: it only linted contracts/**/*.sol, all deleted here. Not retargeted to solidity/ on purpose: solidity/'s own npm run lint:sol currently fails on pre-existing natspec debt under --max-warnings 0 (verified in docker) — wiring that into CI would add a permanently red job. The team can adopt it deliberately once the debt is paid.
  • Broken lint-contracts / lint-fix-contracts Make targets removed (they invoked npm scripts that never existed).
  • Review follow-up: the entire Compile Solidity Contracts Makefile section (contracts-compile / openzeppelin / contracts-clean / create-contracts-json) is also removed — it compiled the deleted erc20 .sol sources (its own comment: "for the erc20 module") and could no longer work; worse, contracts-clean ran rm -rf contracts/compiled_contracts, which would now delete the kept ERC721 artifact (which has no in-tree source to regenerate from). The guard test now pins exact ABI signatures (mint(address,uint256), burn(uint256)) — verified to fail on a reordered signature — instead of arity only.

🤖 Generated with Claude Code

…e NFT facade

The four ERC20 test doubles (MinterBurnerDecimals, Burnable,
DirectBalanceManipulation, MaliciousDelayed) have had zero references since
the x/erc20 removal (#221); three of the four ship upstream in cosmos/evm
should they ever be needed again. Delete them with their .sol sources,
compiled artifacts, and the contracts npm manifest.

contracts/ itself stays: cosmos/evm files module-consumed artifacts under a
single top-level contracts/ package (x/erc20 and x/ibc/callbacks import from
there), and moca follows that convention. What remains is the moca-specific
ERC721NonTransferable facade the storage keeper mints/burns bucket/object/
group NFTs through — now pinned by a guard test covering the ABI surface the
keeper calls (mint/burn), the six fixed token/hub addresses, and the fact
that the artifact intentionally carries no bytecode: nothing deploys it and
no precompile serves 0x3000-3002; the keeper only encodes calldata. The
existing storage keeper tests (CreateBucket et al.) exercise the mint path
and CI's Comprehensive e2e covers storage on a live chain.

Lint wiring follows the deletions: Slither retargets contracts/ ->
solidity/contracts/ (dropping the openzeppelin npm step the interfaces never
needed), the contracts/-scoped solhint workflow is removed with its subject
(solidity/'s own lint:sol currently fails on pre-existing natspec debt under
--max-warnings 0, so wiring it into CI now would add a permanently red job),
and the broken lint-contracts Make targets are dropped.

Signed-off-by: puneetmahajan <59960662+puneet2019@users.noreply.github.com>
@puneet2019 puneet2019 force-pushed the refactor/slim-contracts branch from fac7a26 to 7ec76d4 Compare July 7, 2026 06:55
@puneet2019 puneet2019 changed the title refactor(contracts): drop dead ERC20 doubles; move the storage NFT facade into x/storage refactor(contracts): drop the dead ERC20 test doubles; pin the storage NFT facade Jul 7, 2026
@puneet2019 puneet2019 requested a review from phenix3443 July 7, 2026 09:41

@phenix3443 phenix3443 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left two follow-ups: one on the stale contracts-compile developer target, and one on the new ABI guard test not asserting the exact method signatures it says it pins. I also re-ran go test ./contracts and go test ./x/storage/keeper locally while checking these paths.

Comment thread contracts/erc721NonTransferable_test.go Outdated
Comment thread Makefile
…mpile targets

Review follow-ups (phenix):

The guard test asserted method presence and argument count only, so a
reordered signature like mint(uint256,address) would still pass while
breaking the keeper's positional CallEVM arguments. Assert the exact
signatures (mint(address,uint256), burn(uint256)) instead; verified the
reordered variant now fails the test.

Remove the whole 'Compile Solidity Contracts' Makefile section
(contracts-compile / openzeppelin / contracts-clean / create-contracts-json):
it compiled the deleted erc20 .sol sources — its own comment says 'for the
erc20 module' — and could no longer work without contracts/package.json.
Worse, contracts-clean ran rm -rf contracts/compiled_contracts, which would
now delete the kept ERC721 artifact that has no in-tree source to regenerate
from.

Signed-off-by: puneetmahajan <59960662+puneet2019@users.noreply.github.com>
…story

Make the package answer the reviewer's question where a maintainer will
actually look: the artifacts are ABI-only with no in-tree Solidity source
(and never had one — the removed compile targets only ever built the deleted
erc20 .sols), the embedded JSON is the source of truth, and changes go
through editing the JSON plus the guard test that pins signatures, addresses,
and the bytecode-less nature.

Signed-off-by: puneetmahajan <59960662+puneet2019@users.noreply.github.com>
@puneet2019 puneet2019 merged commit bc38941 into main Jul 8, 2026
29 checks passed
@puneet2019 puneet2019 deleted the refactor/slim-contracts branch July 8, 2026 04:08
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.

2 participants