test(evm): add storage precompile baseline#335
Merged
Conversation
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.
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.
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 usecreateGroup— a transactional write whose only precondition is a funded creator. The EOA-only guard andContract.Runsnapshot/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 viaEvmKeeper.CallEVMWithData; asserts a group is created andowner == caller.TestCreateGroup_RejectsContractForwarding— direct-callsContract.CreateGroupwithorigin != caller; pins the currentEOA-onlyguard.TestCreateGroup_FailureDoesNotMutateState— pre-creates a group, then dispatches a duplicatecreateGroup; the keeper's duplicate check (which runs before the NFT mint) fails withGroup already exists; asserts a clean revert with the existing group intact. Post-call reads use a fresh context because the failed EVM call exhaustss.ctx's gas meter.Reviewer note: control-hub account fixture
createGroupmints a group NFT via an internalCallEVMwhose sender is the group control hub (contracts.GroupControlHubAddress,0x…dead). EthSetup's trimmed genesis does not create that account, soSetupTestregisters it — otherwise the mint fails withaccount 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
go test ./x/evm/precompiles/storage -count=1→ ok.precompile-integration.