Skip to content

MNT Part 3: tests: adapt fixtures and goldens to the QKC account encoding - #50

Open
ping-ke wants to merge 2 commits into
feature/mnt-statefrom
feature/mnt-state-test-fixtures
Open

MNT Part 3: tests: adapt fixtures and goldens to the QKC account encoding#50
ping-ke wants to merge 2 commits into
feature/mnt-statefrom
feature/mnt-state-test-fixtures

Conversation

@ping-ke

@ping-ke ping-ke commented Aug 10, 2026

Copy link
Copy Markdown

Summary

  • Update trie, snapshot, snap sync, and pathdb tests for the QKC 6-element account encoding.
  • Refresh affected state root and trie hash golden values.
  • Skip upstream Ethereum fixture tests whose expected genesis, block, fork ID, or state hashes depend on the original 4-element account encoding.

Notes

This is a test-only follow-up based on feature/mnt-state. It contains no production code changes.

Carry QuarkChain multi-native-token (MNT) balances through the state
layer so accounts can hold per-token balances alongside the native
Ether balance.

- state_object_qkc.go / statedb_qkc.go: MNT balance accessors on
  stateObject and StateDB (Get/Add/Sub/Set), guarding the per-account
  token count against the MNT limit.
- journal.go: journal entries for MNT balance changes so they revert
  correctly with snapshots.
- state_object.go: deep-copy MntBalances in newObject and on copy, so
  a mutation through one object cannot leak into another.
- reader.go: decode MntBalances and FullShardKey out of the slim
  account served by the flat reader.
- database_mpt.go / database_ubt.go: re-encode AccountsOrigin from
  slim-RLP to full QKC account RLP before handing it to pathdb, which
  needs it to match the trie leaf format for history verification.
- pathdb/execute.go: decode AccountsOrigin as a full QKC StateAccount
  instead of slim-RLP, matching the invariant the commit paths now
  establish.

mnt_test.go covers the accessors, journal revert, and copy isolation.
The in-package test adaptations (state_test.go, statedb_fuzz_test.go)
follow the account encoding change.
The QKC 6-element account encoding changes every account RLP, and with
it trie node hashes, state roots, genesis hashes and derived fork IDs.
Tests outside core/state that assert upstream Ethereum golden values
need to follow.

Recomputed goldens, where the value is derived from code rather than an
external fixture:

- trie/trie_test.go: roots in TestTinyTrie, TestCommitAfterHash and
  TestCommitSequence.
- triedb/pathdb/generate_test.go, core/state/snapshot/generate_test.go:
  the generation root, plus the trie node hash TestGenerateCorruptAccountTrie
  deletes to corrupt the trie.
- core/genesis_test.go: the custom genesis hash.

Encoding-format fixes, where the test hand-rolled an account codec that
the QKC format invalidates:

- eth/protocols/snap/sync_test.go: decode into types.StateAccount so the
  QKC-aware DecodeRLP runs, instead of a local 4-field struct.
- triedb/pathdb/database_test.go: encode AccountsOrigin as full QKC
  account RLP (mustEncodeAccount) to match the trie leaf format the
  history recovery path verifies against.
- core/state/snapshot/*_test.go: build snapshot values with
  SlimAccountRLP, since the snapshot layer stores slim-RLP.

Skipped, where the expected values live in external JSON fixtures or
golden files that would have to be regenerated for the MNT layout:
tests/{state,block}_test.go, core/forkid, cmd/{evm,geth,devp2p},
eth/filters, eth/tracers supply tests, internal/ethapi and the
remaining genesis hash tests. Each skip says why.
@ping-ke ping-ke changed the title tests: adapt fixtures and goldens to the QKC account encoding MNT Part 3: tests: adapt fixtures and goldens to the QKC account encoding Aug 10, 2026
@ping-ke
ping-ke force-pushed the feature/mnt-state branch 4 times, most recently from 87ce75f to 3357d5b Compare August 14, 2026 05:35
@ping-ke
ping-ke force-pushed the feature/mnt-state branch 2 times, most recently from a3d68df to d31d1a2 Compare August 24, 2026 07:04
@ping-ke
ping-ke force-pushed the feature/mnt-state branch from d31d1a2 to a1791e3 Compare August 27, 2026 10:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant