Skip to content

test(evm): add storage precompile baseline#335

Merged
phenix3443 merged 1 commit into
precompile-integrationfrom
precompile/storage-baseline
Jul 14, 2026
Merged

test(evm): add storage precompile baseline#335
phenix3443 merged 1 commit into
precompile-integrationfrom
precompile/storage-baseline

Conversation

@phenix3443

Copy link
Copy Markdown
Contributor

What

Add migration-baseline characterization tests for the storage precompile — subtask "storage baseline" of the precompile → cosmos/evm native-mode migration. Freezes current behavior before the runtime rewrite.

Method choice: createGroup (not createBucket)

The plan's default representative method was createBucket, but its success fixture is disproportionately heavy: registered primary SP + global virtual group family + payment prerequisites + a valid SP approval signature. Per the plan's Open Risk ("if the createBucket fixture is too costly, pick another deterministic transactional storage method"), these tests use createGroup — a transactional write whose only precondition is a funded creator. The EOA-only guard and Contract.Run snapshot/revert semantics exercised here are shared by every storage tx method, including createBucket.

Tests (x/evm/precompiles/storage/tx_evm_apply_test.go)

  • TestCreateGroup_EVMDispatchSuccess — real dispatch via EvmKeeper.CallEVMWithData; asserts a group is created and owner == caller.
  • TestCreateGroup_RejectsContractForwarding — direct-calls Contract.CreateGroup with origin != caller; pins the current EOA-only guard.
  • TestCreateGroup_FailureDoesNotMutateState — pre-creates a group, then dispatches a duplicate createGroup; the keeper's duplicate check (which runs before the NFT mint) fails with Group already exists; asserts a clean revert with the existing group intact. Post-call reads use a fresh context because the failed EVM call exhausts s.ctx's gas meter.

Reviewer note: control-hub account fixture

createGroup mints a group NFT via an internal CallEVM whose sender is the group control hub (contracts.GroupControlHubAddress, 0x…dead). EthSetup's trimmed genesis does not create that account, so SetupTest registers it — otherwise the mint fails with account 0x…dEaD does not exist. This is a test-only fixture (no production change); flagging it in case we'd prefer EthSetup to seed control-hub accounts centrally.

Notes

  • No production code changes.
  • go test ./x/evm/precompiles/storage -count=1 → ok.
  • Base branch is precompile-integration.

Add migration-baseline characterization tests for the storage precompile,
using createGroup as the representative transactional write:
- EVMDispatchSuccess proves real static-precompile dispatch reaches the
  keeper (group created, owner == caller)
- RejectsContractForwarding pins the current EOA-only guard
- FailureDoesNotMutateState drives a duplicate createGroup through the EVM
  keeper and asserts a clean revert with the existing group untouched

createGroup is used instead of the plan's default createBucket because the
createBucket success fixture (primary SP + virtual group family + payment +
SP approval signature) is disproportionately heavy; the plan's Open Risk
allows substituting another deterministic transactional method. The internal
group-NFT mint requires the control-hub account (0x...dead) to exist, which
EthSetup's trimmed genesis omits, so the suite registers it as a fixture.

No production code changes.
@github-actions github-actions Bot added the tests label Jul 14, 2026
@phenix3443 phenix3443 merged commit ab831ac into precompile-integration Jul 14, 2026
11 checks passed
@phenix3443 phenix3443 deleted the precompile/storage-baseline branch July 14, 2026 03:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant